Example #1
0
        //=====================================================================
        // Methods, etc.

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="title">The title for the file dialog</param>
        /// <param name="filter">The filter to use for the file dialog</param>
        /// <param name="dialogType">The type of file dialog to display</param>
        /// <overloads>There are two overloads for the constructor.</overloads>
        public FileDialogAttribute(string title, string filter,
                                   FileDialogType dialogType)
        {
            dlgTitle  = title;
            dlgFilter = filter;
            dlgType   = dialogType;
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="isfocuse">if its in focuse or not</param>
        public void ShowSaveDialog(bool isfocuse, string currentFile)
        {
            if (currentFile == null)
            {
                currentFile = string.Empty;
            }

            TextBox tb = FindComponateById("txtfile") as TextBox;

            tb.Text    = currentFile;
            tb.Visible = true;
            tb.Active  = true;

            if (tb.Text == string.Empty)
            {
                FindComponateById("ok").Active = false;
            }
            else
            {
                FindComponateById("ok").Active = true;
            }

            _type = FileDialogType.Save;


            Button bnt = FindComponateById("ok") as Button;

            bnt.Text = "Save";


            BuildDirectoryTree();

            base.Activate(isfocuse);
        }
        protected void setupOpenFileDialogue(FileDialogType fdt, string lastknownfile)
        {
            String filename = "";
            String fileFilter = "";
            String currentFile = "";
            const String allFilesFilter = "|All Files|*.*";
            switch (fdt)
            {
                case FileDialogType.PUTTY:
                    filename = "putty.exe";
                    currentFile = Properties.Settings.Default.PuttyLocation;
                    break;
                case FileDialogType.PAGEANT:
                    filename = "pageant.exe";
                    currentFile = Properties.Settings.Default.PageantLocation;
                    break;
                case FileDialogType.PAGEANT_KEYS:
                    filename = "*.ppk";
                    break;
                case FileDialogType.FILEZILLA:
                    filename = "FileZilla.exe";
                    currentFile = Properties.Settings.Default.FileZillaLocation;
                    break;
                case FileDialogType.WINSCP:
                    filename = "WinSCP*.exe";
                    currentFile = Properties.Settings.Default.WinSCPLocation;
                    break;
                case FileDialogType.WINSCPINI:
                    filename = "*.ini";
                    currentFile = Properties.Settings.Default.WinSCPIniLocation;
                    break;
                case FileDialogType.CSV:
                    filename = "*.csv";
                    currentFile = Properties.Settings.Default.WinSCPIniLocation;
                    break;
                case FileDialogType.PSFTP:
                    filename = "psftp.exe";
                    currentFile = Properties.Settings.Default.PSFTPLocation;
                    break;
            }

            // Override the default current file if we have supplied
            // an existing file
            if (lastknownfile != null && !lastknownfile.Equals(""))
                currentFile = lastknownfile;

            // Attempt to set the working directory
            string directory = "";
            if (currentFile != null && !currentFile.Equals(""))
                directory = Path.GetFullPath(currentFile);
            if (File.Exists(directory))
                openFileDialog.InitialDirectory = directory;

            // And the filename
            openFileDialog.FileName = filename;

            // And the file filter
            fileFilter = filename + "|" + filename + allFilesFilter;
            openFileDialog.Filter = fileFilter;
        }
Example #4
0
 public void ShowFileDialog(FileDialogType type, Action <bool?, FileDialogEventArgs> callback = null)
 {
     ShowFileDialog(new FileDialogEventArgs(type, callback)
     {
         Filter = "All Files|*.*"
     });
 }
Example #5
0
 public FileDialog CreateDialog(FileDialogType DialogType, string Title)
 {
     this.DialogType       = DialogType;
     this.Title            = Title;
     this.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
     this.filters          = new List <FileTypeFilter>();
     return(GetDialog());
 }
 public FileChooserAttribute(FileDialogType dialogType,
                             bool preserveExistingFileName = false,
                             string extension = null)
 {
     this.dialogType = dialogType;
     this.preserveExistingFileName = preserveExistingFileName;
     this.extension = extension;
 }
Example #7
0
 public FileDialog CreateDialog(FileDialogType DialogType, string Title)
 {
     this.DialogType = DialogType;
     this.Title = Title;
     this.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
     this.filters = new List<FileTypeFilter>();
     return GetDialog();
 }
Example #8
0
        public void ShowFolderDialog(FileDialogType type, Action <bool?, FileDialogEventArgs> callback)
        {
            FileDialogEventArgs e = new FileDialogEventArgs(type, callback)
            {
                InitialDirectory = Settings.TheSettings.LastDirectoryAccessed
            };

            FolderDialogRequest?.Invoke(this, e);
        }
Example #9
0
 public FileDialog(string start, string title, FileDialogType type, string[] fileTypeOptions)
 {
     this.StartDirectory  = start.Replace(@"\", @"/");
     this.IsOpen          = false;
     this.IsDone          = false;
     this.Title           = title;
     this.SelectedFiles   = new List <string>();
     this.fileTypeOptions = fileTypeOptions;
     this.DialogType      = type;
     ChangeDirectory(StartDirectory);
 }
Example #10
0
 public FileDialogEventArgs(FileDialogType dialogType,
                            string title    = null,
                            string filter   = null,
                            string fileName = null,
                            Action <bool?, FileDialogEventArgs> resultAction = null)
 {
     DialogType   = dialogType;
     Title        = title;
     Filter       = filter;
     FileName     = fileName;
     ResultAction = resultAction;
 }
Example #11
0
 protected override void GetDialogProps(ITypeDescriptorContext context, out FileDialogType dialogType, out string filter)
 {
     dialogType = FileDialogType.Open;
     filter     = String.Format("*.*|*.*");
     foreach (Attribute attr in context.PropertyDescriptor.Attributes)
     {
         if (attr is FileNameEditorPropsAttribute)
         {
             var a = (FileNameEditorPropsAttribute)attr;
             dialogType = a.DialogType;
             filter     = a.Filter;
         }
     }
 }
Example #12
0
        private static FileDialog CreateFileDialog(FileDialogType dialogType)
        {
            switch (dialogType)
            {
            case FileDialogType.Open:
                return(new OpenFileDialog());

            case FileDialogType.Save:
                return(new SaveFileDialog());

            default:
                throw new ArgumentOutOfRangeException(nameof(dialogType), dialogType,
                                                      @"Unsupported dialog type");
            }
        }
Example #13
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="type">The dialog type.</param>
 /// <param name="fileSystem">File system model to represent.</param>
 /// <param name="dialogView">The dialog UI.</param>
 protected FileDialog(FileDialogType type, FileSystemModel fileSystem, FileDialogView dialogView)
 {
     DialogType    = type;
     FileSystem    = fileSystem;
     UI            = dialogView;
     DialogPanel   = dialogView.UI;
     UI.Controller = this;
     if (DialogType == FileDialogType.OpenFileDialog)
     {
         UI.ConfirmButtonText = "Open";
     }
     else
     {
         UI.ConfirmButtonText = "Save";
     }
 }
Example #14
0
        /// <summary>
        /// Initialize the OpenRasterFileDialog.
        /// </summary>
        /// <param name="type">Type of the file dialog.</param>
        public RasterFileDialog(FileDialogType type)
        {
            dialog = new GxDialogClass();
            IGxObjectFilterCollection filterCollection = (IGxObjectFilterCollection)dialog;

            IGxObjectFilter objectFilter = new RasterFormatTifFilter();

            filterCollection.AddFilter(objectFilter, true);
            objectFilter = new RasterFormatBMPFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatENVIFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatBILFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatBIPFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatBSQFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatGIFFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatGridFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatImgFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatJP2Filter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatJPGFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatPNGFilter();
            filterCollection.AddFilter(objectFilter, false);

            this.type = type;
            switch (type)
            {
            case FileDialogType.Save:
                this.Title = "Save Raster Layer as";
                break;

            case FileDialogType.Open:
                this.Title = "Open Raster Layer";
                break;
            }
        }
Example #15
0
        /// <summary>
        /// Initialize the OpenRasterFileDialog.
        /// </summary>
        /// <param name="type">Type of the file dialog.</param>
        public RasterFileDialog(FileDialogType type)
        {
            dialog = new GxDialogClass();
            IGxObjectFilterCollection filterCollection = (IGxObjectFilterCollection)dialog;

            IGxObjectFilter objectFilter = new RasterFormatTifFilter();
            filterCollection.AddFilter(objectFilter, true);
            objectFilter = new RasterFormatBMPFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatENVIFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatBILFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatBIPFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatBSQFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatGIFFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatGridFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatImgFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatJP2Filter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatJPGFilter();
            filterCollection.AddFilter(objectFilter, false);
            objectFilter = new RasterFormatPNGFilter();
            filterCollection.AddFilter(objectFilter, false);

            this.type = type;
            switch (type)
            {
                case FileDialogType.Save:
                    this.Title = "Save Raster Layer as";
                    break;
                case FileDialogType.Open:
                    this.Title = "Open Raster Layer";
                    break;
            }
        }
Example #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="isfocuse">if its in focuse or not</param>
        public void ShowLoadDialog(bool isfocuse, string currentFile)
        {
            if (currentFile == null)
            {
                currentFile = string.Empty;
            }

            TextBox tb = (TextBox)WinFormControler.FindComponateById("txtfile");

            tb.Text    = currentFile;
            tb.Visible = true;

            _type = FileDialogType.Load;
            Button bnt = FindComponateById("ok") as Button;

            bnt.Text = "Load";

            BuildDirectoryTree();

            base.Activate(isfocuse);
        }
Example #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="isfocuse">if its in focuse or not</param>
        public void ShowFilePicker(bool isfocuse, string currentFile, Action <Componate, string> returnFunction = null)
        {
            _returnFunction = returnFunction;
            if (currentFile == null)
            {
                currentFile = string.Empty;
            }

            TextBox tb = (TextBox)WinFormControler.FindComponateById("txtfile");

            tb.Visible = false;
            tb.Active  = false;
            _type      = FileDialogType.Picker;
            Button bnt = FindComponateById("ok") as Button;

            bnt.Text = "Select";

            BuildDirectoryTree();

            base.Activate(isfocuse);
        }
Example #18
0
        private string GetSelectedFileName([NotNull] IWin32Window owner,
                                           FileDialogType dialogType)
        {
            // TODO set initial folder
            // - from current text box value
            // - if that is undefined: value of new property?

            using (FileDialog dlg = CreateFileDialog(dialogType))
            {
                dlg.AddExtension                 = true;
                dlg.DereferenceLinks             = true;
                dlg.RestoreDirectory             = true;
                dlg.SupportMultiDottedExtensions = true;
                dlg.ValidateNames                = true;

                dlg.CheckPathExists = FileCheckPathExists;
                dlg.CheckFileExists = FileCheckFileExists;

                if (!string.IsNullOrEmpty(FileDefaultExtension))
                {
                    dlg.DefaultExt = FileDefaultExtension;
                }

                if (!string.IsNullOrEmpty(FileFilter))
                {
                    dlg.Filter = FileFilter;
                }

                dlg.FilterIndex = 0;

                DialogResult result = dlg.ShowDialog(owner);

                return(result == DialogResult.OK
                                               ? dlg.FileName
                                               : string.Empty);
            }
        }
Example #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="isfocuse">if its in focuse or not</param>
        /// <param name="data">true for save dialog false for load dialog</param>
        public override void Activate(bool isfocuse, object data)
        {
            _type = (FileDialogType)data;

            Button bnt = FindComponateById("ok") as Button;

            switch (_type)
            {
            case FileDialogType.Load:
                bnt.Text = "Load";
                FindComponateById("txtfile").Active  = false;
                FindComponateById("txtfile").Visible = true;
                break;

            case FileDialogType.Picker:
                FindComponateById("txtfile").Visible = false;
                FindComponateById("txtfile").Active  = false;
                break;

            case FileDialogType.Save:
                bnt.Text = "Save";
                FindComponateById("txtfile").Active  = true;
                FindComponateById("txtfile").Visible = true;
                break;
            }


            if (CurrentDirectory == null)
            {
                CurrentDirectory = DefaultDirectory;
            }
            DirectoryInfo parentInfo = Directory.GetParent(CurrentDirectory);

            BuildDirectoryListing(parentInfo.FullName);

            base.Activate(isfocuse);
        }
Example #20
0
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="title">The title for the file dialog</param>
        /// <param name="filter">The filter to use for the file dialog</param>
        /// <param name="dialogType">The type of file dialog to display</param>
        /// <overloads>There are two overloads for the constructor.</overloads>
        public FileDialogAttribute(string title, string filter, FileDialogType dialogType)
        {
            this.Title      = title;
            this.Filter     = filter;
            this.DialogType = dialogType;
        }
Example #21
0
 protected abstract void GetDialogProps(ITypeDescriptorContext context, out FileDialogType dialogType, out string filter);
Example #22
0
 public FileDialog(string start, string title, FileDialogType type) : this(start, title, type, defaultFileTypes)
 {
 }
Example #23
0
 public FileNameEditorPropsAttribute(FileDialogType dtype, string extension)
 {
     DialogType = dtype;
     Filter     = String.Format("{1} {0}|*.{2}", Texts.Get("s_files"), extension.ToUpper(), extension.ToLower());
 }
Example #24
0
        //=====================================================================
        // Methods, etc.

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="title">The title for the file dialog</param>
        /// <param name="filter">The filter to use for the file dialog</param>
        /// <param name="dialogType">The type of file dialog to display</param>
        /// <overloads>There are two overloads for the constructor.</overloads>
        public FileDialogAttribute(string title, string filter,
          FileDialogType dialogType)
        {
            dlgTitle = title;
            dlgFilter = filter;
            dlgType = dialogType;
        }
Example #25
0
 private void RequestFileDialog(FileDialogType type)
 {
     FileDialogRequested?.Invoke(this, new FileDialogEventArgs(type, FileDialogRequested_Callback));
 }
Example #26
0
        protected void setupOpenFileDialogue(FileDialogType fdt, string lastknownfile)
        {
            String       filename       = "";
            String       fileFilter     = "";
            String       currentFile    = "";
            const String allFilesFilter = "|All Files|*.*";

            switch (fdt)
            {
            case FileDialogType.PUTTY:
                filename    = "putty.exe";
                currentFile = Properties.Settings.Default.PuttyLocation;
                break;

            case FileDialogType.PAGEANT:
                filename    = "pageant.exe";
                currentFile = Properties.Settings.Default.PageantLocation;
                break;

            case FileDialogType.PAGEANT_KEYS:
                filename = "*.ppk";
                break;

            case FileDialogType.FILEZILLA:
                filename    = "FileZilla.exe";
                currentFile = Properties.Settings.Default.FileZillaLocation;
                break;

            case FileDialogType.WINSCP:
                filename    = "WinSCP*.exe";
                currentFile = Properties.Settings.Default.WinSCPLocation;
                break;

            case FileDialogType.WINSCPINI:
                filename    = "*.ini";
                currentFile = Properties.Settings.Default.WinSCPIniLocation;
                break;

            case FileDialogType.CSV:
                filename    = "*.csv";
                currentFile = Properties.Settings.Default.WinSCPIniLocation;
                break;

            case FileDialogType.PSFTP:
                filename    = "psftp.exe";
                currentFile = Properties.Settings.Default.PSFTPLocation;
                break;
            }

            // Override the default current file if we have supplied
            // an existing file
            if (lastknownfile != null && !lastknownfile.Equals(""))
            {
                currentFile = lastknownfile;
            }

            // Attempt to set the working directory
            string directory = "";

            if (currentFile != null && !currentFile.Equals(""))
            {
                directory = Path.GetFullPath(currentFile);
            }
            if (File.Exists(directory))
            {
                openFileDialog.InitialDirectory = directory;
            }

            // And the filename
            openFileDialog.FileName = filename;

            // And the file filter
            fileFilter            = filename + "|" + filename + allFilesFilter;
            openFileDialog.Filter = fileFilter;
        }
Example #27
0
 protected void setupOpenFileDialogue(FileDialogType fdt)
 {
     setupOpenFileDialogue(fdt, "");
 }
Example #28
0
 public bool OnFileDialog(FileDialogType type, IEnumerable <string> acceptFilters, TCallback callback)
 {
     if (type is FileDialogType.Open or FileDialogType.OpenMultiple)
     {
         var multiple            = type == FileDialogType.OpenMultiple;
         var supportedExtensions = acceptFilters.SelectMany(ParseFileType).Where(static filter => !string.IsNullOrEmpty(filter)).ToArray();
 protected void setupOpenFileDialogue(FileDialogType fdt)
 {
     setupOpenFileDialogue(fdt, "");
 }