本文整理汇总了C#中System.Windows.Forms.FileDialog类的典型用法代码示例。如果您正苦于以下问题:C# FileDialog类的具体用法?C# FileDialog怎么用?C# FileDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileDialog类属于System.Windows.Forms命名空间,在下文中一共展示了FileDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditValue
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;
}
示例2: CustomOpenFileDialog
const int DialogWidth = 460; // predefined/desired width
public CustomOpenFileDialog (FileDialog dialog, OpenFileDialogData data)
: base (dialog)
{
Initialize (data);
StartLocation = AddonWindowLocation.Bottom;
}
示例3: imageOCRTest
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);
}
}
}
示例4: AmbilFile
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;
}
示例5: StartDialog
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: FileDialogButton
public FileDialogButton()
{
InitializeComponent();
_dialog = new OpenFileDialog
{
Filter = "All files (*.*)|*.*"
};
}
示例7: STAShowDialog
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: OpenFileDialogEx
public OpenFileDialogEx (FileDialog fileDialog)
{
if (fileDialog == null)
throw new ArgumentNullException ("fileDialog");
InitializeComponent();
// dlgOpen.AutoUpgradeEnabled = false;
//SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.fileDialog = fileDialog;
}
示例9: SetFileDialogProperties
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]);
}
}
示例10: Prompts
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");
}
示例11: CustomOpenFileDialog
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;
}
}
示例12: PrepareFileDialog
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);
}
示例13: FileButtonClick
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 = "";
}
}
示例14: FileDialog
/// <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: extractStrings
private void extractStrings(FileDialog fileDialog)
{
try
{
fileLocationAndFileName = fileDialog.FileName;
fileLocation = Path.GetDirectoryName(fileLocationAndFileName);
fileName = Path.GetFileName(fileLocationAndFileName);
_blFileFound = true;
}
catch (Exception)
{
_blFileFound = false;
}
}