void HandleMapViewSelectionChanged(object sender, EventArgs e) { TreeIter iter; TreeModel model; if (((TreeSelection)sender).GetSelected(out model, out iter)) { MapDescription val = (MapDescription)model.GetValue(iter, 0); if (val != null) { upButton.Sensitive = m_maps.IndexOf(val) > 0; downButton.Sensitive = m_maps.IndexOf(val) < (m_maps.Count - 1); deleteButton.Sensitive = true; activateButton.Sensitive = !val.Active; deactivateButton.Sensitive = val.Active; deleteButton.Sensitive = true; } } else { upButton.Sensitive = false; downButton.Sensitive = false; deleteButton.Sensitive = false; activateButton.Sensitive = false; deactivateButton.Sensitive = false; deleteButton.Sensitive = false; } }
private void RenderMapCovered(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { MapDescription map = (MapDescription)model.GetValue(iter, 0); CellRendererText text = cell as CellRendererText; text.Text = map.Covered; }
protected virtual void OnDownButtonClicked(object sender, System.EventArgs e) { Gtk.TreeIter itr; Gtk.TreeModel model; if (mapView.Selection.GetSelected(out model, out itr)) { MapDescription map = (MapDescription)model.GetValue(itr, 0); int index = m_maps.IndexOf(map); if (index < m_maps.Count - 1) // Can't move the last element down { int[] order = new int[m_maps.Capacity]; for (int i = 0; i < m_maps.Capacity; i++) { order[i] = i; } order[index] = index + 1; order[index + 1] = index; m_mapModel.Reorder(order); // due double data holding, not fine but it works m_maps.RemoveAt(index); m_maps.Insert(index + 1, map); upButton.Sensitive = m_maps.IndexOf(map) > 0; downButton.Sensitive = m_maps.IndexOf(map) < (m_maps.Count - 1); } } }
private void RenderMapBaseLayer(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { MapDescription map = (MapDescription)model.GetValue(iter, 0); CellRendererText text = cell as CellRendererText; text.Text = map.BaseLayer ? Catalog.GetString("yes") : Catalog.GetString("no"); }
protected virtual void OnDeactivateButtonClicked(object sender, System.EventArgs e) { Gtk.TreeIter itr; Gtk.TreeModel model; if (mapView.Selection.GetSelected(out model, out itr)) { MapDescription map = (MapDescription)model.GetValue(itr, 0); map.Active = false; UpdateMaps(model, itr); } }
protected virtual void OnDeleteButtonClicked(object sender, System.EventArgs e) { Gtk.TreeIter itr; Gtk.TreeModel model; if (mapView.Selection.GetSelected(out model, out itr)) { MapDescription map = (MapDescription)model.GetValue(itr, 0); MessageDialog dlg = new MessageDialog(null, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, String.Format(Catalog.GetString("Are you sure you want to delete map {0}?"), map.Name)); if ((int)ResponseType.Yes == dlg.Run()) { m_maps.Remove(map); ReloadMaps(); } dlg.Hide(); } }
private void RenderMapName(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { MapDescription map = (MapDescription)model.GetValue(iter, 0); CellRendererText text = cell as CellRendererText; text.Text = map.Name; if (map.Active) { text.Strikethrough = false; } else { text.Strikethrough = true; } }
public static List<MapDescription> GetMapsFromReader(TextReader reader) { List<MapDescription> mapList = new List<MapDescription>(); XPathNavigator nav = new XPathDocument(reader).CreateNavigator(); XPathNodeIterator maps = nav.Select("/maps/map"); while (maps.MoveNext()) { MapDescription map = new MapDescription(); map.Name = maps.Current.SelectSingleNode("name").Value; map.Code = maps.Current.SelectSingleNode("code").Value; map.BaseLayer = maps.Current.SelectSingleNode("baseLayer").ValueAsBoolean; map.Covered = maps.Current.SelectSingleNode("covered").Value; map.Active = maps.Current.SelectSingleNode("active").ValueAsBoolean; mapList.Add(map); } return mapList; }
public static List <MapDescription> GetMapsFromReader(TextReader reader) { List <MapDescription> mapList = new List <MapDescription>(); XPathNavigator nav = new XPathDocument(reader).CreateNavigator(); XPathNodeIterator maps = nav.Select("/maps/map"); while (maps.MoveNext()) { MapDescription map = new MapDescription(); map.Name = maps.Current.SelectSingleNode("name").Value; map.Code = maps.Current.SelectSingleNode("code").Value; map.BaseLayer = maps.Current.SelectSingleNode("baseLayer").ValueAsBoolean; map.Covered = maps.Current.SelectSingleNode("covered").Value; map.Active = maps.Current.SelectSingleNode("active").ValueAsBoolean; mapList.Add(map); } return(mapList); }