public override void Run() { string dir = FileService.GetDirectory(Res.GetString("TITLE_CONNECT_SHP_DIR")); if (FileService.DirectoryExists(dir)) { FdoConnection conn = new FdoConnection("OSGeo.SHP", "DefaultFileLocation=" + dir); FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>(); NamingService namer = ServiceManager.Instance.GetService <NamingService>(); string name = Msg.ShowInputBox(Res.GetString("TITLE_CONNECTION_NAME"), Res.GetString("PROMPT_ENTER_CONNECTION"), namer.GetDefaultConnectionName("OSGeo.SHP")); if (name == null) { return; } while (string.IsNullOrEmpty(name) || mgr.NameExists(name)) { Msg.ShowError(Res.GetString("ERR_CONNECTION_NAME_EMPTY_OR_EXISTS")); name = Msg.ShowInputBox(Res.GetString("TITLE_CONNECTION_NAME"), Res.GetString("PROMPT_ENTER_CONNECTION"), name); if (name == null) { return; } } mgr.AddConnection(name, conn); } }
public override void Run() { string file = FileService.OpenFile(Res.GetString("TITLE_CONNECT_SQLITE"), Res.GetString("FILTER_SQLITE")); if (FileService.FileExists(file)) { FdoConnection conn = ExpressUtility.CreateFlatFileConnection("OSGeo.SQLite", file); FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>(); NamingService namer = ServiceManager.Instance.GetService <NamingService>(); string name = Msg.ShowInputBox(Res.GetString("TITLE_CONNECTION_NAME"), Res.GetString("PROMPT_ENTER_CONNECTION"), namer.GetDefaultConnectionName("OSGeo.SQLite")); if (name == null) { return; } while (name == string.Empty || mgr.NameExists(name)) { Msg.ShowError(Res.GetString("ERR_CONNECTION_NAME_EMPTY_OR_EXISTS")); name = Msg.ShowInputBox(Res.GetString("TITLE_CONNECTION_NAME"), Res.GetString("PROMPT_ENTER_CONNECTION"), name); if (name == null) { return; } } mgr.AddConnection(name, conn); } }
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); } } }
public override void Run() { string path = FileService.SaveFile(Res.GetString("TITLE_EXPORT_DATASTORE_XML"), Res.GetString("FILTER_XML_FILES")); if (!string.IsNullOrEmpty(path)) { TreeNode connNode = Workbench.Instance.ObjectExplorer.GetSelectedNode(); FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>(); FdoConnection conn = mgr.GetConnection(connNode.Name); using (new TempCursor(Cursors.WaitCursor)) { using (var svc = conn.CreateFeatureService()) { var scs = new List <SpatialContextInfo>(svc.GetSpatialContexts()).ToArray(); var schemas = svc.DescribeSchema(); var mappings = svc.DescribeSchemaMapping(true); var dstore = new FdoDataStoreConfiguration(schemas, scs, mappings); dstore.Save(path); Log.InfoFormatted("Connection saved to: {0}", path); } } } }
/// <summary> /// Invokes the command. /// </summary> public override void Run() { EventWatcher.Initialize(); ServiceManager svcMgr = ServiceManager.Instance; Res.RegisterNeutralStrings(FdoToolbox.Base.Strings.ResourceManager); Res.RegisterNeutralImages(FdoToolbox.Base.Images.ResourceManager); Res.RegisterNeutralStrings(ResourceUtil.StringResourceManager); Workbench.WorkbenchInitialized += delegate { Workbench wb = Workbench.Instance; List <IObjectExplorerExtender> extenders = AddInTree.BuildItems <IObjectExplorerExtender>("/ObjectExplorer/Extenders", this); if (extenders != null) { foreach (IObjectExplorerExtender dec in extenders) { dec.Decorate(wb.ObjectExplorer); } } svcMgr.RestoreSession(); Msg.MainForm = wb; //Find and register drag and drop handlers List <IDragDropHandler> handlers = AddInTree.BuildItems <IDragDropHandler>("/FdoToolbox/DragDropHandlers", this); if (handlers != null) { IDragDropHandlerService handlerSvc = ServiceManager.Instance.GetService <IDragDropHandlerService>(); foreach (IDragDropHandler h in handlers) { handlerSvc.RegisterHandler(h); } } //Init the scripting engine ScriptingEngine engine = ScriptingEngine.Instance; ScriptManager mgr = new ScriptManager(); wb.ShowContent(mgr, ViewRegion.Right); string startup = Path.Combine(Application.StartupPath, "Scripts\\" + ScriptingEngine.STARTUP_SCRIPT); engine.ScriptLoaded += new ScriptEventHandler(EventWatcher.OnScriptLoaded); //Run startup script engine.RunScript(startup); wb.FormClosing += delegate { svcMgr.UnloadAllServices(); }; }; }
public override void Run() { string path = FileService.SaveFile(Res.GetString("TITLE_SAVE_CONNECTION"), Res.GetString("FILTER_CONNECTION_FILE")); if (!string.IsNullOrEmpty(path)) { TreeNode connNode = Workbench.Instance.ObjectExplorer.GetSelectedNode(); FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>(); FdoConnection conn = mgr.GetConnection(connNode.Name); conn.Save(path); Log.InfoFormatted("Connection saved to: {0}", path); } }
public override void Run() { TreeNode connNode = Workbench.Instance.ObjectExplorer.GetSelectedNode(); FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>(); FdoConnection conn = mgr.GetConnection(connNode.Name); if (!conn.Capability.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsSQL)) { MessageService.ShowError(Res.GetString("ERR_UNSUPPORTED_SQL")); } else { var dlg = new FdoSqlCommandDialog(conn); dlg.ShowDialog(); } }
public ToolBarCommand(Codon codon, object caller, bool createCommand) { this.RightToLeft = RightToLeft.Inherit; this.caller = caller; this.codon = codon; if (createCommand) { menuCommand = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]); } if (codon.Properties.Contains("label")) { Text = StringParser.Parse(codon.Properties["label"]); } if (Image == null && codon.Properties.Contains("icon")) { Image = ResourceService.GetBitmap(StringParser.Parse(codon.Properties["icon"])); } UpdateStatus(); UpdateText(); }
public override void Run() { TreeNode taskName = Workbench.Instance.ObjectExplorer.GetSelectedNode(); TaskManager mgr = ServiceManager.Instance.GetService <TaskManager>(); string name = Msg.ShowInputBox(Res.GetString("TITLE_RENAME_TASK"), Res.GetString("PROMPT_ENTER_NEW_TASK_NAME"), taskName.Name); if (name == null) { return; } while (name == string.Empty || mgr.NameExists(name)) { name = Msg.ShowInputBox(Res.GetString("TITLE_RENAME_TASK"), Res.GetString("PROMPT_ENTER_NEW_TASK_NAME"), taskName.Name); if (name == null) { return; } } mgr.RenameTask(taskName.Name, name); }
public override void Run() { TreeNode connNode = Workbench.Instance.ObjectExplorer.GetSelectedNode(); FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>(); string name = Msg.ShowInputBox(Res.GetString("TITLE_RENAME_CONNECTION"), Res.GetString("PROMPT_ENTER_NEW_CONNECTION_NAME"), connNode.Name); if (name == null) { return; } while (name == string.Empty || mgr.NameExists(name)) { name = Msg.ShowInputBox(Res.GetString("TITLE_RENAME_CONNECTION"), Res.GetString("PROMPT_ENTER_NEW_CONNECTION_NAME"), connNode.Name); if (name == null) { return; } } mgr.RenameConnection(connNode.Name, name); }
public override void Run() { TreeNode schemaNode = Workbench.Instance.ObjectExplorer.GetSelectedNode(); if (schemaNode.Level == 2 && MessageService.AskQuestion("Are you sure you want to delete this schema?")) { FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>(); FdoConnection conn = mgr.GetConnection(schemaNode.Parent.Name); using (FdoFeatureService service = conn.CreateFeatureService()) { try { service.DestroySchema(schemaNode.Name); Msg.ShowMessage(Res.GetString("MSG_SCHEMA_DELETED"), Res.GetString("TITLE_DELETE_SCHEMA")); Log.InfoFormatted(Res.GetString("LOG_SCHEMA_DELETED"), schemaNode.Name, schemaNode.Parent.Name); mgr.RefreshConnection(schemaNode.Parent.Name); } catch (OSGeo.FDO.Common.Exception ex) { Msg.ShowError(ex); } } } }
public ToolBarDropDownButton(Codon codon, object caller, ArrayList subItems) { this.RightToLeft = RightToLeft.Inherit; this.caller = caller; this.codon = codon; this.subItems = subItems; if (codon.Properties.Contains("label")) { Text = StringParser.Parse(codon.Properties["label"]); } if (Image == null && codon.Properties.Contains("icon")) { Image = ResourceService.GetBitmap(StringParser.Parse(codon.Properties["icon"])); } if (menuBuilder == null && codon.Properties.Contains("class")) { menuBuilder = codon.AddIn.CreateObject(StringParser.Parse(codon.Properties["class"])) as ICommand; menuBuilder.Owner = this; } UpdateStatus(); UpdateText(); }
static string GetValue(string propertyName, string[,] customTags) { // most properties start with res: in lowercase, // so we can save 2 string allocations here, in addition to all the jumps // All other prefixed properties {prefix:Key} shoulg get handled in the switch below. if (propertyName.StartsWith("res:", StringComparison.OrdinalIgnoreCase)) { try { return(Parse(ResourceService.GetString(propertyName.Substring(4)), customTags)); } catch (ResourceNotFoundException) { return(null); } } if (propertyName.StartsWith("DATE:", StringComparison.OrdinalIgnoreCase)) { try { return(DateTime.Now.ToString(propertyName.Split(':')[1])); } catch (Exception ex) { return(ex.Message); } } if (propertyName.Equals("DATE", StringComparison.OrdinalIgnoreCase)) { return(DateTime.Today.ToShortDateString()); } if (propertyName.Equals("TIME", StringComparison.OrdinalIgnoreCase)) { return(DateTime.Now.ToShortTimeString()); } if (propertyName.Equals("ProductName", StringComparison.OrdinalIgnoreCase)) { return(MessageService.ProductName); } if (propertyName.Equals("GUID", StringComparison.OrdinalIgnoreCase)) { return(Guid.NewGuid().ToString().ToUpperInvariant()); } if (customTags != null) { for (int j = 0; j < customTags.GetLength(0); ++j) { if (propertyName.Equals(customTags[j, 0], StringComparison.OrdinalIgnoreCase)) { return(customTags[j, 1]); } } } if (properties.ContainsKey(propertyName)) { return(properties[propertyName]); } if (stringTagProviders.ContainsKey(propertyName)) { return(stringTagProviders[propertyName].Convert(propertyName)); } int k = propertyName.IndexOf(':'); if (k <= 0) { return(null); } string prefix = propertyName.Substring(0, k); propertyName = propertyName.Substring(k + 1); switch (prefix.ToUpperInvariant()) { case "SDKTOOLPATH": return(FileUtility.GetSdkPath(propertyName)); case "ADDINPATH": foreach (AddIn addIn in AddInTree.AddIns) { if (addIn.Manifest.Identities.ContainsKey(propertyName)) { return(System.IO.Path.GetDirectoryName(addIn.FileName)); } } return(null); case "ENV": return(Environment.GetEnvironmentVariable(propertyName)); case "RES": try { return(Parse(ResourceService.GetString(propertyName), customTags)); } catch (ResourceNotFoundException) { return(null); } case "PROPERTY": return(GetProperty(propertyName)); default: if (propertyObjects.ContainsKey(prefix)) { return(Get(propertyObjects[prefix], propertyName)); } else { return(null); } } }
private static string GetValue(string propertyName, string[,] customTags) { if (propertyName.StartsWith("res:", System.StringComparison.OrdinalIgnoreCase)) { try { string result = StringParser.Parse(ResourceService.GetString(propertyName.Substring(4)), customTags); return(result); } catch (ResourceNotFoundException) { string result = null; return(result); } } if (propertyName.StartsWith("DATE:", System.StringComparison.OrdinalIgnoreCase)) { try { string result = System.DateTime.Now.ToString(propertyName.Split(new char[] { ':' })[1]); return(result); } catch (System.Exception ex) { string result = ex.Message; return(result); } } if (propertyName.Equals("DATE", System.StringComparison.OrdinalIgnoreCase)) { return(System.DateTime.Today.ToShortDateString()); } if (propertyName.Equals("TIME", System.StringComparison.OrdinalIgnoreCase)) { return(System.DateTime.Now.ToShortTimeString()); } if (propertyName.Equals("ProductName", System.StringComparison.OrdinalIgnoreCase)) { return("ProductName"); } if (propertyName.Equals("GUID", System.StringComparison.OrdinalIgnoreCase)) { return(System.Guid.NewGuid().ToString().ToUpperInvariant()); } if (customTags != null) { for (int i = 0; i < customTags.GetLength(0); i++) { if (propertyName.Equals(customTags[i, 0], System.StringComparison.OrdinalIgnoreCase)) { return(customTags[i, 1]); } } } if (StringParser.properties.ContainsKey(propertyName)) { return(StringParser.properties[propertyName]); } if (StringParser.stringTagProviders.ContainsKey(propertyName)) { return(StringParser.stringTagProviders[propertyName].Convert(propertyName)); } int num = propertyName.IndexOf(':'); if (num <= 0) { return(null); } string text = propertyName.Substring(0, num); propertyName = propertyName.Substring(num + 1); string a; if ((a = text.ToUpperInvariant()) != null) { if (a == "ADDINPATH") { foreach (AddIn current in AddInTree.AddIns) { if (current.Manifest.Identities.ContainsKey(propertyName)) { string result = System.IO.Path.GetDirectoryName(current.FileName); return(result); } } return(null); } if (a == "ENV") { return(System.Environment.GetEnvironmentVariable(propertyName)); } if (a == "PROPERTY") { return(StringParser.GetProperty(propertyName)); } } if (StringParser.propertyObjects.ContainsKey(text)) { return(StringParser.Get(StringParser.propertyObjects[text], propertyName)); } return(null); }
/// <summary> /// Evaluates a property using the StringParser. Equivalent to StringParser.Parse("${" + propertyName + "}"); /// </summary> public static string GetValue(string propertyName, params StringTagPair[] customTags) { if (propertyName == null) { throw new ArgumentNullException("propertyName"); } if (customTags != null) { foreach (StringTagPair pair in customTags) { if (propertyName.Equals(pair.Tag, StringComparison.OrdinalIgnoreCase)) { return(pair.Value); } } } int k = propertyName.IndexOf(':'); if (k <= 0) { // it's property without prefix if (propertyName.Equals("DATE", StringComparison.OrdinalIgnoreCase)) { return(DateTime.Today.ToShortDateString()); } if (propertyName.Equals("TIME", StringComparison.OrdinalIgnoreCase)) { return(DateTime.Now.ToShortTimeString()); } if (propertyName.Equals("ProductName", StringComparison.OrdinalIgnoreCase)) { return(MessageService.ProductName); } if (propertyName.Equals("GUID", StringComparison.OrdinalIgnoreCase)) { return(Guid.NewGuid().ToString().ToUpperInvariant()); } if (propertyName.Equals("USER", StringComparison.OrdinalIgnoreCase)) { return(Environment.UserName); } if (propertyName.Equals("Version", StringComparison.OrdinalIgnoreCase)) { return(RevisionClass.FullVersion); } if (propertyName.Equals("CONFIGDIRECTORY", StringComparison.OrdinalIgnoreCase)) { return(PropertyService.ConfigDirectory); } foreach (IStringTagProvider provider in stringTagProviders) { string result = provider.ProvideString(propertyName, customTags); if (result != null) { return(result); } } return(null); } else { // it's a prefixed property // res: properties are quite common, so optimize by testing for them first // before allocaing the prefix/propertyName strings // All other prefixed properties {prefix:Key} shoulg get handled in the switch below. if (propertyName.StartsWith("res:", StringComparison.OrdinalIgnoreCase)) { try { return(Parse(ResourceService.GetString(propertyName.Substring(4)), customTags)); } catch (ResourceNotFoundException) { return(null); } } string prefix = propertyName.Substring(0, k); propertyName = propertyName.Substring(k + 1); switch (prefix.ToUpperInvariant()) { case "SDKTOOLPATH": return(FileUtility.GetSdkPath(propertyName)); case "ADDINPATH": foreach (AddIn addIn in AddInTree.AddIns) { if (addIn.Manifest.Identities.ContainsKey(propertyName)) { return(System.IO.Path.GetDirectoryName(addIn.FileName)); } } return(null); case "DATE": try { return(DateTime.Now.ToString(propertyName, CultureInfo.CurrentCulture)); } catch (Exception ex) { return(ex.Message); } case "ENV": return(Environment.GetEnvironmentVariable(propertyName)); case "PROPERTY": return(GetProperty(propertyName)); default: IStringTagProvider provider; if (prefixedStringTagProviders.TryGetValue(prefix, out provider)) { return(provider.ProvideString(propertyName, customTags)); } else { return(null); } } } }
/// <summary> /// This method was autogenerated - do not change the contents manually /// </summary> private void InitializeComponents(bool chooseLocationEnabled) { // // Set up generated class SaveErrorChooseDialog // this.ClientSize = new Size(508, 320); this.SuspendLayout(); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "SaveErrorChooseDialog"; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.ShowInTaskbar = false; this.StartPosition = FormStartPosition.CenterScreen; // // Set up member descriptionLabel // this.descriptionLabel = new Label(); this.descriptionLabel.Name = "descriptionLabel"; this.descriptionLabel.Location = new Point(8, 8); this.descriptionLabel.Size = new Size(584, 24); this.descriptionLabel.TabIndex = 3; this.descriptionLabel.Anchor = (System.Windows.Forms.AnchorStyles.Top | (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)); this.descriptionLabel.TextAlign = System.Drawing.ContentAlignment.BottomLeft; this.descriptionLabel.Text = StringParser.Parse("${res:ICSharpCode.Core.Services.ErrorDialogs.DescriptionLabel}"); this.Controls.Add(descriptionLabel); // // Set up member descriptionTextBox // this.descriptionTextBox = new TextBox(); this.descriptionTextBox.Multiline = true; this.descriptionTextBox.Size = new Size(584, 237); this.descriptionTextBox.Location = new Point(8, 40); this.descriptionTextBox.TabIndex = 2; this.descriptionTextBox.Anchor = (System.Windows.Forms.AnchorStyles.Top | (System.Windows.Forms.AnchorStyles.Bottom | (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.descriptionTextBox.ReadOnly = true; this.descriptionTextBox.Name = "descriptionTextBox"; this.Controls.Add(descriptionTextBox); // // Set up member retryButton // this.retryButton = new Button(); this.retryButton.DialogResult = System.Windows.Forms.DialogResult.Retry; this.retryButton.Name = "retryButton"; this.retryButton.TabIndex = 5; this.retryButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); this.retryButton.Text = StringParser.Parse("${res:Global.RetryButtonText}"); this.retryButton.Size = new Size(110, 27); this.retryButton.Location = new Point(28, 285); this.Controls.Add(retryButton); // // Set up member ignoreButton // this.ignoreButton = new Button(); this.ignoreButton.Name = "ignoreButton"; this.ignoreButton.DialogResult = System.Windows.Forms.DialogResult.Ignore; this.ignoreButton.TabIndex = 4; this.ignoreButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); this.ignoreButton.Text = StringParser.Parse("${res:Global.IgnoreButtonText}"); this.ignoreButton.Size = new Size(110, 27); this.ignoreButton.Location = new Point(146, 285); this.Controls.Add(ignoreButton); // // Set up member exceptionButton // this.exceptionButton = new Button(); this.exceptionButton.TabIndex = 1; this.exceptionButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); this.exceptionButton.Name = "exceptionButton"; this.exceptionButton.Text = ResourceService.GetString("ICSharpCode.Core.Services.ErrorDialogs.ShowExceptionButton"); this.exceptionButton.Size = new Size(110, 27); this.exceptionButton.Location = new Point(382, 285); this.exceptionButton.Click += new EventHandler(ShowException); this.Controls.Add(exceptionButton); if (chooseLocationEnabled) { // // Set up member chooseLocationButton // this.chooseLocationButton = new Button(); this.chooseLocationButton.Name = "chooseLocationButton"; this.chooseLocationButton.DialogResult = System.Windows.Forms.DialogResult.OK; this.chooseLocationButton.TabIndex = 0; this.chooseLocationButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); this.chooseLocationButton.Text = ResourceService.GetString("Global.ChooseLocationButtonText"); this.chooseLocationButton.Size = new Size(110, 27); this.chooseLocationButton.Location = new Point(264, 285); } this.Controls.Add(chooseLocationButton); this.ResumeLayout(false); this.Size = new Size(526, 262); }