public override void Execute(ICommandToken commandToken)
        {
            var token = commandToken as AddNodeCommandToken;

            // TODO Test if the connection already exists
            var pos     = mApp.Graph.Nodes.Count == 0 ? new Point2(0, 0) : mApp.Graph.Nodes.Last().Position + new Point2(200, 0);
            var inputs  = ImmutableArray <NodeInput> .Empty;
            var outputs = ImmutableArray <NodeOutput> .Empty;

            var type = ComponentFinder.FindByName(token.Type);

            foreach (var attr in ComponentFinder.GetInputAttributes(type))
            {
                inputs = inputs.Add(new NodeInput(attr.Name, null));
            }
            foreach (var attr in ComponentFinder.GetOutputAttributes(type))
            {
                outputs = outputs.Add(new NodeOutput(attr.Name, false));
            }

            var node = new Node(FindUniqueName(mApp.Graph, token.Type), token.Type, pos,
                                inputs, outputs);

            mApp.SetGraph(mApp.Graph.AddNode(node));
        }
    public MainWindow(string [] args, string application_name) : base(args, application_name)
    {
        // running with mac os, Graphics could fail
        GLib.ExceptionManager.UnhandledException += (a) =>
        {
            MessageWriteLine("{0}: {1}", a, a.ExceptionObject);
        };

        var assemblyDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);

        // configuration should stored in shared folder and not in application folder, note: this is an example
        var configFile        = System.IO.Path.Combine(assemblyDirectory, "config.xml");
        var defaultConfigFile = System.IO.Path.Combine(assemblyDirectory, "default_config.xml");

        // copy default config if exist as config if not already exist
        // nice for 1st start of test app to avoid empty framework
        // the default config is a part of this project
        if (!File.Exists(configFile))
        {
            if (File.Exists(defaultConfigFile))
            {
                File.Copy(defaultConfigFile, configFile);
            }
        }

        // load old configuration or init new one if not existing
        LicenseGroup.DefaultState = Docking.Components.LicenseGroup.State.ENABLED;
        LoadConfigurationFile(configFile);

        // Create designer elements
        Build();

        // tell the component manager about all widgets to manage
        SetDockFrame(theDockFrame);
        theStatusBar.Visible = false; // SetStatusBar(theStatusBar);
        theToolBar.Visible   = false; // SetToolBar(theToolBar);
        SetMenuBar(menubar3);

        // scan all *.exe and *.dll files for component factories
        string [] search = { System.IO.Path.Combine(assemblyDirectory, "*.exe"),
                             System.IO.Path.Combine(assemblyDirectory, "*.dll") };
        ComponentFinder.SearchForComponents(search);

        // install all known component menus
        AddComponentMenus();

        InstallLanguageMenu("Options");

        LoadLayout();
        SetLanguage("default", true, false);

        // update with own persistence
        LoadPersistency(true);

        // after layout has been set, call component initialization
        // any component could load its persistence data now
        ComponentsLoaded();

        UpdateLanguage(false);
    }
示例#3
0
        protected override void OnInitialize()
        {
            var panel = TransformFinder.Find("Menu/ErrorContainer");

            _panelVisibility = panel.GetChild(0);

            _buttons = new ButtonList("ErrorContainer/ErrorPanelContainer/ButtonPanel");

            _messageText = ComponentFinder.Find <InputField>("ErrorPanel/Scroll View/Viewport/Content", _panelVisibility);

            _backButton = _buttons.GetButton("BackButtonContainer");
            _backButton.onClick.AddListener(OnBackButtonClick);
        }
        public void Test_FindComponents()
        {
            Workspace workspace = new Workspace("Name", "Description");
            Container container = workspace.Model.AddSoftwareSystem("Name", "Description").AddContainer("Name", "Description", "Technology");

            ComponentFinder componentFinder = new ComponentFinder(
                container,
                typeof(MyApp.MyController).Namespace,
                new TypeBasedComponentFinderStrategy(
                    new NameSuffixTypeMatcher("Controller", "", "ASP.NET MVC")
                    ));

            ICollection <Component> components = componentFinder.FindComponents().ToList();

            Assert.AreEqual(1, components.Count);
            Assert.AreEqual("MyController", components.First().Name);
        }
