mirror of https://github.com/n00mkrad/flowframes
Added pausing/resuming for interpolation, async (background) web checks
This commit is contained in:
parent
abc9817c66
commit
d64e81c866
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Win32Interop;
|
||||
|
||||
namespace Flowframes.Extensions
|
||||
{
|
||||
public static class ProcessExtensions
|
||||
{
|
||||
[Flags]
|
||||
public enum ThreadAccess : int
|
||||
{
|
||||
TERMINATE = (0x0001),
|
||||
SUSPEND_RESUME = (0x0002),
|
||||
GET_CONTEXT = (0x0008),
|
||||
SET_CONTEXT = (0x0010),
|
||||
SET_INFORMATION = (0x0020),
|
||||
QUERY_INFORMATION = (0x0040),
|
||||
SET_THREAD_TOKEN = (0x0080),
|
||||
IMPERSONATE = (0x0100),
|
||||
DIRECT_IMPERSONATION = (0x0200)
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
static extern IntPtr OpenThread(ThreadAccess dwDesiredAccess, bool bInheritHandle, uint dwThreadId);
|
||||
[DllImport("kernel32.dll")]
|
||||
static extern uint SuspendThread(IntPtr hThread);
|
||||
[DllImport("kernel32.dll")]
|
||||
static extern int ResumeThread(IntPtr hThread);
|
||||
|
||||
public static void Suspend(this Process process)
|
||||
{
|
||||
foreach (ProcessThread thread in process.Threads)
|
||||
{
|
||||
var pOpenThread = OpenThread(ThreadAccess.SUSPEND_RESUME, false, (uint)thread.Id);
|
||||
|
||||
if (pOpenThread == IntPtr.Zero)
|
||||
break;
|
||||
|
||||
SuspendThread(pOpenThread);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Resume(this Process process)
|
||||
{
|
||||
foreach (ProcessThread thread in process.Threads)
|
||||
{
|
||||
var pOpenThread = OpenThread(ThreadAccess.SUSPEND_RESUME, false, (uint)thread.Id);
|
||||
|
||||
if (pOpenThread == IntPtr.Zero)
|
||||
break;
|
||||
|
||||
ResumeThread(pOpenThread);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -329,6 +329,7 @@
|
|||
<Compile Include="Data\PseudoUniqueFile.cs" />
|
||||
<Compile Include="Data\ResumeState.cs" />
|
||||
<Compile Include="Data\SubtitleTrack.cs" />
|
||||
<Compile Include="Extensions\ProcessExtensions.cs" />
|
||||
<Compile Include="Forms\BatchForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -377,7 +378,7 @@
|
|||
<Compile Include="MiscUtils\Benchmarker.cs" />
|
||||
<Compile Include="MiscUtils\FrameRename.cs" />
|
||||
<Compile Include="OS\AiProcess.cs" />
|
||||
<Compile Include="ExtensionMethods.cs" />
|
||||
<Compile Include="Extensions\ExtensionMethods.cs" />
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -392,6 +393,7 @@
|
|||
<Compile Include="IO\Logger.cs" />
|
||||
<Compile Include="Magick\Converter.cs" />
|
||||
<Compile Include="Magick\Dedupe.cs" />
|
||||
<Compile Include="OS\AiProcessSuspend.cs" />
|
||||
<Compile Include="OS\NvApi.cs" />
|
||||
<Compile Include="OS\OSUtils.cs" />
|
||||
<Compile Include="OS\Python.cs" />
|
||||
|
@ -461,6 +463,9 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="FlowframesLogo2021.ico" />
|
||||
<None Include="Resources\baseline_play_arrow_white_48dp.png" />
|
||||
<None Include="Resources\baseline_pause_white_48dp.png" />
|
||||
<None Include="Resources\baseline_stop_white_48dp.png" />
|
||||
<None Include="Resources\devmode.bat" />
|
||||
<None Include="Resources\flowframesIcoNew-512px.png" />
|
||||
<None Include="Resources\flowframesIcoNew.png" />
|
||||
|
|
|
@ -78,7 +78,6 @@
|
|||
this.panel14 = new System.Windows.Forms.Panel();
|
||||
this.panel3 = new System.Windows.Forms.Panel();
|
||||
this.longProgBar = new HTAlt.WinForms.HTProgressBar();
|
||||
this.cancelBtn = new System.Windows.Forms.Button();
|
||||
this.mainTabControl = new HTAlt.WinForms.HTTabControl();
|
||||
this.welcomeTab = new System.Windows.Forms.TabPage();
|
||||
this.welcomeLabel2 = new System.Windows.Forms.Label();
|
||||
|
@ -125,6 +124,10 @@
|
|||
this.htButton1 = new HTAlt.WinForms.HTButton();
|
||||
this.runStepBtn = new System.Windows.Forms.Button();
|
||||
this.stepSelector = new System.Windows.Forms.ComboBox();
|
||||
this.busyControlsPanel = new System.Windows.Forms.Panel();
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.cancelBtn = new System.Windows.Forms.Button();
|
||||
this.pauseBtn = new System.Windows.Forms.Button();
|
||||
this.panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
|
||||
|
@ -145,6 +148,8 @@
|
|||
this.previewTab.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.previewPicturebox)).BeginInit();
|
||||
this.abtTab.SuspendLayout();
|
||||
this.busyControlsPanel.SuspendLayout();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// titleLabel
|
||||
|
@ -734,21 +739,6 @@
|
|||
this.longProgBar.Size = new System.Drawing.Size(700, 15);
|
||||
this.longProgBar.TabIndex = 33;
|
||||
//
|
||||
// cancelBtn
|
||||
//
|
||||
this.cancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.cancelBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||
this.cancelBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.cancelBtn.ForeColor = System.Drawing.Color.LightCoral;
|
||||
this.cancelBtn.Location = new System.Drawing.Point(12, 418);
|
||||
this.cancelBtn.Name = "cancelBtn";
|
||||
this.cancelBtn.Size = new System.Drawing.Size(203, 71);
|
||||
this.cancelBtn.TabIndex = 34;
|
||||
this.cancelBtn.Text = "Cancel";
|
||||
this.cancelBtn.UseVisualStyleBackColor = false;
|
||||
this.cancelBtn.Visible = false;
|
||||
this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
|
||||
//
|
||||
// mainTabControl
|
||||
//
|
||||
this.mainTabControl.AllowDrop = true;
|
||||
|
@ -1447,6 +1437,62 @@
|
|||
this.stepSelector.Size = new System.Drawing.Size(203, 24);
|
||||
this.stepSelector.TabIndex = 73;
|
||||
//
|
||||
// busyControlsPanel
|
||||
//
|
||||
this.busyControlsPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||
this.busyControlsPanel.Controls.Add(this.tableLayoutPanel1);
|
||||
this.busyControlsPanel.Location = new System.Drawing.Point(12, 418);
|
||||
this.busyControlsPanel.Name = "busyControlsPanel";
|
||||
this.busyControlsPanel.Size = new System.Drawing.Size(203, 71);
|
||||
this.busyControlsPanel.TabIndex = 74;
|
||||
this.busyControlsPanel.Visible = false;
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.ColumnCount = 2;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 49F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 51F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.pauseBtn, 1, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.cancelBtn, 0, 0);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 1;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(203, 71);
|
||||
this.tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// cancelBtn
|
||||
//
|
||||
this.cancelBtn.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.cancelBtn.BackgroundImage = global::Flowframes.Properties.Resources.baseline_stop_white_48dp;
|
||||
this.cancelBtn.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.cancelBtn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Firebrick;
|
||||
this.cancelBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.cancelBtn.ForeColor = System.Drawing.Color.Firebrick;
|
||||
this.cancelBtn.Location = new System.Drawing.Point(24, 10);
|
||||
this.cancelBtn.Name = "cancelBtn";
|
||||
this.cancelBtn.Size = new System.Drawing.Size(50, 50);
|
||||
this.cancelBtn.TabIndex = 0;
|
||||
this.cancelBtn.UseVisualStyleBackColor = true;
|
||||
this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
|
||||
//
|
||||
// pauseBtn
|
||||
//
|
||||
this.pauseBtn.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.pauseBtn.BackgroundImage = global::Flowframes.Properties.Resources.baseline_pause_white_48dp;
|
||||
this.pauseBtn.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.pauseBtn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.DarkOrange;
|
||||
this.pauseBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.pauseBtn.ForeColor = System.Drawing.Color.DarkOrange;
|
||||
this.pauseBtn.Location = new System.Drawing.Point(126, 10);
|
||||
this.pauseBtn.Name = "pauseBtn";
|
||||
this.pauseBtn.Size = new System.Drawing.Size(50, 50);
|
||||
this.pauseBtn.TabIndex = 1;
|
||||
this.pauseBtn.UseVisualStyleBackColor = true;
|
||||
this.pauseBtn.Visible = false;
|
||||
this.pauseBtn.Click += new System.EventHandler(this.pauseBtn_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
|
@ -1454,7 +1500,7 @@
|
|||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32)))));
|
||||
this.ClientSize = new System.Drawing.Size(934, 501);
|
||||
this.Controls.Add(this.cancelBtn);
|
||||
this.Controls.Add(this.busyControlsPanel);
|
||||
this.Controls.Add(this.runBtn);
|
||||
this.Controls.Add(this.stepSelector);
|
||||
this.Controls.Add(this.runStepBtn);
|
||||
|
@ -1510,6 +1556,8 @@
|
|||
this.previewTab.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.previewPicturebox)).EndInit();
|
||||
this.abtTab.ResumeLayout(false);
|
||||
this.busyControlsPanel.ResumeLayout(false);
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
@ -1556,7 +1604,6 @@
|
|||
private System.Windows.Forms.PictureBox pictureBox3;
|
||||
private System.Windows.Forms.Label label23;
|
||||
private HTAlt.WinForms.HTProgressBar longProgBar;
|
||||
private System.Windows.Forms.Button cancelBtn;
|
||||
private HTAlt.WinForms.HTButton discordBtn;
|
||||
private HTAlt.WinForms.HTButton paypalBtn;
|
||||
private HTAlt.WinForms.HTButton patreonBtn;
|
||||
|
@ -1612,6 +1659,10 @@
|
|||
private System.Windows.Forms.ComboBox mpdecimateMode;
|
||||
private System.Windows.Forms.LinkLabel linkLabel1;
|
||||
private HTAlt.WinForms.HTButton scnDetectTestBtn;
|
||||
private System.Windows.Forms.Panel busyControlsPanel;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private System.Windows.Forms.Button pauseBtn;
|
||||
private System.Windows.Forms.Button cancelBtn;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,13 +68,14 @@ namespace Flowframes
|
|||
{
|
||||
try
|
||||
{
|
||||
await Task.Delay(100);
|
||||
await StartupChecks.SymlinksCheck();
|
||||
await Updater.UpdateModelList(); // Update AI model list
|
||||
await Updater.AsyncUpdateCheck(); // Check for Flowframes updates
|
||||
await GetWebInfo.LoadNews(newsLabel); // Loads news/MOTD
|
||||
await GetWebInfo.LoadPatronListCsv(patronsLabel); // Load patron list
|
||||
//await Task.Delay(100);
|
||||
Task.Run(() => Updater.UpdateModelList());
|
||||
Task.Run(() => Updater.AsyncUpdateCheck());
|
||||
Task.Run(() => GetWebInfo.LoadNews(newsLabel));
|
||||
Task.Run(() => GetWebInfo.LoadPatronListCsv(patronsLabel));
|
||||
await Python.CheckCompression();
|
||||
await StartupChecks.SymlinksCheck();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -106,6 +107,7 @@ namespace Flowframes
|
|||
|
||||
public HTTabControl GetMainTabControl() { return mainTabControl; }
|
||||
public TextBox GetInputFpsTextbox () { return fpsInTbox; }
|
||||
public Button GetPauseBtn() { return pauseBtn; }
|
||||
|
||||
public bool IsInFocus() { return (ActiveForm == this); }
|
||||
|
||||
|
@ -223,6 +225,7 @@ namespace Flowframes
|
|||
if (!BatchProcessing.busy) // Don't load values from gui if batch processing is used
|
||||
Interpolate.current = GetCurrentSettings();
|
||||
|
||||
AiProcessSuspend.Reset();
|
||||
Interpolate.Start();
|
||||
}
|
||||
|
||||
|
@ -324,12 +327,15 @@ namespace Flowframes
|
|||
Control[] controlsToDisable = new Control[] { runBtn, runStepBtn, stepSelector, settingsBtn };
|
||||
Control[] controlsToHide = new Control[] { runBtn, runStepBtn, stepSelector };
|
||||
progressCircle.Visible = state;
|
||||
cancelBtn.Visible = state;
|
||||
busyControlsPanel.Visible = state;
|
||||
|
||||
foreach (Control c in controlsToDisable)
|
||||
c.Enabled = !state;
|
||||
|
||||
foreach (Control c in controlsToHide)
|
||||
c.Visible = !state;
|
||||
cancelBtn.Enabled = allowCancel;
|
||||
|
||||
busyControlsPanel.Enabled = allowCancel;
|
||||
Program.busy = state;
|
||||
Program.mainForm.UpdateStepByStepControls();
|
||||
}
|
||||
|
@ -399,8 +405,13 @@ namespace Flowframes
|
|||
|
||||
private void cancelBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetTab("interpolation");
|
||||
Interpolate.Cancel();
|
||||
DialogResult dialog = MessageBox.Show($"Are you sure you want to cancel the interpolation?", "Are you sure?", MessageBoxButtons.YesNo);
|
||||
|
||||
if (dialog == DialogResult.Yes)
|
||||
{
|
||||
SetTab("interpolation");
|
||||
Interpolate.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void discordBtn_Click(object sender, EventArgs e)
|
||||
|
@ -550,5 +561,10 @@ namespace Flowframes
|
|||
{
|
||||
Magick.SceneDetect.RunSceneDetection(inputTbox.Text.Trim());
|
||||
}
|
||||
|
||||
private void pauseBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
AiProcessSuspend.SuspendResumeAi(!AiProcessSuspend.aiProcFrozen);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -747,7 +747,7 @@ namespace Flowframes.IO
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"OverwriteWithText failed for '{path}': {e.Message}");
|
||||
Logger.Log($"OverwriteWithText failed for '{path}': {e.Message}", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
using Flowframes.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Flowframes.OS;
|
||||
using Flowframes.UI;
|
||||
using Flowframes.Main;
|
||||
using Flowframes.Data;
|
||||
using Flowframes.MiscUtils;
|
||||
using Flowframes.Magick;
|
||||
using Flowframes.Media;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Flowframes
|
||||
{
|
||||
|
@ -35,6 +30,7 @@ namespace Flowframes
|
|||
|
||||
try
|
||||
{
|
||||
AiProcessSuspend.SetRunning(false);
|
||||
OSUtils.KillProcessTree(lastAiProcess.Id);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -48,13 +44,14 @@ namespace Flowframes
|
|||
lastStartupTimeMs = startupTimeMs;
|
||||
processTime.Restart();
|
||||
lastAiProcess = proc;
|
||||
AiProcessSuspend.SetRunning(true);
|
||||
lastInPath = string.IsNullOrWhiteSpace(inPath) ? Interpolate.current.framesFolder : inPath;
|
||||
hasShownError = false;
|
||||
}
|
||||
|
||||
static void SetProgressCheck(string interpPath, float factor)
|
||||
{
|
||||
int frames = IOUtils.GetAmountOfFiles(lastInPath, false, "*.*");
|
||||
int frames = IOUtils.GetAmountOfFiles(lastInPath, false);
|
||||
int target = ((frames * factor) - (factor - 1)).RoundToInt();
|
||||
InterpolationProgress.progressPaused = false;
|
||||
InterpolationProgress.currentFactor = factor;
|
||||
|
@ -69,6 +66,7 @@ namespace Flowframes
|
|||
{
|
||||
if (Interpolate.canceled) return;
|
||||
Program.mainForm.SetProgress(100);
|
||||
AiProcessSuspend.SetRunning(false);
|
||||
InterpolationProgress.UpdateInterpProgress(IOUtils.GetAmountOfFiles(Interpolate.current.interpFolder, false, "*" + Interpolate.current.interpExt), InterpolationProgress.targetFrames);
|
||||
string logStr = $"Done running {aiName} - Interpolation took {FormatUtils.Time(processTime.Elapsed)}. Peak Output FPS: {InterpolationProgress.peakFpsOut.ToString("0.00")}";
|
||||
|
||||
|
@ -164,7 +162,7 @@ namespace Flowframes
|
|||
}
|
||||
|
||||
rifePy.Start();
|
||||
|
||||
|
||||
if (!OSUtils.ShowHiddenCmd())
|
||||
{
|
||||
rifePy.BeginOutputReadLine();
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
using Flowframes.Extensions;
|
||||
using Flowframes.Properties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Flowframes.OS
|
||||
{
|
||||
class AiProcessSuspend
|
||||
{
|
||||
public static bool aiProcFrozen;
|
||||
static List<Process> suspendedProcesses = new List<Process>();
|
||||
public static bool isRunning;
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
SetRunning(false);
|
||||
SetPauseButtonStyle(false);
|
||||
}
|
||||
|
||||
public static void SetRunning (bool running)
|
||||
{
|
||||
isRunning = running;
|
||||
Program.mainForm.GetPauseBtn().Visible = running;
|
||||
}
|
||||
|
||||
public static void SuspendResumeAi(bool freeze, bool excludeCmd = true)
|
||||
{
|
||||
if (AiProcess.lastAiProcess == null || AiProcess.lastAiProcess.HasExited)
|
||||
return;
|
||||
|
||||
Process currProcess = AiProcess.lastAiProcess;
|
||||
Logger.Log($"{(freeze ? "Suspending" : "Resuming")} main process ({currProcess.StartInfo.FileName} {currProcess.StartInfo.Arguments})", true);
|
||||
|
||||
if (freeze)
|
||||
{
|
||||
List<Process> procs = new List<Process>();
|
||||
procs.Add(currProcess);
|
||||
|
||||
foreach (var subProc in OSUtils.GetChildProcesses(currProcess))
|
||||
procs.Add(subProc);
|
||||
|
||||
aiProcFrozen = true;
|
||||
SetPauseButtonStyle(true);
|
||||
AiProcess.processTime.Stop();
|
||||
|
||||
foreach (Process process in procs)
|
||||
{
|
||||
if (process == null || process.HasExited)
|
||||
continue;
|
||||
|
||||
if (excludeCmd && (process.ProcessName == "conhost" || process.ProcessName == "cmd"))
|
||||
continue;
|
||||
|
||||
Logger.Log($"Suspending {process.ProcessName}", true);
|
||||
|
||||
process.Suspend();
|
||||
suspendedProcesses.Add(process);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aiProcFrozen = false;
|
||||
SetPauseButtonStyle(false);
|
||||
AiProcess.processTime.Start();
|
||||
|
||||
foreach (Process process in new List<Process>(suspendedProcesses)) // We MUST clone the list here since we modify it in the loop!
|
||||
{
|
||||
if (process == null || process.HasExited)
|
||||
continue;
|
||||
|
||||
Logger.Log($"Resuming {process.ProcessName}", true);
|
||||
|
||||
process.Resume();
|
||||
suspendedProcesses.Remove(process);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetPauseButtonStyle (bool paused)
|
||||
{
|
||||
System.Windows.Forms.Button btn = Program.mainForm.GetPauseBtn();
|
||||
|
||||
if (paused)
|
||||
{
|
||||
btn.BackgroundImage = Resources.baseline_play_arrow_white_48dp;
|
||||
btn.FlatAppearance.BorderColor = System.Drawing.Color.MediumSeaGreen;
|
||||
btn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.MediumSeaGreen;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn.BackgroundImage = Resources.baseline_pause_white_48dp;
|
||||
btn.FlatAppearance.BorderColor= System.Drawing.Color.DarkOrange;
|
||||
btn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.DarkOrange;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ using Flowframes.IO;
|
|||
using DiskDetector;
|
||||
using DiskDetector.Models;
|
||||
using Microsoft.VisualBasic.Devices;
|
||||
using Flowframes.Extensions;
|
||||
|
||||
namespace Flowframes.OS
|
||||
{
|
||||
|
@ -124,7 +125,7 @@ namespace Flowframes.OS
|
|||
return (Encoding.UTF8.GetByteCount(str) != str.Length);
|
||||
}
|
||||
|
||||
public static int GetFreeRamMb ()
|
||||
public static int GetFreeRamMb()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -155,5 +156,18 @@ namespace Flowframes.OS
|
|||
|
||||
return info;
|
||||
}
|
||||
|
||||
public static IEnumerable<Process> GetChildProcesses(Process process)
|
||||
{
|
||||
List<Process> children = new List<Process>();
|
||||
ManagementObjectSearcher mos = new ManagementObjectSearcher(String.Format("Select * From Win32_Process Where ParentProcessID={0}", process.Id));
|
||||
|
||||
foreach (ManagementObject mo in mos.Get())
|
||||
{
|
||||
children.Add(Process.GetProcessById(Convert.ToInt32(mo["ProcessID"])));
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -120,6 +120,26 @@ namespace Flowframes.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap baseline_pause_white_48dp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("baseline_pause_white_48dp", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap baseline_play_arrow_white_48dp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("baseline_play_arrow_white_48dp", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
@ -140,6 +160,16 @@ namespace Flowframes.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap baseline_stop_white_48dp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("baseline_stop_white_48dp", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
|
|
@ -133,12 +133,12 @@
|
|||
<data name="paypal256px" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\paypal256px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="flowframesIcoNew_512px" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\flowframesIcoNew-512px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="baseline_system_update_alt_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\baseline_system_update_alt_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="patreon256px" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\patreon256px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="questmark-72px-bordeer" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\questmark-72px-bordeer.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
@ -157,22 +157,31 @@
|
|||
<data name="separatorTest1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\separatorTest1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="baseline_stop_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\baseline_stop_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="devmode" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\devmode.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
<data name="baseline_pause_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\baseline_pause_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="baseline_image_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\baseline_image_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="baseline_create_white_18dp-semiTransparent" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\baseline_create_white_18dp-semiTransparent.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="patreon256px" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\patreon256px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="baseline_settings_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\baseline_settings_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="baseline_image_white_48dp-4x-25pcAlpha" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\baseline_image_white_48dp-4x-25pcAlpha.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="flowframesIcoNew_512px" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\flowframesIcoNew-512px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="devmode" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\devmode.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
<data name="baseline_play_arrow_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\baseline_play_arrow_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
Binary file not shown.
After Width: | Height: | Size: 94 B |
Binary file not shown.
After Width: | Height: | Size: 322 B |
Binary file not shown.
After Width: | Height: | Size: 95 B |
Binary file not shown.
After Width: | Height: | Size: 94 B |
Binary file not shown.
After Width: | Height: | Size: 322 B |
Binary file not shown.
After Width: | Height: | Size: 95 B |
Loading…
Reference in New Issue