Exemplo n.º 1
0
        private void OpenFileButton_Clicked(object sender, EventArgs e)
        {
            var fileChooser = new FileChooserDialog("Pick a file", this.Window, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
            fileChooser.Filter = new FileFilter();
            fileChooser.Filter.AddPattern("*.xt");
#if DEBUG
            fileChooser.SetCurrentFolder(@"c:\tmp\traces");
#endif
            var result = (ResponseType)Enum.ToObject(typeof(ResponseType), fileChooser.Run());
            switch (result)
            {
                case ResponseType.Accept:
                    var filename = fileChooser.Filename;
                    Parser parser = null;
                    fileChooser.Destroy();
                    try
                    {
                        parser = Parser.ParseFile(filename);
                    }
                    catch (Exception ex)
                    {
                        var dlg = new MessageDialog(this.Window, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Failed to load/parse the selected file! \r\nSome indication: " + ex.Message);
                        dlg.Run();
                    }
                    if (parser != null)
                    {
                        ShowTraces(parser);
                    }
                    break;
                case ResponseType.Cancel:
                case ResponseType.DeleteEvent:
                    fileChooser.Destroy();
                    break;
            }
        }
Exemplo n.º 2
0
        protected override void OnActivated()
        {
            base.OnActivated();

            if(String.IsNullOrEmpty(MainClass.Workspace.FilePath)){
                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("workspace_not_exist"), MainClass.Languages.Translate("please_create_workspace"), Gtk.MessageType.Error);
                md.ShowDialog();
                return;
            }

            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("save_project_export"), MainClass.MainWindow, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);

            if (!String.IsNullOrEmpty(MainClass.Settings.LastOpenedExportDir))
                fc.SetCurrentFolder(MainClass.Settings.LastOpenedExportDir);

            FileFilter filter = new FileFilter();
            filter.Name = "zip files";
            filter.AddMimeType("zip file");
            filter.AddPattern("*.zip");
            fc.AddFilter(filter);

            string appname = "";
            int typ = -1;
            Gtk.TreeIter ti = new Gtk.TreeIter();
            MainClass.MainWindow.WorkspaceTree.GetSelectedFile(out appname, out typ, out ti);

            if (String.IsNullOrEmpty(appname)){
                return;
            }

            Project p = MainClass.Workspace.FindProject_byApp(appname, true);

            if(p== null){
                return;
            }

            fc.CurrentName =p.ProjectName;

            if (fc.Run() != (int)ResponseType.Accept) {
                fc.Destroy();
                return;
            }

            string name =fc.Filename;

            string ext = System.IO.Path.GetExtension(name);

            if(ext.ToLower() != ".zip")
                name = name+".zip";

            if(p!= null){
                p.Export(name,false);
                MainClass.Settings.LastOpenedExportDir = System.IO.Path.GetDirectoryName(fc.Filename);
            }
            fc.Destroy();
        }
Exemplo n.º 3
0
    protected void OnSaveStageAsActionActivated(object sender, System.EventArgs e)
    {
        Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog("Save stage description",
                                                              this,
                                                              FileChooserAction.Save,
                                                              "Cancel", ResponseType.Cancel,
                                                              "Save", ResponseType.Accept);

        FileFilter[] ffs = new FileFilter[1];
        ffs[0] = new FileFilter();
        ffs[0].AddPattern("*.cestage");
        ffs[0].Name = "CatEye Stage file";

        fcd.AddFilter(ffs[0]);

        fcd.CurrentName = System.IO.Path.GetFileNameWithoutExtension(mStage.RawFileName);
        fcd.SetCurrentFolder(System.IO.Path.GetDirectoryName(mStage.RawFileName));

        if (fcd.Run() == (int)Gtk.ResponseType.Accept)
        {
            string fn = fcd.Filename;
            if (System.IO.Path.GetExtension(fn).ToLower() != ".cestage")
            {
                fn += ".cestage";
            }

            mStage.SaveStage(fn);
        }
        fcd.Destroy();
    }
Exemplo n.º 4
0
        internal static string OpenExperimentDialog(Window parentWindow) 
        {
            var fileChooserDialog = new Gtk.FileChooserDialog(Mono.Unix.Catalog.GetString ("Open Experiment File"), 
                                                               parentWindow,
                                                               FileChooserAction.Open, 
                                                               Gtk.Stock.Cancel, 
                                                               Gtk.ResponseType.Cancel,
                                                               Gtk.Stock.Open, Gtk.ResponseType.Ok);

            fileChooserDialog.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
            fileChooserDialog.SelectMultiple = false;

            AddFilters(fileChooserDialog);

            int response = fileChooserDialog.Run();

            string filename = null;
            if(response == (int)Gtk.ResponseType.Ok) 
            {
                filename = fileChooserDialog.Filename;
            }
            
            fileChooserDialog.Destroy();

            return filename;
        }
Exemplo n.º 5
0
    /*
     * void HandleAboutDialogActivateLinkFunc (AboutDialog about, string uri)
     * {
     * }
     */

    void OnOpenActionActivated(object sender, System.EventArgs e)
    {
        Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose ROM file to open", this, FileChooserAction.Open, Gtk.Stock.Cancel, ResponseType.Cancel, Gtk.Stock.Open, ResponseType.Accept);

        Gtk.FileFilter ff;
        ff = new FileFilter {
            Name = "ROM, BIN, HEX files"
        };
        ff.AddPattern("*.rom");
        ff.AddPattern("*.bin");
        ff.AddPattern("*.hex");
        fc.AddFilter(ff);

        ff = new FileFilter {
            Name = "All files"
        };
        ff.AddPattern("*");
        fc.AddFilter(ff);

        ResponseType response = (ResponseType)fc.Run();
        string       path     = fc.Filename;

        fc.Destroy();

        if (response == ResponseType.Accept)
        {
            try {
                OpenRom(path);
            } catch (System.Exception ex) {
                ErrorMsg("Error opening file", ex.Message);
            }
        }
    }
Exemplo n.º 6
0
        protected void LoadProbeClicked(object sender, EventArgs e)
        {
            Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog("Open File", null, Gtk.FileChooserAction.Open);
            fcd.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
            fcd.AddButton(Gtk.Stock.Open, Gtk.ResponseType.Ok);
            fcd.DefaultResponse = Gtk.ResponseType.Ok;
            fcd.SelectMultiple  = false;

            Gtk.FileFilter filter = new FileFilter
            {
                Name = "NIRS probe"
            };
            filter.AddMimeType("XML");
            filter.AddMimeType("Matlab");
            filter.AddPattern("*.SD");
            filter.AddPattern("*.xml");
            fcd.Filter = filter;

            fcd.SetCurrentFolder(MainClass.win.settings.PROBEDIR);

            Gtk.ResponseType response = (Gtk.ResponseType)fcd.Run();
            if (response == Gtk.ResponseType.Ok)
            {
                probe = nirs.io.LoadProbe(fcd.Filename, lambda);
                Sdgdraw(sender, e);
            }
            probefilename = fcd.Filename;
            fcd.Destroy();
        }
