/// <summary>Allows the user to browse the file system for a stylesheet.</summary>
        /// <returns>The stylesheet filename the user selected; otherwise null.</returns>
        public static string BrowseForStylesheetFile()
        {
            var dlg = new SelectFileDialog(GettextCatalog.GetString("Select XSLT Stylesheet"))
            {
                TransientFor = IdeApp.Workbench.RootWindow,
            };

            dlg.AddFilter(new SelectFileDialogFilter(
                              GettextCatalog.GetString("XML Files"),
                              new string[] { "*.xml" },
                              new string[] { "text/xml", "application/xml" }
                              ));
            dlg.AddFilter(new SelectFileDialogFilter(
                              GettextCatalog.GetString("XSL Files"),
                              new string[] { "*.xslt", "*.xsl" },
                              new string[] { "text/x-xslt" }
                              ));
            dlg.AddAllFilesFilter();

            if (dlg.Run())
            {
                return(dlg.SelectedFile);
            }
            return(null);
        }
        void AddColorScheme(object sender, EventArgs args)
        {
            var dialog = new SelectFileDialog(GettextCatalog.GetString("Highlighting Scheme"), Gtk.FileChooserAction.Open)
            {
                TransientFor = this.Toplevel as Gtk.Window,
            };

            dialog.AddFilter(GettextCatalog.GetString("Color schemes"), "*.json");
            dialog.AddFilter(GettextCatalog.GetString("Visual Studio .NET settings"), "*.vssettings");
            if (!dialog.Run())
            {
                return;
            }

            string newFileName = SourceEditorDisplayBinding.SyntaxModePath.Combine(dialog.SelectedFile.FileName);

            bool success = true;

            try {
                File.Copy(dialog.SelectedFile.FullPath, newFileName);
            } catch (Exception e) {
                success = false;
                LoggingService.LogError("Can't copy syntax mode file.", e);
            }
            if (success)
            {
                SourceEditorDisplayBinding.LoadCustomStylesAndModes();
                ShowStyles();
            }
        }
		protected virtual void OnButton24Clicked (object sender, System.EventArgs e)
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Add items to toolbox")) {
				SelectMultiple = true,
				TransientFor = this,
			};
			dialog.AddFilter (null, "*.dll");
			if (dialog.Run ()) {
				indexModified = true;
				// Add the new files to the index
				using (var monitor = new MessageDialogProgressMonitor (true, false, false, true)) {
					monitor.BeginTask (GettextCatalog.GetString ("Looking for components..."), dialog.SelectedFiles.Length);
					foreach (string s in dialog.SelectedFiles) {
						var cif = index.AddFile (s);
						monitor.Step (1);
						if (cif != null) {
							// Select all new items by default
							foreach (var it in cif.Components)
								currentItems.Add (it, it);
						}
						else
							MessageService.ShowWarning (GettextCatalog.GetString ("The file '{0}' does not contain any component.", s));
					}
				}
				Fill ();
			}
		}
        public void Add()
        {
            var project = (DotNetProject)CurrentNode.GetParentDataItem(typeof(DotNetProject), true);
            var inrproj = project as INativeReferencingProject;

            var dlg = new SelectFileDialog(GettextCatalog.GetString("Select Native Library"), Gtk.FileChooserAction.Open);

            dlg.SelectMultiple = true;
            dlg.AddAllFilesFilter();

            foreach (var filter in inrproj.NativeReferenceFileFilters)
            {
                dlg.AddFilter(filter.Description, "*" + filter.FileExtension);
            }

            if (!dlg.Run())
            {
                return;
            }

            foreach (var file in dlg.SelectedFiles)
            {
                var item = new NativeReference(file, inrproj.GetNativeReferenceKind(file));
                project.Items.Add(item);
            }

            IdeApp.ProjectOperations.Save(project);
        }
