Update test project with multiple independent windows for testing snapping

This commit is contained in:
2014-05-13 17:00:32 -04:00
parent 2a3e2dc104
commit feb1ac7972
9 changed files with 269 additions and 18 deletions

View File

@@ -10,12 +10,21 @@
</startup>
<userSettings>
<TestWindow.Properties.Settings>
<setting name="WindowSettings" serializeAs="String">
<setting name="WindowSettings1" serializeAs="String">
<value />
</setting>
<setting name="AutoStart" serializeAs="String">
<value>True</value>
</setting>
<setting name="WindowSettings2" serializeAs="String">
<value />
</setting>
<setting name="WindowSettings3" serializeAs="String">
<value />
</setting>
<setting name="WindowSettings4" serializeAs="String">
<value />
</setting>
</TestWindow.Properties.Settings>
</userSettings>
</configuration>

View File

@@ -1,4 +1,5 @@
using FloatingStatusWindowLibrary;
using System;
using FloatingStatusWindowLibrary;
using System.Collections.Generic;
using System.Windows;
using Settings = TestWindow.Properties.Settings;
@@ -7,7 +8,7 @@ namespace TestWindow
{
public partial class App
{
private List<WindowSource> _windowSourceList;
private List<IDisposable> _windowSourceList;
protected override void OnStartup(StartupEventArgs e)
{
@@ -21,11 +22,12 @@ namespace TestWindow
Settings.Default.Save();
});
_windowSourceList = new List<WindowSource>
_windowSourceList = new List<IDisposable>
{
//new WindowSource(),
//new WindowSource(),
new WindowSource()
new WindowSource1(),
new WindowSource2(),
new WindowSource3(),
new WindowSource4()
};
}

View File