Exemplo n.º 7
0
        private void HandlerPintaCoreActionsEditSavePaletteActivated(object sender, EventArgs e)
        {
            var fcd = new Gtk.FileChooserDialog(Catalog.GetString("Save Palette File"), PintaCore.Chrome.MainWindow,
                                                FileChooserAction.Save, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
                                                Gtk.Stock.Save, Gtk.ResponseType.Ok);

            FileFilter ffPDN = new FileFilter();

            ffPDN.AddPattern("*.txt");
            ffPDN.Name = Catalog.GetString("Paint.NET palette (*.txt)");
            fcd.AddFilter(ffPDN);

            FileFilter ffGIMP = new FileFilter();

            ffGIMP.AddPattern("*.gpl");
            ffGIMP.Name = Catalog.GetString("GIMP palette (*.gpl)");
            fcd.AddFilter(ffGIMP);

            fcd.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };

            if (lastPaletteDir != null)
            {
                fcd.SetCurrentFolder(lastPaletteDir);
            }

            int response = fcd.Run();

            if (response == (int)Gtk.ResponseType.Ok)
            {
                Palette.FileFormat format = (fcd.Filter == ffPDN) ? Palette.FileFormat.PDN : Palette.FileFormat.GIMP;
                PintaCore.Palette.CurrentPalette.Save(fcd.Filename, format);
            }

            fcd.Destroy();
        }
Exemplo n.º 8
0
        protected override void OnActivated()
        {
            base.OnActivated();

            if(String.IsNullOrEmpty(MainClass.Workspace.FilePath)){
                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("workspace_not_exist"), MainClass.Languages.Translate("please_create_workspace"), Gtk.MessageType.Error);
                md.ShowDialog();
                return;
            }

            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("chose_project_import"), MainClass.MainWindow, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

            if (!String.IsNullOrEmpty(MainClass.Settings.LastOpenedImportDir))
                fc.SetCurrentFolder(MainClass.Settings.LastOpenedImportDir);

            FileFilter filter = new FileFilter();
            filter.Name = "zip files";
            filter.AddMimeType("zip file");
            filter.AddPattern("*.zip");
            fc.AddFilter(filter);

            if (fc.Run() == (int)ResponseType.Accept) {

                MainClass.Settings.LastOpenedImportDir = System.IO.Path.GetDirectoryName(fc.Filename);

                MainClass.MainWindow.ImportProject(fc.Filename,true);
            }

            fc.Destroy();
        }
Exemplo n.º 9
0
    protected virtual void onOpenPlayerDatClick(object sender, EventArgs e)
    {
        Gtk.FileChooserDialog filechooser =
            new Gtk.FileChooserDialog("Select your player.dat file",
                                      this,
                                      FileChooserAction.Open,
                                      "Cancel", ResponseType.Cancel,
                                      "Open", ResponseType.Accept);

        if (filechooser.Run() == (int)ResponseType.Accept)
        {
            playerDat = System.IO.File.Open(filechooser.Filename,
                                            System.IO.FileMode.Open,
                                            System.IO.FileAccess.ReadWrite,
                                            System.IO.FileShare.None);

            if (playerDat == null)
            {
                throw new Exception("player.dat is not opened");
            }

            BinaryFormatter binaryFormatter = new BinaryFormatter();
            vars       = (Dictionary <string, float>)binaryFormatter.Deserialize(playerDat);
            stringVars = (Dictionary <string, string>)binaryFormatter.Deserialize(playerDat);

            ParsePlayerDat();

            btnSave.Sensitive = true;
        }

        filechooser.Destroy();
    }
        protected async void OnButtonAddClicked(object sender, EventArgs e)
        {
            var FileList = new List <string>();

            var filechooser = new Gtk.FileChooserDialog("Choose files to upload", null,
                                                        FileChooserAction.Open,
                                                        "Cancel", ResponseType.Cancel,
                                                        "Open", ResponseType.Accept);

            filechooser.SelectMultiple = true;

            if (filechooser.Run() == (int)ResponseType.Accept)
            {
                FileList.AddRange(filechooser.Filenames);
            }

            filechooser.Destroy();

            if (FileList.Count > 0)
            {
                foreach (var file in FileList)
                {
                    var filename = System.IO.Path.GetFileName(file);
                    await meadowPad.meadowSerialDevice.WriteFile(filename, System.IO.Path.GetDirectoryName(file));
                }
                BuildList();
            }
        }
Exemplo n.º 11
0
    public void abrirArchivo()
    {
        string r;

        Gtk.FileChooserDialog filechooser =
            new Gtk.FileChooserDialog("Choose the file to open",
                                      this,
                                      FileChooserAction.Open,
                                      "Cancel", ResponseType.Cancel,
                                      "Open", ResponseType.Accept);

        if (filechooser.Run() == (int)ResponseType.Accept)
        {
            this.currentFile = filechooser.Filename;
            StreamReader file = new StreamReader(filechooser.Filename);
            r = file.ReadToEnd();
            file.Close();
            textview3.Buffer.Text = r;

            this.caracteresActuales = textview3.Buffer.CharCount;
            this.caracteresEscritos = textview3.Buffer.CharCount;


            AddLineNumbers();
            IsEditing();
        }
        filechooser.Destroy();
        this.changed = false;
    }
Exemplo n.º 12
0
        void OnAddFileClick(object sender, EventArgs e)
        {
            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("chose_file_to_copy"), null, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

            if (fc.Run() == (int)ResponseType.Accept)
            {
                string filename = System.IO.Path.GetFileName(fc.Filename);
                string newFile  = "";

                newFile = System.IO.Path.Combine(parent.FullName, filename);
                if (System.IO.File.Exists(newFile))
                {
                    newFile = System.IO.Path.Combine(parent.FullName, "Copy_" + filename);
                }

                try {
                    System.IO.File.Copy(fc.Filename, newFile);
                } catch (Exception ex) {
                    MessageDialogs md =
                        new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_copy", fc.Filename), ex.Message, Gtk.MessageType.Error);
                    md.ShowDialog();
                }
            }
            fc.Destroy();
            FillStore(true);
        }
Exemplo n.º 13
0
        public static void LoadNewDictionaryDialog(object sender, EventArgs e)
        {
            var fch = new Gtk.FileChooserDialog("Vyberte slovník", null, FileChooserAction.Open,
                                                Stock.Open, ResponseType.Ok,
                                                Stock.Cancel, ResponseType.Cancel);
            FileFilter ff = new FileFilter();

            ff.AddPattern("*.txt");
            ff.Name = "Slovník";
            fch.AddFilter(ff);

            try {
                ResponseType choice = (ResponseType)fch.Run();
                if (choice == ResponseType.Ok)
                {
                    System.IO.StreamReader sr = new System.IO.StreamReader(fch.Filename);
                    game.dictionary = new Scrabble.Lexicon.GADDAG(sr);
                    MessageDialog info = new MessageDialog(null, DialogFlags.Modal, MessageType.Info,
                                                           ButtonsType.Close, false, null);
                    info.Text = "Slovník úspěšně načten. Obsahuje:\n" +
                                game.dictionary.WordCount + "\t\t slov\n" +
                                game.dictionary.NodeCount + "\t\t vrcholů";
                    info.Run();
                    info.Hide();
                    info.Destroy();
                }
            }
            catch {  }
            finally { fch.Destroy(); }
        }