示例#5
0
        void PrivateKeyLocationButton_Clicked(object sender, EventArgs e)
        {
            var dialog = new SelectFileDialog(GettextCatalog.GetString("Select a private SSH key to use."))
            {
                ShowHidden    = true,
                CurrentFolder = System.IO.File.Exists(privateKeyLocationTextEntry.Text) ?
                                System.IO.Path.GetDirectoryName(privateKeyLocationTextEntry.Text) : Environment.GetFolderPath(Environment.SpecialFolder.Personal)
            };

            dialog.AddFilter(GettextCatalog.GetString("Private Key Files"), "*");
            if (dialog.Run())
            {
                privateKeyLocationTextEntry.Text = dialog.SelectedFile;
                if (System.IO.File.Exists(privateKeyLocationTextEntry.Text + ".pub"))
                {
                    publicKeyLocationTextEntry.Text = privateKeyLocationTextEntry.Text + ".pub";
                }

                OnCredentialsChanged();

                if (string.IsNullOrEmpty(Credentials.PublicKey))
                {
                    publicKeyLocationTextEntry.SetFocus();
                }
                else if (passphraseEntry.Sensitive)
                {
                    passphraseEntry.SetFocus();
                }
            }
            ;
        }
        void HandleButtonExportClicked(object sender, EventArgs e)
        {
            var dialog = new SelectFileDialog(GettextCatalog.GetString("Highlighting Scheme"), Gtk.FileChooserAction.Save)
            {
                TransientFor = this.Toplevel as Gtk.Window,
            };

            dialog.AddFilter(GettextCatalog.GetString("Color schemes"), "*.json");
            if (!dialog.Run())
            {
                return;
            }
            TreeIter selectedIter;

            if (styleTreeview.Selection.GetSelected(out selectedIter))
            {
                var sheme        = (Mono.TextEditor.Highlighting.ColorScheme) this.styleStore.GetValue(selectedIter, 1);
                var selectedFile = dialog.SelectedFile.ToString();
                if (!selectedFile.EndsWith(".json", StringComparison.Ordinal))
                {
                    selectedFile += ".json";
                }
                sheme.Save(selectedFile);
            }
        }
示例#7
0
        private static void OpenCmd_Execute(object sender, CommandRunArgs e)
        {
            string str = (string)null;

            if (e.DataItem == null)
            {
                string lastBrowserLocation = Services.RecentFileService.LastBrowserLocation;
                if (Option.IsXP)
                {
                    str = FileChooserDialogModel.GetOpenFilePath(new string[1] {
                        "*.ccs"
                    }, "Open File", false, lastBrowserLocation).FileName;
                    Services.RecentFileService.LastBrowserLocation = Path.GetDirectoryName(str);
                }
                else
                {
                    SelectFileDialog selectFileDialog = new SelectFileDialog();
                    selectFileDialog.Title          = LanguageInfo.Menu_File_OpenProject;
                    selectFileDialog.Action         = FileChooserAction.Open;
                    selectFileDialog.SelectMultiple = false;
                    selectFileDialog.CurrentFolder  = (FilePath)lastBrowserLocation;
                    selectFileDialog.AddFilter("Solution Files", "*.ccs");
                    if (selectFileDialog.Run())
                    {
                        str = (string)selectFileDialog.SelectedFile;
                        Services.RecentFileService.LastBrowserLocation = Path.GetDirectoryName(str);
                    }
                }
            }
            else
            {
                str = e.DataItem.ToString();
            }
            StartInfoService.Instance.HandleOpenSolution(str);
        }
        void AddColorScheme(object sender, EventArgs args)
        {
            var dialog = new SelectFileDialog(GettextCatalog.GetString("Highlighting Scheme"), Gtk.FileChooserAction.Open)
            {
                TransientFor = this.Toplevel as Gtk.Window,
            };

            dialog.AddFilter(null, "*.xml");
            if (!dialog.Run())
            {
                return;
            }

            System.Collections.Generic.List <System.Xml.Schema.ValidationEventArgs> validationResult;
            try {
                validationResult = Mono.TextEditor.Highlighting.SyntaxModeService.ValidateStyleFile(dialog.SelectedFile);
            } catch (Exception) {
                MessageService.ShowError(GettextCatalog.GetString("Validation of style file failed."));
                return;
            }

            if (validationResult.Count == 0)
            {
                string newFileName = SourceEditorDisplayBinding.SyntaxModePath.Combine(dialog.SelectedFile.FileName);
                if (!newFileName.EndsWith("Style.xml"))
                {
                    newFileName = SourceEditorDisplayBinding.SyntaxModePath.Combine(dialog.SelectedFile.FileNameWithoutExtension + "Style.xml");
                }
                bool success = true;
                try {
                    File.Copy(dialog.SelectedFile, newFileName);
                } catch (Exception e) {
                    success = false;
                    LoggingService.LogError("Can't copy syntax mode file.", e);
                }
                if (success)
                {
                    SourceEditorDisplayBinding.LoadCustomStylesAndModes();
                    ShowStyles();
                }
            }
            else
            {
                StringBuilder errorMessage = new StringBuilder();
                errorMessage.AppendLine(GettextCatalog.GetString("Validation of style file failed."));
                int count = 0;
                foreach (System.Xml.Schema.ValidationEventArgs vArg in validationResult)
                {
                    errorMessage.AppendLine(vArg.Message);
                    if (count++ > 5)
                    {
                        errorMessage.AppendLine("...");
                        break;
                    }
                }
                MessageService.ShowError(errorMessage.ToString());
            }
        }
