Exemple #1
0
 /// <summary>Adds a child node.</summary>
 /// <param name="parentNodePath">The node path.</param>
 /// <param name="nodeDescription">The node description.</param>
 /// <param name="position">The position.</param>
 public void AddChild(string parentNodePath, TreeViewNode nodeDescription, int position = -1)
 {
     if (FindNode(parentNodePath, out TreeIter node))
     {
         TreeIter iter;
         if (position == -1)
         {
             iter = treemodel.AppendNode(node);
         }
         else
         {
             iter = treemodel.InsertNode(node, position);
         }
         RefreshNode(iter, nodeDescription);
         treeview1.ExpandToPath(treemodel.GetPath(iter));
     }
 }
Exemple #2
0
        void SelectAll(TreeIter iter)
        {
            AddinHeader info = (AddinHeader)treeStore.GetValue(iter, ColAddin);

            if (info != null)
            {
                treeStore.SetValue(iter, ColSelected, true);
                if (!selected.Contains(info))
                {
                    selected.Add(info);
                }
                treeView.ExpandToPath(treeStore.GetPath(iter));
            }
            else
            {
                if (treeStore.IterChildren(out iter, iter))
                {
                    do
                    {
                        SelectAll(iter);
                    } while (treeStore.IterNext(ref iter));
                }
            }
        }
Exemple #3
0
    public void Add(string personName, System.Object newEvent)
    {
        TreeIter iter          = new TreeIter();
        TreeIter iterDeep      = new TreeIter();    //only used by two levels treeviews
        bool     modelNotEmpty = treeview.Model.GetIterFirst(out iter);
        string   iterPersonString;
        bool     found = false;

        if (modelNotEmpty)
        {
            do
            {
                iterPersonString = (treeview.Model.GetValue(iter, 0)).ToString();
                if (iterPersonString == personName)
                {
                    found = true;

                    //expand the person
                    treeview.ExpandToPath(treeview.Model.GetPath(iter));

                    //getLineToStore is overriden in two level treeviews
                    iterDeep = store.AppendValues(iter, getLineToStore(newEvent));

                    //select the test
                    treeview.Selection.SelectIter(iterDeep);

                    TreePath path = store.GetPath(iterDeep);
                    treeview.ScrollToCell(path, null, true, 0, 0);

                    if (treeviewHasTwoLevels)
                    {
                        addStatisticInfo(iterDeep, newEvent);
                        for (int i = 0; i < getNumOfSubEvents(newEvent); i++)
                        {
                            store.AppendValues(iterDeep, getSubLineToStore(newEvent, i));
                        }
                    }
                }
            } while (treeview.Model.IterNext(ref iter));
        }

        //if the person has not done this kind of event in this session, it's name doesn't appear in the treeview
        //create the name, and write the event
        if (!found)
        {
            iter = store.AppendValues(personName);

            iterDeep = store.AppendValues(iter, getLineToStore(newEvent));

            //scroll treeview if needed
            TreePath path = store.GetPath(iterDeep);
            treeview.ScrollToCell(path, null, true, 0, 0);

            if (treeviewHasTwoLevels)
            {
                addStatisticInfo(iterDeep, newEvent);
                for (int i = 0; i < getNumOfSubEvents(newEvent); i++)
                {
                    store.AppendValues(iterDeep, getSubLineToStore(newEvent, i));
                }
            }

            //expand the person
            treeview.ExpandToPath(treeview.Model.GetPath(iter));

            //select the test
            treeview.Selection.SelectIter(iterDeep);
        }
    }
