Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 22 additions & 51 deletions SimpleStateMachineNodeEditor/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Images.xaml"/>
<ResourceDictionary Source="Styles/Colors.xaml"/>
<ResourceDictionary Source="Styles/ErrorList/ExpanderTemplate.xaml"/>
<ResourceDictionary Source="Styles/ErrorList/TextBoxTemplate.xaml"/>
<ResourceDictionary Source="Styles/ErrorList/ScrollBarTemplate.xaml"/>
<ResourceDictionary Source="Styles/ErrorList/ScrollViewerTemplate.xaml"/>
<ResourceDictionary Source="Styles/Themes/Dark.xaml"/>
<!--<ResourceDictionary Source="Styles/Themes/Light.xaml"/>-->
<!--<ResourceDictionary Source="Styles/Theme.xaml"/>-->
<ResourceDictionary Source="Styles/ErrorList/StyleExpander.xaml"/>
<ResourceDictionary Source="Styles/ErrorList/StyleScrollBar.xaml"/>
<ResourceDictionary Source="Styles/ErrorList/StyleScrollViewer.xaml"/>

<ResourceDictionary Source="Styles/ErrorList/ListBoxTemplate.xaml"/>
<ResourceDictionary Source="Styles/ErrorList/LabelTemplate.xaml"/>
<ResourceDictionary Source="Styles/ErrorList/ListBoxItemTemplate.xaml"/>
<ResourceDictionary Source="Styles/ErrorList/TemplateListBox.xaml"/>
<ResourceDictionary Source="Styles/ErrorList/StyleLabel.xaml"/>
<ResourceDictionary Source="Styles/ErrorList/StyleListBoxItem.xaml"/>



<!--#region Test-->

<!--#endregion Test-->
Expand All @@ -24,48 +28,14 @@

<!--#region Selector-->

<ResourceDictionary Source="Styles\SelectorStyle.xaml"/>
<ResourceDictionary Source="Styles\StyleSelector.xaml"/>

<!--#endregion Selector-->

<!--#region Node-->

<!--#region LeftConnector-->

<!--#region LeftConnectorTextBox-->

<ResourceDictionary Source="Styles\Node\LeftConnector\LeftConnectorTextBoxStyle.xaml"/>

<!--#endregion LeftConnectorTextBox-->

<!--#region LeftConnectorEllipse-->

<ResourceDictionary Source="Styles\Node\LeftConnector\LeftConnectorEllipseStyle.xaml"/>

<!--#endregion LeftConnectorEllipse-->

<!--#endregion LeftConnector-->

<!--#region RightConnector-->

<!--#region RightConnectorTextBox-->

<ResourceDictionary Source="Styles\Node\RightConnector\RightConnectorTextBoxStyle.xaml"/>

<!--#endregion RightConnectorTextBox-->

<!--#region RightConnectorEllipse-->

<ResourceDictionary Source="Styles\Node\RightConnector\RightConnectorEllipseStyle.xaml"/>

<!--#endregion RightConnectorEllipse-->

<!--#endregion RightConnector-->


<ResourceDictionary Source="Styles\Node\NodeBorderStyle.xaml"/>
<ResourceDictionary Source="Styles\Node\NodeButtonRollUpStyle.xaml"/>
<ResourceDictionary Source="Styles\Node\NodeHeaderStyle.xaml"/>
<ResourceDictionary Source="Styles\Node\StyleNodeCollapseButton.xaml"/>
<ResourceDictionary Source="Styles\StyleEmptyTextBox.xaml"/>

<!--#endregion Node-->

Expand All @@ -77,29 +47,30 @@
<!--#region Header-->
<ResourceDictionary Source="Styles/MainWindow/ToolBar/ToolButtonTemplate.xaml"/>
<ResourceDictionary Source="Styles/MainWindow/ToolBarTemplate.xaml"/>
<ResourceDictionary Source="Styles/MainWindow/Header/HeaderButtonTemplate.xaml"/>

<ResourceDictionary Source="Styles/MainWindow/Header/StyleHeaderButton.xaml"/>
<ResourceDictionary Source="Styles/MainWindow/Header/StyleHeaderButtonPath.xaml"/>
<ResourceDictionary Source="Styles/MainWindow/Header/StyleHeaderButtonClosePath.xaml"/>
<!--#endregion Header-->

<!--#endregion MainWindow-->

<!--#region Menu-->

<ResourceDictionary Source="Styles/Menu/MenuTemplate.xaml"/>
<ResourceDictionary Source="Styles/Menu/MenuItemStyle.xaml"/>
<ResourceDictionary Source="Styles/Menu/StyleMenuItem.xaml"/>

<!--#endregion Menu-->

<!--#region ContextMenu-->

<ResourceDictionary Source="Styles/ContextMenu/ContextMenuTemplate.xaml"/>
<ResourceDictionary Source="Styles/ContextMenu/ContextMenuItemStyle.xaml"/>
<ResourceDictionary Source="Styles/ContextMenu/TemplateContextMenu.xaml"/>
<ResourceDictionary Source="Styles/ContextMenu/StyleContextMenuItem.xaml"/>

<!--#endregion ContextMenu-->

<!--#region Tabs-->

<ResourceDictionary Source="Styles/Tabs/TabItemTemplate.xaml"/>
<ResourceDictionary Source="Styles/Tabs/StyleTabItem.xaml"/>

<!--#endregion Tabs-->

Expand Down
12 changes: 6 additions & 6 deletions SimpleStateMachineNodeEditor/Helpers/Commands/Command.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

using SimpleStateMachineNodeEditor.Helpers.Extensions;
using System;
using System.Windows.Input;

namespace SimpleStateMachineNodeEditor.Helpers.Commands
{

public class Command<TParameter, TResult> : CommandUndoRedo, ICommand, ICloneable where TParameter : class where TResult : class
public class Command<TParameter, TResult> : CommandUndoRedo, ICommand, ICloneable
{

private readonly Func<TParameter, TResult, TResult> _execute;
Expand Down Expand Up @@ -74,12 +75,11 @@ public bool CanExecute(object parameter)
/// <param name="parameter"> Параметр команды </param>
public void Execute(object parameter)
{

//Запоминаем параметр ( чтобы можно было егоже передать в отмену)
Parameters = (parameter as TParameter);
Parameters = parameter.Cast<TParameter>();

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

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

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

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

OnExecute?.Invoke();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using SimpleStateMachineNodeEditor.Helpers.Extensions;
using System;
using System.Windows.Input;

namespace SimpleStateMachineNodeEditor.Helpers.Commands
Expand All @@ -7,7 +8,7 @@ namespace SimpleStateMachineNodeEditor.Helpers.Commands
/// Команда без Undo/Redo
/// </summary>
/// <typeparam name="TParameter"></typeparam>
public class SimpleCommandWithParameter<TParameter> : ICommand where TParameter : class
public class SimpleCommandWithParameter<TParameter> : ICommand
{
/// <summary>
/// Функция с параметром, которая будет вызвана при выполнении команды
Expand Down Expand Up @@ -41,7 +42,9 @@ public bool CanExecute(object parameter)
/// <param name="parameter"> Параметр команды </param>
public void Execute(object parameter)
{
this._execute(parameter as TParameter);

this._execute(parameter.Cast<TParameter>());

OnExecute?.Invoke();
}

Expand Down
14 changes: 14 additions & 0 deletions SimpleStateMachineNodeEditor/Helpers/Enums/SelectMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace SimpleStateMachineNodeEditor.Helpers.Enums
{
public enum SelectMode
{
noCorrect = 0,
Click,
ClickWithCtrl,
ClickWithShift
}
}
23 changes: 23 additions & 0 deletions SimpleStateMachineNodeEditor/Helpers/Extensions/ObjectExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace SimpleStateMachineNodeEditor.Helpers.Extensions
{
public static class ObjectExtension
{
public static T Cast<T>(this object obj)
{
return (obj is T) ? (T)obj : default(T);
}

public static bool TryCast<T>(this object obj, out T newValue)
{
bool typeCorrect = obj is T;

newValue = typeCorrect?(T)obj:default(T);

return typeCorrect;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,9 @@
</ItemGroup>

<ItemGroup>
<Page Update="Styles\Node\RightConnector\RightConnectorEllipseStyle.xaml">
<Page Update="Styles\MainWindow\Header\StyleHeaderButtonClosePath.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Styles\Node\RightConnector\RightConnectorTextBoxStyle.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>

<ItemGroup>
<Folder Include="Images\" />
</ItemGroup>

</Project>
Loading