Ejemplo n.º 1
0
        /// <summary>
        /// Deletes the selected UI objects from UIMap.
        /// </summary>
        private void DeleteSelectedUIObjects()
        {
            if (tvUIMap.SelectedNodes.Count == 0)
            {
                return;
            }

            try
            {
                if (tvUIMap.SelectedNodes.Count == 1)
                {
                    string path = (string)tvUIMap.SelectedNode.Tag;

                    if (MessageBox.Show(String.Format("Delete '{0}'?", path), Program.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        _uiMapFile.DeleteUIObject(path);
                        tvUIMap.SelectedNode.Remove();
                    }
                }
                else
                {
                    if (MessageBox.Show(String.Format("Delete selected {0} elements?", tvUIMap.SelectedNodes.Count), Program.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        foreach (TreeNode node in tvUIMap.SelectedNodes)
                        {
                            string path = (string)node.Tag;

                            _uiMapFile.DeleteUIObject(path);
                            node.Remove();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Program.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 2
0
        public void TestDeleteTopLevelElement()
        {
            UIMapFile uiMap = UIMapFile.Create(@"TestData\NotepadUIMap1.uitest");

            string path = "NotepadUIMap1.UIUntitledNotepadWindow";

            // first verify that we can find object from given path
            UIObject uiObject = uiMap.FindUIObject(path);

            Assert.IsNotNull(uiObject);

            // delete it
            uiMap.DeleteUIObject(path);

            // verify that we no longer can find it
            uiObject = uiMap.FindUIObject(path);
            Assert.IsNull(uiObject);
        }