Пример #1
0
        //  Enables the user to add his own  root folder to the view he wants to create
        private void addRootNode(object sender, RoutedEventArgs e)
        {
            TreeViewItem newRoot = new TreeViewItem();

            Controls.InputDialog.inputMessage inputDialog = new Controls.InputDialog.inputMessage("Please enter folder name", "");
            inputDialog.Title = "Add New Folder";
            if (inputDialog.ShowDialog() == true && inputDialog.Answer != string.Empty)
            {
                if (viewName.Text != string.Empty)
                {
                    TreeViewItem topParent = (TreeViewItem)CustomviewTree.Items[0];
                    newRoot.Header = inputDialog.txtAnswer.Text;
                    newRoot.Tag    = "Custom Folder";
                    topParent.Items.Add(newRoot);
                }
                else
                {
                    newRoot.Header = inputDialog.txtAnswer.Text;
                    newRoot.Tag    = "Custom Folder";
                    CustomviewTree.Items.Add(newRoot);
                }
                //inputDialog.txtAnswer.Text = viewName.Text;
            }

            return;
        }
Пример #2
0
        private void saveView(object sender, RoutedEventArgs e) //save the view created by the user
        {
            Views.HandleViews b = new Views.HandleViews();
            //save existing view
            if (viewName.Text != string.Empty)
            {
                b.saveCustomView(CustomviewTree, viewName.Text, true);
                return;
            }

            if (CustomviewTree.Items.Count > 0)
            {
                Controls.InputDialog.inputMessage inputDialog = new Controls.InputDialog.inputMessage("Please enter view name", "");
                inputDialog.Title = "Save Custom View";
                if (viewName.Text != string.Empty)
                {
                    inputDialog.txtAnswer.Text = viewName.Text;
                }
                if (inputDialog.ShowDialog() == true && inputDialog.Answer != string.Empty)
                {
                    string msg = b.saveCustomView(CustomviewTree, inputDialog.Answer, false);
                    if (msg == "success")
                    {
                        MessageBox.Show("View saved");
                        viewName.Text = inputDialog.Answer;
                    }

                    else
                    {
                        MessageBox.Show("View wasn't saved as view name already exists"); return;
                    }
                }
            }
        }
Пример #3
0
        // The user can add child folders as much as he wants and in each level he wants
        private void addNode(object sender, RoutedEventArgs e)
        {
            TreeViewItem newRoot = new TreeViewItem();

            Controls.InputDialog.inputMessage inputDialog = new Controls.InputDialog.inputMessage("Please enter folder name", "");
            inputDialog.Title = "Add New Folder";
            if (inputDialog.ShowDialog() == true)
            {
                newRoot.Header = inputDialog.txtAnswer.Text;
                newRoot.Tag    = "Custom Folder";
                //first root for empty tree

                if (CustomviewTree.Items.Count < 1)
                {
                    //TreeViewItem topParent = (TreeViewItem)CustomviewTree.Items[0];

                    CustomviewTree.Items.Add(newRoot);
                    return;
                }
                else
                {
                    TreeViewItem DestToAdd = (TreeViewItem)CustomviewTree.SelectedItem;

                    if (DestToAdd != null)
                    {
                        if ((DestToAdd.Header.ToString()).IndexOf('.') > -1)
                        {
                            MessageBox.Show("you add folder  into  file, you can drag folder only into folder  ");

                            return;
                        }

                        DestToAdd.Items.Add(newRoot);
                    }
                    else
                    {
                        MessageBox.Show("No Item was selected - please select an item to add the folder to");
                        return;
                    }
                }
            }
        }