Skip to content

Commit c7f67ce

Browse files
Merge pull request #2 from SimpleStateMachine/StylesRefact
Styles refact
2 parents 0cf9350 + b638b35 commit c7f67ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+943
-1194
lines changed

SimpleStateMachineNodeEditor/App.xaml

Lines changed: 22 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@
77
<ResourceDictionary>
88
<ResourceDictionary.MergedDictionaries>
99
<ResourceDictionary Source="Images.xaml"/>
10-
<ResourceDictionary Source="Styles/Colors.xaml"/>
11-
<ResourceDictionary Source="Styles/ErrorList/ExpanderTemplate.xaml"/>
12-
<ResourceDictionary Source="Styles/ErrorList/TextBoxTemplate.xaml"/>
13-
<ResourceDictionary Source="Styles/ErrorList/ScrollBarTemplate.xaml"/>
14-
<ResourceDictionary Source="Styles/ErrorList/ScrollViewerTemplate.xaml"/>
10+
<ResourceDictionary Source="Styles/Themes/Dark.xaml"/>
11+
<!--<ResourceDictionary Source="Styles/Themes/Light.xaml"/>-->
12+
<!--<ResourceDictionary Source="Styles/Theme.xaml"/>-->
13+
<ResourceDictionary Source="Styles/ErrorList/StyleExpander.xaml"/>
14+
<ResourceDictionary Source="Styles/ErrorList/StyleScrollBar.xaml"/>
15+
<ResourceDictionary Source="Styles/ErrorList/StyleScrollViewer.xaml"/>
1516

16-
<ResourceDictionary Source="Styles/ErrorList/ListBoxTemplate.xaml"/>
17-
<ResourceDictionary Source="Styles/ErrorList/LabelTemplate.xaml"/>
18-
<ResourceDictionary Source="Styles/ErrorList/ListBoxItemTemplate.xaml"/>
17+
<ResourceDictionary Source="Styles/ErrorList/TemplateListBox.xaml"/>
18+
<ResourceDictionary Source="Styles/ErrorList/StyleLabel.xaml"/>
19+
<ResourceDictionary Source="Styles/ErrorList/StyleListBoxItem.xaml"/>
20+
21+
22+
1923
<!--#region Test-->
2024

2125
<!--#endregion Test-->
@@ -24,48 +28,14 @@
2428

2529
<!--#region Selector-->
2630

27-
<ResourceDictionary Source="Styles\SelectorStyle.xaml"/>
31+
<ResourceDictionary Source="Styles\StyleSelector.xaml"/>
2832

2933
<!--#endregion Selector-->
3034

3135
<!--#region Node-->
3236

33-
<!--#region LeftConnector-->
34-
35-
<!--#region LeftConnectorTextBox-->
36-
37-
<ResourceDictionary Source="Styles\Node\LeftConnector\LeftConnectorTextBoxStyle.xaml"/>
38-
39-
<!--#endregion LeftConnectorTextBox-->
40-
41-
<!--#region LeftConnectorEllipse-->
42-
43-
<ResourceDictionary Source="Styles\Node\LeftConnector\LeftConnectorEllipseStyle.xaml"/>
44-
45-
<!--#endregion LeftConnectorEllipse-->
46-
47-
<!--#endregion LeftConnector-->
48-
49-
<!--#region RightConnector-->
50-
51-
<!--#region RightConnectorTextBox-->
52-
53-
<ResourceDictionary Source="Styles\Node\RightConnector\RightConnectorTextBoxStyle.xaml"/>
54-
55-
<!--#endregion RightConnectorTextBox-->
56-
57-
<!--#region RightConnectorEllipse-->
58-
59-
<ResourceDictionary Source="Styles\Node\RightConnector\RightConnectorEllipseStyle.xaml"/>
60-
61-
<!--#endregion RightConnectorEllipse-->
62-
63-
<!--#endregion RightConnector-->
64-
65-
66-
<ResourceDictionary Source="Styles\Node\NodeBorderStyle.xaml"/>
67-
<ResourceDictionary Source="Styles\Node\NodeButtonRollUpStyle.xaml"/>
68-
<ResourceDictionary Source="Styles\Node\NodeHeaderStyle.xaml"/>
37+
<ResourceDictionary Source="Styles\Node\StyleNodeCollapseButton.xaml"/>
38+
<ResourceDictionary Source="Styles\StyleEmptyTextBox.xaml"/>
6939

7040
<!--#endregion Node-->
7141

@@ -77,29 +47,30 @@
7747
<!--#region Header-->
7848
<ResourceDictionary Source="Styles/MainWindow/ToolBar/ToolButtonTemplate.xaml"/>
7949
<ResourceDictionary Source="Styles/MainWindow/ToolBarTemplate.xaml"/>
80-
<ResourceDictionary Source="Styles/MainWindow/Header/HeaderButtonTemplate.xaml"/>
81-
50+
<ResourceDictionary Source="Styles/MainWindow/Header/StyleHeaderButton.xaml"/>
51+
<ResourceDictionary Source="Styles/MainWindow/Header/StyleHeaderButtonPath.xaml"/>
52+
<ResourceDictionary Source="Styles/MainWindow/Header/StyleHeaderButtonClosePath.xaml"/>
8253
<!--#endregion Header-->
8354

8455
<!--#endregion MainWindow-->
8556

8657
<!--#region Menu-->
8758

8859
<ResourceDictionary Source="Styles/Menu/MenuTemplate.xaml"/>
89-
<ResourceDictionary Source="Styles/Menu/MenuItemStyle.xaml"/>
60+
<ResourceDictionary Source="Styles/Menu/StyleMenuItem.xaml"/>
9061

