# HG changeset patch # User cin # Date 1379979084 -14400 # Node ID f2559580b48107966e8e99395d5abc6163dba95e # Parent 381095ad0a6990c59e6371ff5a073f230602ce14 implemented overlay helpers and some animation heplers improvments diff -r 381095ad0a69 -r f2559580b481 .hgignore --- a/.hgignore Tue Sep 17 04:27:30 2013 +0400 +++ b/.hgignore Tue Sep 24 03:31:24 2013 +0400 @@ -8,3 +8,5 @@ TestResults/ Implab.Fx/obj/ Implab.Fx/bin/ +Implab.Fx.Test/bin/ +Implab.Fx.Test/obj/ diff -r 381095ad0a69 -r f2559580b481 Implab.Fx.Test/Implab.Fx.Test.csproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Fx.Test/Implab.Fx.Test.csproj Tue Sep 24 03:31:24 2013 +0400 @@ -0,0 +1,94 @@ + + + + Debug + AnyCPU + + + 2.0 + {2F31E405-E267-4195-A05D-574093C21209} + Library + Properties + Implab.Fx.Test + Implab.Fx.Test + v4.0 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + 3.5 + + + + + + + + + + False + + + + + + + Form + + + MainForm.cs + + + Form + + + OverlayForm.cs + + + + + MainForm.cs + + + OverlayForm.cs + + + + + {06E706F8-6881-43EB-927E-FFC503AF6ABC} + Implab.Fx + + + {F550F1F8-8746-4AD0-9614-855F4C4B7F05} + Implab + + + + + \ No newline at end of file diff -r 381095ad0a69 -r f2559580b481 Implab.Fx.Test/OverlayTest.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Fx.Test/OverlayTest.cs Tue Sep 24 03:31:24 2013 +0400 @@ -0,0 +1,35 @@ +using System; +using System.Text; +using System.Collections.Generic; +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Windows.Forms; +using Implab.Fx.Test.Sample; +using System.Drawing; +using Implab.Fx; + +namespace Implab.Fx.Test +{ + [TestClass] + public class OverlayTest + { + [TestMethod] + public void TestMethod1() + { + var mainForm = new MainForm(); + + mainForm.ButtonEvent += (sender, args) => + { + var overlay = new OverlayForm(); + mainForm.OverlayFadeIn(overlay).Then( + o => o.ButtonEvent += (s2, args2) => + { + o.CloseFadeOut(); + } + ); + }; + + Application.Run(mainForm); + } + } +} diff -r 381095ad0a69 -r f2559580b481 Implab.Fx.Test/Properties/AssemblyInfo.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Fx.Test/Properties/AssemblyInfo.cs Tue Sep 24 03:31:24 2013 +0400 @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Implab.Fx.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Implab.Fx.Test")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ac9cc552-177e-4b6d-923c-763dc6f87dd6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff -r 381095ad0a69 -r f2559580b481 Implab.Fx.Test/Sample/MainForm.Designer.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Fx.Test/Sample/MainForm.Designer.cs Tue Sep 24 03:31:24 2013 +0400 @@ -0,0 +1,82 @@ +namespace Implab.Fx.Test.Sample +{ + partial class MainForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.button1 = new System.Windows.Forms.Button(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(138, 12); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 0; + this.button1.Text = "button1"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Location = new System.Drawing.Point(138, 41); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(121, 21); + this.comboBox1.TabIndex = 1; + // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.Location = new System.Drawing.Point(12, 12); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(120, 95); + this.listBox1.TabIndex = 2; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 262); + this.Controls.Add(this.listBox1); + this.Controls.Add(this.comboBox1); + this.Controls.Add(this.button1); + this.Name = "MainForm"; + this.Text = "MainForm"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button button1; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.ListBox listBox1; + } +} \ No newline at end of file diff -r 381095ad0a69 -r f2559580b481 Implab.Fx.Test/Sample/MainForm.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Fx.Test/Sample/MainForm.cs Tue Sep 24 03:31:24 2013 +0400 @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace Implab.Fx.Test.Sample +{ + public partial class MainForm : Form + { + public event EventHandler ButtonEvent; + + public MainForm() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + EventHandler temp = ButtonEvent; + if (temp != null) + { + temp(this,new EventArgs()); + } + } + } +} diff -r 381095ad0a69 -r f2559580b481 Implab.Fx.Test/Sample/MainForm.resx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Fx.Test/Sample/MainForm.resx Tue Sep 24 03:31:24 2013 +0400 @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff -r 381095ad0a69 -r f2559580b481 Implab.Fx.Test/Sample/OverlayForm.Designer.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Fx.Test/Sample/OverlayForm.Designer.cs Tue Sep 24 03:31:24 2013 +0400 @@ -0,0 +1,99 @@ +namespace Implab.Fx.Test.Sample +{ + partial class OverlayForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.button1 = new System.Windows.Forms.Button(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.label1 = new System.Windows.Forms.Label(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(12, 12); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 0; + this.button1.Text = "button1"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(12, 88); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(80, 17); + this.checkBox1.TabIndex = 1; + this.checkBox1.Text = "checkBox1"; + this.checkBox1.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(13, 42); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(35, 13); + this.label1.TabIndex = 2; + this.label1.Text = "label1"; + // + // progressBar1 + // + this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.progressBar1.Location = new System.Drawing.Point(12, 59); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(260, 23); + this.progressBar1.TabIndex = 3; + // + // OverlayForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 262); + this.Controls.Add(this.progressBar1); + this.Controls.Add(this.label1); + this.Controls.Add(this.checkBox1); + this.Controls.Add(this.button1); + this.Name = "OverlayForm"; + this.Text = "OverlayForm"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button button1; + private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ProgressBar progressBar1; + } +} \ No newline at end of file diff -r 381095ad0a69 -r f2559580b481 Implab.Fx.Test/Sample/OverlayForm.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Fx.Test/Sample/OverlayForm.cs Tue Sep 24 03:31:24 2013 +0400 @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace Implab.Fx.Test.Sample +{ + public partial class OverlayForm : Form + { + public event EventHandler ButtonEvent; + + public OverlayForm() + { + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + EventHandler temp = ButtonEvent; + if (temp != null) + { + temp(this,new EventArgs()); + } + } + } +} diff -r 381095ad0a69 -r f2559580b481 Implab.Fx.Test/Sample/OverlayForm.resx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Fx.Test/Sample/OverlayForm.resx Tue Sep 24 03:31:24 2013 +0400 @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff -r 381095ad0a69 -r f2559580b481 Implab.Fx/AnimationHelpers.cs --- a/Implab.Fx/AnimationHelpers.cs Tue Sep 17 04:27:30 2013 +0400 +++ b/Implab.Fx/AnimationHelpers.cs Tue Sep 24 03:31:24 2013 +0400 @@ -9,7 +9,7 @@ { public static class AnimationHelpers { - public static Animation AnimateProperty(this Animation animation, Action setter, Func getter, TVal newValue, Func fx) where TTarget: class + public static Animation AnimateProperty(this Animation animation, Action setter, Func getter, TVal newValue, Func fx) where TTarget : class { if (animation == null) throw new ArgumentNullException("animation"); @@ -25,9 +25,9 @@ return animation; } - public static Animation
AnimateTransparency(this Form ctl, float newValue) + public static Animation AnimateTransparency(this T ctl, float newValue) where T : Form { - var anim = new Animation(ctl); + var anim = new Animation(ctl); anim.AnimateProperty( (target, value) => target.Opacity = value, @@ -37,5 +37,53 @@ ); return anim; } + + public static Promise CloseFadeOut(this T ctl) where T : Form + { + var anim = ctl.AnimateTransparency(0); + + return anim.Play().DispatchToControl(ctl).Then(frm => frm.Close()); + } + + public static Promise OverlayFadeIn(this Form that, T overlay) where T : Form + { + if (that == null) + throw new ArgumentNullException("that"); + if (overlay == null) + throw new ArgumentNullException("overlay"); + + // setup overlay + overlay.Opacity = 0; + overlay.FormBorderStyle = FormBorderStyle.None; + overlay.ShowInTaskbar = false; + + that.AddOwnedForm(overlay); + + EventHandler handler = (object sender, EventArgs args) => + { + overlay.Bounds = that.RectangleToScreen(that.ClientRectangle); + }; + + // attach handlers + that.Move += handler; + that.Resize += handler; + that.Shown += handler; + + // remove handlers to release overlay + overlay.FormClosed += (sender, args) => + { + that.Move -= handler; + that.Resize -= handler; + that.Shown -= handler; + }; + + overlay.Show(that); + overlay.Bounds = that.RectangleToScreen(that.ClientRectangle); + + return overlay + .AnimateTransparency(1) + .Play() + .DispatchToControl(overlay); + } } } diff -r 381095ad0a69 -r f2559580b481 Implab.Fx/Implab.Fx.csproj --- a/Implab.Fx/Implab.Fx.csproj Tue Sep 17 04:27:30 2013 +0400 +++ b/Implab.Fx/Implab.Fx.csproj Tue Sep 24 03:31:24 2013 +0400 @@ -33,6 +33,7 @@ + diff -r 381095ad0a69 -r f2559580b481 Implab.sln --- a/Implab.sln Tue Sep 17 04:27:30 2013 +0400 +++ b/Implab.sln Tue Sep 24 03:31:24 2013 +0400 @@ -14,6 +14,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Fx", "Implab.Fx\Implab.Fx.csproj", "{06E706F8-6881-43EB-927E-FFC503AF6ABC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Fx.Test", "Implab.Fx.Test\Implab.Fx.Test.csproj", "{2F31E405-E267-4195-A05D-574093C21209}" +EndProject Global GlobalSection(TestCaseManagementSettings) = postSolution CategoryFile = Implab.vsmdi @@ -35,6 +37,10 @@ {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug|Any CPU.Build.0 = Debug|Any CPU {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release|Any CPU.ActiveCfg = Release|Any CPU {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release|Any CPU.Build.0 = Release|Any CPU + {2F31E405-E267-4195-A05D-574093C21209}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F31E405-E267-4195-A05D-574093C21209}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F31E405-E267-4195-A05D-574093C21209}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F31E405-E267-4195-A05D-574093C21209}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff -r 381095ad0a69 -r f2559580b481 Implab.suo Binary file Implab.suo has changed