Skip to content

Commit 28d38dd

Browse files
committed
for messages
1 parent 551cd0a commit 28d38dd

12 files changed

Lines changed: 181 additions & 73 deletions

SimpleStateMachineNodeEditor/App.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
<ResourceDictionary Source="Styles/ErrorList/ScrollViewerTemplate.xaml"/>
1414
<ResourceDictionary Source="Styles/ErrorList/ScrollBarTemplate.xaml"/>
1515
<ResourceDictionary Source="Styles/ErrorList/ListBoxTemplate.xaml"/>
16-
16+
<ResourceDictionary Source="Styles/ErrorList/ListBoxItemTemplate.xaml"/>
17+
<ResourceDictionary Source="Styles/ErrorList/LabelTemplate.xaml"/>
1718
<!--#region Test-->
1819

1920
<!--#endregion Test-->
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:local="clr-namespace:SimpleStateMachineNodeEditor.Styles.ErrorList">
4+
5+
<Style x:Key="LabelTemplate" TargetType="{x:Type Label}">
6+
<Setter Property="Padding" Value="0"/>
7+
<Setter Property="HorizontalContentAlignment" Value="Left"/>
8+
<Setter Property="VerticalContentAlignment" Value="Top"/>
9+
<Setter Property="Foreground" Value="LightGray"/>
10+
11+
<Setter Property="Template">
12+
<Setter.Value>
13+
<ControlTemplate TargetType="{x:Type Label}">
14+
<Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
15+
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
16+
</Border>
17+
<ControlTemplate.Triggers>
18+
<Trigger Property="IsMouseOver" Value="true">
19+
<Setter Property="Foreground" Value="#007acc"/>
20+
</Trigger>
21+
</ControlTemplate.Triggers>
22+
</ControlTemplate>
23+
</Setter.Value>
24+
</Setter>
25+
</Style>
26+
</ResourceDictionary>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:local="clr-namespace:SimpleStateMachineNodeEditor.Styles.ErrorList">
4+
<Style x:Key="_ListBoxItemStyle" TargetType="ListBoxItem">
5+
<Setter Property="Template">
6+
<Setter.Value>
7+
<ControlTemplate TargetType="ListBoxItem">
8+
<Border Name="Border" SnapsToDevicePixels="true">
9+
<ContentPresenter />
10+
</Border>
11+
<ControlTemplate.Triggers>
12+
<Trigger Property="IsSelected" Value="true">
13+
<Setter TargetName="Border" Property="Background" Value="{DynamicResource ColorHeaderButtonIsPressed}"/>
14+
</Trigger>
15+
</ControlTemplate.Triggers>
16+
</ControlTemplate>
17+
</Setter.Value>
18+
</Setter>
19+
</Style>
20+
</ResourceDictionary>
Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:local="clr-namespace:SimpleStateMachineNodeEditor.Styles.ErrorList">
4-
5-
<SolidColorBrush x:Key="ListBox.Disabled.Background" Color="#FFFFFFFF"/>
6-
<SolidColorBrush x:Key="ListBox.Disabled.Border" Color="#FFD9D9D9"/>
4+
75
<ControlTemplate x:Key="ListBoxTemplate" TargetType="{x:Type ListBox}">
86
<Border x:Name="Bd" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Padding="1" SnapsToDevicePixels="true">
9-
<ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}">
7+
<ScrollViewer Padding="{TemplateBinding Padding}" Focusable="false" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Style="{DynamicResource ScrollViewerTemplate}" >
108
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
119
</ScrollViewer>
1210
</Border>
13-
<ControlTemplate.Triggers>
14-
<Trigger Property="IsEnabled" Value="false">
15-
<Setter Property="Background" TargetName="Bd" Value="{StaticResource ListBox.Disabled.Background}"/>
16-
<Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource ListBox.Disabled.Border}"/>
17-
</Trigger>
18-
<MultiTrigger>
19-
<MultiTrigger.Conditions>
20-
<Condition Property="IsGrouping" Value="true"/>
21-
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
22-
</MultiTrigger.Conditions>
23-
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
24-
</MultiTrigger>
25-
</ControlTemplate.Triggers>
2611
</ControlTemplate>
12+
2713
</ResourceDictionary>

