Exemple #1
0
    protected void OnPickFilesClicked(object sender, EventArgs e)
    {
        // Create an instance of the open file dialog box.
        // lblFileMarker.Visible = false;
        FileChooserDialog OFD = new FileChooserDialog(
            "Please select the cia's to boop",
            this,
            FileChooserAction.Open,
            "Cancel", ResponseType.Cancel,
            "Open", ResponseType.Accept);

        OFD.SelectMultiple = true;
        FileFilter filter = new FileFilter();

        filter.Name = "FBI compatible files";
        filter.AddPattern("*.cia");
        OFD.AddFilter(filter);

        if (OFD.Run() == (int)ResponseType.Accept)
        {
            if (OFD.Filenames.Length > 0)
            {
                FilesToBoop = OFD.Filenames.ToArray();
                ProcessFilenames();
            }
        }
        // end if
        OFD.Destroy();
    }
Exemple #2
0
        protected void OnButtonSaveClicked(object sender, EventArgs e)
        {
            TreePath sel = iconviewFiles.SelectedItems [0];
            TreeIter iter;

            FilesStore.GetIter(out iter, sel);

            FileChooserDialog fc =
                new FileChooserDialog("Укажите путь для сохранения файла",
                                      (Gtk.Window) this.Toplevel,
                                      FileChooserAction.Save,
                                      "Отмена", ResponseType.Cancel,
                                      "Сохранить", ResponseType.Accept);

            fc.CurrentName = (string)FilesStore.GetValue(iter, (int)FilesCol.name);
            fc.Show();
            if (fc.Run() == (int)ResponseType.Accept)
            {
                fc.Hide();
                logger.Info("Сохраняем файл на диск...");
                byte[] file = (byte[])FilesStore.GetValue(iter, (int)FilesCol.file);
                if (file == null)
                {
                    file = LoadFileFromDB((int)FilesStore.GetValue(iter, (int)FilesCol.id));
                }
                System.IO.File.WriteAllBytes(fc.Filename, file);
            }
            fc.Destroy();
            logger.Info("Ок");
        }
Exemple #3
0
        protected void OnEscenarioDesdeArchivoActionActivated(object sender, EventArgs e)
        {
            FileChooserDialog Fcd = new FileChooserDialog("Abrir escenario", this, FileChooserAction.Open, "Abrir", ResponseType.Accept, "Cancelar", ResponseType.Cancel);

            Fcd.SetCurrentFolder("..\\");

            Fcd.Filter = new FileFilter();
            Fcd.Filter.AddPattern("*.svg");
            string tempname = GetEmptyPath();

            if (Fcd.Run() == (int)ResponseType.Accept)
            {
                limpiarPantalla();
                activarBotonesSimulacion();
                String fileconfig = Fcd.Filename.Split('.')[0] + ".conf";
                leer_archivo(Fcd.Filename, fileconfig);

//				Gdk.Pixbuf img=Rsvg.Pixbuf.FromFile (Fcd.Filename);
                Constantes.escenarioCargado = true;
//				img.Save (tempname, "png");
//				Constantes.escenarioSurface.Dispose ();
//				Constantes.escenarioSurface = new Cairo.ImageSurface (tempname);
//				File.Delete (tempname);
                GuardarEscenarioAction.Sensitive = true;
                Logica.grilla.cargar_obstaculos();
            }

            Fcd.Destroy();
        }
Exemple #4
0
    protected virtual void OnOpenActivated(object sender, System.EventArgs e)
    {
        FileChooserDialog dialog =
            new FileChooserDialog("Open Object Map File", null, FileChooserAction.Open,
                                  Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
                                  Gtk.Stock.Open, Gtk.ResponseType.Ok);

        if (lastFolder != null)
        {
            dialog.SetCurrentFolder(lastFolder);
        }

        int response = dialog.Run();

        try {
            if (response == (int)Gtk.ResponseType.Ok)
            {
                lastFolder = dialog.CurrentFolder;
                ResetFile();
                OpenFile(dialog.Filename);
            }
        } finally {
            dialog.Destroy();
        }
    }
