private void FindMabiDir() { DialogResult result1 = MessageBox.Show( "沒有發現瑪奇安裝路徑,請問是否自行新增路徑?", "無瑪奇執行檔", MessageBoxButtons.YesNo); if (result1 == DialogResult.Yes) { FileFolderDialog folderDialog = new FileFolderDialog(); folderDialog.onlyPath = true; if (folderDialog.ShowDialog() == DialogResult.OK) { if (File.Exists(folderDialog.SelectedPath + "\\" + "Client.exe")) { mabiDir = folderDialog.SelectedPath; SaveMabiDirToConfig(); } else { MessageBox.Show("該路徑非瑪奇安裝路徑"); } } } }
/// <summary> /// Creates a browse dialog that allows selecting of files or folders. /// </summary> /// <returns>The selected path from the browse dialog or an empty string if there was no valid selection</returns> private string browseForFileOrFolder() { String selectedPath = string.Empty; FileFolderDialog browseDialog = new FileFolderDialog(); browseDialog.Dialog.Multiselect = true; DialogResult dialogResult = browseDialog.ShowDialog(); if (dialogResult == DialogResult.OK) { if (browseDialog.SelectedPaths != null) { selectedPath = browseDialog.SelectedPaths; } else { if (Directory.Exists(browseDialog.SelectedPath) || File.Exists(browseDialog.SelectedPath)) { selectedPath = browseDialog.SelectedPath; } } } return(selectedPath); }
private void BrowseSvp_Click(object sender, RoutedEventArgs e) { string Result = FileFolderDialog.ShowFileDialog(settings.SvpPath, "Executable File|*.exe"); if (Result != null) { settings.SvpPath = Result; } }
private void BrowseFolder_Click(object sender, RoutedEventArgs e) { string Result = FileFolderDialog.ShowFolderDialog(settings.NaturalGroundingFolder); if (Result != null) { settings.NaturalGroundingFolder = Result; } }
private void AddFolderButton_Click(object sender, RoutedEventArgs e) { string NewPath = FileFolderDialog.ShowFolderDialog(null, false); if (NewPath != null) { currentPlaylist.Folders.Add(NewPath); RefreshFiles(); } }
private void BrowseFile_Click(object sender, RoutedEventArgs e) { string Filter = OutputContainerTextBox.Text.Trim().Length > 0 ? string.Format("{0}|*.{0}", OutputContainerTextBox.Text.Trim()) : ""; string Result = FileFolderDialog.ShowSaveFileDialog("", Filter); if (Result != null) { OutputFileTextBox.Text = Result; } }
private void AddButton_Click(object sender, RoutedEventArgs e) { string[] ResultList = FileFolderDialog.ShowFileDialogMultiple("", ""); foreach (string Result in ResultList) { if (!string.IsNullOrEmpty(Result) && !files.Any(f => f.Path == Result)) { string FileName = Path.GetFileName(Result); List <FFmpegStreamInfo> FileInfo = MediaInfo.GetFileInfo(Result, new ProcessStartOptions(FFmpegDisplayMode.None)).FileStreams; if (files.Count == 0) { // Store streams of first file. foreach (FFmpegStreamInfo item in FileInfo) { sourceStreams.Add(new UIFileStream(item, Result)); } } else { // Make sure streams match the first file. bool Mismatch = false; if (FileInfo.Count != sourceStreams.Count) { Mismatch = true; } else { for (int i = 0; i < FileInfo.Count; i++) { if (FileInfo[i].StreamType != sourceStreams[i].Type || FileInfo[i].Format != sourceStreams[i].Format) { Mismatch = true; MessageBox.Show("Streams don't match the first media file.", "Validation"); break; } } } if (Mismatch) { break; } } if (FileInfo.Count > 0) { files.Add(new FileItem(Result, FileName)); } else { MessageBox.Show("No video or audio stream found in file.", "Validation"); } } } }
private void btnAddTask_Click(object sender, RoutedEventArgs e) { FileFolderDialog taskTypeWin = new FileFolderDialog(); string taskPath = taskTypeWin.ShowDialog(); // Process save file dialog box results if (taskPath != "") { ManagedTask newTask = new ManagedTask(); newTask.TaskPath = taskPath; newTask.Name = Path.GetFileName(taskPath); Model.AddTask(newTask); } }
private void btnSelectFolder_Click(object sender, EventArgs e) { var dlg = new FileFolderDialog(); dlg.IsDialog = true; if (txtFolder.Text != string.Empty) { dlg.SelectedPath = txtFolder.Text; } if (dlg.ShowDialog() == DialogResult.OK) { txtFolder.Text = dlg.SelectedPath; } }
private async void DownloadButton_Click(object sender, RoutedEventArgs e) { if (Info == null) { return; } string Filter = string.Format("Video files (*{0})|*{0}|All files (*.*)|*.*", ContainerText.Text); string Destination = FileFolderDialog.ShowSaveFileDialog(null, Filter); if (!string.IsNullOrEmpty(Destination)) { DownloadsView.Visibility = Visibility.Visible; await Manager.DownloadVideoAsync(VideoUrl, Destination, TitleText.Text, null, DownloadAction.Download, Options, null); } }
private void dGridTasks_BeginningEdit(object sender, DataGridBeginningEditEventArgs e) { int index = dGridTasks.SelectedIndex; string colName = e.Column.Header.ToString(); if (colName == "Path") { FileFolderDialog taskTypeWin = new FileFolderDialog(); string taskPath = taskTypeWin.ShowDialog(); // Process save file dialog box results if (taskPath != "") { Model.Tasks[index].TaskPath = taskPath; } } }
private async void SelectVideoButton_Click(object sender, RoutedEventArgs e) { string SelectedFile = null; string DisplayName = null; //if (SelectVideoButton.Content == MenuSelectFromPlaylist.Header) { //VideoListItem PlaylistItem = SearchVideoWindow.Instance(new SearchSettings() { // MediaType = MediaType.Video, // ConditionField = FieldConditionEnum.FileExists, // ConditionValue = BoolConditionEnum.Yes, // RatingCategory = "Height", // RatingOperator = OperatorConditionEnum.Smaller //}); //if (PlaylistItem != null) { // SelectedFile = Settings.NaturalGroundingFolder + PlaylistItem.FileName; // DisplayName = PlaylistItem.FileName; //} //} else { string ExtFilter = string.Format("Video Files|*{0}", string.Join(";*", AppPaths.VideoExtensions)); SelectedFile = FileFolderDialog.ShowFileDialog(null, ExtFilter); DisplayName = SelectedFile; //} if (!string.IsNullOrEmpty(SelectedFile)) { HidePreview(); encodeSettings.AutoCalculateSize = false; encodeSettings.FilePath = null; encodeSettings.CustomScript = null; SettingsTab.SelectedIndex = 0; encodeSettings.FilePath = SelectedFile; encodeSettings.DisplayName = DisplayName; encodeSettings.CropBottom = 0; encodeSettings.CropLeft = 0; encodeSettings.CropRight = 0; encodeSettings.CropTop = 0; try { await business.PreparePreviewFile(encodeSettings, true, true); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Cannot Open File", MessageBoxButton.OK, MessageBoxImage.Error); encodeSettings.FilePath = ""; } encodeSettings.AutoCalculateSize = true; } }
private void buttonOpenRVT_Click(object sender, RoutedEventArgs e) { try { FileFolderDialog fileFolderDialog = new FileFolderDialog(); fileFolderDialog.Dialog.Title = "Select the directory that Revit files exist."; WinForms.DialogResult result = fileFolderDialog.ShowDialog(); if (result == WinForms.DialogResult.OK) { rvtFolderName = fileFolderDialog.SelectedPath; textBoxRevitFile.Text = rvtFolderName; } } catch (Exception ex) { System.Windows.MessageBox.Show("Cannot open the selected folder.\n" + ex.Message, "Select Folder", MessageBoxButton.OK); } }
private void AddButton_Click(object sender, RoutedEventArgs e) { string Result = FileFolderDialog.ShowFileDialog("", ""); if (!string.IsNullOrEmpty(Result) && !files.Any(f => f.Path == Result)) { string FileName = Path.GetFileName(Result); List <FFmpegStreamInfo> FileInfo = MediaInfo.GetFileInfo(Result, new ProcessStartOptions(FFmpegDisplayMode.None)).FileStreams; if (FileInfo != null && FileInfo.Count > 0) { files.Add(new FileItem(Result, FileName)); foreach (FFmpegStreamInfo item in FileInfo) { fileStreams.Add(new UIFileStream(item, Result)); } } else { MessageBox.Show("No video or audio stream found in file.", "Validation"); } } }
public MainWindow() { string[] args = Environment.GetCommandLineArgs(); string strMinimized = ""; if (args.Length > 1 && args[1] == "Minimized") { strMinimized = "Minimized"; } string _PositionType = "Absolute"; string _RelativeTop = "0"; string _RelativeLeft = "0"; string _RelativeFullFileName = ""; string relativeCodeSnippet = ""; bool boolRunningFromHome = false; var window = new Window() //make sure the window is invisible { Width = 0, Height = 0, Left = -2000, WindowStyle = WindowStyle.None, ShowInTaskbar = false, ShowActivated = false, }; window.Show(); IdealAutomate.Core.Methods myActions = new Methods(); myActions.ScriptStartedUpdateStats(); StringBuilder sb = new StringBuilder(); InitializeComponent(); this.Hide(); string strWindowTitle = myActions.PutWindowTitleInEntity(); if (strWindowTitle.StartsWith("MultipleWindowControls")) { myActions.TypeText("%(\" \"n)", 1000); // minimize visual studio } myActions.Sleep(1000); tryAgain: FileFolderDialog dialog = new FileFolderDialog(); // dialog.ShowDialog(); dialog.SelectedPath = myActions.GetValueByKey("LastSearchFolder"); string str = "LastSearchFolder"; System.Windows.Forms.DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK && (Directory.Exists(dialog.SelectedPath) || File.Exists(dialog.SelectedPath))) { //cbxFolder.SelectedValue = dialog.SelectedPath; //cbxFolder.Text = dialog.SelectedPath; myActions.SetValueByKey("LastSearchFolder", dialog.SelectedPath); string strFolder = dialog.SelectedPath; myActions.SetValueByKey("cbxFolderSelectedValue", strFolder); } using (StreamReader reader = File.OpenText(dialog.SelectedPath)) { sb.Clear(); while (!reader.EndOfStream) { string myLine = reader.ReadLine(); sb.AppendLine(myLine); } } if (intWindowHeight > 700) { intWindowHeight = 700; } int startPointXTemp = startPoint.X; int startPointYTemp = startPoint.Y; double windowWidthTemp = windowWidth * 2; if (windowWidthTemp > 1000) { windowWidthTemp = 1000; } if (windowWidthTemp < 500) { windowWidthTemp = 500; } if (_PositionType == "Relative") { startPointXTemp = 0; startPointYTemp = 0; } else { startPointXTemp = startPoint.X; startPointYTemp = startPoint.Y; } // http://www.codeproject.com/Tips/715891/Compiling-Csharp-Code-at-Runtime string code = sb.ToString(); // code = @" // using System.Windows; //using IdealAutomate.Core; //using System.Collections.Generic; //using System.Linq; //using System.Diagnostics; //using System.Text; //using System; //using System.Drawing; //using System.Windows.Media.Imaging; //using System.IO; //using System.Reflection; // namespace First // { // public class Program : Window // { // public static void Main() // { // var window = new Window() //make sure the window is invisible // { // Width = 0, // Height = 0, // Left = -2000, // WindowStyle = WindowStyle.None, // ShowInTaskbar = false, // ShowActivated = false, // }; // window.Show(); // " + //"\r\n IdealAutomate.Core.Methods myActions = new Methods();" + // sb.ToString() //+ @" // } //"; CSharpCodeProvider provider = new CSharpCodeProvider(); CompilerParameters parameters = new CompilerParameters(); // Reference to System.Drawing library parameters.ReferencedAssemblies.Add("System.Drawing.dll"); parameters.ReferencedAssemblies.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"IdealAutomate\IdealAutomateCore.dll")); parameters.ReferencedAssemblies.Add(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\PresentationFramework.dll"); parameters.ReferencedAssemblies.Add(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\PresentationCore.dll"); parameters.ReferencedAssemblies.Add("System.dll"); parameters.ReferencedAssemblies.Add("System.Core.dll"); parameters.ReferencedAssemblies.Add("System.Data.dll"); parameters.ReferencedAssemblies.Add("System.Data.DataSetExtensions.dll"); parameters.ReferencedAssemblies.Add("System.Xml.Linq.dll"); parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll"); parameters.ReferencedAssemblies.Add("System.Xaml.dll"); parameters.ReferencedAssemblies.Add("System.Xml.dll"); parameters.ReferencedAssemblies.Add(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\WindowsBase.dll"); // True - memory generation, false - external file generation parameters.GenerateInMemory = true; // True - exe file generation, false - dll file generation parameters.GenerateExecutable = true; CompilerResults results = provider.CompileAssemblyFromSource(parameters, code); if (results.Errors.HasErrors) { StringBuilder sb5 = new StringBuilder(); foreach (CompilerError error in results.Errors) { sb5.AppendLine(String.Format("Error ({0}): {1} Line: {2}", error.ErrorNumber, error.ErrorText, error.Line)); } myActions.Run(@"C:\Program Files\Notepad++\notepad++.exe", "\"" + dialog.SelectedPath + "\""); System.Windows.Forms.DialogResult myResult = myActions.MessageBoxShowWithYesNo(sb5.ToString() + "\n\r Do you want to try again"); if (myResult == System.Windows.Forms.DialogResult.Yes) { goto tryAgain; } else { goto myExit; } } Assembly assembly = results.CompiledAssembly; Type program = assembly.GetType("First.Program"); MethodInfo main = program.GetMethod("Main"); main.Invoke(null, null); // Done -------------------- if (intWindowHeight > 700) { intWindowHeight = 700; } //bool boolUseNewTab = myListControlEntity.Find(x => x.ID == "myCheckBox").Checked; //if (boolUseNewTab == true) //{ // List<string> myWindowTitles = myActions.GetWindowTitlesByProcessName("iexplore"); // myWindowTitles.RemoveAll(item => item == ""); // if (myWindowTitles.Count > 0) // { // myActions.ActivateWindowByTitle(myWindowTitles[0], (int)WindowShowEnum.SW_SHOWMAXIMIZED); // myActions.TypeText("%(d)", 1500); // select address bar // myActions.TypeText("{ESC}", 1500); // myActions.TypeText("%({ENTER})", 1500); // Alt enter while in address bar opens new tab // myActions.TypeText("%(d)", 1500); // myActions.TypeText(myWebSite, 1500); // myActions.TypeText("{ENTER}", 1500); // myActions.TypeText("{ESC}", 1500); // } // else { // myActions.Run("iexplore", myWebSite); // } //} //else { // myActions.Run("iexplore", myWebSite); //} //myActions.Sleep(1000); //myActions.TypeText(mySearchTerm, 500); //myActions.TypeText("{ENTER}", 500); goto myExit; myExit: myActions.ScriptEndedSuccessfullyUpdateStats(); Application.Current.Shutdown(); }
private async void downloadAndRunToolStripMenuItem_Click(object sender, EventArgs e) { IdealAutomate.Core.Methods myActions = new Methods(); FileFolderDialog dialog = new FileFolderDialog(); // dialog.ShowDialog(); dialog.SelectedPath = myActions.GetValueByKey("LastSearchFolder"); string str = "LastSearchFolder"; System.Windows.Forms.DialogResult result = dialog.ShowDialog(); FileAttributes attr = File.GetAttributes(dialog.SelectedPath); string downloadFileType = ""; //detect whether its a directory or file if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { downloadFileType = "directory"; } else { downloadFileType = "file"; } if (result == System.Windows.Forms.DialogResult.OK && (Directory.Exists(dialog.SelectedPath) || File.Exists(dialog.SelectedPath))) { //cbxFolder.SelectedValue = dialog.SelectedPath; //cbxFolder.Text = dialog.SelectedPath; myActions.SetValueByKey("LastSearchFolder", dialog.SelectedPath); string strFolder = dialog.SelectedPath; myActions.SetValueByKey("cbxFolderSelectedValue", strFolder); } DataGridViewSelectedRowCollection rows = mainDataGridView.SelectedRows; object item = rows.Count > 0 ? rows[0].DataBoundItem : null; var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.UserAgent.Add( new System.Net.Http.Headers.ProductInfoHeaderValue("MyApplication", "1")); var repo = ((Octokit.SearchCode)(item)).Repository.Owner.Login + "/" + ((Octokit.SearchCode)(item)).Repository.Name; var contentsUrl = $"https://api.github.com/repos/{repo}/contents/" + ((Octokit.SearchCode)(item)).Path; var contentsJson = await httpClient.GetStringAsync(contentsUrl); var contents = (JObject)JsonConvert.DeserializeObject(contentsJson); string url = (string)contents["download_url"]; // Create an instance of WebClient WebClient client = new WebClient(); // Hookup DownloadFileCompleted Event client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted2); if (downloadFileType == "directory") { downloadFileName = dialog.SelectedPath + "\\" + ((Octokit.SearchCode)(item)).Name; } else { downloadFileName = dialog.SelectedPath; } // Start the download client.DownloadFileAsync(new Uri(url), downloadFileName); }