示例#9
0
        protected override void Run()
        {
            var proj = GetSelectedMonoMacProject();

            var settings = proj.UserProperties.GetValue <MonoMacPackagingSettings> (PROP_KEY)
                           ?? MonoMacPackagingSettings.GetAppStoreDefault();

            MonoMacPackagingSettingsDialog dlg = null;

            try {
                dlg = new MonoMacPackagingSettingsDialog();
                dlg.LoadSettings(settings);
                if (MessageService.RunCustomDialog(dlg) != (int)ResponseType.Ok)
                {
                    return;
                }
                dlg.SaveSettings(settings);
            } finally {
                if (dlg != null)
                {
                    dlg.Destroy();
                }
            }

            var configSel = IdeApp.Workspace.ActiveConfiguration;
            var cfg       = (MonoMacProjectConfiguration)proj.GetConfiguration(configSel);

            var ext = settings.CreatePackage? ".pkg" : ".app";

            var fileDlg = new SelectFileDialog()
            {
                Title = settings.CreatePackage?
                        GettextCatalog.GetString("Save Installer Package") :
                        GettextCatalog.GetString("Save Application Bundle"),
                InitialFileName = cfg.AppName + ext,
                Action          = FileChooserAction.Save
            };

            fileDlg.DefaultFilter = fileDlg.AddFilter("", "*" + ext);

            if (!fileDlg.Run())
            {
                return;
            }

            proj.UserProperties.SetValue(PROP_KEY, settings);

            var target = fileDlg.SelectedFile;

            if (!string.Equals(target.Extension, ext, StringComparison.OrdinalIgnoreCase))
            {
                target.ChangeExtension(ext);
            }

            MonoMacPackaging.Package(proj, configSel, settings, target);
        }
示例#10
0
        void AddColorScheme(object sender, EventArgs args)
        {
            var dialog = new SelectFileDialog(GettextCatalog.GetString("Import Color Theme"), MonoDevelop.Components.FileChooserAction.Open)
            {
                TransientFor = this.Toplevel as Gtk.Window,
            };

            dialog.AddFilter(GettextCatalog.GetString("Color themes (Visual Studio, Xamarin Studio, TextMate) "), "*.json", "*.vssettings", "*.tmTheme");
            if (!dialog.Run())
            {
                return;
            }

            var    fileName    = dialog.SelectedFile.FileName;
            var    filePath    = dialog.SelectedFile.FullPath;
            string newFilePath = TextEditorDisplayBinding.SyntaxModePath.Combine(fileName);

            if (!SyntaxHighlightingService.IsValidTheme(filePath))
            {
                MessageService.ShowError(GettextCatalog.GetString("Could not import color theme."));
                return;
            }

            bool success = true;

            try {
                if (File.Exists(newFilePath))
                {
                    var answer = MessageService.AskQuestion(
                        GettextCatalog.GetString(
                            "A color theme with the name '{0}' already exists in your theme folder. Would you like to replace it?",
                            fileName
                            ),
                        AlertButton.Cancel,
                        AlertButton.Replace
                        );
                    if (answer != AlertButton.Replace)
                    {
                        return;
                    }
                    File.Delete(newFilePath);
                }
                File.Copy(filePath, newFilePath);
            } catch (Exception e) {
                success = false;
                LoggingService.LogError("Can't copy color theme file.", e);
            }
            if (success)
            {
                SyntaxHighlightingService.LoadStylesAndModesInPath(TextEditorDisplayBinding.SyntaxModePath);
                TextEditorDisplayBinding.LoadCustomStylesAndModes();
                ShowStyles();
            }
        }
