private void OnDeviceChanged(object o, EventArgs args) { Device device = o as Device; TreeIter iter = FindDevice(device.VolumeInfo.MountPoint); if (!iter.Equals(TreeIter.Zero)) { store.SetValue(iter, 0, device.Name); store.EmitRowChanged(store.GetPath(iter), iter); } }
void HandleTeamPropertyChanged(object sender, PropertyChangedEventArgs e) { var teamVM = sender as TeamVM; if (teamVM != null && teamVM.NeedsSync(e.PropertyName, "Model")) { TreeIter iter; if (GetIterFromTeam(teamVM, out iter)) { teamsStore.EmitRowChanged(teamsStore.GetPath(iter), iter); } } }
private bool UpdateRows() { TreeIter iter; if (EventListStore.GetIterFirst(out iter)) { do { TriggeredEvent ev = (TriggeredEvent)EventListStore.GetValue(iter, 0); if (ev.LastDisplay != ev.TimeStamp.TimeAgo()) { TreePath path = EventListStore.GetPath(iter); EventListStore.EmitRowChanged(path, iter); } }while (EventListStore.IterNext(ref iter)); } return(true); }
/// <summary> /// Loads the plugins treeview. /// </summary> private void LoadPluginsTreeview() { ListStore store = new ListStore(typeof(PluginTreeviewContainer)); foreach (IBase plug in Plugins.LoadAllPlugins()) { bool loaded = true; IBase loaded_plug = this.ui.Plugins.FirstOrDefault(p => p.GetType().Assembly.GetName().Name == plug.GetType().Assembly.GetName().Name); if (loaded_plug == null) { loaded_plug = this.ui.Trays.FirstOrDefault(p => p.GetType().Assembly.GetName().Name == plug.GetType().Assembly.GetName().Name); } if (loaded_plug == null) { loaded_plug = plug; loaded = false; } store.AppendValues(new PluginTreeviewContainer() { Enabled = loaded, Name = plug.Name, Description = plug.Description, DllName = plug.GetType().Assembly.GetName().Name, Plugin = loaded_plug }); } TreeViewColumn column = new TreeViewColumn(); column.Title = Catalog.GetString("Enabled"); CellRendererToggle toggle_cell = new CellRendererToggle(); toggle_cell.Toggled += (s, e) => { TreeIter iter; store.GetIter(out iter, new TreePath(e.Path)); PluginTreeviewContainer item = (PluginTreeviewContainer)store.GetValue(iter, 0); item.Enabled = !((CellRendererToggle)s).Active; Type t = item.Plugin.GetType(); string[] plugins = Core.Settings.Instance[Core.Settings.Keys.Plugins.List].AsString().Split('|'); string name = t.Assembly.GetName().Name; ((CellRendererToggle)s).Active = !((CellRendererToggle)s).Active; if (((CellRendererToggle)s).Active) { try { if (t.GetInterface(typeof(IPlugin).Name) != null) { IPlugin plugin = (IPlugin)item.Plugin; plugin.Load(); this.ui.Plugins.Add(plugin); this.ui.Plugins = this.ui.Plugins.OrderBy(p => p.Name).ToList(); this.ui.RebuildMenu(); this.ReloadPluginPreferencesPages(); } else if (t.GetInterface(typeof(ITray).Name) != null) { ITray plugin = (ITray)item.Plugin; plugin.Load(this.ui.Menu, this.ui.RebuildMenu); this.ui.Trays.Add((ITray)item.Plugin); } if (!plugins.Contains(name)) { Core.Settings.Instance[Core.Settings.Keys.Plugins.List] = plugins[0] != string.Empty ? string.Join("|", plugins) + "|" + name : name; } } catch (Exception ex) { Tools.PrintInfo(ex, this.GetType()); if (plugins.Contains(name)) { Core.Settings.Instance[Core.Settings.Keys.Plugins.List] = string.Join("|", plugins.Where(p => p != name).ToArray()); } } } else { try { if (t.GetInterface(typeof(IPlugin).Name) != null) { IPlugin plugin = (IPlugin)item.Plugin; this.ui.Plugins.Remove(plugin); plugin.Dispose(); this.ui.RebuildMenu(); this.ReloadPluginPreferencesPages(); } else if (t.GetInterface(typeof(ITray).Name) != null) { ITray plugin = (ITray)item.Plugin; this.ui.Trays.Remove(plugin); plugin.Unload(); } } catch (Exception ex) { Tools.PrintInfo(ex, this.GetType()); } finally { if (plugins.Contains(name)) { Core.Settings.Instance[Core.Settings.Keys.Plugins.List] = string.Join("|", plugins.Where(p => p != name).ToArray()); } } } store.EmitRowChanged(new TreePath(e.Path), iter); }; column.PackStart(toggle_cell, true); column.SetCellDataFunc(toggle_cell, delegate(TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) { ((CellRendererToggle)cell).Active = ((PluginTreeviewContainer)model.GetValue(iter, 0)).Enabled; }); this.treeviewPlugins.AppendColumn(column); column = new TreeViewColumn(); column.Title = Catalog.GetString("Name"); CellRendererText text_cell = new CellRendererText(); column.PackStart(text_cell, true); column.SetCellDataFunc(text_cell, delegate(TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) { ((CellRendererText)cell).Text = ((PluginTreeviewContainer)model.GetValue(iter, 0)).Name; }); this.treeviewPlugins.AppendColumn(column); column = new TreeViewColumn(); column.Title = Catalog.GetString("Description"); text_cell = new CellRendererText(); column.PackStart(text_cell, true); column.SetCellDataFunc(text_cell, delegate(TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) { ((CellRendererText)cell).Text = ((PluginTreeviewContainer)model.GetValue(iter, 0)).Description; }); this.treeviewPlugins.AppendColumn(column); this.treeviewPlugins.Model = store; this.treeviewPlugins.ShowAll(); }
protected void OnBtnSwapRolesClicked(object sender, EventArgs e) { TreePath[] r = treeDebaters.Selection.GetSelectedRows(); if (r.Length != 2) { MiscHelpers.ShowMessage(this, "Select exactly two Debaters to swap.", MessageType.Error); return; } TreeIter iter1; TreeIter iter2; if (!treeDebaters.Model.GetIter(out iter1, r[0]) || !treeDebaters.Model.GetIter(out iter2, r[1])) { // this should never happen return; } // get the references in the store TreeIter storeIter1 = ConvertModelIterToStoreIter(iter1); TreeIter storeIter2 = ConvertModelIterToStoreIter(iter2); EditableDebater d1 = (EditableDebater) store.GetValue(storeIter1, 0); EditableDebater d2 = (EditableDebater) store.GetValue(storeIter2, 0); // swapping it in the store Role tmp = d2.Role; d2.Role = d1.Role; d1.Role = tmp; // update in existing rounds (this is ugly due to our data model) // this resets the info about available judges... // any other approach wouldn't be future-proof foreach (RoundData round in Tournament.I.Rounds) { // clear all round results of the debaters in the store! d1.SetRoom(round.RoundName, null); d2.SetRoom(round.RoundName, null); // always create new instance for each round RoundDebater rd1 = new RoundDebater(d1); RoundDebater rd2 = new RoundDebater(d2); // search for d1, replace by d2 and vice versa // this should work since d1 and d2 have already swapped roles foreach (RoomData room in round.Rooms) { room.ReplaceRoomMember(rd1, RoundDebater.Dummy()); } foreach (RoomData room in round.Rooms) { room.ReplaceRoomMember(rd2, rd1); } foreach (RoomData room in round.Rooms) { room.ReplaceRoomMember(RoundDebater.Dummy(), rd2); } // update also allArrays, the following UpdateAllArrays // relies on at least consistent arrays round.ReplaceInAllArrays(rd1, RoundDebater.Dummy()); round.ReplaceInAllArrays(rd2, new RoundDebater(rd1)); round.ReplaceInAllArrays(RoundDebater.Dummy(), new RoundDebater(rd2)); // since complicated things can happen above // we make the arrays consistent by brute force // this creates many warnings that round results are cleared, // but the debaters are backed up in store here...complicated, as said round.UpdateAllArrays(); } // overwrite the changes with the changes from the store SaveDebaters(); // and reflect the possible reset of RoundResults ShowRanking.I.UpdateAll(); // tell the treeview to update, don't know why path and iter is necessary store.EmitRowChanged(store.GetPath(storeIter1), storeIter1); store.EmitRowChanged(store.GetPath(storeIter2), storeIter2); }