SimpleStateMachineNodeEditor/View/MainWindow.xaml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@
9999
<GridSplitter Grid.Row="3" x:Name="ErrorListSplitter" HorizontalAlignment="Stretch" Background="{DynamicResource ColorWindowHeader}" Height="3" ShowsPreview="False" IsEnabled="False"/>
100100
<Expander Style="{DynamicResource ExpanderTemplate}" x:Name="ErrorListExpander" Grid.Row="4" HorizontalContentAlignment="Stretch" ExpandDirection="Up" OpacityMask="#FFB34F4F" Margin="3,0,0,0" >
101101
<Expander.Header>
102-
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="White" >Error List</TextBlock>
102+
<!--<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="White" >Error List</TextBlock>-->
103+
<Label Style="{DynamicResource LabelTemplate}" HorizontalAlignment="Left" VerticalAlignment="Top">Error List</Label>
103104
</Expander.Header>
104105
<Expander.Content>
105-
<ListBox x:Name="ErrorList" Template="{DynamicResource ListBoxTemplate}" Style="{DynamicResource ListBoxStyle}">
106+
<ListBox x:Name="MessageList" Template="{DynamicResource ListBoxTemplate}" Style="{DynamicResource ListBoxStyle}" Background="#2a2a2c" BorderBrush="{DynamicResource ColorMenuBorder}" Foreground="AliceBlue" ItemContainerStyle="{DynamicResource _ListBoxItemStyle}">
106107
<ListBox.InputBindings>
107108
<KeyBinding x:Name="BindingCopyError" Key="C" Modifiers="Control" />
108109
</ListBox.InputBindings>
@@ -111,22 +112,11 @@
111112
<MenuItem Header="Copy" x:Name="ItemCopyError" InputGestureText="Ctrl + C" Style="{DynamicResource ContextMenuItemStyle}" />
112113
</ContextMenu>
113114
</ListBox.ContextMenu>
114-
<sys1:String>Lumia 950</sys1:String>
115-
<sys1:String>iPhone 6S Plus</sys1:String>
116-
<sys1:String>Xiaomi Mi5</sys1:String>
117-
<sys1:String>Nexus 5X</sys1:String>
118-
<sys1:String>Lumia 950</sys1:String>
119-
<sys1:String>iPhone 6S Plus</sys1:String>
120-
<sys1:String>Xiaomi Mi5</sys1:String>
121-
<sys1:String>Nexus 5X</sys1:String>
122-
<sys1:String>Lumia 950</sys1:String>
123-
<sys1:String>iPhone 6S Plus</sys1:String>
124-
<sys1:String>Xiaomi Mi5</sys1:String>
125-
<sys1:String>Nexus 5X</sys1:String>
126-
<sys1:String>Lumia 950</sys1:String>
127-
<sys1:String>iPhone 6S Plus</sys1:String>
128-
<sys1:String>Xiaomi Mi5</sys1:String>
129-
<sys1:String>Nexus 5X</sys1:String>
115+
<ListBox.ItemTemplate>
116+
<DataTemplate>
117+
<view:ViewMessage ViewModel="{Binding}" />
118+
</DataTemplate>
119+
</ListBox.ItemTemplate>
130120
</ListBox>
131121
<!--<TextBox x:Name="ErrorList" Style="{DynamicResource TextBoxTemplate}" BorderBrush="{DynamicResource ColorMenuBorder}"
132122
IsReadOnly="True" TextWrapping="NoWrap" Background="#2a2a2c"

