コード例 #1
0
ファイル: Window.cs プロジェクト: fakoor/ERTMSFormalSpecs
        /// <summary>
        ///     Handles a drop event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void watchDataGridView_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("WindowsForms10PersistentObject", false))
            {
                object       data       = e.Data.GetData("WindowsForms10PersistentObject");
                BaseTreeNode sourceNode = data as BaseTreeNode;
                if (sourceNode != null)
                {
                    IVariable variable = sourceNode.Model as IVariable;
                    if (variable == null)
                    {
                        Shortcut shortCut = sourceNode.Model as Shortcut;
                        if (shortCut != null)
                        {
                            variable = shortCut.GetReference() as IVariable;
                        }
                    }

                    if (variable != null)
                    {
                        AddVariable(variable);
                    }
                }

                OLVListItem item = data as OLVListItem;
                if (item != null)
                {
                    IVariable variable = item.RowObject as IVariable;
                    if (variable != null)
                    {
                        AddVariable(variable);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        ///     Handles drop event
        /// </summary>
        /// <param name="sourceNode"></param>
        public override void AcceptDrop(BaseTreeNode sourceNode)
        {
            if (sourceNode is ShortcutTreeNode)
            {
                ShortcutTreeNode shortcut = sourceNode as ShortcutTreeNode;

                if (shortcut.Item.Dictionary == Item.Dictionary)
                {
                    Shortcut otherShortcut = (Shortcut)shortcut.Item.Duplicate();
                    Item.appendShortcuts(otherShortcut);
                    shortcut.Delete();
                }
            }
            else if (sourceNode is ShortcutFolderTreeNode)
            {
                ShortcutFolderTreeNode folder = sourceNode as ShortcutFolderTreeNode;

                if (folder.Item.Dictionary == Item.Dictionary)
                {
                    ShortcutFolder otherFolder = (ShortcutFolder)folder.Item.Duplicate();
                    Item.appendFolders(otherFolder);
                    folder.Delete();
                }
            }
            else
            {
                Namable namable = sourceNode.Model as Namable;

                Shortcut shortcut = (Shortcut)acceptor.getFactory().createShortcut();
                shortcut.CopyFrom(namable);
                Item.appendShortcuts(shortcut);
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates a new shortcut
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public ShortcutTreeNode createShortcut(DataDictionary.Shortcuts.Shortcut shortcut)
        {
            ShortcutTreeNode retVal;

            Item.appendShortcuts(shortcut);
            retVal = new ShortcutTreeNode(shortcut);
            Nodes.Add(retVal);
            SortSubNodes();

            return(retVal);
        }
コード例 #4
0
        /// <summary>
        /// Handles drop event
        /// </summary>
        /// <param name="SourceNode"></param>
        public override void AcceptDrop(BaseTreeNode SourceNode)
        {
            if (SourceNode is ShortcutTreeNode)
            {
                ShortcutTreeNode shortcut = SourceNode as ShortcutTreeNode;

                if (shortcut.Item.Dictionary == Item.Dictionary)
                {
                    DataDictionary.Shortcuts.Shortcut otherShortcut = (DataDictionary.Shortcuts.Shortcut)DataDictionary.Generated.acceptor.getFactory().createShortcut();
                    shortcut.Item.copyTo(otherShortcut);
                    createShortcut(otherShortcut);

                    shortcut.Delete();
                }
            }
            else if (SourceNode is ShortcutFolderTreeNode)
            {
                ShortcutFolderTreeNode folder = SourceNode as ShortcutFolderTreeNode;

                if (folder.Item.Dictionary == Item.Dictionary)
                {
                    DataDictionary.Shortcuts.ShortcutFolder otherFolder = (DataDictionary.Shortcuts.ShortcutFolder)DataDictionary.Generated.acceptor.getFactory().createShortcutFolder();
                    folder.Item.copyTo(otherFolder);
                    createFolder(otherFolder);

                    folder.Delete();
                }
            }
            else if (SourceNode is DataDictionaryView.RuleTreeNode)
            {
                DataDictionaryView.RuleTreeNode rule = SourceNode as DataDictionaryView.RuleTreeNode;

                if (rule.Item.Dictionary == Item.Dictionary)
                {
                    DataDictionary.Shortcuts.Shortcut shortcut = (DataDictionary.Shortcuts.Shortcut)DataDictionary.Generated.acceptor.getFactory().createShortcut();
                    shortcut.CopyFrom(rule.Item);
                    createShortcut(shortcut);
                }
            }
            else if (SourceNode is DataDictionaryView.FunctionTreeNode)
            {
                DataDictionaryView.FunctionTreeNode function = SourceNode as DataDictionaryView.FunctionTreeNode;

                if (function.Item.Dictionary == Item.Dictionary)
                {
                    DataDictionary.Shortcuts.Shortcut shortcut = (DataDictionary.Shortcuts.Shortcut)DataDictionary.Generated.acceptor.getFactory().createShortcut();
                    shortcut.CopyFrom(function.Item);
                    createShortcut(shortcut);
                }
            }
            else if (SourceNode is DataDictionaryView.ProcedureTreeNode)
            {
                DataDictionaryView.ProcedureTreeNode procedure = SourceNode as DataDictionaryView.ProcedureTreeNode;

                if (procedure.Item.Dictionary == Item.Dictionary)
                {
                    DataDictionary.Shortcuts.Shortcut shortcut = (DataDictionary.Shortcuts.Shortcut)DataDictionary.Generated.acceptor.getFactory().createShortcut();
                    shortcut.CopyFrom(procedure.Item);
                    createShortcut(shortcut);
                }
            }
            else if (SourceNode is DataDictionaryView.VariableTreeNode)
            {
                DataDictionaryView.VariableTreeNode variable = SourceNode as DataDictionaryView.VariableTreeNode;

                if (variable.Item.Dictionary == Item.Dictionary)
                {
                    DataDictionary.Shortcuts.Shortcut shortcut = (DataDictionary.Shortcuts.Shortcut)DataDictionary.Generated.acceptor.getFactory().createShortcut();
                    shortcut.CopyFrom(variable.Item);
                    createShortcut(shortcut);
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Creates a new shortcut based on a namable element
        /// </summary>
        /// <param name="step"></param>
        private void createShortcut(DataDictionary.Namable namable)
        {
            DataDictionary.Shortcuts.Shortcut shortcut = (DataDictionary.Shortcuts.Shortcut)DataDictionary.Generated.acceptor.getFactory().createShortcut();

            createShortcut(shortcut);
        }
コード例 #6
0
        /// <summary>
        ///     Accepts a drop event
        /// </summary>
        /// <param name="sourceNode"></param>
        public override void AcceptDrop(BaseTreeNode sourceNode)
        {
            {
                if (sourceNode is ShortcutTreeNode)
                {
                    ShortcutTreeNode shortcut = sourceNode as ShortcutTreeNode;

                    if (shortcut.Item.Dictionary == Item.Dictionary)
                    {
                        Shortcut otherShortcut = (Shortcut)shortcut.Item.Duplicate();
                        Item.appendShortcuts(otherShortcut);

                        shortcut.Delete();
                    }
                }
                else if (sourceNode is ShortcutFolderTreeNode)
                {
                    ShortcutFolderTreeNode folder = sourceNode as ShortcutFolderTreeNode;

                    if (folder.Item.Dictionary == Item.Dictionary)
                    {
                        ShortcutFolder otherFolder = (ShortcutFolder)folder.Item.Duplicate();
                        Item.appendFolders(otherFolder);

                        folder.Delete();
                    }
                }
                else if (sourceNode is RuleTreeNode)
                {
                    RuleTreeNode rule = sourceNode as RuleTreeNode;

                    if (rule.Item.Dictionary == Item.Dictionary)
                    {
                        Shortcut shortcut = (Shortcut)acceptor.getFactory().createShortcut();
                        shortcut.CopyFrom(rule.Item);
                        Item.appendShortcuts(shortcut);
                    }
                }
                else if (sourceNode is FunctionTreeNode)
                {
                    FunctionTreeNode function = sourceNode as FunctionTreeNode;

                    if (function.Item.Dictionary == Item.Dictionary)
                    {
                        Shortcut shortcut = (Shortcut)acceptor.getFactory().createShortcut();
                        shortcut.CopyFrom(function.Item);
                        Item.appendShortcuts(shortcut);
                    }
                }
                else if (sourceNode is ProcedureTreeNode)
                {
                    ProcedureTreeNode procedure = sourceNode as ProcedureTreeNode;

                    if (procedure.Item.Dictionary == Item.Dictionary)
                    {
                        Shortcut shortcut = (Shortcut)acceptor.getFactory().createShortcut();
                        shortcut.CopyFrom(procedure.Item);
                        Item.appendShortcuts(shortcut);
                    }
                }
                else if (sourceNode is VariableTreeNode)
                {
                    VariableTreeNode variable = sourceNode as VariableTreeNode;

                    if (variable.Item.Dictionary == Item.Dictionary)
                    {
                        Shortcut shortcut = (Shortcut)acceptor.getFactory().createShortcut();
                        shortcut.CopyFrom(variable.Item);
                        Item.appendShortcuts(shortcut);
                    }
                }
            }
        }