Beispiel #1
0
        public void DuplicateSelectedNode()
        {
            if (SelectedNode == null)
            {
                return;
            }

            var selectedNodeType = SelectedNode.GetTreeNodeType();

            if (selectedNodeType != TreeNodeType.Connection && selectedNodeType != TreeNodeType.Container)
            {
                return;
            }

            var newNode = SelectedNode.Clone();

            SelectedNode.Parent.AddChildBelow(newNode, SelectedNode);
            newNode.Parent.SetChildBelow(newNode, SelectedNode);
        }
Beispiel #2
0
        /// <summary>
        /// Adds a Struct (a Feat structure) to the "FeatList" List.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void contextclick_AddFeat(object sender, EventArgs e)
        {
            BeginUpdate();

            TreeNode top = TopNode;

            var field = new GffData.Field();

            field.type          = FieldTypes.Struct;
            field.label         = SelectedNode.Nodes.Count.ToString(); // Structs in Lists do not have a Label
            field.Struct        = new Struct();
            field.Struct.typeid = 1;                                   // <- that's what's in the UTCs I've looked at.

            string text = GeneralGFF.ConstructNodetext(field);
            var    node = new Sortable(text, field.label);

            node.Tag = field;
            int id = SelectedNode.Nodes.Add(node);


            field       = new GffData.Field();
            field.type  = FieldTypes.WORD;
            field.label = "Feat";
            field.WORD  = 0;

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(node);

            SelectedNode = SelectedNode.Nodes[id];
            SelectedNode.Expand();

            TopNode = top;

            _f.GffData.Changed = true;
            _f.GffData         = _f.GffData;

            EndUpdate();

            node.EnsureVisible();             // yes those calls are in a specific sequence.
        }
        protected override bool ExecuteAllCore()
        {
            if (SelectedNode == null || SelectedNode.Extensions == null || SelectedNode.Extensions.Count == 0)
            {
                return(false);
            }

            ShowProgressWindow();

            _activePackageManager = GetActivePackageManager();
            Debug.Assert(_activePackageManager != null);

            IDisposable action = _activePackageManager.SourceRepository.StartOperation(OperationName);

            try
            {
                List <PackageOperation> allOperations;
                bool accepted = ShowLicenseAgreementForAllPackages(_activePackageManager, out allOperations);
                if (!accepted)
                {
                    return(false);
                }

                RegisterPackageOperationEvents(_activePackageManager, null);

                var allUpdatePackages = SelectedNode.GetPackages(String.Empty, IncludePrerelease);
                _activePackageManager.UpdateSolutionPackages(
                    allUpdatePackages,
                    allOperations,
                    updateDependencies: true,
                    allowPrereleaseVersions: IncludePrerelease,
                    logger: this,
                    eventListener: this);

                return(true);
            }
            finally
            {
                UnregisterPackageOperationEvents(_activePackageManager, null);
                action.Dispose();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Finds the parent of the currently selected node and will add a new node to the parent
        /// </summary>
        /// <param name="node">node to be added</param>
        public void FindParentAndAdd(CustomNode node, bool editafter = true)
        {
            if (SelectedNode == null)
            {
                AddNode(Nodes, node, editafter);
                return;
            }

            if (SelectedNode is FolderNode)
            {
                SelectedNode.Expand();
                AddNode(SelectedNode.Nodes, node, editafter);
                return;
            }
            else
            {
                SelectedNode = SelectedNode.Parent;
                FindParentAndAdd(node, editafter);
            }
        }
Beispiel #5
0
        private void ToolBox_MouseDown(object sender, MouseEventArgs e)
        {
            SelectNodeAt(e.X, e.Y);
            if (SelectedNode == null)
            {
                return;
            }

            if (SelectedNode.Nodes.Count > 0 && (SelectedNode.AlwaysExpand || e.X < SelectedNode.Level * Indent - 10))
            {
                if (SelectedNode.IsExpanded)
                {
                    SelectedNode.Collapse();
                }
                else
                {
                    SelectedNode.Expand();
                }
            }
            this.Refresh();
        }
Beispiel #6
0
    public void ProcessAcceptInner(SelectedNode node, bool deleteOuterNucleons)
    {
        var panel       = node.Node.GetComponent <NodelistPanelScript>();
        var nukleonNode = panel.nukleonNode.GetComponent <NukleonNodeScript>();
        var massPoints  = nukleonNode.GetMassPoints();

        foreach (var massPoint in massPoints.Where(mp => mp != Vector3.zero))
        {
            var nucleons = nukleonNode.RemoveNucleonsFromNuclide(massPoint);
            if (!deleteOuterNucleons)
            {
                AddNuclide(nukleonNode.transform.localPosition + massPoint, nucleons);
            }
            else
            {
                nucleons.ForEach(n => Destroy(n));
            }
        }
        nukleonNode.AcceptInnerNucleons();
        nukleonNode.ResetDecay();
    }
Beispiel #7
0
        /// <summary>
        /// Handles the Click event of the deleteToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RegistryKey key = SelectedKey;

            if (MessageBox.Show("Are you sure you want to delete this key and all of its subkeys?",
                                "Delete confirmation",
                                MessageBoxButtons.OKCancel,
                                MessageBoxIcon.Exclamation) == DialogResult.Cancel)
            {
                return;
            }

            if (key != null)
            {
                RegistryHelper.DeleteKey(key);
                SelectedNode.Remove();

                OnDeleteKey(new RegistryEventArgs(key.Name, null, null));
                OnDeleteRegistryEntry(new RegistryEventArgs(key.Name, null, null));
            }
        }
    /// <summary>
    /// Register JS for preselection node
    /// </summary>
    protected void RegisterJavascriptForPreselection()
    {
        if (!String.IsNullOrEmpty(SelectedNode))
        {
            String target    = UseIFrame ? "" : "parent.";
            String targetUrl = String.IsNullOrEmpty(StartingPage) ? "$cmsj(node).parent().attr('href')" : "'" + StartingPage + "'";
            string script    = @"
$cmsj(document).ready(SelectPreselectedNode('#node_" + SelectedNode.Replace(".", String.Empty) + @"'));
                    
function SelectPreselectedNode(node){
    var targetFrame = $cmsj(node).parent().attr('target');
    var targetUrl = $cmsj(node).parent().attr('href');

    " + target + @"frames[targetFrame].location.href = " + targetUrl + @";

    SelectNode(node);
}";

            ScriptHelper.RegisterStartupScript(this, typeof(string), "UIMenu_PreSelectItem", script, true);
        }
    }
Beispiel #9
0
        protected bool ShowLicenseAgreementForAllPackages(IVsPackageManager activePackageManager)
        {
            var allOperations = new List <PackageOperation>();

            var allPackages = SelectedNode.GetPackages(String.Empty, IncludePrerelease).ToList();

            foreach (var package in allPackages)
            {
                var installWalker = new InstallWalker(
                    LocalRepository,
                    activePackageManager.SourceRepository,
                    _project.GetTargetFrameworkName(),
                    logger: this,
                    ignoreDependencies: false,
                    allowPrereleaseVersions: IncludePrerelease);

                var operations = installWalker.ResolveOperations(package);
                allOperations.AddRange(operations);
            }

            return(ShowLicenseAgreement(activePackageManager, allOperations.Reduce()));
        }
Beispiel #10
0
        void DrawDescInfo()
        {
            if (SelectedNode != null)
            {
                RectDesc = new Rect(0, 20, 220, position.height - 20);
                GUILayout.BeginArea(RectDesc, EditorStyles.helpBox);
                GUILayout.BeginVertical();

                EditorGUILayout.BeginToggleGroup("", false);
                var i = (VisualNode.NodeType)EditorGUILayout.EnumPopup("NodeType", SelectedNode.GetNodeType());
                EditorGUILayout.EndToggleGroup();
                SelectedNode.Title = EditorGUILayout.TextField("Title", SelectedNode.Title);

                if (SelectedNode.GetNodeType() == VisualNode.NodeType.Func)
                {
                    if (GUILayout.Button("Add Param"))
                    {
                        ((FuncNode)SelectedNode).AddParam(true, false);
                    }
                }
                else if (SelectedNode.GetNodeType() == VisualNode.NodeType.Proc)
                {
                    if (GUILayout.Button("Add Param"))
                    {
                        ((ProcNode)SelectedNode).AddParam(false, true);
                    }
                }

                EditorGUILayout.BeginToggleGroup("Refresh", false);

                EditorGUILayout.EndToggleGroup();
                GUILayout.EndVertical();
                GUILayout.EndArea();
            }
            else
            {
                RectDesc = new Rect();
            }
        }
Beispiel #11
0
        public void SetInitialExpansion()
        {
            CollapseAll();

            switch (GetDisplayStyle())
            {
            case DisplayStyle.Expand:
                ExpandAll();
                break;

            case DisplayStyle.HideTests:
                HideTests();
                break;

            case DisplayStyle.Collapse:
            default:
                break;
            }

            SelectedNode = Nodes[0];
            SelectedNode.EnsureVisible();
        }
        /// ------------------------------------------------------------------------------------
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (e.Handled || SelectedNode == null)
            {
                return;
            }

            if (e.KeyCode == Keys.F2 && LabelEdit)
            {
                SelectedNode.BeginEdit();
            }
            else if (e.KeyCode == Keys.X && SelectedNode.Level > 0)
            {
                m_cutCommand = true;
            }
            else if (e.KeyCode == Keys.C && e.Control && SelectedNode.Level > 0)
            {
                m_copyCommand = true;
            }
            else if (e.KeyCode == Keys.V && e.Control)
            {
                m_pasteCommand = true;
            }
            else if (e.KeyCode == Keys.Delete && m_allowModifications && !m_isForToolbarPopup)
            {
                if (SelectedNode.Level == 0)
                {
                    DeleteCategory(SelectedNode);
                }
                else
                {
                    DeletePattern(SelectedNode, true);
                }

                UpdateButtons();
            }
        }
