Added BootstrapFile properties dialog

This commit is contained in:
Michael Becker 2015-04-21 11:00:44 -04:00
parent 62808289ec
commit ccd48a4510
6 changed files with 460 additions and 0 deletions

View File

@ -0,0 +1,140 @@
namespace UniversalEditor.Dialogs.Setup.Microsoft.ACME.BootstrapScript
{
partial class BootstrapFilePropertiesDialogImpl
{
/// <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.cmdBrowseSourceFileName = new System.Windows.Forms.Button();
this.txtSourceFileName = new System.Windows.Forms.TextBox();
this.cmdBrowseDestinationFileName = new System.Windows.Forms.Button();
this.txtDestinationFileName = new System.Windows.Forms.TextBox();
this.cmdCancel = new System.Windows.Forms.Button();
this.cmdOK = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// cmdBrowseSourceFileName
//
this.cmdBrowseSourceFileName.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cmdBrowseSourceFileName.Location = new System.Drawing.Point(12, 12);
this.cmdBrowseSourceFileName.Name = "cmdBrowseSourceFileName";
this.cmdBrowseSourceFileName.Size = new System.Drawing.Size(125, 23);
this.cmdBrowseSourceFileName.TabIndex = 0;
this.cmdBrowseSourceFileName.Text = "&Source file name:";
this.cmdBrowseSourceFileName.UseVisualStyleBackColor = true;
this.cmdBrowseSourceFileName.Click += new System.EventHandler(this.cmdBrowseSourceFileName_Click);
//
// txtSourceFileName
//
this.txtSourceFileName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtSourceFileName.HideSelection = false;
this.txtSourceFileName.Location = new System.Drawing.Point(143, 14);
this.txtSourceFileName.Name = "txtSourceFileName";
this.txtSourceFileName.Size = new System.Drawing.Size(241, 20);
this.txtSourceFileName.TabIndex = 1;
//
// cmdBrowseDestinationFileName
//
this.cmdBrowseDestinationFileName.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cmdBrowseDestinationFileName.Location = new System.Drawing.Point(12, 41);
this.cmdBrowseDestinationFileName.Name = "cmdBrowseDestinationFileName";
this.cmdBrowseDestinationFileName.Size = new System.Drawing.Size(125, 23);
this.cmdBrowseDestinationFileName.TabIndex = 2;
this.cmdBrowseDestinationFileName.Text = "&Destination file name:";
this.cmdBrowseDestinationFileName.UseVisualStyleBackColor = true;
this.cmdBrowseDestinationFileName.Click += new System.EventHandler(this.cmdBrowseDestinationFileName_Click);
//
// txtDestinationFileName
//
this.txtDestinationFileName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtDestinationFileName.HideSelection = false;
this.txtDestinationFileName.Location = new System.Drawing.Point(143, 43);
this.txtDestinationFileName.Name = "txtDestinationFileName";
this.txtDestinationFileName.Size = new System.Drawing.Size(241, 20);
this.txtDestinationFileName.TabIndex = 3;
//
// cmdCancel
//
this.cmdCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cmdCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cmdCancel.Location = new System.Drawing.Point(309, 69);
this.cmdCancel.Name = "cmdCancel";
this.cmdCancel.Size = new System.Drawing.Size(75, 23);
this.cmdCancel.TabIndex = 5;
this.cmdCancel.Text = "&Cancel";
this.cmdCancel.UseVisualStyleBackColor = true;
this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click);
//
// cmdOK
//
this.cmdOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cmdOK.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cmdOK.Location = new System.Drawing.Point(228, 69);
this.cmdOK.Name = "cmdOK";
this.cmdOK.Size = new System.Drawing.Size(75, 23);
this.cmdOK.TabIndex = 4;
this.cmdOK.Text = "&OK";
this.cmdOK.UseVisualStyleBackColor = true;
this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click);
//
// BootstrapFilePropertiesDialogImpl
//
this.AcceptButton = this.cmdOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cmdCancel;
this.ClientSize = new System.Drawing.Size(396, 104);
this.Controls.Add(this.cmdOK);
this.Controls.Add(this.cmdCancel);
this.Controls.Add(this.txtDestinationFileName);
this.Controls.Add(this.txtSourceFileName);
this.Controls.Add(this.cmdBrowseDestinationFileName);
this.Controls.Add(this.cmdBrowseSourceFileName);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(412, 142);
this.Name = "BootstrapFilePropertiesDialogImpl";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Bootstrap File Properties";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button cmdBrowseSourceFileName;
private System.Windows.Forms.Button cmdBrowseDestinationFileName;
private System.Windows.Forms.Button cmdCancel;
private System.Windows.Forms.Button cmdOK;
internal System.Windows.Forms.TextBox txtSourceFileName;
internal System.Windows.Forms.TextBox txtDestinationFileName;
}
}

