Ejemplo n.º 1
0
 private void OnOutputFolderClicked(object sender, EventArgs e)
 {
     if (folderDialog.Run(this))
     {
         _outputFolderEntry.Text = folderDialog.Folder;
     }
 }
Ejemplo n.º 2
0
 private void BtnChooseFolder_Clicked(object sender, EventArgs e)
 {
     var dlg = new SelectFolderDialog();
     if(dlg.Run() == true)
     {
         textInput.Text = dlg.Folder;
     }
 }
		public string SelectFolder ()
		{
			var dialog = new SelectFolderDialog ();
			if (dialog.Run ()) {
				return dialog.SelectedFile;
			}
			return null;
		}
Ejemplo n.º 4
0
		public async void AddExistingFolder ()
		{
			var project = (Project) CurrentNode.GetParentDataItem (typeof(Project), true);
			var selectedFolder = ((FilePath) GetFolderPath (CurrentNode.DataItem)).CanonicalPath;
			
			var ofdlg = new SelectFolderDialog (GettextCatalog.GetString ("Add Existing Folder")) {
				CurrentFolder = !PreviousFolderPath.IsNullOrEmpty ? PreviousFolderPath : selectedFolder 
			};
			if(!ofdlg.Run ())
				return;

			// We store the parent directory of the folder the user chooses as they will not need to add the same
			// directory twice. We can save them navigating up one directory by doing it for them
			PreviousFolderPath = ofdlg.SelectedFile.CanonicalPath;
			if (!PreviousFolderPath.ParentDirectory.IsNullOrEmpty)
				PreviousFolderPath = PreviousFolderPath.ParentDirectory;

			var srcRoot = ofdlg.SelectedFile.CanonicalPath;
			var targetRoot = selectedFolder.Combine (srcRoot.FileName);

			bool changedProject = false;

			if (File.Exists (targetRoot)) {
				MessageService.ShowWarning (GettextCatalog.GetString (
					"There is already a file with the name '{0}' in the target directory", srcRoot.FileName));
				return;
			}

			var existingPf = project.Files.GetFileWithVirtualPath (targetRoot.ToRelative (project.BaseDirectory));
			if (existingPf != null) {
				if (existingPf.Subtype != Subtype.Directory) {
					MessageService.ShowWarning (GettextCatalog.GetString (
						"There is already a link with the name '{0}' in the target directory", srcRoot.FileName));
					return;
				}
			}

			var foundFiles = Directory.GetFiles (srcRoot, "*", SearchOption.AllDirectories);
			
			using (var impdlg = new IncludeNewFilesDialog (GettextCatalog.GetString ("Select files to add from {0}", srcRoot.FileName), srcRoot.ParentDirectory)) {
				impdlg.AddFiles (foundFiles);
				if (MessageService.ShowCustomDialog (impdlg) == (int)ResponseType.Ok) {
					var srcFiles = impdlg.SelectedFiles;
					var targetFiles = srcFiles.Select (f => targetRoot.Combine (f.ToRelative (srcRoot)));
					if (IdeApp.ProjectOperations.AddFilesToProject (project, srcFiles.ToArray (), targetFiles.ToArray (), null).Any ())
						changedProject = true;
					else if (!srcFiles.Any () && existingPf == null) {
						// Just add empty folder.
						project.Files.Add (new ProjectFile (targetRoot) { Subtype = Subtype.Directory });
						changedProject = true;
					}
				}
			
				if (changedProject)
					await IdeApp.ProjectOperations.SaveAsync (project);
			}
		}
        public void AddExistingFolder()
        {
            var project        = (FolderBasedProject)CurrentNode.GetParentDataItem(typeof(FolderBasedProject), true);
            var selectedFolder = ((FilePath)GetPath(CurrentNode.DataItem)).CanonicalPath;

            var ofdlg = new SelectFolderDialog(GettextCatalog.GetString("Add Existing Folder"))
            {
                CurrentFolder = !PreviousFolderPath.IsNullOrEmpty ? PreviousFolderPath : selectedFolder
            };

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

            // We store the parent directory of the folder the user chooses as they will not need to add the same
            // directory twice. We can save them navigating up one directory by doing it for them
            PreviousFolderPath = ofdlg.SelectedFile.CanonicalPath;
            if (!PreviousFolderPath.ParentDirectory.IsNullOrEmpty)
            {
                PreviousFolderPath = PreviousFolderPath.ParentDirectory;
            }

            var srcRoot    = ofdlg.SelectedFile.CanonicalPath;
            var targetRoot = selectedFolder.Combine(srcRoot.FileName);

            if (File.Exists(targetRoot))
            {
                MessageService.ShowWarning(GettextCatalog.GetString(
                                               "There is already a file with the name '{0}' in the target directory", srcRoot.FileName));
                return;
            }

            var foundFiles = Directory.GetFiles(srcRoot, "*", SearchOption.AllDirectories);

            using (var impdlg = new IncludeNewFilesDialog(GettextCatalog.GetString("Select files to add from {0}", srcRoot.FileName), srcRoot.ParentDirectory)) {
                impdlg.AddFiles(foundFiles);
                if (MessageService.ShowCustomDialog(impdlg) == (int)ResponseType.Ok)
                {
                    var srcFiles    = impdlg.SelectedFiles;
                    var targetFiles = srcFiles.Select(f => targetRoot.Combine(f.ToRelative(srcRoot)));
                    foreach (var srcFile in srcFiles)
                    {
                        foreach (var targetFile in targetFiles)
                        {
                            if (srcFile.ToRelative(srcRoot).Equals(targetFile.ToRelative(targetRoot)))
                            {
                                CopyFile(srcFile, targetFile);
                            }
                        }
                    }
                    project.OnFilesAdded(targetFiles.ToList());
                }
            }
            Tree.BuilderContext.GetTreeBuilder(CurrentNode).UpdateChildren();
        }