Beispiel #13
0
        void m_worker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (e.Argument is VCServerPathNodeViewModel)
            {
                VCServerPathNodeViewModel node = e.Argument as VCServerPathNodeViewModel;
                node.GetItems(m_server);
                e.Result = node;
            }
            else
            {
                TeamFoundationServer collection = TeamFoundationServerFactory.GetServer(m_migrationSource.ServerUrl);
                m_server = collection.GetService(typeof(VersionControlServer)) as VersionControlServer;

                Item item = m_server.GetItem(VersionControlPath.RootFolder + m_migrationSource.SourceIdentifier);
                VCServerPathRootViewModel rootNode = new VCServerPathRootViewModel(item, this);
                rootNode.Load(m_server);
                rootNode.IsExpanded = true;
                SelectedNode        = rootNode;
                string[] tokens = m_filterItem.FilterString.Split(VersionControlPath.Separator);
                for (int i = 2; i < tokens.Length; i++)
                {
                    SelectedNode.Load(m_server);
                    SelectedNode.IsExpanded = true;

                    VCServerPathNodeViewModel newSelectedNode = SelectedNode.Children.FirstOrDefault(x => string.Equals(x.DisplayName, tokens[i]));

                    if (newSelectedNode != null)
                    {
                        SelectedNode = newSelectedNode;
                    }
                    else
                    {
                        break;
                    }
                }
                e.Result = rootNode;
            }
        }
        private static SelectedNode CreateNode(GameObject rSelectedGo)
        {
            var rSelectedNode = new SelectedNode();

            rSelectedNode.Node        = new GameObjectNode(rSelectedGo);
            rSelectedNode.Node.Curves = GetCurves(rSelectedGo);

            rSelectedNode.ChildNodes = new List <GameObjectNode>();
            Transform[] rChildTransforms = rSelectedGo.GetComponentsInChildren <Transform>(true);
            for (int i = 0; i < rChildTransforms.Length; i++)
            {
                // 过滤掉自己
                if (rChildTransforms[i] == rSelectedGo.transform)
                {
                    continue;
                }

                var rChildNode = new GameObjectNode(rChildTransforms[i].gameObject);
                rChildNode.Curves = GetCurves(rChildTransforms[i].gameObject);
                rSelectedNode.ChildNodes.Add(rChildNode);
            }
            return(rSelectedNode);
        }
