#2144: Work in progress simple actions edit window

This commit is contained in:
Jaex 2016-12-29 21:17:16 +03:00
parent 8aa7f4ea6d
commit b9f8407ea3
9 changed files with 414 additions and 0 deletions

View file

@ -233,6 +233,7 @@ private void InitializeComponent()
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Window;
this.Controls.Add(this.btnOK);
this.Controls.Add(this.flpProperties);
this.Controls.Add(this.txtInput);

View file

@ -0,0 +1,114 @@
namespace ShareX
{
partial class SimpleActionsEditForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.btnRemove = new System.Windows.Forms.Button();
this.btnAdd = new ShareX.HelpersLib.MenuButton();
this.cmsAction = new System.Windows.Forms.ContextMenuStrip(this.components);
this.lvActions = new ShareX.HelpersLib.MyListView();
this.chAction = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.ilMain = new System.Windows.Forms.ImageList(this.components);
this.SuspendLayout();
//
// btnRemove
//
this.btnRemove.Location = new System.Drawing.Point(128, 8);
this.btnRemove.Name = "btnRemove";
this.btnRemove.Size = new System.Drawing.Size(112, 23);
this.btnRemove.TabIndex = 1;
this.btnRemove.Text = "Remove";
this.btnRemove.UseVisualStyleBackColor = true;
this.btnRemove.Click += new System.EventHandler(this.btnRemove_Click);
//
// btnAdd
//
this.btnAdd.Location = new System.Drawing.Point(8, 8);
this.btnAdd.Menu = this.cmsAction;
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(115, 23);
this.btnAdd.TabIndex = 2;
this.btnAdd.Text = "Add";
this.btnAdd.UseVisualStyleBackColor = true;
//
// cmsAction
//
this.cmsAction.Name = "cmsAction";
this.cmsAction.Size = new System.Drawing.Size(61, 4);
//
// lvActions
//
this.lvActions.AutoFillColumn = true;
this.lvActions.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.chAction});
this.lvActions.FullRowSelect = true;
this.lvActions.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.lvActions.Location = new System.Drawing.Point(8, 40);
this.lvActions.Name = "lvActions";
this.lvActions.Size = new System.Drawing.Size(448, 368);
this.lvActions.SmallImageList = this.ilMain;
this.lvActions.TabIndex = 3;
this.lvActions.UseCompatibleStateImageBehavior = false;
this.lvActions.View = System.Windows.Forms.View.Details;
//
// chAction
//
this.chAction.Width = 435;
//
// ilMain
//
this.ilMain.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
this.ilMain.ImageSize = new System.Drawing.Size(16, 16);
this.ilMain.TransparentColor = System.Drawing.Color.Transparent;
//
// SimpleActionsEditForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Window;
this.ClientSize = new System.Drawing.Size(466, 417);
this.Controls.Add(this.lvActions);
this.Controls.Add(this.btnAdd);
this.Controls.Add(this.btnRemove);
this.Name = "SimpleActionsEditForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ShareX - Simple actions edit";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button btnRemove;
private HelpersLib.MenuButton btnAdd;
private System.Windows.Forms.ContextMenuStrip cmsAction;
private HelpersLib.MyListView lvActions;
private System.Windows.Forms.ColumnHeader chAction;
private System.Windows.Forms.ImageList ilMain;
}
}

View file