Exemplo n.º 14
0
        //Will load in multiple files, or a folder of files which will be matched against
        //loaded templates
        public static List<Tuple<string, List<PointD>>> loadBatchPoints()
        {
            List<Tuple<string,List<PointD>>> result = new List<Tuple<string,List<PointD>>> ();

            //Setup of dialog and limiting it to only XML files
            FileChooserDialog fileChooser = new FileChooserDialog ("Open Files", null, FileChooserAction.Open);
            fileChooser.AddButton (Stock.Cancel, ResponseType.Cancel);
            fileChooser.AddButton (Stock.Open, ResponseType.Ok);

            fileChooser.Filter = new FileFilter ();
            fileChooser.Filter.AddPattern ("*.xml");

            string tmp = System.IO.Directory.GetCurrentDirectory();
            string newTmp = tmp + "/../../Gestures/RecordedDataPoints/";
            fileChooser.SetCurrentFolder (newTmp);

            fileChooser.SelectMultiple = true;

            ResponseType retVal = (ResponseType)fileChooser.Run ();

            if (retVal == ResponseType.Ok) {
                foreach (string file in fileChooser.Filenames) {
                    result.Add (XMLParser.BatchLoadPoints (file));
                }
            }

            fileChooser.Destroy ();
            return result;
        }
Exemplo n.º 15
0
        protected void OnButtonAddIncludeClicked(object sender, System.EventArgs e)
        {
            Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog(
                "Select D Source Folder",
                Ide.IdeApp.Workbench.RootWindow,
                Gtk.FileChooserAction.SelectFolder,
                "Cancel",
                Gtk.ResponseType.Cancel,
                "Ok",
                Gtk.ResponseType.Ok)
            {
                TransientFor   = Toplevel as Gtk.Window,
                WindowPosition = Gtk.WindowPosition.Center
            };

            if (lastDir != null)
            {
                dialog.SetCurrentFolder(lastDir);
            }
            else if (Directory.Exists(txtBinPath.Text))
            {
                dialog.SetCurrentFolder(txtBinPath.Text);
            }

            try {
                if (dialog.Run() == (int)Gtk.ResponseType.Ok)
                {
                    lastDir = dialog.Filename;
                    text_Includes.Buffer.Text += (text_Includes.Buffer.CharCount == 0 ? "" : "\n") + dialog.Filename;
                }
            } finally {
                dialog.Destroy();
            }
        }
Exemplo n.º 16
0
        internal static string OpenExperimentDialog(Window parentWindow)
        {
            var fileChooserDialog = new Gtk.FileChooserDialog(Mono.Unix.Catalog.GetString("Open Experiment File"),
                                                              parentWindow,
                                                              FileChooserAction.Open,
                                                              Gtk.Stock.Cancel,
                                                              Gtk.ResponseType.Cancel,
                                                              Gtk.Stock.Open, Gtk.ResponseType.Ok);

            fileChooserDialog.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
            fileChooserDialog.SelectMultiple         = false;

            AddFilters(fileChooserDialog);

            int response = fileChooserDialog.Run();

            string filename = null;

            if (response == (int)Gtk.ResponseType.Ok)
            {
                filename = fileChooserDialog.Filename;
            }

            fileChooserDialog.Destroy();

            return(filename);
        }
        void OpenFile(string title, string filterName, string filter)
        {
            var fc = new Gtk.FileChooserDialog(title,
                                               this, Gtk.FileChooserAction.Open, "Cancel", Gtk.ResponseType.Cancel,
                                               "Open", Gtk.ResponseType.Accept);

            var f = new Gtk.FileFilter();

            f.Name = filterName;
            f.AddPattern(filter);

            fc.AddFilter(f);

            if (fc.Run() == (int)Gtk.ResponseType.Accept)
            {
                if (filterName == ".keystore")
                {
                    entryCustomKeystore.Text = fc.Filename;
                }
                else if (filterName == "keytool")
                {
                    entryKeytool.Text = fc.Filename;
                }
            }
            fc.Destroy();
        }
Exemplo n.º 18
0
        public void OpenImage(object openMenuItem, EventArgs args)
        {
            Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog("Open File",
                                          this,
                                          FileChooserAction.Open,
                                          "Cancel", ResponseType.Cancel,
                                          "Open", ResponseType.Accept);

            if (fc.Run() == (int)ResponseType.Accept)
            {
                if (!_model.LoadBaseImage(fc.Filename))
                {
                    MessageDialog md =
                        new MessageDialog(this,
                                          DialogFlags.DestroyWithParent,
                                          MessageType.Error,
                                          ButtonsType.Close, "Error loading file!");

                    int result = md.Run();
                    md.Destroy();
                }
            }

            fc.Destroy();
        }
Exemplo n.º 19
0
    protected void OnSendFileActionActivated(object sender, EventArgs e)
    {
        Gtk.FileChooserDialog aFileChooser = new Gtk.FileChooserDialog("Choose the file to open",
                                                                       this,
                                                                       FileChooserAction.Open,
                                                                       "Cancel", ResponseType.Cancel,
                                                                       "Open", ResponseType.Accept);

        if (aFileChooser.Run() == (int)ResponseType.Accept)
        {
            try
            {
                const int bufferLength = 1024;
                byte[]    buffer       = new byte[bufferLength];
                int       bytesRead    = 0;

                using (FileStream source = new FileStream(aFileChooser.Filename, FileMode.Open, FileAccess.Read))
                {
                    while ((bytesRead = source.Read(buffer, 0, bufferLength)) > 0)
                    {
                        _serialPort.Write(buffer, 0, bytesRead);
                    }
                }

                OutputMessage("File sent: " + aFileChooser.Filename);
            }
            catch (Exception)
            {
                OutputMessage("Error: Unable to write data to serial port.");
            }
        }

        aFileChooser.Destroy();
    }
Exemplo n.º 20
0
        public void SaveImage(object saveMenuItem, EventArgs args)
        {
            Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog("Save File As",
                                          null,
                                          Gtk.FileChooserAction.Save,
                                          "Cancel", ResponseType.Cancel,
                                          "Save", ResponseType.Accept);

            if (fc.Run() == (int)Gtk.ResponseType.Accept)
            {
                if (!_model.SaveCompositeImage(fc.Filename))
                {
                    MessageDialog md =
                        new MessageDialog(this,
                                          DialogFlags.DestroyWithParent,
                                          MessageType.Error,
                                          ButtonsType.Close, "Error saving file!");

                    int result = md.Run();
                    md.Destroy();
                }
            }

            fc.Destroy();
        }