示例#11
0
        void AddColorScheme(object sender, EventArgs args)
        {
            var dialog = new SelectFileDialog(GettextCatalog.GetString("Highlighting Scheme"), MonoDevelop.Components.FileChooserAction.Open)
            {
                TransientFor = this.Toplevel as Gtk.Window,
            };

            dialog.AddFilter(GettextCatalog.GetString("Color schemes"), "*.json");
            dialog.AddFilter(GettextCatalog.GetString("Visual Studio .NET settings"), "*.vssettings");
            if (!dialog.Run())
            {
                return;
            }

            string newFileName = MonoDevelop.Ide.Editor.TextEditorDisplayBinding.SyntaxModePath.Combine(dialog.SelectedFile.FileName);

            bool success = true;

            try {
                if (File.Exists(newFileName))
                {
                    MessageService.ShowError(string.Format(GettextCatalog.GetString("Highlighting with the same name already exists. Remove {0} first."), System.IO.Path.GetFileNameWithoutExtension(newFileName)));
                    return;
                }

                File.Copy(dialog.SelectedFile.FullPath, newFileName);
            } catch (Exception e) {
                success = false;
                LoggingService.LogError("Can't copy syntax mode file.", e);
            }
            if (success)
            {
                Mono.TextEditor.Highlighting.SyntaxModeService.LoadStylesAndModes(TextEditorDisplayBinding.SyntaxModePath);
                MonoDevelop.Ide.Editor.Highlighting.SyntaxModeService.LoadStylesAndModes(TextEditorDisplayBinding.SyntaxModePath);
                MonoDevelop.Ide.Editor.TextEditorDisplayBinding.LoadCustomStylesAndModes();
                ShowStyles();
            }
        }
        void AddLanguageBundle(object sender, EventArgs e)
        {
            var dialog = new SelectFileDialog(GettextCatalog.GetString("Language Bundles"), MonoDevelop.Components.FileChooserAction.Open)
            {
                TransientFor = this.Toplevel as Gtk.Window,
            };

            dialog.AddFilter(GettextCatalog.GetString("Bundles"), "*.tmBundle", "*.sublime-package", "*.tmbundle");
            if (!dialog.Run())
            {
                return;
            }
            string newFileName = SyntaxHighlightingService.LanguageBundlePath.Combine(dialog.SelectedFile.FileName);
            bool   success     = true;

            try {
                if (File.Exists(newFileName))
                {
                    MessageService.ShowError(string.Format(GettextCatalog.GetString("Bundle with the same name already exists. Remove {0} first."), System.IO.Path.GetFileNameWithoutExtension(newFileName)));
                    return;
                }
                File.Copy(dialog.SelectedFile.FullPath, newFileName);
            } catch (Exception ex) {
                success = false;
                LoggingService.LogError("Can't copy syntax mode file.", ex);
            }
            if (success)
            {
                var bundle = SyntaxHighlightingService.LoadStyleOrMode(SyntaxHighlightingService.userThemeBundle, newFileName) as LanguageBundle;
                if (bundle != null)
                {
#pragma warning disable CS0618 // Type or member is obsolete
                    foreach (var h in bundle.Highlightings)
                    {
                        var def = h as SyntaxHighlightingDefinition;
                        def?.PrepareMatches();
                    }
#pragma warning restore CS0618 // Type or member is obsolete
                    FillBundles();
                }
                else
                {
                    MessageService.ShowError(GettextCatalog.GetString("Invalid bundle: {0}", dialog.SelectedFile.FileName));
                    try {
                        File.Delete(newFileName);
                    } catch (Exception) {}
                }
            }
        }
示例#13
0
        /// <summary>Allows the user to browse the file system for a schema.</summary>
        /// <returns>The schema filename the user selected; otherwise null.</returns>
        public static string BrowseForSchemaFile()
        {
            var dlg = new SelectFileDialog(GettextCatalog.GetString("Select XML Schema"));

            dlg.AddFilter(new SelectFileDialogFilter(
                              GettextCatalog.GetString("XML Files"),
                              new string[] { "*.xsd" },
                              new string[] { "text/xml", "application/xml" }
                              ));
            dlg.AddAllFilesFilter();

            if (dlg.Run())
            {
                return(dlg.SelectedFile);
            }
            return(null);
        }