示例#5
0
        public void TestFindComponents()
        {
            string graphString = @"
0-1,2
1-0
2-0,3
3-2
4-6
5-6
6-4,5
7-8
8-7
9-";
            var    graph       = ReadDirectedGraphFromString(graphString);

            ComponentFinder <string>        componentFinder = new ComponentFinder <string>(new DFSRecursive <string>());
            List <GraphComponent <string> > graphComponents = componentFinder.FindComponents(graph);

            Assert.Equal(4, graphComponents.Count);
        }
        public NodeEditorApp()
        {
            mHistory             = ImmutableList <Graph> .Empty;
            mCurrentHistoryIndex = -1;

            CommandManager = new CommandManager();
            CommandManager.RegisterCommand(typeof(RemoveConnectionCommandToken), () => new RemoveConnectionCommand(this));
            CommandManager.RegisterCommand(typeof(AddConnectionCommandToken), () => new AddConnectionCommand(this));
            CommandManager.RegisterCommand(typeof(MoveNodeCommandToken), () => new MoveNodeCommand(this));
            CommandManager.RegisterCommand(typeof(UndoRedoCommandToken), () => new UndoRedoCommand(this));
            CommandManager.RegisterCommand(typeof(PlayCommandToken), () => new PlayCommand(this));
            CommandManager.RegisterCommand(typeof(EditNodeInputInitialDataToken), () => new EditNodeInputInitialDataCommand(this));
            CommandManager.RegisterCommand(typeof(AddNodeCommandToken), () => new AddNodeCommand(this));
            CommandManager.RegisterCommand(typeof(RemoveNodeCommandToken), () => new RemoveNodeCommand(this));
            CommandManager.RegisterCommand(typeof(SaveCommandToken), () => new SaveCommand(this));
            CommandManager.RegisterCommand(typeof(ToggleNodeOutputIsStreamCommandToken), () => new ToggleNodeOutputIsStreamCommand(this));

            LoadedComponents = ComponentFinder.GetAllComponents();

            CurrentFbpFullFileName = @"..\..\TestData\FbpGraphs\HelloWorld.fbp";
            SetGraph(FbpReader.Read(CurrentFbpFullFileName));
        }
