Example #1
0
            private void BtnDelete_click(object sender, EventArgs e)
            {
                if (SelectedNode == null)
                {
                    return;
                }

                // Determine the new node to select
                System.Windows.Forms.TreeNode selNode = null;
                if (SelectedNode.NextNode != null)
                {
                    selNode = SelectedNode.NextNode;
                }
                else if (SelectedNode.PrevNode != null)
                {
                    selNode = SelectedNode.PrevNode;
                }
                else if (SelectedNode.Parent != null)
                {
                    selNode = SelectedNode.Parent;
                }

                ((Microsoft.Web.UI.WebControls.TreeNode)(SelectedNode.Tag)).Remove();
                SelectedNode.Remove();

                btnApply.Enabled = true;

                SelectedNode = selNode;
            }
        public void Delete(object sender, System.EventArgs e)
        {
            if (Nodes.Count > 0 && null != SelectedNode && parent.LabelEdit)
            {
                string tmp = Xml;

                try
                {
                    XmlNode elemToRemove = ((XmlTreeNode)SelectedNode).ConnectedXmlElement;

                    if (null != elemToRemove)
                    {
                        elemToRemove.ParentNode.RemoveChild(elemToRemove);

                        if (SelectedNode.NextNode.Text.Equals("</" + elemToRemove.Name + ">"))
                        {
                            SelectedNode.NextNode.Remove();
                        }

                        SelectedNode.Remove();
                    }
                }
                catch
                {
                    MessageBox.Show("Cannot delete this node ! Rolling back...", XmlTreeView.MessageBoxTitle);
                    parent.Xml = tmp;
                }
            }
        }