Ejemplo n.º 6
0
        public string SelectFolder()
        {
            var dialog = new SelectFolderDialog();

            if (dialog.Run())
            {
                return(dialog.SelectedFile);
            }
            return(null);
        }
Ejemplo n.º 7
0
        public void AddExistingFolder()
        {
            var project = (Project) CurrentNode.GetParentDataItem (typeof(Project), true);
            var selectedFolder = ((FilePath) GetFolderPath (CurrentNode.DataItem)).CanonicalPath;

            var ofdlg = new SelectFolderDialog (GettextCatalog.GetString ("Add Existing Folder")) {
                CurrentFolder = !PreviousFolderPath.IsNullOrEmpty ? PreviousFolderPath : selectedFolder
            };
            if(!ofdlg.Run ())
                return;

            // We store the parent directory of the folder the user chooses as they will not need to add the same
            // directory twice. We can save them navigating up one directory by doing it for them
            PreviousFolderPath = ofdlg.SelectedFile.CanonicalPath;
            if (!PreviousFolderPath.ParentDirectory.IsNullOrEmpty)
                PreviousFolderPath = PreviousFolderPath.ParentDirectory;

            var srcRoot = ofdlg.SelectedFile.CanonicalPath;
            var targetRoot = selectedFolder.Combine (srcRoot.FileName);

            bool changedProject = false;

            if (File.Exists (targetRoot)) {
                MessageService.ShowWarning (GettextCatalog.GetString (
                    "There is already a file with the name '{0}' in the target directory", srcRoot.FileName));
                return;
            }

            var existingPf = project.Files.GetFileWithVirtualPath (targetRoot.ToRelative (project.BaseDirectory));
            if (existingPf != null) {
                if (existingPf.Subtype != Subtype.Directory) {
                    MessageService.ShowWarning (GettextCatalog.GetString (
                        "There is already a link with the name '{0}' in the target directory", srcRoot.FileName));
                    return;
                }
            } else {
                project.Files.Add (new ProjectFile (targetRoot) { Subtype = Subtype.Directory });
                changedProject = true;
            }

            var foundFiles = Directory.GetFiles (srcRoot, "*", SearchOption.AllDirectories);

            var impdlg = new IncludeNewFilesDialog (GettextCatalog.GetString ("Select files to add from {0}", srcRoot.FileName), srcRoot.ParentDirectory);
            impdlg.AddFiles (foundFiles);
            if (MessageService.ShowCustomDialog (impdlg) == (int) ResponseType.Ok) {
                var srcFiles = impdlg.SelectedFiles;
                var targetFiles = srcFiles.Select (f => targetRoot.Combine (f.ToRelative (srcRoot)));
                if (IdeApp.ProjectOperations.AddFilesToProject (project, srcFiles.ToArray (), targetFiles.ToArray (), null).Any ())
                    changedProject = true;
            }

            if (changedProject)
                IdeApp.ProjectOperations.Save (project);
        }
Ejemplo n.º 8
0
        public MainWindow()
        {
            model      = new Model();
            controller = new Controller(model);

            this.Width   = 600;
            this.Height  = 400;
            this.Closed += delegate {
                model.Synthesizer.Stop();
                Application.Exit();
            };

            this.MainMenu = new Menu();

            var file = new MenuItem("_File");

            file.SubMenu = new Menu();
            this.MainMenu.Items.Add(file);

            var configPatchDir = new MenuItem("_Configure Patch directory");

            configPatchDir.Clicked += delegate {
                var dirdlg = new SelectFolderDialog("Choose Patch directory.")
                {
                    Multiselect = false,
                };
                if (dirdlg.Run(this))
                {
                    controller.SetPatchDirectory(dirdlg.Folder);
                }
            };
            file.SubMenu.Items.Add(configPatchDir);

            var exit = new MenuItem("E_xit");

            exit.Clicked += (o, e) => Close();
            file.SubMenu.Items.Add(exit);

            var patch = new MenuItem("_Patch");

            this.MainMenu.Items.Add(patch);

            model.PatchDirectoryUpdated += delegate { patch.SubMenu = XwtUtility.BuildDirectoryTree(new DirectoryInfo(model.PatchDirectory), s => Task.Run(() => controller.SelectPatchFile(s))); };

            var button = new Button("PLAY");

            button.Clicked += delegate {
                Task.Run(() => controller.PlayTestSound());
            };
            this.Content = button;

            controller.StartMain();
        }
        void OnBrowse(object sender, EventArgs args)
        {
            using (SelectFolderDialog folderSelect = new SelectFolderDialog("Browse Folder"))
            {
                folderSelect.Multiselect      = false;
                folderSelect.CanCreateFolders = true;

                if (folderSelect.Run(MessageDialog.RootWindow))
                {
                    _pathEntry.Text = folderSelect.Folder;
                }
            }
        }
		protected override string ShowBrowseDialog (string name, string start_in)
		{
			SelectFolderDialog fd = new SelectFolderDialog (name);
			if (start_in != null)
				fd.InitialFileName = start_in;
			
			fd.TransientFor = GetTransientFor ();
			
			if (fd.Run ())
				return fd.SelectedFile;
			else
				return null;
		}