示例#14
0
        void HandleButtonExportClicked(object sender, EventArgs e)
        {
            var dialog = new SelectFileDialog(GettextCatalog.GetString("Highlighting Scheme"), Gtk.FileChooserAction.Save)
            {
                TransientFor = this.Toplevel as Gtk.Window,
            };

            dialog.AddFilter(null, "*.xml");
            if (!dialog.Run())
            {
                return;
            }
            TreeIter selectedIter;

            if (styleTreeview.Selection.GetSelected(out selectedIter))
            {
                var sheme = (Mono.TextEditor.Highlighting.ColorScheme) this.styleStore.GetValue(selectedIter, 1);
                sheme.Save(dialog.SelectedFile);
            }
        }
		public void Add ()
		{
			var project = (DotNetProject) CurrentNode.GetParentDataItem (typeof(DotNetProject), true);
			
			var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select Native Library"), Gtk.FileChooserAction.Open);
			dlg.SelectMultiple = true;
			dlg.AddAllFilesFilter ();
			//FIXME: add more filters, amke correct for platform
			dlg.AddFilter (GettextCatalog.GetString ("Static Library"), ".a");
			
			if (!dlg.Run ())
				return;
			
			foreach (var file in dlg.SelectedFiles) {
				var item = new NativeReference (file);
				project.Items.Add (item);
			}
			
			IdeApp.ProjectOperations.Save (project);
		}
示例#16
0
		public WorkspaceItem AddWorkspaceItem (Workspace parentWorkspace)
		{
			WorkspaceItem res = null;
			
			var dlg = new SelectFileDialog () {
				Action = Gtk.FileChooserAction.Open,
				CurrentFolder = parentWorkspace.BaseDirectory,
				SelectMultiple = false,
			};
		
			dlg.AddAllFilesFilter ();
			dlg.DefaultFilter = dlg.AddFilter (GettextCatalog.GetString ("Solution Files"), "*.mds", "*.sln");
			
			if (dlg.Run ()) {
				try {
					res = AddWorkspaceItem (parentWorkspace, dlg.SelectedFile);
				} catch (Exception ex) {
					MessageService.ShowException (ex, GettextCatalog.GetString ("The file '{0}' could not be loaded.", dlg.SelectedFile));
				}
			}

			return res;
		}
示例#17
0
		protected override void Run ()
		{
			var proj = GetSelectedMonoMacProject ();
			
			var settings = proj.UserProperties.GetValue<MonoMacPackagingSettings> (PROP_KEY)
				?? MonoMacPackagingSettings.GetAppStoreDefault ();
			
			MonoMacPackagingSettingsDialog dlg;
			try {
				dlg = new MonoMacPackagingSettingsDialog ();
				dlg.LoadSettings (settings);
				if (MessageService.RunCustomDialog (dlg) != (int)ResponseType.Ok)
					return;
				dlg.SaveSettings (settings);
			} finally {
				dlg.Destroy ();
			}
			
			var configSel = IdeApp.Workspace.ActiveConfiguration;
			var cfg = (MonoMacProjectConfiguration) proj.GetConfiguration (configSel);
			
			var ext = settings.CreatePackage? ".pkg" : ".app";
			
			var fileDlg = new SelectFileDialog () {
				Title = settings.CreatePackage?
					GettextCatalog.GetString ("Save Installer Package") :
					GettextCatalog.GetString ("Save Application Bundle"),
				InitialFileName = cfg.AppName + ext,
				Action = FileChooserAction.Save
			};
			fileDlg.DefaultFilter = fileDlg.AddFilter ("", "*" + ext);
			
			if (!fileDlg.Run ())
				return;
			
			proj.UserProperties.SetValue (PROP_KEY, settings);
			
			var target = fileDlg.SelectedFile;
			if (!string.Equals (target.Extension, ext, StringComparison.OrdinalIgnoreCase))
				target.ChangeExtension (ext);
			
			MonoMacPackaging.Package (proj, configSel, settings, target);
		}
		void HandleButtonExportClicked (object sender, EventArgs e)
		{
			if (comboboxProfiles.Active < 0)
				return;
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Export profile"), Gtk.FileChooserAction.Save) {
				TransientFor = this.Toplevel as Gtk.Window,
			};
			dialog.AddFilter (null, "*.xml");
			if (!dialog.Run ())
				return;
			policies[comboboxProfiles.Active].Save (dialog.SelectedFile);
		}