Beispiel #15
0
        /// <summary>
        /// Removes the selected node
        /// </summary>
        /// <returns>true if node was removed</returns>
        public bool RemoveSelectedNode()
        {
            if (SelectedNode != null)
            {
                DialogResult dialogResult;
                if (SelectedNode is FolderNode)
                {
                    dialogResult = MessageBox.Show("Do you want to delete this folder and all its contents?", "Folder deletion", MessageBoxButtons.YesNo);
                }
                else
                {
                    dialogResult = MessageBox.Show("Do you want to delete this plan?", "Plan deletion", MessageBoxButtons.YesNo);
                }

                if (dialogResult == DialogResult.Yes)
                {
                    SelectedNode.Remove();
                    OnRemove?.Invoke();
                    return(true);
                }
            }
            return(false);
        }
Beispiel #16
0
        public bool CreateWaypoint()
        {
            int id = 0;

            while ((( WaypointNetworkAsset )SelectedNetwork).Get("NewWaypoint" + (++id)) != null)
            {
                ;
            }

            SelectedNode.Clear();
            SelectedNode.Add((( WaypointNetworkAsset )SelectedNetwork).Add(new WaypointAsset("NewWaypoint" + id, Vector3.zero, 1.0f, ( WaypointNetworkAsset )SelectedNetwork, Collection)));

            SaveCollection();

            if (Browser.Instance != null)
            {
                Browser.Instance.Editing          = false;
                Browser.Instance.CurrentHighlight = Browser.ItemType.Node;
                Browser.Instance.Editing          = true;
            }

            return(true);
        }
