Add listview group expander
This commit is contained in:
@@ -89,7 +89,7 @@ namespace StructureHelper.Windows.MainGraph
|
|||||||
{
|
{
|
||||||
if (Function is null)
|
if (Function is null)
|
||||||
{
|
{
|
||||||
Function = new FormulaFunction();
|
Function = new FormulaFunction(isUser: true);
|
||||||
}
|
}
|
||||||
Function.Name = Name;
|
Function.Name = Name;
|
||||||
Function.Description = Description;
|
Function.Description = Description;
|
||||||
|
|||||||
@@ -5,10 +5,13 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
|
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
|
||||||
xmlns:local="clr-namespace:StructureHelper.Windows.MainGraph"
|
xmlns:local="clr-namespace:StructureHelper.Windows.MainGraph"
|
||||||
|
Loaded="Window_Loaded"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DataContext="{d:DesignInstance local:GraphViewModel}"
|
d:DataContext="{d:DesignInstance local:GraphViewModel}"
|
||||||
Title="StructureHelper" Height="700"
|
Title="StructureHelper" Height="700"
|
||||||
Width="1000" MinHeight="400" MinWidth="600">
|
Width="1000"
|
||||||
|
MinHeight="400"
|
||||||
|
MinWidth="600">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="300"/>
|
<ColumnDefinition Width="300"/>
|
||||||
@@ -18,14 +21,15 @@
|
|||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="100"/>
|
<RowDefinition Height="100"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<ListView Grid.Row="0" Grid.Column="0" Margin="5"
|
<ListView Name="FunctionList"
|
||||||
|
Grid.Row="0" Grid.Column="0" Margin="5"
|
||||||
ItemsSource="{Binding Functions, UpdateSourceTrigger=PropertyChanged}"
|
ItemsSource="{Binding Functions, UpdateSourceTrigger=PropertyChanged}"
|
||||||
SelectedItem="{Binding SelectedFuntion, UpdateSourceTrigger=PropertyChanged}">
|
SelectedItem="{Binding SelectedFuntion, UpdateSourceTrigger=PropertyChanged}">
|
||||||
<ListView.GroupStyle>
|
<ListView.GroupStyle>
|
||||||
<GroupStyle>
|
<GroupStyle>
|
||||||
<GroupStyle.HeaderTemplate>
|
<GroupStyle.HeaderTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}"/>
|
<TextBlock Text="{Binding Name, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</GroupStyle.HeaderTemplate>
|
</GroupStyle.HeaderTemplate>
|
||||||
<GroupStyle.ContainerStyle>
|
<GroupStyle.ContainerStyle>
|
||||||
@@ -36,9 +40,15 @@
|
|||||||
<Expander IsExpanded="True">
|
<Expander IsExpanded="True">
|
||||||
<Expander.Header>
|
<Expander.Header>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Text="{Binding Name}" FontWeight="Bold" Foreground="Gray" FontSize="22" VerticalAlignment="Bottom" />
|
<TextBlock Text="{Binding Name}" FontWeight="Bold"
|
||||||
<TextBlock Text="{Binding ItemCount}" FontSize="22" Foreground="Green" FontWeight="Bold" FontStyle="Italic" Margin="10,0,0,0" VerticalAlignment="Bottom" />
|
Foreground="DarkSlateBlue"
|
||||||
<TextBlock Text=" item(s)" FontSize="22" Foreground="Silver" FontStyle="Italic" VerticalAlignment="Bottom" />
|
VerticalAlignment="Bottom"/>
|
||||||
|
<TextBlock Text=": " FontWeight="Bold"
|
||||||
|
Foreground="DarkSlateBlue"
|
||||||
|
VerticalAlignment="Bottom"/>
|
||||||
|
<TextBlock Text="{Binding ItemCount}" FontWeight="Bold"
|
||||||
|
Foreground="Gray"
|
||||||
|
VerticalAlignment="Bottom" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Expander.Header>
|
</Expander.Header>
|
||||||
<ItemsPresenter/>
|
<ItemsPresenter/>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace StructureHelper.Windows.MainGraph
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class GraphView : Window
|
public partial class GraphView : Window
|
||||||
{
|
{
|
||||||
|
private const string GROUP_FACTOR = "Group";
|
||||||
private GraphViewModel viewModel;
|
private GraphViewModel viewModel;
|
||||||
public GraphView(GraphViewModel viewModel)
|
public GraphView(GraphViewModel viewModel)
|
||||||
{
|
{
|
||||||
@@ -33,5 +34,11 @@ namespace StructureHelper.Windows.MainGraph
|
|||||||
public GraphView() : this(new GraphViewModel())
|
public GraphView() : this(new GraphViewModel())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(FunctionList.ItemsSource);
|
||||||
|
PropertyGroupDescription groupDescription = new PropertyGroupDescription(GROUP_FACTOR);
|
||||||
|
view.GroupDescriptions.Add(groupDescription);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ namespace StructureHelper.Windows.MainGraph
|
|||||||
{
|
{
|
||||||
if (Function is null)
|
if (Function is null)
|
||||||
{
|
{
|
||||||
Function = new TableFunction();
|
Function = new TableFunction(isUser: true);
|
||||||
}
|
}
|
||||||
Function.Name = Name;
|
Function.Name = Name;
|
||||||
Function.Description = Description;
|
Function.Description = Description;
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
|||||||
{
|
{
|
||||||
public interface IOneVariableFunction : ICloneable, ISaveable
|
public interface IOneVariableFunction : ICloneable, ISaveable
|
||||||
{
|
{
|
||||||
|
public const string GROUP_TYPE_1 = "System function";
|
||||||
|
public const string GROUP_TYPE_2 = "User function";
|
||||||
public bool IsUser { get; set; }
|
public bool IsUser { get; set; }
|
||||||
|
public string Group { get; set; }
|
||||||
public FunctionType Type { get; set; }
|
public FunctionType Type { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using Microsoft.VisualBasic.ApplicationServices;
|
||||||
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -13,8 +14,11 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
public class FormulaFunction : IOneVariableFunction
|
public class FormulaFunction : IOneVariableFunction
|
||||||
{
|
{
|
||||||
private const string COPY = "copy";
|
private const string COPY = "copy";
|
||||||
|
public const string GROUP_TYPE_1 = "System function";
|
||||||
|
public const string GROUP_TYPE_2 = "User function";
|
||||||
public bool IsUser { get; set; }
|
public bool IsUser { get; set; }
|
||||||
public FunctionType Type { get; set; }
|
public FunctionType Type { get; set; }
|
||||||
|
public string Group { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Description { get ; set; }
|
public string Description { get ; set; }
|
||||||
public List<GraphPoint> Table { get; set; }
|
public List<GraphPoint> Table { get; set; }
|
||||||
@@ -23,9 +27,19 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
public Guid Id => throw new NotImplementedException();
|
public Guid Id => throw new NotImplementedException();
|
||||||
|
|
||||||
public ObservableCollection<IOneVariableFunction> Functions { get; set; }
|
public ObservableCollection<IOneVariableFunction> Functions { get; set; }
|
||||||
public FormulaFunction()
|
public FormulaFunction(bool isUser = false)
|
||||||
{
|
{
|
||||||
Type = FunctionType.FormulaFunction;
|
Type = FunctionType.FormulaFunction;
|
||||||
|
if (isUser)
|
||||||
|
{
|
||||||
|
IsUser = true;
|
||||||
|
Group = GROUP_TYPE_2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IsUser = false;
|
||||||
|
Group = GROUP_TYPE_1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Check()
|
public bool Check()
|
||||||
@@ -43,6 +57,7 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
formulaFunction.Description = Description;
|
formulaFunction.Description = Description;
|
||||||
formulaFunction.Formula = Formula;
|
formulaFunction.Formula = Formula;
|
||||||
formulaFunction.IsUser = true;
|
formulaFunction.IsUser = true;
|
||||||
|
formulaFunction.Group = GROUP_TYPE_2;
|
||||||
return formulaFunction;
|
return formulaFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,14 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
public class TableFunction : IOneVariableFunction
|
public class TableFunction : IOneVariableFunction
|
||||||
{
|
{
|
||||||
private const string COPY = "copy";
|
private const string COPY = "copy";
|
||||||
|
public const string GROUP_TYPE_1 = "System function";
|
||||||
|
public const string GROUP_TYPE_2 = "User function";
|
||||||
|
|
||||||
private string name;
|
private string name;
|
||||||
|
|
||||||
public bool IsUser { get; set; }
|
public bool IsUser { get; set; }
|
||||||
public FunctionType Type { get; set; }
|
public FunctionType Type { get; set; }
|
||||||
|
public string Group { get; set; }
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get => name;
|
get => name;
|
||||||
@@ -31,9 +35,19 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
public Guid Id => throw new NotImplementedException();
|
public Guid Id => throw new NotImplementedException();
|
||||||
public ObservableCollection<IOneVariableFunction> Functions { get; set; }
|
public ObservableCollection<IOneVariableFunction> Functions { get; set; }
|
||||||
|
|
||||||
public TableFunction()
|
public TableFunction(bool isUser = false)
|
||||||
{
|
{
|
||||||
Type = FunctionType.TableFunction;
|
Type = FunctionType.TableFunction;
|
||||||
|
if (isUser)
|
||||||
|
{
|
||||||
|
IsUser = true;
|
||||||
|
Group = GROUP_TYPE_2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IsUser = false;
|
||||||
|
Group = GROUP_TYPE_1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Check()
|
public bool Check()
|
||||||
@@ -53,7 +67,7 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
Table.ForEach(x => newTable.Add(x.Clone() as GraphPoint));
|
Table.ForEach(x => newTable.Add(x.Clone() as GraphPoint));
|
||||||
tableFunction.Table = newTable;
|
tableFunction.Table = newTable;
|
||||||
tableFunction.IsUser = true;
|
tableFunction.IsUser = true;
|
||||||
|
tableFunction.Group = GROUP_TYPE_2;
|
||||||
return tableFunction;
|
return tableFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user