示例#19
0
		void HandleButtonExportClicked (object sender, EventArgs e)
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Highlighting Scheme"), Gtk.FileChooserAction.Save) {
				TransientFor = this.Toplevel as Gtk.Window,
			};
			dialog.AddFilter (null, "*.xml");
			if (!dialog.Run ())
				return;
			TreeIter selectedIter;
			if (styleTreeview.Selection.GetSelected (out selectedIter)) {
				var sheme = (Mono.TextEditor.Highlighting.ColorSheme)this.styleStore.GetValue (selectedIter, 1);
				sheme.Save (dialog.SelectedFile);
			}

		}
		public async Task<WorkspaceItem> AddWorkspaceItem (Workspace parentWorkspace)
		{
			WorkspaceItem res = null;
			
			var dlg = new SelectFileDialog () {
				Action = FileChooserAction.Open,
				CurrentFolder = parentWorkspace.BaseDirectory,
				SelectMultiple = false,
			};
		
			dlg.AddAllFilesFilter ();
			dlg.DefaultFilter = dlg.AddFilter (GettextCatalog.GetString ("Solution Files"), "*.mds", "*.sln");
			
			if (dlg.Run ()) {
				try {
					if (WorkspaceContainsWorkspaceItem (parentWorkspace, dlg.SelectedFile)) {
						MessageService.ShowMessage (GettextCatalog.GetString ("The workspace already contains '{0}'.", Path.GetFileNameWithoutExtension (dlg.SelectedFile)));
						return res;
					}

					res = await AddWorkspaceItem (parentWorkspace, dlg.SelectedFile);
				} catch (Exception ex) {
					MessageService.ShowError (GettextCatalog.GetString ("The file '{0}' could not be loaded.", dlg.SelectedFile), ex);
				}
			}

			return res;
		}
示例#21
0
		void AddColorScheme (object sender, EventArgs args)
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Highlighting Scheme"), Gtk.FileChooserAction.Open) {
				TransientFor = this.Toplevel as Gtk.Window,
			};
			dialog.AddFilter (GettextCatalog.GetString ("Color schemes"), "*.json");
			dialog.AddFilter (GettextCatalog.GetString ("Visual Studio .NET settings"), "*.vssettings");
			if (!dialog.Run ())
				return;

			string newFileName = SourceEditorDisplayBinding.SyntaxModePath.Combine (dialog.SelectedFile.FileName);

			bool success = true;
			try {
				File.Copy (dialog.SelectedFile.FullPath, newFileName);
			} catch (Exception e) {
				success = false;
				LoggingService.LogError ("Can't copy syntax mode file.", e);
			}
			if (success) {
				SourceEditorDisplayBinding.LoadCustomStylesAndModes ();
				ShowStyles ();
			}
		}
		/// <summary>Allows the user to browse the file system for a schema.</summary>
		/// <returns>The schema filename the user selected; otherwise null.</returns>
		public static string BrowseForSchemaFile ()
		{
			var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select XML Schema")) {
				TransientFor = IdeApp.Workbench.RootWindow,
			};
			dlg.AddFilter (new SelectFileDialogFilter (GettextCatalog.GetString ("XML Files"), "*.xsd") {
				MimeTypes = { "text/xml", "application/xml" },
			});
			dlg.AddAllFilesFilter ();
			
			if (dlg.Run ())
				return dlg.SelectedFile;
			return null;
		}
		void HandleButtonExportClicked (object sender, EventArgs e)
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Highlighting Scheme"), MonoDevelop.Components.FileChooserAction.Save) {
				TransientFor = this.Toplevel as Gtk.Window,
			};
			dialog.AddFilter (GettextCatalog.GetString ("Color schemes"), "*.json");
			if (!dialog.Run ())
				return;
			TreeIter selectedIter;
			if (styleTreeview.Selection.GetSelected (out selectedIter)) {
				var sheme = (Mono.TextEditor.Highlighting.ColorScheme)this.styleStore.GetValue (selectedIter, 1);
				var selectedFile = dialog.SelectedFile.ToString ();
				if (!selectedFile.EndsWith (".json", StringComparison.Ordinal))
					selectedFile += ".json";
				sheme.Save (selectedFile);
			}

		}
		void HandleButtonImportClicked (object sender, EventArgs e)
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Profile to import"), Gtk.FileChooserAction.Open) {
				TransientFor = this.Toplevel as Gtk.Window,
			};
			dialog.AddFilter (null, "*.xml");
			if (!dialog.Run ())
				return;
			int selection = comboboxProfiles.Active;
			var p = CSharpFormattingPolicy.Load (dialog.SelectedFile);
			FormattingProfileService.AddProfile (p);
			policies.Add (p);
			InitComboBox ();
			comboboxProfiles.Active = selection;
		}
