예제 #1
0
        protected virtual void DoEdit(object sender, System.EventArgs e)
        {
            try {

                Gtk.TreeIter itr;
                Gtk.TreeModel model;
                if (wptView.Selection.GetSelected (out model, out itr)) {
                    Waypoint wpt = (Waypoint)model.GetValue (itr, 0);
                    if (wpt is Geocache)
                    {
                        m_mon.ModifyCache();
                        return;
                    }
                    WaypointDialog dlg = new WaypointDialog ();
                    String origname = wpt.Name;
                    dlg.SetPoint (wpt);
                    if ((int)ResponseType.Ok == dlg.Run ()) {
                        wpt = dlg.GetPoint ();
                        CacheStore store = Engine.getInstance().Store;
                        if (wpt.Name == origname)
                            store.UpdateWaypointAtomic (wpt);
                        else
                        {
                            store.DeleteWaypoint(origname);
                            store.UpdateWaypointAtomic(wpt);
                        }
                        dlg.Dispose ();
                        UpdateCacheInfo ();
                    }
                }
            } catch (Exception ex) {
                UIMonitor.ShowException (ex);
            }
        }
예제 #2
0
 protected virtual void doAdd(object sender, System.EventArgs e)
 {
     try {
         Waypoint newPoint = new Waypoint ();
         Geocache parent = m_mon.SelectedCache;
         newPoint.Symbol = "Final Location";
         newPoint.Parent = parent.Name;
         newPoint.Lat = parent.Lat;
         newPoint.Lon = parent.Lon;
         String name = "FL" + parent.Name.Substring (2);
         WaypointDialog dlg = new WaypointDialog ();
         if (m_mon.Configuration.IgnoreWaypointPrefixes)
         {
             name = parent.Name;
             dlg.IgnorePrefix = true;
         }
         name = Engine.getInstance().Store.GenerateNewName(name);
         newPoint.Name = name;
         dlg.SetPoint (newPoint);
         if ((int)ResponseType.Ok == dlg.Run ()) {
             newPoint = dlg.GetPoint ();
             if (newPoint.Symbol == "Final Location")
                 parent.HasFinal = true;
             CacheStore store = Engine.getInstance ().Store;
             store.AddWaypointAtomic (newPoint);
             dlg.Dispose ();
             UpdateCacheInfo ();
         }
     } catch (Exception ex) {
         UIMonitor.ShowException (ex);
     }
 }