HyperGraph

Используется библиотека Extended.Wpf.Toolkit для NumericUpDown. Обновлен

12/4/2020 12:41:34 AM

Changes

WPF/Common/WPF/Controls/NumericUpDown.xaml 120(+0 -120)

WPF/Common/WPF/Controls/NumericUpDown.xaml.cs 123(+0 -123)

WPF/WPF.csproj 22(+15 -7)

Details

diff --git a/WPF/Common/WPF/Style/ScrollBarStyle.xaml b/WPF/Common/WPF/Style/ScrollBarStyle.xaml
index 9faa878..0d41326 100644
--- a/WPF/Common/WPF/Style/ScrollBarStyle.xaml
+++ b/WPF/Common/WPF/Style/ScrollBarStyle.xaml
@@ -27,6 +27,32 @@
         </Setter>
     </Style>
 
+    <Style x:Key="ScrollBarLineButtonLeftStyle" TargetType="{x:Type RepeatButton}">
+        <Setter Property="Focusable" Value="False"/>
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type RepeatButton}">
+                    <Canvas Height="18">
+                        <Polygon Fill="{DynamicResource UiElementForegroundAlt}" Points="3,9 15,15 15,3"></Polygon>
+                    </Canvas>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+
+    <Style x:Key="ScrollBarLineButtonRightStyle" TargetType="{x:Type RepeatButton}">
+        <Setter Property="Focusable" Value="False"/>
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type RepeatButton}">
+                    <Canvas Height="18">
+                        <Polygon Fill="{DynamicResource UiElementForegroundAlt}" Points="3,3 3,15 15,9"></Polygon>
+                    </Canvas>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+
     <Style x:Key="ScrollBarPageButtonStyle" TargetType="{x:Type RepeatButton}">
         <Setter Property="IsTabStop" Value="False"/>
         <Setter Property="Focusable" Value="False"/>
@@ -86,4 +112,38 @@
         </Grid>
     </ControlTemplate>
 
+    <ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
+        <Grid>
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition MaxWidth="18"/>
+                <ColumnDefinition Width="0.00001*"/>
+                <ColumnDefinition MaxWidth="18"/>
+            </Grid.ColumnDefinitions>
+
+            <RepeatButton Grid.Column="0" Width="18"
+                          Style="{StaticResource ScrollBarLineButtonLeftStyle}"
+                          Command="ScrollBar.LineLeftCommand" >
+            </RepeatButton>
+            <Track Name="PART_Track" Grid.Column="1" 
+                   IsDirectionReversed="False">
+                <Track.DecreaseRepeatButton>
+                    <RepeatButton Command="ScrollBar.PageLeftCommand" Style="{StaticResource ScrollBarPageButtonStyle}">
+                    </RepeatButton>
+                </Track.DecreaseRepeatButton>
+                <Track.Thumb>
+                    <Thumb Style="{StaticResource ScrollBarThumbStyle}">
+                    </Thumb>
+                </Track.Thumb>
+                <Track.IncreaseRepeatButton>
+                    <RepeatButton Command="ScrollBar.PageRightCommand" Style="{StaticResource ScrollBarPageButtonStyle}">
+                    </RepeatButton>
+                </Track.IncreaseRepeatButton>
+            </Track>
+            <RepeatButton Grid.Column="2" Width="18"
+                          Style="{StaticResource ScrollBarLineButtonRightStyle}"
+                          Command="ScrollBar.LineRightCommand">
+            </RepeatButton>
+        </Grid>
+    </ControlTemplate>
+
 </ResourceDictionary>
\ No newline at end of file
diff --git a/WPF/packages.config b/WPF/packages.config
index 01e2767..92dd1aa 100644
--- a/WPF/packages.config
+++ b/WPF/packages.config
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
   <package id="Costura.Fody" version="4.1.0" targetFramework="net45" />
+  <package id="Extended.Wpf.Toolkit" version="4.0.1" targetFramework="net45" />
   <package id="Fody" version="6.0.0" targetFramework="net45" developmentDependency="true" />
 </packages>
\ No newline at end of file
diff --git a/WPF/View/MainWindow.xaml b/WPF/View/MainWindow.xaml
index 553a08c..33330b2 100644
--- a/WPF/View/MainWindow.xaml
+++ b/WPF/View/MainWindow.xaml
@@ -3,7 +3,9 @@
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
         xmlns:local="clr-namespace:WPF.View"
+        xmlns:viewmodel="clr-namespace:WPF.ViewModel"
         xmlns:converters="clr-namespace:Common.WPF.Converters"
         xmlns:controls="clr-namespace:Common.WPF.Controls"
         WindowStartupLocation="CenterScreen"
@@ -15,14 +17,14 @@
         ResizeMode="CanResizeWithGrip"
         AllowsTransparency="True"
         Loaded="Window_Loaded"