示例#25
0
		public SolutionItem AddSolutionItem (SolutionFolder parentFolder)
		{
			SolutionItem res = null;
			
			var dlg = new SelectFileDialog () {
				Action = Gtk.FileChooserAction.Open,
				CurrentFolder = parentFolder.BaseDirectory,
				SelectMultiple = false,
			};
		
			dlg.AddAllFilesFilter ();
			dlg.DefaultFilter = dlg.AddFilter (GettextCatalog.GetString ("Project Files"), "*.*proj");
			
			if (dlg.Run ()) {
				if (!Services.ProjectService.IsSolutionItemFile (dlg.SelectedFile)) {
					MessageService.ShowMessage (GettextCatalog.GetString ("The file '{0}' is not a known project file format.", dlg.SelectedFile));
					return res;
				}

				if (SolutionContainsProject (parentFolder, dlg.SelectedFile)) {
					MessageService.ShowMessage (GettextCatalog.GetString ("The project '{0}' has already been added.", Path.GetFileNameWithoutExtension (dlg.SelectedFile)));
					return res;
				}

				try {
					res = AddSolutionItem (parentFolder, dlg.SelectedFile);
				} catch (Exception ex) {
					MessageService.ShowError (GettextCatalog.GetString ("The file '{0}' could not be loaded.", dlg.SelectedFile), ex);
				}
			}
			
			if (res != null)
				IdeApp.Workspace.Save ();

			return res;
		}
		void AddColorScheme (object sender, EventArgs args)
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Highlighting Scheme"), MonoDevelop.Components.FileChooserAction.Open) {
				TransientFor = this.Toplevel as Gtk.Window,
			};
			dialog.AddFilter (GettextCatalog.GetString ("Color schemes"), "*.json");
			dialog.AddFilter (GettextCatalog.GetString ("Visual Studio .NET settings"), "*.vssettings");
			if (!dialog.Run ())
				return;

			string newFileName = MonoDevelop.Ide.Editor.TextEditorDisplayBinding.SyntaxModePath.Combine (dialog.SelectedFile.FileName);

			bool success = true;
			try {
				if (File.Exists (newFileName)) {
					MessageService.ShowError (string.Format (GettextCatalog.GetString ("Highlighting with the same name already exists. Remove {0} first."), System.IO.Path.GetFileNameWithoutExtension (newFileName)));
					return;
				}

				File.Copy (dialog.SelectedFile.FullPath, newFileName);
			} catch (Exception e) {
				success = false;
				LoggingService.LogError ("Can't copy syntax mode file.", e);
			}
			if (success) {
				Mono.TextEditor.Highlighting.SyntaxModeService.LoadStylesAndModes (TextEditorDisplayBinding.SyntaxModePath);
				MonoDevelop.Ide.Editor.Highlighting.SyntaxModeService.LoadStylesAndModes (TextEditorDisplayBinding.SyntaxModePath);
				MonoDevelop.Ide.Editor.TextEditorDisplayBinding.LoadCustomStylesAndModes ();
				ShowStyles ();
			}
		}
		/// <summary>Allows the user to browse the file system for a schema.</summary>
		/// <returns>The schema filename the user selected; otherwise null.</returns>
		public static string BrowseForSchemaFile ()
		{
			var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select XML Schema"));
			dlg.AddFilter (new SelectFileDialogFilter (
				GettextCatalog.GetString ("XML Files"),
				new string[] { "*.xsd" },
				new string[] { "text/xml", "application/xml" }
			));
			dlg.AddAllFilesFilter ();
			
			if (dlg.Run ())
				return dlg.SelectedFile;
			return null;
		}
		void AddColorScheme (object sender, EventArgs args)
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Application to Debug"), Gtk.FileChooserAction.Open) {
				TransientFor = this.Toplevel as Gtk.Window,
			};
			dialog.AddFilter (null, "*.xml");
			if (!dialog.Run ())
				return;
			
			System.Collections.Generic.List<System.Xml.Schema.ValidationEventArgs> validationResult;
			try {
				validationResult = Mono.TextEditor.Highlighting.SyntaxModeService.ValidateStyleFile (dialog.SelectedFile);
			} catch (Exception) {
				MessageService.ShowError (GettextCatalog.GetString ("Validation of style file failed."));
				return;
			}
			if (validationResult.Count == 0) {
				string newFileName = SourceEditorDisplayBinding.SyntaxModePath.Combine (dialog.SelectedFile.FileName);
				if (!newFileName.EndsWith ("Style.xml"))
					newFileName = SourceEditorDisplayBinding.SyntaxModePath.Combine (dialog.SelectedFile.FileNameWithoutExtension + "Style.xml");
				bool success = true;
				try {
					File.Copy (dialog.SelectedFile, newFileName);
				} catch (Exception e) {
					success = false;
					LoggingService.LogError ("Can't copy syntax mode file.", e);
				}
				if (success) {
					SourceEditorDisplayBinding.LoadCustomStylesAndModes ();
					ShowStyles ();
				}
			} else {
				StringBuilder errorMessage = new StringBuilder ();
				errorMessage.AppendLine (GettextCatalog.GetString ("Validation of style file failed."));
				int count = 0;
				foreach (System.Xml.Schema.ValidationEventArgs vArg in validationResult) {
					errorMessage.AppendLine (vArg.Message);
					if (count++ > 5) {
						errorMessage.AppendLine ("...");
						break;
					}
				}
				MessageService.ShowError (errorMessage.ToString ());
			}
		}
		void HandleButtonImportClicked (object sender, EventArgs e)
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Highlighting Scheme"), Gtk.FileChooserAction.Open)
				{
					TransientFor = this.Toplevel as Gtk.Window,
				};
			dialog.AddFilter ("Visual Studio 2010 settings file", "*.vssettings");
			dialog.AddFilter ("XML file", "*.xml");
			if (!dialog.Run ())
				return;
			
			var defStyle = Mono.TextEditor.Highlighting.SyntaxModeService.GetColorStyle (this.Style, "Default");
			var style = defStyle.Clone ();   
			var vsImporter = new VisualStudioHighlitingSchemeImporter ();  
			
			style.Name = "Absolutely new style";
			style.Description = "Absolutely new style description";
			
			var path = SourceEditorDisplayBinding.SyntaxModePath;
			var baseName = style.Name.Replace (" ", "_");
			
			while (File.Exists (System.IO.Path.Combine (path, baseName + "Style.xml")))
			{
				baseName = baseName + "_";
			}
			
			var fileName = System.IO.Path.Combine (path, baseName + "Style.xml");
			
			try
			{
				vsImporter.Import (dialog.SelectedFile, style);
				MonoDevelop.Ide.MessageService.ShowMessage (fileName);
				style.Save (fileName);
				Mono.TextEditor.Highlighting.SyntaxModeService.AddStyle (fileName, style);
			}
 			catch (Exception ex)
			{
				MonoDevelop.Ide.MessageService.ShowException (ex);
			}
			
			//var fileName = Mono.TextEditor.Highlighting.SyntaxModeService.GetFileNameForStyle (style);
			
			
			//style.Save (fileName);
		}