Beispiel #17
0
        public bool CreateGridNode()
        {
            int id = 0;

            while ((( GridNetworkAsset )SelectedNetwork).Get("NewGridNode" + (++id)) != null)
            {
                ;
            }

            SelectedNode.Clear();
            SelectedNode.Add((( GridNetworkAsset )SelectedNetwork).Add(new GridNodeAsset("NewGridNode" + id, ( GridNetworkAsset )SelectedNetwork, Collection)));

            SaveCollection();

            if (Browser.Instance != null)
            {
                Browser.Instance.Editing          = false;
                Browser.Instance.CurrentHighlight = Browser.ItemType.Node;
                Browser.Instance.Editing          = true;
            }

            return(true);
        }
Beispiel #18
0
        public void Populate()
        {
            try
            {
                BeginUpdate();
                Nodes.Clear();
                foreach (Database database in Dome.Databases)
                {
                    DatabaseTreeNode dbTreeNode = new DatabaseTreeNode(database);
                    Nodes.Add(dbTreeNode);
                }

                if (Nodes.Count != 0)
                {
                    SelectedNode = Nodes[0];
                    SelectedNode.EnsureVisible();
                }
            }
            finally
            {
                EndUpdate();
            }
        }
Beispiel #19
0
        private void OpenSelected()
        {
            string path = GetTreeViewPath(SelectedNode);

            if (Directory.Exists(path))
            {
                SelectedNode.Expand();
                return;
            }

            string extension = System.IO.Path.GetExtension(path).ToLower();

            if (extension == ".png")
            {
                Process.Start(System.IO.Path.Combine(Directory.GetCurrentDirectory(), "bin\\NPixelPaint.exe"), "\"" + path + "\"");
            }
            else if (extension == ".json")
            {
                if (ProgramData.Project.Type == ProjectType.MODPE)
                {
                    try
                    {
                        new fJsonItem(path).Show();
                    }
                    catch { EditorsManager.GetEditor(path).Edit(); }
                }
                else
                {
                    EditorsManager.GetEditor(path).Edit();
                }
            }
            else
            {
                Editor editor = EditorsManager.GetEditor(path);
                editor.Edit();
            }
        }