Ejemplo n.º 11
0
        void RunSoundFontDirectoryChooser()
        {
            // FIXME: current XWt is buggy and does not respect my `Multiselect = true`.
            // var dlg = new SelectFolderDialog { Title = "Select soundfont directories", Multiselect = true, CanCreateFolders = false };
            var dlg = new SelectFolderDialog {
                Title = "Select soundfont directories", CanCreateFolders = false
            };

            if (dlg.Run())
            {
                model.UpdateDirectoryList(model.UserSettings.SoundFontPaths.Concat(dlg.Folders).ToArray());
            }
        }
Ejemplo n.º 12
0
		protected override string ShowBrowseDialog (string name, string startIn)
		{
			var fd = new SelectFolderDialog (name);
			if (startIn != null)
				fd.CurrentFolder = startIn;

			fd.SetFilters (FileFilters);
			fd.TransientFor = GetTransientFor ();
			
			if (fd.Run ())
				return fd.SelectedFile;
			return null;
		}
        public void AddFilesFromFolder()
        {
            var project    = (FolderBasedProject)CurrentNode.GetParentDataItem(typeof(FolderBasedProject), true);
            var targetRoot = ((FilePath)GetPath(CurrentNode.DataItem)).CanonicalPath;

            var ofdlg = new SelectFolderDialog(GettextCatalog.GetString("Import From Folder"))
            {
                CurrentFolder = !PreviousFolderPath.IsNullOrEmpty ? PreviousFolderPath : targetRoot
            };

            if (!ofdlg.Run())
            {
                return;
            }
            PreviousFolderPath = ofdlg.SelectedFile.CanonicalPath;
            if (!PreviousFolderPath.ParentDirectory.IsNullOrEmpty)
            {
                PreviousFolderPath = PreviousFolderPath.ParentDirectory;
            }

            var srcRoot    = ofdlg.SelectedFile.CanonicalPath;
            var foundFiles = Directory.GetFiles(srcRoot, "*", SearchOption.AllDirectories);

            if (foundFiles.Length == 0)
            {
                MessageService.GenericAlert(MonoDevelop.Ide.Gui.Stock.Information,
                                            GettextCatalog.GetString("Empty directory."),
                                            GettextCatalog.GetString("Directory {0} is empty, no files have been added.", srcRoot.FileName),
                                            AlertButton.Close);
                return;
            }

            using (var impdlg = new IncludeNewFilesDialog(GettextCatalog.GetString("Select files to add from {0}", srcRoot.FileName), srcRoot)) {
                impdlg.AddFiles(foundFiles);
                if (MessageService.ShowCustomDialog(impdlg) != (int)ResponseType.Ok)
                {
                    return;
                }

                var srcFiles    = impdlg.SelectedFiles;
                var targetFiles = srcFiles.Select(f => targetRoot.Combine(f.ToRelative(srcRoot)));

                foreach (var file in srcFiles.ToArray())
                {
                    CopyFile(file, targetRoot);
                }
                project.OnFilesAdded(targetFiles.ToList());
            }

            Tree.BuilderContext.GetTreeBuilder(CurrentNode).UpdateChildren();
        }
Ejemplo n.º 14
0
        public void AddFilesFromFolder()
        {
            var project    = (Project)CurrentNode.GetParentDataItem(typeof(Project), true);
            var targetRoot = ((FilePath)GetFolderPath(CurrentNode.DataItem)).CanonicalPath;

            var ofdlg = new SelectFolderDialog(GettextCatalog.GetString("Import From Folder"))
            {
                CurrentFolder = !PreviousFolderPath.IsNullOrEmpty ? PreviousFolderPath : targetRoot
            };

            if (!ofdlg.Run())
            {
                return;
            }
            PreviousFolderPath = ofdlg.SelectedFile.CanonicalPath;
            if (!PreviousFolderPath.ParentDirectory.IsNullOrEmpty)
            {
                PreviousFolderPath = PreviousFolderPath.ParentDirectory;
            }

            var srcRoot    = ofdlg.SelectedFile.CanonicalPath;
            var foundFiles = Directory.GetFiles(srcRoot, "*", SearchOption.AllDirectories);

            if (foundFiles.Length == 0)
            {
                MessageService.GenericAlert(Stock.Information,
                                            GettextCatalog.GetString("Empty directory."),
                                            GettextCatalog.GetString("Directory {0} is empty, no files have been added.", srcRoot.FileName),
                                            AlertButton.Close);
                return;
            }

            var impdlg = new IncludeNewFilesDialog(GettextCatalog.GetString("Select files to add from {0}", srcRoot.FileName), srcRoot);

            impdlg.AddFiles(foundFiles);
            if (MessageService.ShowCustomDialog(impdlg) != (int)ResponseType.Ok)
            {
                return;
            }

            var srcFiles    = impdlg.SelectedFiles;
            var targetFiles = srcFiles.Select(f => targetRoot.Combine(f.ToRelative(srcRoot)));

            var added = IdeApp.ProjectOperations.AddFilesToProject(project, srcFiles.ToArray(), targetFiles.ToArray(), null).Any();

            if (added)
            {
                IdeApp.ProjectOperations.Save(project);
            }
        }
Ejemplo n.º 15
0
        protected async override void Run()
        {
            var dialog = new SelectFolderDialog();

            try {
                if (dialog.Run())
                {
                    await OpenFolder(dialog.SelectedFile);
                }
            } catch (Exception ex) {
                string message = GettextCatalog.GetString("Unable to open folder '{0}'.", dialog.SelectedFile);
                LoggingService.LogError(message, ex.Message);
                MessageService.ShowError(message, ex);
            }
        }
        FilePath BrowseForFolder(FilePath startingFolder)
        {
            var dialog = new SelectFolderDialog();

            if (startingFolder != null)
            {
                dialog.CurrentFolder = startingFolder;
            }

            dialog.TransientFor = Toplevel as Window;

            if (dialog.Run())
            {
                return(dialog.SelectedFile);
            }
            return(null);
        }