Exemple #5
0
        public virtual bool ChooseFolder(string title, string initialFolder, out string folder)
        {
            bool ret;

            using (FileChooserDialog fc = new FileChooserDialog(title, null, FileChooserAction.SelectFolder,
                                                                Translator.GetString("OK"), ResponseType.Accept,
                                                                Translator.GetString("Cancel"), ResponseType.Cancel)) {
                DialogBase.PushModalDialog(fc, "ChooseOutputFolder");

                if (!string.IsNullOrEmpty(initialFolder) && Directory.Exists(initialFolder))
                {
                    fc.SetCurrentFolder(initialFolder);
                }

                if (fc.Run() == (int)ResponseType.Accept)
                {
                    folder = fc.CurrentFolder;
                    ret    = true;
                }
                else
                {
                    folder = null;
                    ret    = false;
                }

                fc.Destroy();
                DialogBase.PopModalDialog(fc, "ChooseOutputFolder");
            }

            return(ret);
        }
        protected void OnButtonAddImageClicked(object sender, EventArgs e)
        {
            FileChooserDialog Chooser = new FileChooserDialog("Выберите изображение...",
                                                              (Window)this.Toplevel,
                                                              FileChooserAction.Open,
                                                              "Отмена", ResponseType.Cancel,
                                                              "Загрузить", ResponseType.Accept);

            FileFilter Filter = new FileFilter();

            Filter.AddPixbufFormats();
            Filter.Name = "Все изображения";
            Chooser.AddFilter(Filter);

            if ((ResponseType)Chooser.Run() == ResponseType.Accept)
            {
                Chooser.Hide();
                logger.Info("Загрузка изображения...");

                var imageFile = ImageHelper.LoadImageToJpgBytes(Chooser.Filename);
                ViewModel.Entity.Images.Add(new NomenclatureImage(ViewModel.Entity, imageFile));
                ReloadImages();

                logger.Info("Ok");
            }
            Chooser.Destroy();
        }
Exemple #7
0
    public bool DoSaveDialog()
    {
        bool retval = false;

        FileChooserDialog chooser = new FileChooserDialog(
            "Save Handwriting", null, FileChooserAction.Save);

        chooser.SetCurrentFolder(Environment.GetFolderPath(
                                     Environment.SpecialFolder.Personal));
        chooser.AddButton(Gtk.Stock.Cancel, ResponseType.Cancel);
        chooser.AddButton(Gtk.Stock.Ok, ResponseType.Ok);
        chooser.DefaultResponse = ResponseType.Ok;

        if (chooser.Run() == (int)ResponseType.Ok)
        {
            string        path = (new Uri(chooser.Uri)).AbsolutePath;
            XmlTextWriter xml  = new XmlTextWriter(path,
                                                   System.Text.Encoding.UTF8);
            xml.Formatting = Formatting.Indented;
            handwriting.Serialize(xml);
            xml.Close();
            hasChanged = false;
            retval     = true;
        }

        chooser.Destroy();
        return(retval);
    }
        public void Activate()
        {
            object[]          buttonResponses = new object[] { "Accept", ResponseType.Accept, "Cancel", ResponseType.Cancel };
            FileChooserDialog fileDialog      = new FileChooserDialog("Local Studies", (Window)_mainView.GuiElement, FileChooserAction.SelectFolder, buttonResponses);

            int    result = fileDialog.Run();
            string folder = fileDialog.Filename;

            fileDialog.Destroy();               // must manually destroy the dialog

            if (result == (int)ResponseType.Accept)
            {
                LocalImageLoader loader   = new LocalImageLoader();
                string           studyUID = loader.Load(folder);
                //if(studyUID == "" || WorkstationModel.StudyManager.StudyTree.GetStudy(studyUID) == null)
                if (studyUID == "" || ImageWorkspace.StudyManager.StudyTree.GetStudy(studyUID) == null)
                {
                    //Platform.ShowMessageBox(ClearCanvas.Workstation.Model.SR.ErrorUnableToLoadStudy);
                    Platform.ShowMessageBox(ClearCanvas.ImageViewer.SR.ErrorUnableToLoadStudy);
                }
                else
                {
                    ImageWorkspace ws = new ImageWorkspace(studyUID);
                    //WorkstationModel.WorkspaceManager.Workspaces.Add(ws);
                    DesktopApplication.WorkspaceManager.Workspaces.Add(ws);
                }
            }
        }
        public IDbServerConnection getConnection(Window parentWindow)
        {
            FileChooserDialog chooseFileDialog = new FileChooserDialog(
                openNew ? "New SQLite database" : "Open existing SQLite database",
                parentWindow,
                openNew ? FileChooserAction.Save : FileChooserAction.Open,
                "Cancel", ResponseType.Cancel,
                openNew ? "Create" : "Open", ResponseType.Accept
                );

            try {
                if (chooseFileDialog.Run() != (int)ResponseType.Accept)
                {
                    return(null);
                }

                SqliteConnectionStringBuilder conStrBuilder = new SqliteConnectionStringBuilder();
                conStrBuilder.DataSource    = chooseFileDialog.Filename;
                conStrBuilder.FailIfMissing = !openNew;

                return(new SqliteDbServerConnection(chooseFileDialog.Filename, conStrBuilder.ConnectionString));
            } finally {
                chooseFileDialog.Destroy();
            }
        }