Beispiel #20
0
        public PlanTree() : base()
        {
            LabelEdit    = true;
            DoubleClick += (Object sender, EventArgs e) =>
            {
                SelectedNode.BeginEdit();
            };

            // enable both left and right click for selecting nodes
            NodeMouseClick += (sender, e) => {
                SelectedNode = e.Node;
            };
            ContextMenuStrip = new PlanTreeContextMenu(this);
            BeforeExpand    += OpenFolderIcon;
            BeforeCollapse  += CloseFolderIcon;

            // placeholder for drag move
            Controls.Add(DragPlaceHolder = new Label());
            DragPlaceHolder.Visible      = false;
            DragPlaceHolder.TextAlign    = ContentAlignment.MiddleCenter;
            DragPlaceHolder.AutoSize     = true;
            MouseMove += Drag;
            MouseUp   += DragEnd;
        }
Beispiel #21
0
		//-----------------------------------------------------------------------------
		// Constructor
		//-----------------------------------------------------------------------------

		public WorldTreeView() {
			editorControl = null;
			worldNode = null;

			// Open nodes on double click.
			NodeMouseDoubleClick += delegate(object sender, TreeNodeMouseClickEventArgs e) {
				OpenNode(e.Node);
			};

			/*LabelEdit = true; // Allows the editing of labels.

			// Only allow label editing with object nodes.
			BeforeLabelEdit += delegate(object sender, NodeLabelEditEventArgs e) {
				if (!(e.Node is IWorldTreeViewNode))
					e.CancelEdit = true;
			};

			// Update node names after label editing.
			AfterLabelEdit += delegate(object sender, NodeLabelEditEventArgs e) {
				if (e.CancelEdit)
					Console.WriteLine("CANCEL EDIT!!");
				TreeNode node = e.Node;
				if (node is IWorldTreeViewNode)
					((IWorldTreeViewNode) node).Rename(e.Label);
				node.Text = e.Label;
			};*/
			
			// Make sure the right clicked node doesn't change back after selecting an item in the content menu.
			MouseClick += delegate(object sender, MouseEventArgs e) {
				// Only check with right click so pressing the pluses and minuses don't change the selection.
				if (e.Button == MouseButtons.Right)
					SelectedNode = GetNodeAt(e.X, e.Y);
				if (SelectedNode.IsEditing)
					SelectedNode.EndEdit(true);
			};
		}
Beispiel #22
0
 private void tsmiDelete_Click(object sender, EventArgs e)
 {
     if (SelectedNode.Text != "main.js" &&
         new Path(SelectedNode.Text).GetExtension() != ".nproj")
     {
         try
         {
             string path = GetTreeViewPath(SelectedNode);
             if (File.Exists(path))
             {
                 FileSystem.DeleteFile(path, UIOption.AllDialogs, RecycleOption.SendToRecycleBin);
             }
             else if (Directory.Exists(path))
             {
                 Directory.Delete(path, true);
             }
             SelectedNode.Remove();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Cannot delete this file");
         }
     }
 }
Beispiel #23
0
        //Input Handling
        public void HandleNodeClick(Vector2Int nodeCoordinates)
        {
            //SELECT
            if (SelectedTool == 0)
            {
                if (SelectedNode == nodeCoordinates)
                {
                    SelectedNode = NavGrid.NO_NODE;
                }
                else
                {
                    SelectedNode = nodeCoordinates;
                }
            }

            //SINGLE
            if (SelectedTool == 1)
            {
                currentNavGrid.TogglePathablity(nodeCoordinates, nodeCoordinates);
            }

            //SQUARE
            if (SelectedTool == 2)
            {
                if (SelectedNode.Equals(NavGrid.NO_NODE))
                {
                    SelectedNode = nodeCoordinates;
                }
                else
                {
                    //Toggle entire squares of walkable area
                    currentNavGrid.TogglePathablity(SelectedNode, nodeCoordinates);
                    SelectedNode = NavGrid.NO_NODE;
                }
            }
        }