Exemplo n.º 21
0
 protected void onLoadBtnClicked(object obj, EventArgs args)
 {
     Gtk.FileChooserDialog filechooser =
         new Gtk.FileChooserDialog("Виберіть файл з кодом на мові C#",
                                   this,
                                   FileChooserAction.Open,
                                   "Відміна", ResponseType.Cancel,
                                   "Відкрити", ResponseType.Accept);
     filechooser.Filter = new FileFilter();
     filechooser.Filter.AddPattern("*.cs");
     if (filechooser.Run() == (int)ResponseType.Accept)
     {
         try
         {
             System.IO.StreamReader file = new System.IO.StreamReader(filechooser.Filename);
             string fileCode             = file.ReadToEnd();
             this.sourceCodeField.Buffer.Text = fileCode;
         }
         catch (Exception e)
         {
             Console.WriteLine(e.ToString());
         }
     }
     filechooser.Destroy();
 }
Exemplo n.º 22
0
    //Add audiotrack dialog and corresponding procedure
    public bool AddAudioDialog()
    {
        //Checking the capacity overflow
        if (lat.Count >= Dynamic_Widgets_Audio.Count - 2)
        {
            Alert.Show(this, "The audiotrack limit has been reached");
            return(false);
        }
        //Prepare dialog and extension filters
        var temporarydialog = new Gtk.FileChooserDialog("", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

        temporarydialog.SetCurrentFolder(@".");
        var filefilter_all = new FileFilter();

        filefilter_all.Name = "All Files (*.*)";
        filefilter_all.AddPattern("*.*");
        var filefilter_wave = new FileFilter();

        filefilter_wave.Name = "Standard Audio Files (*.mp3;*.wav)";
        filefilter_wave.AddPattern("*.mp3");
        filefilter_wave.AddPattern("*.wav");
        temporarydialog.AddFilter(filefilter_wave);
        temporarydialog.AddFilter(filefilter_all);
        //Check if file has been selected
        bool result = temporarydialog.Run() == (int)ResponseType.Accept;

        if (result)
        {
            //Add selected file and refresh corresponding panel
            lat.Add(new AudioTracks(temporarydialog.Filename));
            Refresh_Audio_Widgets(lat.Count);
        }
        temporarydialog.Destroy();
        return(result);
    }
Exemplo n.º 23
0
        protected void SelectElementTableClicked(object sender, EventArgs e)
        {
            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Open xstage file.", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
            fc.SetCurrentFolder(settings.GetSettingsFileLocationUri().AbsolutePath);
            FileFilter ff = new FileFilter();

            ff.AddPattern("*.xstage");
            fc.Filter = ff;

            if (fc.Run() == (int)ResponseType.Accept)
            {
                XStageProject        xsp          = XStageProject.Load(fc.Filename);
                List <XStageElement> elementTable = xsp.elements;

                elementTableUrl = fc.Filename;

                nodestore.Clear();
                foreach (XStageElement element in elementTable)
                {
                    Uri elementTableUri       = new Uri(elementTableUrl);
                    Uri elementTableDirectory = new Uri(elementTableUri, ".");

                    foreach (XStageDrawing d in element.drawings)
                    {
                        VectorFilePath vfp = new VectorFilePath();
                        vfp.Path = elementTableDirectory.OriginalString + element.rootFolder + "/" + element.elementFolder + "/" + element.elementName + "-" + d.name + ".tvg";
                        vfp.Name = element.elementName + "-" + d.name;
                        nodestore.AddNode(vfp);
                    }
                }

                Console.WriteLine(xsp.GetXmlString());
            }
            fc.Destroy();
        }
Exemplo n.º 24
0
    /// <summary>
    /// Loads a plugin using the Add command from the Plugins menu.
    /// </summary>
    /// <param name='sender'>
    /// Sender.
    /// </param>
    /// <param name='e'>
    /// Event args.
    /// </param>
    protected void OnAddActionActivated(object sender, EventArgs e)
    {
        var fc = new Gtk.FileChooserDialog("Choose the file to open", null,
                                           Gtk.FileChooserAction.Open, "Cancel",
                                           Gtk.ResponseType.Cancel, "Open", Gtk.ResponseType.Accept);

        try {
            fc.SelectMultiple = true;
            fc.SetCurrentFolder(Environment.CurrentDirectory);
            if (fc.Run() == (int)Gtk.ResponseType.Accept)
            {
                PluginServiceContainer pluginsToAdd = new PluginServiceContainer();
                for (int i = 0; i < fc.Filenames.Length; i++)
                {
                    if (!plugins.Plugins.Exists(x => x.codeBase == fc.Filenames[i]))
                    {
                        plugins.AddPlugin(fc.Filenames[i]);
                        pluginsToAdd.AddPlugin(fc.Filenames[i]);
                    }
                }

                pluginsToAdd.LoadPlugins();
                foreach (IPlugin p in pluginsToAdd.GetServices <IPlugin>())
                {
                    p.Init(this);
                }
            }
        } finally {
            fc.Destroy();
        }
    }
Exemplo n.º 25
0
    protected void OnButtonClicked(object sender, EventArgs e)
    {
        if (sender == button1)
        {

            Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog ("Choose item...", this, FileChooserAction.Open, "Cancel",  ResponseType.Cancel, "Insert Spacer",  ResponseType.None, "Add", ResponseType.Accept);

            Gtk.Alignment align = new Alignment (1, 0, 0, 1);
            Gtk.Frame frame = new Frame ("Position");
            Gtk.HBox hbox = new HBox (false, 4);

            RadioButton rbRight;
            rbRight = new RadioButton ("Right");
            hbox.PackEnd(rbRight, false, false, 1);
            hbox.PackEnd(new RadioButton (rbRight, "Left"), false, false, 1);

            frame.Add (hbox);
            align.Add (frame);
            align.ShowAll ();
            dialog.ExtraWidget = align;

            ResponseType response = (ResponseType)dialog.Run ();
            if (response == ResponseType.Accept) {
                RunCommand ("defaults write com.apple.dock " + GetAlign(dialog.ExtraWidget) + " -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>" + dialog.Filename + "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' && /bin/sleep 1 &&/usr/bin/killall Dock");
            } else if (response == ResponseType.None) {
                RunCommand ("defaults write com.apple.dock " + GetAlign(dialog.ExtraWidget) + " -array-add '{tile-data={}; tile-type=\"spacer-tile\";}' && /bin/sleep 1 &&/usr/bin/killall Dock");
            }
            dialog.Destroy ();

        }
    }
Exemplo n.º 26
0
        static string GetPath()
        {
            string path = Properties.Settings.Default.DaggerfallPath;
            int    check;

            while ((check = CheckPath(ref path)) != 1)
            {
                if (check < 0)
                {
                    return(null);
                }
                var chooser = new Gtk.FileChooserDialog("Select the path Daggerfall is in.", null, FileChooserAction.SelectFolder,
                                                        "Select", ResponseType.Accept, "Cancel", ResponseType.Cancel);

                chooser.Show();
                if (chooser.Run() == (int)ResponseType.Accept)
                {
                    path = chooser.Filename;
                }
                else
                {
                    return(null);
                }
                chooser.Destroy();
            }

            Properties.Settings.Default.DaggerfallPath = path;
            Properties.Settings.Default.Save();
            return(path);
        }
Exemplo n.º 27
0
        private string SelectFileDialog(Window parentWindow)
        {
            var fileChooserDialog = new Gtk.FileChooserDialog(Mono.Unix.Catalog.GetString("Select file..."),
                                                              parentWindow,
                                                              FileChooserAction.SelectFolder,
                                                              Gtk.Stock.Cancel,
                                                              Gtk.ResponseType.Cancel,
                                                              Gtk.Stock.Open, Gtk.ResponseType.Ok);

            fileChooserDialog.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
            fileChooserDialog.SelectMultiple         = false;

            int response = fileChooserDialog.Run();

            string directory = null;

            if (response == (int)Gtk.ResponseType.Ok)
            {
                directory = fileChooserDialog.Filename;
            }

            fileChooserDialog.Destroy();

            return(directory);
        }
Exemplo n.º 28
0
        public static string ShowBrowseFolderDialog(string title, ref string defaultPath)
        {
            Gtk.FileChooserDialog filechooser =
                new Gtk.FileChooserDialog("Choose the file to save",
                                          null,
                                          FileChooserAction.Save,
                                          "Cancel", ResponseType.Cancel,
                                          "Save", ResponseType.Accept);

            filechooser.Modal           = true;
            filechooser.Action          = FileChooserAction.SelectFolder;
            filechooser.SkipTaskbarHint = true;
            filechooser.TransientFor    = FamiStudioForm.Instance;
            filechooser.SetCurrentFolder(defaultPath);

            string filename = null;

            if (filechooser.Run() == (int)ResponseType.Accept)
            {
                filename    = filechooser.Filename;
                defaultPath = Path.GetDirectoryName(filename);
            }

            filechooser.Destroy();

            return(filename);
        }
Exemplo n.º 29
0
        protected void OnButtonSaveClicked(object sender, EventArgs e)
        {
            var settings = new XmlWriterSettings {
                OmitXmlDeclaration = true,
                Indent             = true,
                Encoding           = System.Text.Encoding.UTF8,
                NewLineChars       = "\r\n"
            };
            var fileChooser = new Gtk.FileChooserDialog("Выберите файл для сохранения выгрузки",
                                                        (Window)this.Toplevel,
                                                        Gtk.FileChooserAction.Save,
                                                        "Отмена", ResponseType.Cancel,
                                                        "Сохранить", ResponseType.Accept
                                                        );
            var dateText = exportData.EndPeriodDate.ToShortDateString().Replace(System.IO.Path.DirectorySeparatorChar, '-');

            fileChooser.CurrentName = $"Выгрузка 1с на {dateText}.xml";
            var filter = new FileFilter();

            filter.AddPattern("*.xml");
            fileChooser.Filter = filter;
            if (fileChooser.Run() == (int)ResponseType.Accept)
            {
                var filename = fileChooser.Filename.EndsWith(".xml") ? fileChooser.Filename : fileChooser.Filename + ".xml";
                using (XmlWriter writer = XmlWriter.Create(filename, settings)) {
                    exportData.ToXml().WriteTo(writer);
                }
            }

            fileChooser.Destroy();
        }
Exemplo n.º 30
0
        /// <summary>
        /// On click "..." button - select file
        /// </summary>
        protected virtual void OnBtnSelectFileClicked(object sender, System.EventArgs e)
        {
            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(
                AddinManager.CurrentLocalizer.GetString("Choose the file to open"), new Dialog(),
                Gtk.FileChooserAction.Open,
                AddinManager.CurrentLocalizer.GetString("Cancel"), ResponseType.Cancel,
                AddinManager.CurrentLocalizer.GetString("Open"), ResponseType.Accept);

            if (!string.IsNullOrEmpty(this.eCommand.Text))
            {
                fc.SetFilename(this.eCommand.Text);
            }

            if (fc.Run() == (int)ResponseType.Accept)
            {
                // check
                UnixFileInfo info = new UnixFileInfo(fc.Filename);
                if ((info.FileAccessPermissions & FileAccessPermissions.UserExecute)
                    != FileAccessPermissions.UserExecute)
                {
                    MessageDialog md = new MessageDialog(new Dialog(),
                                                         DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close,
                                                         AddinManager.CurrentLocalizer.GetString("Selected invalid file!\nShould be executable."));
                    md.Run();
                    md.Destroy();
                }
                else
                {
                    this.eCommand.Text = fc.Filename;
                }
            }

            fc.Destroy();
        }
Exemplo n.º 31
0
        internal static string OpenExperimentDialog(Window parentWindow) 
        {
            var fileChooserDialog = new Gtk.FileChooserDialog(Mono.Unix.Catalog.GetString ("Open Experiment File"), 
                                                               parentWindow,
                                                               FileChooserAction.Open, 
                                                               Gtk.Stock.Cancel, 
                                                               Gtk.ResponseType.Cancel,
                                                               Gtk.Stock.Open, Gtk.ResponseType.Ok);

            fileChooserDialog.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
            fileChooserDialog.SelectMultiple = false;

            // HERZUM SPRINT 4 TLAB-214
            fileChooserDialog.SetCurrentFolder(TraceLab.Core.Settings.Settings.GetSettings().DefaultExperimentsDirectory);
            // END SPRINT HERZUM 4 HERZUM 4: TLAB-214

            AddFilters(fileChooserDialog);

            int response = fileChooserDialog.Run();

            string filename = null;
            if(response == (int)Gtk.ResponseType.Ok) 
            {
                filename = fileChooserDialog.Filename;
            }
            
            fileChooserDialog.Destroy();

            return filename;
        }
Exemplo n.º 32
0
        public static byte[] GetTemplateFromDisk()
        {
            //Читаем файл документа
            FileChooserDialog Chooser = new FileChooserDialog ("Выберите шаблон документа...",
                null,
                FileChooserAction.Open,
                "Отмена", ResponseType.Cancel,
                "Выбрать", ResponseType.Accept);
            FileFilter Filter = new FileFilter ();
            Filter.Name = "ODT документы и OTT шаблоны";
            Filter.AddMimeType ("application/vnd.oasis.opendocument.text");
            Filter.AddMimeType ("application/vnd.oasis.opendocument.text-template");
            Filter.AddPattern ("*.odt");
            Filter.AddPattern ("*.ott");
            Chooser.AddFilter (Filter);

            Filter = new FileFilter ();
            Filter.Name = "Все файлы";
            Filter.AddPattern ("*.*");
            Chooser.AddFilter (Filter);

            byte[] file = null;

            if ((ResponseType)Chooser.Run () == ResponseType.Accept) {
                Chooser.Hide ();
                logger.Info ("Чтение файла...");

                file = File.ReadAllBytes(Chooser.Filename);

                logger.Info ("Ok");
            }
            Chooser.Destroy ();

            return file;
        }
Exemplo n.º 33
0
        private static string getOutputDirDialog(Window parent)
        {
            string dir_save = null;

            do
            {
                if (dir_save != null)
                {
                    Alert("Please select a directory");
                }

                Gtk.FileChooserDialog filechooser =
                    new Gtk.FileChooserDialog("Choose a folder to save the map",
                                              parent,
                                              FileChooserAction.CreateFolder,
                                              "Cancel", ResponseType.Cancel,
                                              "Chose", ResponseType.Accept);

                if (filechooser.Run() == (int)ResponseType.Accept)
                {
                    dir_save = filechooser.Filename;
                }
                else
                {
                    return("");
                }

                filechooser.Destroy();
            } while (!Directory.Exists(dir_save));

            return(dir_save);
        }
Exemplo n.º 34
0
        protected void onBNLoadDB(object sender, EventArgs e)
        {
            // select a database and load it

            Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog("Choose the file to open",
                                          parentGtkWindow,
                                          FileChooserAction.Open,
                                          "Cancel", ResponseType.Cancel,
                                          "Open", ResponseType.Accept);

            if (fc.Run() == (int)ResponseType.Accept)
            {
                if (CGError.OK == CardGeneratorDB.Instance.loadDBAtPath(fc.Filename))
                {
                    labelFile.Text = "File Selected: " + fc.Filename;
                }
                else
                {
                    labelFile.Text = "File Selected: none";
                    MessageDialog md = new MessageDialog(parentGtkWindow,
                                                         Gtk.DialogFlags.Modal,
                                                         MessageType.Info,
                                                         ButtonsType.Ok,
                                                         "Error in DB File load");
                    md.Run();
                    md.Destroy();
                }
                //System.IO.FileStream file=System.IO.File.OpenRead(fc.Filename);
                //file.Close();
            }
            //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
            fc.Destroy();
        }
Exemplo n.º 35
0
        protected override void OnActivated()
        {
            base.OnActivated();

            Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("chose_workspace_open"), MainClass.MainWindow, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);

            FileFilter filter = new FileFilter();
            filter.Name = "Workspace files";
            filter.AddMimeType("Workspace file");
            filter.AddPattern("*.msw");
            fc.AddFilter(filter);

            if (!String.IsNullOrEmpty(MainClass.Settings.LastOpenedWorkspaceDir))
                fc.SetCurrentFolder(MainClass.Settings.LastOpenedWorkspaceDir);

            if (fc.Run() == (int)ResponseType.Accept) {

                MainClass.Settings.LastOpenedWorkspaceDir = System.IO.Path.GetDirectoryName(fc.Filename);

                //CloseActualWorkspace();
                Workspace.Workspace workspace = Workspace.Workspace.OpenWorkspace(fc.Filename);

                if (workspace != null){
                    //MainClass.Settings.RecentFiles.AddWorkspace(fc.Filename,fc.Filename);
                    MainClass.MainWindow.ReloadWorkspace(workspace,true,true);
                }

            }

            fc.Destroy();
        }
