public static void SetInterfaceName(this ProjectEditorViewModel vm, string callableMethodSignature, string interfaceName) { vm.CurrentProject.Interfaces .First(x => x.CallableMethodsSignature == callableMethodSignature) .Name = interfaceName; }
private static ProjectEditorViewModel CreateCSharpProjectEditorViewModel() { ProjectEditorViewModel vm = new ProjectEditorViewModel(); vm.StartNewProject(OutputLanguageFactory.GetLanguages().First(x => x.Name == "C#")); return(vm); }
public void Test_CreateNewViewModel() { ProjectEditorViewModel vm = new ProjectEditorViewModel(); // Assertions vm.OutputLanguages.Count.ShouldBe(1); vm.OutputLanguages.Exists(ol => ol.Name == "C#").ShouldBeTrue(); vm.CurrentProject.ShouldBeNull(); }
public void Test_StartNewProject() { ProjectEditorViewModel vm = new ProjectEditorViewModel(); OutputLanguage outputLanguage = vm.OutputLanguages.First(ol => ol.Name == "C#"); vm.StartNewProject(outputLanguage); // Assertions vm.CurrentProject.ShouldNotBeNull(); vm.CurrentProject.Datatypes.Count.ShouldBe(17); }
public static void SetCallableMethods(this ProjectEditorViewModel vm, string chainStartingMethodName, params string[] callableMethods) { foreach (CallableMethodIndicator method in vm.CurrentProject.ChainStartingMethods .First(x => x.Name == chainStartingMethodName) .MethodsCallableNext) { if (callableMethods.Contains(method.Name)) { method.CanCall = true; } } }
private bool Validate(ProjectEditorViewModel editorViewModel, object sender, DragEventArgs e, bool bExecute) { var point = GetPosition(sender, e); if (e.Data.Contains(DataFormats.Text)) { var text = e.Data.GetText(); if (bExecute) { editorViewModel?.OnTryPaste(text); } return(true); } foreach (var format in e.Data.GetDataFormats()) { var data = e.Data.Get(format); switch (data) { case BaseShapeViewModel shape: return(editorViewModel?.OnDropShape(shape, point.X, point.Y, bExecute) == true); case RecordViewModel record: return(editorViewModel?.OnDropRecord(record, point.X, point.Y, bExecute) == true); case ShapeStyleViewModel style: return(editorViewModel?.OnDropStyle(style, point.X, point.Y, bExecute) == true); case TemplateContainerViewModel template: return(editorViewModel?.OnDropTemplate(template, point.X, point.Y, bExecute) == true); default: break; } } if (e.Data.Contains(DataFormats.FileNames)) { var files = e.Data.GetFileNames().ToArray(); if (bExecute) { editorViewModel?.OnDropFiles(files, point.X, point.Y); } return(true); } return(false); }
private static void LoadLayout(ProjectEditorViewModel editor, IRootDock layout) { if (editor.DockFactory is IFactory dockFactory) { editor.RootDock = layout; if (editor.RootDock is IDock dock) { dockFactory.InitLayout(dock); editor.NavigateTo = id => dock.Navigate.Execute(id); dock.Navigate.Execute("Dashboard"); } } }
private static void CreateLayout(ProjectEditorViewModel editor) { if (editor.DockFactory is IFactory dockFactory) { editor.RootDock = dockFactory.CreateLayout(); if (editor.RootDock is IDock dock) { dockFactory.InitLayout(dock); dockFactory.GetDockable <IDocumentDock>("Pages")?.CreateDocument?.Execute(null); editor.NavigateTo = id => dock.Navigate.Execute(id); dock.Navigate.Execute("Dashboard"); } } }
public void Test_CreateEmailBuilderFluentInterfaceFiles() { ProjectEditorViewModel vm = CreateCSharpProjectEditorViewModel(); // Set project properties vm.CurrentProject.Name = "Email"; vm.CurrentProject.FactoryClassNamespace = "Engine"; // Add instantiating method(s) vm.MethodUnderEdit.Group = Method.MethodGroup.Instantiating; vm.MethodUnderEdit.Name = "CreateEmailFrom"; vm.SetMethodParameterPropertiesTo("string", "emailAddress"); vm.AddNewMethod(); // Add chaining method(s) vm.MethodUnderEdit.Group = Method.MethodGroup.Chaining; vm.MethodUnderEdit.Name = "To"; vm.SetMethodParameterPropertiesTo("string", "emailAddress"); vm.AddNewMethod(); vm.MethodUnderEdit.Group = Method.MethodGroup.Chaining; vm.MethodUnderEdit.Name = "Subject"; vm.SetMethodParameterPropertiesTo("string", "subject"); vm.AddNewMethod(); vm.MethodUnderEdit.Group = Method.MethodGroup.Chaining; vm.MethodUnderEdit.Name = "Body"; vm.SetMethodParameterPropertiesTo("string", "body"); vm.AddNewMethod(); // Add executing method(s) vm.MethodUnderEdit.Group = Method.MethodGroup.Executing; vm.MethodUnderEdit.Name = "Send"; vm.MethodUnderEdit.ReturnDatatype = vm.DatatypeOf("void"); vm.AddNewMethod(); // Set callable methods vm.SetCallableMethods("CreateEmailFrom", "To"); vm.SetCallableMethods("To", "To"); vm.SetCallableMethods("To", "Subject"); vm.SetCallableMethods("Subject", "Body"); vm.SetCallableMethods("Body", "Send"); vm.RefreshInterfaces(); // Name interfaces vm.CurrentProject.Interfaces.Count.ShouldBe(4); vm.SetInterfaceName("Chaining:To", "ICanSetTo"); vm.SetInterfaceName("Chaining:Subject|Chaining:To", "ICanSetToOrSubject"); vm.SetInterfaceName("Chaining:Body", "ICanSetBody"); vm.SetInterfaceName("Executing:Send", "ICanSend"); // Perform tests vm.CurrentProject.OutputLanguage.Name.ShouldBe("C#"); vm.CurrentProject.FactoryClassName.ShouldBe("EmailBuilder"); vm.CurrentProject.InstantiatingMethods.Count.ShouldBe(1); vm.CurrentProject.ChainingMethods.Count.ShouldBe(3); vm.CurrentProject.ExecutingMethods.Count.ShouldBe(1); IFluentInterfaceCreator creator = FluentInterfaceCreatorFactory.GetFluentInterfaceFileCreator(vm.CurrentProject); // Test single file matches expected output FluentInterfaceFile singleFile = creator.CreateInSingleFile(); singleFile.Name.ShouldBe("EmailBuilder.cs"); singleFile.FormattedText().ShouldBe(TextIn("SingleFile.EmailBuilder.txt")); // Test multiple file matches expected output IEnumerable <FluentInterfaceFile> multipleFiles = creator.CreateInMultipleFiles().ToList(); multipleFiles.Count().ShouldBe(5); multipleFiles.First(x => x.Name == "EmailBuilder.cs") .FormattedText().ShouldBe(TextIn("MultipleFiles.EmailBuilder.txt")); multipleFiles.First(x => x.Name == "ICanSetTo.cs") .FormattedText().ShouldBe(TextIn("MultipleFiles.ICanSetTo.txt")); multipleFiles.First(x => x.Name == "ICanSetToOrSubject.cs") .FormattedText().ShouldBe(TextIn("MultipleFiles.ICanSetToOrSubject.txt")); multipleFiles.First(x => x.Name == "ICanSetBody.cs") .FormattedText().ShouldBe(TextIn("MultipleFiles.ICanSetBody.txt")); multipleFiles.First(x => x.Name == "ICanSend.cs") .FormattedText().ShouldBe(TextIn("MultipleFiles.ICanSend.txt")); }
public static void SetMethodParameterPropertiesTo(this ProjectEditorViewModel vm, string datatype, string name) { vm.ParameterUnderEdit.Datatype = vm.DatatypeOf(datatype); vm.ParameterUnderEdit.Name = name; vm.AddParameterToMethod(); }
public static Datatype DatatypeOf(this ProjectEditorViewModel vm, string datatype) { return(vm.CurrentProject.Datatypes.First(x => x.Name.Equals(datatype, StringComparison.CurrentCultureIgnoreCase))); }
public static Window InitializationClassicDesktopStyle(IClassicDesktopStyleApplicationLifetime?desktopLifetime, out ProjectEditorViewModel editor) { var jsonSettings = new JsonSerializerSettings() { Formatting = Formatting.Indented, TypeNameHandling = TypeNameHandling.Objects, PreserveReferencesHandling = PreserveReferencesHandling.Objects, ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ListContractResolver(typeof(ObservableCollection <>)), NullValueHandling = NullValueHandling.Ignore, Converters = { new KeyValuePairConverter() } }; var builder = new ContainerBuilder(); builder.RegisterModule <AppModule>(); var container = builder.Build(); var serviceProvider = container.Resolve <IServiceProvider>(); var log = serviceProvider.GetService <ILog>(); var fileSystem = serviceProvider.GetService <IFileSystem>(); log?.Initialize(System.IO.Path.Combine(fileSystem?.GetBaseDirectory(), "Core2D.log")); var windowSettings = default(WindowConfiguration); var windowSettingsPath = System.IO.Path.Combine(fileSystem?.GetBaseDirectory(), "Core2D.window"); if (fileSystem.Exists(windowSettingsPath)) { var jsonWindowSettings = fileSystem?.ReadUtf8Text(windowSettingsPath); if (!string.IsNullOrEmpty(jsonWindowSettings)) { windowSettings = JsonConvert.DeserializeObject <WindowConfiguration>(jsonWindowSettings, jsonSettings); } } editor = serviceProvider.GetService <ProjectEditorViewModel>(); editor.DockFactory = new DockFactory(editor); var recentPath = System.IO.Path.Combine(fileSystem.GetBaseDirectory(), "Core2D.recent"); if (fileSystem.Exists(recentPath)) { editor.OnLoadRecent(recentPath); } var rootDock = default(RootDock); var rootDockPath = System.IO.Path.Combine(fileSystem?.GetBaseDirectory(), "Core2D.layout"); if (fileSystem.Exists(rootDockPath)) { var jsonRootDock = fileSystem?.ReadUtf8Text(rootDockPath); if (!string.IsNullOrEmpty(jsonRootDock)) { rootDock = JsonConvert.DeserializeObject <RootDock>(jsonRootDock, jsonSettings); if (rootDock is { })
public ProjectEditorInputTarget(ProjectEditorViewModel editor) { _editor = editor; }
public DockFactory(ProjectEditorViewModel projectEditor) { _projectEditor = projectEditor; }