Ejemplo n.º 17
0
        protected void OnButtonBrowseClicked(object sender, EventArgs e)
        {
            SelectFolderDialog selectFolderDialog = new SelectFolderDialog();

            selectFolderDialog.TransientFor   = this;
            selectFolderDialog.Title          = LanguageInfo.Dialog_ProjectPath;
            selectFolderDialog.Action         = FileChooserAction.CreateFolder;
            selectFolderDialog.SelectMultiple = false;
            string text = null;

            if (selectFolderDialog.Run())
            {
                text = selectFolderDialog.SelectedFile;
            }
            if (!string.IsNullOrEmpty(text))
            {
                this.entry_Path.Text = text;
            }
        }
Ejemplo n.º 18
0
 private void OnAddWorkingFolder(object sender, EventArgs e)
 {
     using (var projectSelect = new ProjectSelectDialog(this.projectCollection))
     {
         if (projectSelect.Run(this) == Command.Ok && !string.IsNullOrEmpty(projectSelect.SelectedPath))
         {
             using (SelectFolderDialog folderSelect = new SelectFolderDialog("Browse For Folder"))
             {
                 folderSelect.Multiselect      = false;
                 folderSelect.CanCreateFolders = true;
                 if (folderSelect.Run(this))
                 {
                     var row = _workingFoldersStore.AddRow();
                     _workingFoldersStore.SetValue(row, _tfsFolder, projectSelect.SelectedPath);
                     _workingFoldersStore.SetValue(row, _localFolder, folderSelect.Folder);
                 }
             }
         }
     }
 }
Ejemplo n.º 19
0
        protected virtual void OnButtonAddClicked(object sender, System.EventArgs e)
        {
            var dlg = new SelectFolderDialog(GettextCatalog.GetString("Select the mono installation prefix"))
            {
                TransientFor = this.Toplevel as Gtk.Window,
            };

            //set a platform-dependent default folder for the dialog if possible
            if (Platform.IsWindows)
            {
                // ProgramFilesX86 is broken on 32-bit WinXP
                string programFilesX86 = Environment.GetFolderPath(
                    IntPtr.Size == 8? Environment.SpecialFolder.ProgramFilesX86 : Environment.SpecialFolder.ProgramFiles);
                if (!string.IsNullOrEmpty(programFilesX86) && System.IO.Directory.Exists(programFilesX86))
                {
                    dlg.CurrentFolder = programFilesX86;
                }
            }
            else
            {
                if (System.IO.Directory.Exists("/usr"))
                {
                    dlg.CurrentFolder = "/usr";
                }
            }

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

            var rinfo = new MonoRuntimeInfo(dlg.SelectedFile);

            if (!rinfo.IsValidRuntime)
            {
                MessageService.ShowError(GettextCatalog.GetString("Mono runtime not found"), GettextCatalog.GetString("Please provide a valid directory prefix where mono is installed (for example, /usr)"));
                return;
            }
            newInfos.Add(rinfo);
            store.AppendValues(rinfo.DisplayName, rinfo);
        }
Ejemplo n.º 20
0
        protected virtual void OnButtonAddClicked(object sender, System.EventArgs e)
        {
            var dlg = new SelectFolderDialog(GettextCatalog.GetString("Select the mono installation prefix"))
            {
                TransientFor  = this.Toplevel as Gtk.Window,
                CurrentFolder = "/usr",
            };

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

            var rinfo = new MonoRuntimeInfo(dlg.SelectedFile);

            if (!rinfo.IsValidRuntime)
            {
                MessageService.ShowError(GettextCatalog.GetString("Mono runtime not found"), GettextCatalog.GetString("Please provide a valid directory prefix where mono is installed (for example, /usr)"));
                return;
            }
            newInfos.Add(rinfo);
            store.AppendValues(rinfo.DisplayName, rinfo);
        }
Ejemplo n.º 21
0
        void ButtonBrowsePathsClicked(object sender, EventArgs e)
        {
            var dlg = new SelectFolderDialog(GettextCatalog.GetString("Select directory"))
            {
                TransientFor = this,
            };

            string defaultFolder = comboboxentryPath.Entry.Text;

            if (string.IsNullOrEmpty(defaultFolder))
            {
                defaultFolder = IdeApp.ProjectOperations.ProjectsDefaultPath;
            }
            if (!string.IsNullOrEmpty(defaultFolder))
            {
                dlg.CurrentFolder = defaultFolder;
            }

            if (dlg.Run())
            {
                comboboxentryPath.Entry.Text = dlg.SelectedFile;
            }
        }