Exemple #10
0
    protected void OnButtonOutputChooseClicked(object sender, EventArgs e)
    {
        FileChooserDialog fileChooserDialog;

        fileChooserDialog = new FileChooserDialog("Choose output file", this, FileChooserAction.Save, ("Cancel"), ResponseType.Cancel, ("Save"), ResponseType.Accept, null);
        try
        {
            if (File.Exists(entry_output_file_path.Text) || Directory.Exists(entry_output_file_path.Text))
            {
                fileChooserDialog.SetFilename(entry_output_file_path.Text);
            }
            else if (Directory.Exists(System.IO.Path.GetDirectoryName(entry_output_file_path.Text)))
            {
                fileChooserDialog.SetFilename(System.IO.Path.GetDirectoryName(entry_output_file_path.Text));
            }
        }
        catch (Exception ex)
        {
        }
        fileChooserDialog.Show();
        if (fileChooserDialog.Run() == -3)
        {
            entry_output_file_path.Text = fileChooserDialog.Filename;
            checkbutton_output_copy_input_name.Active = false;
        }
        fileChooserDialog.Destroy();
    }
Exemple #11
0
    protected void BtnDataChoose(object sender, EventArgs e)
    {
        // get file
        FileChooserDialog dialog = new FileChooserDialog(
            "Select a data file:", this, FileChooserAction.Open,
            "Cancel", ResponseType.Cancel,
            "Open", ResponseType.Accept);

        // read file
        if (dialog.Run() == (int)ResponseType.Accept)
        {
            isInitialized = false;
            ReadDataFile(dialog.Filename);
            // make perceptron
            perceptron = new Rosenblatt.Rosenblatt(dimensionality);
            // update visual
            UpdateAxisAndCombo();
            // update controls
            lblQuality.Text = $"Quality: {TestPerceptron():N}";
            RenderRoot();
        }

        // finalize
        dialog.Destroy();
    }
Exemple #12
0
    // data
    protected void BtnDataSave(object sender, EventArgs e)
    {
        if (!isInitialized)
        {
            ShowDlg("There is nothing to save.", MessageType.Info);
            return;
        }

        // get file
        FileChooserDialog dialog = new FileChooserDialog(
            "Select a data file:", this, FileChooserAction.Save,
            "Cancel", ResponseType.Cancel,
            "Open", ResponseType.Accept);

        // write file
        if (dialog.Run() == (int)ResponseType.Accept)
        {
            StreamWriter writer;
            writer = File.CreateText(dialog.Filename);
            WriteDataFile(writer);
            writer.Flush();
            writer.Close();
        }
        dialog.Destroy();
    }
Exemple #13
0
        void fixupBrowseButton_Clicked(object sender, EventArgs e)
        {
            var fixupFilter = new FileFilter {
                Name = "Gir fixup files (*.girfixup)"
            };

            fixupFilter.AddPattern("*.girfixup");
            var allFilesFilter = new FileFilter {
                Name = "All files (*.*)"
            };

            allFilesFilter.AddPattern("*.*");

            var fileDialog = new FileChooserDialog("Select", this, FileChooserAction.Open,
                                                   "_Cancel", ResponseType.Cancel,
                                                   "_Open", ResponseType.Ok);

            fileDialog.AddFilter(fixupFilter);
            fileDialog.AddFilter(allFilesFilter);
            if (File.Exists(fixupFileNameEntry.Text))
            {
                fileDialog.SetFilename(fixupFileNameEntry.Text);
            }
            else
            {
                fileDialog.SetCurrentFolder(".");
            }
            if (fileDialog.Run() == (int)ResponseType.Ok)
            {
                fixupFileNameEntry.Text = fileDialog.Filename;
            }
            fileDialog.Destroy();
        }
