diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index b692b6b..dee5ecd 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,3 @@ # These are supported funding model platforms -custom: ['paypal.me/romansolovyov'] +open_collective: simplestatemachine diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..a3936a2 --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,25 @@ +name: .NET + +on: + push: + branches: [ ToAvaloniaUI ] + pull_request: + branches: [ ToAvaloniaUI ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal diff --git a/README.md b/README.md index 10a0d2e..d69992f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ - - - -# StateMachineNodeEditor [![](https://img.shields.io/github/v/release/SimpleStateMachine/SimpleStateMachineNodeEditor)](https://github.com/SimpleStateMachine/SimpleStateMachineNodeEditor/releases) [![](https://img.shields.io/github/stars/SimpleStateMachine/SimpleStateMachineNodeEditor)](https://github.com/SimpleStateMachine/SimpleStateMachineNodeEditor) [![](https://img.shields.io/github/license/SimpleStateMachine/SimpleStateMachineNodeEditor)](https://github.com/SimpleStateMachine/SimpleStateMachineNodeEditor) [![](https://img.shields.io/badge/chat-slack-blueviolet.svg)](https://join.slack.com/t/simplestatemachine/shared_invite/zt-fnfhvvsx-fTejcpPn~PPb2ojdG_MQBg) - StateMachineNodeEditor is a WPF node-editor for visual work and editoring state-machine + [![](https://img.shields.io/github/v/release/SimpleStateMachine/SimpleStateMachineNodeEditor)](https://github.com/SimpleStateMachine/SimpleStateMachineNodeEditor/releases) [![](https://img.shields.io/github/stars/SimpleStateMachine/SimpleStateMachineNodeEditor)](https://github.com/SimpleStateMachine/SimpleStateMachineNodeEditor) [![](https://img.shields.io/github/license/SimpleStateMachine/SimpleStateMachineNodeEditor)](https://github.com/SimpleStateMachine/SimpleStateMachineNodeEditor) [![](https://img.shields.io/github/languages/code-size/SimpleStateMachine/SimpleStateMachineNodeEditor)](https://github.com/SimpleStateMachine/SimpleStateMachineNodeEditor) + [![]( https://img.shields.io/github/last-commit/SimpleStateMachine/SimpleStateMachineNodeEditor/ToAvaloniaUI)](https://github.com/SimpleStateMachine/SimpleStateMachineNodeEditor) [![](https://img.shields.io/badge/chat-slack-blueviolet.svg)](https://join.slack.com/t/simplestatemachine/shared_invite/zt-fnfhvvsx-fTejcpPn~PPb2ojdG_MQBg) [![](https://img.shields.io/badge/chat-telegram-blue.svg)](https://t.me/joinchat/HMLJFkv9do6aDV188rhd0w) + [![Build Status](https://dev.azure.com/GMIKE/SimpleStateMachineNodeEditor/_apis/build/status/SimpleStateMachine.SimpleStateMachineNodeEditor?branchName=master)](https://dev.azure.com/GMIKE/SimpleStateMachineNodeEditor/_build/latest?definitionId=1&branchName=master) + + # SimpleStateMachineNodeEditor + + SimpleStateMachineNodeEditor is a WPF node-editor for visual work and editoring state-machine ## Give a Star! :star: If you like or are using this project please give it a star. Thanks! @@ -49,15 +51,20 @@ If you like or are using this project please give it a star. Thanks! - - - + + + + + + + + ``` ### Save work space as PNG/JPEG @@ -71,7 +78,6 @@ If you like or are using this project please give it a star. Thanks! **3.** Run the exe file - ## Shortcuts📎 * Ctrl +A = Select All Nodes * Ctrl + S = Save @@ -97,6 +103,14 @@ If you like or are using this project please give it a star. Thanks! * C + Delete = Delete Selected Connector * N + Delete = Delete Selected Nodes + ## FAQ❔ + If you think you have found a bug, create a github [issue](https://github.com/SimpleStateMachine/SimpleStateMachineNodeEditor/issues). + + But if you just have questions about how to use: + +- [Slack channel](https://join.slack.com/t/simplestatemachine/shared_invite/zt-fnfhvvsx-fTejcpPn~PPb2ojdG_MQBg) +- [Telegram channel](https://t.me/joinchat/HMLJFkv9do6aDV188rhd0w) + ## License📑 Copyright (c) SimpleStateMachine diff --git a/SimpleStateMachineNodeEditor/App.xaml.cs b/SimpleStateMachineNodeEditor/App.xaml.cs index 0d61160..07c417c 100644 --- a/SimpleStateMachineNodeEditor/App.xaml.cs +++ b/SimpleStateMachineNodeEditor/App.xaml.cs @@ -1,9 +1,9 @@ using System.Reflection; using Microsoft.Extensions.Configuration; using ReactiveUI; -using SimpleStateMachineNodeEditor.Helpers.Configuration; using Splat; using SimpleStateMachineNodeEditor.Helpers.Converters; +using WritableJsonConfiguration; using Application = System.Windows.Application; namespace SimpleStateMachineNodeEditor @@ -18,16 +18,8 @@ public App() Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetCallingAssembly()); Locator.CurrentMutable.RegisterConstant(new ConverterBoolAndVisibility(), typeof(IBindingTypeConverter)); - IConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); - IConfigurationRoot configuration = configurationBuilder.Add(s => - { - s.FileProvider = null; - s.Path = "Settings.json"; - s.Optional = true; - s.ReloadOnChange = true; - s.ResolveFileProvider(); - }).Build(); - + IConfigurationRoot configuration; + configuration = WritableJsonConfigurationFabric.Create("Settings.json"); Locator.CurrentMutable.RegisterConstant(configuration, typeof(IConfiguration)); } } diff --git a/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationProvider.cs b/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationProvider.cs deleted file mode 100644 index be17ef1..0000000 --- a/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationProvider.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.IO; -using Microsoft.Extensions.Configuration.Json; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace SimpleStateMachineNodeEditor.Helpers.Configuration -{ - public class WritableJsonConfigurationProvider : JsonConfigurationProvider - { - public WritableJsonConfigurationProvider(JsonConfigurationSource source) : base(source) - { - } - - private void Save(dynamic jsonObj) - { - var fileFullPath = base.Source.FileProvider.GetFileInfo(base.Source.Path).PhysicalPath; - string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); - File.WriteAllText(fileFullPath, output); - } - - private void SetValue(string key, string value, dynamic jsonObj) - { - base.Set(key, value); - var split = key.Split(":"); - var context = jsonObj; - for (int i = 0; i < split.Length; i++) - { - var currentKey = split[i]; - if (i < split.Length - 1) - { - var child = jsonObj[currentKey]; - if (child == null) - { - context[currentKey] = new JObject(); - } - context = context[currentKey]; - } - else - { - context[currentKey] = value; - } - } - } - - private dynamic GetJsonObj() - { - var fileFullPath = base.Source.FileProvider.GetFileInfo(base.Source.Path).PhysicalPath; - var json = File.Exists(fileFullPath) ? File.ReadAllText(fileFullPath) : "{}"; - return JsonConvert.DeserializeObject(json); - } - - public override void Set(string key, string value) - { - var jsonObj = GetJsonObj(); - SetValue(key, value, jsonObj); - Save(jsonObj); - } - - public void Set(string key, object value) - { - var jsonObj = GetJsonObj(); - var serialized = JsonConvert.SerializeObject(value); - var jToken = JsonConvert.DeserializeObject(serialized) as JToken ?? new JValue(value); - WalkAndSet(key, jToken, jsonObj); - Save(jsonObj); - } - - private void WalkAndSet(string key, JToken value, dynamic jsonObj) - { - switch (value) - { - case JArray jArray: - { - //TODO Realize arrays - break; - } - case JObject jObject: - { - foreach (var propertyInfo in jObject.Properties()) - { - var propName = propertyInfo.Name; - var currentKey = key == null ? propName : $"{key}:{propName}"; - var propValue = propertyInfo.Value; - WalkAndSet(currentKey, propValue, jsonObj); - } - break; - } - case JValue jValue: - { - SetValue(key, jValue.ToString(), jsonObj); - break; - } - default: - throw new ArgumentOutOfRangeException(nameof(value)); - } - } - } -} \ No newline at end of file diff --git a/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationProviderExtensions.cs b/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationProviderExtensions.cs deleted file mode 100644 index bf38a50..0000000 --- a/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationProviderExtensions.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; -using Microsoft.Extensions.Configuration; - -namespace SimpleStateMachineNodeEditor.Helpers.Configuration -{ - public static class WritableJsonConfigurationProviderExtensions - { - public static void Set(this IConfiguration configuration, object value) - { - switch (configuration) - { - case IConfigurationRoot configurationRoot: - { - var provider = configurationRoot.Providers.First(p => p is WritableJsonConfigurationProvider) as WritableJsonConfigurationProvider; - provider.Set(null, value); - break; - } - case ConfigurationSection configurationSection: - { - var rootProp = typeof(ConfigurationSection).GetField("_root", BindingFlags.NonPublic | BindingFlags.Instance); ; - var root = rootProp.GetValue(configurationSection) as IConfigurationRoot; - var provider = root.Providers.First(p => p is WritableJsonConfigurationProvider) as WritableJsonConfigurationProvider; - provider.Set(configurationSection.Path, value); - break; - } - default: - throw new ArgumentOutOfRangeException(nameof(configuration)); - } - } - } -} \ No newline at end of file diff --git a/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationSource.cs b/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationSource.cs deleted file mode 100644 index fdd871d..0000000 --- a/SimpleStateMachineNodeEditor/Helpers/Configuration/WritableJsonConfigurationSource.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Configuration.Json; - -namespace SimpleStateMachineNodeEditor.Helpers.Configuration -{ - public class WritableJsonConfigurationSource : JsonConfigurationSource - { - public override IConfigurationProvider Build(IConfigurationBuilder builder) - { - this.EnsureDefaults(builder); - return (IConfigurationProvider)new WritableJsonConfigurationProvider(this); - } - } -} \ No newline at end of file diff --git a/SimpleStateMachineNodeEditor/SimpleStateMachineNodeEditor.csproj b/SimpleStateMachineNodeEditor/SimpleStateMachineNodeEditor.csproj index 479dbcb..11538cd 100644 --- a/SimpleStateMachineNodeEditor/SimpleStateMachineNodeEditor.csproj +++ b/SimpleStateMachineNodeEditor/SimpleStateMachineNodeEditor.csproj @@ -7,7 +7,7 @@ SimpleStateMachineNodeEditor.App StateMachine.ico false - 1.1.0 + 2.0.0 MIT https://github.com/SimpleStateMachine/SimpleStateMachineNodeEditor SimpleStateMachine.png @@ -15,11 +15,11 @@ statemachine state-machine finite-state-machine false Node editor for SimpleStateMachine - 1.1.0.0 - 1.1.0.0 - Table of transitions -Fix for read start state -ReactiveUI 11.4.17 + 2.0.0.0 + 2.0.0.0 + Correct scaling +Config for save last selected theme +New format for xml file with schemes @@ -64,7 +64,7 @@ ReactiveUI 11.4.17 - + @@ -72,6 +72,7 @@ ReactiveUI 11.4.17 + diff --git a/SimpleStateMachineNodeEditor/ViewModel/NodesCanvas/NodesCanvasCommandsViewModel.cs b/SimpleStateMachineNodeEditor/ViewModel/NodesCanvas/NodesCanvasCommandsViewModel.cs index c252718..1ae6cc2 100644 --- a/SimpleStateMachineNodeEditor/ViewModel/NodesCanvas/NodesCanvasCommandsViewModel.cs +++ b/SimpleStateMachineNodeEditor/ViewModel/NodesCanvas/NodesCanvasCommandsViewModel.cs @@ -1,4 +1,4 @@ -using DynamicData; +using DynamicData; using ReactiveUI; using SimpleStateMachineNodeEditor.Helpers; using SimpleStateMachineNodeEditor.Helpers.Commands; @@ -13,7 +13,6 @@ using System.Windows.Input; using System.Xml.Linq; using Microsoft.Extensions.Configuration; -using SimpleStateMachineNodeEditor.Helpers.Configuration; using Splat; using System.Drawing.Drawing2D; using System.Windows.Media; diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..8d1f537 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,21 @@ +jobs: +- job: Windows + pool: + vmImage: 'windows-2019' + variables: + buildConfiguration: 'Release' + steps: + - task: DotNetCoreInstaller@0 + inputs: + version: '3.1.302' + - script: cd $(Build.SourcesDirectory) && dotnet build + displayName: 'Windows Full Build and Tests' + - task: PublishTestResults@2 + inputs: + testRunner: VSTest + testResultsFiles: '**/*.trx' + - task: PublishCodeCoverageResults@1 + inputs: + summaryFileLocation: $(Build.SourcesDirectory)\artifacts\coverage.cobertura.xml + reportDirectory: $(Build.SourcesDirectory)\artifacts + codecoverageTool: cobertura