-        Title="Password storage" 
+        Title="{Binding TitleText}" 
         Height="450" Width="800"
         MinHeight="370" MinWidth="630"
         BorderBrush="#FF494957"
         BorderThickness="1">
     <Window.Resources>
         <Style TargetType="{x:Type ScrollBar}">
-            <Setter Property="Template" Value="{StaticResource VerticalScrollBar}"/>
+            <Setter Property="Template" Value="{StaticResource HorizontalScrollBar}"/>
         </Style>
         <Style TargetType="{x:Type Expander}" BasedOn="{StaticResource AdvancedExpander}"/>
         <Style TargetType="ToolTip">
@@ -37,6 +39,15 @@
             </Setter>
         </Style>
 
+        <Style TargetType="{x:Type xctk:DecimalUpDown}" BasedOn="{StaticResource {x:Type xctk:DecimalUpDown}}">
+            <Setter Property="FontSize" Value="18"/>
+            <Setter Property="Width" Value="50"/>
+            <Setter Property="Margin" Value="2"/>
+            <Setter Property="Background" Value="{StaticResource WindowBackground}"/>
+            <Setter Property="BorderBrush" Value="#FF494957"/>
+            <Setter Property="Foreground" Value="White"/>
+        </Style>
+
     </Window.Resources>
     <Grid>
         <Grid.RowDefinitions>
@@ -50,8 +61,7 @@
                 <ColumnDefinition Width="Auto"></ColumnDefinition>
             </Grid.ColumnDefinitions>
             <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Column="0" Margin="74,0,0,0">
-                <!--<TextBlock Text="RubezhCAD - " FontSize="18" Foreground="{StaticResource UiElementForegroundAlt}" Visibility="{Binding StandaloneApplication, Converter={StaticResource InversedBoolToVisibilityConverter}}"/>-->
-                <TextBlock Text="Password strorage"  FontSize="18" Foreground="{StaticResource Yellow}"/>
+                <TextBlock Text="{Binding TitleText}"  FontSize="18" Foreground="{StaticResource Yellow}"/>
             </StackPanel>
             <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,5,0">
                 <Button Style="{StaticResource MinimizeButton}" Width="23" Height="23"
@@ -69,10 +79,14 @@
             <Grid.RowDefinitions>
                 <RowDefinition Height="Auto"/>
                 <RowDefinition Height="Auto"/>
+                <RowDefinition Height="Auto"/>
+                <RowDefinition Height="Auto"/>
                 <RowDefinition Height="*"/>
             </Grid.RowDefinitions>
             <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="Auto"/>
+                <ColumnDefinition Width="Auto"/>
+                <ColumnDefinition Width="Auto"/>
                 <ColumnDefinition Width="*"/>
             </Grid.ColumnDefinitions>
 
@@ -83,10 +97,70 @@
                     </DataTemplate>
                 </ComboBox.ItemTemplate>
             </ComboBox>
-            <controls:NumericUpDown Grid.Row="1" Grid.Column="0" MyText="{Binding Path=TestNum, Converter={StaticResource IntToStringConverter}}">
-                
-            </controls:NumericUpDown>
-            <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding TestNum}"/>
+
+            <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding EdgesText}" Margin="2" Style="{StaticResource WhiteCaptionTextStyle}" ToolTipService.InitialShowDelay="1000">
+                <TextBlock.ToolTip>
+                    <TextBlock Text="{Binding EdgesTextTooltip}" Foreground="GhostWhite" Margin="1"/>
+                </TextBlock.ToolTip>
+            </TextBlock>
+            <xctk:DecimalUpDown Grid.Row="1" Grid.Column="2" HorizontalAlignment="Left" Value="{Binding EdgesNum}" Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}"/>
+
+            <TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding SameVertText}" Margin="2" Style="{StaticResource WhiteCaptionTextStyle}" ToolTipService.InitialShowDelay="1000">
+                <TextBlock.ToolTip>
+                    <TextBlock Text="{Binding SameVertTextTooltip}" Foreground="GhostWhite" Margin="1"/>
+                </TextBlock.ToolTip>
+            </TextBlock>
+            <xctk:DecimalUpDown Grid.Row="2" Grid.Column="2" HorizontalAlignment="Left" Value="{Binding SameVertNum}" Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}"/>
+
+            <Grid Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" Visibility="{Binding VisibilityVerticies}">
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="Auto"/>
+                    <ColumnDefinition Width="*"/>
+                </Grid.ColumnDefinitions>
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="Auto"/>
+                    <RowDefinition Height="Auto"/>
+                </Grid.RowDefinitions>
+
+                <TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding VerticiesText}" Margin="2" Style="{StaticResource WhiteCaptionTextStyle}" ToolTipService.InitialShowDelay="1000">
+                    <TextBlock.ToolTip>
+                        <TextBlock Text="{Binding VerticiesTextTooltip}" Foreground="GhostWhite" Margin="1"/>
+                    </TextBlock.ToolTip>
+                </TextBlock>
+
+                <TextBlock Grid.Row="1" Grid.Column="0" Text="{Binding VerticiesValueText}" Margin="2" Style="{StaticResource WhiteCaptionTextStyle}" ToolTipService.InitialShowDelay="1000">
+                    <TextBlock.ToolTip>
+                        <TextBlock Text="{Binding VerticiesValueTooltip}" Foreground="GhostWhite" Margin="1"/>
+                    </TextBlock.ToolTip>
+                </TextBlock>
+
+                <ScrollViewer Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden">
+                    <ItemsControl ItemsSource="{Binding Verticies}">
+                        <ItemsControl.ItemsPanel>
+                            <ItemsPanelTemplate>
+                                <StackPanel Orientation="Horizontal"/>
+                            </ItemsPanelTemplate>
+                        </ItemsControl.ItemsPanel>
+                        <ItemsControl.ItemTemplate>
+                            <DataTemplate>
+                                <Grid Margin="0">
+                                    <Grid.RowDefinitions>
+                                        <RowDefinition Height="Auto"/>
+                                        <RowDefinition Height="Auto"/>
+                                    </Grid.RowDefinitions>
+
+                                    <TextBlock Grid.Row="0" Text="{Binding VertText}" Margin="2" Style="{StaticResource WhiteCaptionTextStyle}" HorizontalAlignment="Center"/>
+                                    <xctk:DecimalUpDown Grid.Row="1" Value="{Binding Value}" Minimum="{Binding MinValue}" Maximum="{Binding Source={x:Static viewmodel:MainViewModel.MaxValue}}"/>
+
+                                </Grid>
+                            </DataTemplate>
+                        </ItemsControl.ItemTemplate>
+                    </ItemsControl>
+                </ScrollViewer>
+
+            </Grid>
+            
+            
 
         </Grid>
 
diff --git a/WPF/ViewModel/MainViewModel.cs b/WPF/ViewModel/MainViewModel.cs
index 1f32ef9..7f5ec1e 100644
--- a/WPF/ViewModel/MainViewModel.cs
+++ b/WPF/ViewModel/MainViewModel.cs
@@ -7,6 +7,7 @@ using System.Collections.ObjectModel;
 using System.IO;
 using System.Linq;
 using System.Threading.Tasks;
+using Visibility = System.Windows.Visibility;
 
 namespace WPF.ViewModel
 {
@@ -19,6 +20,7 @@ namespace WPF.ViewModel
             //CreatePanel = new CreatingViewModel(this);
             //IsAllDataHide = true;
 
+            Verticies = new ObservableCollection<VertViewModel>();
             EnumTheorems = Enum.GetValues(typeof(EnumTheorem)).Cast<EnumTheorem>().ToList();
             SelectedTheorem = EnumTheorems.First();
 
@@ -31,6 +33,9 @@ namespace WPF.ViewModel
 
         #region Поля и свойства
 
+        public static int MaxValue { get; } = 99;
+        public static int MinValue { get; } = 0;
+
         public List<EnumTheorem> EnumTheorems { get; }
 
         private EnumTheorem _selectedTheorem;
@@ -39,24 +44,62 @@ namespace WPF.ViewModel
             set
             {
                 _selectedTheorem = value;
-                OnPropertyChanged(()=> SelectedTheorem);
+                OnPropertyChanged(() => SelectedTheorem);
                 // do smth
             }
 
             get => _selectedTheorem;
         }
 
-        private int _testNum;
-        public int TestNum
+        private decimal _edgesNum;
+        public decimal EdgesNum
+        {
+            get => _edgesNum;
+            set
+            {
+                _edgesNum = value;
+                OnPropertyChanged(() => EdgesNum);
+                UpdateVerticies();
+                OnPropertyChanged(() => VisibilityVerticies);
+            }
+        }
+
+        private decimal _sameVertNum;
+        public decimal SameVertNum
         {
-            get => _testNum;
+            get => _sameVertNum;
             set
             {
-                _testNum = value;
-                OnPropertyChanged(() => TestNum);
+                _sameVertNum = value;
+                OnPropertyChanged(() => SameVertNum);
+                UpdateVerticiesValue();
+                OnPropertyChanged(() => VisibilityVerticies);
+            }
+        }
+
+        public Visibility VisibilityVerticies
+        {
+            get
+            {
+                return EdgesNum > 0 && SameVertNum > 0 ? Visibility.Visible : Visibility.Collapsed;
             }
         }
 