Exemplo n.º 36
0
        public override bool Execute()
        {
            Image image = null;
              if (File.Exists(_path))
            {
              image = Image.Load(RunMode.Noninteractive, _path, _path);
            }
              else
            {
              var choose = new FileChooserDialog("Open...",
                         null,
                         FileChooserAction.Open,
                         "Cancel", ResponseType.Cancel,
                         "Open", ResponseType.Accept);
              if (choose.Run() == (int) ResponseType.Accept)
            {
              string fileName = choose.Filename;
              image = Image.Load(RunMode.Noninteractive, fileName, fileName);
            };
              choose.Destroy();
            }

              if (image != null)
            {
              image.CleanAll();
              ActiveDisplay = new Display(image);
              ActiveImage = image;
              return true;
            }

              return false;
        }
Exemplo n.º 37
0
        protected virtual void OnInstallThemeClicked(object sender, System.EventArgs e)
        {
            GLib.File             file           = null;
            Gtk.FileChooserDialog script_chooser = new Gtk.FileChooserDialog("Themes", this, FileChooserAction.Open, Gtk.Stock.Cancel, ResponseType.Cancel, Catalog.GetString("_Select"), ResponseType.Ok);
            FileFilter            filter         = new FileFilter();

            filter.AddPattern("*.tar");
            filter.Name = Catalog.GetString(".tar Archives");
            script_chooser.AddFilter(filter);

            if ((ResponseType)script_chooser.Run() == ResponseType.Ok)
            {
                file = GLib.FileFactory.NewForPath(script_chooser.Filename);
            }

            script_chooser.Destroy();

            if (file == null)
            {
                return;
            }

            string theme = DockServices.Theme.InstallTheme(file);

            if (theme != null)
            {
                theme_combo.AppendText(theme);
            }
        }