Exemple #14
0
        protected void OnImportFromFile()
        {
            FileChooserDialog dlg = new FileChooserDialog(
                GettextCatalog.GetString("Import From File"), null, FileChooserAction.Open,
                "gtk-cancel", ResponseType.Cancel,
                "gtk-open", ResponseType.Accept
                );

            dlg.SelectMultiple = false;
            dlg.LocalOnly      = true;
            dlg.Modal          = true;

            FileFilter filter = new FileFilter();

            filter.AddPattern("*.[sS][qQ][lL]");
            filter.Name = GettextCatalog.GetString("SQL files");
            FileFilter filterAll = new FileFilter();

            filterAll.AddPattern("*");
            filterAll.Name = GettextCatalog.GetString("All files");
            dlg.AddFilter(filter);
            dlg.AddFilter(filterAll);

            if (dlg.Run() == (int)ResponseType.Accept)
            {
                using (FileStream stream = File.Open(dlg.Filename, FileMode.Open)) {
                    using (StreamReader reader = new StreamReader(stream)) {
                        Text = reader.ReadToEnd();
                    }
                }
            }
            dlg.Destroy();
        }
Exemple #15
0
        protected void ButtonBrowse_Clicked(object sender, EventArgs e)
        {
            var dialog = new FileChooserDialog("Add Content Folder",
                                               _window,
                                               FileChooserAction.SelectFolder,
                                               "Cancel", ResponseType.Cancel,
                                               "Open", ResponseType.Accept);

            dialog.SetCurrentFolder(_window._controller.GetFullPath(entryPath.Text));

            var responseId = dialog.Run();
            var fileName   = dialog.Filename;

            dialog.Destroy();

            if (responseId != (int)ResponseType.Accept)
            {
                return;
            }

            var pathUri = new Uri(fileName);

            entryPath.Text     = Uri.UnescapeDataString(_projectLocation.MakeRelativeUri(pathUri).ToString().Replace('/', System.IO.Path.DirectorySeparatorChar));
            entryPath.Position = entryPath.Text.Length;
        }
Exemple #16
0
        protected void OnButton41Clicked(object sender, EventArgs e)
        {
            // Download config to local
            FileChooserDialog folderChoose = new FileChooserDialog("Choose configuration download path", null, FileChooserAction.SelectFolder);

            folderChoose.AddButton("Cancel", (int)ResponseType.Cancel);
            folderChoose.AddButton("Select", (int)ResponseType.Ok);
            if (folderChoose.Run() == (int)ResponseType.Ok)
            {
                //TODO
                List <String> config = GetConfigFromTreeview(treeview3);
                                #if DEBUG
                foreach (var line in config)
                {
                    Debug.WriteLine(line);
                }
                                #endif
                File.WriteAllLines(folderChoose.Filename + "/load_server_runtime_config", config);
                config = GetConfigFromTreeview(treeview6);
                                #if DEBUG
                foreach (var line in config)
                {
                    Debug.WriteLine(line);
                }
                                #endif
                File.WriteAllLines(folderChoose.Filename + "/load_client_runtime_config", config);
            }
            folderChoose.Destroy();
        }
Exemple #17
0
        public void DialogRun(ResponseType type)
        {
            if ((int)type == 2 || ((int)type == 3 && _filename == null))
            {
                var fc = new FileChooserDialog(_("HTML Save As"), this,
                                               FileChooserAction.Save,
                                               "Cancel", ResponseType.Cancel,
                                               "Save", ResponseType.Accept);

                if (fc.Run() == (int)ResponseType.Accept)
                {
                    string filename = fc.Filename;
                    if (System.IO.File.Exists(filename))
                    {
                        var message = new FileExistsDialog(filename);
                        if (!message.IsYes())
                        {
                            return;
                        }
                    }
                    SetTitle(filename);
                    Save(filename);
                }
                fc.Destroy();
            }
            else // type == 3
            {
                Save(_filename);
            }
        }