View File

@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace UniversalEditor.Dialogs.Setup.Microsoft.ACME.BootstrapScript
{
public partial class BootstrapFilePropertiesDialogImpl : Form
{
public BootstrapFilePropertiesDialogImpl()
{
InitializeComponent();
}
private void cmdBrowseSourceFileName_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
txtSourceFileName.Text = ofd.FileName;
}
}
private void cmdBrowseDestinationFileName_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
txtDestinationFileName.Text = sfd.FileName;
}
}
private void cmdOK_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(txtSourceFileName.Text))
{
MessageBox.Show("Please provide a source file name.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (String.IsNullOrEmpty(txtDestinationFileName.Text))
{
if (MessageBox.Show("You have not specified a destination file name. Would you like to use the same file name ('" + System.IO.Path.GetFileName(txtSourceFileName.Text) + "') as the source file?", "Destination File Name", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
{
return;
}
txtDestinationFileName.Text = System.IO.Path.GetFileName(txtSourceFileName.Text);
}
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
}
private void cmdCancel_Click(object sender, EventArgs e)
{
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Close();
}
}
public class BootstrapFilePropertiesDialog
{
private string mvarSourceFileName = String.Empty;
public string SourceFileName { get { return mvarSourceFileName; } set { mvarSourceFileName = value; } }
private string mvarDestinationFileName = String.Empty;
public string DestinationFileName { get { return mvarDestinationFileName; } set { mvarDestinationFileName = value; } }
public DialogResult ShowDialog()
{
BootstrapFilePropertiesDialogImpl dlg = new BootstrapFilePropertiesDialogImpl();
dlg.txtSourceFileName.Text = mvarSourceFileName;
dlg.txtDestinationFileName.Text = mvarDestinationFileName;
if (dlg.ShowDialog() == DialogResult.OK)
{
mvarSourceFileName = dlg.txtSourceFileName.Text;
mvarDestinationFileName = dlg.txtDestinationFileName.Text;
return DialogResult.OK;
}
return DialogResult.Cancel;
}
}
}

View File

@ -0,0 +1,120 @@
<?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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -287,6 +287,7 @@
// cmdFilesClear
//
this.cmdFilesClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.cmdFilesClear.Enabled = false;
this.cmdFilesClear.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cmdFilesClear.Location = new System.Drawing.Point(392, 19);
this.cmdFilesClear.Name = "cmdFilesClear";
@ -294,9 +295,11 @@
this.cmdFilesClear.TabIndex = 1;
this.cmdFilesClear.Text = "Cl&ear";
this.cmdFilesClear.UseVisualStyleBackColor = true;
this.cmdFilesClear.Click += new System.EventHandler(this.cmdFilesClear_Click);
//
// cmdFilesRemove
//
this.cmdFilesRemove.Enabled = false;
this.cmdFilesRemove.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cmdFilesRemove.Location = new System.Drawing.Point(168, 19);
this.cmdFilesRemove.Name = "cmdFilesRemove";
@ -304,9 +307,11 @@
this.cmdFilesRemove.TabIndex = 1;
this.cmdFilesRemove.Text = "&Remove";
this.cmdFilesRemove.UseVisualStyleBackColor = true;
this.cmdFilesRemove.Click += new System.EventHandler(this.cmdFilesRemove_Click);
//
// cmdFilesModify
//
this.cmdFilesModify.Enabled = false;
this.cmdFilesModify.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cmdFilesModify.Location = new System.Drawing.Point(87, 19);
this.cmdFilesModify.Name = "cmdFilesModify";
@ -314,6 +319,7 @@
this.cmdFilesModify.TabIndex = 1;
this.cmdFilesModify.Text = "&Modify...";
this.cmdFilesModify.UseVisualStyleBackColor = true;
this.cmdFilesModify.Click += new System.EventHandler(this.cmdFilesModify_Click);
//
// cmdFilesAdd
//
@ -324,6 +330,7 @@
this.cmdFilesAdd.TabIndex = 1;
this.cmdFilesAdd.Text = "&Add...";
this.cmdFilesAdd.UseVisualStyleBackColor = true;
this.cmdFilesAdd.Click += new System.EventHandler(this.cmdFilesAdd_Click);
//
// lvFiles
//
@ -340,6 +347,8 @@
this.lvFiles.TabIndex = 0;
this.lvFiles.UseCompatibleStateImageBehavior = false;
this.lvFiles.View = System.Windows.Forms.View.Details;
this.lvFiles.ItemActivate += new System.EventHandler(this.lvFiles_ItemActivate);
this.lvFiles.SelectedIndexChanged += new System.EventHandler(this.lvFiles_SelectedIndexChanged);
//
// chSource
//

View File

@ -9,6 +9,7 @@ using UniversalEditor.UserInterface;
using UniversalEditor.UserInterface.WindowsForms;
using UniversalEditor.ObjectModels.Setup.Microsoft.ACME.BootstrapScript;
using UniversalEditor.Dialogs.Setup.Microsoft.ACME.BootstrapScript;
namespace UniversalEditor.Editors.Setup.Microsoft.ACME.BootstrapScript
{
@ -143,5 +144,102 @@ namespace UniversalEditor.Editors.Setup.Microsoft.ACME.BootstrapScript
script.Require31Message = txtRequire31.Text;
EndEdit();
}
private void cmdFilesAdd_Click(object sender, EventArgs e)
{
BootstrapFilePropertiesDialog dlg = new BootstrapFilePropertiesDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
ListViewItem lvi = new ListViewItem();
BootstrapFile file = new BootstrapFile();
file.SourceFileName = dlg.SourceFileName;
file.DestinationFileName = dlg.DestinationFileName;
BootstrapScriptObjectModel script = (ObjectModel as BootstrapScriptObjectModel);
BeginEdit();
script.Files.Add(file);
EndEdit();
lvi.Tag = file;
lvi.Text = file.SourceFileName;
lvi.SubItems.Add(file.DestinationFileName);
lvFiles.Items.Add(lvi);
RefreshButtons();
}
}
private void cmdFilesModify_Click(object sender, EventArgs e)
{
if (lvFiles.SelectedItems.Count == 1)
{
BootstrapFile file = (lvFiles.SelectedItems[0].Tag as BootstrapFile);
BootstrapFilePropertiesDialog dlg = new BootstrapFilePropertiesDialog();
dlg.SourceFileName = file.SourceFileName;
dlg.DestinationFileName = file.DestinationFileName;
if (dlg.ShowDialog() == DialogResult.OK)
{
file.SourceFileName = dlg.SourceFileName;
file.DestinationFileName = dlg.DestinationFileName;
lvFiles.SelectedItems[0].Text = file.SourceFileName;
lvFiles.SelectedItems[0].SubItems[1].Text = file.DestinationFileName;
}
}
}
private void cmdFilesRemove_Click(object sender, EventArgs e)
{
if (lvFiles.SelectedItems.Count > 0)
{
if (MessageBox.Show("Are you sure you want to remove the selected files from the list?", "Remove Files", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
BootstrapScriptObjectModel script = (ObjectModel as BootstrapScriptObjectModel);
BeginEdit();
foreach (ListViewItem lvi in lvFiles.SelectedItems)
{
script.Files.Remove(lvi.Tag as BootstrapFile);
}
EndEdit();
while (lvFiles.SelectedItems.Count > 0)
{
lvFiles.SelectedItems[0].Remove();
}
RefreshButtons();
}
}
private void RefreshButtons()
{
cmdFilesModify.Enabled = (lvFiles.SelectedItems.Count == 1);
cmdFilesRemove.Enabled = (lvFiles.SelectedItems.Count > 0);
cmdFilesClear.Enabled = (lvFiles.Items.Count > 0);
}
private void cmdFilesClear_Click(object sender, EventArgs e)
{
lvFiles.Items.Clear();
BootstrapScriptObjectModel script = (ObjectModel as BootstrapScriptObjectModel);
BeginEdit();
script.Files.Clear();
EndEdit();
}
private void lvFiles_ItemActivate(object sender, EventArgs e)
{
cmdFilesModify_Click(sender, e);
}
private void lvFiles_SelectedIndexChanged(object sender, EventArgs e)
{
RefreshButtons();
}
}
}

View File

@ -37,6 +37,12 @@
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="Dialogs\Setup\Microsoft\ACME\BootstrapScript\BootstrapFilePropertiesDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Dialogs\Setup\Microsoft\ACME\BootstrapScript\BootstrapFilePropertiesDialog.Designer.cs">
<DependentUpon>BootstrapFilePropertiesDialog.cs</DependentUpon>
</Compile>
<Compile Include="Editors\Setup\Microsoft\ACME\BootstrapScript\BootstrapScriptEditor.cs">
<SubType>UserControl</SubType>
</Compile>
@ -73,6 +79,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Dialogs\Setup\Microsoft\ACME\BootstrapScript\BootstrapFilePropertiesDialog.resx">
<DependentUpon>BootstrapFilePropertiesDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Editors\Setup\Microsoft\ACME\BootstrapScript\BootstrapScriptEditor.resx">
<DependentUpon>BootstrapScriptEditor.cs</DependentUpon>
</EmbeddedResource>