windows: implement some Setup pages

This commit is contained in:
Hylke Bons 2012-03-05 21:55:39 +00:00
parent 038f673c0f
commit 72704cc740
7 changed files with 423 additions and 489 deletions

View file

@ -23,13 +23,9 @@ using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
#if __MonoCS__
using Gtk; using Gtk;
using Mono.Unix; using Mono.Unix;
using Mono.Unix.Native; using Mono.Unix.Native;
#else
using System.Windows.Forms;
#endif
using SparkleLib; using SparkleLib;
namespace SparkleShare { namespace SparkleShare {
@ -55,13 +51,10 @@ namespace SparkleShare {
public SparkleUI () public SparkleUI ()
{ {
// Initialize the application
#if __MonoCS__
Application.Init (); Application.Init ();
// Use translations // Use translations
Catalog.Init (Defines.GETTEXT_PACKAGE, Defines.LOCALE_DIR); Catalog.Init (Defines.GETTEXT_PACKAGE, Defines.LOCALE_DIR);
#endif
Setup = new SparkleSetup (); Setup = new SparkleSetup ();
EventLog = new SparkleEventLog (); EventLog = new SparkleEventLog ();
@ -69,8 +62,7 @@ namespace SparkleShare {
Bubbles = new SparkleBubbles (); Bubbles = new SparkleBubbles ();
StatusIcon = new SparkleStatusIcon (); StatusIcon = new SparkleStatusIcon ();
if (Program.Controller.FirstRun) Program.Controller.UIHasLoaded ();
Program.Controller.ShowSetupWindow (PageType.Setup);
} }
@ -78,9 +70,6 @@ namespace SparkleShare {
public void Run () public void Run ()
{ {
Application.Run (); Application.Run ();
#if !__MonoCS__
StatusIcon.Dispose ();
#endif
} }
} }
} }

View file

@ -16,10 +16,8 @@
using System; using System;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Timers;
using Mono.Unix; using Mono.Unix;
using MonoMac.Foundation; using MonoMac.Foundation;
@ -36,41 +34,36 @@ namespace SparkleShare {
public static SparkleSetup Setup; public static SparkleSetup Setup;
public static SparkleBubbles Bubbles; public static SparkleBubbles Bubbles;
public static SparkleAbout About; public static SparkleAbout About;
public static NSFont Font;
public static NSFont BoldFont; public static NSFont Font = NSFontManager.SharedFontManager.FontWithFamily
("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);
public static NSFont BoldFont = NSFontManager.SharedFontManager.FontWithFamily
("Lucida Grande", NSFontTraitMask.Bold, 0, 13);
public SparkleUI () public SparkleUI ()
{ {
using (var a = new NSAutoreleasePool ()) using (var a = new NSAutoreleasePool ())
{ {
// Use translations
Catalog.Init ("sparkleshare", Catalog.Init ("sparkleshare",
Path.Combine (NSBundle.MainBundle.ResourcePath, "Translations")); Path.Combine (NSBundle.MainBundle.ResourcePath, "Translations"));
// Needed for Growl
GrowlApplicationBridge.WeakDelegate = this; GrowlApplicationBridge.WeakDelegate = this;
GrowlApplicationBridge.Delegate = new SparkleGrowlDelegate (); GrowlApplicationBridge.Delegate = new SparkleGrowlDelegate ();
NSApplication.SharedApplication.ApplicationIconImage NSApplication.SharedApplication.ApplicationIconImage =
= NSImage.ImageNamed ("sparkleshare.icns"); NSImage.ImageNamed ("sparkleshare.icns");
SetFolderIcon (); SetFolderIcon ();
Font = NSFontManager.SharedFontManager.FontWithFamily
("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);
BoldFont = NSFontManager.SharedFontManager.FontWithFamily
("Lucida Grande", NSFontTraitMask.Bold, 0, 13);
Setup = new SparkleSetup (); Setup = new SparkleSetup ();
EventLog = new SparkleEventLog (); EventLog = new SparkleEventLog ();
About = new SparkleAbout (); About = new SparkleAbout ();
Bubbles = new SparkleBubbles (); Bubbles = new SparkleBubbles ();
StatusIcon = new SparkleStatusIcon (); StatusIcon = new SparkleStatusIcon ();
if (Program.Controller.FirstRun) Program.Controller.UIHasLoaded ();
Program.Controller.ShowSetupWindow (PageType.Setup);
} }
} }
@ -79,8 +72,10 @@ namespace SparkleShare {
{ {
using (var a = new NSAutoreleasePool ()) using (var a = new NSAutoreleasePool ())
{ {
string folder_icon_path = Path.Combine (NSBundle.MainBundle.ResourcePath, string folder_icon_path = Path.Combine (
"sparkleshare-mac.icns"); NSBundle.MainBundle.ResourcePath,
"sparkleshare-mac.icns"
);
NSImage folder_icon = new NSImage (folder_icon_path); NSImage folder_icon = new NSImage (folder_icon_path);
@ -111,13 +106,15 @@ namespace SparkleShare {
private void HideDockIcon () private void HideDockIcon ()
{ {
// Currently not supported, here for completeness sake (see Apple's docs) // Currently not supported, here for completeness sake (see Apple's docs)
// NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.None; // NSApplication.SharedApplication.ActivationPolicy =
// NSApplicationActivationPolicy.None;
} }
private void ShowDockIcon () private void ShowDockIcon ()
{ {
NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular; NSApplication.SharedApplication.ActivationPolicy =
NSApplicationActivationPolicy.Regular;
} }

View file

@ -90,6 +90,40 @@ namespace SparkleShare {
public delegate void NoteNotificationRaisedEventHandler (SparkleUser user, string folder_name); public delegate void NoteNotificationRaisedEventHandler (SparkleUser user, string folder_name);
public bool FirstRun {
get {
return SparkleConfig.DefaultConfig.User.Email.Equals ("Unknown");
}
}
public List<string> Folders {
get {
List<string> folders = SparkleConfig.DefaultConfig.Folders;
folders.Sort ();
return folders;
}
}
public List<string> UnsyncedFolders {
get {
List<string> unsynced_folders = new List<string> ();
lock (this.repo_lock) {
foreach (SparkleRepoBase repo in Repositories) {
if (repo.HasUnsyncedChanges)
unsynced_folders.Add (repo.Name);
}
}
return unsynced_folders;
}
}
// Path where the plugins are kept // Path where the plugins are kept
public abstract string PluginsPath { get; } public abstract string PluginsPath { get; }
@ -210,53 +244,9 @@ namespace SparkleShare {
public void UIHasLoaded () public void UIHasLoaded ()
{ {
if (FirstRun) // if (FirstRun)
ShowSetupWindow (PageType.Setup); ShowSetupWindow (PageType.Setup);
} }
public bool FirstRun {
get {
return SparkleConfig.DefaultConfig.User.Email.Equals ("Unknown");
}
}
public List<string> Folders {
get {
List<string> folders = SparkleConfig.DefaultConfig.Folders;
folders.Sort ();
return folders;
}
}
public List<string> PreviousHosts {
get {
List<string> hosts = SparkleConfig.DefaultConfig.HostsWithUsername;
hosts.AddRange(SparkleConfig.DefaultConfig.Hosts);
hosts.Sort ();
return hosts;
}
}
public List<string> UnsyncedFolders {
get {
List<string> unsynced_folders = new List<string> ();
lock (this.repo_lock) {
foreach (SparkleRepoBase repo in Repositories) {
if (repo.HasUnsyncedChanges)
unsynced_folders.Add (repo.Name);
}
}
return unsynced_folders;
}
}
public void ShowSetupWindow (PageType page_type) public void ShowSetupWindow (PageType page_type)

View file

@ -16,293 +16,371 @@
using System; using System;
using System.Diagnostics; using System.ComponentModel;
using System.IO;
using System.Text.RegularExpressions;
using System.Timers;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Forms;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Media;
using System.Windows;
using System.Windows.Controls;
namespace SparkleShare { namespace SparkleShare {
public partial class SparkleSetup : Form { public class SparkleSetup : SparkleSetupWindow {
public SparkleSetupController Controller = new SparkleSetupController (); public SparkleSetupController Controller = new SparkleSetupController ();
private TreeView treeView;
public SparkleSetup ()
// Short alias for the translations {
public static string _ (string s) { Controller.ShowWindowEvent += delegate {
return Program._ (s); Dispatcher.Invoke ((Action) delegate {
} Show ();
Activate ();
BringIntoView ();
public SparkleSetup () {
InitializeComponent ();
Program.TranslateWinForm (this);
pictureBox.Image = Icons.side_splash;
this.Icon = Icons.sparkleshare;
Controller.HideWindowEvent += delegate
{
this.Hide();
};
Controller.ShowWindowEvent += delegate
{
this.Show();
};
Controller.ChangePageEvent += delegate (PageType type, string [] warnings) {
tabControl.SafeInvoke ((Action)delegate {
switch (type) {
case PageType.Setup:
tabControl.SelectedIndex = 0;
NameEntry.Text = Controller.GuessedUserName;
EmailEntry.Text = Controller.GuessedUserEmail;
Show();
Controller.CheckSetupPage(NameEntry.Text, EmailEntry.Text);
break;
case PageType.Add:
tabControl.SelectedIndex = 1;
// Add plugins to tree
// ===================
// Check whether the treeView is already created
// If it is dispose it and start over
if (treeView != null) {
treeView.Dispose();
}
// Set up the treeview
ImageList imageList = new ImageList ();
imageList.ImageSize = new Size (24, 24);
treeView = new TreeView ();
treeView.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText;
treeView.FullRowSelect = true;
treeView.ImageIndex = 0;
treeView.Indent = 35;
treeView.HideSelection = false;
treeView.ItemHeight = 40;
TreeNode [] nodes = new TreeNode [Controller.Plugins.Count];
for (int i = 0; i < Controller.Plugins.Count; i++) {
nodes [i] = new TreeNode (Controller.Plugins [i].Name + ";" + Controller.Plugins [i].Description);
nodes [i].ImageIndex = i;
nodes [i].SelectedImageIndex = i;
nodes [i].Tag = Controller.Plugins [i].Name;
imageList.Images.Add (Image.FromFile (Controller.Plugins [i].ImagePath));
}
treeView.Nodes.AddRange (nodes);
treeView.ImageList = imageList;
treeView.ShowLines = false;
treeView.ShowRootLines = false;
treeView.Size = new System.Drawing.Size (panel_server_selection.Size.Width,
panel_server_selection.Size.Height);
panel_server_selection.Controls.Add (treeView);
// Finished adding and populating tree
// Select first node
treeView.SelectedNode = treeView.Nodes[0];
treeView.Select();
Controller.SelectedPluginChanged(0);
treeView.AfterSelect += new TreeViewEventHandler(CheckTreeNode);
Show ();
Controller.CheckAddPage(ServerEntry.Text, FolderEntry.Text, 1);
break;
case PageType.Invite:
tabControl.SelectedIndex = 5;
InviteAddressEntry.Text = Controller.PendingInvite.Address;
InviteFolderEntry.Text = Controller.PendingInvite.RemotePath;
Show();
break;
case PageType.Syncing:
tabControl.SelectedIndex = 2;
Show();
break;
case PageType.Error:
tabControl.SelectedIndex = 3;
label3.Text = "First, have you tried turning it off and on again?\n\n" +
Controller.PreviousUrl + " is the address we've compiled. Does this look alright?\n\n" +
"The host needs to know who you are. Have you uploaded the key that sits in your SparkleShare folder?";
Show ();
break;
case PageType.Finished:
tabControl.SelectedIndex = 4;
Show ();
break;
case PageType.Tutorial:
// Do nothing in tutorial by now
Controller.TutorialSkipped();;
break;
default:
throw new NotImplementedException ("unknown PageType");
}
}); });
}; };
Controller.UpdateSetupContinueButtonEvent += new SparkleSetupController.UpdateSetupContinueButtonEventHandler(UpdateSetupContinueButtonEvent); Controller.HideWindowEvent += delegate {
Dispatcher.Invoke ((Action) delegate {
Hide ();
});
};
Controller.ChangePageEvent += delegate (PageType type, string [] warnings) {
Dispatcher.Invoke ((Action) delegate {
Reset ();
switch (type) {
case PageType.Setup: {
Header = "Welcome to SparkleShare!";
Description = "Before we get started, what's your name and email?\n" +
"Don't worry, this information will only visible to any team members.";
TextBlock name_label = new TextBlock () {
Text = "Full Name:",
Width = 150,
TextAlignment = TextAlignment.Right,
FontWeight = FontWeights.Bold
};
TextBox name_box = new TextBox () {
Text = Controller.GuessedUserName,
Width = 175
};
TextBlock email_label = new TextBlock () {
Text = "Email:",
Width = 150,
TextAlignment = TextAlignment.Right,
FontWeight = FontWeights.Bold
};
TextBox email_box = new TextBox () {
Width = 175,
Text = Controller.GuessedUserEmail
};
Button continue_button = new Button () {
Content = "Continue",
IsEnabled = false
};
ContentCanvas.Children.Add (name_label);
Canvas.SetLeft (name_label, 180);
Canvas.SetTop (name_label, 200 + 3);
ContentCanvas.Children.Add (name_box);
Canvas.SetLeft (name_box, 340);
Canvas.SetTop (name_box, 200);
ContentCanvas.Children.Add (email_label);
Canvas.SetLeft (email_label, 180);
Canvas.SetTop (email_label, 230 + 3);
ContentCanvas.Children.Add (email_box);
Canvas.SetLeft (email_box, 340);
Canvas.SetTop (email_box, 230);
Buttons.Add (continue_button);
Controller.UpdateSetupContinueButtonEvent += delegate (bool enabled) {
Dispatcher.Invoke ((Action) delegate {
continue_button.IsEnabled = enabled;
});
};
name_box.TextChanged += delegate {
Controller.CheckSetupPage (name_box.Text, email_box.Text);
};
email_box.TextChanged += delegate {
Controller.CheckSetupPage (name_box.Text, email_box.Text);
};
continue_button.Click += delegate {
Controller.SetupPageCompleted (name_box.Text, email_box.Text);
};
Controller.CheckSetupPage (name_box.Text, email_box.Text);
break;
}
Controller.ChangeAddressFieldEvent += new SparkleSetupController.ChangeAddressFieldEventHandler(ChangeAddressFieldEvent); case PageType.Invite: {
Controller.ChangePathFieldEvent += new SparkleSetupController.ChangePathFieldEventHandler(ChangePathFieldEvent); // TODO
Controller.UpdateAddProjectButtonEvent += new SparkleSetupController.UpdateAddProjectButtonEventHandler(UpdateAddProjectButtonEvent); break;
}
case PageType.Add: {
Header = "Where's your project hosted?";
Button cancel_button = new Button () {
Content = "Cancel"
};
Button add_button = new Button () {
Content = "Add"
};
Buttons.Add (add_button);
Buttons.Add (cancel_button);
Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) {
Dispatcher.Invoke ((Action) delegate {
add_button.IsEnabled = button_enabled;
});
};
cancel_button.Click += delegate {
Controller.PageCancelled ();
};
Controller.UpdateProgressBarEvent += new SparkleSetupController.UpdateProgressBarEventHandler(UpdateProgressBarEvent); add_button.Click += delegate {
} Controller.AddPageCompleted ("github.com", "hbons/Stuff"); // TODO
};
break;
}
case PageType.Syncing: {
Header = "Adding project " + Controller.SyncingFolder + "’…";
Description = "This may take a while.\n" +
"Are you sure its not coffee o'clock?";
Button finish_button = new Button () {
Content = "Finish",
IsEnabled = false
};
Button cancel_button = new Button () {
Content = "Cancel"
};
ProgressBar progress_bar = new ProgressBar () {
Width = 414,
Height = 15,
Value = 1
};
ContentCanvas.Children.Add (progress_bar);
Canvas.SetLeft (progress_bar, 185);
Canvas.SetTop (progress_bar, 150);
Buttons.Add (finish_button);
Buttons.Add (cancel_button);
Controller.UpdateProgressBarEvent += delegate (double percentage) {
Dispatcher.Invoke ((Action) delegate {
progress_bar.Value = percentage;
});
};
cancel_button.Click += delegate {
Controller.SyncingCancelled ();
};
break;
}
case PageType.Error: {
Header = "Something went wrong…";
Description = "Please check the following:";
// TODO: Bullet points
Button try_again_button = new Button () {
Content = "Try again…"
};
Buttons.Add (try_again_button);
try_again_button.Click += delegate {
Controller.ErrorPageCompleted ();
};
break;
}
case PageType.Finished: {
Header = "Project " + Path.GetFileName (Controller.PreviousPath) +
" succesfully added!";
Description = "Access the files from your SparkleShare folder.";
// TODO: warnings
Button finish_button = new Button () {
Content = "Finish"
};
Button open_folder_button = new Button () {
Content = "Open folder"
};
Buttons.Add (finish_button);
Buttons.Add (open_folder_button);
finish_button.Click += delegate {
Controller.FinishPageCompleted ();
};
private void SparkleSetup_FormClosing (object sender, FormClosingEventArgs e) { open_folder_button.Click += delegate {
if (e.CloseReason != CloseReason.ApplicationExitCall Controller.OpenFolderClicked ();
&& e.CloseReason != CloseReason.TaskManagerClosing };
&& e.CloseReason != CloseReason.WindowsShutDown) {
e.Cancel = true;
this.Hide (); SystemSounds.Exclamation.Play ();
} // TODO: Catch attention without having to raise the window
}
break;
#region Things for "Setup" page }
private void SetupNextClicked(object sender, EventArgs e)
{ case PageType.Tutorial: {
Controller.SetupPageCompleted(NameEntry.Text, EmailEntry.Text);
} switch (Controller.TutorialPageNumber) {
case 1: {
private void CheckSetupPage(object sender, EventArgs e) Header = "What's happening next?";
{ Description = "SparkleShare creates a special folder on your computer " +
Controller.CheckSetupPage(NameEntry.Text, EmailEntry.Text); "that will keep track of your projects.";
}
void UpdateSetupContinueButtonEvent(bool button_enabled) Button skip_tutorial_button = new Button () {
{ Content = "Skip tutorial"
buttonNext.Enabled = button_enabled; };
}
#endregion
Button continue_button = new Button () {
#region Things for "Add" page Content = "Continue"
void ChangeAddressFieldEvent(string text, string example_text, FieldState state) };
{
ServerEntry.Text = text; // TODO: Add slides
ServerEntry.Enabled = state == FieldState.Enabled;
ServerEntry.ExampleText = example_text; Buttons.Add (continue_button);
} Buttons.Add (skip_tutorial_button);
void ChangePathFieldEvent(string text, string example_text, FieldState state)
{ skip_tutorial_button.Click += delegate {
FolderEntry.Text = text; Controller.TutorialSkipped ();
FolderEntry.Enabled = state == FieldState.Enabled; };
FolderEntry.ExampleText = example_text;
} continue_button.Click += delegate {
Controller.TutorialPageCompleted ();
private void CheckTreeNode(object sender, EventArgs e) };
{
Controller.SelectedPluginChanged(treeView.SelectedNode.Index); break;
} }
private void CancelButtonClicked (object sender, EventArgs e) { case 2: {
Controller.PageCancelled(); Header = "Sharing files with others";
} Description = "All files added to your project folders are synced automatically with " +
"the host and your team members.";
private void AddButtonClicked(object sender, EventArgs e)
{ Button continue_button = new Button () {
Controller.AddPageCompleted(ServerEntry.Text, FolderEntry.Text); Content = "Continue"
} };
void UpdateAddProjectButtonEvent(bool button_enabled) Buttons.Add (continue_button);
{
buttonSync.Enabled = button_enabled; continue_button.Click += delegate {
} Controller.TutorialPageCompleted ();
};
private void CheckAddPage(object sender, EventArgs e)
{ break;
Controller.CheckAddPage(ServerEntry.Text, FolderEntry.Text, treeView.SelectedNode.Index); }
}
#endregion case 3: {
Header = "The status icon is here to help";
#region Things for "Invite" page Description = "It shows the syncing progress, provides easy access to " +
private void InviteAddButtonClicked(object sender, EventArgs e) "your projects and let's you view recent changes.";
{
Controller.InvitePageCompleted();
} Button continue_button = new Button () {
Content = "Continue"
private void InviteCancelButtonClicked(object sender, EventArgs e) };
{
Controller.PageCancelled(); Buttons.Add (continue_button);
}
#endregion continue_button.Click += delegate {
Controller.TutorialPageCompleted ();
#region Things for "Syncing" page };
private void syncCancelClicked(object sender, EventArgs e)
{ break;
Controller.SyncingCancelled(); }
}
case 4: {
void UpdateProgressBarEvent(double percentage) Header = "Adding projects to SparkleShare";
{ Description = "You can do this through the status icon menu, or by clicking " +
syncingProgressBar.Value = (int)percentage; "magic buttons on webpages that look like this:";
}
#endregion
Button finish_button = new Button () {
#region Things for "Error" page Content = "Finish"
private void buttonTryAgain_Click(object sender, EventArgs e) };
{
Controller.ErrorPageCompleted(); CheckBox check_box = new CheckBox () {
} Content = "Add SparkleShare to startup items",
#endregion IsChecked = true
};
#region Thigngs for "Finish" page
private void buttonFinished_Click (object sender, EventArgs e) {
Controller.FinishPageCompleted(); ContentCanvas.Children.Add (check_box);
} Canvas.SetLeft (check_box, 185);
Canvas.SetBottom (check_box, 12);
private void buttonOpenFolder_Click (object sender, EventArgs e) {
Controller.OpenFolderClicked(); Buttons.Add (finish_button);
}
#endregion
} finish_button.Click += delegate {
Controller.TutorialPageCompleted ();
};
break;
}
}
break;
}
}
ShowAll ();
});
};
}
}
} }
public class TreeView : System.Windows.Forms.TreeView {
protected override void OnDrawNode (DrawTreeNodeEventArgs e) {
e.Graphics.DrawString (e.Node.Text.Split (';') [0], new Font (Font.SystemFontName, 13),
new SolidBrush (Color.Black), e.Bounds.X, e.Bounds.Y);
e.Graphics.DrawString (e.Node.Text.Split (';') [1], new Font (Font.SystemFontName, 9),
new SolidBrush (Color.Black), e.Bounds.X + 10, e.Bounds.Y + 15);
}
}
public class TreeNode : System.Windows.Forms.TreeNode {
public TreeNode (string text) {
this.Text = text;
}
}

View file

@ -19,7 +19,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Forms.Integration; using System.Windows.Forms.Integration;
using System.Threading;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
@ -31,7 +30,7 @@ namespace SparkleShare {
public class SparkleSetupWindow : Window { public class SparkleSetupWindow : Window {
public Canvas ContentCanvas = new Canvas (); public Canvas ContentCanvas = new Canvas ();
public List <Button> Buttons = new List <Button> (); public List <Button> Buttons = new List <Button> ();
public string Header; public string Header;
public string Description; public string Description;
@ -39,6 +38,7 @@ namespace SparkleShare {
private Image side_splash; private Image side_splash;
private Rectangle bar; private Rectangle bar;
private Rectangle line; private Rectangle line;
public SparkleSetupWindow () public SparkleSetupWindow ()
{ {
@ -53,7 +53,6 @@ namespace SparkleShare {
Closing += Close; Closing += Close;
this.bar = new Rectangle () { this.bar = new Rectangle () {
Width = Width, Width = Width,
Height = 40, Height = 40,
@ -155,9 +154,9 @@ namespace SparkleShare {
button.Width = rect.Width + 26; button.Width = rect.Width + 26;
//if (button.Width < 60) if (button.Width < 75)
// button.Width = 60; button.Width = 75;
ContentCanvas.Children.Add (button); ContentCanvas.Children.Add (button);
Canvas.SetRight (button, right); Canvas.SetRight (button, right);
Canvas.SetBottom (button, 9); Canvas.SetBottom (button, 9);
@ -169,121 +168,11 @@ namespace SparkleShare {
ElementHost.EnableModelessKeyboardInterop (this); ElementHost.EnableModelessKeyboardInterop (this);
Show (); Show ();
} }
private void Close (object sender, CancelEventArgs args) private void Close (object sender, CancelEventArgs args)
{ {
//Controller.WindowClosed ();
args.Cancel = true; args.Cancel = true;
} }
}
public class SparkleWindow : SparkleSetupWindow {
public SparkleSetupController Controller = new SparkleSetupController ();
public SparkleWindow ()
{
Reset ();
Header = "Welcome to SparkleShare!";
Description = "Before we get started, what's your name and email?\n" +
"Don't worry, this information will only visible to any team members.";
Button continue_button = new Button () {
Content = "Continue",
IsEnabled = false//,
//Width = 75
};
Button cancel_button = new Button () {
Content = "Cancel"//,
//Width = 75
};
Buttons.Add (continue_button);
Buttons.Add (cancel_button);
CheckBox check_box = new CheckBox () {
Content = "Add SparkleShare to startup items",
IsChecked = true
};
ContentCanvas.Children.Add (check_box);
Canvas.SetLeft (check_box, 185);
Canvas.SetBottom (check_box, 12);
TextBlock name_label = new TextBlock () {
Text = "Full Name:",
Width = 150,
TextAlignment = TextAlignment.Right,
FontWeight = FontWeights.Bold
};
TextBox name = new TextBox () {
Text = Controller.GuessedUserName,
Width = 175
};
TextBlock email_label = new TextBlock () {
Text = "Email:",
Width = 150,
TextAlignment = TextAlignment.Right,
FontWeight = FontWeights.Bold
};
TextBox email = new TextBox () {
Width = 175,
Text = Controller.GuessedUserEmail
};
name.TextChanged += delegate {
Controller.CheckSetupPage (name.Text, email.Text);
};
email.TextChanged += delegate {
Controller.CheckSetupPage (name.Text, email.Text);
};
Controller.UpdateSetupContinueButtonEvent += delegate (bool enabled) {
Dispatcher.Invoke ((Action) delegate {
continue_button.IsEnabled = enabled;
});
};
ContentCanvas.Children.Add (name);
Canvas.SetLeft (name, 340);
Canvas.SetTop (name, 200);
ContentCanvas.Children.Add (name_label);
Canvas.SetLeft (name_label, 180);
Canvas.SetTop (name_label, 200 + 3);
ContentCanvas.Children.Add (email_label);
Canvas.SetLeft (email_label, 180);
Canvas.SetTop (email_label, 230 + 3);
ContentCanvas.Children.Add (email);
Canvas.SetLeft (email, 340);
Canvas.SetTop (email, 230);
Controller.CheckSetupPage (name.Text, email.Text);
ShowAll ();
}
} }
} }

View file

@ -125,12 +125,7 @@
<Compile Include="SparkleAbout.cs" /> <Compile Include="SparkleAbout.cs" />
<Compile Include="SparkleController.cs" /> <Compile Include="SparkleController.cs" />
<Compile Include="SparkleEventLog.cs" /> <Compile Include="SparkleEventLog.cs" />
<Compile Include="SparkleSetup.cs"> <Compile Include="SparkleSetup.cs" />
<SubType>Form</SubType>
</Compile>
<Compile Include="SparkleSetup.Designer.cs">
<DependentUpon>SparkleSetup.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="SparkleStatusIcon.cs" /> <Compile Include="SparkleStatusIcon.cs" />
<Compile Include="SparkleUIHelpers.cs" /> <Compile Include="SparkleUIHelpers.cs" />

View file

@ -18,23 +18,19 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using SparkleLib;
namespace SparkleShare { namespace SparkleShare {
public class SparkleUI { public class SparkleUI {
public static SparkleStatusIcon StatusIcon; public static SparkleSetup Setup;
public static SparkleEventLog EventLog; public static SparkleEventLog EventLog;
public static SparkleBubbles Bubbles; public static SparkleBubbles Bubbles;
public static SparkleSetup Setup; public static SparkleStatusIcon StatusIcon;
public static SparkleAbout About; public static SparkleAbout About;
public SparkleUI () public SparkleUI ()
{ {
SparkleWindow window = new SparkleWindow ();
Setup = new SparkleSetup (); Setup = new SparkleSetup ();
EventLog = new SparkleEventLog (); EventLog = new SparkleEventLog ();
About = new SparkleAbout (); About = new SparkleAbout ();