Exemple #4
0
        private void ShowAdd2Page()
        {

            Header = CmisSync.Properties_Resources.ResourceManager.GetString("Which", CultureInfo.CurrentCulture);

            VBox layout_vertical   = new VBox (false, 12);

            Button cancel_button = new Button (cancelText);
            cancel_button.Clicked += delegate {
                Controller.PageCancelled ();
            };

            Button continue_button = new Button (continueText)
            {
                Sensitive = false
            };
            continue_button.Clicked += delegate {
                Controller.Add2PageCompleted(
                        Controller.saved_repository, Controller.saved_remote_path);
            };

            Button back_button = new Button (backText)
            {
                Sensitive = true
            };
            back_button.Clicked += delegate {
                Controller.BackToPage1();
            };

            TreeStore repoStore = new Gtk.TreeStore(typeof (string), typeof (SelectionTreeItem));
            TreeIter iter;
            foreach (KeyValuePair<String, String> repository in Controller.repositories)
            {
                iter = repoStore.AppendNode();
                repoStore.SetValues(iter, repository.Value , new SelectionTreeItem(repository.Key, "/"));
            }
            Gtk.TreeView treeView = new Gtk.TreeView(repoStore);
            treeView.HeadersVisible = false;
            treeView.Selection.Mode = SelectionMode.Single;
            treeView.AppendColumn("Name", new CellRendererText(), "text", 0);
            treeView.CursorChanged += delegate(object o, EventArgs args) {
                TreeSelection selection = (o as TreeView).Selection;
                TreeModel model;
                if (selection.GetSelected(out model, out iter)) {
                    SelectionTreeItem sti = model.GetValue(iter, 1) as SelectionTreeItem;

                    // Identify the selected remote path.
                    Controller.saved_remote_path = sti.fullPath;

                    // Identify the selected repository.
                    TreeIter cnode = iter;
                    TreeIter pnode = iter;
                    while (model.IterParent(out pnode, cnode)) {
                        cnode = pnode;
                    }
                    Controller.saved_repository = (model.GetValue(cnode, 1) as SelectionTreeItem).repository;

                    // Load sub-folders if it has not been done already.
                    // We use each item's Tag to store metadata: whether this item's subfolders have been loaded or not.
                    if (sti.childrenLoaded == false)
                    {
                        this.GdkWindow.Cursor = wait_cursor;

                        // Get list of subfolders asynchronously
                        GetSubfoldersDelegate dlgt = new GetSubfoldersDelegate(CmisUtils.GetSubfolders);
                        IAsyncResult ar = dlgt.BeginInvoke(Controller.saved_repository,
                                Controller.saved_remote_path, Controller.saved_address,
                                Controller.saved_user, Controller.saved_password, null, null);
                        while (!ar.AsyncWaitHandle.WaitOne(100)) {
                            while (Application.EventsPending()) {
                                Application.RunIteration();
                            }
                        }
                        string[] subfolders = dlgt.EndInvoke(ar);

                        TreePath tp = null;
                        // Create a sub-item for each subfolder
                        foreach (string subfolder in subfolders) {
                            TreeIter newchild = repoStore.AppendNode(iter);
                            repoStore.SetValues(newchild, System.IO.Path.GetFileName(subfolder),
                                    new SelectionTreeItem(null, subfolder));
                            if (null == tp) {
                                tp = repoStore.GetPath(newchild);
                            }
                        }
                        sti.childrenLoaded = true;
                        if (null != tp) {
                            treeView.ExpandToPath(tp);
                        }
                        this.GdkWindow.Cursor = default_cursor;
                    }
                    continue_button.Sensitive = true;

                }
            };

            ScrolledWindow sw = new ScrolledWindow() {
                ShadowType = Gtk.ShadowType.In
            };
            sw.Add(treeView);

            layout_vertical.PackStart (new Label(""), false, false, 0);
            layout_vertical.PackStart (sw, true, true, 0);
            Add(layout_vertical);
            AddButton(back_button);
            AddButton(continue_button);
            AddButton(cancel_button);
        }