示例#7
0
        static void Main(string[] args)
        {
            Workspace workspace = new Workspace("Contoso University", "A software architecture model of the Contoso University sample project.");
            Model     model     = workspace.Model;
            ViewSet   views     = workspace.Views;
            Styles    styles    = views.Configuration.Styles;

            Person         universityStaff   = model.AddPerson("University Staff", "A staff member of the Contoso University.");
            SoftwareSystem contosoUniversity = model.AddSoftwareSystem("Contoso University", "Allows staff to view and update student, course, and instructor information.");

            universityStaff.Uses(contosoUniversity, "uses");

            // if the client-side of this application was richer (e.g. it was a single-page app), I would include the web browser
            // as a container (i.e. User --uses-> Web Browser --uses-> Web Application (backend for frontend) --uses-> Database)
            Container webApplication = contosoUniversity.AddContainer("Web Application", "Allows staff to view and update student, course, and instructor information.", "Microsoft ASP.NET MVC");
            Container database       = contosoUniversity.AddContainer("Database", "Stores information about students, courses and instructors", "Microsoft SQL Server Express LocalDB");

            database.AddTags("Database");
            universityStaff.Uses(webApplication, "Uses", "HTTPS");
            webApplication.Uses(database, "Reads from and writes to");

            ComponentFinder componentFinder = new ComponentFinder(
                webApplication,
                typeof(ContosoUniversity.MvcApplication).Namespace, // doing this typeof forces the ContosoUniversity assembly to be loaded
                new TypeBasedComponentFinderStrategy(
                    new InterfaceImplementationTypeMatcher(typeof(System.Web.Mvc.IController), null, "ASP.NET MVC Controller"),
                    new ExtendsClassTypeMatcher(typeof(System.Data.Entity.DbContext), null, "Entity Framework DbContext")
                    )
                //new TypeSummaryComponentFinderStrategy(@"C:\Users\simon\ContosoUniversity\ContosoUniversity.sln", "ContosoUniversity")
                );

            componentFinder.FindComponents();

            // connect the user to the web MVC controllers
            webApplication.Components.ToList().FindAll(c => c.Technology == "ASP.NET MVC Controller").ForEach(c => universityStaff.Uses(c, "uses"));

            // connect all DbContext components to the database
            webApplication.Components.ToList().FindAll(c => c.Technology == "Entity Framework DbContext").ForEach(c => c.Uses(database, "Reads from and writes to"));

            // link the components to the source code
            foreach (Component component in webApplication.Components)
            {
                foreach (CodeElement codeElement in component.Code)
                {
                    if (codeElement.Url != null)
                    {
                        codeElement.Url = codeElement.Url.Replace(new Uri(@"C:\Users\simon\ContosoUniversity\").AbsoluteUri, "https://github.com/simonbrowndotje/ContosoUniversity/blob/master/");
                        codeElement.Url = codeElement.Url.Replace('\\', '/');
                    }
                }
            }

            // rather than creating a component model for the database, let's simply link to the DDL
            // (this is really just an example of linking an arbitrary element in the model to an external resource)
            database.Url = "https://github.com/simonbrowndotje/ContosoUniversity/tree/master/ContosoUniversity/Migrations";

            SystemContextView contextView = views.CreateSystemContextView(contosoUniversity, "Context", "The system context view for the Contoso University system.");

            contextView.AddAllElements();

            ContainerView containerView = views.CreateContainerView(contosoUniversity, "Containers", "The containers that make up the Contoso University system.");

            containerView.AddAllElements();

            ComponentView componentView = views.CreateComponentView(webApplication, "Components", "The components inside the Contoso University web application.");

            componentView.AddAllElements();

            // create an example dynamic view for a feature
            DynamicView dynamicView      = views.CreateDynamicView(webApplication, "GetCoursesForDepartment", "A summary of the \"get courses for department\" feature.");
            Component   courseController = webApplication.GetComponentWithName("CourseController");
            Component   schoolContext    = webApplication.GetComponentWithName("SchoolContext");

            dynamicView.Add(universityStaff, "Requests the list of courses from", courseController);
            dynamicView.Add(courseController, "Uses", schoolContext);
            dynamicView.Add(schoolContext, "Gets a list of courses from", database);

            // add some styling
            styles.Add(new ElementStyle(Tags.Person)
            {
                Background = "#0d4d4d", Color = "#ffffff", Shape = Shape.Person
            });
            styles.Add(new ElementStyle(Tags.SoftwareSystem)
            {
                Background = "#003333", Color = "#ffffff"
            });
            styles.Add(new ElementStyle(Tags.Container)
            {
                Background = "#226666", Color = "#ffffff"
            });
            styles.Add(new ElementStyle("Database")
            {
                Shape = Shape.Cylinder
            });
            styles.Add(new ElementStyle(Tags.Component)
            {
                Background = "#407f7f", Color = "#ffffff"
            });

            StructurizrClient structurizrClient = new StructurizrClient("20e54135-adff-4bdf-b684-ff6c3ffc478f", "1c714777-3b06-4e2a-9eb4-35a3648b1592");

            structurizrClient.MergeWorkspace(32431, workspace);
        }
示例#8
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var componentReferenceAttribute = attribute as ComponentReferenceAttribute;

            var targetObject = property.serializedObject.targetObject as Component;

            EditorGUI.BeginProperty(position, label, property);
            var controlsRect = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            var indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            var buttonWidth = 70;
            var fieldRect   = new Rect(controlsRect.x, controlsRect.y, controlsRect.width - buttonWidth, controlsRect.height);
            var buttonRect  = new Rect(controlsRect.x + controlsRect.width - buttonWidth, controlsRect.y, buttonWidth, controlsRect.height);

            if (targetObject == null)
            {
                EditorGUI.HelpBox(position, "Invalid serialized object", MessageType.Warning);
                return;
            }

            // if (component != null)
            // {
            bool wasEnabled = GUI.enabled;

            // GUI.enabled = false;
            EditorGUI.PropertyField(fieldRect, property, GUIContent.none, true);
            GUI.enabled = wasEnabled;
            // }
            // else
            //     EditorGUI.HelpBox(position, $"Missing {fieldInfo.FieldType}", MessageType.Warning);
            var desiredComponentType = fieldInfo.FieldType;

            if (GUI.Button(buttonRect, "Auto-set"))
            {
                var serializedComponent = property.objectReferenceValue as Component;
                var component           = serializedComponent;
                if (componentReferenceAttribute is OwnComponentAttribute)
                {
                    component = ComponentFinder.GetOwnComponent(targetObject, desiredComponentType);
                }
                else if (componentReferenceAttribute is DescendantComponentAttribute)
                {
                    component = ComponentFinder.GetDescendantComponent(targetObject, desiredComponentType);
                }
                else if (componentReferenceAttribute is AncestorComponentAttribute)
                {
                    component = ComponentFinder.GetAncestorComponent(targetObject, desiredComponentType);
                }
                else if (componentReferenceAttribute is ChildComponentAttribute)
                {
                    component = ComponentFinder.GetChildComponent(targetObject, desiredComponentType);
                }
                else if (componentReferenceAttribute is ParentComponentAttribute)
                {
                    component = ComponentFinder.GetParentComponent(targetObject, desiredComponentType);
                }
                else if (componentReferenceAttribute is SiblingComponentAttribute)
                {
                    component = ComponentFinder.GetSiblingComponent(targetObject, desiredComponentType);
                }
                if (component != serializedComponent)
                {
                    property.objectReferenceValue = component;
                }
            }

            EditorGUI.indentLevel = indent;
            EditorGUI.EndProperty();
        }
示例#9
0
        static void Main()
        {
            Workspace workspace = new Workspace("Structurizr for .NET Annotations", "This is a model of my software system.");
            Model     model     = workspace.Model;

            Person         user           = model.AddPerson("User", "A user of my software system.");
            SoftwareSystem softwareSystem = model.AddSoftwareSystem("Software System", "My software system.");

            Container webApplication = softwareSystem.AddContainer("Web Application", "Provides users with information.", "C#");
            Container database       = softwareSystem.AddContainer("Database", "Stores information.", "Relational database schema");

            database.AddTags(DatabaseTag);

            string assemblyPath = typeof(StructurizrAnnotations).Assembly.Location;
            DefaultAssemblyResolver resolver = new DefaultAssemblyResolver();

            resolver.AddSearchDirectory(Path.GetDirectoryName(assemblyPath));
            AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(
                assemblyPath,
                new ReaderParameters {
                AssemblyResolver = resolver
            }
                );

            ComponentFinder componentFinder = new ComponentFinder(
                webApplication,
                "Structurizr.Examples.Annotations",
                new StructurizrAnnotationsComponentFinderStrategy(assembly)
                );

            componentFinder.FindComponents();
            model.AddImplicitRelationships();

            ViewSet           views       = workspace.Views;
            SystemContextView contextView = views.CreateSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");

            contextView.AddAllElements();

            ContainerView containerView = views.CreateContainerView(softwareSystem, "Containers", "The container diagram from my software system.");

            containerView.AddAllElements();

            ComponentView componentView = views.CreateComponentView(webApplication, "Components", "The component diagram for the web application.");

            componentView.AddAllElements();

            Styles styles = views.Configuration.Styles;

            styles.Add(new ElementStyle(Tags.Element)
            {
                Color = "#ffffff"
            });
            styles.Add(new ElementStyle(Tags.SoftwareSystem)
            {
                Background = "#1168bd"
            });
            styles.Add(new ElementStyle(Tags.Container)
            {
                Background = "#438dd5"
            });
            styles.Add(new ElementStyle(Tags.Component)
            {
                Background = "#85bbf0", Color = "#000000"
            });
            styles.Add(new ElementStyle(Tags.Person)
            {
                Background = "#08427b", Shape = Shape.Person
            });
            styles.Add(new ElementStyle(DatabaseTag)
            {
                Shape = Shape.Cylinder
            });

            StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret);

            structurizrClient.PutWorkspace(WorkspaceId, workspace);
        }