Exemple #18
0
    protected void On_SaveAsAction_Activated(object sender, EventArgs e)
    {
        //create and display a FileChooserDialog
        FileChooserDialog fileChooser =
            new FileChooserDialog("Save File", this, FileChooserAction.Save,
                                  "Cancle", ResponseType.Cancel,
                                  "Save", ResponseType.Ok);

        //click ok
        if (fileChooser.Run() == (int)ResponseType.Ok)
        {
            //write contents into the file
            //if the file not exist,create it and write
            //if already exist,overwrite it
            System.IO.File.WriteAllText(fileChooser.Filename,
                                        TextView.Buffer.Text);
        }

        //success message
        MessageDialog md =
            new MessageDialog(this, DialogFlags.DestroyWithParent,
                              MessageType.Info, ButtonsType.Ok,
                              "Save Success!");

        md.Run();

        //destory windows
        fileChooser.Destroy();
        md.Destroy();
    }
        private void OnMenuOpenActivate(object sender, EventArgs args)
        {
            FileChooserDialog chooser = new FileChooserDialog("Selecciona un fichero para abrir", (Window)mainComponentBuilderForm["mainView"], FileChooserAction.Open, Stock.Open);

            chooser.AddButton(Stock.Open, ResponseType.Accept);
            chooser.AddButton(Stock.Cancel, ResponseType.Cancel);
            chooser.SelectMultiple = false;
            ResponseType response = (ResponseType)chooser.Run();

            switch (response)
            {
            case ResponseType.Accept:
                if (chooser.Filename.Length != 0)
                {
                    DefaultContainer.Instance.Execute("ComponentBuilder", "DeserializeProject", new object[] { chooser.Filename }, this);
                }
                break;

            case ResponseType.Cancel:
                break;

            default:
                break;
            }
            chooser.Destroy();
            chooser = null;
        }
Exemple #20
0
        /// <summary>Opens a file chooser dialog for the user to choose a directory.</summary>
        /// <return>
        /// The path of the chosen directory, or an empty string if the user pressed cancel or
        /// selected a nonexistent directory.
        /// </return>
        private string GetDirectory()
        {
            string path = "";

            Application.Invoke(delegate
            {
                FileChooserDialog fc = new FileChooserDialog(
                    "Choose the file to open",
                    null,
                    FileChooserAction.SelectFolder,
                    "Cancel", ResponseType.Cancel,
                    "Select Folder", ResponseType.Accept);
                try
                {
                    if (fc.Run() == (int)ResponseType.Accept)
                    {
                        path = fc.Filename;
                    }
                }
                catch (Exception ex)
                {
                    (Owner as MainView).ShowMessage(ex.ToString(), Models.Core.Simulation.ErrorLevel.Error);
                }
                finally
                {
                    fc.Destroy();
                }
            });

            return(path);
        }
        protected virtual void OnOpenbuttonClicked(object sender, System.EventArgs e)
        {
            FileChooserDialog fChooser = new FileChooserDialog(Catalog.GetString("Save Video As ..."),
                                                               this,
                                                               FileChooserAction.Save,
                                                               "gtk-cancel", ResponseType.Cancel,
                                                               "gtk-save", ResponseType.Accept);

            fChooser.SetCurrentFolder(Config.VideosDir);
            fChooser.CurrentName             = "NewVideo." + GetExtension();
            fChooser.DoOverwriteConfirmation = true;
            FileFilter filter = new FileFilter();

            filter.Name = "Multimedia Files";
            filter.AddPattern("*.mkv");
            filter.AddPattern("*.mp4");
            filter.AddPattern("*.ogg");
            filter.AddPattern("*.avi");
            filter.AddPattern("*.mpg");
            filter.AddPattern("*.vob");
            fChooser.Filter = filter;
            if (fChooser.Run() == (int)ResponseType.Accept)
            {
                filelabel.Text = fChooser.Filename;
            }
            fChooser.Destroy();
        }
Exemple #22
0
        private void buttonCacheLocationClick(object sender, EventArgs e)
        {
            Log.Debug("buttonCacheLocationClick");
            // Thanks Petteri Kautonen - http://mono.1490590.n4.nabble.com/Gtk-sharp-list-FileOpenDialog-td1544553.html
            var dialog = new FileChooserDialog("Select folder to save the cached thumbnails:",
                                               null, FileChooserAction.SelectFolder);

            var preferences = getModelFromFields();

            dialog.SetCurrentFolder(preferences.CacheLocation);

            dialog.AddButton(Stock.Cancel, ResponseType.Cancel);
            dialog.AddButton(Stock.Ok, ResponseType.Ok);

            var result = (ResponseType)dialog.Run();

            if (result == ResponseType.Ok)
            {
                Preferences.CacheLocation = preferences.CacheLocation = dialog.CurrentFolder;
                setFieldsFromModel(preferences);
                SetCacheSize();
            }

            dialog.Destroy();
        }