+        public ObservableCollection<VertViewModel> Verticies { get; }
+
+        public string EdgesText { get => "Количество ребер"; }
+        public string EdgesTextTooltip { get => "Подсказка. Количество ребер"; }
+
+        public string SameVertText { get => "Количество общих вершин"; }
+        public string SameVertTextTooltip { get => "Подсказка. Количество общих вершин"; }
+
+        public string VerticiesText { get => "Номер ребра"; }
+        public string VerticiesTextTooltip { get => "Подсказка. Номер ребра"; }
+
+        public string VerticiesValueText { get => "Число вершин"; }
+        public string VerticiesValueTooltip { get => "Подсказка. Число вершин в каждом ребре"; }
+        public string TitleText { get => "Расчет гиперграфов"; }
+
         #endregion
 
         #region Методы и команды
@@ -67,7 +110,73 @@ namespace WPF.ViewModel
             //LoadDataAsync(App.DataFilePath, true);
         }
 
+        private void UpdateVerticies()
+        {
+            if (EdgesNum > Verticies.Count)
+            {
+                for (int i = Verticies.Count; i < EdgesNum; i++)
+                    Verticies.Add(new VertViewModel(SameVertNum, (i + 1).ToString()));
+            }
+            else if (EdgesNum < Verticies.Count)
+            {
+                if (EdgesNum == 0)
+                    Verticies.Clear();
+                else
+                {
+                    var skip = Verticies.Skip((int)EdgesNum).ToList();
+                    foreach (var vert in skip)
+                    {
+                        Verticies.Remove(vert);
+                    }
+                }
+            }
+        }
+
+        private void UpdateVerticiesValue()
+        {
+            foreach (var vert in Verticies)
+            {
+                if (vert.Value < SameVertNum)
+                    vert.Value = SameVertNum;
+                vert.MinValue = SameVertNum;
+            }
+        }
+
         #endregion
 
     }
+
+    public class VertViewModel : BaseViewModel
+    {
+        public VertViewModel(decimal startValue, string text)
+        {
+            Value = startValue;
+            MinValue = startValue;
+            VertText = text;
+        }
+
+        private decimal _value;
+        public decimal Value
+        {
+            get => _value;
+            set
+            {
+                _value = value;
+                OnPropertyChanged(() => Value);
+            }
+        }
+
+        private decimal _minValue;
+        public decimal MinValue
+        {
+            get => _minValue;
+            set
+            {
+                _minValue = value;
+                OnPropertyChanged(() => MinValue);
+            }
+        }
+
+        public string VertText { get; }
+    }
 }

WPF/WPF.csproj 22(+15 -7)

diff --git a/WPF/WPF.csproj b/WPF/WPF.csproj
index 6e9af91..b112602 100644
--- a/WPF/WPF.csproj
+++ b/WPF/WPF.csproj
@@ -59,6 +59,21 @@
     <Reference Include="WindowsBase" />
     <Reference Include="PresentationCore" />
     <Reference Include="PresentationFramework" />
+    <Reference Include="Xceed.Wpf.AvalonDock, Version=4.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
+      <HintPath>..\packages\Extended.Wpf.Toolkit.4.0.1\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath>
+    </Reference>
+    <Reference Include="Xceed.Wpf.AvalonDock.Themes.Aero, Version=4.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
+      <HintPath>..\packages\Extended.Wpf.Toolkit.4.0.1\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath>
+    </Reference>
+    <Reference Include="Xceed.Wpf.AvalonDock.Themes.Metro, Version=4.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
+      <HintPath>..\packages\Extended.Wpf.Toolkit.4.0.1\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath>
+    </Reference>
+    <Reference Include="Xceed.Wpf.AvalonDock.Themes.VS2010, Version=4.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
+      <HintPath>..\packages\Extended.Wpf.Toolkit.4.0.1\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath>
+    </Reference>
+    <Reference Include="Xceed.Wpf.Toolkit, Version=4.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
+      <HintPath>..\packages\Extended.Wpf.Toolkit.4.0.1\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <ApplicationDefinition Include="App.xaml">
@@ -69,10 +84,6 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Common\WPF\Controls\NumericUpDown.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="Common\WPF\Dictionary.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
@@ -247,9 +258,6 @@
     <Compile Include="Common\WPF\Controls\TreeList\TreeList.cs" />
     <Compile Include="Common\WPF\Controls\TreeList\TreeListItem.cs" />
     <Compile Include="Common\WPF\Controls\TreeList\TreeNodeViewModel.cs" />
-    <Compile Include="Common\WPF\Controls\NumericUpDown.xaml.cs">
-      <DependentUpon>NumericUpDown.xaml</DependentUpon>
-    </Compile>
     <Compile Include="Common\WPF\Converters\BoolToVisibilityConverter.cs" />
     <Compile Include="Common\WPF\Converters\CanExpandConverter.cs" />
     <Compile Include="Common\WPF\Converters\ColorToBrushConverter.cs" />