コード例 #1
0
        /// <summary>
        /// Add a new backup root folder
        /// </summary>
        /// <param name="sender">Sender (not used)</param>
        /// <param name="e">Event arguments (not used)</param>
        private void OnRootAdd(object sender, EventArgs e)
        {
            RootRecord Dialog = new RootRecord(RootsListBox.Items, -1);

            if (Dialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            // insert based on sort order
            RootsListBox.Items.Insert(Dialog.RootIndex, Dialog.NewRoot);
            RootsListBox.SelectedIndex = Dialog.RootIndex;
            Modified = true;
            RootModifyButton.Enabled = true;
            if (RootsListBox.Items.Count > 1)
            {
                RootDeleteButton.Enabled = true;
            }
            return;
        }
コード例 #2
0
        /// <summary>
        /// Modify root folder
        /// </summary>
        /// <param name="sender">Sender (not used)</param>
        /// <param name="e">Event arguments (not used)</param>
        private void OnRootModify(object sender, EventArgs e)
        {
            int Index = RootsListBox.SelectedIndex;

            if (Index < 0)
            {
                return;
            }
            RootRecord Dialog = new RootRecord(RootsListBox.Items, Index);

            if (Dialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            // Root index
            int NewIndex = Dialog.RootIndex;

            // modify text only
            if (NewIndex == Index)
            {
                RootsListBox.Items[Index] = Dialog.NewRoot;
                Modified = true;
                return;
            }

            // delete
            RootsListBox.Items.RemoveAt(Index);

            // adjust new index
            if (Index < NewIndex)
            {
                NewIndex--;
            }

            // insert based on sort order
            RootsListBox.Items.Insert(NewIndex, Dialog.NewRoot);
            RootsListBox.SelectedIndex = NewIndex;
            Modified = true;
            return;
        }