@ -0,0 +1,146 @@
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
Copyright (c) 2007-2016 ShareX Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/
#endregion License Information (GPL v3)
using ShareX.HelpersLib;
using ShareX.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ShareX
{
public partial class SimpleActionsEditForm : Form
{
public List<HotkeyType> Actions { get; private set; }
public SimpleActionsEditForm(List<HotkeyType> actions)
{
InitializeComponent();
Icon = ShareXResources.Icon;
Actions = actions;
foreach (HotkeyType hotkeyType in Helpers.GetEnums<HotkeyType>())
{
Image img;
if (hotkeyType == HotkeyType.None)
{
img = Resources.ui_splitter;
}
else
{
img = TaskHelpers.GetHotkeyTypeIcon(hotkeyType);
}
ilMain.Images.Add(hotkeyType.ToString(), img);
}
AddEnumItemsContextMenu(x =>
{
AddActionToList(x);
}, cmsAction);
foreach (HotkeyType action in Actions)
{
AddActionToList(action);
}
}
private void AddEnumItemsContextMenu(Action<HotkeyType> selectedEnum, params ToolStripDropDown[] parents)
{
EnumInfo[] enums = Helpers.GetEnums<HotkeyType>().OfType<Enum>().Select(x => new EnumInfo(x)).ToArray();
foreach (ToolStripDropDown parent in parents)
{
foreach (EnumInfo enumInfo in enums)
{
HotkeyType hotkeyType = (HotkeyType)Enum.ToObject(typeof(HotkeyType), enumInfo.Value);
Image img;
if (hotkeyType == HotkeyType.None)
{
img = Resources.ui_splitter;
}
else
{
img = TaskHelpers.GetHotkeyTypeIcon(hotkeyType);
}
ToolStripMenuItem tsmi = new ToolStripMenuItem(enumInfo.Description.Replace("&", "&&"));
tsmi.Image = img;
tsmi.Tag = enumInfo;
tsmi.Click += (sender, e) =>
{
selectedEnum(hotkeyType);
};
if (!string.IsNullOrEmpty(enumInfo.Category))
{
ToolStripMenuItem tsmiParent = parent.Items.OfType<ToolStripMenuItem>().FirstOrDefault(x => x.Text == enumInfo.Category);
if (tsmiParent == null)
{
tsmiParent = new ToolStripMenuItem(enumInfo.Category);
parent.Items.Add(tsmiParent);
}
tsmiParent.DropDownItems.Add(tsmi);
}
else
{
parent.Items.Add(tsmi);
}
}
}
}
private void AddActionToList(HotkeyType hotkeyType)
{
ListViewItem lvi = new ListViewItem()
{
Text = hotkeyType.GetLocalizedDescription(),
ImageKey = hotkeyType.ToString()
};
lvActions.Items.Add(lvi);
}
private void btnRemove_Click(object sender, EventArgs e)
{
if (lvActions.SelectedItems.Count > 0)
{
lvActions.Items.Remove(lvActions.SelectedItems[0]);
}
}
}
}

View file

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="cmsAction.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="ilMain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>125, 17</value>
</metadata>
</root>

View file

@ -224,6 +224,10 @@ private void tslTitle_MouseUp(object sender, MouseEventArgs e)
{
Close();
}
else if (e.Button == MouseButtons.Middle)
{
new SimpleActionsEditForm(Actions).Show();
}
}
}
}

View file

@ -2100,6 +2100,16 @@ public class Resources {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap ui_splitter {
get {
object obj = ResourceManager.GetObject("ui_splitter", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View file

@ -870,4 +870,7 @@ Tray icon tasks:
<data name="drive_upload" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\drive-upload.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ui_splitter" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ui-splitter.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: 406 B

View file

@ -204,6 +204,12 @@
<Compile Include="Forms\FirstTimeConfigForm.Designer.cs">
<DependentUpon>FirstTimeConfigForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\SimpleActionsEditForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\SimpleActionsEditForm.Designer.cs">
<DependentUpon>SimpleActionsEditForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\SimpleActionsForm.cs">
<SubType>Form</SubType>
</Compile>
@ -989,6 +995,9 @@
<EmbeddedResource Include="Forms\FirstTimeConfigForm.resx">
<DependentUpon>FirstTimeConfigForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\SimpleActionsEditForm.resx">
<DependentUpon>SimpleActionsEditForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\TaskSettingsForm.de.resx">
<DependentUpon>TaskSettingsForm.cs</DependentUpon>
</EmbeddedResource>
@ -1322,6 +1331,7 @@
<None Include="Resources\Patreon_Button_02.png" />
<None Include="Resources\drive-download.png" />
<None Include="Resources\drive-upload.png" />
<None Include="Resources\ui-splitter.png" />
<Content Include="ShareX_Icon.ico" />
<None Include="Resources\globe--pencil.png" />
<None Include="Resources\camcorder--pencil.png" />