Esempio n. 1
0
        private void DeleteTreeNode(TreeNode treeNodeSelected)
        {
            try
            {
                if (treeNodeSelected.Name == "PARENTNODE")//the selected node is a parentNode
                {
                    if (MessageBox.Show("Do you want to delete this parent node [" + treeNodeSelected.Text + "]" +
                                        " and all its children?\n(NB: This action cannot be undone.)",
                                        "Warning!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        foreach (TreeNode child in treeNodeSelected.Nodes)//close tabpage if possible
                        {
                            CloseTabPage(child.Name);
                            RecentlyOpenedDocs.DeleteSermonFromID(int.Parse(child.Name));
                            Sermon.DeleteSermon(int.Parse(child.Name));
                        }
                        if (int.TryParse(treeNodeSelected.Name, out int id))
                        {
                            CloseTabPage(treeNodeSelected.Name);
                            RecentlyOpenedDocs.DeleteSermonFromID(int.Parse(treeNodeSelected.Name));
                            Sermon.DeleteSermon(int.Parse(treeNodeSelected.Name));
                        }
                        treeNodeSelected.Remove();
                    }
                }
                else//i.e. the selected node is not a parent node
                {
                    TreeNode parentNode = treeNodeSelected.Parent;

                    if (treeNodeSelected.Name != null)
                    {
                        if (MessageBox.Show("Do you want to delete this node [" + treeNodeSelected.Text + "]" +
                                            "?\n(NB: This action cannot be undone.)",
                                            "Warning!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            CloseTabPage(treeNodeSelected.Name);//close tabpage if possible
                            treeNodeSelected.Remove();
                            RecentlyOpenedDocs.DeleteSermonFromID(int.Parse(treeNodeSelected.Name));
                            Sermon.DeleteSermon(int.Parse(treeNodeSelected.Name));
                            StatusBarMessages.SetStatusBarMessageAction("Deleted " + treeNodeSelected.Text);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Could not access node data.\nPlease try again.", "Failed to delete!");
                    }
                    if (parentNode.GetNodeCount(false) == 0)
                    {
                        parentNode.Remove();
                    }
                }
            }
            catch
            {
                MessageBox.Show("Kindly specify the node to be deleted.");
            }
        }
Esempio n. 2
0
        public StartPageContentForm(SplitterPanel parent, ParentForm formParent)
        {
            parentForm = formParent;

            FormBorderStyle = FormBorderStyle.None;
            TopLevel        = false;
            Parent          = parent;
            Dock            = DockStyle.Fill;
            Visible         = false;

            SplitContainer splitContainer0 = new SplitContainer()
            {
                Parent           = this,
                Dock             = DockStyle.Fill,
                Orientation      = Orientation.Vertical,
                IsSplitterFixed  = true,
                SplitterWidth    = 1,
                SplitterDistance = Width / 3
            };
            GroupBox gbx1Start = new GroupBox()
            {
                Text   = "Start",
                Parent = splitContainer0.Panel1,
                Dock   = DockStyle.Fill
            };
            GroupBox gbx2RecentsPanel = new GroupBox()
            {
                Text   = "Recent",
                Parent = splitContainer0.Panel2,
                Dock   = DockStyle.Fill
            };
            TreeView tvStart = new TreeView()
            {
                Parent      = gbx1Start,
                Dock        = DockStyle.Fill,
                BorderStyle = BorderStyle.None
            };
            TreeView tvRecent = new TreeView()
            {
                Parent      = gbx2RecentsPanel,
                Dock        = DockStyle.Fill,
                BorderStyle = BorderStyle.None
            };

            tvStart.NodeMouseDoubleClick  += new TreeNodeMouseClickEventHandler(StartTreeNode_DoubleClick);
            tvRecent.NodeMouseDoubleClick += new TreeNodeMouseClickEventHandler(RecentsTreeNode_DoubleClick);

            try { RecentlyOpenedDocs RODs = new RecentlyOpenedDocs(); }
            catch {; }

            AddTreeNodesToTreeViewStart(tvStart);
            AddTreeNodesToTreeViewRecent(tvRecent);
        }
Esempio n. 3
0
 private void RecentsTreeNode_DoubleClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         string[] arraySermonComponents = RecentlyOpenedDocs.OpenSermonFromID(int.Parse(e.Node.Name));
         if (arraySermonComponents == null)
         {
             return;
         }
         else
         {
             Form displayForm = SermonReader.DisplayStoredSermon(arraySermonComponents);
             parentForm.AddNewTabPage(displayForm);
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Occurs when a control is successfully added to the TabControl
 /// </summary>
 /// <param name="sender">The control that initiated the event.</param>
 /// <param name="e">ControlEvent arguments.</param>
 private void TabControl_ControlAdded(object sender, ControlEventArgs e)
 {
     if (tabControl.SelectedTab != null)
     {
         StatusBarMessages.SetStatusBarMessageShowing(tabControl.SelectedTab.Text);
     }
     if (e.Control is TabPage tabPage)
     {
         foreach (var c in tabPage.Name)
         {
             if (!char.IsDigit(c))
             {
                 return;
             }
         }
         menuItemFile_Close.Enabled    = true;
         menuItemFile_CloseAll.Enabled = true;
         menuItemFile_Print.Enabled    = true;
         RecentlyOpenedDocs.AddNewNode(int.Parse(tabPage.Name), tabPage.Text);
     }
 }
Esempio n. 5
0
        private void MenuItemDeleteAll_Click(object sender, EventArgs e)
        {
            DialogResult userChoice = MessageBox.Show("This option is going to delete every record in your library. Do you wish to continue?\n(NB: This action cannot be undone.)", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (userChoice == DialogResult.Yes)
            {
                try
                {
                    foreach (TreeNode tnParentNode in Nodes)
                    {
                        foreach (TreeNode tnChildNode in tnParentNode.Nodes)
                        {
                            try
                            {
                                string szRemoved = tnChildNode.Name;
                                CloseTabPage(szRemoved);//close tabpage if possible
                                Sermon.DeleteSermon(int.Parse(szRemoved));
                                RecentlyOpenedDocs.DeleteSermonFromID(int.Parse(szRemoved));
                            }
                            catch {; }
                        }
                    }
                    Nodes.Clear();
                    Sort();
                    if (Nodes.Count != 0)
                    {
                        MessageBox.Show("An error was encountered in deleting some nodes. Please try again.");
                        StatusBarMessages.SetStatusBarMessageAction("Partial deletion");
                    }
                    else
                    {
                        StatusBarMessages.SetStatusBarMessageAction("Deleted all stored sermons");
                    }
                }
                catch {; }
            }
        }