Beispiel #24
0
 public MethodNodeView(MethodNode node, SelectedNode selectedNode,
                       PlayModeTestRunner.PlayingMethodNode currentPlayingTest) : base(node, selectedNode)
 {
     methodNode = node;
     this.currentPlayingTest = currentPlayingTest;
 }
Beispiel #25
0
 public virtual Color GetNodeColor(TreeGumpNode node)
 {
     return(node != null && SelectedNode != node && !SelectedNode.IsChildOf(node) ? Color.White : Color.Gold);
 }
Beispiel #26
0
 public virtual int GetNodeHue(TreeGumpNode node)
 {
     return(node != null && SelectedNode != node && !SelectedNode.IsChildOf(node) ? TextHue : HighlightHue);
 }
        private void HandleRenameFolder(object sender, EventArgs e)
        {
            var tiw = new TextInputWindow();

            tiw.Message = "Enter new folder name";
            tiw.Result  = SelectedNode.Text;
            var dialogResult = tiw.ShowDialog();

            if (dialogResult == DialogResult.OK && tiw.Result != SelectedNode.Text)
            {
                bool   isValid = true;
                string whyNotValid;
                if (!NameVerifier.Self.IsFolderNameValid(tiw.Result, out whyNotValid))
                {
                    isValid = false;
                }


                // see if it already exists:
                string fullFilePath = FileManager.GetDirectory(SelectedNode.GetFullFilePath().FullPath) + tiw.Result + "\\";

                if (System.IO.Directory.Exists(fullFilePath))
                {
                    whyNotValid = $"Folder {tiw.Result} already exists.";
                    isValid     = false;
                }

                if (!isValid)
                {
                    MessageBox.Show(whyNotValid);
                }
                else
                {
                    string rootForElement;
                    if (SelectedNode.IsScreensFolderTreeNode())
                    {
                        rootForElement = FileLocations.Self.ScreensFolder;
                    }
                    else if (SelectedNode.IsComponentsFolderTreeNode())
                    {
                        rootForElement = FileLocations.Self.ComponentsFolder;
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }

                    var oldFullPath = SelectedNode.GetFullFilePath();

                    string oldPathRelativeToElementsRoot = FileManager.MakeRelative(SelectedNode.GetFullFilePath().FullPath, rootForElement, preserveCase: true);
                    SelectedNode.Text = tiw.Result;
                    string newPathRelativeToElementsRoot = FileManager.MakeRelative(SelectedNode.GetFullFilePath().FullPath, rootForElement, preserveCase: true);

                    if (SelectedNode.IsScreensFolderTreeNode())
                    {
                        foreach (var screen in ProjectState.Self.GumProjectSave.Screens)
                        {
                            if (screen.Name.StartsWith(oldPathRelativeToElementsRoot))
                            {
                                string oldVaue = screen.Name;
                                string newName = newPathRelativeToElementsRoot + screen.Name.Substring(oldPathRelativeToElementsRoot.Length);

                                screen.Name = newName;
                                RenameLogic.HandleRename(screen, (InstanceSave)null, oldVaue, NameChangeAction.Move, askAboutRename: false);
                            }
                        }
                    }
                    else if (SelectedNode.IsComponentsFolderTreeNode())
                    {
                        foreach (var component in ProjectState.Self.GumProjectSave.Components)
                        {
                            if (component.Name.ToLowerInvariant().StartsWith(oldPathRelativeToElementsRoot.ToLowerInvariant()))
                            {
                                string oldVaue = component.Name;
                                string newName = newPathRelativeToElementsRoot + component.Name.Substring(oldPathRelativeToElementsRoot.Length);
                                component.Name = newName;

                                RenameLogic.HandleRename(component, (InstanceSave)null, oldVaue, NameChangeAction.Move, askAboutRename: false);
                            }
                        }
                    }

                    bool isNowEmpty = Directory.GetFiles(oldFullPath.FullPath).Length == 0;
                    if (isNowEmpty)
                    {
                        Directory.Delete(oldFullPath.FullPath);
                        GumCommands.Self.GuiCommands.RefreshElementTreeView();
                    }
                }
            }
        }
        public void PopulateMenuStrip()
        {
            mMenuStrip.Items.Clear();

            if (SelectedNode != null)
            {
                // InstanceSave selected
                if (SelectedState.Self.SelectedInstance != null)
                {
                    mMenuStrip.Items.Add(mGoToDefinition);
                }
                // ScreenSave or ComponentSave
                else if (SelectedState.Self.SelectedScreen != null || SelectedState.Self.SelectedComponent != null)
                {
                    mMenuStrip.Items.Add("View in explorer", null, HandleViewInExplorer);

                    mMenuStrip.Items.Add("View References", null, HandleViewReferences);

                    mMenuStrip.Items.Add("-");

                    mAddInstance.Text = "Add object to " + SelectedState.Self.SelectedElement.Name;
                    mMenuStrip.Items.Add(mAddInstance);
                    mMenuStrip.Items.Add(mSaveObject);
                    if (SelectedState.Self.SelectedScreen != null)
                    {
                        duplicateElement.Text = $"Duplicate {SelectedState.Self.SelectedScreen.Name}";
                    }
                    else
                    {
                        duplicateElement.Text = $"Duplicate {SelectedState.Self.SelectedComponent.Name}";
                    }
                    mMenuStrip.Items.Add(duplicateElement);

                    mMenuStrip.Items.Add("-");


                    mDeleteObject.Text = "Delete " + SelectedState.Self.SelectedElement.ToString();
                    mMenuStrip.Items.Add(mDeleteObject);
                }
                else if (SelectedState.Self.SelectedBehavior != null)
                {
                    mDeleteObject.Text = "Delete " + SelectedState.Self.SelectedBehavior.ToString();
                    mMenuStrip.Items.Add(mDeleteObject);
                }
                else if (SelectedState.Self.SelectedStandardElement != null)
                {
                    mMenuStrip.Items.Add(mSaveObject);
                }
                else if (SelectedNode.IsTopScreenContainerTreeNode() || SelectedNode.IsScreensFolderTreeNode())
                {
                    mMenuStrip.Items.Add(mAddScreen);
                    mMenuStrip.Items.Add(mImportScreen);
                    mMenuStrip.Items.Add(mAddFolder);
                    mMenuStrip.Items.Add("View in explorer", null, HandleViewInExplorer);

                    if (SelectedNode.IsScreensFolderTreeNode())
                    {
                        mMenuStrip.Items.Add("Delete Folder", null, HandleDeleteFolder);
                        mMenuStrip.Items.Add("Rename Folder", null, HandleRenameFolder);
                    }
                }
                else if (SelectedNode.IsTopComponentContainerTreeNode() || SelectedNode.IsComponentsFolderTreeNode())
                {
                    mMenuStrip.Items.Add(mAddComponent);
                    mMenuStrip.Items.Add(mImportComponent);
                    mMenuStrip.Items.Add(mAddFolder);
                    mMenuStrip.Items.Add("View in explorer", null, HandleViewInExplorer);

                    if (SelectedNode.IsComponentsFolderTreeNode())
                    {
                        mMenuStrip.Items.Add("Delete Folder", null, HandleDeleteFolder);
                        mMenuStrip.Items.Add("Rename Folder", null, HandleRenameFolder);
                    }
                }
                else if (SelectedNode.IsTopBehaviorTreeNode())
                {
                    mMenuStrip.Items.Add("Add Behavior", null, HandleAddBehavior);
                }
            }
        }
