private void btnOk_Click(object sender, System.EventArgs e) { if (!IsChanged()) { return; } try { Rect bounds; bounds.left = int.Parse(leftTextBox.Text); bounds.top = int.Parse(topTextBox.Text); bounds.right = int.Parse(rightTextBox.Text); bounds.bottom = int.Parse(bottomTextBox.Text); int smin = int.Parse(tbSmin.Text); int smax = int.Parse(tbSmax.Text); lib.StyleStr = tbStyle.Text; lib.SetBounds(bounds); lib.SMin = smin; lib.SMax = smax; lib.Name = tbName.Text; if (lib.HasDb) { lib.Save(BatchLevel.Current); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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(); } }
public void CreateLib(ConnectionInfo conn) { if (!SaveAndCloseLib()) { return; } try { using (WaitCursor wr = new WaitCursor(mainForm, Locale.Get("_createMap..."))) { connection = conn; Rect bounds = new Rect(0, 0, 1000000, 1000000); lib = new GLib(connection.CreateConnectionFactory(), bounds, new Indexer()); lib.Name = conn.name; lib.SMin = 10; lib.SMax = GeoLibUtils.RoundScale(bounds.MaxSize / 10); lib.StyleStr = "pc=red"; lib.Scales.InitScales(); GType type; GeomType[] geomTypes = { GeomType.Polygon, GeomType.Polyline, GeomType.Point, GeomType.Caption }; foreach (GeomType gt in geomTypes) { type = new GType(lib, gt); type.Name = Locale.Get(gt.ToString()); } if (conn.name.Length == 0) { lib.Name = "Generic library"; Geomethod.GeoLib.MapCreator.CreateTestObjects(lib, config.testObjectCount); } if (lib.HasDb) { lib.Save(BatchLevel.Object); try { UpdateConnectionList(connection); } catch (Exception ex) { Log.Exception(ex); } } LibLoaded(); } } catch (Exception ex) { Log.Exception(ex); CloseLib(); } }
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); } }