diff --git a/SimpleStateMachineNodeEditor.sln b/SimpleStateMachineNodeEditor.sln index eae3017..390760d 100644 --- a/SimpleStateMachineNodeEditor.sln +++ b/SimpleStateMachineNodeEditor.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.29728.190 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleStateMachineNodeEditor", "SimpleStateMachineNodeEditor\SimpleStateMachineNodeEditor.csproj", "{F405DC54-B579-44A4-B414-3925A236A98D}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleStateMachineNodeEditorAvalonia", "SimpleStateMachineNodeEditorAvalonia\SimpleStateMachineNodeEditorAvalonia.csproj", "{DDB33469-E9BF-4BD7-A4C5-61EEB0CB5881}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {F405DC54-B579-44A4-B414-3925A236A98D}.Debug|Any CPU.Build.0 = Debug|Any CPU {F405DC54-B579-44A4-B414-3925A236A98D}.Release|Any CPU.ActiveCfg = Release|Any CPU {F405DC54-B579-44A4-B414-3925A236A98D}.Release|Any CPU.Build.0 = Release|Any CPU + {DDB33469-E9BF-4BD7-A4C5-61EEB0CB5881}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DDB33469-E9BF-4BD7-A4C5-61EEB0CB5881}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DDB33469-E9BF-4BD7-A4C5-61EEB0CB5881}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DDB33469-E9BF-4BD7-A4C5-61EEB0CB5881}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SimpleStateMachineNodeEditor/App.xaml b/SimpleStateMachineNodeEditor/App.xaml index 86f8570..b1cfd93 100644 --- a/SimpleStateMachineNodeEditor/App.xaml +++ b/SimpleStateMachineNodeEditor/App.xaml @@ -1,7 +1,6 @@  diff --git a/SimpleStateMachineNodeEditor/Dictionary1.xaml b/SimpleStateMachineNodeEditor/Dictionary1.xaml index e423de9..825650e 100644 --- a/SimpleStateMachineNodeEditor/Dictionary1.xaml +++ b/SimpleStateMachineNodeEditor/Dictionary1.xaml @@ -1,5 +1,4 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> \ No newline at end of file diff --git a/SimpleStateMachineNodeEditor/Helpers/Commands/Command.cs b/SimpleStateMachineNodeEditor/Helpers/Commands/Command.cs index 4169445..605e6f5 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Commands/Command.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Commands/Command.cs @@ -15,8 +15,8 @@ public object Clone() { return new Command(_execute, _unExecute, OnExecute) { - Parameters = this.Parameters, - Result = this.Result + Parameters = Parameters, + Result = Result }; } @@ -36,9 +36,9 @@ public void Execute(object parameter = default) { Parameters = parameter.Cast(); - Result = this._execute(Parameters, Result).Cast(); + Result = _execute(Parameters, Result).Cast(); - ICommandWithUndoRedo.AddInUndo(this.Clone() as ICommandWithUndoRedo); + ICommandWithUndoRedo.AddInUndo(Clone() as ICommandWithUndoRedo); ICommandWithUndoRedo.StackRedo.Clear(); @@ -51,16 +51,16 @@ public void Execute(object parameter = default) void ICommandWithUndoRedo.ExecuteWithSubscribe() { - this.Result = this._execute(this.Parameters, this.Result); + Result = _execute(Parameters, Result); - ICommandWithUndoRedo.AddInUndo(this.Clone() as ICommandWithUndoRedo); + ICommandWithUndoRedo.AddInUndo(Clone() as ICommandWithUndoRedo); } void ICommandWithUndoRedo.UnExecute() { - this._unExecute(Parameters, Result); + _unExecute(Parameters, Result); - ICommandWithUndoRedo.AddInRedo(this.Clone() as ICommandWithUndoRedo); + ICommandWithUndoRedo.AddInRedo(Clone() as ICommandWithUndoRedo); } public Command(Func ExecuteWithSubscribe, Func unExecute, Action onExecute = null) diff --git a/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationProvider.cs b/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationProvider.cs index be17ef1..e0a1596 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationProvider.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationProvider.cs @@ -14,7 +14,7 @@ public WritableJsonConfigurationProvider(JsonConfigurationSource source) : base( private void Save(dynamic jsonObj) { - var fileFullPath = base.Source.FileProvider.GetFileInfo(base.Source.Path).PhysicalPath; + var fileFullPath = Source.FileProvider.GetFileInfo(Source.Path).PhysicalPath; string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(fileFullPath, output); } @@ -45,7 +45,7 @@ private void SetValue(string key, string value, dynamic jsonObj) private dynamic GetJsonObj() { - var fileFullPath = base.Source.FileProvider.GetFileInfo(base.Source.Path).PhysicalPath; + var fileFullPath = Source.FileProvider.GetFileInfo(Source.Path).PhysicalPath; var json = File.Exists(fileFullPath) ? File.ReadAllText(fileFullPath) : "{}"; return JsonConvert.DeserializeObject(json); } diff --git a/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationSource.cs b/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationSource.cs index fdd871d..dbf6ec4 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationSource.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationSource.cs @@ -7,7 +7,7 @@ public class WritableJsonConfigurationSource : JsonConfigurationSource { public override IConfigurationProvider Build(IConfigurationBuilder builder) { - this.EnsureDefaults(builder); + EnsureDefaults(builder); return (IConfigurationProvider)new WritableJsonConfigurationProvider(this); } } diff --git a/SimpleStateMachineNodeEditor/Helpers/Converters/InverseBooleanConverter.cs b/SimpleStateMachineNodeEditor/Helpers/Converters/InverseBooleanConverter.cs index 9d53bcc..440e51f 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Converters/InverseBooleanConverter.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Converters/InverseBooleanConverter.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Windows.Data; namespace SimpleStateMachineNodeEditor.Helpers.Converters diff --git a/SimpleStateMachineNodeEditor/Helpers/Enums/DeleteMode.cs b/SimpleStateMachineNodeEditor/Helpers/Enums/DeleteMode.cs index 3a631bb..0c7c63d 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Enums/DeleteMode.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Enums/DeleteMode.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SimpleStateMachineNodeEditor.Helpers.Enums +namespace SimpleStateMachineNodeEditor.Helpers.Enums { public enum DeleteMode { diff --git a/SimpleStateMachineNodeEditor/Helpers/Enums/ImageFormats.cs b/SimpleStateMachineNodeEditor/Helpers/Enums/ImageFormats.cs index 72fe9f0..d37d60b 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Enums/ImageFormats.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Enums/ImageFormats.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SimpleStateMachineNodeEditor.Helpers.Enums +namespace SimpleStateMachineNodeEditor.Helpers.Enums { public enum ImageFormats { diff --git a/SimpleStateMachineNodeEditor/Helpers/Enums/NodeCanvasClickMode.cs b/SimpleStateMachineNodeEditor/Helpers/Enums/NodeCanvasClickMode.cs index ac3163e..0c178e5 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Enums/NodeCanvasClickMode.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Enums/NodeCanvasClickMode.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SimpleStateMachineNodeEditor.Helpers.Enums +namespace SimpleStateMachineNodeEditor.Helpers.Enums { public enum NodeCanvasClickMode { diff --git a/SimpleStateMachineNodeEditor/Helpers/Enums/SelectMode.cs b/SimpleStateMachineNodeEditor/Helpers/Enums/SelectMode.cs index f6fd920..04acde4 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Enums/SelectMode.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Enums/SelectMode.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SimpleStateMachineNodeEditor.Helpers.Enums +namespace SimpleStateMachineNodeEditor.Helpers.Enums { public enum SelectMode { diff --git a/SimpleStateMachineNodeEditor/Helpers/Enums/Themes.cs b/SimpleStateMachineNodeEditor/Helpers/Enums/Themes.cs index 0bdf17b..3cbb384 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Enums/Themes.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Enums/Themes.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SimpleStateMachineNodeEditor.Helpers.Enums +namespace SimpleStateMachineNodeEditor.Helpers.Enums { public enum Themes { diff --git a/SimpleStateMachineNodeEditor/Helpers/Enums/TypeMessage.cs b/SimpleStateMachineNodeEditor/Helpers/Enums/TypeMessage.cs index cbdf14e..fdb66a6 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Enums/TypeMessage.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Enums/TypeMessage.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; - -namespace SimpleStateMachineNodeEditor.Helpers.Enums +namespace SimpleStateMachineNodeEditor.Helpers.Enums { public enum TypeMessage { diff --git a/SimpleStateMachineNodeEditor/Helpers/Enums/TypeMove.cs b/SimpleStateMachineNodeEditor/Helpers/Enums/TypeMove.cs index 313bbe3..6f5a276 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Enums/TypeMove.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Enums/TypeMove.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SimpleStateMachineNodeEditor.Helpers.Enums +namespace SimpleStateMachineNodeEditor.Helpers.Enums { public enum TypeMove { diff --git a/SimpleStateMachineNodeEditor/Helpers/Extensions/EnumExtension.cs b/SimpleStateMachineNodeEditor/Helpers/Extensions/EnumExtension.cs index 1d5792b..8bf72aa 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Extensions/EnumExtension.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Extensions/EnumExtension.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace SimpleStateMachineNodeEditor.Helpers.Extensions { diff --git a/SimpleStateMachineNodeEditor/Helpers/Extensions/FileDialogResultExtension.cs b/SimpleStateMachineNodeEditor/Helpers/Extensions/FileDialogResultExtension.cs index 44d29c3..6198e8a 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Extensions/FileDialogResultExtension.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Extensions/FileDialogResultExtension.cs @@ -8,14 +8,14 @@ public static Enums.DialogResult ToDialogResult(this System.Windows.Forms.Dialog { return fileDialogResult switch { - System.Windows.Forms.DialogResult.Yes => Helpers.Enums.DialogResult.Yes, - System.Windows.Forms.DialogResult.No => Helpers.Enums.DialogResult.No, - System.Windows.Forms.DialogResult.OK => Helpers.Enums.DialogResult.Ok, - System.Windows.Forms.DialogResult.Cancel => Helpers.Enums.DialogResult.Cancel, - System.Windows.Forms.DialogResult.None => Helpers.Enums.DialogResult.None, - System.Windows.Forms.DialogResult.Abort => Helpers.Enums.DialogResult.Abort, - System.Windows.Forms.DialogResult.Retry => Helpers.Enums.DialogResult.Retry, - System.Windows.Forms.DialogResult.Ignore => Helpers.Enums.DialogResult.Ignore, + System.Windows.Forms.DialogResult.Yes => Enums.DialogResult.Yes, + System.Windows.Forms.DialogResult.No => Enums.DialogResult.No, + System.Windows.Forms.DialogResult.OK => Enums.DialogResult.Ok, + System.Windows.Forms.DialogResult.Cancel => Enums.DialogResult.Cancel, + System.Windows.Forms.DialogResult.None => Enums.DialogResult.None, + System.Windows.Forms.DialogResult.Abort => Enums.DialogResult.Abort, + System.Windows.Forms.DialogResult.Retry => Enums.DialogResult.Retry, + System.Windows.Forms.DialogResult.Ignore => Enums.DialogResult.Ignore, _ => throw new NotImplementedException(), }; } diff --git a/SimpleStateMachineNodeEditor/Helpers/Extensions/IObservableExtension.cs b/SimpleStateMachineNodeEditor/Helpers/Extensions/IObservableExtension.cs index d5c46c1..56e3821 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Extensions/IObservableExtension.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Extensions/IObservableExtension.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.Generic; using System.Reactive; using System.Reactive.Linq; -using System.Text; namespace SimpleStateMachineNodeEditor.Helpers.Extensions { diff --git a/SimpleStateMachineNodeEditor/Helpers/Extensions/MatrixExtension.cs b/SimpleStateMachineNodeEditor/Helpers/Extensions/MatrixExtension.cs index 8314faa..c4f1378 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Extensions/MatrixExtension.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Extensions/MatrixExtension.cs @@ -1,6 +1,4 @@ -using System.Windows; -using System.Windows.Media; -using static System.Math; +using System.Windows.Media; namespace SimpleStateMachineNodeEditor.Helpers.Extensions { diff --git a/SimpleStateMachineNodeEditor/Helpers/Extensions/MessageBoxResultExtension.cs b/SimpleStateMachineNodeEditor/Helpers/Extensions/MessageBoxResultExtension.cs index 9dd5c78..adc997a 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Extensions/MessageBoxResultExtension.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Extensions/MessageBoxResultExtension.cs @@ -5,15 +5,15 @@ namespace SimpleStateMachineNodeEditor.Helpers.Extensions { public static class MessageBoxResultExtension { - public static Helpers.Enums.DialogResult ToDialogResult(this MessageBoxResult messageBoxResult) + public static Enums.DialogResult ToDialogResult(this MessageBoxResult messageBoxResult) { return messageBoxResult switch { - MessageBoxResult.Yes => Helpers.Enums.DialogResult.Yes, - MessageBoxResult.No => Helpers.Enums.DialogResult.No, - MessageBoxResult.OK => Helpers.Enums.DialogResult.Ok, - MessageBoxResult.Cancel => Helpers.Enums.DialogResult.Cancel, - MessageBoxResult.None => Helpers.Enums.DialogResult.None, + MessageBoxResult.Yes => Enums.DialogResult.Yes, + MessageBoxResult.No => Enums.DialogResult.No, + MessageBoxResult.OK => Enums.DialogResult.Ok, + MessageBoxResult.Cancel => Enums.DialogResult.Cancel, + MessageBoxResult.None => Enums.DialogResult.None, _ => throw new NotImplementedException() }; } diff --git a/SimpleStateMachineNodeEditor/Helpers/Extensions/ObjectExtension.cs b/SimpleStateMachineNodeEditor/Helpers/Extensions/ObjectExtension.cs index 8a25ff2..3f679c3 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Extensions/ObjectExtension.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Extensions/ObjectExtension.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SimpleStateMachineNodeEditor.Helpers.Extensions +namespace SimpleStateMachineNodeEditor.Helpers.Extensions { public static class ObjectExtension { diff --git a/SimpleStateMachineNodeEditor/Helpers/Extensions/PointExtensition.cs b/SimpleStateMachineNodeEditor/Helpers/Extensions/PointExtensition.cs index d482e30..d872c8b 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Extensions/PointExtensition.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Extensions/PointExtensition.cs @@ -1,9 +1,4 @@ -using ReactiveUI; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Runtime.CompilerServices; -using System.Text; +using System.Globalization; using System.Windows; namespace SimpleStateMachineNodeEditor.Helpers.Extensions diff --git a/SimpleStateMachineNodeEditor/Helpers/Extensions/ReactiveCommandExtension.cs b/SimpleStateMachineNodeEditor/Helpers/Extensions/ReactiveCommandExtension.cs index fc1ac52..0a9f2b1 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Extensions/ReactiveCommandExtension.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Extensions/ReactiveCommandExtension.cs @@ -1,8 +1,5 @@ using ReactiveUI; -using SimpleStateMachineNodeEditor.Helpers.Commands; using System; -using System.Collections.Generic; -using System.Text; namespace SimpleStateMachineNodeEditor.Helpers.Extensions { diff --git a/SimpleStateMachineNodeEditor/Helpers/MyUtils.cs b/SimpleStateMachineNodeEditor/Helpers/MyUtils.cs index b231e14..993f81c 100644 --- a/SimpleStateMachineNodeEditor/Helpers/MyUtils.cs +++ b/SimpleStateMachineNodeEditor/Helpers/MyUtils.cs @@ -2,7 +2,6 @@ using System.Windows.Media; using System; using System.Collections.Generic; -using System.Windows.Controls; using SimpleStateMachineNodeEditor.Helpers.Enums; using System.Windows.Media.Imaging; using System.IO; diff --git a/SimpleStateMachineNodeEditor/Helpers/Transformations/Scale.cs b/SimpleStateMachineNodeEditor/Helpers/Transformations/Scale.cs index d901937..77cf12b 100644 --- a/SimpleStateMachineNodeEditor/Helpers/Transformations/Scale.cs +++ b/SimpleStateMachineNodeEditor/Helpers/Transformations/Scale.cs @@ -1,9 +1,7 @@ using ReactiveUI; using ReactiveUI.Fody.Helpers; using SimpleStateMachineNodeEditor.Helpers.Extensions; -using Splat; using System; -using System.Reactive.Linq; using System.Windows; namespace SimpleStateMachineNodeEditor.Helpers.Transformations diff --git a/SimpleStateMachineNodeEditor/Icons/Icons.xaml b/SimpleStateMachineNodeEditor/Icons/Icons.xaml index 3170a87..e961e92 100644 --- a/SimpleStateMachineNodeEditor/Icons/Icons.xaml +++ b/SimpleStateMachineNodeEditor/Icons/Icons.xaml @@ -1,6 +1,5 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> diff --git a/SimpleStateMachineNodeEditor/Icons/Loop.xaml b/SimpleStateMachineNodeEditor/Icons/Loop.xaml index 805b4d5..56b2365 100644 --- a/SimpleStateMachineNodeEditor/Icons/Loop.xaml +++ b/SimpleStateMachineNodeEditor/Icons/Loop.xaml @@ -1,7 +1,5 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> diff --git a/SimpleStateMachineNodeEditor/Icons/SelectedLoop.xaml b/SimpleStateMachineNodeEditor/Icons/SelectedLoop.xaml index efe3ba1..f9246fe 100644 --- a/SimpleStateMachineNodeEditor/Icons/SelectedLoop.xaml +++ b/SimpleStateMachineNodeEditor/Icons/SelectedLoop.xaml @@ -1,7 +1,5 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> diff --git a/SimpleStateMachineNodeEditor/SimpleStateMachineNodeEditor.csproj b/SimpleStateMachineNodeEditor/SimpleStateMachineNodeEditor.csproj index c59128a..b88ff83 100644 --- a/SimpleStateMachineNodeEditor/SimpleStateMachineNodeEditor.csproj +++ b/SimpleStateMachineNodeEditor/SimpleStateMachineNodeEditor.csproj @@ -62,16 +62,16 @@ New format for xml file with schemes - - - - - - - - - - + + + + + + + + + + diff --git a/SimpleStateMachineNodeEditor/Styles/ErrorList/StyleExpander.xaml b/SimpleStateMachineNodeEditor/Styles/ErrorList/StyleExpander.xaml index ce81bc2..fd28cd6 100644 --- a/SimpleStateMachineNodeEditor/Styles/ErrorList/StyleExpander.xaml +++ b/SimpleStateMachineNodeEditor/Styles/ErrorList/StyleExpander.xaml @@ -1,6 +1,5 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> + + + + \ No newline at end of file diff --git a/SimpleStateMachineNodeEditorAvalonia/Styles/Connector/LeftConnector/TextBoxLeftConnector.xaml b/SimpleStateMachineNodeEditorAvalonia/Styles/Connector/LeftConnector/TextBoxLeftConnector.xaml new file mode 100644 index 0000000..c4b9696 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Styles/Connector/LeftConnector/TextBoxLeftConnector.xaml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/SimpleStateMachineNodeEditorAvalonia/Styles/Connector/RightConnector/EllipseRightConnector.xaml b/SimpleStateMachineNodeEditorAvalonia/Styles/Connector/RightConnector/EllipseRightConnector.xaml new file mode 100644 index 0000000..a0167a5 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Styles/Connector/RightConnector/EllipseRightConnector.xaml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/SimpleStateMachineNodeEditorAvalonia/Styles/Connector/RightConnector/RightConnector.xaml b/SimpleStateMachineNodeEditorAvalonia/Styles/Connector/RightConnector/RightConnector.xaml new file mode 100644 index 0000000..6325dc8 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Styles/Connector/RightConnector/RightConnector.xaml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/SimpleStateMachineNodeEditorAvalonia/Styles/Connector/RightConnector/TextBoxRightConnector.xaml b/SimpleStateMachineNodeEditorAvalonia/Styles/Connector/RightConnector/TextBoxRightConnector.xaml new file mode 100644 index 0000000..4a61941 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Styles/Connector/RightConnector/TextBoxRightConnector.xaml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/SimpleStateMachineNodeEditorAvalonia/Styles/CornerRadius.xaml b/SimpleStateMachineNodeEditorAvalonia/Styles/CornerRadius.xaml new file mode 100644 index 0000000..bafa21b --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Styles/CornerRadius.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/SimpleStateMachineNodeEditorAvalonia/Styles/EmptyTextBox.xaml b/SimpleStateMachineNodeEditorAvalonia/Styles/EmptyTextBox.xaml new file mode 100644 index 0000000..22e1272 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Styles/EmptyTextBox.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/SimpleStateMachineNodeEditorAvalonia/Styles/Node/Header/ButtonNodeHeader.xaml b/SimpleStateMachineNodeEditorAvalonia/Styles/Node/Header/ButtonNodeHeader.xaml new file mode 100644 index 0000000..9d655e6 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Styles/Node/Header/ButtonNodeHeader.xaml @@ -0,0 +1,45 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/SimpleStateMachineNodeEditorAvalonia/Styles/Node/Header/TextBoxNodeHeader.xaml b/SimpleStateMachineNodeEditorAvalonia/Styles/Node/Header/TextBoxNodeHeader.xaml new file mode 100644 index 0000000..07bbaec --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Styles/Node/Header/TextBoxNodeHeader.xaml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/SimpleStateMachineNodeEditorAvalonia/Styles/Node/Node.xaml b/SimpleStateMachineNodeEditorAvalonia/Styles/Node/Node.xaml new file mode 100644 index 0000000..735800c --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Styles/Node/Node.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file diff --git a/SimpleStateMachineNodeEditorAvalonia/Styles/Styles.xaml b/SimpleStateMachineNodeEditorAvalonia/Styles/Styles.xaml new file mode 100644 index 0000000..4180083 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Styles/Styles.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SimpleStateMachineNodeEditorAvalonia/Themes/Dark.xaml b/SimpleStateMachineNodeEditorAvalonia/Themes/Dark.xaml new file mode 100644 index 0000000..a383f33 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Themes/Dark.xaml @@ -0,0 +1,89 @@ + + diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewLocator.cs b/SimpleStateMachineNodeEditorAvalonia/ViewLocator.cs new file mode 100644 index 0000000..a6caf9a --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewLocator.cs @@ -0,0 +1,32 @@ +using System; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia +{ + public class ViewLocator : IDataTemplate + { + public bool SupportsRecycling => false; + + public IControl Build(object data) + { + var name = data.GetType().FullName.Replace("ViewModel", "View"); + var type = Type.GetType(name); + + if (type != null) + { + return (Control)Activator.CreateInstance(type); + } + else + { + return new TextBlock { Text = "Not Found: " + name }; + } + } + + public bool Match(object data) + { + return data is BaseViewModel; + } + } +} \ No newline at end of file diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Base/BaseViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Base/BaseViewModel.cs new file mode 100644 index 0000000..478a3b0 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Base/BaseViewModel.cs @@ -0,0 +1,16 @@ +using ReactiveUI; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public abstract class BaseViewModel : ReactiveObject + { + protected abstract void SetupCommands(); + protected abstract void SetupSubscriptions(); + + public BaseViewModel() + { + SetupCommands(); + SetupSubscriptions(); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connect/CommandsConnectViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connect/CommandsConnectViewModel.cs new file mode 100644 index 0000000..81964c0 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connect/CommandsConnectViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class ConnectViewModel + { + protected override void SetupCommands() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connect/ConnectViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connect/ConnectViewModel.cs new file mode 100644 index 0000000..99117ad --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connect/ConnectViewModel.cs @@ -0,0 +1,19 @@ +using Avalonia; +using ReactiveUI; +using ReactiveUI.Fody.Helpers; +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class ConnectViewModel : BaseViewModel + { + [Reactive] public RightConnectorViewModel FromConnector { get; set; } + [Reactive] public LeftConnectorViewModel ToConnector { get; set; } + + public ConnectViewModel(RightConnectorViewModel connectorFrom, LeftConnectorViewModel connectorTo) + { + FromConnector = connectorFrom; + ToConnector = connectorTo; + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connect/SubscriptionsConnectViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connect/SubscriptionsConnectViewModel.cs new file mode 100644 index 0000000..684c7c2 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connect/SubscriptionsConnectViewModel.cs @@ -0,0 +1,29 @@ +using ReactiveUI; +using System; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class ConnectViewModel + { + IDisposable fromConnectorPositionSubscrube; + protected override void SetupSubscriptions() + { + // this.WhenAnyValue(x => x.FromConnector.Node.Header.IsCollapse).Subscribe(value => UpdateSubscriptionForPosition(value)); + } + + // private void UpdateSubscriptionForPosition(bool nodeIsCollapse) + // { + // if (!nodeIsCollapse) + // { + // fromConnectorPositionSubscrube?.Dispose(); + // fromConnectorPositionSubscrube = this.WhenAnyValue(x => x.FromConnector.Position).BindTo(this, vm => vm.StartPoint); + // + // } + // else + // { + // fromConnectorPositionSubscrube?.Dispose(); + // fromConnectorPositionSubscrube = this.WhenAnyValue(x => x.FromConnector.Node.Output.Position).BindTo(this, vm => vm.StartPoint); + // } + // } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/Connector/CommandsConnectorViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/Connector/CommandsConnectorViewModel.cs new file mode 100644 index 0000000..a5747ac --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/Connector/CommandsConnectorViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class ConnectorViewModel + { + protected override void SetupCommands() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/Connector/ConnectorViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/Connector/ConnectorViewModel.cs new file mode 100644 index 0000000..f4de810 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/Connector/ConnectorViewModel.cs @@ -0,0 +1,18 @@ +using Avalonia; +using ReactiveUI.Fody.Helpers; +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class ConnectorViewModel : BaseViewModel + { + [Reactive] public NodeViewModel Node { get; set; } + [Reactive] public StringWithEnable Name { get; set; } + [Reactive] public Point Position { get; set; } + public ConnectorViewModel(NodeViewModel node, string name="", bool isEnable = true ) + { + Node = node; + Name = new StringWithEnable(name, isEnable); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/Connector/SubscriptionsConnectorViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/Connector/SubscriptionsConnectorViewModel.cs new file mode 100644 index 0000000..d982918 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/Connector/SubscriptionsConnectorViewModel.cs @@ -0,0 +1,16 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class ConnectorViewModel + { + protected override void SetupSubscriptions() + { + // this.WhenAnyValue(x => x.Node).Where(x => x != null).Subscribe(_ => SubscriptToNode()); + + } + // + // private void SubscriptToNode() + // { + // Node.WhenAnyValue(n => n.Point1).Buffer(2, 1).Select(value => value[1] - value[0]).Subscribe(x => Position = Position + x); + // } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/LeftConnector/CommandsLeftConnectorViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/LeftConnector/CommandsLeftConnectorViewModel.cs new file mode 100644 index 0000000..8da3056 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/LeftConnector/CommandsLeftConnectorViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class LeftConnectorViewModel + { + protected override void SetupCommands() + { + base.SetupCommands(); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/LeftConnector/LeftConnectorViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/LeftConnector/LeftConnectorViewModel.cs new file mode 100644 index 0000000..6ccedfc --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/LeftConnector/LeftConnectorViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class LeftConnectorViewModel : ConnectorViewModel + { + public LeftConnectorViewModel(NodeViewModel node, string name = "", bool isEnable = true) : base(node, name, isEnable) + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/LeftConnector/SubscriptionsLeftConnectorViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/LeftConnector/SubscriptionsLeftConnectorViewModel.cs new file mode 100644 index 0000000..51ff9b5 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/LeftConnector/SubscriptionsLeftConnectorViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class LeftConnectorViewModel + { + protected override void SetupSubscriptions() + { + base.SetupSubscriptions(); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/RightConnector/CommandsRightConnectorViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/RightConnector/CommandsRightConnectorViewModel.cs new file mode 100644 index 0000000..8402be8 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/RightConnector/CommandsRightConnectorViewModel.cs @@ -0,0 +1,25 @@ +using Avalonia; +using ReactiveUI; +using System.Reactive; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class RightConnectorViewModel + { + public ReactiveCommand AddConnectCommand { get; set; } + + protected override void SetupCommands() + { + base.SetupCommands(); + AddConnectCommand = ReactiveCommand.Create(AddConnect); + + } + + public void AddConnect(Point point) + { + // Connect = Node.NodesCanvas.Connects.GetNewConnect(this, point); + } + + + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/RightConnector/RightConnectorViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/RightConnector/RightConnectorViewModel.cs new file mode 100644 index 0000000..0231499 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/RightConnector/RightConnectorViewModel.cs @@ -0,0 +1,14 @@ +using ReactiveUI.Fody.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class RightConnectorViewModel : ConnectorViewModel + { + [Reactive] public ConnectViewModel Connect { get; set; } + [Reactive] public bool IsSelect { get; set; } + public RightConnectorViewModel(NodeViewModel node, string name = "", bool isEnable = true):base(node, name, isEnable) + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/RightConnector/SubscriptionsRightConnectorViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/RightConnector/SubscriptionsRightConnectorViewModel.cs new file mode 100644 index 0000000..50494eb --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Connector/RightConnector/SubscriptionsRightConnectorViewModel.cs @@ -0,0 +1,11 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class RightConnectorViewModel + { + protected override void SetupSubscriptions() + { + base.SetupSubscriptions(); + } + + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Cutter/CommandsCutterViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Cutter/CommandsCutterViewModel.cs new file mode 100644 index 0000000..190a1f4 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Cutter/CommandsCutterViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class CutterViewModel + { + protected override void SetupCommands() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Cutter/CutterViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Cutter/CutterViewModel.cs new file mode 100644 index 0000000..a62830b --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Cutter/CutterViewModel.cs @@ -0,0 +1,13 @@ +using Avalonia; +using ReactiveUI.Fody.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class CutterViewModel : BaseViewModel + { + [Reactive] public bool? Visible { get; set; } = false; + [Reactive] public Point StartPoint { get; set; } + [Reactive] public Point EndPoint { get; set; } + [Reactive] public double StrokeThickness { get; set; } = 1; + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Cutter/SubscriptionsCutterViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Cutter/SubscriptionsCutterViewModel.cs new file mode 100644 index 0000000..dea6361 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Cutter/SubscriptionsCutterViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class CutterViewModel + { + protected override void SetupSubscriptions() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/DraggableConnector/DraggableConnectorViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/DraggableConnector/DraggableConnectorViewModel.cs new file mode 100644 index 0000000..7c3bd9a --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/DraggableConnector/DraggableConnectorViewModel.cs @@ -0,0 +1,22 @@ + +using Avalonia; +using ReactiveUI.Fody.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public class DraggableConnectorViewModel:BaseViewModel + { + [Reactive] public Point StartPoint { get; set; } + [Reactive] public Point EndPoint { get; set; } + + protected override void SetupCommands() + { + + } + + protected override void SetupSubscriptions() + { + + } + } +} \ No newline at end of file diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/MainWindow/CommandsMainWindowViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/MainWindow/CommandsMainWindowViewModel.cs new file mode 100644 index 0000000..6c3c2f3 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/MainWindow/CommandsMainWindowViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class MainWindowViewModel + { + protected override void SetupCommands() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/MainWindow/MainWindowViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/MainWindow/MainWindowViewModel.cs new file mode 100644 index 0000000..4f3eb47 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/MainWindow/MainWindowViewModel.cs @@ -0,0 +1,14 @@ +using ReactiveUI; +using ReactiveUI.Fody.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class MainWindowViewModel: BaseViewModel + { + [Reactive] public NodesCanvasViewModel NodesCanvas { get; set; } = new(); + + public MainWindowViewModel() + { + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/MainWindow/SubscriptionsMainWindowViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/MainWindow/SubscriptionsMainWindowViewModel.cs new file mode 100644 index 0000000..c7d4305 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/MainWindow/SubscriptionsMainWindowViewModel.cs @@ -0,0 +1,11 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class MainWindowViewModel + { + protected override void SetupSubscriptions() + { + + } + + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/CommandsNodeViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/CommandsNodeViewModel.cs new file mode 100644 index 0000000..014cbcd --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/CommandsNodeViewModel.cs @@ -0,0 +1,28 @@ +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class NodeViewModel + { + public ReactiveCommand SelectCommand; + protected override void SetupCommands() + { + SelectCommand = ReactiveCommand.Create(Select); + } + + private void Select(SelectMode selectMode) + { + if (selectMode == SelectMode.ClickWithCtrl) + { + IsSelect = !IsSelect; + } + else if((selectMode == SelectMode.Click)&&(!IsSelect)) + { + NodesCanvas.Nodes.SetIsSelectAllNodesCommand.ExecuteWithSubscribe((false, null)); + IsSelect = true; + } + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Connectors/CommandsConnectorsNodeViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Connectors/CommandsConnectorsNodeViewModel.cs new file mode 100644 index 0000000..5b7a5ee --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Connectors/CommandsConnectorsNodeViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class ConnectorsNodeViewModel + { + protected override void SetupCommands() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Connectors/ConnectorsNodeViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Connectors/ConnectorsNodeViewModel.cs new file mode 100644 index 0000000..02475b3 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Connectors/ConnectorsNodeViewModel.cs @@ -0,0 +1,34 @@ +using Avalonia; +using DynamicData; +using DynamicData.Binding; +using ReactiveUI; +using System; +using System.Reactive.Linq; +using SimpleStateMachineNodeEditorAvalonia.Helpers.Extensions; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class ConnectorsNodeViewModel: BaseViewModel + { + public SourceList Connectors { get; set; } = new SourceList(); + public IObservableList SelectedConnectors; + + + public readonly ObservableCollectionExtended ConnectorsForView = new ObservableCollectionExtended(); + + public ConnectorsNodeViewModel(NodeViewModel node) + { + Connectors.Connect().ObserveOn(RxApp.MainThreadScheduler).Bind(ConnectorsForView).Subscribe(); + SelectedConnectors = Connectors.Connect().AutoRefresh(x=>x.IsSelect) + .Filter(x => x.IsSelect && x.Name.IsNotNullAndEmpty()).AsObservableList(); + + + Connectors.Add(new RightConnectorViewModel(node, "", false) {Position= node.Point1 + new Point(75.5, 52) }); + + Connectors.Add(new RightConnectorViewModel(node, "Transition1") { Position= node.Point1 + new Point(75.5, 52) }); + Connectors.Add(new RightConnectorViewModel(node, "Transition2") { Position= node.Point1 + new Point(75.5, 52) }); + } + + + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Connectors/SubscriptionsConnectorsNodeViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Connectors/SubscriptionsConnectorsNodeViewModel.cs new file mode 100644 index 0000000..a923b7d --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Connectors/SubscriptionsConnectorsNodeViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class ConnectorsNodeViewModel + { + protected override void SetupSubscriptions() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Header/CommandsHeaderNodeViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Header/CommandsHeaderNodeViewModel.cs new file mode 100644 index 0000000..c75159f --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Header/CommandsHeaderNodeViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class HeaderNodeViewModel + { + protected override void SetupCommands() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Header/HeaderNodeViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Header/HeaderNodeViewModel.cs new file mode 100644 index 0000000..4650f95 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Header/HeaderNodeViewModel.cs @@ -0,0 +1,16 @@ +using ReactiveUI.Fody.Helpers; +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class HeaderNodeViewModel:BaseViewModel + { + public HeaderNodeViewModel(string name = "") + { + Name = new StringWithEnable(name); + } + + [Reactive] public StringWithEnable Name { get; set; } + [Reactive] public bool IsCollapse { get; set; } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Header/SubscriptionsHeaderNodeViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Header/SubscriptionsHeaderNodeViewModel.cs new file mode 100644 index 0000000..0ffbbd3 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/Header/SubscriptionsHeaderNodeViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class HeaderNodeViewModel + { + protected override void SetupSubscriptions() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/NodeViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/NodeViewModel.cs new file mode 100644 index 0000000..203764a --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/NodeViewModel.cs @@ -0,0 +1,40 @@ +using Avalonia; +using ReactiveUI.Fody.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class NodeViewModel:BaseViewModel + { + [Reactive] public NodesCanvasViewModel NodesCanvas { get; set; } + [Reactive] public HeaderNodeViewModel Header { get; set; } + [Reactive] public ConnectorsNodeViewModel Connectors { get; set; } + [Reactive] public LeftConnectorViewModel Input { get; set; } + [Reactive] public RightConnectorViewModel Output { get; set; } + [Reactive] public Point Point1 { get; set; } + [Reactive] public Size Size { get; set; } + [Reactive] public Point Point2 { get; set; } + [Reactive] public bool DeleteEnable { get; set; } = true; + [Reactive] public bool IsSelect { get; set; } + + public NodeViewModel(NodesCanvasViewModel nodeCanvas, string name, Point position) + { + NodesCanvas = nodeCanvas; + Point1 = position; + Connectors = new ConnectorsNodeViewModel(this); + Header = new HeaderNodeViewModel(name); + InitConnectors(); + } + public NodeViewModel(NodesCanvasViewModel nodeCanvas, string name, int x = 0, int y = 0):this(nodeCanvas, name, new Point(x, y)) + { + + } + + private void InitConnectors() + { + Input = new LeftConnectorViewModel(this, "Input", false); + Output = new RightConnectorViewModel(this, "Output", false) { Position = Point1 + new Point(70.5, 52) }; + + } + + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/SubscriptionsNodeViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/SubscriptionsNodeViewModel.cs new file mode 100644 index 0000000..a2f02ad --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Node/SubscriptionsNodeViewModel.cs @@ -0,0 +1,20 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class NodeViewModel + { + protected override void SetupSubscriptions() + { + + } + + + //public void Test() + //{ + // this.Where(x => x.Output != null) + // .WhenAnyValue(x => x.Point1).Buffer(2, 1).Select(values => values[1] - values[0]).Subscribe(value => Output.Position = Output.Position + value); + //} + + + + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/CommandsNodesCanvasViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/CommandsNodesCanvasViewModel.cs new file mode 100644 index 0000000..31acdd9 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/CommandsNodesCanvasViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class NodesCanvasViewModel + { + protected override void SetupCommands() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Connects/CommandsConnectsNodesCanvasViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Connects/CommandsConnectsNodesCanvasViewModel.cs new file mode 100644 index 0000000..5c4170a --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Connects/CommandsConnectsNodesCanvasViewModel.cs @@ -0,0 +1,11 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class ConnectsNodesCanvasViewModel + { + protected override void SetupCommands() + { + + } + } + +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Connects/ConnectsNodesCanvasViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Connects/ConnectsNodesCanvasViewModel.cs new file mode 100644 index 0000000..6d74d47 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Connects/ConnectsNodesCanvasViewModel.cs @@ -0,0 +1,33 @@ +using Avalonia; +using DynamicData; +using DynamicData.Binding; +using ReactiveUI; +using ReactiveUI.Fody.Helpers; +using System; +using System.Reactive.Linq; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class ConnectsNodesCanvasViewModel : BaseViewModel + { + public SourceList Connects = new SourceList(); + public ObservableCollectionExtended ConnectsForView = new ObservableCollectionExtended(); + [Reactive] public ConnectViewModel DraggedConnect { get; set; } + + public ConnectsNodesCanvasViewModel() + { + Connects.Connect().ObserveOn(RxApp.MainThreadScheduler).Bind(ConnectsForView).Subscribe(); + + //Connects.Add(new ConnectViewModel() { StartPoint = new Point(10, 10), EndPoint = new Point(500, 500) }); + } + + // public ConnectViewModel GetNewConnect(RightConnectorViewModel connectorFrom, Point point = default) + // { + // var newConnect = new ConnectViewModel(connectorFrom, point); + // Connects.Add(newConnect); + // + // return newConnect; + // } + } + +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Connects/SubscriptionsConnectsNodesCanvasViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Connects/SubscriptionsConnectsNodesCanvasViewModel.cs new file mode 100644 index 0000000..bacfbfe --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Connects/SubscriptionsConnectsNodesCanvasViewModel.cs @@ -0,0 +1,11 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class ConnectsNodesCanvasViewModel + { + protected override void SetupSubscriptions() + { + + } + } + +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Nodes/CommandsNodesNodesCanvasViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Nodes/CommandsNodesNodesCanvasViewModel.cs new file mode 100644 index 0000000..fce7af6 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Nodes/CommandsNodesNodesCanvasViewModel.cs @@ -0,0 +1,37 @@ +using Avalonia; +using ReactiveUI; +using System.Collections.Generic; +using System.Linq; +using System.Reactive; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class NodesNodesCanvasViewModel + { + public ReactiveCommand MoveCommand { get; set; } + public ReactiveCommand<(bool value, List exludedNodes), Unit> SetIsSelectAllNodesCommand { get; set; } + + protected override void SetupCommands() + { + MoveCommand = ReactiveCommand.Create(Move); + SetIsSelectAllNodesCommand = ReactiveCommand.Create<(bool value, List exludedNodes)>(SelectAllNodes); + } + + private void Move(Point point) + { + foreach (var node in SelectedNodes.Items) + { + node.Point1 = node.Point1 + point; + } + } + + private void SelectAllNodes((bool value, List exludedNodes) parameter) + { + List exludedNodes = parameter.exludedNodes ?? new List(); + foreach (var node in SelectedNodes.Items.Except(exludedNodes)) + { + node.IsSelect = parameter.value; + } + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Nodes/NodesNodesCanvasViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Nodes/NodesNodesCanvasViewModel.cs new file mode 100644 index 0000000..e4109f3 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Nodes/NodesNodesCanvasViewModel.cs @@ -0,0 +1,32 @@ +using Avalonia; +using DynamicData; +using ReactiveUI; +using ReactiveUI.Fody.Helpers; +using System; +using System.Collections.ObjectModel; +using System.Reactive.Linq; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class NodesNodesCanvasViewModel : BaseViewModel + { + protected IObservableList SelectedNodes; + [Reactive] public NodeViewModel StartState { get; set; } + protected SourceList Nodes = new(); + public ReadOnlyObservableCollection NodesForView; + + public NodesNodesCanvasViewModel(NodesCanvasViewModel nodesCanvas) + { + + SelectedNodes = Nodes.Connect() + .AutoRefresh(x=>x.IsSelect) + .Filter(x => x.IsSelect) + .AsObservableList(); + + Nodes.Connect().ObserveOn(RxApp.MainThreadScheduler).Bind(out NodesForView).Subscribe(); + Nodes.Add(new NodeViewModel(nodesCanvas, "State 5", new Point(150, 100))); + Nodes.Add(new NodeViewModel(nodesCanvas, "State 3", new Point(100, 100))); + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Nodes/SubscriptionsNodesNodesCanvasViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Nodes/SubscriptionsNodesNodesCanvasViewModel.cs new file mode 100644 index 0000000..dacd2b0 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/Nodes/SubscriptionsNodesNodesCanvasViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class NodesNodesCanvasViewModel + { + protected override void SetupSubscriptions() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/NodesCanvasViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/NodesCanvasViewModel.cs new file mode 100644 index 0000000..bb097ac --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/NodesCanvasViewModel.cs @@ -0,0 +1,18 @@ +using ReactiveUI.Fody.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class NodesCanvasViewModel : BaseViewModel + { + [Reactive] public NodesNodesCanvasViewModel Nodes { get; set; } + [Reactive] public ConnectsNodesCanvasViewModel Connects { get; set; } = new(); + [Reactive] public SelectorViewModel Selector { get; set; } = new(); + [Reactive] public CutterViewModel Cutter { get; set; } = new(); + [Reactive] public DraggableConnectorViewModel DraggableConnector { get; set; } = new(); + + public NodesCanvasViewModel() + { + Nodes = new NodesNodesCanvasViewModel(this); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/SubscriptionsNodesCanvasViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/SubscriptionsNodesCanvasViewModel.cs new file mode 100644 index 0000000..b32a976 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/NodesCanvas/SubscriptionsNodesCanvasViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class NodesCanvasViewModel + { + protected override void SetupSubscriptions() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Selector/CommandsSelectorViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Selector/CommandsSelectorViewModel.cs new file mode 100644 index 0000000..d3b6e53 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Selector/CommandsSelectorViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class SelectorViewModel + { + protected override void SetupCommands() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Selector/SelectorViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Selector/SelectorViewModel.cs new file mode 100644 index 0000000..0ab5b98 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Selector/SelectorViewModel.cs @@ -0,0 +1,7 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class SelectorViewModel : BaseViewModel + { + + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/ViewModels/Selector/SubscriptionsSelectorViewModel.cs b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Selector/SubscriptionsSelectorViewModel.cs new file mode 100644 index 0000000..00e8635 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/ViewModels/Selector/SubscriptionsSelectorViewModel.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.ViewModels +{ + public partial class SelectorViewModel + { + protected override void SetupSubscriptions() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Base/BaseView.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Base/BaseView.cs new file mode 100644 index 0000000..b6ceb8a --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Base/BaseView.cs @@ -0,0 +1,19 @@ +using Avalonia.ReactiveUI; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public abstract class BaseView: ReactiveUserControl + where TViewModel:class + { + protected abstract void SetupBinding(); + protected abstract void SetupEvents(); + protected abstract void SetupSubscriptions(); + + public BaseView() + { + SetupBinding(); + SetupEvents(); + SetupSubscriptions(); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connect/BindingConnect.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connect/BindingConnect.cs new file mode 100644 index 0000000..b8275c8 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connect/BindingConnect.cs @@ -0,0 +1,28 @@ +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Connect + { + protected override void SetupBinding() + { + this.WhenViewModelAnyValue(disposable => + { + // this.OneWayBind(ViewModel, x => x.StartPoint, x=>x.PathFigureConnect.StartPoint).DisposeWith(disposable); + // this.OneWayBind(ViewModel, x => x.EndPoint, x => x.BezierSegmentConnect.Point3).DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x => x.FromConnector.Position, + x=>x.PathFigureConnect.StartPoint) + .DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x => x.ToConnector.Position, + x => x.BezierSegmentConnect.Point3) + .DisposeWith(disposable); + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connect/Connect.xaml b/SimpleStateMachineNodeEditorAvalonia/Views/Connect/Connect.xaml new file mode 100644 index 0000000..931c637 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connect/Connect.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connect/Connect.xaml.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connect/Connect.xaml.cs new file mode 100644 index 0000000..d4a8c61 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connect/Connect.xaml.cs @@ -0,0 +1,20 @@ +using System.Linq; +using Avalonia.Media; +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Connect : BaseView + { + private readonly PathGeometry PathGeometryConnect; + private readonly PathFigure PathFigureConnect; + private BezierSegment BezierSegmentConnect; + public Connect() + { + InitializeComponent(); + PathGeometryConnect = PathConnect.Data as PathGeometry; + PathFigureConnect = PathGeometryConnect.Figures.First(); + BezierSegmentConnect = PathFigureConnect.Segments.First() as BezierSegment; + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connect/EventsConnect.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connect/EventsConnect.cs new file mode 100644 index 0000000..488c29b --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connect/EventsConnect.cs @@ -0,0 +1,19 @@ +using System.Reactive.Disposables; +using Avalonia.Input; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System; +using Avalonia; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Connect + { + protected override void SetupEvents() + { + this.WhenViewModelAnyValue(disposable => + { + + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connect/SubscriptionsConnect.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connect/SubscriptionsConnect.cs new file mode 100644 index 0000000..164690e --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connect/SubscriptionsConnect.cs @@ -0,0 +1,32 @@ +using Avalonia; +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; +using System.Reactive.Linq; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Connect + { + protected override void SetupSubscriptions() + { + this.WhenViewModelAnyValue(disposable => + { + var points = ViewModel.WhenAnyValue(x => x.FromConnector.Position, + x => x.ToConnector.Position).Select(points => UpdateMediumPoints(points.Item1, points.Item2)); + + points.Select(x => x.Point1).BindTo(BezierSegmentConnect, x => x.Point1).DisposeWith(disposable); + points.Select(x => x.Point2).BindTo(BezierSegmentConnect, x => x.Point2).DisposeWith(disposable); + }); + } + + public static (Point Point1, Point Point2) UpdateMediumPoints(Point startPoint, Point endPoint) + { + var different = endPoint - startPoint; + var Point1 = new Point(startPoint.X + 3 * different.X / 8, startPoint.Y + 1 * different.Y / 8); + var Point2 = new Point(startPoint.X + 5 * different.X / 8, startPoint.Y + 7 * different.Y / 8); + + return (Point1, Point2); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connector/Connector/BindingConnector.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/Connector/BindingConnector.cs new file mode 100644 index 0000000..2439281 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/Connector/BindingConnector.cs @@ -0,0 +1,27 @@ +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Connector + { + protected override void SetupBinding() + { + this.WhenViewModelAnyValue(disposable => + { + this.OneWayBind(this.ViewModel, + x => x.Name.Value, + x => x.textBox.Text) + .DisposeWith(disposable); + + this.OneWayBind(this.ViewModel, + x => x.Name.IsEnabled, + x => x.textBox.IsEnabled) + .DisposeWith(disposable); + }); + + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connector/Connector/Connector.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/Connector/Connector.cs new file mode 100644 index 0000000..765bf20 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/Connector/Connector.cs @@ -0,0 +1,32 @@ +using Avalonia.ReactiveUI; +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.ViewModels; +using System; +using System.Collections.Generic; +using System.Text; +using System.Reactive.Disposables; +using System.Reactive.Linq; +using Avalonia.Controls; +using Avalonia.Controls.Shapes; +using SimpleStateMachineNodeEditorAvalonia.Helpers; + + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Connector : BaseView + where TViewModel: ConnectorViewModel + { + + private Grid grid; + private TextBox textBox; + private Ellipse ellipse; + + protected void InitializeComponent() + { + grid = this.FindControlWithExeption("GridConnector"); + textBox = this.FindControlWithExeption("TextBoxConnector"); + ellipse = this.FindControlWithExeption("EllipseConnector"); + } + + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connector/Connector/EventsConnector.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/Connector/EventsConnector.cs new file mode 100644 index 0000000..bef82f8 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/Connector/EventsConnector.cs @@ -0,0 +1,23 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Input; +using Avalonia.Markup.Xaml; +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using SimpleStateMachineNodeEditorAvalonia.Views.NodeElements; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Connector + { + protected override void SetupEvents() + { + this.WhenViewModelAnyValue(disposable => + { + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connector/Connector/SubscriptionsConnector.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/Connector/SubscriptionsConnector.cs new file mode 100644 index 0000000..f5b6143 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/Connector/SubscriptionsConnector.cs @@ -0,0 +1,23 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Input; +using Avalonia.Markup.Xaml; +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using SimpleStateMachineNodeEditorAvalonia.Views.NodeElements; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Connector + { + protected override void SetupSubscriptions() + { + this.WhenViewModelAnyValue(disposable => + { + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/BindingLeftConnector.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/BindingLeftConnector.cs new file mode 100644 index 0000000..1fb96ff --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/BindingLeftConnector.cs @@ -0,0 +1,19 @@ +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class LeftConnector + { + protected override void SetupBinding() + { + base.SetupBinding(); + this.WhenViewModelAnyValue(disposable => + { + + }); + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/EventsLeftConnector.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/EventsLeftConnector.cs new file mode 100644 index 0000000..0877f93 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/EventsLeftConnector.cs @@ -0,0 +1,18 @@ +using System; +using System.Reactive.Disposables; +using Avalonia.Input; +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class LeftConnector + { + protected override void SetupEvents() + { + this.WhenViewModelAnyValue(disposable => + { + this.EllipseConnector.AddHandler(DragDrop.DropEvent, HelperDragDrop.DropDraggableDelegate); + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/LeftConnector.xaml b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/LeftConnector.xaml new file mode 100644 index 0000000..1fd48e1 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/LeftConnector.xaml @@ -0,0 +1,26 @@ + + + + + + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/LeftConnector.xaml.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/LeftConnector.xaml.cs new file mode 100644 index 0000000..30e7d1c --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/LeftConnector.xaml.cs @@ -0,0 +1,14 @@ +using Avalonia.Input; +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class LeftConnector : Connector + { + public LeftConnector() + { + InitializeComponent(); + base.InitializeComponent(); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/SubscriptionsLeftConnector.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/SubscriptionsLeftConnector.cs new file mode 100644 index 0000000..1392fc9 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/LeftConnector/SubscriptionsLeftConnector.cs @@ -0,0 +1,15 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class LeftConnector + { + protected override void SetupSubscriptions() + { + this.WhenViewModelAnyValue(disposable => + { + + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/BindingRightConnector.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/BindingRightConnector.cs new file mode 100644 index 0000000..880b575 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/BindingRightConnector.cs @@ -0,0 +1,30 @@ +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class RightConnector + { + protected override void SetupBinding() + { + base.SetupBinding(); + this.WhenViewModelAnyValue(disposable => + { + + //this.TextBoxConnector.Events().PointerPressed.Subscribe(e => e.Handled = true).DisposeWith(disposable); + //this.Events().PointerPressed.Subscribe(e => + //{ + + // if (Keyboard.IsKeyDown(Key.LeftAlt)) + // { + // e.Handled = true; + // } + + //}).DisposeWith(disposable); + + }); + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/EventsRightConnector.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/EventsRightConnector.cs new file mode 100644 index 0000000..5039495 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/EventsRightConnector.cs @@ -0,0 +1,82 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Input; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System; +using System.Linq; +using System.Reactive.Disposables; +using Avalonia.Controls.Primitives; +using Avalonia.Interactivity; +using Avalonia.LogicalTree; +using Avalonia.VisualTree; +using SimpleStateMachineNodeEditorAvalonia.Helpers.Extensions; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class RightConnector + { + protected override void SetupEvents() + { + this.WhenViewModelAnyValue(disposable => + { + this.Events().DoubleTapped.Subscribe(OnTextBoxHeaderDoubleTappedEvent).DisposeWith(disposable); + this.TextBoxConnector.Events().LostFocus.Subscribe(OnLostFocusEvent).DisposeWith(disposable); + // this.Events().PointerPressed.Subscribe(OnRightConnectorPointerPressed).DisposeWith(disposable); + EllipseConnector.Events().PointerPressed.Subscribe(OnEllipsePointerPressed).DisposeWith(disposable); + // TextBoxConnector.AddHandler(PointerPressedEvent, OnTextBoxPointerPressed, RoutingStrategies.Bubble,true); + }); + + } + protected virtual void OnTextBoxHeaderDoubleTappedEvent(RoutedEventArgs e) + { + if(!TextBoxConnector.IsEnabled) + return; + TextBoxConnector.IsHitTestVisible = true; + TextBoxConnector.Focus(); + TextBoxConnector.CaretIndex = TextBoxConnector.Text.Length; + TextBoxConnector.ClearSelection(); + } + + protected virtual void OnLostFocusEvent(RoutedEventArgs e) + { + TextBoxConnector.IsHitTestVisible = false; + } + + + + protected virtual void OnRightConnectorPointerPressed(PointerPressedEventArgs e) + { + if (e.Source is not TextBox) + { + e.Source = this; + } + + //empty connector will not be selected + if (ViewModel.Name.IsNullOrEmpty()) + { + e.Handled = true; + } + } + protected virtual void OnTextBoxPointerPressed(object sender, PointerPressedEventArgs e) + { + //if without shift and control - connect will not be selected + e.Handled = !e.HasShift() && !e.HasControl(); + e.Source = TextBoxConnector; + } + + protected virtual void OnEllipsePointerPressed(PointerPressedEventArgs e) + { + var nodesCanvas = this.FindAncestorOfType(); + var positionConnectPoint = EllipseConnector.TranslatePoint(new Point(EllipseConnector.Width / 2, + EllipseConnector.Height / 2), this); + positionConnectPoint = this.TranslatePoint(positionConnectPoint.Value, nodesCanvas); + nodesCanvas.StartDrag(e, positionConnectPoint.Value); + + // positionConnectPoint = this.TranslatePoint(positionConnectPoint.Value, nodesCanvas); + // e.Handled = true; + // ViewModel.AddConnectCommand.ExecuteWithSubscribe(positionConnectPoint.Value); + + e.Handled = true; + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/RightConnector.xaml b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/RightConnector.xaml new file mode 100644 index 0000000..b96b577 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/RightConnector.xaml @@ -0,0 +1,30 @@ + + + + + + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/RightConnector.xaml.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/RightConnector.xaml.cs new file mode 100644 index 0000000..26785ef --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/RightConnector.xaml.cs @@ -0,0 +1,15 @@ +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + + public partial class RightConnector : Connector + { + public RightConnector() + { + InitializeComponent(); + base.InitializeComponent(); + } + + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/SubscriptionsRightConnector.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/SubscriptionsRightConnector.cs new file mode 100644 index 0000000..ff94fcf --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Connector/RightConnector/SubscriptionsRightConnector.cs @@ -0,0 +1,18 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class RightConnector + { + protected override void SetupSubscriptions() + { + + this.WhenViewModelAnyValue(disposable => + { + + }); + + } + } + +} \ No newline at end of file diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/BindingCutter.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/BindingCutter.cs new file mode 100644 index 0000000..b39696c --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/BindingCutter.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Cutter + { + protected override void SetupBinding() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/Cutter.xaml b/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/Cutter.xaml new file mode 100644 index 0000000..dc6e2f9 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/Cutter.xaml @@ -0,0 +1,8 @@ + + + \ No newline at end of file diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/Cutter.xaml.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/Cutter.xaml.cs new file mode 100644 index 0000000..2197478 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/Cutter.xaml.cs @@ -0,0 +1,13 @@ +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Cutter : BaseView + { + public Cutter() + { + InitializeComponent(); + } + + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/EventsCutter.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/EventsCutter.cs new file mode 100644 index 0000000..6d04973 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/EventsCutter.cs @@ -0,0 +1,14 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Cutter + { + protected override void SetupEvents() + { + this.WhenViewModelAnyValue(disposable => + { + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/SubscriptionsCutter.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/SubscriptionsCutter.cs new file mode 100644 index 0000000..c92b2ac --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Cutter/SubscriptionsCutter.cs @@ -0,0 +1,15 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Cutter + { + protected override void SetupSubscriptions() + { + this.WhenViewModelAnyValue(disposable => + { + + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/BindingDraggableConnect.cs b/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/BindingDraggableConnect.cs new file mode 100644 index 0000000..ee1605d --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/BindingDraggableConnect.cs @@ -0,0 +1,25 @@ +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class DraggableConnect + { + protected override void SetupBinding() + { + this.WhenViewModelAnyValue(disposable => + { + this.OneWayBind(ViewModel, + x => x.StartPoint, + x=>x.PathFigureConnect.StartPoint) + .DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x => x.EndPoint, + x => x.BezierSegmentConnect.Point3) + .DisposeWith(disposable); + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/DraggableConnect.xaml b/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/DraggableConnect.xaml new file mode 100644 index 0000000..9488ba5 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/DraggableConnect.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/DraggableConnect.xaml.cs b/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/DraggableConnect.xaml.cs new file mode 100644 index 0000000..bdde5fb --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/DraggableConnect.xaml.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using System.Dynamic; +using System.Linq; +using Avalonia; +using Avalonia.Input; +using Avalonia.Media; +using Avalonia.VisualTree; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class DraggableConnect : BaseView, IDraggable + { + private readonly PathGeometry PathGeometryConnect; + private readonly PathFigure PathFigureConnect; + private BezierSegment BezierSegmentConnect; + private NodesCanvas _canvas; + public DraggableConnect() + { + InitializeComponent(); + PathGeometryConnect = PathConnect.Data as PathGeometry; + PathFigureConnect = PathGeometryConnect.Figures.First(); + BezierSegmentConnect = PathFigureConnect.Segments.First() as BezierSegment; + } + + public void StartDrag(params (string key, object value)[] parameters) + { + dynamic t = new ExpandoObject(); + t.StartPoint = new Point(); + var startPositionPair = parameters.FirstOrDefault(x => x.key == "StartPosition"); + var startPosition = (Point) startPositionPair.value; + this.IsVisible = true; + this.ViewModel.StartPoint = startPosition; + this.ViewModel.EndPoint = startPosition; + } + + public void DragOver(object handler, DragEventArgs e) + { + if (handler is NodesCanvas canvas) + { + this.ViewModel.EndPoint = e.GetPosition(canvas) - new Point(2, 2); + } + // throw new System.NotImplementedException(); + } + + public void Drop(object handler, DragEventArgs e) + { + this.IsVisible = false; + // throw new System.NotImplementedException(); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/EventsDraggableConnect.cs b/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/EventsDraggableConnect.cs new file mode 100644 index 0000000..d1f467d --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/EventsDraggableConnect.cs @@ -0,0 +1,95 @@ +using System.Reactive.Disposables; +using Avalonia.Input; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System; +using System.Linq; +using System.Net; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.Shapes; +using Avalonia.Interactivity; +using Avalonia.Remote.Protocol.Input; +using Avalonia.VisualTree; +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class DraggableConnect + { + private Node NodeTo = null; + string magnetClassName = "MagnetDragOver"; + protected override void SetupEvents() + { + this.WhenViewModelAnyValue(disposable => + { + // _canvas = this.FindAncestorOfType(); + // this.Events().PointerMoved.Subscribe(OnPointerMovedEvent).DisposeWith(disposable); + // this.Events().PointerReleased.Subscribe(OnPointerReleasedEvent).DisposeWith(disposable); + // AddHandler(DragDrop.DropEvent, OnNodesCanvasDragOver); + }); + } + // void OnNodesCanvasDragOver(object handler, DragEventArgs e) + // { + // var t = 5; + // // e.GetDraggable().DragOver(e.GetPosition(this)); + // } + // void OnPointerMovedEvent(PointerEventArgs e) + // { + // var point = e.GetPosition(_canvas); + // ViewModel.EndPoint = point - new Point(2,2); + // + // var node = FindNodeByInput(point); + // + // if (node is not null) + // { + // MagnetToNodeInput(node); + // AddClassToNodeInput(node, magnetClassName); + // } + // + // if (NodeTo != node) + // { + // RemoveClassFromNodeInput(NodeTo, magnetClassName); + // NodeTo = node; + // } + // + // } + // void OnPointerReleasedEvent(PointerEventArgs e) + // { + // var point = e.GetPosition(_canvas); + // // var node = FindNodeByInput(point); + // } + // + // Node FindNodeByInput(Point point) + // { + // var all = _canvas.GetInputElementsAt(point); + // var connector = all.Where(x => x is StyledElement styledElement && + // styledElement.Name.Contains(nameof(Node.InputConnector))) + // .Select(x => x.FindAncestorOfType()) + // .FirstOrDefault(x => x is not null); + // + // return connector; + // } + // + // void MagnetToNodeInput(Node node) + // { + // var connector = node.InputConnector; + // var ellipseConnector = connector.EllipseConnector; + // var positionConnectPoint = ellipseConnector. + // TranslatePoint(new Point(ellipseConnector.Width / 2, ellipseConnector.Height / 2), connector); + // var startPosition = connector.TranslatePoint(positionConnectPoint.Value, _canvas); + // ViewModel.EndPoint = startPosition.Value; + // } + // + // void AddClassToNodeInput(Node node, string className) + // { + // node?.InputConnector.EllipseConnector.Classes.Add(className); + // } + // + // + // void RemoveClassFromNodeInput(Node node, string className) + // { + // node?.InputConnector.EllipseConnector.Classes.Remove(className); + // } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/SubscriptionsDraggableConnect.cs b/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/SubscriptionsDraggableConnect.cs new file mode 100644 index 0000000..ac57a2e --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/DraggableConnector/SubscriptionsDraggableConnect.cs @@ -0,0 +1,31 @@ +using Avalonia; +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; +using System.Reactive.Linq; +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class DraggableConnect + { + protected override void SetupSubscriptions() + { + this.WhenViewModelAnyValue(disposable => + { + var points = ViewModel + .WhenAnyValue(x => x.StartPoint, + x => x.EndPoint) + .Select(points => Connect.UpdateMediumPoints(points.Item1, points.Item2)); + + points.Select(x => x.Point1) + .BindTo(BezierSegmentConnect, + x => x.Point1).DisposeWith(disposable); + + points.Select(x => x.Point2) + .BindTo(BezierSegmentConnect, + x => x.Point2).DisposeWith(disposable); + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/BindingMainWindow.cs b/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/BindingMainWindow.cs new file mode 100644 index 0000000..d00a183 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/BindingMainWindow.cs @@ -0,0 +1,17 @@ +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class MainWindow + { + protected virtual void SetupBinding() + { + this.WhenViewModelAnyValue(disposable => + { + this.OneWayBind(ViewModel, x => x.NodesCanvas, x => x.NodesCanvasMainWindow.ViewModel).DisposeWith(disposable); + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/EventsMainWindow.cs b/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/EventsMainWindow.cs new file mode 100644 index 0000000..39a674b --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/EventsMainWindow.cs @@ -0,0 +1,12 @@ +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class MainWindow + { + // protected override void SetupEvents() + // { + // this.WhenViewModelAnyValue(disposable => + // { + // }); + // } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/MainWindow.xaml b/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/MainWindow.xaml new file mode 100644 index 0000000..ab15c2d --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/MainWindow.xaml @@ -0,0 +1,14 @@ + + + + + + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/MainWindow.xaml.cs b/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/MainWindow.xaml.cs new file mode 100644 index 0000000..5f37ac6 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/MainWindow.xaml.cs @@ -0,0 +1,14 @@ +using Avalonia.ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class MainWindow : ReactiveWindow + { + public MainWindow() + { + InitializeComponent(); + SetupBinding(); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/SubscriptionsMainWindow.cs b/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/SubscriptionsMainWindow.cs new file mode 100644 index 0000000..1efb5b9 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/MainWindow/SubscriptionsMainWindow.cs @@ -0,0 +1,15 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class MainWindow + { + protected void SetupSubscriptions() + { + this.WhenViewModelAnyValue(disposable => + { + + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/BindingConnectors.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/BindingConnectors.cs new file mode 100644 index 0000000..d46c5b7 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/BindingConnectors.cs @@ -0,0 +1,18 @@ +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodeElements +{ + public partial class Connectors + { + protected override void SetupBinding() + { + this.WhenViewModelAnyValue(disposable => + { + //this.OneWayBind(this.ViewModel, x => x.ConnectorsForView, x => x.ItemsControlConnectors.Items).DisposeWith(disposable); + this.OneWayBind(ViewModel, x => x.ConnectorsForView, x => x.ListBoxConnectors.Items).DisposeWith(disposable); + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/Connectors.xaml b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/Connectors.xaml new file mode 100644 index 0000000..7aa2104 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/Connectors.xaml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/Connectors.xaml.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/Connectors.xaml.cs new file mode 100644 index 0000000..79aea74 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/Connectors.xaml.cs @@ -0,0 +1,12 @@ +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodeElements +{ + public partial class Connectors: BaseView + { + public Connectors() + { + InitializeComponent(); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/EventsConnector.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/EventsConnector.cs new file mode 100644 index 0000000..8e157fb --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/EventsConnector.cs @@ -0,0 +1,28 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using Avalonia.Controls; +using Avalonia.Controls.Presenters; +using Avalonia.Input; +using Avalonia.Interactivity; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodeElements +{ + public partial class Connectors + { + protected override void SetupEvents() + { + this.WhenViewModelAnyValue(disposable => + { + ListBoxConnectors.AddHandler(PointerPressedEvent, OnListBoxPointerPressed, RoutingStrategies.Bubble,true); + }); + } + + public void OnListBoxPointerPressed(object sender, PointerPressedEventArgs e) + { + //If is not textbox - can be moved + if (e.Source is not TextPresenter) + { + e.Handled = false; + } + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/SubscriptionsConnectors.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/SubscriptionsConnectors.cs new file mode 100644 index 0000000..c6434e9 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Connectors/SubscriptionsConnectors.cs @@ -0,0 +1,15 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodeElements +{ + public partial class Connectors + { + protected override void SetupSubscriptions() + { + this.WhenViewModelAnyValue(disposable => + { + + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/BindingHeader.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/BindingHeader.cs new file mode 100644 index 0000000..919cd1e --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/BindingHeader.cs @@ -0,0 +1,19 @@ +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodeElements +{ + public partial class Header + { + protected override void SetupBinding() + { + this.WhenViewModelAnyValue(disposable => + { + this.OneWayBind(ViewModel, x => x.Name.Value, x => x.TextBoxHeader.Text).DisposeWith(disposable); + this.OneWayBind(ViewModel, x => x.Name.IsEnabled, x => x.TextBoxHeader.IsEnabled).DisposeWith(disposable); + this.Bind(ViewModel, x => x.IsCollapse, x => x.ToggleButtonHeader.IsChecked).DisposeWith(disposable); + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/EventsHeader.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/EventsHeader.cs new file mode 100644 index 0000000..4b4a49c --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/EventsHeader.cs @@ -0,0 +1,34 @@ +using System.Reactive.Disposables; +using Avalonia.Input; +using Avalonia.Interactivity; +using Avalonia.OpenGL.Egl; +using System; +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodeElements +{ + public partial class Header + { + protected override void SetupEvents() + { + this.WhenViewModelAnyValue(disposable => + { + this.Events().DoubleTapped.Subscribe(OnTextBoxHeaderDoubleTappedEvent).DisposeWith(disposable); + this.TextBoxHeader.Events().LostFocus.Subscribe(OnLostFocusEvent).DisposeWith(disposable); + }); + } + + protected virtual void OnTextBoxHeaderDoubleTappedEvent(RoutedEventArgs e) + { + TextBoxHeader.IsHitTestVisible = true; + TextBoxHeader.Focus(); + TextBoxHeader.CaretIndex = TextBoxHeader.Text.Length; + TextBoxHeader.ClearSelection(); + } + + protected virtual void OnLostFocusEvent(RoutedEventArgs e) + { + TextBoxHeader.IsHitTestVisible = false; + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/Header.xaml b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/Header.xaml new file mode 100644 index 0000000..312e0e7 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/Header.xaml @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/Header.xaml.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/Header.xaml.cs new file mode 100644 index 0000000..e79a4e1 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/Header.xaml.cs @@ -0,0 +1,13 @@ +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodeElements +{ + public partial class Header : BaseView + { + public Header() + { + InitializeComponent(); + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/SubscriptionsHeader.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/SubscriptionsHeader.cs new file mode 100644 index 0000000..1c6ee00 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Header/SubscriptionsHeader.cs @@ -0,0 +1,15 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodeElements +{ + public partial class Header + { + protected override void SetupSubscriptions() + { + this.WhenViewModelAnyValue(disposable => + { + + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/BindingNode.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/BindingNode.cs new file mode 100644 index 0000000..ef2379f --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/BindingNode.cs @@ -0,0 +1,84 @@ +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; +using Avalonia.Controls; +using Avalonia; +using ReactiveUI; +using System; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; +using System.Reactive.Linq; +using Avalonia.VisualTree; + + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Node + { + protected override void SetupBinding() + { + + this.WhenViewModelAnyValue(disposable => + { + _canvas = this.FindAncestorOfType(); + this.OneWayBind(ViewModel, + x => x.Header, + x => x.Header.ViewModel) + .DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x=>x.IsSelect, + x=>x.IsSelect) + .DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x => x.Connectors, + x => x.Connectors.ViewModel) + .DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x => x.Input, + x => x.InputConnector.ViewModel) + .DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x => x.Output, + x => x.OutputConnector.ViewModel) + .DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x => x.Header.IsCollapse, + x => x.Connectors.IsVisible, + x=>!x).DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x => x.Header.IsCollapse, + x => x.OutputConnector.IsVisible) + .DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x=>x.Point1.X, + x=>x.TranslateTransformNode.X) + .DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x => x.Point1.Y, + x => x.TranslateTransformNode.Y) + .DisposeWith(disposable); + + + ViewModel.WhenAnyValue(x => x.Point1.X) + .BindTo(this, x => x.Parent.ZIndex) + .DisposeWith(disposable); + }); + } + + // void InputConnectUpdateClasses(bool magnetDragOver) + // { + // if(magnetDragOver) + // this.InputConnector.Classes.Add("MagnetDragOver"); + // else + // this.InputConnector.Classes.Remove("MagnetDragOver"); + // } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/CommandsNode.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/CommandsNode.cs new file mode 100644 index 0000000..a4470b7 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/CommandsNode.cs @@ -0,0 +1,7 @@ +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Node + { + + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/EventsNode.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/EventsNode.cs new file mode 100644 index 0000000..b2b477a --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/EventsNode.cs @@ -0,0 +1,44 @@ +using Avalonia; +using Avalonia.Input; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System; +using System.Reactive.Disposables; +using Avalonia.VisualTree; +using SimpleStateMachineNodeEditor.Helpers.Extensions; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Node + { + private Point oldPosition; + protected override void SetupEvents() + { + this.WhenViewModelAnyValue(disposable => + { + BorderNode.Events().PointerPressed.Subscribe(OnEventBorderPointerPressed).DisposeWith(disposable); + BorderNode.Events().PointerReleased.Subscribe(OnEventBorderPointerReleased).DisposeWith(disposable); + // AddHandler(); + // InputConnectorMagnetBorder.AddHandler(DragDrop.); + }); + } + + private void OnEventBorderPointerPressed(PointerPressedEventArgs e) + { + ViewModel.SelectCommand.ExecuteWithSubscribe((e.KeyModifiers & KeyModifiers.Control)!= 0 ? SelectMode.ClickWithCtrl : SelectMode.Click); + oldPosition = e.GetPosition(_canvas); + PointerMoved += OnEventPointerMoved; + } + + private void OnEventBorderPointerReleased(PointerReleasedEventArgs e) + { + PointerMoved -= OnEventPointerMoved; + } + + private void OnEventPointerMoved(object subject, PointerEventArgs e) + { + var currentPosition = e.GetPosition(_canvas); + ViewModel.NodesCanvas.Nodes.MoveCommand.ExecuteWithSubscribe(currentPosition - oldPosition); + oldPosition = currentPosition; + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/Node.xaml b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/Node.xaml new file mode 100644 index 0000000..4f95338 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/Node.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/Node.xaml.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/Node.xaml.cs new file mode 100644 index 0000000..b26dd85 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/Node.xaml.cs @@ -0,0 +1,34 @@ +using System; +using Avalonia; +using Avalonia.Media; +using Avalonia.VisualTree; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Node : BaseView + { + private NodesCanvas _canvas; + + #region IsSelectProperty + + public static readonly AvaloniaProperty IsSelectProperty = + AvaloniaProperty.Register("IsSelect", inherits: true); + public bool IsSelect + { + get => this.GetValue(IsSelectProperty); + set => SetValue(IsSelectProperty, value); + } + + #endregion + + public TranslateTransform TranslateTransformNode; + public Node() + { + InitializeComponent(); + TranslateTransformNode = RenderTransform as TranslateTransform; + } + + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/SubscriptionsNode.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/SubscriptionsNode.cs new file mode 100644 index 0000000..50ea4c2 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Node/Node/SubscriptionsNode.cs @@ -0,0 +1,15 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Node + { + protected override void SetupSubscriptions() + { + this.WhenViewModelAnyValue(disposable => + { + + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/BindingConnects.cs b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/BindingConnects.cs new file mode 100644 index 0000000..cc34d41 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/BindingConnects.cs @@ -0,0 +1,17 @@ +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodesCanvasElements +{ + public partial class Connects + { + protected override void SetupBinding() + { + this.WhenViewModelAnyValue(disposable => + { + this.OneWayBind(ViewModel, x => x.ConnectsForView, x => x.ItemsControlConnects.Items).DisposeWith(disposable); + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/Connects.xaml b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/Connects.xaml new file mode 100644 index 0000000..eca2905 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/Connects.xaml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/Connects.xaml.cs b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/Connects.xaml.cs new file mode 100644 index 0000000..55a4b1b --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/Connects.xaml.cs @@ -0,0 +1,12 @@ +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodesCanvasElements +{ + public partial class Connects : BaseView + { + public Connects() + { + InitializeComponent(); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/EventsConnects.cs b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/EventsConnects.cs new file mode 100644 index 0000000..b204a09 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/EventsConnects.cs @@ -0,0 +1,14 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodesCanvasElements +{ + public partial class Connects + { + protected override void SetupEvents() + { + this.WhenViewModelAnyValue(disposable => + { + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/SubscriptionsConnects.cs b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/SubscriptionsConnects.cs new file mode 100644 index 0000000..e2dabc3 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Connects/SubscriptionsConnects.cs @@ -0,0 +1,15 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodesCanvasElements +{ + public partial class Connects + { + protected override void SetupSubscriptions() + { + this.WhenViewModelAnyValue(disposable => + { + + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/BindingNodes.cs b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/BindingNodes.cs new file mode 100644 index 0000000..1249450 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/BindingNodes.cs @@ -0,0 +1,19 @@ +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodesCanvasElements +{ + public partial class Nodes + { + protected override void SetupBinding() + { + this.WhenViewModelAnyValue(disposable => + { + this.OneWayBind(ViewModel, + x => x.NodesForView, + x => x.ItemsControlNodes.Items).DisposeWith(disposable); + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/EventsNodes.cs b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/EventsNodes.cs new file mode 100644 index 0000000..1a99a78 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/EventsNodes.cs @@ -0,0 +1,15 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodesCanvasElements +{ + public partial class Nodes + { + protected override void SetupEvents() + { + this.WhenViewModelAnyValue(disposable => + { + }); + } + + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/Nodes.xaml b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/Nodes.xaml new file mode 100644 index 0000000..61797b8 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/Nodes.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/Nodes.xaml.cs b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/Nodes.xaml.cs new file mode 100644 index 0000000..3121afd --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/Nodes.xaml.cs @@ -0,0 +1,13 @@ +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodesCanvasElements +{ + public partial class Nodes : BaseView + { + public Nodes() + { + InitializeComponent(); + } + + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/SubscriptionsNodes.cs b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/SubscriptionsNodes.cs new file mode 100644 index 0000000..0c9e9c5 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/Nodes/SubscriptionsNodes.cs @@ -0,0 +1,15 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views.NodesCanvasElements +{ + public partial class Nodes + { + protected override void SetupSubscriptions() + { + this.WhenViewModelAnyValue(disposable => + { + + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/BindingNodesCanvas.cs b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/BindingNodesCanvas.cs new file mode 100644 index 0000000..ed16c23 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/BindingNodesCanvas.cs @@ -0,0 +1,37 @@ +using ReactiveUI; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using System.Reactive.Disposables; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class NodesCanvas + { + protected override void SetupBinding() + { + this.WhenViewModelAnyValue(disposable => + { + this.OneWayBind(ViewModel, + x => x.Nodes, + x => x.NodesNodesCanvas.ViewModel).DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x => x.Connects, + x => x.ConnectsNodesCanvas.ViewModel).DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x => x.Selector, + x => x.SelectorNodesCanvas.ViewModel).DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x => x.Cutter, + x => x.CutterNodesCanvas.ViewModel).DisposeWith(disposable); + + this.OneWayBind(ViewModel, + x => x.DraggableConnector, + x => x.DraggableConnect.ViewModel).DisposeWith(disposable); + }); + } + + } +} + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/EventsNodesCanvas.cs b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/EventsNodesCanvas.cs new file mode 100644 index 0000000..e475517 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/EventsNodesCanvas.cs @@ -0,0 +1,21 @@ +using Avalonia.Input; +using SimpleStateMachineNodeEditorAvalonia.Helpers; + + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class NodesCanvas + { + protected override void SetupEvents() + { + this.WhenViewModelAnyValue(disposable => + { + AddHandler(DragDrop.DragOverEvent, HelperDragDrop.DragDraggableOverDelegate); + AddHandler(DragDrop.DropEvent, HelperDragDrop.DropDraggableDelegate); + }); + } + + + } +} + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/NodesCanvas.xaml b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/NodesCanvas.xaml new file mode 100644 index 0000000..63693dc --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/NodesCanvas.xaml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/NodesCanvas.xaml.cs b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/NodesCanvas.xaml.cs new file mode 100644 index 0000000..6f590aa --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/NodesCanvas.xaml.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using System.Dynamic; +using Avalonia; +using Avalonia.Input; +using SimpleStateMachineNodeEditorAvalonia.Helpers; +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class NodesCanvas : BaseView + { + public NodesCanvas() + { + InitializeComponent(); + } + public void StartDrag(PointerEventArgs e, Point startPosition) + { + DraggableConnect.DoDragDrop(e, ("StartPosition", startPosition)); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/SubscriptionsNodesCanvas.cs b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/SubscriptionsNodesCanvas.cs new file mode 100644 index 0000000..5943da0 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/NodesCanvas/NodesCanvas/SubscriptionsNodesCanvas.cs @@ -0,0 +1,16 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class NodesCanvas + { + protected override void SetupSubscriptions() + { + this.WhenViewModelAnyValue(disposable => + { + + }); + } + } +} + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Selector/BindingSelector.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Selector/BindingSelector.cs new file mode 100644 index 0000000..f28f753 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Selector/BindingSelector.cs @@ -0,0 +1,10 @@ +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Selector + { + protected override void SetupBinding() + { + + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Selector/EventsSelector.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Selector/EventsSelector.cs new file mode 100644 index 0000000..667a8a4 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Selector/EventsSelector.cs @@ -0,0 +1,14 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Selector + { + protected override void SetupEvents() + { + this.WhenViewModelAnyValue(disposable => + { + }); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Selector/Selector.xaml b/SimpleStateMachineNodeEditorAvalonia/Views/Selector/Selector.xaml new file mode 100644 index 0000000..e93a7f7 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Selector/Selector.xaml @@ -0,0 +1,17 @@ + + + + + diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Selector/Selector.xaml.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Selector/Selector.xaml.cs new file mode 100644 index 0000000..bc9ba46 --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Selector/Selector.xaml.cs @@ -0,0 +1,18 @@ +using Avalonia.Markup.Xaml; +using SimpleStateMachineNodeEditorAvalonia.ViewModels; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Selector : BaseView + { + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + public Selector() + { + + InitializeComponent(); + } + } +} diff --git a/SimpleStateMachineNodeEditorAvalonia/Views/Selector/SubscriptionsSelector.cs b/SimpleStateMachineNodeEditorAvalonia/Views/Selector/SubscriptionsSelector.cs new file mode 100644 index 0000000..bbdb39b --- /dev/null +++ b/SimpleStateMachineNodeEditorAvalonia/Views/Selector/SubscriptionsSelector.cs @@ -0,0 +1,15 @@ +using SimpleStateMachineNodeEditorAvalonia.Helpers; + +namespace SimpleStateMachineNodeEditorAvalonia.Views +{ + public partial class Selector + { + protected override void SetupSubscriptions() + { + this.WhenViewModelAnyValue(disposable => + { + + }); + } + } +} diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..6c273ab --- /dev/null +++ b/nuget.config @@ -0,0 +1,11 @@ + + + + + + + + +