Exemplo n.º 38
0
        protected void OnMAddButtonClicked(object sender, EventArgs e)
        {
            // TODO - fix strings
            var dialog = new Gtk.FileChooserDialog(
                "Select private key files",
                null,
                FileChooserAction.Open,
                "Cancel", ResponseType.Cancel,
                "Open", ResponseType.Accept);

            dialog.SelectMultiple = true;
            var response = (ResponseType)dialog.Run();

            if (response == ResponseType.Accept)
            {
                foreach (var file in dialog.Filenames)
                {
                    try {
                        mAgent.AddKeyFromFile(file, null, null);
                    } catch (Exception ex) {
                        Debug.Fail(ex.ToString());
                    }
                }
            }
            dialog.Destroy();
            if (!(mAgent is Agent))
            {
                ReloadKeyListView();
            }
        }
Exemplo n.º 39
0
        private string SelectFileDialog(Window parentWindow)
        {
            var fileChooserDialog = new Gtk.FileChooserDialog(Mono.Unix.Catalog.GetString("Select file..."),
                                                              parentWindow,
                                                              FileChooserAction.Open,
                                                              Gtk.Stock.Cancel,
                                                              Gtk.ResponseType.Cancel,
                                                              Gtk.Stock.Open, Gtk.ResponseType.Ok);

            fileChooserDialog.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
            fileChooserDialog.SelectMultiple         = false;

            //add filter for all files
            FileFilter allFilesFilter = new FileFilter();

            allFilesFilter.Name = Mono.Unix.Catalog.GetString("All files");
            allFilesFilter.AddPattern("*.*");
            fileChooserDialog.AddFilter(allFilesFilter);

            int response = fileChooserDialog.Run();

            string filename = null;

            if (response == (int)Gtk.ResponseType.Ok)
            {
                filename = fileChooserDialog.Filename;
            }

            fileChooserDialog.Destroy();

            return(filename);
        }