Exemple #23
0
    void OpenGameDialog()
    {
        FileChooserDialog folderChooser =
            new FileChooserDialog("Find the " + gameName + " game folder",
                                  this,
                                  FileChooserAction.SelectFolder,
                                  "Cancel", ResponseType.Cancel,
                                  "Open", ResponseType.Accept);

        if (folderChooser.Run() == (int)ResponseType.Accept)
        {
            string folderName = folderChooser.Filename;
            Console.WriteLine("Selected " + folderName);

            customGamePath = folderName + gameExtention;
            Console.WriteLine("Custom game path set to: " + customGamePath);

            isCustomGamePath = true;
            Console.WriteLine("Set custom game path to: " + isCustomGamePath);
        }

        folderChooser.Destroy();

        SettingGamePath();
    }
Exemple #24
0
        protected void saveFileBrief(string extension, WritingDataToFile writeAction)
        {
            FileChooserDialog dialog = new FileChooserDialog(extension, "Сохранить как", this,
                                                             FileChooserAction.Save,
                                                             Stock.Cancel, ResponseType.Cancel,
                                                             Stock.Ok, ResponseType.Ok);

            switch (dialog.Run())
            {
            case ( int )ResponseType.Cancel:
                log("отмена сохранения");
                break;

            case ( int )ResponseType.Ok:
                var builder = new StringBuilder(dialog.Filename);

                if (!dialog.Filename.EndsWith(extension, StringComparison.OrdinalIgnoreCase))
                {
                    builder.Append(extension);
                }

                writeAction(builder.ToString());
                break;
            }
            dialog.Destroy();
        }
Exemple #25
0
    /// <summary>
    /// Picks an archive file for opening
    /// </summary>
    /// <returns>The path to the file.</returns>
    /// <param name="title">The title of the dialog.</param>
    /// <param name="fileName">The pre-selected file name.</param>
    /// <param name="patterns">File filter patters as an array of {patternName, pattern}.</param>
    /// <param name="OKLabel">The label for the OK button (where supported)</param>
    /// <param name="CancelLabel">The label for the Cancel button (where supported)</param>
    public string pickFile(string title, string fileName, string[,] patterns, string OKLabel, string CancelLabel)
    {
        FileChooserDialog dialog = new FileChooserDialog(title, this, FileChooserAction.Open);

        if (fileName != "")
        {
            dialog.CurrentName = fileName;
            dialog.SetCurrentFolder(fileName);
        }

        dialog.AddButton(CancelLabel, Gtk.ResponseType.Cancel);
        dialog.AddButton(OKLabel, Gtk.ResponseType.Accept);

        for (int i = 0; i < patterns.Length / 2; i++)
        {
            FileFilter filter = new FileFilter();
            filter.Name = patterns[i, 0];
            filter.AddPattern(patterns[i, 1]);
            dialog.AddFilter(filter);
        }

        ResponseType ret         = (ResponseType)dialog.Run();
        string       newFileName = dialog.Filename;

        dialog.Destroy();

        if (ret != ResponseType.Accept)
        {
            return("");
        }

        return(newFileName);
    }
Exemple #26
0
        private void Export()
        {
            var parentW   = GtkHelper.GetParentWindow(this);
            var csvFilter = new FileFilter();

            csvFilter.AddPattern("*.csv");
            csvFilter.Name = "Comma Separated Values File (*.csv)";

            var param = new object[4];

            param[0] = "Cancel";
            param[1] = ResponseType.Cancel;
            param[2] = "Save";
            param[3] = ResponseType.Accept;

            var fc = new FileChooserDialog("Save File As", parentW, FileChooserAction.Save, param)
            {
                DoOverwriteConfirmation = true,
                CurrentName             = "Аналитика заказов.csv"
            };

            fc.AddFilter(csvFilter);

            if (fc.Run() == (int)ResponseType.Accept)
            {
                ViewModel.FileName = fc.Filename;
                ViewModel.ExportCommand.Execute();
            }

            fc.Destroy();
        }