Example #3
0
        /// <summary>Удаляет выбранную группу</summary>
        private void f_DeleteGroup()
        {
            if (p_SelectedGroup == null && p_SelectedGroup.p_Group == null)
            {
                return;
            }
            if (MessageBox.Show($"Удалить группу \"{p_SelectedGroup.p_Group.p_Name}\"?", "Удаление группы", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }
            Cl_Group parentGroup = p_SelectedGroup.p_Group.p_Parent;

            if (parentGroup == null)
            {
                return;
            }
            p_SelectedGroup.p_Group.p_IsDelete = true;
            Cl_App.m_DataContext.SaveChanges();

            if (!p_IsShowDeleted)
            {
                SelectedNode.Remove();
            }
            else
            {
                p_SelectedGroup.p_Group = p_SelectedGroup.p_Group;
            }
        }
Example #4
0
        private void Ctrl_ElementDelete_Click(object sender, EventArgs e)
        {
            if (p_SelectedElement == null && p_SelectedElement.p_Element == null)
            {
                return;
            }
            if (MessageBox.Show($"Удалить элемент \"{p_SelectedElement.p_Element.p_Name}\"?", "Удаление элемента", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }

            using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction())
            {
                try
                {
                    Cl_EntityLog eLog = new Cl_EntityLog();
                    var          els  = Cl_App.m_DataContext.p_Elements.Where(el => el.p_ElementID == p_SelectedElement.p_Element.p_ElementID).OrderByDescending(v => v.p_Version);
                    if (els != null)
                    {
                        Cl_Element lastVersion = els.FirstOrDefault();
                        eLog.f_SetEntity(lastVersion);
                        bool isChange = false;
                        foreach (Cl_Element el in els)
                        {
                            el.p_IsDelete = true;
                            isChange      = true;
                        }
                        if (isChange)
                        {
                            Cl_App.m_DataContext.SaveChanges();
                            eLog.f_SaveEntity(lastVersion);
                            transaction.Commit();

                            if (!p_IsShowDeleted)
                            {
                                SelectedNode.Remove();
                            }
                            else
                            {
                                p_SelectedElement.p_Element = p_SelectedElement.p_Element;
                            }
                        }
                    }
                    else
                    {
                        MonitoringStub.Error("Error_Tree", "Не найдена элемент", new Exception("EX ERROR"), "p_SelectedElement.p_Element.p_ElementID = " + p_SelectedElement.p_Element.p_ElementID, null);
                    }
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    MonitoringStub.Error("Error_Tree", "При удалении элемента произошла ошибка", ex, null, null);
                    return;
                }
            }
        }
Example #5
0
 /// <summary>
 /// Triggers when we stop dragging
 /// </summary>
 public void DragEnd(Object sender, MouseEventArgs e)
 {
     Dragging = false;
     DragPlaceHolder.Visible = false;
     if (BelowMouse != null)
     {
         TreeNode selected = SelectedNode;
         SelectedNode.Remove();
         SelectedNode = BelowMouse;
         FindParentAndAdd((CustomNode)selected, false);
         SelectedNode         = selected;
         BelowMouse.BackColor = Color.Transparent;
         BelowMouse           = null;
     }
 }
Example #6
0
        void RemoveFile(object sender, EventArgs e)
        {
            BuildItem file = (SelectedNode.Tag) as BuildItem;

            if (file != null)
            {
                if (DialogResult.OK == MessageBox.Show(this, "Remove '" + file + "' from project?",
                                                       "Confirmation", MessageBoxButtons.OKCancel))
                {
                    Project proj = ServiceHost.Project.Current;
                    SelectedNode.Remove();
                    proj.RemoveFile(file.Include);
                }
            }
        }
Example #7
0
        void ChangeAction(object sender, EventArgs e)
        {
            BuildItem file   = SelectedNode.Tag as BuildItem;
            string    action = (sender as ToolStripMenuItem).Text as string;

            Project proj = ServiceHost.Project.Current;

            proj.RemoveFile(file.Include);

            if (SelectedNode.Nodes.Count == 0)
            {
                SelectedNode.Remove();
            }

            proj.AddFile(file.Include, action, true);
        }
 /// <summary>
 /// Removes the element from the tree.
 /// </summary>
 public void RemoveElement(XmlElement element)
 {
     // Try selected node first.
     if (IsSelectedNode(element))
     {
         SelectedNode.Remove();
     }
     else
     {
         ExtTreeNode node = FindNode(Nodes, element);
         if (node != null)
         {
             node.Remove();
         }
     }
 }
Example #9
0
        /// <summary>
        /// Обработчик удаления пользователя
        /// </summary>
        private void del_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.Delete))//Удаление роли
            {
                if (EditNode != null)
                {
                    EditNode(this, new EditNodeEventArgs(m_selNode_id, ID_Operation.Delete, m_selNode_id.id_user));
                }

                SelectedNode.Remove();
            }
        }
 /// <summary>Delete the selected node from the edited tree.</summary>
 /// <remarks>If the selected node is the Stem of the tree, clear the workspace.  Otherwise prune the selected node from the tree structure.</remarks>
 public void DeleteSelection()
 {
     if (SelectedNode != null)
     {
         if (SelectedNode == SelectedNode.Stem)
         {
             ClearModel();
         }
         else
         {
             IElementTreeNode newSelection = (IElementTreeNode)SelectedNode.Stem;
             SelectedNode.Remove();
             newSelection.Root.OnTreeStructureChanged();
             SelectNode(newSelection);
         }
     }
 }
        private void ContainerDelete()
        {
            if (ShowDeleteMessage(SelectedNode) == DialogResult.Yes)
            {
                ContainerEventArgs ee = new ContainerEventArgs((SelectedNode as ContainerTreeNode).Container);

                if (cutNode != null && cutNode == SelectedNode)
                {
                    CancelCut();
                }

                OnContainerDelete(ee);

                if (!ee.Cancel)
                {
                    SelectedNode.Remove();
                }
            }
        }
        private void LeafDelete()
        {
            if (ShowDeleteMessage(SelectedNode) == DialogResult.Yes)
            {
                LeafEventArgs ee = new LeafEventArgs((SelectedNode as LeafTreeNode).Leaf);

                if (cutNode != null && cutNode == SelectedNode)
                {
                    CancelCut();
                }

                OnLeafDelete(ee);

                if (!ee.Cancel)
                {
                    SelectedNode.Remove();
                }
            }
        }
Example #13
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));
            }
        }
Example #14
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);
        }
Example #15
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");
         }
     }
 }