Exemplo n.º 40
0
 protected void onAddClicked(object sender, System.EventArgs e)
 {
     String[] items = {};
     FileChooserDialog dialog =
         new FileChooserDialog("Open",
              null,
             FileChooserAction.Open,
             "Cancel",ResponseType.Cancel,
             "Open",ResponseType.Accept);
     dialog.SelectMultiple=true;
     FileFilter filter = new FileFilter();
     /*filter.AddPattern("*.jpg");
     filter.AddPattern("*.jpeg");
     filter.AddPattern("*.png");
     filter.AddPattern("*.svg");*/
     filter.AddMimeType("image/*");
     dialog.Filter = filter;
     if(dialog.Run()==(int)ResponseType.Accept)
     {
         items = dialog.Filenames;
     }
     dialog.Destroy();
     localfiles.LocalFiles.addItems(items);
     fillList();
 }
Exemplo n.º 41
0
        protected void onBNNewDB(object sender, EventArgs e)
        {
            // create a new database and load it
            Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog("Choose the file to open",
                                          parentGtkWindow,
                                          FileChooserAction.Save,
                                          "Cancel", ResponseType.Cancel,
                                          "Save", ResponseType.Accept);

            if (fc.Run() == (int)ResponseType.Accept)
            {
                if (CGError.OK == CardGeneratorDB.Instance.createDBAtPath(fc.Filename))
                {
                    labelFile.Text = "File Selected: " + fc.Filename;
                }
                else
                {
                    labelFile.Text = "File Selected: none";
                    MessageDialog md = new MessageDialog(parentGtkWindow,
                                                         Gtk.DialogFlags.Modal,
                                                         MessageType.Info,
                                                         ButtonsType.Ok,
                                                         "Error in DB File creation");
                    md.Run();
                    md.Destroy();
                }
            }
            fc.Destroy();
        }
		void buttonBrowsePickTake_Clicked(object sender, EventArgs e)
		{
			FileChooserDialog fc =
			new FileChooserDialog
				(
				  "Choose the file to open"
				, this
				, FileChooserAction.Open
				, "Cancel", ResponseType.Cancel
				, "Open", ResponseType.Accept
				);

			if (fc.Run() == (int)ResponseType.Accept)
			{
				int l = fc.Filename.LastIndexOf('\\') + 1;
				textBoxImageNamePickedTaken.Text = fc.Filename.Substring(l);
				
				System.IO.FileStream file = System.IO.File.OpenRead(fc.Filename);
				file.Close();
			}
			//Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
			fc.Destroy();

			return;
		}
Exemplo n.º 43
0
		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);
				}
			}
		}
Exemplo n.º 44
0
    public string AskForQuizFilePath()
    {
        string output;

        Gtk.FileChooserDialog fc =
            new Gtk.FileChooserDialog("Choose the quiz to open",
                this,
                FileChooserAction.Open,
                "Cancel",ResponseType.Cancel,
                "Open",ResponseType.Accept);

        if (fc.Run() == (int)ResponseType.Accept)
        {
            output = fc.Filename;
        }
        else
        {
            throw new ApplicationException("Could for some reason not read the wanted file: " + fc.Filename);
        }

        //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
        fc.Destroy();

        return output;
    }
Exemplo n.º 45
0
    protected void OnOpenActionActivated(object sender, EventArgs e)
    {
        Gtk.FileChooserDialog fc = new FileChooserDialog (
                                       "Choose image to open",
                                       this,
                                       Gtk.FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
        fc.Filter = new FileFilter();
        fc.Filter.AddPattern ("*.png");
        fc.Filter.AddPattern ("*.jpg");
        fc.Filter.AddPattern("*.jpeg");
        fc.Filter.AddPattern ("*.gif");
        fc.Filter.AddPattern("*.tiff");

        if (fc.Run() == (int)ResponseType.Accept)
        {
            System.Drawing.Image host = System.Drawing.Image.FromFile (fc.Filename);
            Bitmap hostImage = new Bitmap (host);
            MemoryStream pic = new MemoryStream ();
            hostImage.Save (pic, System.Drawing.Imaging.ImageFormat.Png);

            pic.Seek (0, SeekOrigin.Begin);
            Gdk.Pixbuf pb = new Gdk.Pixbuf (pic);
            originalImage.Pixbuf = pb;
        }
        //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
        fc.Destroy();
    }
Exemplo n.º 46
0
    // Use this for initializatio
    public string openFile()
    {
        FileChooserDialog Fc = new FileChooserDialog("Choose new Crosshair",this,FileChooserAction.Open,"Cancel",ResponseType.Cancel,"Open",ResponseType.Accept);

        //if(Fc.Run() == (int)ResponseType.Accept)        //Unity stirbt hier
        //{
        //	FileChooser chooser = new FileChooser(Fc);
        //	path = chooser.Filename;
        //
            path = Fc.Filename;
            Fc.Destroy ();
            //return path;                //Inhalt von CrosshairGUI ist leer
        //}

        Fc.Destroy ();
        return "";
    }
Exemplo n.º 47
0
        protected void OnBtnSaveClicked(object sender, System.EventArgs e)
        {
            Gtk.FileChooserDialog fd = new Gtk.FileChooserDialog("Save", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save",ResponseType.Ok);

            if (fd.Run() == (int)ResponseType.Ok)
            {
                sg.SavePNG(fd.Filename);
            }
            fd.Destroy();
        }
Exemplo n.º 48
0
        public FolderListGui(string Title, string Description, string[] Folders)
        {
            this.Build ();

            this.Folders = Folders;
            this.label12.Text = Description;
            this.Title = Title;

            NodeStore store = new NodeStore(typeof(StringNode));
            foreach(string folder in Folders)
                store.AddNode(new StringNode(){ Value = folder});
            nodeview1.NodeStore = store;
            nodeview1.AppendColumn("Folder", new Gtk.CellRendererText (), "text", 0);

            buttonOk.Clicked += delegate {
                // get the folders
                List<string> nodes = new List<string>();
                var enumerator = store.GetEnumerator();
                while(enumerator.MoveNext())
                {
                    string folder = ((StringNode)enumerator.Current).Value;
                    if(folder.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
                        folder = folder.Substring(0, folder.Length - 1);
                    nodes.Add(folder);
                }
                this.Folders = nodes.ToArray();
                this.DialogResult = ResponseType.Ok;
                this.Destroy();
            };
            buttonCancel.Clicked += delegate{
                this.DialogResult = ResponseType.Cancel;
                this.Destroy();
            };

            btnAdd.Clicked += delegate {
                using(Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Choose the Folder to scan.",
                          	                    						    this,
                                                                            FileChooserAction.SelectFolder,
                                                                            "Cancel", ResponseType.Cancel,
                                                     				 	    "Open", ResponseType.Accept)){
                    fc.LocalOnly = false;
                    if (fc.Run() == (int)ResponseType.Accept)
                    {
                        store.AddNode(new StringNode(){ Value = fc.Filename});
                    }
                    //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
                    fc.Destroy();
                }
            };

            btnRemove.Clicked += delegate {
                foreach(var node in nodeview1.NodeSelection.SelectedNodes)
                    store.RemoveNode(node);
            };
        }
Exemplo n.º 49
0
 protected void OnBtnExeBrowseClicked(object o, EventArgs args)
 {
     FileChooserDialog fileChooser = new FileChooserDialog("Locate SuperTux Executable", settingsDialog, FileChooserAction.Open, new object[] {});
     fileChooser.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
     fileChooser.AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok);
     fileChooser.DefaultResponse = Gtk.ResponseType.Ok;
     if (fileChooser.Run() == (int)ResponseType.Ok) {
         entryExe.Text = fileChooser.Filename;
     }
     fileChooser.Destroy();
 }
Exemplo n.º 50
0
        public void WriteToFile(String text)
        {
            Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog ("Save Image File", null, FileChooserAction.Save, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Save, Gtk.ResponseType.Ok);

            int response = fcd.Run ();

            if (response == (int)Gtk.ResponseType.Ok)
                SaveFile (fcd.Filename, text);

            fcd.Destroy ();
        }
Exemplo n.º 51
0
 protected void OnBtnDataDirBrowseClicked(object o, EventArgs args)
 {
     FileChooserDialog fileChooser = new FileChooserDialog("Locate SuperTux Data Directory", settingsDialog, FileChooserAction.SelectFolder, new object[] {});
     fileChooser.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
     fileChooser.AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok);
     fileChooser.DefaultResponse = Gtk.ResponseType.Ok;
     if (fileChooser.Run() == (int)ResponseType.Ok) {
         entryDataDir.Text = fileChooser.Filename;
     }
     fileChooser.Destroy();
 }