Beispiel #29
0
        /// <summary>
        /// Обработчик добавления нового пользователя
        /// </summary>
        private void add_New_User(object sender, ToolStripItemClickedEventArgs e)
        {
            if (Report != null)
            {
                Report(this, new ReportEventArgs(string.Empty, string.Empty, string.Empty, true));
            }

            if (e.ClickedItem.Text == (string)getNameMode((int)ID_Menu.AddUser))//Добавление нового пользователя
            {
                int id_newUser = 0;

                ID_Comp id = new ID_Comp();

                id.id_role = -1;
                id.id_user = -1;

                if (GetID != null)
                {
                    id_newUser = GetID(this, new GetIDEventArgs(m_selNode_id, (int)ID_OBJ.User));
                }

                id.id_role = m_selNode_id.id_role;
                id.id_user = id_newUser;

                if (EditNode != null)
                {
                    EditNode(this, new EditNodeEventArgs(id, ID_Operation.Insert, id.id_user));
                }

                foreach (TreeNode role in Nodes)
                {
                    if (Convert.ToInt32(role.Name) == m_selNode_id.id_role)
                    {
                        role.Nodes.Add(Mass_NewVal_Comp((int)ID_OBJ.User));
                        role.Nodes[role.Nodes.Count - 1].Name = Convert.ToString(id.id_role) + ":" + Convert.ToString(id_newUser);
                    }
                }
            }
            else
            {
                if (e.ClickedItem.Text == (string)getNameMode((int)ID_Menu.Delete))//Удаление роли
                {
                    bool del = false;


                    if (SelectedNode.FirstNode == null)
                    {
                        del = true;
                    }
                    if (del == true)
                    {
                        if (EditNode != null)
                        {
                            EditNode(this, new EditNodeEventArgs(m_selNode_id, ID_Operation.Delete, m_selNode_id.id_role));
                        }

                        SelectedNode.Remove();
                    }
                    else
                    {
                        m_warningReport = "У роли " + SelectedNode.Text + " имеются пользователи!";
                        if (Report != null)
                        {
                            Report(this, new ReportEventArgs(string.Empty, string.Empty, m_warningReport, false));
                        }
                        //MessageBox.Show("Имеются не выведенные из состава компоненты в " + SelectedNode.Text,"Внимание!",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                    }
                }
            }
        }
Beispiel #30
0
        protected override void CompileList(List <TreeGumpNode> list)
        {
            foreach (var n in Nodes.Keys)
            {
                list.AddOrReplace(n);
            }

            var nodes = ListPool <TreeGumpNode> .AcquireObject();

            var selected = ListPool <TreeGumpNode> .AcquireObject();

            var parents = ListPool <TreeGumpNode> .AcquireObject();

            nodes.Capacity = list.Count;

            foreach (var n in list)
            {
                foreach (var p in n.GetParents())
                {
                    nodes.AddOrReplace(p);
                }

                nodes.AddOrReplace(n);
            }

            if (SelectedNode.HasParent)
            {
                nodes.AddOrReplace(SelectedNode.Parent);
            }

            selected.AddRange(SelectedNode.GetParents());

            nodes.RemoveAll(
                c =>
            {
                parents.AddRange(c.GetParents());

                var remove = false;

                if (parents.Count > 0)
                {
                    if (parents.Count <= selected.Count && c != SelectedNode && !parents.Contains(SelectedNode) &&
                        !selected.Any(p => p == c || c.Parent == p))
                    {
                        remove = true;
                    }
                    else if (parents.Count > selected.Count && c.Parent != SelectedNode)
                    {
                        remove = true;
                    }
                }

                parents.Clear();

                return(remove);
            });

            list.Clear();
            list.AddRange(nodes);

            ObjectPool.Free(ref nodes);
            ObjectPool.Free(ref selected);
            ObjectPool.Free(ref parents);

            base.CompileList(list);
        }