Esempio n. 1
0
        void Remove(LMDashboardVM dashboardVM)
        {
            TreeIter iter;

            dashboardsStore.GetIterFirst(out iter);
            while (dashboardsStore.IterIsValid(iter))
            {
                if (dashboardsStore.GetValue(iter, COL_DASHBOARD) == dashboardVM)
                {
                    dashboardsStore.Remove(ref iter);
                    break;
                }
                dashboardsStore.IterNext(ref iter);
            }
        }
Esempio n. 2
0
        void removeButton_Clicked(object sender, EventArgs e)
        {
            //get selected iter and the replacement selection
            TreeIter  iter, newSelection;
            TreeModel model;

            if (!itemTree.Selection.GetSelected(out model, out iter))
            {
                return;
            }

            newSelection = iter.Copy();
            if (!IterPrev(model, ref newSelection))
            {
                newSelection = iter.Copy();
                if (!itemStore.IterNext(ref newSelection))
                {
                    newSelection = TreeIter.Zero;
                }
            }

            //new selection. Zeroing previousIter prevents trying to update name of deleted iter.
            previousIter = TreeIter.Zero;
            if (itemStore.IterIsValid(newSelection))
            {
                itemTree.Selection.SelectIter(newSelection);
            }

            //and the removal and index update
            ((ListStore)model).Remove(ref iter);
            UpdateIndices();
        }