Exemple #5
0
        private void ShowAdd2Page()
        {
            Header = CmisSync.Properties_Resources.ResourceManager.GetString("Which", CultureInfo.CurrentCulture);

            VBox layout_vertical = new VBox(false, 12);

            Button cancel_button = new Button(cancelText);

            cancel_button.Clicked += delegate {
                Controller.PageCancelled();
            };

            Button continue_button = new Button(continueText)
            {
                Sensitive = false
            };

            continue_button.Clicked += delegate {
                Controller.Add2PageCompleted(
                    Controller.saved_repository, Controller.saved_remote_path);
            };

            Button back_button = new Button(backText)
            {
                Sensitive = true
            };

            back_button.Clicked += delegate {
                Controller.BackToPage1();
            };

            TreeStore repoStore = new Gtk.TreeStore(typeof(string), typeof(SelectionTreeItem));
            TreeIter  iter;

            foreach (KeyValuePair <String, String> repository in Controller.repositories)
            {
                iter = repoStore.AppendNode();
                repoStore.SetValues(iter, repository.Value, new SelectionTreeItem(repository.Key, "/"));
            }
            Gtk.TreeView treeView = new Gtk.TreeView(repoStore);
            treeView.HeadersVisible = false;
            treeView.Selection.Mode = SelectionMode.Single;
            treeView.AppendColumn("Name", new CellRendererText(), "text", 0);
            treeView.CursorChanged += delegate(object o, EventArgs args) {
                TreeSelection selection = (o as TreeView).Selection;
                TreeModel     model;
                if (selection.GetSelected(out model, out iter))
                {
                    SelectionTreeItem sti = model.GetValue(iter, 1) as SelectionTreeItem;

                    // Identify the selected remote path.
                    Controller.saved_remote_path = sti.fullPath;

                    // Identify the selected repository.
                    TreeIter cnode = iter;
                    TreeIter pnode = iter;
                    while (model.IterParent(out pnode, cnode))
                    {
                        cnode = pnode;
                    }
                    Controller.saved_repository = (model.GetValue(cnode, 1) as SelectionTreeItem).repository;

                    // Load sub-folders if it has not been done already.
                    // We use each item's Tag to store metadata: whether this item's subfolders have been loaded or not.
                    if (sti.childrenLoaded == false)
                    {
                        this.GdkWindow.Cursor = wait_cursor;

                        // Get list of subfolders asynchronously
                        GetSubfoldersDelegate dlgt = new GetSubfoldersDelegate(CmisUtils.GetSubfolders);
                        IAsyncResult          ar   = dlgt.BeginInvoke(Controller.saved_repository,
                                                                      Controller.saved_remote_path, Controller.saved_address.ToString(),
                                                                      Controller.saved_user, Controller.saved_password, null, null);
                        while (!ar.AsyncWaitHandle.WaitOne(100))
                        {
                            while (Application.EventsPending())
                            {
                                Application.RunIteration();
                            }
                        }
                        string[] subfolders = dlgt.EndInvoke(ar);

                        TreePath tp = null;
                        // Create a sub-item for each subfolder
                        foreach (string subfolder in subfolders)
                        {
                            TreeIter newchild = repoStore.AppendNode(iter);
                            repoStore.SetValues(newchild, System.IO.Path.GetFileName(subfolder),
                                                new SelectionTreeItem(null, subfolder));
                            if (null == tp)
                            {
                                tp = repoStore.GetPath(newchild);
                            }
                        }
                        sti.childrenLoaded = true;
                        if (null != tp)
                        {
                            treeView.ExpandToPath(tp);
                        }
                        this.GdkWindow.Cursor = default_cursor;
                    }
                    continue_button.Sensitive = true;
                }
            };

            ScrolledWindow sw = new ScrolledWindow()
            {
                ShadowType = Gtk.ShadowType.In
            };

            sw.Add(treeView);

            layout_vertical.PackStart(new Label(""), false, false, 0);
            layout_vertical.PackStart(sw, true, true, 0);
            Add(layout_vertical);
            AddButton(back_button);
            AddButton(continue_button);
            AddButton(cancel_button);
        }