Ejemplo n.º 22
0
        public void AddFilesFromFolder()
        {
            var project    = (Project)CurrentNode.GetParentDataItem(typeof(Project), true);
            var targetRoot = ((FilePath)GetFolderPath(CurrentNode.DataItem)).CanonicalPath;

            var ofdlg = new SelectFolderDialog(GettextCatalog.GetString("Import From Folder"))
            {
                CurrentFolder = targetRoot
            };

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

            var srcRoot    = ofdlg.SelectedFile.CanonicalPath;
            var foundFiles = Directory.GetFiles(srcRoot, "*", SearchOption.AllDirectories);

            var impdlg = new IncludeNewFilesDialog(GettextCatalog.GetString("Select files to add from {0}", srcRoot.FileName), srcRoot);

            impdlg.AddFiles(foundFiles);
            if (MessageService.ShowCustomDialog(impdlg) != (int)ResponseType.Ok)
            {
                return;
            }

            var srcFiles    = impdlg.SelectedFiles;
            var targetFiles = srcFiles.Select(f => targetRoot.Combine(f.ToRelative(srcRoot)));

            var added = IdeApp.ProjectOperations.AddFilesToProject(project, srcFiles.ToArray(), targetFiles.ToArray(), null).Any();

            if (added)
            {
                IdeApp.ProjectOperations.Save(project);
            }
        }
Ejemplo n.º 23
0
		void ButtonBrowsePathsClicked (object sender, EventArgs e)
		{
			var dlg = new SelectFolderDialog (GettextCatalog.GetString ("Select directory")) {
				TransientFor = this,
			};
			
			string defaultFolder = comboboxentryPath.Entry.Text;
			if (string.IsNullOrEmpty (defaultFolder))
				defaultFolder = IdeApp.ProjectOperations.ProjectsDefaultPath;
			if (!string.IsNullOrEmpty (defaultFolder))
				dlg.CurrentFolder = defaultFolder;
			
			if (dlg.Run ())
				comboboxentryPath.Entry.Text = dlg.SelectedFile;
		}
Ejemplo n.º 24
0
		protected virtual void OnButtonAddClicked (object sender, System.EventArgs e)
		{
			var dlg = new SelectFolderDialog (GettextCatalog.GetString ("Select the mono installation prefix")) {
				TransientFor = this.Toplevel as Gtk.Window,
			};
			
			//set a platform-dependent default folder for the dialog if possible
			if (PropertyService.IsWindows) {
				string folder = Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86);
				if (!string.IsNullOrEmpty (folder) && System.IO.Directory.Exists (folder))
					dlg.CurrentFolder = folder;
			} else {
				if (System.IO.Directory.Exists ("/usr"))
					dlg.CurrentFolder = "/usr";
			}
			
			if (!dlg.Run ())
				return;
			
			var rinfo = new MonoRuntimeInfo (dlg.SelectedFile);
			if (!rinfo.IsValidRuntime) {
				MessageService.ShowError (GettextCatalog.GetString ("Mono runtime not found"), GettextCatalog.GetString ("Please provide a valid directory prefix where mono is installed (for example, /usr)"));
				return;
			}
			newInfos.Add (rinfo);
			store.AppendValues (rinfo.DisplayName, rinfo);
		}
		FilePath BrowseForFolder (FilePath startingFolder)
		{
			var dialog = new SelectFolderDialog ();
			if (startingFolder != null)
				dialog.CurrentFolder = startingFolder;

			dialog.TransientFor = Toplevel as Window;

			if (dialog.Run ())
				return dialog.SelectedFile;
			return null;
		}
Ejemplo n.º 26
0
        public Windows()
        {
            Button bp = new Button("Show borderless window");

            PackStart(bp);
            bp.Clicked += delegate {
                Window w = new Window();
                w.Decorated = false;
                Button c = new Button("This is a window");
//				c.Margin.SetAll (10);
                w.Content  = c;
                c.Clicked += delegate {
                    w.Dispose();
                };
                var bpos = bp.ScreenBounds;
                w.ScreenBounds = new Rectangle(bpos.X, bpos.Y + bp.Size.Height, w.Width, w.Height);
                w.Show();
            };
            Button b = new Button("Show message dialog");

            PackStart(b);
            b.Clicked += delegate {
                MessageDialog.ShowMessage(ParentWindow, "Hi there!");
            };

            Button db = new Button("Show custom dialog");

            PackStart(db);
            db.Clicked += delegate {
                Dialog d = new Dialog();
                d.Title = "This is a dialog";
                Table t = new Table();
                t.Add(new Label("Some field:"), 0, 0);
                t.Add(new TextEntry(), 1, 0);
                t.Add(new Label("Another field:"), 0, 1);
                t.Add(new TextEntry(), 1, 1);
                d.Content = t;

                Command custom = new Command("Custom");
                d.Buttons.Add(new DialogButton(custom));
                d.Buttons.Add(new DialogButton("Custom OK", Command.Ok));
                d.Buttons.Add(new DialogButton(Command.Cancel));
                d.Buttons.Add(new DialogButton(Command.Ok));

                var r = d.Run(this.ParentWindow);
                db.Label = "Result: " + r.Label;
                d.Dispose();
            };

            b = new Button("Show Open File dialog");
            PackStart(b);
            b.Clicked += delegate {
                OpenFileDialog dlg = new OpenFileDialog("Select a file");
                dlg.InitialFileName = "Some file";
                dlg.Multiselect     = true;
                dlg.Filters.Add(new FileDialogFilter("Xwt files", "*.xwt"));
                dlg.Filters.Add(new FileDialogFilter("All files", "*.*"));
                if (dlg.Run())
                {
                    MessageDialog.ShowMessage("Files have been selected!", string.Join("\n", dlg.FileNames));
                }
            };

            b = new Button("Show Save File dialog");
            PackStart(b);
            b.Clicked += delegate {
                SaveFileDialog dlg = new SaveFileDialog("Select a file");
                dlg.InitialFileName = "Some file";
                dlg.Multiselect     = true;
                dlg.Filters.Add(new FileDialogFilter("Xwt files", "*.xwt"));
                dlg.Filters.Add(new FileDialogFilter("All files", "*.*"));
                if (dlg.Run())
                {
                    MessageDialog.ShowMessage("Files have been selected!", string.Join("\n", dlg.FileNames));
                }
            };

            b = new Button("Show Select Folder dialog (Multi select)");
            PackStart(b);
            b.Clicked += delegate {
                SelectFolderDialog dlg = new SelectFolderDialog("Select some folder");
                dlg.Multiselect = true;
                if (dlg.Run())
                {
                    MessageDialog.ShowMessage("Folders have been selected!", string.Join("\n", dlg.Folders));
                }
            };

            b = new Button("Show Select Folder dialog (Single select)");
            PackStart(b);
            b.Clicked += delegate {
                SelectFolderDialog dlg = new SelectFolderDialog("Select a folder");
                dlg.Multiselect = false;
                if (dlg.Run())
                {
                    MessageDialog.ShowMessage("Folders have been selected!", string.Join("\n", dlg.Folders));
                }
            };

            b = new Button("Show Select Folder dialog (Single select, allow creation)");
            PackStart(b);
            b.Clicked += delegate {
                SelectFolderDialog dlg = new SelectFolderDialog("Select or create a folder");
                dlg.Multiselect      = false;
                dlg.CanCreateFolders = true;
                if (dlg.Run())
                {
                    MessageDialog.ShowMessage("Folders have been selected/created!", string.Join("\n", dlg.Folders));
                }
            };

            b = new Button("Show Select Color dialog");
            PackStart(b);
            b.Clicked += delegate {
                SelectColorDialog dlg = new SelectColorDialog("Select a color");
                dlg.SupportsAlpha = true;
                dlg.Color         = Xwt.Drawing.Colors.AliceBlue;
                if (dlg.Run(ParentWindow))
                {
                    MessageDialog.ShowMessage("A color has been selected!", dlg.Color.ToString());
                }
            };

            b = new Button("Show window shown event");
            PackStart(b);
            b.Clicked += delegate
            {
                Window w = new Window();
                w.Decorated = false;
                Button c = new Button("This is a window with events on");
                w.Content  = c;
                c.Clicked += delegate
                {
                    w.Dispose();
                };
                w.Shown  += (sender, args) => MessageDialog.ShowMessage("My Parent has been shown");
                w.Hidden += (sender, args) => MessageDialog.ShowMessage("My Parent has been hidden");

                w.Show();
            };

            b = new Button("Show dialog with dynamically updating content");
            PackStart(b);
            b.Clicked += delegate
            {
                var dialog = new Dialog();
                dialog.Content = new Label("Hello World");
                Xwt.Application.TimeoutInvoke(TimeSpan.FromSeconds(2), () => {
                    dialog.Content = new Label("Goodbye World");
                    return(false);
                });
                dialog.Run();
            };
        }
Ejemplo n.º 27
0
        public bool Initialize(ToolkitType type)
        {
            _log.Open(Path.Combine(AppData.Path, "ParkitectNexusLauncher.log"));
            _log.MinimumLogLevel = LogLevel.Debug;

            Application.Initialize(type);

            _window = _presenterFactory.InstantiatePresenter <MainWindow>();
            _window.Show();

            var update = _updateManager.CheckForUpdates <App>();

            if (update != null)
            {
                if (
                    MessageDialog.AskQuestion("ParkitectNexus Client Update",
                                              "A required update for the ParkitectNexus Client needs to be installed.\n" +
                                              "Without this update you won't be able to install blueprints, savegames or mods trough this application. The update should take less than a minute.\n" +
                                              $"Would you like to install it now?\n\nYou are currently running v{typeof (App).Assembly.GetName().Version}. The newest version is v{update.Version}",
                                              Command.Yes, Command.No) !=
                    Command.Yes)
                {
                    return(false);
                }

                if (!_updateManager.InstallUpdate(update))
                {
                    MessageDialog.ShowError(_window, "ParkitectNexus Client Update", "Failed installing the update! Please try again later.");
                }

                return(false);
            }

            if (!_parkitect.DetectInstallationPath())
            {
                if (
                    !MessageDialog.Confirm(
                        "We couldn't automatically detect Parkitect on your machine!\nPlease press OK and manually select the installation folder of Parkitect.",
                        Command.Ok))
                {
                    _window.Dispose();
                    Application.Dispose();
                    return(false);
                }

                do
                {
                    var dlg = new SelectFolderDialog("Select your Parkitect installation folder.")
                    {
                        CanCreateFolders = false,
                        Multiselect      = false
                    };


                    if (dlg.Run(_window))
                    {
                        if (_parkitect.SetInstallationPathIfValid(dlg.Folder))
                        {
                            break;
                        }
                    }
                    else
                    {
                        _window.Dispose();
                        Application.Dispose();
                        return(false);
                    }
                } while (!_parkitect.IsInstalled);
            }

            _migrator.Migrate();
            ModLoaderUtil.InstallModLoader(_parkitect, _log);
            _taskManager.Add <CheckForUpdatesTask>();
            return(true);
        }