Exemple #27
0
		void OpenAction_Activated(object sender, EventArgs e)
		{
			// Let the user select a file to open.
			var dialog = new FileChooserDialog(
				string.Format("Open file - {0}", BaseTitle),
				this, FileChooserAction.Open);

			dialog.AddButton(Stock.Cancel, ResponseType.Cancel);
			dialog.AddButton(Stock.Open, ResponseType.Ok);

			// Try to start file selection from current file,
			// if there is one.
			//
			// This enables the user to successively open files
			// from the same directory, e.g., from a collection
			// of notes files.
			if (!string.IsNullOrEmpty(_FilePath))
				dialog.SetFilename(_FilePath);

			int result = dialog.Run();
			string filePath = dialog.Filename;
			dialog.Destroy();

			// Check that the user did in fact give confirmation.
			if (result != (int)ResponseType.Ok)
				return;

			// Actually open the file.
			LoadFile(filePath);
		}
Exemple #28
0
        private void Open(FileChooserAction action)
        {
            string title = Catalog.GetString("Open");

            if (action == FileChooserAction.SelectFolder)
            {
                title = Catalog.GetString("Select Folder");
            }

            FileChooserDialog chooser = new FileChooserDialog(title,
                                                              window,
                                                              action);

            chooser.AddButton(Stock.Cancel, ResponseType.Cancel);
            chooser.AddButton(Stock.Open, ResponseType.Ok);

            chooser.SetUri(uri.ToString());
            int response = chooser.Run();

            if ((ResponseType)response == ResponseType.Ok)
            {
                CurrentUri = new System.Uri(chooser.Uri);
            }


            chooser.Destroy();
        }
Exemple #29
0
        void OnOpen(object sender, EventArgs e)
        {
            var fc =
                new FileChooserDialog("Choose the file to open",
                                      this,
                                      FileChooserAction.Open,
                                      "Cancel", ResponseType.Cancel,
                                      "Open", ResponseType.Accept);

            fc.SetPosition(WindowPosition.Center);
            if (fc.Run() == (int)ResponseType.Accept)
            {
                if (!AppController.Instance.Surface.IsEmpty())
                {
                    string           fileName = Process.GetCurrentProcess().MainModule.FileName.Replace(".vshost", "");
                    ProcessStartInfo info     = new ProcessStartInfo(fileName);
                    info.UseShellExecute = false;
                    info.Arguments       = fc.Filename;
                    Process processChild = Process.Start(info);
                }
                else
                {
                    AppController.Instance.FileName = fc.Filename;
                    var saved = ConfigManager.Read <PrimitivesSurface> (AppController.Instance.FileName);
                    AppController.Instance.ResetSurface();
                    AppController.Instance.ReloadSurface(saved);
                    _grid.Surface = AppController.Instance.Surface;
                    _grid.Surface.QueueDraw();
                }
            }
            //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
            fc.Destroy();
        }
Exemple #30
0
    protected virtual void OnAddFolderActivated(object sender, System.EventArgs e)
    {
        // Create a new window for picking a file
        Window            win    = new Window("Add a new file");
        FileChooserDialog dialog = new FileChooserDialog(
            "Select a folder to add",
            win,
            FileChooserAction.SelectFolder,
            Stock.Cancel,
            ResponseType.Cancel,
            Stock.Open,
            ResponseType.Ok,
            null);

        dialog.SelectMultiple    = true;
        dialog.DestroyWithParent = true;
        dialog.Modal             = true;

        // if they hit OK then add each folder selected to the Library
        if ((ResponseType)dialog.Run() == ResponseType.Ok)
        {
            foreach (string x in dialog.Filenames)
            {
                mp3.createLibrary(x);
            }
        }
        dialog.Destroy();
        win.Destroy();

        RefreshSearchList();
    }
        private void OnBrowseClicked(object o, EventArgs args)
        {
            FileChooserDialog chooser = new FileChooserDialog(
                Catalog.GetString("Open Location"),
                null,
                FileChooserAction.Open
            );

            chooser.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
            chooser.AddButton(Stock.Cancel, ResponseType.Cancel);
            chooser.AddButton(Stock.Open, ResponseType.Ok);
            chooser.DefaultResponse = ResponseType.Ok;
            chooser.LocalOnly = false;

            if(chooser.Run() == (int)ResponseType.Ok) {
                address_entry.Entry.Text = chooser.Uri;
            }

            chooser.Destroy();
        }