示例#10
0
        public bool Execute()
        {
            try
            {
                if (Keys.ControlKey.IsPressed())
                {
                    if (MessageBox.Show("Debug?", "Debug UpdateHydraInstaller", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Debugger.Launch();
                    }
                }

                var      solutionPath    = Path.GetFullPath(Environment.ExpandEnvironmentVariables("%HYDRASOLUTIONPATH%"));
                var      productFilePath = Path.Combine(solutionPath, @"Hydra.InstallerStandalone\Product.wxs");
                var      applicationGeneratorBinaries = Path.Combine(solutionPath, @"ApplicationGenerator\bin", this.Configuration);
                var      applicationGeneratorProject  = Path.Combine(solutionPath, @"ApplicationGenerator\ApplicationGenerator.csproj");
                var      components       = ComponentFinder.GetComponents(applicationGeneratorBinaries, applicationGeneratorProject, this.TargetFramework, this.TargetAssembly, productFilePath);
                var      directories      = ComponentFinder.GetDirectories(applicationGeneratorBinaries, applicationGeneratorProject, this.TargetFramework, this.TargetAssembly, productFilePath);
                var      document         = XDocument.Load(productFilePath);
                var      namespaceManager = new XmlNamespaceManager(new NameTable());
                var      programMenuXml   = typeof(UpdateHydraInstaller).ReadResource <string>("ApplicationGeneratorBuildTasks.ProgramMenu.xml");
                XElement elementFeature;
                XElement elementDirectory;
                ApplicationGeneratorBuildTasks.Directory groupDirectory;
                ApplicationGeneratorBuildTasks.Directory topLeveDirectory;
                ComponentGroupRef componentGroupRef;
                XElement          elementGroupDirectory;
                XElement          elementComponentGroupRef;
                XElement          elementProgramMenu;
                XElement          elementProgramMenuDirectory;
                XElement          elementApplicationShortcutComponentRef;
                XElement          elementFragmentComponentGroup;
                ApplicationGeneratorBuildTasks.Directory programMenuDirectory;

                namespaceManager.AddNamespace("wi", "http://schemas.microsoft.com/wix/2006/wi");

                elementFeature   = document.XPathSelectElement("/wi:Wix/wi:Product/wi:Feature", namespaceManager);
                elementDirectory = document.XPathSelectElement("/wi:Wix/wi:Fragment/wi:Directory", namespaceManager);

                elementFeature.Elements().Remove();
                elementDirectory.Elements().Remove();

                foreach (var component in components)
                {
                    var elementComponent    = component.ToXElement <Component>();
                    var elementFile         = component.File.ToXElement <ApplicationGeneratorBuildTasks.File>();
                    var elementComponentRef = component.CreateComponentRef().ToXElement <ComponentRef>();

                    elementComponent.Add(elementFile);

                    elementDirectory.Add(elementComponent);
                    elementFeature.Add(elementComponentRef);
                }

                groupDirectory           = new ApplicationGeneratorBuildTasks.Directory(this.TargetAssembly + ".Binaries");
                componentGroupRef        = groupDirectory.CreateComponentGroupRef();
                elementGroupDirectory    = groupDirectory.ToXElement <ApplicationGeneratorBuildTasks.Directory>();
                elementComponentGroupRef = componentGroupRef.ToXElement <ComponentGroupRef>();

                elementDirectory.Add(elementGroupDirectory);
                elementFeature.Add(elementComponentGroupRef);

                topLeveDirectory = new ApplicationGeneratorBuildTasks.Directory();
                topLeveDirectory.Directories.AddRange(directories);

                AddDirectories(elementFeature, elementDirectory, topLeveDirectory);

                // add start menu elements

                elementProgramMenuDirectory = elementDirectory.XPathSelectElement("wi:Directory[@Id='ProgramMenuFolder']", namespaceManager);

                if (elementProgramMenuDirectory != null)
                {
                    elementProgramMenuDirectory.Remove();
                }

                programMenuDirectory = new ApplicationGeneratorBuildTasks.Directory("ProgramMenuFolder")
                {
                    Directories = new List <ApplicationGeneratorBuildTasks.Directory> {
                        new ApplicationGeneratorBuildTasks.Directory("HydraShortcuts", "CloudIDEaaS Hydra")
                    }
                };
                elementProgramMenuDirectory = programMenuDirectory.ToXElement <ApplicationGeneratorBuildTasks.Directory>();

                foreach (var shortcutDirectory in programMenuDirectory.Directories)
                {
                    elementProgramMenuDirectory.Add(shortcutDirectory.ToXElement <ApplicationGeneratorBuildTasks.Directory>());
                }

                elementDirectory.Add(elementProgramMenuDirectory);

                elementApplicationShortcutComponentRef = elementFeature.XPathSelectElement("wi:ComponentRef[@Id='ApplicationShortcut']", namespaceManager);

                if (elementApplicationShortcutComponentRef != null)
                {
                    elementApplicationShortcutComponentRef.Remove();
                }

                elementApplicationShortcutComponentRef = new ComponentRef("ApplicationShortcut").ToXElement <ComponentRef>();

                elementFeature.Add(new ComponentRef("ApplicationShortcut").ToXElement <ComponentRef>());

                elementFragmentComponentGroup = document.Root.XPathSelectElement("wi:Fragment/wi:ComponentGroup[@Id='ProductComponents']", namespaceManager);

                if (elementFragmentComponentGroup != null)
                {
                    elementFragmentComponentGroup.Remove();
                }

                elementProgramMenu = XElement.Parse(programMenuXml);
                document.Root.Add(elementProgramMenu);

                document.Save(productFilePath, SaveOptions.DisableFormatting);
            }
            catch (Exception ex)
            {
                var error = string.Format("Error installing Hydra Visual Studio templates. \r\nError: {0}", ex.ToString());

                var message = new BuildErrorEventArgs(string.Empty, string.Empty, string.Empty, 0, 0, 0, 0, error, "", "", DateTime.Now);
                this.BuildEngine.LogErrorEvent(message);

                Console.WriteLine(error);

                return(false);
            }

            return(true);
        }