Пример #1
0
 public TransformationTree(UcTreeDesigner ucTreeDesigner)
 {
     this.DesignTree               = ucTreeDesigner;
     this.Nodes                    = new ObservableCollection <Node>();
     this.Connections              = new ObservableCollection <Connection>();
     this.Nodes.CollectionChanged += this.Nodes_CollectionChanged;
 }
Пример #2
0
        /// <summary>
        /// Loads the last known state and restores it.
        /// <param name="designer">The designer to load into</param>
        /// </summary>
        public static void TryLoad(UcTreeDesigner designer)
        {
            //No designer, nothing to do.
            if (designer == null)
            {
                return;
            }

            //If loading is disabled by config -> do not load.
            var load = true;

            bool.TryParse(Singleton <SmaSTraConfiguration> .Instance.GetConfigOption(SmaSTraConfiguration.LoadLastStatePath, "true"), out load);
            if (!load)
            {
                return;
            }

            //Finally load if we have a file!
            var path = Path.Combine(WorkSpace.DIR, FileName);

            if (File.Exists(path))
            {
                TreeSerilizer.Deserialize(designer.Tree, path);
            }
        }
Пример #3
0
        public void Undo(UcTreeDesigner designer)
        {
            //Reset the Positions:
            _mergedNode.includedNodes
            .ForEach(n => n.PosX -= _mergedNode.PosX)
            .ForEach(n => n.PosY -= _mergedNode.PosY)
            .ForEach(n => designer.RemoveNode(n));

            //Re-Apply the Inputs:
            foreach (var node in _mergedNode.includedNodes)
            {
                _newConnections
                .Where(c => c.InputNode == node)
                .ForEach(c => node.SetInput(c.InputIndex, c.OutputNode));
            }

            //Finally Readd the node:
            designer.AddNode(_mergedNode);

            //Reapply all connections outside of the Node:
            _newConnections
            .Where(c => !_mergedNode.includedNodes.Contains(c.InputNode))
            .Select(c => new Connection(_mergedNode, c.InputNode, c.InputIndex))
            .ForEach(designer.AddConnection);
            _newConnections
            .Where(c => !_mergedNode.includedNodes.Contains(c.OutputNode))
            .Select(c => new Connection(c.OutputNode, _mergedNode, c.InputIndex))
            .ForEach(designer.AddConnection);
        }
Пример #4
0
        /// <summary>
        /// Handles the Loaded event of this control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void This_Loaded(object sender, RoutedEventArgs e)
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                this.NodeViewer = LayoutHelper.FindLogicalParent <UcNodeViewer>(this, true);
                if (this.NodeViewer == null)
                {
                    this.NodeViewer = LayoutHelper.FindVisualParent <UcNodeViewer>(this, true);
                }

                if (this.NodeViewer != null && !this.IsPreview)
                {
                    this.treeDesigner = LayoutHelper.FindLogicalParent <UcTreeDesigner>(this.NodeViewer, true);
                    if (this.treeDesigner != null)
                    {
                        this.treeDesigner.RegisterIOHandle(this);

                        DisposablesHandler.Instance.AddDisposeConnection(this,
                                                                         PropertyChangedHandle.GetDistinctInstance(this.treeDesigner, "ConnectingIOHandle", this.OnTreeDesignerConnectingIOHandleChanged));
                    }

                    DisposablesHandler.Instance.AddDisposeConnection(this,
                                                                     PropertyChangedHandle.GetDistinctInstance(this.NodeViewer, "IsSelected", this.OnNodeViewerIsSelectedChanged));
                }
            }
            LoadedCompletely = true;
        }
Пример #5
0
        /// <summary>
        /// Saves the current State.
        /// <param name="designer">The designer to save from.</param>
        /// </summary>
        public static void Save(UcTreeDesigner designer)
        {
            //No designer, nothing to do.
            if (designer == null)
            {
                return;
            }

            var path = Path.Combine(WorkSpace.DIR, FileName);

            TreeSerilizer.Serialize(designer.Tree, path);
        }
Пример #6
0
        public void Undo(UcTreeDesigner designer)
        {
            //Save the internal Connections for After the unmerge.
            _connectionsAfterUnmerge.Clear();
            _mergedNode.includedNodes
            .ForEach(
                n => n.InputNodes.ForEachNonNull((n2, i) => _connectionsAfterUnmerge.Add(new Connection(n2, n, i)))
                );

            //Then do the unmerge
            designer.UnmergeNode(_mergedNode);
        }