Ejemplo n.º 28
0
		protected virtual void OnButtonAddClicked (object sender, System.EventArgs e)
		{
			var dlg = new SelectFolderDialog (GettextCatalog.GetString ("Select the mono installation prefix")) {
				TransientFor = this.Toplevel as Gtk.Window,
			};

			//set a platform-dependent default folder for the dialog if possible
			if (Platform.IsWindows) {
				// ProgramFilesX86 is broken on 32-bit WinXP
				string programFilesX86 = GetProgramFilesX86 ();
				if (!string.IsNullOrEmpty (programFilesX86) && System.IO.Directory.Exists (programFilesX86))
					dlg.CurrentFolder = programFilesX86;
			} else {
				if (System.IO.Directory.Exists ("/usr"))
					dlg.CurrentFolder = "/usr";
			}

			if (!dlg.Run ())
				return;

			var rinfo64 = new MonoRuntimeInfo (dlg.SelectedFile, true);
			var rinfo32 = new MonoRuntimeInfo (dlg.SelectedFile, false);
			if (rinfo64.IsValidRuntime && rinfo32.IsValidRuntime) {
				newInfos.Add (rinfo64);
				store.AppendValues (rinfo64.DisplayName, rinfo64);
				newInfos.Add (rinfo32);
				store.AppendValues (rinfo32.DisplayName, rinfo32);
			} else if (rinfo64.IsValidRuntime) {
				newInfos.Add (rinfo64);
				store.AppendValues (rinfo64.DisplayName, rinfo64);
			} else if (rinfo32.IsValidRuntime) {
				newInfos.Add (rinfo32);
				store.AppendValues (rinfo32.DisplayName, rinfo32);
			} else {
				var rinfo = new MonoRuntimeInfo (dlg.SelectedFile, null);
				if (rinfo.IsValidRuntime) {
					newInfos.Add (rinfo);
					store.AppendValues (rinfo.DisplayName, rinfo);
				} else {
					MessageService.ShowError (GettextCatalog.GetString ("Mono runtime not found"), GettextCatalog.GetString ("Please provide a valid directory prefix where mono is installed (for example, /usr)"));
				}
			}
		}
Ejemplo n.º 29
0
        public MainWindow()
        {
            Width  = 800;
            Height = 600;

            Controller = new Controller(Model, State);

            MainMenu = BuildMainMenu();

            var layout = new VBox();

            // package ID entry
            var packageRow = new HBox();

            layout.PackStart(packageRow);
            packageRow.PackStart(new Label {
                Text = "POM"
            });
            var packageIdEntry = new ComboBoxEntry();

            Model.PomHistory.Updated += (o, e) => Application.Invoke(() => {
                foreach (var entry in Model.PomHistory.Entries)
                {
                    packageIdEntry.Items.Add(entry);
                }
            });
            Action updatePoms = () => State.PomEntry = packageIdEntry.TextEntry.Text;

            packageIdEntry.TextInput        += (sender, e) => updatePoms();
            packageIdEntry.SelectionChanged += (sender, e) => updatePoms();

            packageRow.PackStart(packageIdEntry, true);

            // Maven download directory entry
            var downloadDirectoryRow = new HBox();

            layout.PackStart(downloadDirectoryRow);
            downloadDirectoryRow.PackStart(new Label {
                Text = "Downloads"
            });
            var downloadDirectoryEntry = new ComboBoxEntry();

            Model.DownloadDirectoryHistory.Updated += (o, e) => Application.Invoke(() => {
                foreach (var entry in Model.DownloadDirectoryHistory.Entries)
                {
                    downloadDirectoryEntry.Items.Add(entry);
                }
            });
            Action updateDownload = () => State.DownloadDirectory = downloadDirectoryEntry.TextEntry.Text;

            downloadDirectoryEntry.TextInput        += (sender, e) => updateDownload();
            downloadDirectoryEntry.SelectionChanged += (sender, e) => updateDownload();

            downloadDirectoryRow.PackStart(downloadDirectoryEntry, true);

            var downloadDirectoryPickerButton = new Button()
            {
                Label = "Choose..."
            };

            downloadDirectoryPickerButton.Clicked += delegate {
                var chooser = new SelectFolderDialog("Choose directory to store downloads.")
                {
                    CanCreateFolders = true
                };
                if (chooser.Run())
                {
                    downloadDirectoryEntry.TextEntry.Text = chooser.Folder;
                }
            };
            downloadDirectoryRow.PackStart(downloadDirectoryPickerButton);

            // solution directory entry
            var solutionDirectoryRow = new HBox();

            layout.PackStart(solutionDirectoryRow);
            solutionDirectoryRow.PackStart(new Label {
                Text = "Projects"
            });
            var solutionDirectoryEntry = new ComboBoxEntry();

            Model.SolutionDirectoryHistory.Updated += (o, e) => Application.Invoke(() => {
                foreach (var entry in Model.SolutionDirectoryHistory.Entries)
                {
                    solutionDirectoryEntry.Items.Add(entry);
                }
            });
            Action updateSolutionDirectory = () => State.SolutionDirectory = solutionDirectoryEntry.TextEntry.Text;

            solutionDirectoryEntry.TextInput        += (sender, e) => updateSolutionDirectory();
            solutionDirectoryEntry.SelectionChanged += (sender, e) => updateSolutionDirectory();
            solutionDirectoryRow.PackStart(solutionDirectoryEntry, true);

            var solutionDirectoryPickerButton = new Button()
            {
                Label = "Choose..."
            };

            solutionDirectoryPickerButton.Clicked += delegate {
                var chooser = new SelectFolderDialog("Choose directory to create projects.")
                {
                    CanCreateFolders = true
                };
                if (chooser.Run())
                {
                    solutionDirectoryEntry.TextEntry.Text = chooser.Folder;
                }
            };
            solutionDirectoryRow.PackStart(solutionDirectoryPickerButton);

            // import button
            import_button = new Button {
                Label = "Import"
            };
            import_button.Clicked += (sender, e) => {
                // switch to importing state
                import_button.Sensitive = false;
                this.Content.Cursor     = CursorType.Wait;             // does not seem to make much sense...

                Controller.SaveHistories();
                Controller.PerformImport();
            };
            layout.PackStart(import_button);

            var tree = new TreeView();

            package_field   = new DataField <string> ();
            tree_store      = new TreeStore(package_field);
            tree.DataSource = tree_store;
            tree.Columns.Add("Packages", package_field);
            layout.PackStart(tree, true);
            Model.PackageListUpdated += packages => {
                Application.Invoke(() => {
                    var nav = tree_store.AddNode();
                    foreach (var package in packages)
                    {
                        nav.AddChild().SetValue(package_field, package.ToString()).MoveToParent();
                    }

                    // restore default state
                    Content.Cursor          = CursorType.Arrow;
                    import_button.Sensitive = true;
                });
            };

            Content = layout;

            Application.InvokeAsync(() => Controller.Start());
        }