9162
<!--#endregion Menu-->
9263

9364
<!--#region ContextMenu-->
9465

95-
<ResourceDictionary Source="Styles/ContextMenu/ContextMenuTemplate.xaml"/>
96-
<ResourceDictionary Source="Styles/ContextMenu/ContextMenuItemStyle.xaml"/>
66+
<ResourceDictionary Source="Styles/ContextMenu/TemplateContextMenu.xaml"/>
67+
<ResourceDictionary Source="Styles/ContextMenu/StyleContextMenuItem.xaml"/>
9768

9869
<!--#endregion ContextMenu-->
9970

10071
<!--#region Tabs-->
10172

102-
<ResourceDictionary Source="Styles/Tabs/TabItemTemplate.xaml"/>
73+
<ResourceDictionary Source="Styles/Tabs/StyleTabItem.xaml"/>
10374

10475
<!--#endregion Tabs-->
10576

SimpleStateMachineNodeEditor/Helpers/Commands/Command.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11

2+
using SimpleStateMachineNodeEditor.Helpers.Extensions;
23
using System;
34
using System.Windows.Input;
45

56
namespace SimpleStateMachineNodeEditor.Helpers.Commands
67
{
78

8-
public class Command<TParameter, TResult> : CommandUndoRedo, ICommand, ICloneable where TParameter : class where TResult : class
9+
public class Command<TParameter, TResult> : CommandUndoRedo, ICommand, ICloneable
910
{
1011

1112
private readonly Func<TParameter, TResult, TResult> _execute;
@@ -74,12 +75,11 @@ public bool CanExecute(object parameter)
7475
/// <param name="parameter"> Параметр команды </param>
7576
public void Execute(object parameter)
7677
{
77-
7878
//Запоминаем параметр ( чтобы можно было егоже передать в отмену)
79-
Parameters = (parameter as TParameter);
79+
Parameters = parameter.Cast<TParameter>();
8080

8181
//Выполняем команду и запоминаем результат ( чтобы можно было выполнить отмену именно для этого результата)
82-
Result = this._execute(Parameters, Result) as TResult;
82+
Result = this._execute(Parameters, Result).Cast<TResult>();
8383

8484
//Если команду можно отменить
8585
if (CanUnExecute)
@@ -92,10 +92,10 @@ public void Execute(object parameter)
9292
}
9393

9494
//Очищаем результат ( чтобы не передавать его при повторном выполнении)
95-
Result = null;
95+
Result = default(TResult);
9696

9797
//Очищаем параметр ( чтобы не передавать его при повторном выполнении)
98-
Parameters = null;
98+
Parameters = default(TParameter);
9999

100100
OnExecute?.Invoke();
101101
}

SimpleStateMachineNodeEditor/Helpers/Commands/SimpleCommandWithParameter.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using SimpleStateMachineNodeEditor.Helpers.Extensions;
2+
using System;
23
using System.Windows.Input;
34

45
namespace SimpleStateMachineNodeEditor.Helpers.Commands
@@ -7,7 +8,7 @@ namespace SimpleStateMachineNodeEditor.Helpers.Commands
78
/// Команда без Undo/Redo
89
/// </summary>
910
/// <typeparam name="TParameter"></typeparam>
10-
public class SimpleCommandWithParameter<TParameter> : ICommand where TParameter : class
11+
public class SimpleCommandWithParameter<TParameter> : ICommand
1112
{
1213
/// <summary>
1314
/// Функция с параметром, которая будет вызвана при выполнении команды
@@ -41,7 +42,9 @@ public bool CanExecute(object parameter)
4142
/// <param name="parameter"> Параметр команды </param>
4243
public void Execute(object parameter)
4344
{
44-
this._execute(parameter as TParameter);
45+
46+
this._execute(parameter.Cast<TParameter>());
47+
4548
OnExecute?.Invoke();
4649
}
4750

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace SimpleStateMachineNodeEditor.Helpers.Enums
6+
{
7+
public enum SelectMode
8+
{
9+
noCorrect = 0,
10+
Click,
11+
ClickWithCtrl,
12+
ClickWithShift
13+
}
14+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace SimpleStateMachineNodeEditor.Helpers.Extensions
6+
{
7+
public static class ObjectExtension
8+
{
9+
public static T Cast<T>(this object obj)
10+
{
11+
return (obj is T) ? (T)obj : default(T);
12+
}
13+
14+
public static bool TryCast<T>(this object obj, out T newValue)
15+
{
16+
bool typeCorrect = obj is T;
17+
18+
newValue = typeCorrect?(T)obj:default(T);
19+
20+
return typeCorrect;
21+
}
22+
}
23+
}

SimpleStateMachineNodeEditor/SimpleStateMachineNodeEditor.csproj

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,9 @@
5454
</ItemGroup>
5555

5656
<ItemGroup>
57-
<Page Update="Styles\Node\RightConnector\RightConnectorEllipseStyle.xaml">
57+
<Page Update="Styles\MainWindow\Header\StyleHeaderButtonClosePath.xaml">
5858
<SubType>Designer</SubType>
5959
</Page>
60-
<Page Update="Styles\Node\RightConnector\RightConnectorTextBoxStyle.xaml">
61-
<SubType>Designer</SubType>
62-
</Page>
63-
</ItemGroup>
64-
65-
<ItemGroup>
66-
<Folder Include="Images\" />
6760
</ItemGroup>
6861

6962
</Project>

0 commit comments

Comments
 (0)