Пример #7
0
        /// <summary>
        /// Property Changed Callback method of the IsSelected Dependency Property.
        /// </summary>
        /// <param name="sender">The instance of the class that had the IsSelected property changed.</param>
        /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void OnIsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            UcNodeViewer subject  = (UcNodeViewer)sender;
            bool         newValue = (bool)e.NewValue;
            bool         oldValue = (bool)e.OldValue;

            if (newValue)
            {
                UcTreeDesigner treeDesigner = LayoutHelper.FindLogicalParent <UcTreeDesigner>(subject, true);
                if (treeDesigner != null)
                {
                    treeDesigner.onNodeViewerSelected(subject);
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Switches the Workspace.
        /// </summary>
        /// <param name="newWorkspace">to switch to.</param>
        /// <param name="treeDesigner">The tree designer to remove remaining stuff.</param>
        public static void SwitchWorkspace(string newWorkspace, UcTreeDesigner treeDesigner)
        {
            //Be sure the new Workspace exists:
            if (!string.IsNullOrWhiteSpace(newWorkspace))
            {
                Directory.CreateDirectory(newWorkspace);
            }


            //Save the new Workspace to the Registry:
            try{
                var key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(RegSubKey);
                if (key != null)
                {
                    key.SetValue(RegWorkspaceKey, newWorkspace);
                    key.Close();
                }
            }catch (Exception exp) { Debug.Print(exp.ToString()); }


            //Clear the current Tree and the GUI:
            treeDesigner?.Clear();


            //Set the new Workspace:
            WorkSpace.DIR = newWorkspace;
            CopyDefault(WorkSpace.DIR);


            //Reload the managers:
            DataType.ReloadFromBaseFolder();
            Singleton <SmaSTraConfiguration> .Instance.Reload();

            Singleton <NodeBlacklist> .Instance.Reload();

            Singleton <ClassManager> .Instance.Reload();

            Singleton <Library> .Instance.loadLibrary();

            //Restore last state:
            if (treeDesigner != null)
            {
                RegularSaver.TryLoad(treeDesigner);
            }
        }
Пример #9
0
        public void Redo(UcTreeDesigner designer)
        {
            //Reset the Positions:
            _mergedNode.includedNodes
            .ForEach(n => n.PosX -= _mergedNode.PosX)
            .ForEach(n => n.PosY -= _mergedNode.PosY)
            .ForEach(n => designer.RemoveNode(n));

            //Re-Apply the Inputs:
            foreach (var node in _mergedNode.includedNodes)
            {
                _connectionsAfterUnmerge
                .Where(c => c.InputNode == node)
                .ForEach(c => node.SetInput(c.InputIndex, c.OutputNode));
            }

            //Finally Readd the node:
            designer.AddNode(_mergedNode);

            //Readd connections from outside the Bundle:
            _oldConnections.ForEach(designer.AddConnection);
        }
Пример #10
0
 public void Undo(UcTreeDesigner designer)
 {
     nodes.ForEach(n => designer.AddNode(n));
     connections.ForEach(c => designer.AddConnection(c));
 }
Пример #11
0
 public void Redo(UcTreeDesigner designer)
 {
     _newPos?.ForEach(n => n.Reset());
 }
 public void Undo(UcTreeDesigner designer)
 {
     movedNodes.ForEach(n => n.PosX -= relateX);
     movedNodes.ForEach(n => n.PosY -= relateY);
 }
 public void Redo(UcTreeDesigner designer)
 {
     movedNodes.ForEach(n => n.PosX += relateX);
     movedNodes.ForEach(n => n.PosY += relateY);
 }
Пример #14
0
 public void Undo(UcTreeDesigner designer)
 {
     _oldPos?.ForEach(n => n.Reset());
 }
Пример #15
0
 public void Undo(UcTreeDesigner designer)
 {
     nodes.ForEach(n => designer.RemoveNode(n));
 }
Пример #16
0
 public void Redo(UcTreeDesigner designer)
 {
     nodes.ForEach(n => designer.AddNode(n));
 }
Пример #17
0
 public void Redo(UcTreeDesigner designer)
 {
     designer.UnmergeNode(_mergedNode);
 }