Esempio n. 3
0
        void AuthorIconFunc(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
        {
            CellRendererPixbuf renderer = (CellRendererPixbuf)cell;
            var rev = (Revision)model.GetValue(iter, 0);

            if (string.IsNullOrEmpty(rev.Email))
            {
                return;
            }
            ImageLoader img = ImageService.GetUserIcon(rev.Email, 16);

            if (img.LoadOperation.IsCompleted)
            {
                renderer.Pixbuf = img.Pixbuf;
            }
            else
            {
                renderer.Pixbuf              = null;
                img.LoadOperation.Completed += delegate {
                    Gtk.Application.Invoke(delegate {
                        if (logstore.IterIsValid(iter))
                        {
                            model.EmitRowChanged(model.GetPath(iter), iter);
                        }
                    });
                };
            }
        }
Esempio n. 4
0
        private void loadFromSettings()
        {
            Gtk.TreeIter iter;
            pluginList.GetIterFirst(out iter);
            while (pluginList.IterIsValid(iter))
            {
                IPlugin plugin = (IPlugin)pluginList.GetValue(iter, 1);
                bool    flag   = false;

                bool.TryParse(SettingsWindow.manager.GetSetting(plugin.GetName()), out flag);

                pluginList.SetValue(iter, 0, flag);

                pluginList.IterNext(ref iter);
            }
        }
Esempio n. 5
0
        public void ReloadStats()
        {
            TreeIter iter;
            TreePath selected = null;

            pstats.UpdateStats();

            treeview.Selection.GetSelected(out iter);
            if (store.IterIsValid(iter))
            {
                selected = store.GetPath(iter);
            }

            store.Clear();
            foreach (EventTypeStats cstats in pstats.EventTypeStats)
            {
                store.AppendValues(cstats, cstats.Name);
            }

            /* Keep the selected category for when we reload the stats changing players */
            if (selected != null)
            {
                store.GetIter(out iter, selected);
            }
            else
            {
                store.GetIterFirst(out iter);
            }
            treeview.Selection.SelectIter(iter);
            categoryviewer1.LoadStats(store.GetValue(iter, 0) as EventTypeStats);
        }
        public void ReloadStats(LMPlayer player)
        {
            PlayerStats playerStats;
            TreeIter    iter;
            TreePath    selected = null;

            playerStats = pstats.GetPlayerStats(player);

            treeview.Selection.GetSelected(out iter);
            if (store.IterIsValid(iter))
            {
                selected = store.GetPath(iter);
            }

            store.Clear();
            foreach (PlayerEventTypeStats petats in playerStats.PlayerEventStats)
            {
                store.AppendValues(petats, petats.EventType.Name);
            }

            /* Keep the selected category for when we reload the stats changing players */
            if (selected != null)
            {
                store.GetIter(out iter, selected);
            }
            else
            {
                store.GetIterFirst(out iter);
            }
            treeview.Selection.SelectIter(iter);
            categoryviewer.LoadStats(store.GetValue(iter, 0) as PlayerEventTypeStats);
        }
Esempio n. 7
0
        void Reset()
        {
            TreeIter iter;

            teamsStore.GetIterFirst(out iter);
            while (teamsStore.IterIsValid(iter))
            {
                (teamsStore.GetValue(iter, COL_TEAM) as TeamVM).PropertyChanged -= HandleTeamPropertyChanged;
                teamsStore.IterNext(ref iter);
            }

            teamsStore.Clear();
            foreach (LMTeamVM teamVM in viewModel.ViewModels)
            {
                Add(teamVM);
            }
        }
Esempio n. 8
0
 public bool SetProgress(double fraction)
 {
     if (statusStore.IterIsValid(currentTaskIter))
     {
         statusStore.SetValue(currentTaskIter, STORE_TaskProgress, System.Convert.ToInt32(fraction * 100));
         return(true);
     }
     return(false);
 }
Esempio n. 9
0
        void Load(string templateName)
        {
            TreeIter templateIter = TreeIter.Zero;
            bool     first        = true;

            templatesNames = new List <string> ();
            teams.Clear();
            foreach (Team template in provider.Templates)
            {
                Pixbuf   img;
                TreeIter iter;
                string   name = template.Name;

                if (template.Shield != null)
                {
                    img = template.Shield.Scale(StyleConf.TeamsShieldIconSize,
                                                StyleConf.TeamsShieldIconSize).Value;
                }
                else
                {
                    img = Helpers.Misc.LoadIcon("longomatch-default-shield",
                                                StyleConf.TeamsShieldIconSize);
                }
                if (template.Static)
                {
                    name += " (" + Catalog.GetString("System") + ")";
                }
                else
                {
                    templatesNames.Add(name);
                }
                iter = teams.AppendValues(img, name, template.Name);
                if (first || template.Name == templateName)
                {
                    templateIter = iter;
                }
                first = false;
            }
            if (teams.IterIsValid(templateIter))
            {
                teamseditortreeview.Selection.SelectIter(templateIter);
                HandleSelectionChanged(null, null);
            }
        }
Esempio n. 10
0
        private void on_removeFileButton_clicked(object o, EventArgs e)
        {
            TreeModel model;
            TreeIter  iter;

            fileList.Selection.GetSelected(out model, out iter);
            if (fileListStore.IterIsValid(iter) == true)
            {
                fileListStore.Remove(ref iter);
            }
        }
Esempio n. 11
0
        public void SetModel(ListStore listStore)
        {
            TreeIter iter;

            listStore.GetIterFirst(out iter);
            Clear();
            while (listStore.IterIsValid(iter))
            {
                Add(listStore.GetValue(iter, 0) as PlayListPlay);
                listStore.IterNext(ref iter);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Updates the project description with a matching ID to the new description.
        /// </summary>
        /// <param name="description">Project Description.</param>
        public void UpdateProject(LMProject project)
        {
            TreeIter first;

            /* Projects are only update in the treeview mode */
            store.GetIterFirst(out first);
            while (store.IterIsValid(first))
            {
                Project p = store.GetValue(first, COL_PROJECT) as Project;
                if (project.ID == p.ID)
                {
                    // Change value in model
                    store.SetValue(first, COL_DISPLAY_NAME, FormatDesc(project.Description));
                    store.SetValue(first, COL_PROJECT, project);
                    // Also update our internal list. Although it's a new instance of Project the ID is the same
                    // and IndexOf should return the index of the old project to replace.
                    projects [projects.IndexOf(project)] = project;
                    break;
                }
                store.IterNext(ref first);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Handles the remove path button clicked event.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        protected void OnRemovePathButtonClicked(object sender, EventArgs e)
        {
            TreeIter selectedIter;

            GamePathSelectionTreeView.Selection.GetSelected(out selectedIter);

            if (GamePathListStore.IterIsValid(selectedIter))
            {
                string gamePath = (string)GamePathListStore.GetValue(selectedIter, 0);
                GamePathStorage.Instance.RemoveStoredPath(gamePath);
                GamePathListStore.Remove(ref selectedIter);
            }
        }
Esempio n. 14
0
 bool GetIterFromTeam(TeamVM team, out TreeIter iter)
 {
     teamsStore.GetIterFirst(out iter);
     while (teamsStore.IterIsValid(iter))
     {
         if ((teamsStore.GetValue(iter, COL_TEAM) as TeamVM).Model.Equals(team.Model))
         {
             return(true);
         }
         teamsStore.IterNext(ref iter);
     }
     return(false);
 }
        void HandleEdited(object o, EditedArgs args, int column)
        {
            TreeIter iter;

            store.GetIterFromString(out iter, args.Path);
            if (!store.IterIsValid(iter))
            {
                return;
            }

            string newText = args.NewText;

            if (column == 0)
            {
                newText = Switch.EspaceSwitchName(newText);
            }
            else if (column == 1)
            {
                newText = Switch.EscapeSwitchDefine(newText);
            }

            store.SetValue(iter, column, newText);

            Switch s = store.GetValue(iter, 3) as Switch;

            if (s != null)
            {
                target.RemoveSwitch(s);
            }

            s = new Switch(store.GetValue(iter, 0) as string,
                           store.GetValue(iter, 1) as string,
                           store.GetValue(iter, 2) as string);
            store.SetValue(iter, 3, s);
            target.AddSwitch(s);
        }
Esempio n. 16
0
        void Load(string templateName)
        {
            TreeIter templateIter = TreeIter.Zero;
            bool     first        = true;

            templatesNames = new List <string> ();
            templates.Clear();
            foreach (Dashboard template in provider.Templates)
            {
                Pixbuf   img;
                TreeIter iter;
                string   name;

                if (template.Image != null)
                {
                    img = template.Image.Value;
                }
                else
                {
                    img = Helpers.Misc.LoadIcon("longomatch", 20);
                }

                name = template.Name;
                if (template.Static)
                {
                    name += " (" + Catalog.GetString("System") + ")";
                }
                else
                {
                    templatesNames.Add(name);
                }
                iter = templates.AppendValues(img, name, template.Name, !template.Static);
                if (first || template.Name == templateName)
                {
                    templateIter = iter;
                }
                first = false;
            }
            if (templates.IterIsValid(templateIter))
            {
                dashboardseditortreeview.Selection.SelectIter(templateIter);
                HandleSelectionChanged(null, null);
            }
        }
Esempio n. 17
0
        private void OnTransportRemoved(object sender, TransportEventArgs args)
        {
            Gui.MainWindow.RefreshCounts();

            Gtk.TreeIter iter;
            connectionListStore.GetIterFirst(out iter);
            if (connectionListStore.IterIsValid(iter))
            {
                do
                {
                    ITransport transport = (ITransport)connectionListStore.GetValue(iter, 0);
                    if (transport == args.Transport)
                    {
                        connectionListStore.Remove(ref iter);
                        return;
                    }
                }  while (connectionListStore.IterNext(ref iter));
            }
        }
Esempio n. 18
0
        void OnButtonRemoveClicked(object sender, System.EventArgs e)
        {
            TreeIter it;

            if (dirList.Selection.GetSelected(out it))
            {
                string dir = (string)store.GetValue(it, 0);
                directories.Remove(dir);
                store.Remove(ref it);
                if (store.IterIsValid(it))
                {
                    FocusRow(it);
                }
                else
                {
                    UpdateStatus();
                }
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Updates the project description with a matching ID to the new description.
        /// </summary>
        /// <param name="description">Project Description.</param>
        public void UpdateProject(ProjectDescription description)
        {
            TreeIter first;

            /* Projects are only update in the treeview mode */
            store.GetIterFirst(out first);
            while (store.IterIsValid(first))
            {
                ProjectDescription pd = store.GetValue(first, COL_PROJECT_DESCRIPTION) as ProjectDescription;
                if (description.ID == pd.ID)
                {
                    // Change value in model
                    store.SetValue(first, COL_DISPLAY_NAME, FormatDesc(description));
                    store.SetValue(first, COL_PROJECT_DESCRIPTION, description);
                    // Also update our internal list
                    projects [projects.IndexOf(pd)] = description;
                    break;
                }
                store.IterNext(ref first);
            }
        }
Esempio n. 20
0
        void AuthorIconFunc(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter)
        {
            CellRendererImage renderer = (CellRendererImage)cell;
            var rev = (Revision)model.GetValue(iter, 0);

            if (string.IsNullOrEmpty(rev.Email))
            {
                return;
            }
            ImageLoader img = ImageService.GetUserIcon(rev.Email, 16);

            renderer.Image = img.Image;
            if (img.Downloading)
            {
                img.Completed += (sender, e) => {
                    renderer.Image = img.Image;
                    if (logstore.IterIsValid(iter))
                    {
                        model.EmitRowChanged(model.GetPath(iter), iter);
                    }
                };
            }
        }
        protected virtual void OnButtonRemoveClicked(object sender, System.EventArgs e)
        {
            TreeIter it;

            if (listView.Selection.GetSelected(out it))
            {
                var s = (XmlFormattingSettings)store.GetValue(it, 1);
                policy.Formats.Remove(s);
                TreePath p = store.GetPath(it);
                store.Remove(ref it);
                if (store.IterIsValid(it))
                {
                    listView.Selection.SelectIter(it);
                }
                else
                {
                    if (p.Prev())
                    {
                        store.GetIter(out it, p);
                        listView.Selection.SelectIter(it);
                    }
                }
            }
        }
Esempio n. 22
0
        protected void ShowContext()
        {
            var selected = Selection.GetSelectedRows();

            if (selected.Length < 1)
            {
                return;
            }

            Menu context = new Menu();

            MenuItem item = new MenuItem("Remove");

            item.Activated += (sender, e) =>
            {
                foreach (var p in selected)
                {
                    TreeIter iter;
                    if (Messages.GetIter(out iter, p))
                    {
                        Messages.Remove(ref iter);
                    }
                }
                Selection.UnselectAll();
            };
            context.Add(item);

            if (selected.Length == 1)
            {
                TreeIter iter;
                Messages.GetIter(out iter, selected[0]);
                var session = Messages.GetValue(iter, 0) as Session;
                if (session != null)
                {
                    item            = new MenuItem("Remove All " + session.Name);
                    item.Activated += (sender, e) =>
                    {
                        TreeIter delIter;
                        Messages.GetIterFirst(out delIter);

                        while (Messages.IterIsValid(delIter))
                        {
                            var delSession = Messages.GetValue(delIter, 0) as Session;
                            if (delSession != null && delSession.GetType() == session.GetType() && delSession.Name == session.Name)
                            {
                                Messages.Remove(ref delIter);
                            }
                            else
                            {
                                Messages.IterNext(ref delIter);
                            }
                        }
                    };
                    context.Add(item);

                    item            = new MenuItem("Remove and Filter Out All " + session.Name);
                    item.Activated += (sender, e) =>
                    {
                        TreeIter delIter;
                        Messages.GetIterFirst(out delIter);

                        FilterItem filterOut = Main.GetFilter(session);
                        if (filterOut != null)
                        {
                            filterOut.Enabled = false;
                        }
                        Main.RedrawFilters();

                        while (Messages.IterIsValid(delIter))
                        {
                            var delSession = Messages.GetValue(delIter, 0) as Session;
                            if (delSession != null && delSession.GetType() == session.GetType() && delSession.Name == session.Name)
                            {
                                Messages.Remove(ref delIter);
                            }
                            else
                            {
                                Messages.IterNext(ref delIter);
                            }
                        }
                    };
                    context.Add(item);


                    FilterItem filter = Main.GetFilter(session);
                    if (filter != null)
                    {
                        var citem = new CheckMenuItem("Receive " + session.Name);
                        citem.Active   = filter.Enabled;
                        citem.Toggled += (sender, e) =>
                        {
                            filter.Enabled = !filter.Enabled;
                            Main.RedrawFilters();
                        };
                        context.Add(citem);
                    }
                }
            }

            context.Add(new SeparatorMenuItem());

            item            = new MenuItem("Select All");
            item.Activated += (sender, e) =>
            {
                Selection.SelectAll();
            };
            context.Add(item);

            item            = new MenuItem("Deselect");
            item.Activated += (sender, e) =>
            {
                Selection.UnselectAll();
            };
            context.Add(item);

            context.Add(new SeparatorMenuItem());

            item            = new MenuItem("Copy");
            item.Activated += (sender, e) =>
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                foreach (var p in selected)
                {
                    TreeIter iter;
                    if (Messages.GetIter(out iter, p))
                    {
                        var session = Messages.GetValue(iter, 0) as Session;
                        if (session != null)
                        {
                            sb.AppendLine(string.Join(" | ", session.Columns));
                        }
                    }

                    Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false)).Text = sb.ToString().TrimEnd();
                }
            };
            context.Add(item);

            item            = new MenuItem("Clear");
            item.Activated += (sender, e) =>
            {
                Selection.UnselectAll();
                Messages.Clear();
            };
            context.Add(item);

            context.ShowAll();
            context.Popup();
        }
Esempio n. 23
0
        public override void LaunchDialogue()
        {
            //the Type in the collection
            IList  collection  = (IList)Value;
            string displayName = Inspector.DisplayName;

            //populate list with existing items
            ListStore itemStore = new ListStore(typeof(object), typeof(int), typeof(string));

            for (int i = 0; i < collection.Count; i++)
            {
                itemStore.AppendValues(collection [i], i, collection [i].ToString());
            }

            #region Building Dialogue

            TreeView      itemTree;
            InspectorGrid grid;
            TreeIter      previousIter = TreeIter.Zero;

            //dialogue and buttons
            Dialog dialog = new Dialog()
            {
                Title       = displayName + " Editor",
                Modal       = true,
                AllowGrow   = true,
                AllowShrink = true,
            };
            var toplevel = this.Container.Toplevel as Window;
            if (toplevel != null)
            {
                dialog.TransientFor = toplevel;
            }

            dialog.AddActionWidget(new Button(Stock.Cancel), ResponseType.Cancel);
            dialog.AddActionWidget(new Button(Stock.Ok), ResponseType.Ok);

            //three columns for items, sorting, PropGrid
            HBox hBox = new HBox();
            dialog.VBox.PackStart(hBox, true, true, 5);

            //propGrid at end
            grid = new InspectorGrid(base.EditorManager)
            {
                CurrentObject = null,
                WidthRequest  = 200,
                ShowHelp      = false
            };
            hBox.PackEnd(grid, true, true, 5);

            //followed by a ButtonBox
            VBox buttonBox = new VBox();
            buttonBox.Spacing = 6;
            hBox.PackEnd(buttonBox, false, false, 5);

            //add/remove buttons
            Button addButton = new Button(new Image(Stock.Add, IconSize.Button));
            buttonBox.PackStart(addButton, false, false, 0);
            if (types [0].IsAbstract)
            {
                addButton.Sensitive = false;
            }
            Button removeButton = new Button(new Gtk.Image(Stock.Remove, IconSize.Button));
            buttonBox.PackStart(removeButton, false, false, 0);

            //sorting buttons
            Button upButton = new Button(new Image(Stock.GoUp, IconSize.Button));
            buttonBox.PackStart(upButton, false, false, 0);
            Button downButton = new Button(new Image(Stock.GoDown, IconSize.Button));
            buttonBox.PackStart(downButton, false, false, 0);

            //Third column has list(TreeView) in a ScrolledWindow
            ScrolledWindow listScroll = new ScrolledWindow();
            listScroll.WidthRequest  = 200;
            listScroll.HeightRequest = 320;
            hBox.PackStart(listScroll, false, false, 5);

            itemTree = new TreeView(itemStore);
            itemTree.Selection.Mode = SelectionMode.Single;
            itemTree.HeadersVisible = false;
            listScroll.AddWithViewport(itemTree);

            //renderers and attribs for TreeView
            CellRenderer rdr = new CellRendererText();
            itemTree.AppendColumn(new TreeViewColumn("Index", rdr, "text", 1));
            rdr = new CellRendererText();
            itemTree.AppendColumn(new TreeViewColumn("Object", rdr, "text", 2));

            #endregion

            #region Events

            addButton.Clicked += delegate {
                //create the object
                object instance = System.Activator.CreateInstance(types[0]);

                //get existing selection and insert after it
                TreeIter oldIter, newIter;
                if (itemTree.Selection.GetSelected(out oldIter))
                {
                    newIter = itemStore.InsertAfter(oldIter);
                }
                //or append if no previous selection
                else
                {
                    newIter = itemStore.Append();
                }
                itemStore.SetValue(newIter, 0, instance);

                //select, set name and update all the indices
                itemTree.Selection.SelectIter(newIter);
                UpdateName(itemStore, newIter);
                UpdateIndices(itemStore);
            };

            removeButton.Clicked += delegate {
                //get selected iter and the replacement selection
                TreeIter iter, newSelection;
                if (!itemTree.Selection.GetSelected(out iter))
                {
                    return;
                }

                newSelection = iter;
                if (!IterPrev(itemStore, ref newSelection))
                {
                    newSelection = iter;
                    if (!itemStore.IterNext(ref newSelection))
                    {
                        newSelection = TreeIter.Zero;
                    }
                }

                //new selection. Zeroing previousIter prevents trying to update name of deleted iter.
                previousIter = TreeIter.Zero;
                if (itemStore.IterIsValid(newSelection))
                {
                    itemTree.Selection.SelectIter(newSelection);
                }

                //and the removal and index update
                itemStore.Remove(ref iter);
                UpdateIndices(itemStore);
            };

            upButton.Clicked += delegate {
                TreeIter iter, prev;
                if (!itemTree.Selection.GetSelected(out iter))
                {
                    return;
                }

                //get previous iter
                prev = iter;
                if (!IterPrev(itemStore, ref prev))
                {
                    return;
                }

                //swap the two
                itemStore.Swap(iter, prev);

                //swap indices too
                object prevVal = itemStore.GetValue(prev, 1);
                object iterVal = itemStore.GetValue(iter, 1);
                itemStore.SetValue(prev, 1, iterVal);
                itemStore.SetValue(iter, 1, prevVal);
            };

            downButton.Clicked += delegate {
                TreeIter iter, next;
                if (!itemTree.Selection.GetSelected(out iter))
                {
                    return;
                }

                //get next iter
                next = iter;
                if (!itemStore.IterNext(ref next))
                {
                    return;
                }

                //swap the two
                itemStore.Swap(iter, next);

                //swap indices too
                object nextVal = itemStore.GetValue(next, 1);
                object iterVal = itemStore.GetValue(iter, 1);
                itemStore.SetValue(next, 1, iterVal);
                itemStore.SetValue(iter, 1, nextVal);
            };

            itemTree.Selection.Changed += delegate {
                TreeIter iter;
                if (!itemTree.Selection.GetSelected(out iter))
                {
                    removeButton.Sensitive = false;
                    return;
                }
                removeButton.Sensitive = true;

                //update grid
                object obj = itemStore.GetValue(iter, 0);
                grid.CurrentObject = obj;

                //update previously selected iter's name
                UpdateName(itemStore, previousIter);

                //update current selection so we can update
                //name next selection change
                previousIter = iter;
            };

            grid.Changed += delegate {
                TreeIter iter;
                if (itemTree.Selection.GetSelected(out iter))
                {
                    UpdateName(itemStore, iter);
                }
            };

            TreeIter selectionIter;
            removeButton.Sensitive = itemTree.Selection.GetSelected(out selectionIter);

            dialog.ShowAll();
            grid.ShowToolbar = false;

            #endregion

            //if 'OK' put items back in collection
            if (GtkExtensions.ShowCustomDialog(dialog, toplevel) == (int)ResponseType.Ok)
            {
                DesignerTransaction tran = CreateTransaction(Instance);
                object old = collection;

                try {
                    collection.Clear();
                    foreach (object[] o in itemStore)
                    {
                        collection.Add(o[0]);
                    }
                    EndTransaction(Instance, tran, old, collection, true);
                }
                catch {
                    EndTransaction(Instance, tran, old, collection, false);
                    throw;
                }
            }
        }