Example #16
0
        /// <summary>
        /// Deletes a field in the TreeList along with any of its subnodes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal void contextclick_Delete(object sender, EventArgs e)
        {
            bool delete;

            if (SelectedNode.Tag == null)             // is TopLevelStruct's node
            {
                delete = false;
                using (var f = new DeleteDialog("Confirm delete TopLevelStruct"))
                {
                    f.cb_Bypass.Visible = false;
                    if (f.ShowDialog(this) == DialogResult.Yes)
                    {
                        delete = true;

                        if (_f.GffData.Pfe == Globals.TopLevelStruct)
                        {
                            _f.GffData = null;
                        }
                    }
                }
            }
            else if (!_bypassDeleteWarning)
            {
                string head = "Confirm delete";
                if (SelectedNode.Nodes.Count != 0)
                {
                    head += " multiple fields";
                }

                delete = false;
                using (var f = new DeleteDialog(head))
                {
                    f.cb_Bypass.Visible = true;

                    if (f.ShowDialog(this) == DialogResult.Yes)
                    {
                        delete = true;
                        _bypassDeleteWarning = f.cb_Bypass.Checked;
                    }
                }
            }
            else
            {
                delete = true;
            }

            if (delete)
            {
                if (SelectedNode.Tag != null)
                {
                    switch (((GffData.Field)SelectedNode.Tag).type)
                    {
                    case FieldTypes.Struct:
                    {
                        // Structs in Lists do not have a Label so keep their pseudo-labels' sequential order

                        var parent = SelectedNode.Parent;
                        if (parent.Tag != null &&                              // parent is NOT TopLevelStruct
                            ((GffData.Field)parent.Tag).type == FieldTypes.List)
                        {
                            Sortable node;

                            var field = (GffData.Field)SelectedNode.Tag;
                            int id    = Int32.Parse(field.label);
                            while (++id != parent.Nodes.Count)
                            {
                                node            = parent.Nodes[id] as Sortable;
                                field           = (GffData.Field)node.Tag;
                                node._label     =
                                    field.label = (id - 1).ToString();

                                node.Text = GeneralGFF.ConstructNodetext(field);
                            }
                        }
                        break;
                    }

                    case FieldTypes.locale:
                    {
                        var parent  = (GffData.Field)SelectedNode.Parent.Tag;
                        var locales = parent.Locales;

                        int            localeid = (int)((GffData.Field)SelectedNode.Tag).localeid;
                        GffData.Locale locale   = locales[localeid];

                        LocaleDialog.ClearLocaleFlag(ref parent.localeflags,
                                                     locale.langid,
                                                     locale.F);

                        for (int i = 0; i != SelectedNode.Parent.Nodes.Count; ++i)
                        {
                            var field = (GffData.Field)SelectedNode.Parent.Nodes[i].Tag;
                            if (field.localeid > localeid)
                            {
                                --field.localeid;
                            }
                        }

                        locales.Remove(locale);
                        break;
                    }
                    }
                }

                SelectedNode.Remove();

                if (SelectedNode == null)
                {
                    _f.ResetEditPanel();
                }

                if (_f.GffData != null)
                {
                    _f.GffData.Changed = true;
                }
                _f.GffData = _f.GffData;
            }
        }
Example #17
0
        private void Makros_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete)
            {
                ActivatorTime.CancelTimers(SelectedNode);
                ActivatorShortcut.RemoveEvents(SelectedNode);

                if (SelectedNode.GetType() == typeof(ActivatorShortcut))
                {
                    SelectedNode.Remove();
                }
                else if (SelectedNode.GetType() == typeof(ActivatorTime))
                {
                    SelectedNode.Remove();
                }
                else if (SelectedNode.Name == "command" || SelectedNode.Name == "activator" || SelectedNode.Name == "condition")
                {
                    SelectedNode.Remove();
                }
                else if (SelectedNode.Name == "makro" || SelectedNode.Name == "folder")
                {
                    DialogResult result = MessageBox.Show("Wollen Sie \"" + SelectedNode.Text + "\" und somit auch alle Unterpunkte wirklich löschen?", "Löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (result == DialogResult.Yes)
                    {
                        Nodes.Remove(SelectedNode);
                    }
                }
            }
            else if (e.KeyCode == Keys.Add)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    if (cw.Duration + 50 <= 3600000)
                    {
                        cw.Duration += 50;
                    }
                    else
                    {
                        cw.Duration = 3600000;
                    }
                }
            }
            else if (e.KeyCode == Keys.Subtract)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    if (cw.Duration - 50 >= 20)
                    {
                        cw.Duration -= 50;
                    }
                    else
                    {
                        cw.Duration = 20;
                    }
                }
            }
            else if (e.KeyCode == Keys.NumPad0)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    cw.Duration = 40;
                }
            }
            else if (e.KeyCode == Keys.NumPad1)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    cw.Duration = 100;
                }
            }
            else if (e.KeyCode == Keys.NumPad2)
            {
                if (SelectedNode.GetType() == typeof(CommandWait))
                {
                    CommandWait cw = (CommandWait)SelectedNode;
                    cw.Duration = 200;
                }
            }
            else if (e.KeyCode == Keys.Up && m_controlPressed)
            {
                if (SelectedNode.Name == "command" || SelectedNode.Name == "condition" ||
                    SelectedNode.Name == "activator" || SelectedNode.Name == "makro" || SelectedNode.Name == "folder")
                {
                    int tnIndex = SelectedNode.Index;
                    if (tnIndex - 1 >= 0)
                    {
                        TreeNode parentNode = SelectedNode.Parent;
                        TreeNode tn         = SelectedNode;
                        parentNode.Nodes.Remove(tn);
                        parentNode.Nodes.Insert(tnIndex - 1, tn);
                        SelectedNode = tn;
                    }
                }
            }
            else if (e.KeyCode == Keys.Down && m_controlPressed)
            {
                if (SelectedNode.Name == "command" || SelectedNode.Name == "condition" ||
                    SelectedNode.Name == "activator" || SelectedNode.Name == "makro" || SelectedNode.Name == "folder")
                {
                    int      tnIndex    = SelectedNode.Index;
                    TreeNode parentNode = SelectedNode.Parent;
                    if (tnIndex + 1 <= parentNode.Nodes.Count)
                    {
                        TreeNode tn = SelectedNode;
                        parentNode.Nodes.Remove(tn);
                        parentNode.Nodes.Insert(tnIndex + 1, tn);
                        SelectedNode = tn;
                    }
                }
            }
            if (e.KeyCode == Keys.ControlKey)
            {
                m_controlPressed = true;
            }
        }
