CarotDav_decompile/CarotDAV/ErrorPromptForm.cs

593 lines
18 KiB
C#

// Decompiled with JetBrains decompiler
// Type: CarotDAV.ErrorPromptForm
// Assembly: CarotDAV, Version=1.13.2.18337, Culture=neutral, PublicKeyToken=null
// MVID: C31F2651-A4A8-4D09-916A-8C6106F5E7C8
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\CarotDAV.exe
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
namespace CarotDAV
{
[DesignerGenerated]
public class ErrorPromptForm : Form
{
private IContainer components;
[AccessedThroughProperty("m_CancelButton")]
private Button _m_CancelButton;
[AccessedThroughProperty("IgnoreButton")]
private Button _IgnoreButton;
[AccessedThroughProperty("DescLabel")]
private Label _DescLabel;
[AccessedThroughProperty("IgnoreAllButton")]
private Button _IgnoreAllButton;
[AccessedThroughProperty("MessageLabel")]
private Label _MessageLabel;
[AccessedThroughProperty("DescTextBox")]
private TextBox _DescTextBox;
[AccessedThroughProperty("Label1")]
private Label _Label1;
[AccessedThroughProperty("TargetTextBox")]
private TextBox _TargetTextBox;
[AccessedThroughProperty("Timer1")]
private Timer _Timer1;
[AccessedThroughProperty("RetryButton")]
private Button _RetryButton;
private Exception pEx;
private string pMessage;
private string pTarget;
private ErrorPromptType pType;
private ErrorAction pAction;
private bool pToAll;
private int pRetryMinutes;
private DateTime pIdleStartTime;
public ErrorPromptForm()
{
this.Load += new EventHandler(this.ErrorPromptForm_Load);
this.pMessage = string.Empty;
this.pTarget = string.Empty;
this.InitializeComponent();
}
[DebuggerNonUserCode]
protected override void Dispose(bool disposing)
{
try
{
if (!disposing || this.components == null)
return;
this.components.Dispose();
}
finally
{
base.Dispose(disposing);
}
}
[DebuggerStepThrough]
private void InitializeComponent()
{
this.components = (IContainer) new System.ComponentModel.Container();
this.m_CancelButton = new Button();
this.RetryButton = new Button();
this.IgnoreButton = new Button();
this.DescLabel = new Label();
this.IgnoreAllButton = new Button();
this.MessageLabel = new Label();
this.DescTextBox = new TextBox();
this.Label1 = new Label();
this.TargetTextBox = new TextBox();
this.Timer1 = new Timer(this.components);
this.SuspendLayout();
this.m_CancelButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
this.m_CancelButton.DialogResult = DialogResult.Cancel;
Button mCancelButton1 = this.m_CancelButton;
Point point1 = new Point(288, 152);
Point point2 = point1;
mCancelButton1.Location = point2;
this.m_CancelButton.Name = "m_CancelButton";
Button mCancelButton2 = this.m_CancelButton;
Size size1 = new Size(72, 24);
Size size2 = size1;
mCancelButton2.Size = size2;
this.m_CancelButton.TabIndex = 8;
this.m_CancelButton.Text = "Cancel";
this.m_CancelButton.UseVisualStyleBackColor = true;
this.RetryButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
Button retryButton1 = this.RetryButton;
point1 = new Point(184, 152);
Point point3 = point1;
retryButton1.Location = point3;
this.RetryButton.Name = "RetryButton";
Button retryButton2 = this.RetryButton;
size1 = new Size(96, 24);
Size size3 = size1;
retryButton2.Size = size3;
this.RetryButton.TabIndex = 7;
this.RetryButton.Text = "Retry";
this.RetryButton.UseVisualStyleBackColor = true;
this.IgnoreButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
Button ignoreButton1 = this.IgnoreButton;
point1 = new Point(104, 152);
Point point4 = point1;
ignoreButton1.Location = point4;
this.IgnoreButton.Name = "IgnoreButton";
Button ignoreButton2 = this.IgnoreButton;
size1 = new Size(72, 25);
Size size4 = size1;
ignoreButton2.Size = size4;
this.IgnoreButton.TabIndex = 6;
this.IgnoreButton.Text = "Ignore";
this.IgnoreButton.UseVisualStyleBackColor = true;
this.DescLabel.AutoSize = true;
Label descLabel1 = this.DescLabel;
point1 = new Point(8, 80);
Point point5 = point1;
descLabel1.Location = point5;
this.DescLabel.Name = "DescLabel";
Label descLabel2 = this.DescLabel;
size1 = new Size(65, 12);
Size size5 = size1;
descLabel2.Size = size5;
this.DescLabel.TabIndex = 3;
this.DescLabel.Text = "Description:";
this.IgnoreAllButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
Button ignoreAllButton1 = this.IgnoreAllButton;
point1 = new Point(24, 152);
Point point6 = point1;
ignoreAllButton1.Location = point6;
this.IgnoreAllButton.Name = "IgnoreAllButton";
Button ignoreAllButton2 = this.IgnoreAllButton;
size1 = new Size(72, 24);
Size size6 = size1;
ignoreAllButton2.Size = size6;
this.IgnoreAllButton.TabIndex = 5;
this.IgnoreAllButton.Text = "Ignore All";
this.IgnoreAllButton.UseVisualStyleBackColor = true;
this.MessageLabel.AutoSize = true;
Label messageLabel1 = this.MessageLabel;
point1 = new Point(8, 8);
Point point7 = point1;
messageLabel1.Location = point7;
this.MessageLabel.Name = "MessageLabel";
Label messageLabel2 = this.MessageLabel;
size1 = new Size(79, 12);
Size size7 = size1;
messageLabel2.Size = size7;
this.MessageLabel.TabIndex = 0;
this.MessageLabel.Text = "Error Message";
this.DescTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
TextBox descTextBox1 = this.DescTextBox;
point1 = new Point(8, 96);
Point point8 = point1;
descTextBox1.Location = point8;
this.DescTextBox.Multiline = true;
this.DescTextBox.Name = "DescTextBox";
this.DescTextBox.ReadOnly = true;
TextBox descTextBox2 = this.DescTextBox;
size1 = new Size(352, 48);
Size size8 = size1;
descTextBox2.Size = size8;
this.DescTextBox.TabIndex = 4;
this.DescTextBox.TabStop = false;
this.Label1.AutoSize = true;
Label label1_1 = this.Label1;
point1 = new Point(8, 24);
Point point9 = point1;
label1_1.Location = point9;
this.Label1.Name = "Label1";
Label label1_2 = this.Label1;
size1 = new Size(38, 12);
Size size9 = size1;
label1_2.Size = size9;
this.Label1.TabIndex = 1;
this.Label1.Text = "Target";
this.TargetTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
TextBox targetTextBox1 = this.TargetTextBox;
point1 = new Point(8, 40);
Point point10 = point1;
targetTextBox1.Location = point10;
this.TargetTextBox.Multiline = true;
this.TargetTextBox.Name = "TargetTextBox";
this.TargetTextBox.ReadOnly = true;
TextBox targetTextBox2 = this.TargetTextBox;
size1 = new Size(352, 32);
Size size10 = size1;
targetTextBox2.Size = size10;
this.TargetTextBox.TabIndex = 2;
this.TargetTextBox.TabStop = false;
this.AcceptButton = (IButtonControl) this.RetryButton;
this.AutoScaleDimensions = new SizeF(6f, 12f);
this.AutoScaleMode = AutoScaleMode.Font;
this.CancelButton = (IButtonControl) this.m_CancelButton;
size1 = new Size(368, 184);
this.ClientSize = size1;
this.Controls.Add((Control) this.TargetTextBox);
this.Controls.Add((Control) this.RetryButton);
this.Controls.Add((Control) this.Label1);
this.Controls.Add((Control) this.m_CancelButton);
this.Controls.Add((Control) this.DescTextBox);
this.Controls.Add((Control) this.DescLabel);
this.Controls.Add((Control) this.MessageLabel);
this.Controls.Add((Control) this.IgnoreButton);
this.Controls.Add((Control) this.IgnoreAllButton);
this.MaximizeBox = false;
this.MinimizeBox = false;
size1 = new Size(384, 222);
this.MinimumSize = size1;
this.Name = nameof (ErrorPromptForm);
this.StartPosition = FormStartPosition.CenterParent;
this.Text = "Error";
this.ResumeLayout(false);
this.PerformLayout();
}
internal virtual Button m_CancelButton
{
get
{
return this._m_CancelButton;
}
[MethodImpl(MethodImplOptions.Synchronized)] set
{
EventHandler eventHandler = new EventHandler(this.m_CancelButton_Click);
if (this._m_CancelButton != null)
this._m_CancelButton.Click -= eventHandler;
this._m_CancelButton = value;
if (this._m_CancelButton == null)
return;
this._m_CancelButton.Click += eventHandler;
}
}
internal virtual Button IgnoreButton
{
get
{
return this._IgnoreButton;
}
[MethodImpl(MethodImplOptions.Synchronized)] set
{
EventHandler eventHandler = new EventHandler(this.IgnoreButton_Click);
if (this._IgnoreButton != null)
this._IgnoreButton.Click -= eventHandler;
this._IgnoreButton = value;
if (this._IgnoreButton == null)
return;
this._IgnoreButton.Click += eventHandler;
}
}
internal virtual Label DescLabel
{
get
{
return this._DescLabel;
}
[MethodImpl(MethodImplOptions.Synchronized)] set
{
this._DescLabel = value;
}
}
internal virtual Button IgnoreAllButton
{
get
{
return this._IgnoreAllButton;
}
[MethodImpl(MethodImplOptions.Synchronized)] set
{
EventHandler eventHandler = new EventHandler(this.IgnoreAllButton_Click);
if (this._IgnoreAllButton != null)
this._IgnoreAllButton.Click -= eventHandler;
this._IgnoreAllButton = value;
if (this._IgnoreAllButton == null)
return;
this._IgnoreAllButton.Click += eventHandler;
}
}
internal virtual Label MessageLabel
{
get
{
return this._MessageLabel;
}
[MethodImpl(MethodImplOptions.Synchronized)] set
{
this._MessageLabel = value;
}
}
internal virtual TextBox DescTextBox
{
get
{
return this._DescTextBox;
}
[MethodImpl(MethodImplOptions.Synchronized)] set
{
this._DescTextBox = value;
}
}
internal virtual Label Label1
{
get
{
return this._Label1;
}
[MethodImpl(MethodImplOptions.Synchronized)] set
{
this._Label1 = value;
}
}
internal virtual TextBox TargetTextBox
{
get
{
return this._TargetTextBox;
}
[MethodImpl(MethodImplOptions.Synchronized)] set
{
this._TargetTextBox = value;
}
}
internal virtual Timer Timer1
{
get
{
return this._Timer1;
}
[MethodImpl(MethodImplOptions.Synchronized)] set
{
EventHandler eventHandler = new EventHandler(this.Timer1_Tick);
if (this._Timer1 != null)
this._Timer1.Tick -= eventHandler;
this._Timer1 = value;
if (this._Timer1 == null)
return;
this._Timer1.Tick += eventHandler;
}
}
private virtual Button RetryButton
{
get
{
return this._RetryButton;
}
[MethodImpl(MethodImplOptions.Synchronized)] set
{
EventHandler eventHandler = new EventHandler(this.RetryButton_Click);
if (this._RetryButton != null)
this._RetryButton.Click -= eventHandler;
this._RetryButton = value;
if (this._RetryButton == null)
return;
this._RetryButton.Click += eventHandler;
}
}
public Exception Exception
{
get
{
return this.pEx;
}
set
{
this.pEx = value;
}
}
public string Message
{
get
{
return this.pMessage;
}
set
{
if (value == null)
value = string.Empty;
if (value.Length == 0)
value = "Unknown error occurred.";
this.pMessage = value;
}
}
public string Target
{
get
{
return this.pTarget;
}
set
{
if (value == null)
value = string.Empty;
this.pTarget = value;
}
}
public ErrorPromptType Type
{
get
{
return this.pType;
}
set
{
this.pType = value;
}
}
public ErrorAction Action
{
get
{
return this.pAction;
}
set
{
this.pAction = value;
}
}
public bool ToAll
{
get
{
return this.pToAll;
}
set
{
this.pToAll = value;
}
}
private void ErrorPromptForm_Load(object sender, EventArgs e)
{
this.Icon = CarotDAV.My.Resources.Resources.CarotDAV;
this.MessageLabel.Text = this.pMessage;
this.TargetTextBox.Text = this.pTarget;
this.DescTextBox.Text = this.pEx.ToString();
switch (this.Type)
{
case ErrorPromptType.RetryCancel:
this.IgnoreAllButton.Visible = false;
this.IgnoreButton.Visible = false;
this.RetryButton.Visible = true;
this.m_CancelButton.Visible = true;
break;
case ErrorPromptType.IgnoreCancel:
this.IgnoreAllButton.Visible = false;
this.IgnoreButton.Visible = true;
this.RetryButton.Visible = false;
this.m_CancelButton.Visible = true;
break;
case ErrorPromptType.IgnoreRetryCancel:
this.IgnoreAllButton.Visible = false;
this.IgnoreButton.Visible = true;
this.RetryButton.Visible = true;
this.m_CancelButton.Visible = true;
break;
case ErrorPromptType.IgnoreAllIgnoreCancel:
this.IgnoreAllButton.Visible = true;
this.IgnoreButton.Visible = true;
this.RetryButton.Visible = false;
this.m_CancelButton.Visible = true;
break;
case ErrorPromptType.IgnoreAllIgnoreRetryCancel:
this.IgnoreAllButton.Visible = true;
this.IgnoreButton.Visible = true;
this.RetryButton.Visible = true;
this.m_CancelButton.Visible = true;
break;
default:
throw new NotImplementedException();
}
this.pIdleStartTime = DateTime.MaxValue;
this.Activate();
this.Timer1.Start();
}
private void IgnoreAllButton_Click(object sender, EventArgs e)
{
this.ToAll = true;
this.Action = ErrorAction.Ignore;
this.DialogResult = DialogResult.OK;
}
private void IgnoreButton_Click(object sender, EventArgs e)
{
this.ToAll = false;
this.Action = ErrorAction.Ignore;
this.DialogResult = DialogResult.OK;
}
private void RetryButton_Click(object sender, EventArgs e)
{
this.ToAll = false;
this.Action = ErrorAction.Retry;
this.DialogResult = DialogResult.OK;
}
private void m_CancelButton_Click(object sender, EventArgs e)
{
this.ToAll = false;
this.Action = ErrorAction.Cancel;
this.DialogResult = DialogResult.OK;
}
public static ErrorPromptFormResult ShowDialog(IWin32Window owner, string message, string target, Exception ex, ErrorPromptType type, int retryminutes)
{
ErrorPromptFormResult promptFormResult = new ErrorPromptFormResult();
using (ErrorPromptForm errorPromptForm = new ErrorPromptForm())
{
errorPromptForm.Message = message;
errorPromptForm.Target = target;
errorPromptForm.Exception = ex;
errorPromptForm.Type = type;
errorPromptForm.pRetryMinutes = retryminutes;
int num = (int) errorPromptForm.ShowDialog(owner);
promptFormResult.Action = errorPromptForm.Action;
promptFormResult.ToAll = errorPromptForm.ToAll;
}
return promptFormResult;
}
private void Timer1_Tick(object sender, EventArgs e)
{
if (this.pRetryMinutes < 0)
return;
if ((long) Misc.GetIdleTime() > 600000L)
{
if (DateTime.Compare(this.pIdleStartTime, DateTime.MaxValue) == 0)
this.pIdleStartTime = DateTime.Now;
}
else
{
if (Form.ActiveForm == this)
{
if (DateTime.Compare(this.pIdleStartTime, DateTime.MaxValue) == 0)
return;
this.pIdleStartTime = DateTime.MaxValue;
this.RetryButton.Text = "Retry";
return;
}
if (DateTime.Compare(this.pIdleStartTime, DateTime.MaxValue) == 0)
this.pIdleStartTime = DateTime.Now;
}
if (DateTime.Compare(this.pIdleStartTime, DateTime.MaxValue) == 0)
return;
TimeSpan timeSpan = TimeSpan.FromMinutes((double) this.pRetryMinutes).Subtract(DateTime.Now.Subtract(this.pIdleStartTime));
if (timeSpan.TotalSeconds < 0.0)
{
this.ToAll = false;
this.Action = ErrorAction.AutoRetry;
this.DialogResult = DialogResult.OK;
this.Close();
}
else if (timeSpan.TotalSeconds <= 60.0)
this.RetryButton.Text = string.Format("Retry {0:f0}[s]", (object) timeSpan.TotalSeconds);
else if (timeSpan.TotalMinutes <= 60.0)
this.RetryButton.Text = string.Format("Retry {0:f0}[min]", (object) timeSpan.TotalMinutes);
else if (timeSpan.TotalHours <= 24.0)
this.RetryButton.Text = string.Format("Retry {0:f0}[h]", (object) timeSpan.TotalHours);
else
this.RetryButton.Text = "Retry";
}
}
}