Permalink
Browse files

The gui can now switch theme and install a new theme.

  • Loading branch information...
1 parent 2c29829 commit de800513325bafcc73d196c4f26a2b4e02895b16 @Tobbe committed Apr 8, 2009
Showing with 68 additions and 7 deletions.
  1. +2 −1 Program.cs
  2. +6 −0 ThemeAgentDLLWrapper.cs
  3. +4 −2 ThemeAgentForm.Designer.cs
  4. +22 −4 ThemeAgentForm.cs
  5. +4 −0 ThemeAgentGUI.csproj
  6. +15 −0 ThemeInstaller.cs
  7. +15 −0 ThemeSwitcher.cs
View
@@ -11,10 +11,11 @@ static void Main()
{
ThemeList tl = new ThemeList();
ActiveTheme at = new ActiveTheme();
+ ThemeSwitcher ts = new ThemeSwitcher();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new ThemeAgentForm(tl.List, at));
+ Application.Run(new ThemeAgentForm(tl.List, at, ts));
}
}
}
View
@@ -24,5 +24,11 @@ class ThemeAgentDLLWrapper
[DllImport("themeagent.dll")]
public static extern void getActiveThemeDetails(StringBuilder name,
StringBuilder author, StringBuilder version, StringBuilder preview);
+
+ [DllImport("themeagent.dll")]
+ public static extern void switchTheme();
+
+ [DllImport("themeagent.dll")]
+ public static extern void installTheme(String pathToArchive);
}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -10,11 +10,13 @@ public partial class ThemeAgentForm : Form
{
private BindingList<ThemeNameIndex> data;
private ActiveTheme at;
+ private ThemeSwitcher ts;
- public ThemeAgentForm(BindingList<ThemeNameIndex> data, ActiveTheme at)
+ public ThemeAgentForm(BindingList<ThemeNameIndex> data, ActiveTheme at, ThemeSwitcher ts)
{
this.data = data;
this.at = at;
+ this.ts = ts;
InitializeComponent();
}
@@ -30,15 +32,15 @@ private void ThemeAgentForm_Load(object sender, EventArgs e)
this.listThemes.DisplayMember = "Name";
this.listThemes.ValueMember = "Index";
- Binding b = new Binding("Text", at, "Name");
+ Binding b = new Binding("Text", at, "Name", true);
b.Format += new ConvertEventHandler(NameLabelFormat);
this.lblName.DataBindings.Add(b);
- Binding b2 = new Binding("Text", at, "Author");
+ Binding b2 = new Binding("Text", at, "Author", true);
b2.Format += new ConvertEventHandler(AuthorLabelFormat);
this.lblAuthor.DataBindings.Add(b2);
- Binding b3 = new Binding("Image", at, "Preview");
+ Binding b3 = new Binding("Image", at, "Preview", true);
b3.Format += new ConvertEventHandler(PreviewPictureFormat);
this.picPreview.DataBindings.Add(b3);
}
@@ -108,5 +110,21 @@ private void listThemes_SelectedIndexChanged(object sender, EventArgs e)
{
at.Index = ((ThemeNameIndex)listThemes.SelectedItem).Index;
}
+
+ private void btnSet_Click(object sender, EventArgs e)
+ {
+ ts.SwitchTheme();
+ }
+
+ private void btnInstall_Click(object sender, EventArgs e)
+ {
+ OpenFileDialog dialog = new OpenFileDialog();
+ dialog.Filter = "LiteStep Theme Archive (*.lsz)|*.lsz|Archive file (*.zip)|*.zip|All files (*.*)|*.*";
+ dialog.Title = "Select a LiteStep Theme Archive";
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ ThemeAgentDLLWrapper.installTheme(dialog.FileName);
+ }
+ }
}
}
View
@@ -93,6 +93,10 @@
</Compile>
<Compile Include="ThemeList.cs" />
<Compile Include="ThemeNameIndex.cs" />
+ <Compile Include="ThemeSwitcher.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ThemeInstaller.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
View
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ThemeAgentModel
+{
+ class ThemeInstaller
+ {
+ public void InstallTheme(string pathToArchive)
+ {
+ ThemeAgentDLLWrapper.installTheme(pathToArchive);
+ }
+ }
+}
View
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ThemeAgentModel
+{
+ public class ThemeSwitcher
+ {
+ public void SwitchTheme()
+ {
+ ThemeAgentDLLWrapper.switchTheme();
+ }
+ }
+}

0 comments on commit de80051

Please sign in to comment.