Example #18
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);
                    }
                }
            }
        }
Example #19
0
        private void DataTreeView_ListChanged(object sender, ListChangedEventArgs e)
        {
            if (PropertyAreSet())
            {
                switch (e.ListChangedType)
                {
                case ListChangedType.ItemAdded:
                    try
                    {
                        if (!IsIDNull(GetCurrentID(e.NewIndex)))
                        {
                            if (TryAddNode(CreateNode(e.NewIndex)))
                            {
                                Trace.Write(e);
                            }
                        }
                    }
                    catch (ArgumentException ae)
                    {
                        Trace.Write(ae);
                    }
                    break;

                case ListChangedType.ItemChanged:
                    if (!_handelingItemChanged)
                    {
                        try
                        {
                            _handelingItemChanged = true;
                            var changedNode = GetDatasNode(e.NewIndex);
                            if (changedNode != null)
                            {
                                RefreshData(changedNode, e.NewIndex);
                            }
                            else if (IsIDNull(GetCurrentID(e.NewIndex)))
                            {
                                throw new ApplicationException("Item not found or wrong type.");
                            }
                            else if (TryAddNode(CreateNode(e.NewIndex)))
                            {
                                ResetData();
                            }
                            else
                            {
                                throw new ApplicationException("Item not found or wrong type.");
                            }
                        }
                        finally
                        {
                            _handelingItemChanged = false;
                        }
                    }
                    break;

                case ListChangedType.ItemDeleted:
                    if (SelectedNode != null && ((_listManager.List.IndexOf(SelectedNode.Tag) == -1) ||
                                                 _listManager.List.IndexOf(SelectedNode.Tag) == e.NewIndex))
                    {
                        SelectedNode.Remove();
                        RefreshAllData(e.NewIndex);
                    }
                    break;

                case ListChangedType.Reset:
                    ResetData();
                    break;

                case ListChangedType.ItemMoved:
                    break;
                }
            }
            else
            {
                ResetData();
            }
        }
Example #20
0
        private void ctrl_TemplateDelete_Click(object sender, EventArgs e)
        {
            if (p_SelectedTemplate == null && p_SelectedTemplate.p_Template == null)
            {
                return;
            }
            string typeName  = "шаблон";
            string typeNameR = "шаблона";

            if (p_SelectedTemplate.p_Template.p_Type == Cl_Template.E_TemplateType.Block)
            {
                typeName  = "блок";
                typeNameR = "блока";
            }
            else if (p_SelectedTemplate.p_Template.p_Type == Cl_Template.E_TemplateType.Table)
            {
                typeName  = "таблицу";
                typeNameR = "таблицы";
            }
            if (MessageBox.Show($"Удалить \"{typeName} {p_SelectedTemplate.p_Template.p_Name}\"?", $"Удаление {typeNameR}", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }

            using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction())
            {
                try
                {
                    Cl_EntityLog eLog = new Cl_EntityLog();
                    var          els  = Cl_App.m_DataContext.p_Templates.Where(el => el.p_TemplateID == p_SelectedTemplate.p_Template.p_TemplateID).OrderByDescending(v => v.p_Version);
                    if (els != null)
                    {
                        Cl_Template lastVersion = els.FirstOrDefault();
                        eLog.f_SetEntity(lastVersion);
                        bool isChange = false;
                        foreach (Cl_Template el in els)
                        {
                            el.p_IsDelete = true;
                            isChange      = true;
                        }
                        if (isChange)
                        {
                            Cl_App.m_DataContext.SaveChanges();
                            eLog.f_SaveEntity(lastVersion);
                            transaction.Commit();
                            SelectedNode.Remove();
                        }
                    }
                    else
                    {
                        MonitoringStub.Error("Error_Tree", "Не найдена шаблон", new Exception("EX ERROR"), "p_SelectedTemplate.p_Template.p_TemplateID = " + p_SelectedTemplate.p_Template.p_TemplateID, null);
                    }
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    MonitoringStub.Error("Error_Tree", "При удалении шаблона произошла ошибка", ex, null, null);
                    return;
                }
            }
        }