Esempio n. 1
0
 public bool RenameSelectedLayer()
 {
     try
     {
         Layer layer = SelectedLayer;
         if (layer != null)
         {
             NameForm form = new NameForm(Layers);
             if (form.ShowDialog(this) == DialogResult.OK)
             {
                 if (layer.Name != form.InputText)
                 {
                     layer.Name = form.InputText;
                     if (AutoSave)
                     {
                         using (Context context = Lib.GetContext()) layer.Save(context);
                     }
                     this.UpdateList();
                     if (OnLayerChanged != null)
                     {
                         OnLayerChanged(this, new LayerEventArgs(layer));
                     }
                     return(true);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
     return(false);
 }
Esempio n. 2
0
 void RenameView()
 {
     try
     {
         View selView = SelectedView;
         if (selView != null && !selView.IsOverall)
         {
             NameForm form = new NameForm(Views);
             if (form.ShowDialog(this) == DialogResult.OK)
             {
                 selView.Name = form.InputText;
                 this.UpdateList();
                 if (app.GetControlsAttr(ControlsAttr.AutoSave))
                 {
                     using (Context context = Lib.GetContext()) selView.Save(context);
                 }
                 if (OnViewChanged != null)
                 {
                     OnViewChanged(this, new ViewEventArgs(selView));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }
Esempio n. 3
0
 public bool AddLayer()
 {
     try
     {
         NameForm form = new NameForm(Layers);
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             Layer layer = new Layer(Layers.Lib, form.InputText);
             layer.Init(AppLayer);
             if (Layers.Add(layer))
             {
                 this.UpdateList(layer);
                 if (AutoSave)
                 {
                     using (Context context = Lib.GetContext()) layer.Save(context);
                 }
                 if (OnLayerAdded != null)
                 {
                     OnLayerAdded(this, new LayerEventArgs(layer));
                 }
                 return(true);
             }
             else
             {
                 string s = Locale.Get("_notuniquename") + ": " + layer.Name;
                 MessageBox.Show(s);
             }
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
     return(false);
 }
Esempio n. 4
0
 void AddView()
 {
     try
     {
         Map map = app.CurrentMap;
         if (map != null)
         {
             NameForm form = new NameForm(Views);
             if (form.ShowDialog(this) == DialogResult.OK)
             {
                 GeoLib.View view = new GeoLib.View(form.InputText, map);
                 if (Views.Add(view))
                 {
                     this.UpdateList(view);
                     if (app.GetControlsAttr(ControlsAttr.AutoSave))
                     {
                         using (Context context = Lib.GetContext()) view.Save(context);
                     }
                     if (OnViewAdded != null)
                     {
                         OnViewAdded(this, new ViewEventArgs(view));
                     }
                 }
                 else
                 {
                     string s = Locale.Get("_notuniquename") + ": " + view.Name;
                     MessageBox.Show(s);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }