コード例 #1
0
		const int DialogWidth = 460; // predefined/desired width
		
		public CustomOpenFileDialog (FileDialog dialog, OpenFileDialogData data)
			: base (dialog)
		{
			Initialize (data);
			
			StartLocation = AddonWindowLocation.Bottom;
		}
コード例 #2
0
 public void imageOCRTest(FileDialog openImageDialog )
 {
     DialogResult ImageResult = openImageDialog.ShowDialog();
      if (ImageResult == DialogResult.OK)
      {
          String testImagePath = openImageDialog.FileName;
          try
          {
              using (var tEngine = new TesseractEngine("C:\\Users\\yeghiakoronian\\Documents\\visual studio 2013\\Projects\\NLP Genre Recogition\\NLP Genre Recogition\\tessdata", "eng", EngineMode.Default)) //creating the tesseract OCR engine with English as the language
              {
                  using (var img = Pix.LoadFromFile(testImagePath)) // Load of the image file from the Pix object which is a wrapper for Leptonica PIX structure
                  {
                      using (var page = tEngine.Process(img)) //process the specified image
                      {
                          String text = page.GetText(); //Gets the image's content as plain text.
                          MessageBox.Show(text);
                          getGenreOfSong(text);
                          //  Console.ReadKey();
                      }
                  }
              }
          }
          catch (IOException)
          {
              MessageBox.Show("Woops Cant Open The File", "COMP 6781: NLP", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
          }
      }
 }
コード例 #3
0
        private void AmbilFile(FileDialog dialog, TextBox control, bool useFilter)
        {
            if (useFilter) { dialog.Filter = "Wave Audio (*.wav)|*.wav"; }
            if (dialog.ShowDialog(this) == DialogResult.OK)

                control.Text = dialog.FileName;
        }
コード例 #4
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if ((provider != null) && (((IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService))) != null))
     {
         if (this.fileDialog == null)
         {
             this.fileDialog = new OpenFileDialog();
             string str = CreateFilterEntry(this);
             for (int i = 0; i < imageExtenders.Length; i++)
             {
             }
             this.fileDialog.Filter = str;
         }
         IntPtr focus = System.Drawing.Design.UnsafeNativeMethods.GetFocus();
         try
         {
             if (this.fileDialog.ShowDialog() == DialogResult.OK)
             {
                 FileStream stream = new FileStream(this.fileDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                 value = this.LoadFromStream(stream);
             }
         }
         finally
         {
             if (focus != IntPtr.Zero)
             {
                 System.Drawing.Design.UnsafeNativeMethods.SetFocus(new HandleRef(null, focus));
             }
         }
     }
     return value;
 }
コード例 #5
0
		private static DialogResult StartDialog(FileDialog dialog, string extension, string description)
		{
			dialog.AddExtension = true;
			dialog.DefaultExt = extension;
			dialog.Filter = string.Format("{0}(*{1})|*{1}", description, extension);
			var result = dialog.ShowDialog();
			return result;
		}
コード例 #6
0
ファイル: FileDialogButton.cs プロジェクト: ReMinoer/FormPlug
        public FileDialogButton()
        {
            InitializeComponent();

            _dialog = new OpenFileDialog
            {
                Filter = "All files (*.*)|*.*"
            };
        }
コード例 #7
0
 private DialogResult STAShowDialog(FileDialog dialog)
 {
     DialogState state = new DialogState();
     state.dialog = dialog;
     System.Threading.Thread t = new System.Threading.Thread(state.ThreadProcShowDialog);
     t.SetApartmentState(System.Threading.ApartmentState.STA);
     t.Start();
     t.Join();
     return state.result;
 }
コード例 #8
0
ファイル: ApiChangesForm.cs プロジェクト: frankgit/NChanges
        private static void SetFileDialogProperties(FileDialog dialog)
        {
            dialog.Filter = PROJECT_FILTER;

            var recentProjects = Settings.Default.RecentProjects;

            if (recentProjects != null && recentProjects.Count > 0)
            {
                dialog.InitialDirectory = Path.GetDirectoryName(recentProjects[0]);
            }
        }
コード例 #9
0
        public OpenFileDialogEx (FileDialog fileDialog)
        {
			if (fileDialog == null)
				throw new ArgumentNullException ("fileDialog");
			
            InitializeComponent();
//            dlgOpen.AutoUpgradeEnabled = false; 
            //SetStyle(ControlStyles.SupportsTransparentBackColor, true);
			
			this.fileDialog = fileDialog;
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: GiveCampUK/PPT_2
 private void FileButtonClick(TextBox textBox, FileDialog dialog)
 {
     var result = dialog.ShowDialog();
     if (result == System.Windows.Forms.DialogResult.OK)
     {
         textBox.Text = dialog.FileName;
     }
     else
     {
         textBox.Text = "";
     }
 }
コード例 #11
0
		private static void PrepareFileDialog(FileDialog dialog, FileDialogCreationArgs args)
		{
			dialog.AddExtension = !string.IsNullOrEmpty(args.FileExtension);
			dialog.DefaultExt = args.FileExtension;
			dialog.FileName = args.FileName;
			dialog.InitialDirectory = args.Directory;
			dialog.RestoreDirectory = true;
			dialog.Title = args.Title;

			dialog.Filter = StringUtilities.Combine(args.Filters, "|",
			                                        f => f.Description + "|" + f.Filter);
		}
コード例 #12
0
		public CustomOpenFileDialog (FileDialog dialog, OpenFileDialogData data)
			: base (dialog)
		{
			Initialize (data);
			
			StartLocation = AddonWindowLocation.Bottom;

			// Use the classic dialogs, as the new ones (WPF based) can't handle child controls.
			if (data.ShowEncodingSelector || data.ShowViewerSelector) {
				dialog.AutoUpgradeEnabled = false;
			}
		}
コード例 #13
0
ファイル: Prompts.cs プロジェクト: WCapelle/ttwinstaller
        public Prompts(OpenFileDialog openDialog, SaveFileDialog saveDialog, ILog log, IEnumerable<IPathStore> store)
        {
            Log = log;
            Stores = store;

            this.openDialog = openDialog;
            this.saveDialog = saveDialog;

            Fallout3Path = TryAllStoresGetPath("Fallout3");
            FalloutNVPath = TryAllStoresGetPath("FalloutNV");
            TTWSavePath = TryAllStoresGetPath("TaleOfTwoWastelands");
        }
コード例 #14
0
ファイル: Dialogs.cs プロジェクト: souxiaosou/OmniEngine.Net
 /// <summary>
 /// Opens a "FileDialog" prompt window and returns the Dialog Result if blocking, otherwise DialogResult.OK.
 /// Call will block if a delegate isn't passed.
 /// </summary>
 /// <param name="fd">Reference of a FileDialog </param>
 /// <param name="onfinish">If a delegate is passed, then it doesn't block.</param>
 /// <returns></returns>
 public static DialogResult FileDialog(ref FileDialog fd, onDialogFinished onfinish = null)
 {
     DialogResult dr = new DialogResult();
     Oper o = new Oper(ref fd, ref dr) {_callback = onfinish};
     Thread thread = new Thread(() => FileDialog_DoWork(o));
     thread.SetApartmentState(ApartmentState.STA);
     thread.Start();
     if (onfinish != null)
         return DialogResult.OK;
     while (!o._isFinished)
         Thread.Sleep(100);
     return o._dr;
 }
コード例 #15
0
 private void extractStrings(FileDialog fileDialog)
 {
     try
     {
         fileLocationAndFileName = fileDialog.FileName;
         fileLocation = Path.GetDirectoryName(fileLocationAndFileName);
         fileName = Path.GetFileName(fileLocationAndFileName);
         _blFileFound = true;
     }
     catch (Exception)
     {
         _blFileFound = false;
     }
 }
コード例 #16
0
ファイル: TrialExpired.cs プロジェクト: ranji/NServiceBus
        //When calling a OpenFileDialog it needs to be done from an STA thread model otherwise it throws:
        //"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process."
        private static DialogResult ShowDialogInSTA(FileDialog dialog)
        {
            var result = DialogResult.Cancel;

            var thread = new Thread(() =>
                {
                    result = dialog.ShowDialog();
                });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();

            return result;
        }
コード例 #17
0
		internal static void SetCommonFormProperties (SelectFileDialogData data, FileDialog dialog)
		{
			if (!string.IsNullOrEmpty (data.Title))
				dialog.Title = data.Title;
			
			dialog.AddExtension = true;
			dialog.Filter = GetFilterFromData (data.Filters);
			dialog.FilterIndex = data.DefaultFilter == null ? 1 : data.Filters.IndexOf (data.DefaultFilter) + 1;
			
			dialog.InitialDirectory = data.CurrentFolder;
            if (!string.IsNullOrEmpty (data.InitialFileName))
                dialog.FileName = data.InitialFileName;
			
			OpenFileDialog openDialog = dialog as OpenFileDialog;
			if (openDialog != null)
				openDialog.Multiselect = data.SelectMultiple;
		}
コード例 #18
0
        private void DoProcess(string activity)
        {
            try
            {
                if (string.IsNullOrEmpty(Global.SqlLocalDbPath))
                {
                    _dialog = new OpenFileDialog();
                    _dialog.Title = "Locate SqlLocalDB.exe";
                    _dialog.FileName = "SqlLocalDB.exe";
                    _dialog.Filter = "Executable files (*.exe)|*.exe|All files (*.*)|*.*";
                    _dialog.InitialDirectory = Global.SqlLocalDbDefaultPath;
                    _dialog.FilterIndex = 1;
                    if (_dialog.ShowDialog() == DialogResult.OK)
                    {
                        Global.SqlLocalDbPath = "\"" + _dialog.FileName + "\"";
                    }
                }

                var info = new ProcessStartInfo(Global.SqlLocalDbPath, " " + activity + " " + txtInstanceName.Text);
                var p = new Process();
                p.StartInfo = info;
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = true;
                p.Start();
                p.WaitForExit();
                var reader = p.StandardOutput;
                var output = reader.ReadToEnd();
                reader.Close();

                if (output.Length == 0)
                {
                    reader = p.StandardError;
                    var error = reader.ReadToEnd();
                    reader.Close();
                    txtResult.Text = error;
                } else {
                    txtResult.Text = output;
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #19
0
ファイル: Form1.cs プロジェクト: bublyk/SretProject
 private void CreateFile(FileDialog path, dynamic data)
 {
     bool isImage = false;
     Bitmap image = new Bitmap(1,1);
     if (data.GetType().Name == "Bitmap")
     {
         isImage = true;
         image = data;
     }
     using (BinaryWriter br = new BinaryWriter(new FileStream(path, FileMode.OpenOrCreate)))
     {
         if (isImage)
             image.Save(path, System.Drawing.Imaging.ImageFormat.Bmp);
         else
             br.Write(data);
     }
 }
コード例 #20
0
ファイル: AppUI.Forms.cs プロジェクト: kubaszostak/KSz.Shared
        protected IFileDialogAction ShowDialogNative(FileDialog dlg, Func<Stream> openFile)
        {
            this.AddStarPrefixToExtensions();
            dlg.Filter = this.GetFilter();
            dlg.InitialDirectory = IO.Path.GetDirectoryName(this.FilePath);
            dlg.FileName = IO.Path.GetFileNameWithoutExtension(this.FilePath);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                using (var stream = openFile())
                {
                    if (stream == null)
                        return null;
                    return this.RunAction(dlg.FilterIndex - 1, stream, dlg.FileName);
                }
            }
            return null;
        }
コード例 #21
0
        public static void FileDialogSetValue(FileDialogMemento target, FileDialog source)
        {
            target.DefaultExt = source.DefaultExt;

            target.Filter           = source.Filter;
            target.FilterIndex      = source.FilterIndex;
            target.InitialDirectory = source.InitialDirectory;
            target.Title            = source.Title;

            target.FileName  = source.FileName;
            target.FileNames = source.FileNames;
            var saveDialog = source as SaveFileDialog;

            if (saveDialog != null)
            {
                target.OverwritePrompt = saveDialog.OverwritePrompt;
            }
        }
コード例 #22
0
        public override WindowResponse Show()
        {
            if (DialogType == FileDialogType.SelectFolder)
            {
                fbdlg = new OpenFolderDialog();
                fbdlg.InitialFolder = InitialDirectory;
                fbdlg.Title         = Title;

                WindowResponse resp = WinFormHelper.GetResponse(fbdlg.ShowDialog(owner));
                SelectedPath = fbdlg.Folder;
                return(resp);
            }
            else
            {
                switch (DialogType)
                {
                case FileDialogType.OpenFile:
                    fdlg = new OpenFileDialog();
                    break;

                case FileDialogType.SaveFile:
                    fdlg = new SaveFileDialog();
                    break;
                }

                fdlg.InitialDirectory = InitialDirectory;
                fdlg.Title            = Title;
                string tmpFilter = string.Empty;

                foreach (FileTypeFilter filter in FileTypeFilters)
                {
                    tmpFilter += filter.FilterName + "|";
                    for (int i = 0; i < filter.Filter.Length; i++)
                    {
                        tmpFilter += (i == 0 ? "" : ";") + "*." + filter.Filter[i];
                    }
                }
                fdlg.Filter = tmpFilter;
                WindowResponse resp = WinFormHelper.GetResponse(fdlg.ShowDialog());
                SelectedPath = fdlg.FileName;
                return(resp);
            }
        }
コード例 #23
0
        /// <summary>
        /// Edits the specified object using the editor style provided by the <see cref="GetEditStyle"/> method.
        /// </summary>
        /// <param name="context">An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information.</param>
        /// <param name="provider">A service provider object through which editing services may be obtained.</param>
        /// <param name="value">An instance of the value being edited.</param>
        /// <returns>The new value of the object. If the value of the object hasn't changed, this should return the same object it was passed.</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider == null) return value;
            var service = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            if (service == null) return value;

            if (fileDialog == null)
            {
                fileDialog = new OpenFileDialog();
                fileDialog.Filter = GetFilterString();
            }
            try
            {
                if (fileDialog.ShowDialog() == DialogResult.OK)
                    value = X509Certificate.CreateFromCertFile(fileDialog.FileName);
            }
            finally { }
            return value;
        }
コード例 #24
0
 internal QRCodeDecoderGUIExample()
 {
     System.Console.Out.WriteLine("Starting QRCode Decoder GUI Example ...");
     //UPGRADE_TODO: Method 'java.awt.Component.setSize' was converted to 'System.Windows.Forms.Control.Size' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtComponentsetSize_int_int'"
     Size = new System.Drawing.Size(400, 400);
     Closing += new System.ComponentModel.CancelEventHandler(this.QRCodeDecoderGUIExample_Closing_EXIT_ON_CLOSE);
     menuBar = new System.Windows.Forms.MainMenu();
     openMenu = new System.Windows.Forms.MenuItem();
     openMenu.Text = "Open Image";
     openMenu.Click += new System.EventHandler(this.actionPerformed);
     SupportClass.CommandManager.CheckCommand(openMenu);
     menuBar.MenuItems.Add(openMenu);
     Menu = menuBar;
     //UPGRADE_TODO: Constructor 'javax.swing.JTextField.JTextField' was converted to 'System.Windows.Forms.TextBox' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJTextFieldJTextField_int'"
     url = new System.Windows.Forms.TextBox();
     //UPGRADE_TODO: Method 'javax.swing.text.JTextComponent.setText' was converted to 'System.Windows.Forms.TextBoxBase.Text' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingtextJTextComponentsetText_javalangString'"
     url.Text = "(Or input image url here.)";
     button = SupportClass.ButtonSupport.CreateStandardButton("Open from URL");
     button.Click += new System.EventHandler(this.actionPerformed);
     SupportClass.CommandManager.CheckCommand(button);
     System.Windows.Forms.Panel urlPanel = new System.Windows.Forms.Panel();
     //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent'"
     urlPanel.Controls.Add(url);
     //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent'"
     urlPanel.Controls.Add(button);
     button = SupportClass.ButtonSupport.CreateStandardButton("URL");
     //UPGRADE_TODO: Method 'javax.swing.JFrame.getContentPane' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJFramegetContentPane'"
     //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent_javalangObject'"
     ((System.Windows.Forms.ContainerControl) this).Controls.Add(urlPanel);
     urlPanel.Dock = System.Windows.Forms.DockStyle.Top;
     urlPanel.SendToBack();
     //UPGRADE_TODO: Constructor may need to be changed depending on function performed by the 'System.Windows.Forms.FileDialog' object. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1270'"
     chooser = SupportClass.FileDialogSupport.CreateOpenFileDialog("Open QR Code Image");
     //UPGRADE_ISSUE: Method 'javax.swing.JFileChooser.setFileFilter' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxswingJFileChoosersetFileFilter_javaxswingfilechooserFileFilter'"
     chooser.setFileFilter(new ImageFileFilter());
     //UPGRADE_TODO: Method 'java.awt.Component.setLocation' was converted to 'System.Windows.Forms.Control.Location' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtComponentsetLocation_int_int'"
     Location = new System.Drawing.Point(300, 200);
     SupportClass.SelectText(url, 0, url.Text.Length);
     //UPGRADE_TODO: Method 'java.awt.Component.setVisible' was converted to 'System.Windows.Forms.Control.Visible' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtComponentsetVisible_boolean'"
     //UPGRADE_TODO: 'System.Windows.Forms.Application.Run' must be called to start a main form. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1135'"
     Visible = true;
 }
コード例 #25
0
 internal QRCodeDecoderGUIExample()
 {
     System.Console.Out.WriteLine("Starting QRCode Decoder GUI Example ...");
     //UPGRADE_TODO: Method 'java.awt.Component.setSize' was converted to 'System.Windows.Forms.Control.Size' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtComponentsetSize_int_int'"
     Size            = new System.Drawing.Size(400, 400);
     Closing        += new System.ComponentModel.CancelEventHandler(this.QRCodeDecoderGUIExample_Closing_EXIT_ON_CLOSE);
     menuBar         = new System.Windows.Forms.MainMenu();
     openMenu        = new System.Windows.Forms.MenuItem();
     openMenu.Text   = "Open Image";
     openMenu.Click += new System.EventHandler(this.actionPerformed);
     SupportClass.CommandManager.CheckCommand(openMenu);
     menuBar.MenuItems.Add(openMenu);
     Menu = menuBar;
     //UPGRADE_TODO: Constructor 'javax.swing.JTextField.JTextField' was converted to 'System.Windows.Forms.TextBox' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJTextFieldJTextField_int'"
     url = new System.Windows.Forms.TextBox();
     //UPGRADE_TODO: Method 'javax.swing.text.JTextComponent.setText' was converted to 'System.Windows.Forms.TextBoxBase.Text' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingtextJTextComponentsetText_javalangString'"
     url.Text      = "(Or input image url here.)";
     button        = SupportClass.ButtonSupport.CreateStandardButton("Open from URL");
     button.Click += new System.EventHandler(this.actionPerformed);
     SupportClass.CommandManager.CheckCommand(button);
     System.Windows.Forms.Panel urlPanel = new System.Windows.Forms.Panel();
     //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent'"
     urlPanel.Controls.Add(url);
     //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent'"
     urlPanel.Controls.Add(button);
     button = SupportClass.ButtonSupport.CreateStandardButton("URL");
     //UPGRADE_TODO: Method 'javax.swing.JFrame.getContentPane' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJFramegetContentPane'"
     //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent_javalangObject'"
     ((System.Windows.Forms.ContainerControl) this).Controls.Add(urlPanel);
     urlPanel.Dock = System.Windows.Forms.DockStyle.Top;
     urlPanel.SendToBack();
     //UPGRADE_TODO: Constructor may need to be changed depending on function performed by the 'System.Windows.Forms.FileDialog' object. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1270'"
     chooser = SupportClass.FileDialogSupport.CreateOpenFileDialog("Open QR Code Image");
     //UPGRADE_ISSUE: Method 'javax.swing.JFileChooser.setFileFilter' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxswingJFileChoosersetFileFilter_javaxswingfilechooserFileFilter'"
     chooser.setFileFilter(new ImageFileFilter());
     //UPGRADE_TODO: Method 'java.awt.Component.setLocation' was converted to 'System.Windows.Forms.Control.Location' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtComponentsetLocation_int_int'"
     Location = new System.Drawing.Point(300, 200);
     SupportClass.SelectText(url, 0, url.Text.Length);
     //UPGRADE_TODO: Method 'java.awt.Component.setVisible' was converted to 'System.Windows.Forms.Control.Visible' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtComponentsetVisible_boolean'"
     //UPGRADE_TODO: 'System.Windows.Forms.Application.Run' must be called to start a main form. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1135'"
     Visible = true;
 }
コード例 #26
0
        private Uri GetFileUrl(FileDialog dialog, Uri recentUri)
        {
            dialog.Filter = this.FileFilter;

            if (recentUri != null && recentUri.IsFile)
            {
                dialog.FileName = recentUri.LocalPath;
            }

            var result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                return new Uri(dialog.FileName);
            }
            else
            {
                return null;
            }
        }
コード例 #27
0
        public DialogResult ShowDialog(IWin32Window owner)
        {
            DialogResult returnDialogResult = DialogResult.Cancel;

            if (this.IsDisposed)
            {
                return(returnDialogResult);
            }
            if (owner == null || owner.Handle == IntPtr.Zero)
            {
                WindowWrapper wr = new WindowWrapper(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle);
                owner = wr;
            }
            OriginalCtrlSize = this.Size;
            _MSdialog        = (FileDlgType == FileDialogType.OpenFileDlg)?new OpenFileDialog() as FileDialog:new SaveFileDialog() as FileDialog;
            _dlgWrapper      = new WholeDialogWrapper(this);
            OnPrepareMSDialog();
            if (!_hasRunInitMSDialog)
            {
                InitMSDialog();
            }
            try
            {
                System.Reflection.PropertyInfo AutoUpgradeInfo = MSDialog.GetType().GetProperty("AutoUpgradeEnabled");
                if (AutoUpgradeInfo != null)
                {
                    AutoUpgradeInfo.SetValue(MSDialog, false, null);
                }
                returnDialogResult = _MSdialog.ShowDialog(owner);
            }
            // Sometimes if you open a animated .gif on the preview and the Form is closed, .Net class throw an exception
            // Lets ignore this exception and keep closing the form.
            catch (ObjectDisposedException)
            {
            }
            catch (Exception ex)
            {
                MessageBox.Show("unable to get the modal dialog handle", ex.Message);
            }
            return(returnDialogResult);
        }
コード例 #28
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if ((provider != null) && (((IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService))) != null))
     {
         if (this.fileDialog == null)
         {
             this.fileDialog = new OpenFileDialog();
             this.fileDialog.Title = System.Design.SR.GetString("XMLFilePicker_Caption");
             this.fileDialog.Filter = System.Design.SR.GetString("XMLFilePicker_Filter");
         }
         if (value != null)
         {
             this.fileDialog.FileName = value.ToString();
         }
         if (this.fileDialog.ShowDialog() == DialogResult.OK)
         {
             value = this.fileDialog.FileName;
         }
     }
     return value;
 }
コード例 #29
0
        private void PopulateFileDialog(System.Windows.Forms.FileDialog dlg,
                                        string fileName,
                                        string defaultExtension, string initialDirectory, Dictionary <string, string> filters,
                                        string title, bool addExtension, bool checkFileExists, bool checkPathExists)
        {
            dlg.DefaultExt       = defaultExtension;
            dlg.InitialDirectory = initialDirectory;
            dlg.Title            = title;
            dlg.AddExtension     = addExtension;
            dlg.CheckFileExists  = checkFileExists;
            dlg.CheckPathExists  = checkPathExists;
            dlg.FileName         = fileName;

            dlg.FilterIndex = 0;
            int           thisIndex = 0;
            StringBuilder filtValue = new StringBuilder();

            foreach (string k in filters.Keys)
            {
                if (filtValue.Length > 0)
                {
                    filtValue.Append("|");
                }
                filtValue.Append(filters[k] + " (*." + k + ")|*." + k);
                if (k == defaultExtension)
                {
                    dlg.FilterIndex = thisIndex;
                }
                thisIndex++;
            }

            // Add an All filter
            if (filtValue.Length > 0)
            {
                filtValue.Append("|");
            }
            filtValue.Append(Strings.All_Files + " (*.*)|*.*");

            dlg.Filter = filtValue.ToString();
        }
コード例 #30
0
            public FileRenderer(FileDialog owner)
            {
                this.owner = owner;

                prevPathes = new List <string>();

                filesTree                       = new TreeView();
                filesTree.Anchor                = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
                filesTree.Size                  = new Drawing.Size(Width, Height);
                filesTree.AfterSelect          += filesTree_SelectedNodeChanged;
                filesTree.NodeMouseDoubleClick += filesTree_NodeMouseDoubleClick;
                Controls.Add(filesTree);

                Bitmap folderImage = this.owner.ImageFolder != null ? this.owner.ImageFolder : GenDefaultFolderImage();
                Bitmap fileImage   = this.owner.ImageFile != null ? this.owner.ImageFile : GenDefaultFileImage();

                filesTree.ImageList = new ImageList();
                filesTree.ImageList.Images.Add(folderImage);
                filesTree.ImageList.Images.Add(fileImage);

                currentPath = UnityEngine.Application.dataPath;
            }
コード例 #31
0
        public override WindowResponse Show()
        {
            if (DialogType == FileDialogType.SelectFolder)
            {
                fbdlg = new OpenFolderDialog();
                fbdlg.InitialFolder = InitialDirectory;
                fbdlg.Title = Title;

                WindowResponse resp = WinFormHelper.GetResponse(fbdlg.ShowDialog(owner));
                SelectedPath = fbdlg.Folder;
                return resp;
            }
            else
            {
                switch (DialogType)
                {
                    case FileDialogType.OpenFile:
                        fdlg = new OpenFileDialog();
                        break;
                    case FileDialogType.SaveFile:
                        fdlg = new SaveFileDialog();
                        break;
                }

                fdlg.InitialDirectory = InitialDirectory;
                fdlg.Title = Title;
                string tmpFilter = string.Empty;

                foreach (FileTypeFilter filter in FileTypeFilters)
                {
                    tmpFilter += filter.FilterName + "|";
                    for (int i = 0; i < filter.Filter.Length; i++) tmpFilter += (i == 0 ? "" : ";") + "*." + filter.Filter[i];
                }
                fdlg.Filter = tmpFilter;
                WindowResponse resp = WinFormHelper.GetResponse(fdlg.ShowDialog());
                SelectedPath = fdlg.FileName;
                return resp;
            }
        }
コード例 #32
0
 internal override string[] ProcessVistaFiles(FileDialogNative.IFileDialog dialog)
 {
     FileDialogNative.IShellItem      item2;
     FileDialogNative.IFileOpenDialog dialog2 = (FileDialogNative.IFileOpenDialog)dialog;
     if (this.Multiselect)
     {
         FileDialogNative.IShellItemArray array;
         uint num;
         dialog2.GetResults(out array);
         array.GetCount(out num);
         string[] strArray = new string[num];
         for (uint i = 0; i < num; i++)
         {
             FileDialogNative.IShellItem item;
             array.GetItemAt(i, out item);
             strArray[i] = FileDialog.GetFilePathFromShellItem(item);
         }
         return(strArray);
     }
     dialog2.GetResult(out item2);
     return(new string[] { FileDialog.GetFilePathFromShellItem(item2) });
 }
コード例 #33
0
        internal FileDialogNative.IShellItem GetNativePath()
        {
            // This can throw in a multitude of ways if the path or Guid doesn't correspond
            // to an actual filesystem directory.
            // The Caller is responsible for handling these situations.
            string filePathString;

            if (!string.IsNullOrEmpty(_path))
            {
                filePathString = _path;
            }
            else
            {
                int result = Interop.Shell32.SHGetKnownFolderPath(ref _knownFolderGuid, 0, IntPtr.Zero, out filePathString);
                if (result == 0)
                {
                    return(null);
                }
            }

            return(FileDialog.GetShellItemForPath(filePathString));
        }
コード例 #34
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if ((provider != null) && (((IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService))) != null))
     {
         if (this.fileDialog == null)
         {
             this.fileDialog = new OpenFileDialog();
             string str = CreateFilterEntry(this);
             for (int i = 0; i < this.GetImageExtenders().Length; i++)
             {
                 ImageEditor o = (ImageEditor) Activator.CreateInstance(this.GetImageExtenders()[i], BindingFlags.CreateInstance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, null, null);
                 System.Type type = base.GetType();
                 System.Type type2 = o.GetType();
                 if ((!type.Equals(type2) && (o != null)) && type.IsInstanceOfType(o))
                 {
                     str = str + "|" + CreateFilterEntry(o);
                 }
             }
             this.fileDialog.Filter = str;
         }
         IntPtr focus = System.Drawing.Design.UnsafeNativeMethods.GetFocus();
         try
         {
             if (this.fileDialog.ShowDialog() == DialogResult.OK)
             {
                 FileStream stream = new FileStream(this.fileDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                 value = this.LoadFromStream(stream);
             }
         }
         finally
         {
             if (focus != IntPtr.Zero)
             {
                 System.Drawing.Design.UnsafeNativeMethods.SetFocus(new HandleRef(null, focus));
             }
         }
     }
     return value;
 }
コード例 #35
0
        protected void setupDialog(bool isNewDb = false)
        {
            try
            {
                if (this.dialog != null)
                {
                    this.dialog.Dispose();
                }

                if (!isNewDb)
                {
                    this.dialog             = new System.Windows.Forms.OpenFileDialog();
                    dialog.DefaultExt       = "pdb";
                    dialog.Filter           = "Database file (*.pdb)|*.pdb";
                    dialog.AddExtension     = true;
                    dialog.RestoreDirectory = true;
                    //co the se loi
                    dialog.InitialDirectory             = Utility.Instance().getPathDialog(AppDomain.CurrentDomain.BaseDirectory.ToString());
                    dialog.SupportMultiDottedExtensions = true;
                }
                else
                {
                    this.dialog            = new System.Windows.Forms.SaveFileDialog();                  // Save dialog
                    this.dialog.DefaultExt = "pdb";                                                      // Default extension
                    this.dialog.Filter     = "Database file (*.pdb)|*.pdb";                              // add extension to dialog
                                                                                                         //DialogSave.Filter = "Database file (*.pdb)|*.pdb|All files (*.*)|*.*";
                    this.dialog.AddExtension                 = true;                                     // enable adding extension
                    this.dialog.RestoreDirectory             = true;                                     // Tu dong phuc hoi duong dan cho lan sau
                    this.dialog.Title                        = "Create new database...";
                    this.dialog.InitialDirectory             = Utility.Instance().getPathDialog(AppDomain.CurrentDomain.BaseDirectory.ToString());
                    this.dialog.SupportMultiDottedExtensions = true;
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }
        }
コード例 #36
0
        public static void FileDialogSetValue(FileDialog target, FileDialogMemento source)
        {
            target.AddExtension       = true;
            target.AutoUpgradeEnabled = true;
            target.CheckFileExists    = false;
            target.CheckPathExists    = false;
            target.DefaultExt         = source.DefaultExt;
            target.DereferenceLinks   = true;
            target.FileName           = IoUtils.NiceFileName(source.FileName);
            target.Filter             = source.Filter;
            target.FilterIndex        = source.FilterIndex;
            target.InitialDirectory   = source.InitialDirectory;
            target.RestoreDirectory   = false;
            target.ShowHelp           = false;
            target.Title         = source.Title;
            target.ValidateNames = true;
            var saveDialog = target as SaveFileDialog;

            if (saveDialog != null)
            {
                saveDialog.OverwritePrompt = source.OverwritePrompt;
            }
        }
コード例 #37
0
ファイル: FileDialog.cs プロジェクト: MSylvia/Unity-WinForms
            public FileRender(FileDialog owner)
            {
                _owner = owner;

                prevPathes = new List <string>();

                filesTree                       = new TreeView();
                filesTree.Anchor                = AnchorStyles.All;
                filesTree.BorderColor           = Color.LightGray;
                filesTree.Size                  = new Drawing.Size(Width, Height);
                filesTree.SelectedNodeChanged  += filesTree_SelectedNodeChanged;
                filesTree.NodeMouseDoubleClick += filesTree_NodeMouseDoubleClick;
                Controls.Add(filesTree);

                Bitmap folderImage = _owner.ImageFolder != null ? _owner.ImageFolder : GenDefaultFolderImage();
                Bitmap fileImage   = _owner.ImageFile != null ? _owner.ImageFile : GenDefaultFileImage();

                filesTree.ImageList = new ImageList();
                filesTree.ImageList.Images.Add(folderImage);
                filesTree.ImageList.Images.Add(fileImage);

                currentPath = UnityEngine.Application.dataPath;
            }
コード例 #38
0
ファイル: Extensions.cs プロジェクト: smitcham/libpalaso
        public static void SetPlaces(this FileDialog fd, object[] places)
        {
            if (fd == null)
            {
                return;
            }
            if (m_places == null)
            {
                m_places = new object[5];
            }
            else
            {
                m_places.Initialize();
            }

            if (places != null)
            {
                for (int i = 0; i < m_places.GetLength(0); i++)
                {
                    m_places[i] = places[i];
                }
            }
            if (_fakeKey != null)
            {
                ResetPlaces(fd);
            }
            SetupFakeRegistryTree();
            if (fd != null)
            {
                fd.Disposed += (object sender, EventArgs e) => { if (m_places != null && fd != null)
                                                                 {
                                                                     ResetPlaces(fd);
                                                                 }
                }
            }
            ;
        }
コード例 #39
0
        internal FileDialogNative.IShellItem GetNativePath()
        {
            //This can throw in a multitude of ways if the path or Guid doesn't correspond
            //to an actual filesystem directory.  Caller is responsible for handling these situations.
            string filePathString = "";

            if (!string.IsNullOrEmpty(this._path))
            {
                filePathString = this._path;
            }
            else
            {
                filePathString = GetFolderLocation(this._knownFolderGuid);
            }

            if (string.IsNullOrEmpty(filePathString))
            {
                return(null);
            }
            else
            {
                return(FileDialog.GetShellItemForPath(filePathString));
            }
        }
コード例 #40
0
 protected MdlFileDialog()
 {
     dbService      = DbFactory.GetDatabaseService();
     this.pDatabase = null;
     this.dialog    = null;
 }
コード例 #41
0
 protected ClassicFileDialog(FileDialog fileDialog)
 {
     this.fileDialog = fileDialog;
     this.fileDialog.RestoreDirectory = true;
     this.fileDialog.ShowHelp = false;
     this.fileDialog.ValidateNames = true;
 }
コード例 #42
0
 public VistaDialogEvents(FileDialog dialog)
 {
     _ownerDialog = dialog;
 }
コード例 #43
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
 protected override void Dispose(bool disposing)
 {
     if (IsDisposed)
         return;
     if (MSDialog != null)
     {
         MSDialog.FileOk -= new CancelEventHandler(FileDialogControlBase_ClosingDialog);
         MSDialog.Disposed -= new EventHandler(FileDialogControlBase_DialogDisposed);
         //if (MSDialog.ShowHelp)
         MSDialog.HelpRequest -= new EventHandler(FileDialogControlBase_HelpRequest);
         MSDialog.Dispose();
         MSDialog = null;
     }
     if (disposing && (components != null))
     {
         components.Dispose();
     }
     base.Dispose(disposing);
 }
コード例 #44
0
 public VistaDialogEvents(FileDialog dialog)
 {
     this._dialog = dialog;
 }
コード例 #45
0
 /// <summary>
 /// Returns an observable sequence wrapping the FileOk event on the FileDialog instance.
 /// </summary>
 /// <param name="instance">The FileDialog instance to observe.</param>
 /// <returns>An observable sequence wrapping the FileOk event on the FileDialog instance.</returns>
 public static IObservable <EventPattern <CancelEventArgs> > FileOkObservable(this FileDialog instance)
 {
     return(Observable.FromEventPattern <CancelEventHandler, CancelEventArgs>(
                handler => instance.FileOk += handler,
                handler => instance.FileOk -= handler));
 }
コード例 #46
0
 public PathTextBox(FileDialog owner)
 {
     fileDialog = owner;
     Padding    = new Padding(8, 0, 8, 0);
 }
コード例 #47
0
 /// <summary>
 /// Modifies an instance of OpenFileDialog, to open a given directory.
 /// </summary>
 /// <param name="fileDialog">OpenFileDialog instance to be modified.</param>
 /// <param name="path">Path to be opened by the OpenFileDialog.</param>
 public static void SetOpenFileDialog(System.Windows.Forms.FileDialog fileDialog, System.String path)
 {
     fileDialog.InitialDirectory = path;
 }
コード例 #48
0
		internal DialogResult ShowDialogExt(FileDialog fdlg,IWin32Window owner)
		{
			DialogResult returnDialogResult = DialogResult.Cancel;
			if (this.IsDisposed)
				return returnDialogResult;
			if (owner == null || owner.Handle == IntPtr.Zero)
			{
				WindowWrapper wr = new WindowWrapper(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle);
				owner = wr;
			}
			OriginalCtrlSize = this.Size;
			MSDialog = fdlg;
			_dlgWrapper = new WholeDialogWrapper(this);

			try
			{
				System.Reflection.PropertyInfo AutoUpgradeInfo = MSDialog.GetType().GetProperty("AutoUpgradeEnabled");
				if (AutoUpgradeInfo != null)
					AutoUpgradeInfo.SetValue(MSDialog, false, null);
				returnDialogResult = _MSdialog.ShowDialog(owner);
			}
			// Sometimes if you open a animated .gif on the preview and the Form is closed, .Net class throw an exception
			// Lets ignore this exception and keep closing the form.
			catch (ObjectDisposedException)
			{
			}
			catch (Exception ex)
			{
				MessageBox.Show("unable to get the modal dialog handle", ex.Message);
			}
			return returnDialogResult;
		}
コード例 #49
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.fileDialog != null)
         {
             this.fileDialog.Dispose();
             this.fileDialog = null;
         }
     }
 }
コード例 #50
0
 /// <summary>
 /// Modifies an instance of OpenFileDialog, to open a given directory.
 /// </summary>
 /// <param name="fileDialog">OpenFileDialog instance to be modified.</param>
 /// <param name="path">Path to be opened by the OpenFileDialog</param>
 public static void SetOpenFileDialog(System.Windows.Forms.FileDialog fileDialog, System.IO.FileInfo path)
 {
     fileDialog.InitialDirectory = path.Directory.FullName;
 }