mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-04 04:06:05 +13:00
Dynamic destination changes
This commit is contained in:
parent
73306ffc74
commit
5554acf8b5
2 changed files with 71 additions and 33 deletions
24
ShareX/Forms/BeforeUploadForm.Designer.cs
generated
24
ShareX/Forms/BeforeUploadForm.Designer.cs
generated
|
@ -30,13 +30,14 @@ private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.btnOK = new System.Windows.Forms.Button();
|
this.btnOK = new System.Windows.Forms.Button();
|
||||||
this.btnCancel = new System.Windows.Forms.Button();
|
this.btnCancel = new System.Windows.Forms.Button();
|
||||||
|
this.lblTitle = new System.Windows.Forms.Label();
|
||||||
this.ucBeforeUpload = new ShareX.BeforeUploadControl();
|
this.ucBeforeUpload = new ShareX.BeforeUploadControl();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// btnOK
|
// btnOK
|
||||||
//
|
//
|
||||||
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.btnOK.Location = new System.Drawing.Point(120, 349);
|
this.btnOK.Location = new System.Drawing.Point(240, 349);
|
||||||
this.btnOK.Name = "btnOK";
|
this.btnOK.Name = "btnOK";
|
||||||
this.btnOK.Size = new System.Drawing.Size(75, 23);
|
this.btnOK.Size = new System.Drawing.Size(75, 23);
|
||||||
this.btnOK.TabIndex = 1;
|
this.btnOK.TabIndex = 1;
|
||||||
|
@ -47,7 +48,7 @@ private void InitializeComponent()
|
||||||
// btnCancel
|
// btnCancel
|
||||||
//
|
//
|
||||||
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.btnCancel.Location = new System.Drawing.Point(200, 349);
|
this.btnCancel.Location = new System.Drawing.Point(320, 349);
|
||||||
this.btnCancel.Name = "btnCancel";
|
this.btnCancel.Name = "btnCancel";
|
||||||
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
this.btnCancel.TabIndex = 2;
|
this.btnCancel.TabIndex = 2;
|
||||||
|
@ -55,14 +56,23 @@ private void InitializeComponent()
|
||||||
this.btnCancel.UseVisualStyleBackColor = true;
|
this.btnCancel.UseVisualStyleBackColor = true;
|
||||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||||
//
|
//
|
||||||
|
// lblTitle
|
||||||
|
//
|
||||||
|
this.lblTitle.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.lblTitle.Name = "lblTitle";
|
||||||
|
this.lblTitle.Padding = new System.Windows.Forms.Padding(4);
|
||||||
|
this.lblTitle.Size = new System.Drawing.Size(400, 40);
|
||||||
|
this.lblTitle.TabIndex = 3;
|
||||||
|
this.lblTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
// ucBeforeUpload
|
// ucBeforeUpload
|
||||||
//
|
//
|
||||||
this.ucBeforeUpload.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
this.ucBeforeUpload.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.ucBeforeUpload.Location = new System.Drawing.Point(0, 0);
|
this.ucBeforeUpload.Location = new System.Drawing.Point(0, 48);
|
||||||
this.ucBeforeUpload.Name = "ucBeforeUpload";
|
this.ucBeforeUpload.Name = "ucBeforeUpload";
|
||||||
this.ucBeforeUpload.Size = new System.Drawing.Size(280, 329);
|
this.ucBeforeUpload.Size = new System.Drawing.Size(400, 289);
|
||||||
this.ucBeforeUpload.TabIndex = 0;
|
this.ucBeforeUpload.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// BeforeUploadForm
|
// BeforeUploadForm
|
||||||
|
@ -70,13 +80,14 @@ private void InitializeComponent()
|
||||||
this.AcceptButton = this.btnOK;
|
this.AcceptButton = this.btnOK;
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(284, 381);
|
this.ClientSize = new System.Drawing.Size(404, 381);
|
||||||
|
this.Controls.Add(this.lblTitle);
|
||||||
this.Controls.Add(this.btnCancel);
|
this.Controls.Add(this.btnCancel);
|
||||||
this.Controls.Add(this.btnOK);
|
this.Controls.Add(this.btnOK);
|
||||||
this.Controls.Add(this.ucBeforeUpload);
|
this.Controls.Add(this.ucBeforeUpload);
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.MinimizeBox = false;
|
this.MinimizeBox = false;
|
||||||
this.MinimumSize = new System.Drawing.Size(300, 420);
|
this.MinimumSize = new System.Drawing.Size(420, 420);
|
||||||
this.Name = "BeforeUploadForm";
|
this.Name = "BeforeUploadForm";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "ShareX - Dynamic Destinations";
|
this.Text = "ShareX - Dynamic Destinations";
|
||||||
|
@ -89,5 +100,6 @@ private void InitializeComponent()
|
||||||
private BeforeUploadControl ucBeforeUpload;
|
private BeforeUploadControl ucBeforeUpload;
|
||||||
private System.Windows.Forms.Button btnOK;
|
private System.Windows.Forms.Button btnOK;
|
||||||
private System.Windows.Forms.Button btnCancel;
|
private System.Windows.Forms.Button btnCancel;
|
||||||
|
private System.Windows.Forms.Label lblTitle;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -47,35 +47,23 @@ public BeforeUploadForm(TaskInfo info)
|
||||||
|
|
||||||
Info = info;
|
Info = info;
|
||||||
|
|
||||||
if (info.DataType == EDataType.Image)
|
|
||||||
{
|
|
||||||
Enum.GetValues(typeof(ImageDestination)).Cast<ImageDestination>().ForEach(x =>
|
|
||||||
{
|
|
||||||
if (x != ImageDestination.FileUploader)
|
|
||||||
{
|
|
||||||
AddDestination<ImageDestination>((int)x);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (info.DataType == EDataType.Text)
|
|
||||||
{
|
|
||||||
Enum.GetValues(typeof(TextDestination)).Cast<TextDestination>().ForEach(x =>
|
|
||||||
{
|
|
||||||
if (x != TextDestination.FileUploader)
|
|
||||||
{
|
|
||||||
AddDestination<TextDestination>((int)x);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Enum.GetValues(typeof(FileDestination)).Cast<FileDestination>().ForEach(x =>
|
|
||||||
{
|
|
||||||
AddDestination<FileDestination>((int)x);
|
|
||||||
});
|
|
||||||
|
|
||||||
switch (Info.DataType)
|
switch (Info.DataType)
|
||||||
{
|
{
|
||||||
case EDataType.Image:
|
case EDataType.Image:
|
||||||
|
|
||||||
|
Enum.GetValues(typeof(ImageDestination)).Cast<ImageDestination>().ForEach(x =>
|
||||||
|
{
|
||||||
|
if (x != ImageDestination.FileUploader)
|
||||||
|
{
|
||||||
|
AddDestination<ImageDestination>((int)x);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Enum.GetValues(typeof(FileDestination)).Cast<FileDestination>().ForEach(x =>
|
||||||
|
{
|
||||||
|
AddDestination<FileDestination>((int)x);
|
||||||
|
});
|
||||||
|
|
||||||
ucBeforeUpload.flp.Controls.OfType<RadioButton>().ForEach(x =>
|
ucBeforeUpload.flp.Controls.OfType<RadioButton>().ForEach(x =>
|
||||||
{
|
{
|
||||||
x.Checked = (x.Tag is ImageDestination && (ImageDestination)x.Tag == (ImageDestination)Info.TaskSettings.ImageDestination) ||
|
x.Checked = (x.Tag is ImageDestination && (ImageDestination)x.Tag == (ImageDestination)Info.TaskSettings.ImageDestination) ||
|
||||||
|
@ -83,6 +71,19 @@ public BeforeUploadForm(TaskInfo info)
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case EDataType.Text:
|
case EDataType.Text:
|
||||||
|
Enum.GetValues(typeof(TextDestination)).Cast<TextDestination>().ForEach(x =>
|
||||||
|
{
|
||||||
|
if (x != TextDestination.FileUploader)
|
||||||
|
{
|
||||||
|
AddDestination<TextDestination>((int)x);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Enum.GetValues(typeof(FileDestination)).Cast<FileDestination>().ForEach(x =>
|
||||||
|
{
|
||||||
|
AddDestination<FileDestination>((int)x);
|
||||||
|
});
|
||||||
|
|
||||||
ucBeforeUpload.flp.Controls.OfType<RadioButton>().ForEach(x =>
|
ucBeforeUpload.flp.Controls.OfType<RadioButton>().ForEach(x =>
|
||||||
{
|
{
|
||||||
x.Checked = (x.Tag is TextDestination && (TextDestination)x.Tag == (TextDestination)Info.TaskSettings.ImageDestination) ||
|
x.Checked = (x.Tag is TextDestination && (TextDestination)x.Tag == (TextDestination)Info.TaskSettings.ImageDestination) ||
|
||||||
|
@ -90,12 +91,31 @@ public BeforeUploadForm(TaskInfo info)
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case EDataType.File:
|
case EDataType.File:
|
||||||
|
Enum.GetValues(typeof(FileDestination)).Cast<FileDestination>().ForEach(x =>
|
||||||
|
{
|
||||||
|
AddDestination<FileDestination>((int)x);
|
||||||
|
});
|
||||||
|
|
||||||
ucBeforeUpload.flp.Controls.OfType<RadioButton>().ForEach(x =>
|
ucBeforeUpload.flp.Controls.OfType<RadioButton>().ForEach(x =>
|
||||||
{
|
{
|
||||||
x.Checked = x.Tag is FileDestination && (FileDestination)x.Tag == (FileDestination)Info.TaskSettings.ImageDestination;
|
x.Checked = x.Tag is FileDestination && (FileDestination)x.Tag == (FileDestination)Info.TaskSettings.FileDestination;
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
|
case EDataType.URL:
|
||||||
|
Enum.GetValues(typeof(UrlShortenerType)).Cast<UrlShortenerType>().ForEach(x =>
|
||||||
|
{
|
||||||
|
AddDestination<UrlShortenerType>((int)x);
|
||||||
|
});
|
||||||
|
|
||||||
|
ucBeforeUpload.flp.Controls.OfType<RadioButton>().ForEach(x =>
|
||||||
|
{
|
||||||
|
x.Checked = x.Tag is UrlShortenerType && (UrlShortenerType)x.Tag == (UrlShortenerType)Info.TaskSettings.URLShortenerDestination;
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lblTitle.Text = string.Format("{0} is about to be uploaded to {1}. You may choose a different destination.", info.FileName, ucBeforeUpload.flp.Controls.OfType<RadioButton>().First<RadioButton>(x => x.Checked).Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateUI<T>(int index)
|
private void UpdateUI<T>(int index)
|
||||||
|
@ -151,6 +171,12 @@ private void SetDestinations(bool isActive, object destination)
|
||||||
Info.TaskSettings.FileDestination = (FileDestination)destination;
|
Info.TaskSettings.FileDestination = (FileDestination)destination;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case EDataType.URL:
|
||||||
|
if (destination is UrlShortenerType)
|
||||||
|
{
|
||||||
|
Info.TaskSettings.URLShortenerDestination = (UrlShortenerType)destination;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue