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. 2
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. 3
0
        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);
        }
Esempio n. 4
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. 5
0
 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();
         }
     }
 }
Esempio n. 6
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. 7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            bool ok = false;

            using (TempCursor cur = new TempCursor(Cursors.WaitCursor))
            {
                ok = _presenter.CheckConnectionName() && _presenter.CreateSqlite();
            }
            if (ok)
            {
                this.ShowMessage(ResourceService.GetString("TITLE_CREATE_SQLITE"), ResourceService.GetString("MSG_SQLITE_CREATED"));
                base.Close();
            }
        }
Esempio n. 8
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);
         }
     }
 }
Esempio n. 9
0
        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();
                }
            }
        }
Esempio n. 10
0
 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);
             }
         }
     }
 }