Ejemplo n.º 30
0
        public void AddExistingFolder()
        {
            var project        = (Project)CurrentNode.GetParentDataItem(typeof(Project), true);
            var selectedFolder = ((FilePath)GetFolderPath(CurrentNode.DataItem)).CanonicalPath;

            var ofdlg = new SelectFolderDialog(GettextCatalog.GetString("Add Existing Folder"))
            {
                CurrentFolder = selectedFolder
            };

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

            var srcRoot    = ofdlg.SelectedFile.CanonicalPath;
            var targetRoot = selectedFolder.Combine(srcRoot.FileName);

            bool changedProject = false;

            if (File.Exists(targetRoot))
            {
                MessageService.ShowWarning(GettextCatalog.GetString(
                                               "There is already a file with the name '{0}' in the target directory", srcRoot.FileName));
                return;
            }

            var existingPf = project.Files.GetFileWithVirtualPath(targetRoot.ToRelative(project.BaseDirectory));

            if (existingPf != null)
            {
                if (existingPf.Subtype != Subtype.Directory)
                {
                    MessageService.ShowWarning(GettextCatalog.GetString(
                                                   "There is already a link with the name '{0}' in the target directory", srcRoot.FileName));
                    return;
                }
            }
            else
            {
                project.Files.Add(new ProjectFile(targetRoot)
                {
                    Subtype = Subtype.Directory
                });
                changedProject = true;
            }

            var foundFiles = Directory.GetFiles(srcRoot, "*", SearchOption.AllDirectories);

            var impdlg = new IncludeNewFilesDialog(GettextCatalog.GetString("Select files to add from {0}", srcRoot.FileName), srcRoot.ParentDirectory);

            impdlg.AddFiles(foundFiles);
            if (MessageService.ShowCustomDialog(impdlg) == (int)ResponseType.Ok)
            {
                var srcFiles    = impdlg.SelectedFiles;
                var targetFiles = srcFiles.Select(f => targetRoot.Combine(f.ToRelative(srcRoot)));
                if (IdeApp.ProjectOperations.AddFilesToProject(project, srcFiles.ToArray(), targetFiles.ToArray(), null).Any())
                {
                    changedProject = true;
                }
            }

            if (changedProject)
            {
                IdeApp.ProjectOperations.Save(project);
            }
        }
Ejemplo n.º 31
0
        public void AddFilesFromFolder()
        {
            var project = (Project) CurrentNode.GetParentDataItem (typeof(Project), true);
            var targetRoot = ((FilePath) GetFolderPath (CurrentNode.DataItem)).CanonicalPath;

            var ofdlg = new SelectFolderDialog (GettextCatalog.GetString ("Import From Folder")) {
                CurrentFolder = !PreviousFolderPath.IsNullOrEmpty ? PreviousFolderPath : targetRoot
            };
            if(!ofdlg.Run ())
                return;
            PreviousFolderPath = ofdlg.SelectedFile.CanonicalPath;
            if (!PreviousFolderPath.ParentDirectory.IsNullOrEmpty)
                PreviousFolderPath = PreviousFolderPath.ParentDirectory;

            var srcRoot = ofdlg.SelectedFile.CanonicalPath;
            var foundFiles = Directory.GetFiles (srcRoot, "*", SearchOption.AllDirectories);

            var impdlg = new IncludeNewFilesDialog (GettextCatalog.GetString ("Select files to add from {0}", srcRoot.FileName), srcRoot);
            impdlg.AddFiles (foundFiles);
            if (MessageService.ShowCustomDialog (impdlg) != (int) ResponseType.Ok)
                return;

            var srcFiles = impdlg.SelectedFiles;
            var targetFiles = srcFiles.Select (f => targetRoot.Combine (f.ToRelative (srcRoot)));

            var added = IdeApp.ProjectOperations.AddFilesToProject (project, srcFiles.ToArray (), targetFiles.ToArray (), null).Any ();
            if (added)
                IdeApp.ProjectOperations.Save (project);
        }
		protected virtual void OnButtonAddClicked (object sender, System.EventArgs e)
		{
			var dlg = new SelectFolderDialog (GettextCatalog.GetString ("Select the mono installation prefix")) {
				TransientFor = this.Toplevel as Gtk.Window,
				CurrentFolder = "/usr",
			};
			if (!dlg.Run ())
				return;
			
			var rinfo = new MonoRuntimeInfo (dlg.SelectedFile);
			if (!rinfo.IsValidRuntime) {
				MessageService.ShowError (GettextCatalog.GetString ("Mono runtime not found"), GettextCatalog.GetString ("Please provide a valid directory prefix where mono is installed (for example, /usr)"));
				return;
			}
			newInfos.Add (rinfo);
			store.AppendValues (rinfo.DisplayName, rinfo);
		}