A helper class to temporarily change the active cursor. All operations done within the scope of this class (up to its disposal) will run with the specified active cursor.
Inheritance: IDisposable
Esempio n. 1
0
 private void btnTest_Click(object sender, EventArgs e)
 {
     using (TempCursor cur = new TempCursor(Cursors.WaitCursor))
     {
         _presenter.TestConnection();
     }
 }
        internal static void OnDragDrop(object sender, DragEventArgs e)
        {
            Array a = e.Data.GetData(DataFormats.FileDrop) as Array;
            if (a != null && a.Length > 0)
            {
                IDragDropHandlerService handlerSvc = ServiceManager.Instance.GetService<IDragDropHandlerService>();
                for (int i = 0; i < a.Length; i++)
                {
                    string file = a.GetValue(i).ToString();

                    IList<IDragDropHandler> handlers = handlerSvc.GetHandlersForFile(file);

                    if (handlers.Count == 0)
                        continue;

                    if (handlers.Count == 1)
                    {
                        using (TempCursor cur = new TempCursor(Cursors.WaitCursor))
                        {
                            handlers[0].HandleDrop(file);
                        }
                    }

                    if (handlers.Count > 1)
                    {
                        //Resolve which handler to use
                    }
                }
            }
        }
Esempio n. 3
0
 private void cmbProvider_SelectionChanged(object sender, EventArgs e)
 {
     using (TempCursor cur = new TempCursor(Cursors.WaitCursor))
     {
         pwdCells.Clear();
         _presenter.ProviderChanged();
     }
 }
Esempio n. 4
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     bool ok = false;
     using (TempCursor cur = new TempCursor(Cursors.WaitCursor))
     {
         ok = _presenter.CheckConnectionName() && _presenter.CreateShp();
     }
     if (ok)
     {
         this.ShowMessage(ResourceService.GetString("TITLE_CREATE_SHP"), ResourceService.GetString("MSG_SHP_CREATED"));
         base.Close();
     }
 }
Esempio n. 5
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     using (TempCursor cur = new TempCursor(Cursors.WaitCursor))
     {
         if (!_presenter.Connect())
         {
             this.ShowError("Failed to connect");
         }
         else
         {
             base.Close();
         }
     }
 }
 private void btnImport_Click(object sender, EventArgs e)
 {
     string file = FileService.OpenFile("Open XML Configuration", "XML files (*.xml)|*.xml");
     if (!string.IsNullOrEmpty(file))
     {
         var conf = FdoDataStoreConfiguration.FromFile(file);
         if (!_context.IsConnected)
         {
             using (var cur = new TempCursor(Cursors.WaitCursor))
             {
                 _context.SetConfiguration(conf);
                 schemaView.Reset();
             }
         }
         else
         {
             //Prompt for elements to import
             var impDiag = new ImportElementsDialog(conf, _context);
             impDiag.ShowDialog();
         }
     }
 }
        private bool ExportToFile(string provider, string file, int maxSchemas, int maxSpatialContexts)
        {
            var conf = _context.GetConfiguration();
            if (maxSchemas > 0 && conf.Schemas.Count > maxSchemas)
            {
                ShowError("This provider only allows " + maxSchemas + " feature schema(s)");
                return false;
            }
            if (maxSpatialContexts > 0 && conf.SpatialContexts.Length > maxSpatialContexts)
            {
                ShowError("This provider only allows " + maxSpatialContexts + " spatial context(s)");
                return false;
            }

            if (ExpressUtility.CreateFlatFileDataSource(provider, file))
            {
                var conn = ExpressUtility.CreateFlatFileConnection(provider, file);
                var schema = conf.Schemas[0];
                schema = FdoSchemaUtil.CloneSchema(schema, true);
                using (var svc = conn.CreateFeatureService())
                {
                    IncompatibleSchema incs;
                    if (!svc.CanApplySchema(schema, out incs))
                    {
                        string msg = "This schema has incompatibilities. Attempt to fix it? " + incs.ToString();
                        if (!WrappedMessageBox.Confirm("Incompatible schema", msg, MessageBoxText.YesNo))
                        {
                            return false;
                        }
                        schema = svc.AlterSchema(schema, incs);
                    }

                    using (var cur = new TempCursor(Cursors.WaitCursor))
                    {
                        foreach (var sc in conf.SpatialContexts)
                        {
                            svc.CreateSpatialContext(sc, true);
                        }

                        //Only for SQLite, but this is general enough
                        var fscs = svc.DescribeSchema();
                        if (fscs.Count == 1)
                        {
                            var fsc = fscs[0];
                            foreach (ClassDefinition cls in schema.Classes)
                            {
                                var klass = FdoSchemaUtil.CloneClass(cls);
                                fsc.Classes.Add(klass);
                            }
                            schema = fsc;
                        }
                        svc.ApplySchema(schema);
                    }
                }
                conn.Close();
            }
            return true;
        }
 private void btnSaveSpatialContexts_Click(object sender, EventArgs e)
 {
     using (var cur = new TempCursor(Cursors.WaitCursor))
     {
         ResetApplyButton();
         if (_context.SaveSpatialContexts())
         {
             MessageService.ShowMessage("Spatial Context changes have been saved");
             EvaluateCommandStates();
         }
     }
 }
 private void btnSaveSelectedSchema_Click(object sender, EventArgs e)
 {
     using (var cur = new TempCursor(Cursors.WaitCursor))
     {
         ResetApplyButton();
         string schName = schemaView.GetSelectedSchema();
         if (!string.IsNullOrEmpty(schName))
         {
             try
             {
                 if (_context.SaveSchema(schName))
                 {
                     MessageService.ShowMessage("Schema saved");
                     schemaView.Reset();
                 }
             }
             catch (Exception ex)
             {
                 MessageService.ShowError(ex);
             }
         }
     }
 }
Esempio n. 10
0
 private void btnSaveEverything_Click(object sender, EventArgs e)
 {
     using (var cur = new TempCursor(Cursors.WaitCursor))
     {
         ResetApplyButton();
         if (_context.SaveSpatialContexts() && _context.SaveAllSchemas())
         {
             MessageService.ShowMessage("Changes have been saved");
             schemaView.Reset();
         }
     }
 }
Esempio n. 11
0
 private void btnSaveAllSchemas_Click(object sender, EventArgs e)
 {
     using (var cur = new TempCursor(Cursors.WaitCursor))
     {
         try
         {
             ResetApplyButton();
             if (_context.SaveAllSchemas())
             {
                 MessageService.ShowMessage("Schemas saved");
                 schemaView.Reset();
             }
         }
         catch (Exception ex)
         {
             MessageService.ShowError(ex);
         }
     }
 }
 private void cmbProvider_SelectionChanged(object sender, EventArgs e)
 {
     using (TempCursor cur = new TempCursor(Cursors.WaitCursor))
     {
         pwdCells.Clear();
         _presenter.ProviderChanged();
     }
 }
Esempio n. 13
0
        public override void Run()
        {
            string path = FileService.OpenFile(Res.GetString("TITLE_LOAD_CONNECTION"), Res.GetString("FILTER_CONNECTION_FILE"));
            if (FileService.FileExists(path))
            {
                FdoConnection conn = FdoConnection.LoadFromFile(path);
                FdoConnectionManager mgr = ServiceManager.Instance.GetService<FdoConnectionManager>();

                string name = string.Empty;
                name = Msg.ShowInputBox(Res.GetString("TITLE_NEW_CONNECTION"), Res.GetString("PROMPT_ENTER_NEW_CONNECTION_NAME"), name);
                if (name == null)
                    return;

                while (name == string.Empty || mgr.NameExists(name))
                {
                    name = Msg.ShowInputBox(Res.GetString("TITLE_NEW_CONNECTION"), Res.GetString("PROMPT_ENTER_NEW_CONNECTION_NAME"), name);
                    if (name == null)
                        return;
                }

                using (TempCursor cur = new TempCursor(Cursors.WaitCursor))
                {
                    mgr.AddConnection(name, conn);
                }
            }
        }
Esempio n. 14
0
 public override void Run()
 {
     TreeNode connNode = Workbench.Instance.ObjectExplorer.GetSelectedNode();
     FdoConnectionManager mgr = ServiceManager.Instance.GetService<FdoConnectionManager>();
     using (TempCursor cur = new TempCursor(Cursors.WaitCursor))
     {
         mgr.RefreshConnection(connNode.Name);
     }
 }
Esempio n. 15
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     using (TempCursor cur = new TempCursor(Cursors.WaitCursor))
     {
         if (!_presenter.Connect())
             this.ShowError("Failed to connect");
         else
             base.Close();
     }
 }
Esempio n. 16
0
 private void btnTest_Click(object sender, EventArgs e)
 {
     using (TempCursor cur = new TempCursor(Cursors.WaitCursor))
     {
         _presenter.TestConnection();
     }
 }