@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34014
// Runtime Version:4.0.30319.34209
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -26,12 +26,12 @@ namespace TestWindow.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string WindowSettings {
public string WindowSettings1 {
get {
return ((string)(this["WindowSettings"]));
return ((string)(this["WindowSettings1"]));
}
set {
this["WindowSettings"] = value;
this["WindowSettings1"] = value;
}
}
@@ -46,5 +46,41 @@ namespace TestWindow.Properties {
this["AutoStart"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string WindowSettings2 {
get {
return ((string)(this["WindowSettings2"]));
}
set {
this["WindowSettings2"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string WindowSettings3 {
get {
return ((string)(this["WindowSettings3"]));
}
set {
this["WindowSettings3"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string WindowSettings4 {
get {
return ((string)(this["WindowSettings4"]));
}
set {
this["WindowSettings4"] = value;
}
}
}
}

View File

@@ -2,11 +2,20 @@
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="TestWindow.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="WindowSettings" Type="System.String" Scope="User">
<Setting Name="WindowSettings1" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="AutoStart" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="WindowSettings2" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="WindowSettings3" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="WindowSettings4" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

View File

@@ -59,7 +59,10 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Settings.cs" />
<Compile Include="WindowSource.cs" />
<Compile Include="WindowSource2.cs" />
<Compile Include="WindowSource4.cs" />
<Compile Include="WindowSource3.cs" />
<Compile Include="WindowSource1.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">

View File

@@ -6,13 +6,13 @@ using System.Windows.Threading;
namespace TestWindow
{
internal class WindowSource : IWindowSource, IDisposable
internal class WindowSource1 : IWindowSource, IDisposable
{
private readonly FloatingStatusWindow _floatingStatusWindow;
private readonly Timer _timer;
private readonly Dispatcher _dispatcher;
internal WindowSource()
internal WindowSource1()
{
_floatingStatusWindow = new FloatingStatusWindow(this);
_floatingStatusWindow.SetText("Loading...");
@@ -40,7 +40,7 @@ namespace TestWindow
public string Name
{
get { return "Test Window"; }
get { return "Test Window 1"; }
}
public System.Drawing.Icon Icon
@@ -52,11 +52,11 @@ namespace TestWindow
{
get
{
return Properties.Settings.Default.WindowSettings;
return Properties.Settings.Default.WindowSettings1;
}
set
{
Properties.Settings.Default.WindowSettings = value;
Properties.Settings.Default.WindowSettings1 = value;
Properties.Settings.Default.Save();
}
}

View File

@@ -0,0 +1,64 @@
using FloatingStatusWindowLibrary;
using System;
using System.Globalization;
using System.Timers;
using System.Windows.Threading;
namespace TestWindow
{
internal class WindowSource2 : IWindowSource, IDisposable
{
private readonly FloatingStatusWindow _floatingStatusWindow;
private readonly Timer _timer;
private readonly Dispatcher _dispatcher;
internal WindowSource2()
{
_floatingStatusWindow = new FloatingStatusWindow(this);
_floatingStatusWindow.SetText("Loading...");
_dispatcher = Dispatcher.CurrentDispatcher;
_timer = new Timer(1000);
_timer.Elapsed += HandleTimerElapsed;
_timer.Enabled = true;
}
private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
{
_dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(DateTime.Now.ToString(CultureInfo.InvariantCulture)));
}
public void Dispose()
{
_timer.Enabled = false;
_timer.Dispose();
_floatingStatusWindow.Save();
_floatingStatusWindow.Dispose();
}
public string Name
{
get { return "Test Window 2"; }
}
public System.Drawing.Icon Icon
{
get { return Properties.Resources.ApplicationIcon; }
}
public string WindowSettings
{
get
{
return Properties.Settings.Default.WindowSettings2;
}
set
{
Properties.Settings.Default.WindowSettings2 = value;
Properties.Settings.Default.Save();
}
}
}
}

View File

@@ -0,0 +1,64 @@
using FloatingStatusWindowLibrary;
using System;
using System.Globalization;
using System.Timers;
using System.Windows.Threading;
namespace TestWindow
{
internal class WindowSource3 : IWindowSource, IDisposable
{
private readonly FloatingStatusWindow _floatingStatusWindow;
private readonly Timer _timer;
private readonly Dispatcher _dispatcher;
internal WindowSource3()
{
_floatingStatusWindow = new FloatingStatusWindow(this);
_floatingStatusWindow.SetText("Loading...");
_dispatcher = Dispatcher.CurrentDispatcher;
_timer = new Timer(1000);
_timer.Elapsed += HandleTimerElapsed;
_timer.Enabled = true;
}
private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
{
_dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(DateTime.Now.ToString(CultureInfo.InvariantCulture)));
}
public void Dispose()
{
_timer.Enabled = false;
_timer.Dispose();
_floatingStatusWindow.Save();
_floatingStatusWindow.Dispose();
}
public string Name
{
get { return "Test Window 3"; }
}
public System.Drawing.Icon Icon
{
get { return Properties.Resources.ApplicationIcon; }
}
public string WindowSettings
{
get
{
return Properties.Settings.Default.WindowSettings3;
}
set
{
Properties.Settings.Default.WindowSettings3 = value;
Properties.Settings.Default.Save();
}
}
}
}

View File

@@ -0,0 +1,64 @@
using FloatingStatusWindowLibrary;
using System;
using System.Globalization;
using System.Timers;
using System.Windows.Threading;
namespace TestWindow
{
internal class WindowSource4 : IWindowSource, IDisposable
{
private readonly FloatingStatusWindow _floatingStatusWindow;
private readonly Timer _timer;
private readonly Dispatcher _dispatcher;
internal WindowSource4()
{
_floatingStatusWindow = new FloatingStatusWindow(this);
_floatingStatusWindow.SetText("Loading...");
_dispatcher = Dispatcher.CurrentDispatcher;
_timer = new Timer(1000);
_timer.Elapsed += HandleTimerElapsed;
_timer.Enabled = true;
}
private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
{
_dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(DateTime.Now.ToString(CultureInfo.InvariantCulture)));
}
public void Dispose()
{
_timer.Enabled = false;
_timer.Dispose();
_floatingStatusWindow.Save();
_floatingStatusWindow.Dispose();
}
public string Name
{
get { return "Test Window 4"; }
}
public System.Drawing.Icon Icon
{
get { return Properties.Resources.ApplicationIcon; }
}
public string WindowSettings
{
get
{
return Properties.Settings.Default.WindowSettings4;
}
set
{
Properties.Settings.Default.WindowSettings4 = value;
Properties.Settings.Default.Save();
}
}
}
}