private void removeSourceButton_Click(object sender, EventArgs e) { if (pathBindingSource.Current != null) { DialogResult result = MessageBox.Show("This will remove from Moving Pictures all movies retrieved from this import path, are you sure?", "Warning!", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { // stop the importer MovingPicturesCore.Importer.Stop();; // remove the import path ((DBImportPath)pathBindingSource.Current).Delete(); pathBindingSource.RemoveCurrent(); // clean the database of the old movies using our progress bar popup ProgressPopup progressPopup = new ProgressPopup(new WorkerDelegate(DatabaseMaintenanceManager.RemoveInvalidFiles)); DatabaseMaintenanceManager.MaintenanceProgress += new ProgressDelegate(progressPopup.Progress); progressPopup.Owner = ParentForm; progressPopup.Text = "Removing related movies..."; progressPopup.ShowDialog(); // restart the importer MovingPicturesCore.Importer.RestartScanner(); } } }
private void addDynamicNode(DBField field, DBRelation relation, bool forceRoot) { if (_menu == null) { return; } SuspendLayout(); // build internal node object DBNode <T> newNode = new DBNode <T>(); newNode.Name = field.FriendlyName; newNode.BasicFilteringField = field; newNode.BasicFilteringRelation = relation; newNode.DynamicNode = true; newNode.DBManager = DBManager; count++; // build treenode object (for the UI) asyncInput = newNode; forceNewNodeRoot = forceRoot; ProgressPopup p = new ProgressPopup(new WorkerDelegate(createTreeNodeAsyncWorker)); p.Owner = FindForm(); p.Text = "Building Menu Tree"; p.WorkComplete += new WorkCompleteDelegate(addDynamicNode_TreeNodeCreated); p.ShowDialogDelayed(300); }
//remove selected movies from the ignore list. private void unignoreSelectedButton_Click(object sender, EventArgs e) { //prevent extra clicks by disabling buttons unignoreSelectedButton.Enabled = false; DialogResult result = MessageBox.Show(this, "This will remove the selected files from the ignored list, and restart\n" + "the Importer. This means all uncommitted matches from this\n" + "import session will have to be reapproved. Do you want to\n" + "continue?\n", "Warning", MessageBoxButtons.YesNo); //only process if there is at least one row selected if (result == DialogResult.Yes && ignoredMovieGrid.SelectedRows.Count > 0) { //process selected files ProgressPopup popup = new ProgressPopup(new WorkerDelegate(unignoreSelectedFiles)); popup.Owner = this.ParentForm; popup.Show(); this.DialogResult = DialogResult.OK; } else { if (ignoredMovieGrid.SelectedRows.Count == 0) { MessageBox.Show(this, "No movies were selected."); } //enable the unignore buttons in case user wants to unignore again unignoreSelectedButton.Enabled = true; } }
// Renames files from remaining movies in the list. private void RenameRemainingMovies() { renamingAll = true; this.Visible = false; ProgressPopup popup = new ProgressPopup(new TrackableWorkerDelegate(RenameRemainingWorker)); popup.Owner = this.Owner; popup.ShowDialog(); }
private void reloadDefaultSourcesToolStripMenuItem_Click(object sender, EventArgs e) { WorkerDelegate worker = new WorkerDelegate(MovingPicturesCore.DataProviderManager.LoadInternalProviders); ProgressPopup popup = new ProgressPopup(worker); popup.Owner = this.ParentForm; popup.ShowDialog(); reloadList(); }
private void treeView_DragDrop(object sender, DragEventArgs e) { clearDragDropMarkup(); if (dropPosition == DropPositionEnum.None) { return; } // grab the item being moved movingNode = (TreeNode)e.Data.GetData(typeof(TreeNode)); if (movingNode == null) { return; } // grab the target node Point pt = treeView.PointToClient(new Point(e.X, e.Y)); targetNode = treeView.GetNodeAt(pt); // grab the old parent TreeNode oldParent = movingNode.Parent; // remove node from treeview and internal menu system if (oldParent != null) { oldParent.Nodes.Remove(movingNode); ((DBNode <T>)oldParent.Tag).Children.Remove((DBNode <T>)movingNode.Tag); updateFilteredItems(oldParent, false); setVisualProperties(oldParent); } else { treeView.Nodes.Remove(movingNode); _menu.RootNodes.Remove((DBNode <T>)movingNode.Tag); } // do the heavy lifting in a new thread while displaying a progress dialog ProgressPopup popup = new ProgressPopup(new WorkerDelegate(updateMovedNodeDragDrop)); popup.Owner = FindForm(); popup.Text = "Updating Moved Menu Item"; // node will be reinserted by the callback method when work is complete popup.WorkComplete += new WorkCompleteDelegate(updateMovedNode_Complete); popup.ShowDialogDelayed(300); }
private void MovingPicturesConfig_FormClosing(object sender, FormClosedEventArgs e) { if (!DesignMode) { MovingPicturesCore.Importer.Stop(); ProgressPopup popup = new ProgressPopup(new WorkerDelegate(movieManagerPane1.Commit)); popup.Owner = this; popup.ShowDialog(); } MovingPicturesCore.Settings.ConfigScreenWidth = this.Width; MovingPicturesCore.Settings.ConfigScreenHeight = this.Height; MovingPicturesCore.Settings.ConfigScreenPositionX = this.Left; MovingPicturesCore.Settings.ConfigScreenPositionY = this.Top; }
/// <summary> /// Constructs a DeletedFileViewer, using a given Scanner. /// </summary> /// <param name="scanner">The Scanner that will be the model for this DeletedFileViewer.</param> public DeletedFileViewer(Scanner scanner) { InitializeComponent(); _lvwColumnSorter = new ListViewColumnSorter(); fileView.ListViewItemSorter = _lvwColumnSorter; _extensionMap = new Dictionary <string, ExtensionInfo>(); _imageList = new ImageList(); fileView.SmallImageList = _imageList; _scanner = scanner; scanner.ProgressUpdated += new EventHandler(state_ProgressUpdated); scanner.ScanStarted += new EventHandler(state_ScanStarted); scanner.ScanFinished += new EventHandler(state_ScanFinished); _fileSavingQueue = new FileSavingQueue(); _fileSavingQueue.Finished += FileSavingQueue_Finished; _progressPopup = new ProgressPopup(_fileSavingQueue); UpdateFilterTextBox(); }
void nodeModified(IDBNode node) { if (modificationDetails.ContainsKey((DBNode <T>)node)) { return; } if (treeNodeLookup.ContainsKey((DBNode <T>)node) && this.Visible) { // store modification details TreeNode treeNode = treeNodeLookup[(DBNode <T>)node]; NodeModifiedDetails details = new NodeModifiedDetails(); details.Index = treeNode.Index; details.Parent = treeNode.Parent; modificationDetails[(DBNode <T>)node] = details; pendingModification.Push((DBNode <T>)node); // temporarily remove the node rebuildingNode = true; if (details.Parent == null) { treeView.Nodes.Remove(treeNode); } else { details.Parent.Nodes.Remove(treeNode); } // add a dummy node so the user doesnt freak out // update the node in a new thread while displaying a progress dialog ProgressPopup popup = new ProgressPopup(new WorkerDelegate(nodeModifiedWorker)); popup.Owner = FindForm(); popup.Text = "Updating Menu Items"; popup.WorkComplete += new WorkCompleteDelegate(modifyingNode_Complete); popup.ShowDialogDelayed(300); } }
private void categoriesMenuButton_Click(object sender, EventArgs e) { menuEditorPopup = new MenuEditorPopup(); menuEditorPopup.MenuTree.FieldDisplaySettings.Table = typeof(DBMovieInfo); categoriesMenu = null; ProgressPopup loadingPopup = new ProgressPopup(new WorkerDelegate(loadCategoriesMenu)); loadingPopup.Owner = FindForm(); loadingPopup.Text = "Loading Menu..."; loadingPopup.ShowDialog(); menuEditorPopup.ShowDialog(); menuEditorPopup = null; MovingPicturesCore.DatabaseManager.BeginTransaction(); ProgressPopup savingPopup = new ProgressPopup(new WorkerDelegate(categoriesMenu.Commit)); savingPopup.Owner = FindForm(); savingPopup.Text = "Saving Menu..."; savingPopup.ShowDialog(); MovingPicturesCore.DatabaseManager.EndTransaction(); }
// generally logFile == origFilename, but if the log was transferred remotely then origFilename // is the log locally before being copied we can present to the user in dialogs, etc. public void LoadLogfile(string logFile, string origFilename, bool temporary, bool local) { m_LogFile = origFilename; m_LogLocal = local; m_LogLoadingInProgress = true; if (File.Exists(Core.ConfigFilename)) { m_Config.Serialize(Core.ConfigFilename); } float postloadProgress = 0.0f; bool progressThread = true; // start a modal dialog to prevent the user interacting with the form while the log is loading. // We'll close it down when log loading finishes (whether it succeeds or fails) ProgressPopup modal = new ProgressPopup(LogLoadCallback, true); Thread modalThread = Helpers.NewThread(new ThreadStart(() => { modal.SetModalText(string.Format("Loading Log: {0}", origFilename)); AppWindow.BeginInvoke(new Action(() => { modal.ShowDialog(AppWindow); })); })); modalThread.Start(); // this thread continually ticks and notifies any threads of the progress, through a float // that is updated by the main loading code Thread thread = Helpers.NewThread(new ThreadStart(() => { modal.LogfileProgressBegin(); foreach (var p in m_ProgressListeners) { p.LogfileProgressBegin(); } while (progressThread) { Thread.Sleep(2); float progress = 0.8f * m_Renderer.LoadProgress + 0.19f * postloadProgress + 0.01f; modal.LogfileProgress(progress); foreach (var p in m_ProgressListeners) { p.LogfileProgress(progress); } } })); thread.Start(); // this function call will block until the log is either loaded, or there's some failure m_Renderer.OpenCapture(logFile); // if the renderer isn't running, we hit a failure case so display an error message if (!m_Renderer.Running) { string errmsg = m_Renderer.InitException.Status.Str(); MessageBox.Show(String.Format("{0}\nFailed to open file for replay: {1}.\n\n" + "Check diagnostic log in Help menu for more details.", origFilename, errmsg), "Error opening log", MessageBoxButtons.OK, MessageBoxIcon.Error); progressThread = false; thread.Join(); m_LogLoadingInProgress = false; modal.LogfileProgress(-1.0f); foreach (var p in m_ProgressListeners) { p.LogfileProgress(-1.0f); } return; } if (!temporary) { m_Config.AddRecentFile(m_Config.RecentLogFiles, origFilename, 10); if (File.Exists(Core.ConfigFilename)) { m_Config.Serialize(Core.ConfigFilename); } } m_EventID = 0; m_FrameInfo = null; m_APIProperties = null; // fetch initial data like drawcalls, textures and buffers m_Renderer.Invoke((ReplayRenderer r) => { m_FrameInfo = r.GetFrameInfo(); m_APIProperties = r.GetAPIProperties(); postloadProgress = 0.2f; m_DrawCalls = FakeProfileMarkers(r.GetDrawcalls()); bool valid = HasValidMarkerColors(m_DrawCalls); if (!valid) { RemoveMarkerColors(m_DrawCalls); } postloadProgress = 0.4f; m_Buffers = r.GetBuffers(); postloadProgress = 0.7f; var texs = new List <FetchTexture>(r.GetTextures()); m_Textures = texs.OrderBy(o => o.name).ToArray(); postloadProgress = 0.9f; m_D3D11PipelineState = r.GetD3D11PipelineState(); m_D3D12PipelineState = r.GetD3D12PipelineState(); m_GLPipelineState = r.GetGLPipelineState(); m_VulkanPipelineState = r.GetVulkanPipelineState(); m_PipelineState.SetStates(m_APIProperties, m_D3D11PipelineState, m_D3D12PipelineState, m_GLPipelineState, m_VulkanPipelineState); UnreadMessageCount = 0; AddMessages(m_FrameInfo.debugMessages); postloadProgress = 1.0f; }); Thread.Sleep(20); DateTime today = DateTime.Now; DateTime compare = today.AddDays(-21); if (compare.CompareTo(Config.DegradedLog_LastUpdate) >= 0 && m_APIProperties.degraded) { Config.DegradedLog_LastUpdate = today; MessageBox.Show(String.Format("{0}\nThis log opened with degraded support - " + "this could mean missing hardware support caused a fallback to software rendering.\n\n" + "This warning will not appear every time this happens, " + "check debug errors/warnings window for more details.", origFilename), "Degraded support of log", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } m_LogLoaded = true; progressThread = false; if (local) { try { m_LogWatcher = new FileSystemWatcher(Path.GetDirectoryName(m_LogFile), Path.GetFileName(m_LogFile)); m_LogWatcher.EnableRaisingEvents = true; m_LogWatcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite; m_LogWatcher.Created += new FileSystemEventHandler(OnLogfileChanged); m_LogWatcher.Changed += new FileSystemEventHandler(OnLogfileChanged); m_LogWatcher.SynchronizingObject = m_MainWindow; // callbacks on UI thread please } catch (ArgumentException) { // likely an "invalid" directory name - FileSystemWatcher doesn't support UNC paths properly } } List <ILogViewerForm> logviewers = new List <ILogViewerForm>(); logviewers.AddRange(m_LogViewers); // make sure we're on a consistent event before invoking log viewer forms FetchDrawcall draw = m_DrawCalls.Last(); while (draw.children != null && draw.children.Length > 0) { draw = draw.children.Last(); } SetEventID(logviewers.ToArray(), draw.eventID, true); // notify all the registers log viewers that a log has been loaded foreach (var logviewer in logviewers) { if (logviewer == null || !(logviewer is Control)) { continue; } Control c = (Control)logviewer; if (c.InvokeRequired) { if (!c.IsDisposed) { c.Invoke(new Action(() => { try { logviewer.OnLogfileLoaded(); } catch (Exception ex) { throw new AccessViolationException("Rethrown from Invoke:\n" + ex.ToString()); } })); } } else if (!c.IsDisposed) { logviewer.OnLogfileLoaded(); } } m_LogLoadingInProgress = false; modal.LogfileProgress(1.0f); foreach (var p in m_ProgressListeners) { p.LogfileProgress(1.0f); } }
// start a shaderviewer to edit this shader, optionally generating stub GLSL if there isn't // GLSL source available for this shader. private void shaderedit_Click(object sender, EventArgs e) { VulkanPipelineState.ShaderStage stage = GetStageForSender(sender); if (stage == null) return; ShaderReflection shaderDetails = stage.ShaderDetails; if (stage.Shader == ResourceId.Null || shaderDetails == null) return; var files = new Dictionary<string, string>(); if (m_Core.Config.ExternalDisassemblerEnabled) { BackgroundWorker bgWorker = new BackgroundWorker(); ProgressPopup modal = new ProgressPopup(delegate { return !bgWorker.IsBusy; }, false); modal.SetModalText("Please wait - running external disassembler."); bgWorker.RunWorkerCompleted += (obj, eventArgs) => { if((bool)eventArgs.Result == true) { ShowShaderViewer(stage, files); } }; bgWorker.DoWork += (obj, eventArgs) => { eventArgs.Result = true; //try to use the external disassembler to get back the shader source string spv_bin_file = "spv_bin.spv"; string spv_disas_file = "spv_disas.txt"; spv_bin_file = Path.Combine(Path.GetTempPath(), spv_bin_file); spv_disas_file = Path.Combine(Path.GetTempPath(), spv_disas_file); //replace the {spv_bin} tag with the correct SPIR-V binary source string args = m_Core.Config.GetDefaultExternalDisassembler().args; if (args.Contains(ExternalDisassembler.SPV_BIN_TAG)) { args = args.Replace(ExternalDisassembler.SPV_BIN_TAG, spv_bin_file); //write to temp file try { // Open file for reading using (FileStream fileStream = new FileStream(spv_bin_file, FileMode.Create, FileAccess.Write)) { // Writes a block of bytes to this stream using data from // a byte array. fileStream.Write(shaderDetails.RawBytes, 0, shaderDetails.RawBytes.Length); // close file stream fileStream.Close(); } } catch (Exception ex) { // Error MessageBox.Show("Couldn't save SPIR-V binary to file: " + spv_bin_file + Environment.NewLine + ex.ToString(), "Cannot save", MessageBoxButtons.OK, MessageBoxIcon.Error); eventArgs.Result = false; } } else { MessageBox.Show("Please indicate the " + ExternalDisassembler.SPV_BIN_TAG + " in the arguments list!", "Error disassembling", MessageBoxButtons.OK, MessageBoxIcon.Error); eventArgs.Result = false; } bool useStdout = true; if (args.Contains(ExternalDisassembler.SPV_DISAS_TAG)) { args = args.Replace(ExternalDisassembler.SPV_DISAS_TAG, spv_disas_file); useStdout = false; } // else we assume the disassembler will return the result to stdout //check if any errors if ((bool)eventArgs.Result == false) return; //run the disassembler try { using (System.Diagnostics.Process disassemblerProcess = new System.Diagnostics.Process()) { disassemblerProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; //settings up parameters for the install process disassemblerProcess.StartInfo.FileName = m_Core.Config.GetDefaultExternalDisassembler().executable; disassemblerProcess.StartInfo.Arguments = args; disassemblerProcess.StartInfo.RedirectStandardOutput = true; disassemblerProcess.StartInfo.UseShellExecute = false; disassemblerProcess.StartInfo.CreateNoWindow = true; disassemblerProcess.Start(); string shaderDisassembly = ""; if(useStdout) { StringBuilder q = new StringBuilder(); while (!disassemblerProcess.HasExited) { q.Append(disassemblerProcess.StandardOutput.ReadToEnd()); } shaderDisassembly = q.ToString(); } else { //read from the output file after the process has finished bool ok = disassemblerProcess.WaitForExit(5*1000); //wait for 5 sec max if(ok) { shaderDisassembly = File.ReadAllText(spv_disas_file); } else { eventArgs.Result = false; } } files.Add("Disassembly", shaderDisassembly); // Check for sucessful completion if (disassemblerProcess.ExitCode != 0) { MessageBox.Show("Error wile running external disassembler: " + m_Core.Config.GetDefaultExternalDisassembler().name + Environment.NewLine + "Return code: " + disassemblerProcess.ExitCode, "Error disassembling", MessageBoxButtons.OK, MessageBoxIcon.Error); eventArgs.Result = false; } } //delete the temp files if(File.Exists(spv_bin_file)) File.Delete(spv_bin_file); if(File.Exists(spv_disas_file)) File.Delete(spv_disas_file); } catch (Exception ex) { // Error MessageBox.Show("Error using external disassembler: " + m_Core.Config.GetDefaultExternalDisassembler().name + Environment.NewLine + ex.ToString(), "Error disassembling", MessageBoxButtons.OK, MessageBoxIcon.Error); eventArgs.Result = false; } }; bgWorker.RunWorkerAsync(); modal.ShowDialog(); } else { // use disassembly for now. It's not compilable GLSL but it's better than // starting with a blank canvas files.Add("Disassembly", shaderDetails.Disassembly); ShowShaderViewer(stage, files); } }