Skip to content

Commit

Permalink
adding regions editor
Browse files Browse the repository at this point in the history
  • Loading branch information
dtylman committed Feb 7, 2019
1 parent 144f5c5 commit 54fba32
Show file tree
Hide file tree
Showing 7 changed files with 325 additions and 10 deletions.
19 changes: 10 additions & 9 deletions Retriever/FormProfileEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ public FormProfileEditor(Profile profile, string selectedService, string selecte
appBar.Text = String.Format("Editing '{0}'", this.profile.Name);
appBar.ToolTip = new ModernToolTip();

foreach (var r in RegionEndpoint.EnumerableAllRegions)
{
AppBarMenuItem regionMenuItem = new AppBarMenuTextItem(r.SystemName);
regionMenuItem.Click += RegionMenuItem_Click;
appBar.MenuItems.Add(regionMenuItem);
}

AppAction regionAction = new AppAction();
regionAction.Image = Resources.Gear50;
regionAction.Cursor = Cursors.Hand;
regionAction.ToolTip = "Regions Editor";
regionAction.Click += RegionAction_Click;
this.appBar.Actions.Add(regionAction);
AppAction saveProfileAction = new AppAction();
saveProfileAction.Image = Resources.Output50;
saveProfileAction.Cursor = Cursors.Hand;
Expand All @@ -75,9 +75,10 @@ public FormProfileEditor(Profile profile, string selectedService, string selecte
}
}

private void RegionMenuItem_Click(object sender, EventArgs e)
private void RegionAction_Click(object sender, EventArgs e)
{
// (sender as AppBarMenuTextItem).Text
FormRegions formRegions = new FormRegions(this.profile);
formRegions.ShowDialog();
}

private void SaveProfileAction_Click(object sender, System.EventArgs e)
Expand Down
113 changes: 113 additions & 0 deletions Retriever/FormRegions.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions Retriever/FormRegions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Amazon;
using NickAc.ModernUIDoneRight.Controls;
using NickAc.ModernUIDoneRight.Forms;
using Retriever.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Retriever
{
public partial class FormRegions : ModernForm
{
private Profile profile;

public FormRegions(Profile profile)
{
this.profile = profile;

InitializeComponent();

foreach (RegionEndpoint region in RegionEndpoint.EnumerableAllRegions)
{
CheckBox checkBox = new CheckBox();
checkBox.Text = region.DisplayName;
checkBox.AutoSize = true;
checkBox.Tag = region.SystemName;
checkBox.Checked = this.profile.RegionEnabled(region.SystemName);
checkBox.Click += CheckBox_Click;
this.flowLayoutPanel1.Controls.Add(checkBox);
}
}

private void CheckBox_Click(object sender, EventArgs e)
{
CheckBox checkbox = (sender as CheckBox);
string region = checkbox.Tag as string;
this.profile.EnableRegion(region, checkbox.Checked);
if (checkbox.Checked)
{
ModernMessageBox.Show(String.Format("Region enabled for {0}", region));
} else
{
ModernMessageBox.Show(String.Format("Region disabled for {0}", region));
}

}
}
}
120 changes: 120 additions & 0 deletions Retriever/FormRegions.resx
Original file line number Diff line number Diff line change
@@ -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=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>
</root>
12 changes: 12 additions & 0 deletions Retriever/Model/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ public void Set(ProfileRecord p)
}
}

public bool RegionEnabled(string systemName)
{
foreach (ProfileRecord pr in this)
{
if (pr.RegionEnabled(systemName))
{
return true;
}
}
return false;
}

public void EnableRegion(string region, bool enabled)
{
for (int i = 0; i < this.Count; i++)
Expand Down
8 changes: 7 additions & 1 deletion Retriever/Model/ProfileRecord.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AWSRetriver.Controls;
using System;
using AWSRetriver.Controls;

namespace Retriever
{
Expand Down Expand Up @@ -45,6 +46,11 @@ public void EnableRegion(string region, bool enabled)
}
this.regions = rs.Text();
}

public bool RegionEnabled(string systemName)
{
return this.regions.Contains(systemName);
}
}
}
}
9 changes: 9 additions & 0 deletions Retriever/Retriever.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@
<Compile Include="FormProfileEditor.Designer.cs">
<DependentUpon>FormProfileEditor.cs</DependentUpon>
</Compile>
<Compile Include="FormRegions.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormRegions.Designer.cs">
<DependentUpon>FormRegions.cs</DependentUpon>
</Compile>
<Compile Include="Model\CloudObjects.cs" />
<Compile Include="FormCredentials.cs">
<SubType>Form</SubType>
Expand Down Expand Up @@ -179,6 +185,9 @@
<EmbeddedResource Include="FormProfileEditor.resx">
<DependentUpon>FormProfileEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormRegions.resx">
<DependentUpon>FormRegions.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormRun.resx">
<DependentUpon>FormRun.cs</DependentUpon>
</EmbeddedResource>
Expand Down

0 comments on commit 54fba32

Please sign in to comment.