SimpleStateMachineNodeEditor/View/MainWindow.xaml.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ object IViewFor.ViewModel
4848
public MainWindow()
4949
{
5050
InitializeComponent();
51-
ViewModel = new ViewModelMainWindow();
51+
ViewModel = new ViewModelMainWindow();
5252
SetupBinding();
5353
SetupEvents();
5454
SetupCommands();
@@ -60,9 +60,12 @@ private void SetupBinding()
6060
{
6161
this.WhenActivated(disposable =>
6262
{
63-
var SelectedItem = this.ObservableForProperty(x => x.ErrorList.SelectedItem).Select(x => x.Value);
63+
this.ViewModel.NodesCanvas = this.NodesCanvas.ViewModel;
64+
var SelectedItem = this.ObservableForProperty(x => x.MessageList.SelectedItem).Select(x=>(x.Value as ViewModelMessage)?.Text);
6465
this.BindCommand(this.ViewModel,x=>x.CommandCopyError, x=>x.BindingCopyError, SelectedItem).DisposeWith(disposable);
6566
this.BindCommand(this.ViewModel, x => x.CommandCopyError, x => x.ItemCopyError, SelectedItem).DisposeWith(disposable);
67+
68+
this.OneWayBind(this.ViewModel, x=>x.Messages, x=>x.MessageList.ItemsSource).DisposeWith(disposable);
6669
});
6770
}
6871
#endregion SetupBinding
@@ -109,12 +112,8 @@ void ErrorListCollapse()
109112
void ErrorListExpanded()
110113
{
111114
this.ErrorListSplitter.IsEnabled = true;
112-
double maxHeight = 150;
113-
if(this.ErrorList.Items.Count>5)
114-
this.Fotter.Height = new GridLength(maxHeight);
115-
//if (this.ErrorList.ExtentHeight > maxHeight)
116-
// this.Fotter.Height = new GridLength(maxHeight);
117-
//this.NodesCanvas.ViewModel.Errors.Add("Add line " + this.NodesCanvas.ViewModel.Errors.Count.ToString());
115+
if(this.MessageList.Items.Count>this.ViewModel.CountShowingMessage)
116+
this.Fotter.Height = new GridLength(this.ViewModel.MaxHeightMessagePanel);
118117
}
119118
void StateNormalMaximaze()
120119
{
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<UserControl x:Class="SimpleStateMachineNodeEditor.View.ViewMessage"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:SimpleStateMachineNodeEditor.View"
7+
mc:Ignorable="d"
8+
d:DesignHeight="450" d:DesignWidth="800">
9+
<TextBlock x:Name="TextBlock" Height="auto" VerticalAlignment="Top" TextWrapping="Wrap" Foreground="White" />
10+
11+
12+
</UserControl>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System.Reactive.Disposables;
2+
using System.Windows;
3+
using System.Windows.Controls;
4+
using System.Windows.Input;
5+
using ReactiveUI;
6+
using System;
7+
using System.Windows.Data;
8+
using System.Windows.Documents;
9+
using System.Windows.Media;
10+
using System.Windows.Media.Imaging;
11+
using System.Windows.Navigation;
12+
using System.Windows.Controls.Primitives;
13+
using System.Reactive.Linq;
14+
using System.Windows.Markup;
15+
using SimpleStateMachineNodeEditor.ViewModel;
16+
using SimpleStateMachineNodeEditor.Helpers;
17+
18+
namespace SimpleStateMachineNodeEditor.View
19+
{
20+
/// <summary>
21+
/// Interaction logic for ViewError.xaml
22+
/// </summary>
23+
public partial class ViewMessage : UserControl, IViewFor<ViewModelMessage>
24+
{
25+
#region ViewModel
26+
public static readonly DependencyProperty ViewModelProperty = DependencyProperty.Register(nameof(ViewModel), typeof(ViewModelMessage), typeof(ViewMessage), new PropertyMetadata(null));
27+
28+
public ViewModelMessage ViewModel
29+
{
30+
get { return (ViewModelMessage)GetValue(ViewModelProperty); }
31+
set { SetValue(ViewModelProperty, value); }
32+
}
33+
34+
object IViewFor.ViewModel
35+
{
36+
get { return ViewModel; }
37+
set { ViewModel = (ViewModelMessage)value; }
38+
}
39+
#endregion ViewModel
40+
public ViewMessage()
41+
{
42+
InitializeComponent();
43+
SetupBinding();
44+
}
45+
#region SetupBinding
46+
private void SetupBinding()
47+
{
48+
this.WhenActivated(disposable =>
49+
{
50+
this.OneWayBind(this.ViewModel, x => x.Text, x => x.TextBlock.Text).DisposeWith(disposable);
51+
});
52+
}
53+
#endregion SetupBinding
54+
}
55+
}

SimpleStateMachineNodeEditor/ViewModel/ViewModelMainWindow.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using ReactiveUI;
1+
using DynamicData.Binding;
2+
using ReactiveUI;
3+
using ReactiveUI.Fody.Helpers;
24
using SimpleStateMachineNodeEditor.Helpers.Commands;
35
using System;
46
using System.Collections.Generic;
@@ -9,6 +11,15 @@ namespace SimpleStateMachineNodeEditor.ViewModel
911
{
1012
public class ViewModelMainWindow: ReactiveObject
1113
{
14+
public IObservableCollection<ViewModelMessage> Messages { get { return NodesCanvas.Messages; } }
15+
16+
[Reactive] public ViewModelNodesCanvas NodesCanvas { get; set; }
17+
18+
19+
public double MaxHeightMessagePanel = 150;
20+
21+
public int CountShowingMessage = 5;
22+
1223
public ViewModelMainWindow()
1324
{
1425
SetupCommands();
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Windows;
3+
using System.Reactive.Linq;
4+
5+
using ReactiveUI;
6+
using ReactiveUI.Fody.Helpers;
7+
8+
using SimpleStateMachineNodeEditor.Helpers;
9+
using SimpleStateMachineNodeEditor.Helpers.Commands;
10+
using SimpleStateMachineNodeEditor.Helpers.Transformations;
11+
12+
namespace SimpleStateMachineNodeEditor.ViewModel
13+
{
14+
public class ViewModelMessage : ReactiveObject
15+
{
16+
[Reactive] public string Text { get; set; }
17+
public ViewModelMessage(string text)
18+
{
19+
Text = text;
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)