示例#30
0
		public SolutionItem AddSolutionItem (SolutionFolder parentFolder)
		{
			SolutionItem res = null;
			
			var dlg = new SelectFileDialog () {
				Action = Gtk.FileChooserAction.Open,
				CurrentFolder = parentFolder.BaseDirectory,
				SelectMultiple = false,
			};
		
			dlg.AddAllFilesFilter ();
			dlg.DefaultFilter = dlg.AddFilter (GettextCatalog.GetString ("Project Files"), "*.*proj", "*.mdp");
			
			if (dlg.Run ()) {
				try {
					res = AddSolutionItem (parentFolder, dlg.SelectedFile);
				} catch (Exception ex) {
					MessageService.ShowException (ex, GettextCatalog.GetString ("The file '{0}' could not be loaded.", dlg.SelectedFile));
				}
			}
			
			if (res != null)
				IdeApp.Workspace.Save ();

			return res;
		}
		/// <summary>Allows the user to browse the file system for a stylesheet.</summary>
		/// <returns>The stylesheet filename the user selected; otherwise null.</returns>
		public static string BrowseForStylesheetFile ()
		{
			var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select XSLT Stylesheet")) {
				TransientFor = IdeApp.Workbench.RootWindow,
			};
			dlg.AddFilter (new SelectFileDialogFilter (
				GettextCatalog.GetString ("XML Files"),
				new string[] { "*.xml" },
				new string[] { "text/xml", "application/xml" }
			));
			dlg.AddFilter (new SelectFileDialogFilter(
				GettextCatalog.GetString ("XSL Files"),
				new string[] { "*.xslt", "*.xsl" },
				new string[] { "text/x-xslt" }
			));
			dlg.AddAllFilesFilter ();
			
			if (dlg.Run ())
				return dlg.SelectedFile;
			return null;
		}