/// <summary> /// Show given text on OSD-window /// </summary> /// <param name="pt">Top-left corner of text in screen coordinates</param> /// <param name="alpha">Transparency of text</param> /// <param name="textColor">Color of text</param> /// <param name="textFont">Font of text</param> /// <param name="showTimeMSec">How long text will be remain on screen, in millisecond</param> /// <param name="mode">Effect to be applied. Work only if <c>time</c> greater than 0</param> /// <param name="time">Time, in milliseconds, for effect playing. If this equal to 0 <c>mode</c> ignored and text showed at once</param> /// <param name="text">Text to display</param> public void Show(Point pt, byte alpha, Color textColor, Font textFont, int showTimeMSec, AnimateMode mode, uint time, string text) { try { if (this._viewClock != null) { _viewClock.Stop(); _viewClock.Dispose(); } this._brush = new SolidBrush(textColor); this._textFont = textFont; this._text = text; this._mode = mode; this._time = time; SizeF textArea; this._rScreen = Screen.PrimaryScreen.Bounds; if (this._stringFormat == null) { this._stringFormat = new StringFormat(); this._stringFormat.Alignment = StringAlignment.Near; this._stringFormat.LineAlignment = StringAlignment.Near; this._stringFormat.Trimming = StringTrimming.EllipsisWord; } using (Bitmap bm = new Bitmap(base.Width, base.Height)) using (Graphics fx = Graphics.FromImage(bm)) textArea = fx.MeasureString(text, textFont, this._rScreen.Width, this._stringFormat); base.Location = pt; base.Alpha = alpha; base.Size = new Size((int)Math.Ceiling(textArea.Width), (int)Math.Ceiling(textArea.Height)); _viewClock = new System.Windows.Forms.Timer(); _viewClock.Tick += new System.EventHandler(viewTimer); _viewClock.Interval = showTimeMSec; _viewClock.Start(); if (time > 0) base.ShowAnimate(mode, time); else base.Show(); } catch { } }
public void Show(AnimateMode mode, uint time) { Image logo = Rockband_Drum_Kit.Properties.Resources.SplashBG; this.mBrush = new TextureBrush(logo); this.mMode = mode; this.mTime = time; this.mTextFont = new Font(FontFamily.GenericSansSerif, 12, FontStyle.Regular, GraphicsUnit.Pixel); this.Size = logo.Size; this.mRScreen = Screen.PrimaryScreen.Bounds; if (this.mStringFormat == null) { this.mStringFormat = new StringFormat(); this.mStringFormat.Alignment = StringAlignment.Near; this.mStringFormat.LineAlignment = StringAlignment.Near; this.mStringFormat.Trimming = StringTrimming.EllipsisWord; } base.X = mRScreen.Left + mRScreen.Width / 2 - this.Width / 2; base.Y = mRScreen.Top + mRScreen.Height / 2 - this.Height / 2; if (time > 0) base.ShowAnimate(mode, time); else base.Show(); }
public void Close(AnimateMode mode, uint time) { HideAnimate(mode, time); }
void RepairState(Control control, AnimateMode mode) { invokerControl.Invoke(new MethodInvoker(() => { try { switch (mode) { case AnimateMode.Hide: control.Visible = false; break; case AnimateMode.Show: control.Visible = true; break; } } catch { //form was closed } })); }
public void EndUpdate() { var bmp = GetBackground(AnimatedControl, true, true); #if debug bmp.Save("c:\\bmp.png"); #endif if (animation.AnimateOnlyDifferences) TransfromHelper.CalcDifference(bmp, BgBmp); ctrlBmp = bmp; mode = AnimateMode.Update; #if debug ctrlBmp.Save("c:\\ctrlBmp.png"); #endif }
/// <summary> /// Shows the window with animation effect. Position determined by Location property in screen coordinates /// </summary> /// <param name="mode">Effect to be applied</param> /// <param name="time">Time, in milliseconds, for effect playing</param> public virtual void ShowAnimate(AnimateMode mode, uint time) { uint dwFlag=0; switch(mode) { case AnimateMode.Blend: dwFlag = User32.AW_BLEND; break; case AnimateMode.ExpandCollapse: dwFlag = User32.AW_CENTER; break; case AnimateMode.SlideLeftToRight: dwFlag = User32.AW_HOR_POSITIVE | User32.AW_SLIDE; break; case AnimateMode.SlideRightToLeft: dwFlag = User32.AW_HOR_NEGATIVE | User32.AW_SLIDE; break; case AnimateMode.SlideTopToBottom: dwFlag = User32.AW_VER_POSITIVE | User32.AW_SLIDE; break; case AnimateMode.SlideBottmToTop: dwFlag = User32.AW_VER_NEGATIVE | User32.AW_SLIDE; break; case AnimateMode.RollLeftToRight: dwFlag = User32.AW_HOR_POSITIVE; break; case AnimateMode.RollRightToLeft: dwFlag = User32.AW_HOR_NEGATIVE; break; case AnimateMode.RollBottmToTop: dwFlag = User32.AW_VER_NEGATIVE; break; case AnimateMode.RollTopToBottom: dwFlag = User32.AW_VER_POSITIVE; break; } if(base.Handle == IntPtr.Zero) this.CreateWindowOnly(); if((dwFlag & User32.AW_BLEND) != 0) this.AnimateWithBlend(true, time); else User32.AnimateWindow(base.Handle, time, dwFlag); }
/// <summary> /// Shows the window with animation effect. /// </summary> /// <param name="x">x-coordinate of window in screen coordinates</param> /// <param name="y">x-coordinate of window in screen coordinates</param> /// <param name="mode">Effect to be applied</param> /// <param name="time">Time, in milliseconds, for effect playing</param> public virtual void ShowAnimate(int x, int y, AnimateMode mode, uint time) { this._location.X = x; this._location.Y = y; this.ShowAnimate(mode, time); }
/// <summary> /// Adds the contol to animation queue. /// </summary> /// <param name="control">Target control</param> /// <param name="mode">Animation mode</param> /// <param name="parallel">Allows to animate it same time as other animations</param> /// <param name="animation">Personal animation</param> public void AddToQueue(Control control, AnimateMode mode, bool parallel = true, Animation animation = null, Rectangle clipRectangle = default(Rectangle)) { if(animation == null) animation = DefaultAnimation; if (control is IFakeControl) { control.Visible = false; return; } var item = new QueueItem() { animation = animation, control = control, IsActive = parallel, mode = mode, clipRectangle = clipRectangle }; //check visible state switch (mode) { case AnimateMode.Show: if (control.Visible)//already showed { OnCompleted(new QueueItem {control = control, mode = mode}); return; } break; case AnimateMode.Hide: if (!control.Visible)//already hidden { OnCompleted(new QueueItem { control = control, mode = mode }); return; } break; } //add to queue lock (queue) queue.Add(item); lock (requests) requests.Add(item); }
public DoubleBitmap(Control control, AnimateMode mode, Animation animation, float timeStep, Rectangle controlClipRect) { this.animation = animation; this.AnimatedControl = control; this.mode = mode; if (controlClipRect == default(Rectangle)) { this.clipRect = new Rectangle(Point.Empty, GetBounds().Size); } else { this.clipRect = ControlRectToMyRect(controlClipRect); } if (mode == AnimateMode.Show || mode == AnimateMode.BeginUpdate) { timeStep = -timeStep; } this.TimeStep = timeStep * (animation.TimeCoeff == 0f ? 1f : animation.TimeCoeff); if (this.TimeStep == 0f) { timeStep = 0.01f; } if (control.Parent == null) { throw new Exception("Can not create DoubleBitmap because animated control has not parent."); } Visible = false; SetStyle(ControlStyles.Selectable, false); SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true); switch (mode) { case AnimateMode.Hide: { bgBmp = GetBackground(control); this.Bounds = GetBounds(); this.Parent = control.Parent; var i = control.Parent.Controls.GetChildIndex(control); control.Parent.Controls.SetChildIndex(this, i); ctrlBmp = GetForeground(control); this.Visible = true; control.Visible = false; } break; case AnimateMode.Show: { bgBmp = GetBackground(control); var i = control.Parent.Controls.GetChildIndex(control); this.Parent = control.Parent; this.Bounds = GetBounds(); control.Parent.Controls.SetChildIndex(this, i); this.Visible = true; control.Visible = true; ctrlBmp = GetForeground(control); } break; case AnimateMode.BeginUpdate: case AnimateMode.Update: { this.Bounds = GetBounds(); this.Parent = control.Parent; var i = control.Parent.Controls.GetChildIndex(control); control.Parent.Controls.SetChildIndex(this, i); bgBmp = GetBackground(control, true); this.Visible = true; #if debug bgBmp.Save("c:\\bgBmp.png"); #endif } break; } CurrentTime = timeStep > 0 ? animation.MinTime : animation.MaxTime; }
/// <summary> /// Show given text on OSD-window /// </summary> /// <param name="pt">Top-left corner of text in screen coordinates</param> /// <param name="alpha">Transparency of text</param> /// <param name="textColor">Color of text</param> /// <param name="textFont">Font of text</param> /// <param name="showTimeMSec">How long text will be remain on screen, in millisecond</param> /// <param name="mode">Effect to be applied. Work only if <c>time</c> greater than 0</param> /// <param name="time">Time, in milliseconds, for effect playing. If this equal to 0 <c>mode</c> ignored and text showed at once</param> /// <param name="text">Text to display</param> public void Show(Point pt, byte alpha, Color textColor, Font textFont, int showTimeMSec, AnimateMode mode, uint time, string text) { if (this._viewClock != null) { _viewClock.Stop(); _viewClock.Dispose(); } this._brush = new SolidBrush(textColor); this._textFont = textFont; this._text = text; this._mode = mode; this._time = time; SizeF textArea; this._rScreen = Screen.PrimaryScreen.Bounds; if (this._stringFormat == null) { this._stringFormat = new StringFormat(); this._stringFormat.Alignment = StringAlignment.Near; this._stringFormat.LineAlignment = StringAlignment.Near; this._stringFormat.Trimming = StringTrimming.EllipsisWord; } using (Bitmap bm = new Bitmap(base.Width, base.Height)) using (Graphics fx = Graphics.FromImage(bm)) textArea = fx.MeasureString(text, textFont, this._rScreen.Width, this._stringFormat); base.Location = pt; base.Alpha = alpha; base.Size = new Size((int)Math.Ceiling(textArea.Width), (int)Math.Ceiling(textArea.Height)); if (time > 0) { base.ShowAnimate(mode, time); } else { base.Show(); } _viewClock = new System.Windows.Forms.Timer(); _viewClock.Tick += new System.EventHandler(viewTimer); _viewClock.Interval = showTimeMSec; _viewClock.Start(); }
/// <summary> /// Shows the window with a specific animation. /// </summary> /// <param name="x">The horizontal coordinate.</param> /// <param name="y">The vertical coordinate.</param> /// <param name="mode">An <see cref="AnimateMode"/> parameter.</param> public virtual void ShowAnimate(int x, int y, AnimateMode mode) { uint flag = AnimateWindow.AW_CENTER; switch (mode) { case AnimateMode.Blend: Show(x, y, true); return; case AnimateMode.ExpandCollapse: flag = AnimateWindow.AW_CENTER; break; case AnimateMode.SlideLeftToRight: flag = (AnimateWindow.AW_HOR_POSITIVE | AnimateWindow.AW_SLIDE); break; case AnimateMode.SlideRightToLeft: flag = (AnimateWindow.AW_HOR_NEGATIVE | AnimateWindow.AW_SLIDE); break; case AnimateMode.SlideTopToBottom: flag = (AnimateWindow.AW_VER_POSITIVE | AnimateWindow.AW_SLIDE); break; case AnimateMode.SlideBottomToTop: flag = (AnimateWindow.AW_VER_NEGATIVE | AnimateWindow.AW_SLIDE); break; case AnimateMode.RollLeftToRight: flag = (AnimateWindow.AW_HOR_POSITIVE); break; case AnimateMode.RollRightToLeft: flag = (AnimateWindow.AW_HOR_NEGATIVE); break; case AnimateMode.RollBottomToTop: flag = (AnimateWindow.AW_VER_POSITIVE); break; case AnimateMode.RollTopToBottom: flag = (AnimateWindow.AW_VER_NEGATIVE); break; } if (_supportsLayered) { if (Handle == IntPtr.Zero) CreateHandle(CreateParams); UpdateLayeredWindow(); User32.AnimateWindow(Handle, 100, flag); } else { Show(x, y); } }
public void AddToQueue(Control control, AnimateMode mode, bool parallel = true, Animation animation = null, Rectangle clipRectangle = new Rectangle()) { if (animation == null) { animation = this.DefaultAnimation; } if (control is IFakeControl) { control.Visible = false; } else { QueueItem item = new QueueItem { animation = animation, control = control, IsActive = parallel, mode = mode, clipRectangle = clipRectangle }; switch (mode) { case AnimateMode.Show: { if (!control.Visible) { break; } QueueItem item2 = new QueueItem { control = control, mode = mode }; this.OnCompleted(item2); return; } case AnimateMode.Hide: { if (control.Visible) { break; } QueueItem item3 = new QueueItem { control = control, mode = mode }; this.OnCompleted(item3); return; } } lock (this.queue) { this.queue.Add(item); } lock (this.requests) { this.requests.Add(item); } } }
/// <summary> /// Show given text on OSD-window /// </summary> /// <param name="pt">Top-left corner of text in screen coordinates</param> /// <param name="alpha">Transparency of text</param> /// <param name="textColor">Color of text</param> /// <param name="textFont">Font of text</param> /// <param name="showTimeMSec">How long text will be remain on screen, in millisecond</param> /// <param name="mode">Effect to be applied. Work only if <c>time</c> greater than 0</param> /// <param name="time">Time, in milliseconds, for effect playing. If this equal to 0 <c>mode</c> ignored and text showed at once</param> /// <param name="text">Text to display</param> public void Show(string text, Point pt, byte alpha, Color textColor, Font textFont, int showTimeMSec, AnimateMode mode, uint time) { if (this._viewClock != null) { _viewClock.Stop(); _viewClock.Dispose(); } this._brush = new SolidBrush(textColor); this._textFont = textFont; this._text = text; this._mode = mode; this._time = time; SizeF textArea; if (this._stringFormat == null) { _stringFormat = DefaultStringFormat; } textArea = MeasureString(text, textFont, _stringFormat); base.Location = pt; base.Alpha = alpha; base.Size = new Size((int)Math.Ceiling(textArea.Width), (int)Math.Ceiling(textArea.Height)); if (time > 0) { base.ShowAnimate(mode, time); } else { base.Show(); } _viewClock = new Timer(); _viewClock.Tick += viewTimer; _viewClock.Interval = showTimeMSec; _viewClock.Start(); }
/// <summary> /// Hides the window with animation effect and release it's handle. /// </summary> /// <param name="mode">Effect to be applied</param> /// <param name="time">Time, in milliseconds, for effect playing</param> public virtual void HideAnimate(AnimateMode mode, uint time) { if (base.Handle == IntPtr.Zero) { return; } uint dwFlag = 0; switch (mode) { case AnimateMode.Blend: dwFlag = User32.AW_BLEND; break; case AnimateMode.ExpandCollapse: dwFlag = User32.AW_CENTER; break; case AnimateMode.SlideLeftToRight: dwFlag = User32.AW_HOR_POSITIVE | User32.AW_SLIDE; break; case AnimateMode.SlideRightToLeft: dwFlag = User32.AW_HOR_NEGATIVE | User32.AW_SLIDE; break; case AnimateMode.SlideTopToBottom: dwFlag = User32.AW_VER_POSITIVE | User32.AW_SLIDE; break; case AnimateMode.SlideBottmToTop: dwFlag = User32.AW_VER_NEGATIVE | User32.AW_SLIDE; break; case AnimateMode.RollLeftToRight: dwFlag = User32.AW_HOR_POSITIVE; break; case AnimateMode.RollRightToLeft: dwFlag = User32.AW_HOR_NEGATIVE; break; case AnimateMode.RollBottmToTop: dwFlag = User32.AW_VER_NEGATIVE; break; case AnimateMode.RollTopToBottom: dwFlag = User32.AW_VER_POSITIVE; break; } dwFlag |= User32.AW_HIDE; if ((dwFlag & User32.AW_BLEND) != 0) { this.AnimateWithBlend(false, time); } else { User32.AnimateWindow(base.Handle, time, dwFlag); } this.Hide(); }
public Controller(Control control, AnimateMode mode, Animation animation, float timeStep, Rectangle controlClipRect) { this.DoubleBitmap = new DoubleBitmapControl(); (this.DoubleBitmap as IFakeControl).FramePainting += new EventHandler<PaintEventArgs>(this.OnFramePainting); (this.DoubleBitmap as IFakeControl).FramePainted += new EventHandler<PaintEventArgs>(this.OnFramePainting); (this.DoubleBitmap as IFakeControl).TransfromNeeded += new EventHandler<TransfromNeededEventArg>(this.OnTransfromNeeded); this.DoubleBitmap.MouseDown += new MouseEventHandler(this.OnMouseDown); this.animation = animation; this.AnimatedControl = control; this.mode = mode; if (controlClipRect == new Rectangle()) { this.clipRect = new Rectangle(Point.Empty, this.GetBounds().Size); } else { this.clipRect = this.ControlRectToMyRect(controlClipRect); } if ((mode == AnimateMode.Show) || (mode == AnimateMode.BeginUpdate)) { timeStep = -timeStep; } this.TimeStep = timeStep * ((animation.TimeCoeff == 0f) ? 1f : animation.TimeCoeff); if (this.TimeStep == 0f) { timeStep = 0.01f; } switch (mode) { case AnimateMode.Show: this.BgBmp = this.GetBackground(control, false, false); (this.DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); this.DoubleBitmap.Visible = true; this.DoubleBitmap.Refresh(); control.Visible = true; this.ctrlBmp = this.GetForeground(control); break; case AnimateMode.Hide: this.BgBmp = this.GetBackground(control, false, false); (this.DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); this.ctrlBmp = this.GetForeground(control); this.DoubleBitmap.Visible = true; control.Visible = false; break; case AnimateMode.Update: case AnimateMode.BeginUpdate: (this.DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); this.BgBmp = this.GetBackground(control, true, false); this.DoubleBitmap.Visible = true; break; } this.CurrentTime = (timeStep > 0f) ? animation.MinTime : animation.MaxTime; }
/// <summary> /// Shows the window with a specific animation. /// </summary> /// <param name="x">The horizontal coordinate.</param> /// <param name="y">The vertical coordinate.</param> /// <param name="mode">An <see cref="AnimateMode"/> parameter.</param> public virtual void ShowAnimate(int x, int y, AnimateMode mode) { uint flag = (uint)AnimateWindow.AW_CENTER; switch (mode) { case AnimateMode.Blend: this.Show(x, y, true); return; case AnimateMode.ExpandCollapse: flag = (uint)AnimateWindow.AW_CENTER; break; case AnimateMode.SlideLeftToRight: flag = (uint)(AnimateWindow.AW_HOR_POSITIVE | AnimateWindow.AW_SLIDE); break; case AnimateMode.SlideRightToLeft: flag = (uint)(AnimateWindow.AW_HOR_NEGATIVE | AnimateWindow.AW_SLIDE); break; case AnimateMode.SlideBottmToTop: flag = (uint)(AnimateWindow.AW_VER_POSITIVE | AnimateWindow.AW_SLIDE); break; case AnimateMode.SlideTopToBottom: flag = (uint)(AnimateWindow.AW_VER_NEGATIVE | AnimateWindow.AW_SLIDE); break; case AnimateMode.RollLeftToRight: flag = (uint)(AnimateWindow.AW_HOR_POSITIVE); break; case AnimateMode.RollRightToLeft: flag = (uint)(AnimateWindow.AW_HOR_NEGATIVE); break; case AnimateMode.RollBottmToTop: flag = (uint)(AnimateWindow.AW_VER_POSITIVE); break; case AnimateMode.RollTopToBottom: flag = (uint)(AnimateWindow.AW_VER_NEGATIVE); break; } if (this.supportsLayered) { this.ShowInvisible(x, y); this.UpdateLayeredWindow(); User32.AnimateWindow(base.Handle, 200, flag); } else { this.Show(x, y); } }
public void EndUpdate() { Bitmap bitmap = this.GetBackground(this.AnimatedControl, true, true); if (this.animation.AnimateOnlyDifferences) { TransfromHelper.CalcDifference(bitmap, this.BgBmp); } this.ctrlBmp = bitmap; this.mode = AnimateMode.Update; }
bool IsStateOK(Control control, AnimateMode mode) { switch (mode) { case AnimateMode.Hide: return !control.Visible; case AnimateMode.Show: return control.Visible; } return true; }
/// <summary> /// Show given text on OSD-window /// </summary> /// <param name="pt">Top-left corner of text in screen coordinates</param> /// <param name="alpha">Transparency of text</param> /// <param name="textColor">Color of text</param> /// <param name="textFont">Font of text</param> /// <param name="showTimeMSec">How long text will be remain on screen, in millisecond</param> /// <param name="mode">Effect to be applied. Work only if <c>time</c> greater than 0</param> /// <param name="time"> /// Time, in milliseconds, for effect playing. If this equal to 0 <c>mode</c> ignored and text showed at /// once /// </param> /// <param name="text">Text to display</param> public void Show(Point pt, byte alpha, Color textColor, Font textFont, int showTimeMSec, AnimateMode mode, uint time, string text) { if (_viewClock != null) { _viewClock.Stop(); _viewClock.Dispose(); } _brush = new SolidBrush(textColor); _textFont = textFont; _text = text; _mode = mode; _time = time; SizeF textArea; _rScreen = Screen.PrimaryScreen.Bounds; if (_stringFormat == null) { _stringFormat = new StringFormat(); _stringFormat.Alignment = StringAlignment.Near; _stringFormat.LineAlignment = StringAlignment.Near; _stringFormat.Trimming = StringTrimming.EllipsisWord; } using (var bm = new Bitmap(Width, Height)) using (var fx = Graphics.FromImage(bm)) textArea = fx.MeasureString(text, textFont, _rScreen.Width, _stringFormat); Location = pt; Alpha = alpha; Size = new Size((int)Math.Ceiling(textArea.Width), (int)Math.Ceiling(textArea.Height)); if (time > 0) { ShowAnimate(mode, time); } else { base.Show(); } _viewClock = new Timer(); _viewClock.Tick += viewTimer; _viewClock.Interval = showTimeMSec; _viewClock.Start(); }
/// <summary> /// Hides the window with animation effect and release it's handle. /// </summary> /// <param name="mode">Effect to be applied</param> /// <param name="time">Time, in milliseconds, for effect playing</param> public virtual void HideAnimate(AnimateMode mode, uint time) { if (Handle == IntPtr.Zero) return; uint dwFlag = 0; switch (mode) { case AnimateMode.Blend: dwFlag = User32.AW_BLEND; break; case AnimateMode.ExpandCollapse: dwFlag = User32.AW_CENTER; break; case AnimateMode.SlideLeftToRight: dwFlag = User32.AW_HOR_POSITIVE | User32.AW_SLIDE; break; case AnimateMode.SlideRightToLeft: dwFlag = User32.AW_HOR_NEGATIVE | User32.AW_SLIDE; break; case AnimateMode.SlideTopToBottom: dwFlag = User32.AW_VER_POSITIVE | User32.AW_SLIDE; break; case AnimateMode.SlideBottmToTop: dwFlag = User32.AW_VER_NEGATIVE | User32.AW_SLIDE; break; case AnimateMode.RollLeftToRight: dwFlag = User32.AW_HOR_POSITIVE; break; case AnimateMode.RollRightToLeft: dwFlag = User32.AW_HOR_NEGATIVE; break; case AnimateMode.RollBottmToTop: dwFlag = User32.AW_VER_NEGATIVE; break; case AnimateMode.RollTopToBottom: dwFlag = User32.AW_VER_POSITIVE; break; } dwFlag |= User32.AW_HIDE; if ((dwFlag & User32.AW_BLEND) != 0) AnimateWithBlend(false, time); else User32.AnimateWindow(Handle, time, dwFlag); Hide(); }
/// <summary> /// Hides the window with a specific animation. /// </summary> /// <param name="mode">An <see cref="AnimateMode"/> parameter.</param> public virtual void HideAnimate(AnimateMode mode) { uint flag = (uint)AnimateWindow.AW_CENTER; switch (mode) { case AnimateMode.Blend: this.HideWindowWithAnimation(); return; case AnimateMode.ExpandCollapse: flag = (uint)AnimateWindow.AW_CENTER; break; case AnimateMode.SlideLeftToRight: flag = (uint)(AnimateWindow.AW_HOR_POSITIVE | AnimateWindow.AW_SLIDE); break; case AnimateMode.SlideRightToLeft: flag = (uint)(AnimateWindow.AW_HOR_NEGATIVE | AnimateWindow.AW_SLIDE); break; case AnimateMode.SlideBottmToTop: flag = (uint)(AnimateWindow.AW_VER_POSITIVE | AnimateWindow.AW_SLIDE); break; case AnimateMode.SlideTopToBottom: flag = (uint)(AnimateWindow.AW_VER_NEGATIVE | AnimateWindow.AW_SLIDE); break; case AnimateMode.RollLeftToRight: flag = (uint)(AnimateWindow.AW_HOR_POSITIVE); break; case AnimateMode.RollRightToLeft: flag = (uint)(AnimateWindow.AW_HOR_NEGATIVE); break; case AnimateMode.RollBottmToTop: flag = (uint)(AnimateWindow.AW_VER_POSITIVE); break; case AnimateMode.RollTopToBottom: flag = (uint)(AnimateWindow.AW_VER_NEGATIVE); break; } flag = (uint)((uint)flag | (uint)AnimateWindow.AW_HIDE); if (this.supportsLayered) { this.UpdateLayeredWindow(); User32.AnimateWindow(base.Handle, 200, flag); } this.Hide(); }
/// <summary> /// Initializes a new instance of the <see cref="Controller"/> class. /// </summary> /// <param name="control">The control.</param> /// <param name="mode">The mode.</param> /// <param name="animation">The animation.</param> /// <param name="timeStep">The time step.</param> /// <param name="controlClipRect">The control clip rect.</param> public Controller(Control control, AnimateMode mode, ZeroitAnimate_Animation animation, float timeStep, Rectangle controlClipRect) { if (control is System.Windows.Forms.Form) { DoubleBitmap = new DoubleBitmapForm(); } else { DoubleBitmap = new DoubleBitmapControl(); } (DoubleBitmap as IFakeControl).FramePainting += OnFramePainting; (DoubleBitmap as IFakeControl).FramePainted += OnFramePainting; (DoubleBitmap as IFakeControl).TransfromNeeded += OnTransfromNeeded; DoubleBitmap.MouseDown += OnMouseDown; this.animation = animation; this.AnimatedControl = control; this.mode = mode; this.CustomClipRect = controlClipRect; if (mode == AnimateMode.Show || mode == AnimateMode.BeginUpdate) { timeStep = -timeStep; } this.TimeStep = timeStep * (animation.TimeCoeff == 0f ? 1f : animation.TimeCoeff); if (this.TimeStep == 0f) { timeStep = 0.01f; } try { switch (mode) { case AnimateMode.Hide: { BgBmp = GetBackground(control); (DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); ctrlBmp = GetForeground(control); DoubleBitmap.Visible = true; control.Visible = false; } break; case AnimateMode.Show: { BgBmp = GetBackground(control); (DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); DoubleBitmap.Visible = true; DoubleBitmap.Refresh(); control.Visible = true; ctrlBmp = GetForeground(control); } break; case AnimateMode.BeginUpdate: case AnimateMode.Update: { (DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); BgBmp = GetBackground(control, true); DoubleBitmap.Visible = true; } break; } } catch { Dispose(); } #if debug BgBmp.Save("c:\\bgBmp.png"); if (ctrlBmp != null) { ctrlBmp.Save("c:\\ctrlBmp.png"); } #endif CurrentTime = timeStep > 0 ? animation.MinTime : animation.MaxTime; }
void RepairState(Control control, AnimateMode mode) { control.BeginInvoke(new MethodInvoker(() => { switch (mode) { case AnimateMode.Hide: control.Visible = false; break; case AnimateMode.Show: control.Visible = true; break; } })); }
private Controller CreateDoubleBitmap(Control control, AnimateMode mode, Animation animation, Rectangle clipRect) { Controller controller = new Controller(control, mode, animation, this.TimeStep, clipRect); controller.TransfromNeeded += new EventHandler<TransfromNeededEventArg>(this.OnTransformNeeded); controller.NonLinearTransfromNeeded += new EventHandler<NonLinearTransfromNeededEventArg>(this.OnNonLinearTransfromNeeded); controller.MouseDown += new EventHandler<MouseEventArgs>(this.OnMouseDown); controller.DoubleBitmap.Cursor = this.Cursor; controller.FramePainted += new EventHandler<PaintEventArgs>(this.OnFramePainted); return controller; }
private Controller CreateDoubleBitmap(Control control, AnimateMode mode, Animation animation, Rectangle clipRect) { var controller = new Controller(control, mode, animation, TimeStep, clipRect); controller.TransfromNeeded += OnTransformNeeded; controller.NonLinearTransfromNeeded += OnNonLinearTransfromNeeded; controller.MouseDown += OnMouseDown; controller.DoubleBitmap.Cursor = Cursor; controller.FramePainted += OnFramePainted; return controller; }
private void RepairState(Control control, AnimateMode mode) { control.BeginInvoke(new MethodInvoker(delegate() { switch (mode) { case AnimateMode.Show: control.Visible = true; return; case AnimateMode.Hide: control.Visible = false; return; } })); }
public Controller(Control control, AnimateMode mode, Animation animation, float timeStep, Rectangle controlClipRect) { if (control is Form) DoubleBitmap = new DoubleBitmapForm(); else DoubleBitmap = new DoubleBitmapControl(); (DoubleBitmap as IFakeControl).FramePainting += OnFramePainting; (DoubleBitmap as IFakeControl).FramePainted += OnFramePainting; (DoubleBitmap as IFakeControl).TransfromNeeded += OnTransfromNeeded; DoubleBitmap.MouseDown += OnMouseDown; this.animation = animation; this.AnimatedControl = control; this.mode = mode; this.CustomClipRect = controlClipRect; if (mode == AnimateMode.Show || mode == AnimateMode.BeginUpdate) timeStep = -timeStep; this.TimeStep = timeStep * (animation.TimeCoeff == 0f ? 1f : animation.TimeCoeff); if (this.TimeStep == 0f) timeStep = 0.01f; try { switch (mode) { case AnimateMode.Hide: { BgBmp = GetBackground(control); (DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); ctrlBmp = GetForeground(control); DoubleBitmap.Visible = true; control.Visible = false; } break; case AnimateMode.Show: { BgBmp = GetBackground(control); (DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); DoubleBitmap.Visible = true; DoubleBitmap.Refresh(); control.Visible = true; ctrlBmp = GetForeground(control); } break; case AnimateMode.BeginUpdate: case AnimateMode.Update: { (DoubleBitmap as IFakeControl).InitParent(control, animation.Padding); BgBmp = GetBackground(control, true); DoubleBitmap.Visible = true; } break; } } catch { Dispose(); } #if debug BgBmp.Save("c:\\bgBmp.png"); if (ctrlBmp != null) ctrlBmp.Save("c:\\ctrlBmp.png"); #endif CurrentTime = timeStep > 0 ? animation.MinTime : animation.MaxTime; }
public static void Display(string text, int x, int y, int opacity, int displayTime, AnimateMode animation, int animationTime) { if (opacity < 0) { throw new ArgumentOutOfRangeException("Opacity can not be less than zero."); } if (animationTime < 0) { throw new ArgumentOutOfRangeException("AnimationTime can no be less than zero."); } OSDForm form = new OSDForm(); Point point = new Point(x, y); Font font = OSDForm.DefaultFont; Color textColor = Color.Blue; form.Show(text, point, (byte)opacity, textColor, font, displayTime, animation, (uint)animationTime); }