예제 #1
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("Ок");
        }
예제 #2
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();
    }
예제 #3
0
        protected void OnSaveAsActionActivated(object sender, EventArgs e)
        {
            if (DocTemplate == null)
            {
                return;
            }
            FileChooserDialog fc =
                new FileChooserDialog("Укажите файл для сохранения шаблона...",
                                      this,
                                      FileChooserAction.Save,
                                      "Отмена", ResponseType.Cancel,
                                      "Сохранить", ResponseType.Accept);

            //FileFilter filter = new FileFilter();
            fc.CurrentName = DocTemplate.Name + ".xml";
            fc.Show();
            if (fc.Run() == (int)ResponseType.Accept)
            {
                fc.Hide();
                FileStream fs = new FileStream(fc.Filename, FileMode.Create, FileAccess.Write);
                DocTemplate.SaveToStream(fs);
                fs.Close();
            }
            fc.Destroy();
        }
예제 #4
0
        protected void OnImagePopupSave(object sender, EventArgs Arg)
        {
            FileChooserDialog fc =
                new FileChooserDialog("Укажите файл для сохранения картинки",
                                      this,
                                      FileChooserAction.Save,
                                      "Отмена", ResponseType.Cancel,
                                      "Сохранить", ResponseType.Accept);

            //FileFilter filter = new FileFilter();
            fc.CurrentName = DocInfo.Name + " " + entryNumber.Text + ".jpg";
            fc.Show();
            if (fc.Run() == (int)ResponseType.Accept)
            {
                fc.Hide();
                foreach (DocumentImage img in Images)
                {
                    if (img.id == PopupImageId)
                    {
                        FileStream fs = new FileStream(fc.Filename, FileMode.Create, FileAccess.Write);
                        fs.Write(img.file, 0, (int)img.size);
                        fs.Close();
                    }
                }
            }
            fc.Destroy();
        }
예제 #5
0
        public void Run()
        {
            _chooserDialog.Show();
            var retVal = _chooserDialog.Run();

            // If the user clicked Open, fire Activated ourselves
            // double click activation is will fire the callback itself, triggering dialog closure
            if (retVal == 0)
            {
                ChooserOnFileActivated(_chooserDialog, null);
            }
        }
예제 #6
0
    protected void OnButtonInputChooseClicked(object sender, EventArgs e)
    {
        FileChooserDialog fileChooserDialog;

        fileChooserDialog = new FileChooserDialog("Choose input file", this, FileChooserAction.Open, ("Cancel"), ResponseType.Cancel, ("Open"), ResponseType.Accept, null);
        if (File.Exists(entry_input_file_path.Text) || Directory.Exists(entry_input_file_path.Text))
        {
            fileChooserDialog.SetFilename(entry_input_file_path.Text);
        }
        fileChooserDialog.Show();
        if (fileChooserDialog.Run() == -3)
        {
            entry_input_file_path.Text = fileChooserDialog.Filename;
        }
        fileChooserDialog.Destroy();
    }
예제 #7
0
    private String QueryUserForSearchFolder()
    {
        String result = null;

        FileChooserDialog dialog = new FileChooserDialog("Select a Folder to Search", this, FileChooserAction.SelectFolder, "Select", ResponseType.Ok, "Cancel", ResponseType.Cancel);

        dialog.Show();

        if (dialog.Run() == (int)ResponseType.Ok)
        {
            result = dialog.Filename;
        }

        dialog.Destroy();

        return(result);
    }
예제 #8
0
        protected void OnButtonFileChooserClicked(object sender, EventArgs e)
        {
            FileChooserDialog fc =
                new FileChooserDialog("Укажите файл резервной копии",
                                      (Window)this.Toplevel,
                                      FileChooserAction.Save,
                                      "Отмена", ResponseType.Cancel,
                                      "Сохранить", ResponseType.Accept);

            fc.SetFilename(ViewModel.FileName);
            fc.Show();
            if (fc.Run() == (int)ResponseType.Accept)
            {
                ViewModel.FileName = fc.Filename;
            }
            fc.Destroy();
        }
예제 #9
0
        protected void OnButtonSavePhotoClicked(object sender, EventArgs e)
        {
            FileChooserDialog fc =
                new FileChooserDialog("Укажите файл для сохранения фотографии",
                                      (Gtk.Window) this.Toplevel,
                                      FileChooserAction.Save,
                                      "Отмена", ResponseType.Cancel,
                                      "Сохранить", ResponseType.Accept);

            fc.CurrentName = ViewModel.SuggestedPhotoName;
            fc.Show();
            if (fc.Run() == (int)ResponseType.Accept)
            {
                fc.Hide();
                ViewModel.SavePhoto(fc.Filename);
            }
            fc.Destroy();
        }
예제 #10
0
        public DialogResult ShowDialog(IWin32Window owner)
        {
            var oldDirectory = Directory.GetCurrentDirectory();

            try
            {
                m_dlg = CreateFileChooserDialog();

                m_dlg.Show();
                Gtk.Application.Run();
                return(DialogResult);
            }
            finally
            {
                if (RestoreDirectory)
                {
                    Directory.SetCurrentDirectory(oldDirectory);
                }
            }
        }
예제 #11
0
        protected void OnButtonSavePhotoClicked(object sender, EventArgs e)
        {
            FileChooserDialog fc =
                new FileChooserDialog("Укажите файл для сохранения фотографии",
                                      (Window)this.Toplevel,
                                      FileChooserAction.Save,
                                      "Отмена", ResponseType.Cancel,
                                      "Сохранить", ResponseType.Accept);

            fc.CurrentName = (GetSaveFileName != null ? GetSaveFileName() : "фото") + ".jpg";
            fc.Show();
            if (fc.Run() == (int)ResponseType.Accept)
            {
                fc.Hide();
                FileStream fs = new FileStream(fc.Filename, FileMode.Create, FileAccess.Write);
                fs.Write(ImageFile, 0, ImageFile.Length);
                fs.Close();
            }
            fc.Destroy();
        }
예제 #12
0
        public void ShowFileChooser(object obj, EventArgs args)
        {
            FileChooserDialog fileChooser = new FileChooserDialog("Hola", this.ventana, FileChooserAction.Open, "Cancel", ResponseType.Cancel,
                                                                  "Open", ResponseType.Accept);

            FileFilter file = new FileFilter();

            file.AddPattern("*.mp3");
            file.AddPattern("*.mp4");
            file.AddPattern("*.aac");

            fileChooser.AddFilter(file);
            fileChooser.Show();
            if (fileChooser.Run() == (int)ResponseType.Accept)
            {
                byte[] cancionBytes = System.IO.File.ReadAllBytes(fileChooser.Filename);
                Console.Write(cancionBytes[cancionBytes.Length - 1]);
            }

            fileChooser.Destroy();
        }
예제 #13
0
        protected void OnButtonPDFClicked(object sender, EventArgs e)
        {
            FileChooserDialog fc =
                new FileChooserDialog("Укажите файл для сохранения документа",
                                      this,
                                      FileChooserAction.Save,
                                      "Отмена", ResponseType.Cancel,
                                      "Сохранить", ResponseType.Accept);

            fc.CurrentName = DocInfo.Name + " " + entryNumber.Text + ".pdf";
            fc.Show();
            if (fc.Run() == (int)ResponseType.Accept)
            {
                fc.Hide();
                iTextSharp.text.Document document = new iTextSharp.text.Document();
                using (var stream = new FileStream(fc.Filename, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    iTextSharp.text.pdf.PdfWriter.GetInstance(document, stream);
                    document.Open();
                    foreach (DocumentImage img in Images)
                    {
                        if (img.Image.Width > img.Image.Height)
                        {
                            document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
                        }
                        else
                        {
                            document.SetPageSize(iTextSharp.text.PageSize.A4);
                        }
                        document.NewPage();
                        var image = iTextSharp.text.Image.GetInstance(img.file);
                        image.SetAbsolutePosition(0, 0);
                        image.ScaleToFit(document.PageSize.Width, document.PageSize.Height);
                        document.Add(image);
                    }
                    document.Close();
                }
            }
            fc.Destroy();
        }