Esempio n. 1
0
 private void btnChange_Click(object sender, EventArgs e)
 {
     if (CanChange)
     {
         NamedColor origColor = SelectedNamedColor;
         string     name      = tbColorName.Text.Trim();
         Color      color     = ucColor.BackColor;
         origColor.Name  = name;
         origColor.Color = color;
         foreach (ListViewItem lvi in listView.Items)
         {
             if (lvi.Tag == origColor)
             {
                 lvi.Text = origColor.Name;
                 lvi.SubItems[1].BackColor = origColor.Color;
                 break;
             }
         }
         listView.Sort();
         UpdateControls();
         if (app.GetControlsAttr(ControlsAttr.AutoSave))
         {
             using (Context context = lib.GetContext()) origColor.Save(context);
         }
         if (OnNamedColorChanged != null)
         {
             OnNamedColorChanged(this, new NamedColorEventArgs(origColor));
         }
     }
 }
Esempio n. 2
0
 internal void Save()
 {
     try
     {
         using (WaitCursor wc = new WaitCursor(this, Locale.Get("_savingData") + "..."))
         {
             if (app.Connection == null)
             {
                 string filePath = SaveAs();
                 if (filePath != null)
                 {
                     app.Lib.SetSaved();
                     string connName = Path.GetFileNameWithoutExtension(filePath);
                     app.Connection = new ConnectionInfo(connName, "", "", "file=" + filePath);
                 }
             }
             else
             {
                 GLib lib = app.Lib;
                 if (lib != null)
                 {
                     if (app.Connection.connectionString.Length > 0)
                     {
                         using (Context context = lib.GetContext())
                         {
                             context.Filter = Filter.All;
                             lib.Save(context);
                             lib.SetSaved();
                         }
                     }
                     else if (app.Connection.FilePath.Length > 0)
                     {
                         string filePath = app.Connection.FilePath;
                         using (FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate))
                         {
                             using (BinaryWriter bw = new BinaryWriter(fs))
                             {
                                 using (Context context = lib.GetContext())
                                 {
                                     context.Filter = new Filter(BatchLevel.Object);
                                     lib.Write(context, bw);
                                     lib.SetSaved();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
     finally
     {
         UpdateLibControls();
     }
 }
Esempio n. 3
0
 void AddBgImage()
 {
     try
     {
         GLib lib = Lib;
         Map  map = app.CurrentMap;
         if (lib != null && map != null)
         {
             if (this.dlgOpenFile.ShowDialog() == DialogResult.OK)
             {
                 BgImage bgImage = new BgImage(map);
                 bgImage.FilePath = dlgOpenFile.FileName;
                 BgImages.Add(bgImage);
                 UpdateList();
                 if (app.GetControlsAttr(ControlsAttr.AutoSave))
                 {
                     using (Context context = lib.GetContext()) bgImage.Save(context);
                 }
                 if (OnBgImageAdded != null)
                 {
                     OnBgImageAdded(this, new BgImageEventArgs(bgImage));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }
Esempio n. 4
0
        void Save(string filePath)
        {
            GLib lib = app.Lib;

            if (lib != null)
            {
                using (FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate))
                {
                    using (BinaryWriter bw = new BinaryWriter(fs))
                    {
                        using (Context context = lib.GetContext())
                        {
                            context.Filter = new Filter(BatchLevel.Object);
                            lib.Write(context, bw);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
 void Export()
 {
     try
     {
         GLib lib = app.Lib;
         if (lib != null)
         {
             CreateDbForm form = GetCreateDbForm();
             if (form.ShowDialog() == DialogResult.OK)
             {
                 using (WaitCursor wc = new WaitCursor(this, Locale.Get("_exportingData...")))
                 {
                     if (form.IsDbProvider)
                     {
                         ConnectionInfo gisConn = MapCreator.CreateGisDb(form.DbCreationProperties);
                         using (Context context = lib.GetContext())
                         {
                             context.TargetConn = gisConn.CreateConnection();
                             context.Filter     = Filter.All;
                             lib.Save(context);
                         }
                         app.UpdateConnectionList(gisConn);
                     }
                     else
                     {
                         Save(form.FilePath);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }