initial commit

This commit is contained in:
what 2021-07-26 13:04:16 -07:00
commit 1b60743303
274 changed files with 25866 additions and 0 deletions

View file

@ -0,0 +1,12 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.UserProcess.AsyncOperationCompletedEventHandler
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
namespace SEGATools.UserProcess
{
public delegate void AsyncOperationCompletedEventHandler(
object sender,
UserProcessCompletedEventArgs e);
}

View file

@ -0,0 +1,11 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.UserProcess.AsyncOperationProgressChangedEventHandler
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
namespace SEGATools.UserProcess
{
public delegate void AsyncOperationProgressChangedEventHandler(
UserProcessProgressChangedEventArgs e);
}

View file

@ -0,0 +1,10 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.UserProcess.AsyncOperationProgressUpdateUIEventHandler
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
namespace SEGATools.UserProcess
{
public delegate void AsyncOperationProgressUpdateUIEventHandler(UserProcessUpdateUIViewEventArgs e);
}

View file

@ -0,0 +1,11 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.UserProcess.AsyncOperationProgressWaitingForUserConsentEventHandler
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
namespace SEGATools.UserProcess
{
public delegate void AsyncOperationProgressWaitingForUserConsentEventHandler(
UserProcessWaitingForUserConsentEventArgs e);
}

View file

@ -0,0 +1,156 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.UserProcess.UserProcessBase
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
using System;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Threading;
namespace SEGATools.UserProcess
{
public class UserProcessBase : Component
{
protected static readonly Logger.ILog logger = Logger.CreateLog();
private HybridDictionary userStateToLifetime = new HybridDictionary();
private Container components;
private SendOrPostCallback onProgressReportDelegate;
private SendOrPostCallback onCompletedDelegate;
private SendOrPostCallback onProgressWaitingForUserConsentDelegate;
private SendOrPostCallback onUpdateUIViewDelegate;
public event AsyncOperationProgressChangedEventHandler AsyncOperationProgressChanged;
public event AsyncOperationCompletedEventHandler AsyncOperationCompleted;
public event AsyncOperationProgressWaitingForUserConsentEventHandler AsyncOperationWaitForUserConsent;
public event AsyncOperationProgressUpdateUIEventHandler AsyncOperationUpdateUIView;
public UserProcessBase(IContainer container)
: this()
=> container.Add((IComponent) this);
public UserProcessBase()
{
this.InitializeComponent();
this.InitializeDelegates();
}
private void InitializeComponent() => this.components = new Container();
protected void InitializeDelegates()
{
this.onProgressReportDelegate = new SendOrPostCallback(this.ProgressReport);
this.onCompletedDelegate = new SendOrPostCallback(this.ProcessCompleted);
this.onProgressWaitingForUserConsentDelegate = new SendOrPostCallback(this.ProcessWaitingForUserConsent);
this.onUpdateUIViewDelegate = new SendOrPostCallback(this.ProcessUpdateUIView);
}
protected override void Dispose(bool disposing)
{
if (disposing && this.components != null)
this.components.Dispose();
base.Dispose(disposing);
}
public void CancelAsync(object taskId)
{
if (!(this.userStateToLifetime[taskId] is AsyncOperation))
return;
lock (this.userStateToLifetime.SyncRoot)
this.userStateToLifetime.Remove(taskId);
}
protected AsyncOperation CreateAsyncOperation(object taskId)
{
AsyncOperation operation = AsyncOperationManager.CreateOperation(taskId);
lock (this.userStateToLifetime.SyncRoot)
{
if (this.userStateToLifetime.Contains(taskId))
throw new ArgumentException("Task ID parameter must be unique", nameof (taskId));
this.userStateToLifetime[taskId] = (object) operation;
}
return operation;
}
protected bool TaskCanceled(AsyncOperation asyncOp) => asyncOp != null && this.userStateToLifetime[asyncOp.UserSuppliedState] == null;
protected void ReportProgress(UserProcessProgressChangedEventArgs e, AsyncOperation asyncOp)
{
asyncOp.Post(this.onProgressReportDelegate, (object) e);
Thread.Sleep(0);
}
protected void ReportCompletion(string Filename, Exception exception, AsyncOperation asyncOp)
{
if (asyncOp == null)
return;
bool canceled = this.RemoveTask(asyncOp);
UserProcessCompletedEventArgs completedEventArgs = new UserProcessCompletedEventArgs(Filename, exception, canceled, asyncOp.UserSuppliedState);
this.EndTask(asyncOp, (object) completedEventArgs);
}
protected bool AskForUserConsent(
UserProcessWaitingForUserConsentEventArgs e,
AsyncOperation asyncOp)
{
asyncOp.Post(this.onProgressWaitingForUserConsentDelegate, (object) e);
e.ResetEvent.WaitOne(-1, true);
return this.TaskCanceled(asyncOp);
}
protected void UpdateUIView(UserProcessUpdateUIViewEventArgs e, AsyncOperation asyncOp) => asyncOp?.Post(this.onUpdateUIViewDelegate, (object) e);
private bool RemoveTask(AsyncOperation asyncOp)
{
bool flag = this.TaskCanceled(asyncOp);
if (!flag)
{
lock (this.userStateToLifetime.SyncRoot)
this.userStateToLifetime.Remove(asyncOp.UserSuppliedState);
}
return flag;
}
private void EndTask(AsyncOperation asyncOp, object SendOrPostCallbackArg) => asyncOp.PostOperationCompleted(this.onCompletedDelegate, SendOrPostCallbackArg);
private void ProgressReport(object operationState) => this.OnProgressChanged(operationState as UserProcessProgressChangedEventArgs);
private void ProcessCompleted(object operationState) => this.OnProgressCompleted(operationState as UserProcessCompletedEventArgs);
private void ProcessWaitingForUserConsent(object operationState) => this.OnProgressWaitingForUserConsent(operationState as UserProcessWaitingForUserConsentEventArgs);
private void ProcessUpdateUIView(object operationState) => this.OnProgressUpdateUIView(operationState as UserProcessUpdateUIViewEventArgs);
private void OnProgressChanged(UserProcessProgressChangedEventArgs e)
{
if (this.AsyncOperationProgressChanged == null)
return;
this.AsyncOperationProgressChanged(e);
}
private void OnProgressCompleted(UserProcessCompletedEventArgs e)
{
if (this.AsyncOperationCompleted == null)
return;
this.AsyncOperationCompleted((object) this, e);
}
private void OnProgressWaitingForUserConsent(UserProcessWaitingForUserConsentEventArgs e)
{
if (this.AsyncOperationWaitForUserConsent == null)
return;
this.AsyncOperationWaitForUserConsent(e);
}
private void OnProgressUpdateUIView(UserProcessUpdateUIViewEventArgs e)
{
if (this.AsyncOperationUpdateUIView == null)
return;
this.AsyncOperationUpdateUIView(e);
}
}
}

View file

@ -0,0 +1,26 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.UserProcess.UserProcessCompletedEventArgs
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
using System;
using System.ComponentModel;
namespace SEGATools.UserProcess
{
public class UserProcessCompletedEventArgs : AsyncCompletedEventArgs
{
public string ResourceName { get; private set; }
public UserProcessCompletedEventArgs(
string resourceName,
Exception e,
bool canceled,
object state)
: base(e, canceled, state)
{
this.ResourceName = resourceName;
}
}
}

View file

@ -0,0 +1,49 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.UserProcess.UserProcessProgressChangedEventArgs
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
using System.ComponentModel;
namespace SEGATools.UserProcess
{
public class UserProcessProgressChangedEventArgs : ProgressChangedEventArgs
{
public int TotalProgressPercentage { get; private set; }
public string Input { get; private set; }
public string Output { get; private set; }
public UserProcessProgressChangedEventArgs(
string inputOrOutput,
int progressPercentage,
object userToken)
: this(inputOrOutput, inputOrOutput, progressPercentage, progressPercentage, userToken)
{
}
public UserProcessProgressChangedEventArgs(
string input,
string output,
int progressPercentage,
object userToken)
: this(input, output, progressPercentage, progressPercentage, userToken)
{
}
public UserProcessProgressChangedEventArgs(
string input,
string output,
int progressPercentage,
int totalProgressPercentage,
object userToken)
: base(progressPercentage, userToken)
{
this.Input = input;
this.Output = output;
this.TotalProgressPercentage = totalProgressPercentage;
}
}
}

View file

@ -0,0 +1,55 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.UserProcess.UserProcessUpdateUIViewEventArgs
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
using System;
namespace SEGATools.UserProcess
{
public class UserProcessUpdateUIViewEventArgs : EventArgs
{
public UserProcessUpdateUIViewEventArgs.UserProgressUIStyle UIStyle { get; private set; }
public string InputTitleResourceName { get; private set; }
public bool UpdateInputTitle { get; private set; }
public bool ShowInputText { get; private set; }
public UserProcessUpdateUIViewEventArgs(
UserProcessUpdateUIViewEventArgs.UserProgressUIStyle userProgressUIStyle,
bool showInputText)
{
this.UIStyle = userProgressUIStyle;
this.UpdateInputTitle = false;
this.ShowInputText = showInputText;
}
public UserProcessUpdateUIViewEventArgs(
UserProcessUpdateUIViewEventArgs.UserProgressUIStyle userProgressUIStyle,
string newInputTitleResourceName,
bool showInputText)
{
this.UIStyle = userProgressUIStyle;
this.InputTitleResourceName = newInputTitleResourceName;
this.UpdateInputTitle = true;
this.ShowInputText = showInputText;
}
public static UserProcessUpdateUIViewEventArgs OneProgressBarWithoutPercentage(
string newInputTitleResourceName,
bool showInputText)
{
return new UserProcessUpdateUIViewEventArgs(UserProcessUpdateUIViewEventArgs.UserProgressUIStyle.OneProgressBarWithoutPercentage, newInputTitleResourceName, showInputText);
}
public enum UserProgressUIStyle
{
OneProgressBarWithPercentage,
OneProgressBarWithoutPercentage,
TwoProgressBarsWithPercentage,
}
}
}

View file

@ -0,0 +1,39 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.UserProcess.UserProcessWaitingForUserConsentEventArgs
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
using System;
using System.Threading;
namespace SEGATools.UserProcess
{
public abstract class UserProcessWaitingForUserConsentEventArgs : EventArgs
{
public string QuestionTitleResourceName { get; private set; }
public string QuestionContentResourceName { get; private set; }
public string[] QuestionContentArgs { get; private set; }
public bool HasStringArguments => this.QuestionContentArgs != null && this.QuestionContentArgs.Length > 0;
public object UserState { get; private set; }
public ManualResetEvent ResetEvent { get; private set; }
public UserProcessWaitingForUserConsentEventArgs(
string questionTitleResourceName,
string questionContentResourceName,
string[] questionContentArgs,
object state)
{
this.QuestionTitleResourceName = questionTitleResourceName;
this.QuestionContentResourceName = questionContentResourceName;
this.QuestionContentArgs = questionContentArgs;
this.UserState = state;
this.ResetEvent = new ManualResetEvent(false);
}
}
}

View file

@ -0,0 +1,21 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.UserProcess.UserProcessWaitingForUserConsentFileConflictEventArgs
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
namespace SEGATools.UserProcess
{
public class UserProcessWaitingForUserConsentFileConflictEventArgs :
UserProcessWaitingForUserConsentEventArgs
{
public UserProcessWaitingForUserConsentFileConflictEventArgs(
string questionTitleResourceName,
string questionContentResourceName,
string[] questionContentArgs,
object state)
: base(questionTitleResourceName, questionContentResourceName, questionContentArgs, state)
{
}
}
}