Exemplo n.º 52
0
 protected void OnButton1Clicked(object sender, EventArgs e)
 {
     FileChooserDialog Dlg;
     Dlg = new FileChooserDialog ("Directorio Inicial", null, FileChooserAction.SelectFolder, Stock.Open, ResponseType.Ok, Stock.Cancel, ResponseType.Cancel);
     Dlg.ShowAll ();
     if (Dlg.Run () == (int)ResponseType.Ok) {
         E1.Text = Dlg.Filename;
     }
     Dlg.HideAll ();
     Dlg.Destroy ();
 }
Exemplo n.º 53
0
 protected void OnButton41Clicked(object sender, EventArgs e)
 {
     FileChooserDialog fcd = new FileChooserDialog("Select LunaLua Directory", null, FileChooserAction.SelectFolder);
     fcd.AddButton(Stock.Cancel, ResponseType.Cancel);
     fcd.AddButton(Stock.Ok, ResponseType.Ok);
     int ret = fcd.Run();
     if (ret == (int)ResponseType.Ok)
     {
         lunaLuaDirEntry.Text = fcd.Filename;
     }
     fcd.Destroy();
 }
Exemplo n.º 54
0
 protected void OnOpenActionActivated(object sender, System.EventArgs e)
 {
     FileChooserDialog fileChooserDialog =
         new FileChooserDialog("Abrir archivo", null, FileChooserAction.Open,
                               Stock.Cancel, ResponseType.Cancel,
                               Stock.Open, ResponseType.Accept);
     ResponseType response = (ResponseType)fileChooserDialog.Run();
     if(response == ResponseType.Accept)
         textview1.Buffer.Text = File.ReadAllText(fileChooserDialog.Filename);
     fileChooserDialog.Destroy();
     //throw new System.NotImplementedException ();
 }
Exemplo n.º 55
0
 protected virtual void OnChooseClick(object sender, System.EventArgs e)
 {
     FileChooserDialog dlg = new FileChooserDialog (Catalog.GetString ("Choose Executable or Script"), this,
                                                    FileChooserAction.Open, Catalog.GetString ("Cancel"),
                                                    ResponseType.Cancel, Catalog.GetString ("OK"),
                                                    ResponseType.Accept);
     if (dlg.Run () == (int)ResponseType.Accept) {
         execEntry.Text = dlg.Filename;
         dlg.Hide ();
     }
     dlg.Destroy ();
 }
Exemplo n.º 56
0
 protected void OnButton187Pressed(object sender, EventArgs e)
 {
     FileChooserDialog dialog = new FileChooserDialog("Change snapshots folder",
                                    this, FileChooserAction.SelectFolder,
                                    Stock.Cancel, ResponseType.Cancel,
                                    Stock.Open, ResponseType.Accept);
     if (dialog.Run() == (int)ResponseType.Accept)
     {
         entry_snaps.Text = dialog.Filename;
     }
     dialog.Destroy();
 }
Exemplo n.º 57
0
		void open_file (object sender, EventArgs e)
		{
			Gtk.FileChooserDialog fcd = new FileChooserDialog("Oopen File",null, FileChooserAction.Open, new object[0]);
			fcd.AddButton("Cancel",ResponseType.Cancel);
			fcd.AddButton("OK",ResponseType.Ok);
			if((ResponseType)fcd.Run() == ResponseType.Ok) {
				String mimetype = meticulus.servers.common.mime_types.GetMimeType(System.IO.Path.GetExtension(fcd.Filename));
				view(fcd.Filename, mimetype);
			}
			fcd.Destroy();

		}
Exemplo n.º 58
0
		protected void OnButton46Clicked (object sender, EventArgs e)
		{
			Gtk.FileChooserDialog fcd = new FileChooserDialog("Save File",null, FileChooserAction.Save, new object[0]);
			fcd.AddButton("Cancel",ResponseType.Cancel);
			fcd.AddButton("OK",ResponseType.Ok);
			if((ResponseType)fcd.Run() == ResponseType.Ok) {
				_filename = fcd.Filename;
				this.entry3.Text = fcd.Filename;
			}

			fcd.Destroy();
		}
Exemplo n.º 59
0
 public static string ChooseFolder( string title )
 {
     FileChooserDialog fd = new FileChooserDialog(title, null, FileChooserAction.SelectFolder, Gtk.Stock.Cancel, ResponseType.Cancel, Gtk.Stock.Save, ResponseType.Accept);
     try {
         if (fd.Run() == (int)ResponseType.Accept) {
             return fd.Filename;
         }
     } finally {
         fd.Destroy();
     }
     return null;
 }
Exemplo n.º 60
0
    protected void OnOpenActionActivated(object sender, System.EventArgs e)
    {
        FileChooserDialog ventanaAbrir =
            new FileChooserDialog("Nuevo archivo",null, FileChooserAction.Open, Stock.Cancel,
               					ResponseType.Cancel, Stock.Open, ResponseType.Accept);

            ResponseType responde = (ResponseType)ventanaAbrir.Run();

        if(responde == ResponseType.Accept) {
            campoTexto.Buffer.Text = File.ReadAllText (ventanaAbrir.Filename);
        }
        ventanaAbrir.Destroy();
    }