/// <summary> /// Handler for update event from child. /// Redraw only in non-freezed mode /// </summary> /// <param name="element"></param> protected override void OnUpdated(UIElement element) { if (!FreezeUpdate) { base.Updated(this); } }
public BaseTileGrid(TileTheme tileTheme, UIElement background, string settingsFile, int gridWidth, int gridHeight) { _tileTheme = tileTheme; _gridWidth = gridWidth; _gridHeight = gridHeight; _settingsFile = settingsFile; // запрет перерисовки во время скроллирования OnStartScroll = () => FreezeUpdate(true); OnStopScroll = () => FreezeUpdate(false); VerticalScroll = true; HorizontalScroll = false; TapHandler = GridClickHandler; HoldHandler = p => { if (!SelectionMode) ShowMainPopupMenu(p); return true; }; // холст контейнер плиток _tilesCanvas = new TilesCanvas(background); Content = _tilesCanvas; ReadTilesSettings(); }
public TilesCanvas(UIElement background) { _background = background; Size = new Size(100, 100).ToPixels(); SizeChanged += (s, e) => CreateBuffer(); }
public DecoratorElement(UIElement target) { Target = target; base.Children.Add(target); target.Parent = this; target.Updated = this.Update; this.SizeChanged += HandleSizeChanged;; }
public virtual void AddElement(UIElement element) { if (this.Children.Contains(element)) return; this.Children.Add(element); element.Parent = this; this.Size = new Size(Math.Max(element.Bounds.Right, this.Size.Width), Math.Max(element.Bounds.Bottom, this.Size.Height)); element.Updated = this.Update; }
// draw direct to screen instead of buffer protected override void OnUpdated(UIElement element) { if ((_tilesCanvas != null) && (_tilesCanvas.FreezeUpdate) ) _tilesCanvas.DirectDraw(this.VerticalOffset); else { base.OnUpdated(element); } }
public static Point ScreenLocaton(UIElement element) { var location = element.Location; var curElement = element; while ((curElement = curElement.Parent) != null) location.Offset(curElement.Location.X, curElement.Location.Y); return location; }
private void CommonAddElement(UIElement element) { element.Parent = this; element.Updated = this.OnUpdated; //! metrohome65 element.ParentControl = this.ParentControl; this.Size = new Size(Math.Max(element.Bounds.Right, this.Size.Width), Math.Max(element.Bounds.Bottom, this.Size.Height)); }
public virtual void AddElement(UIElement element) { if (this.Children.Contains(element)) return; this.Children.Add(element); element.Parent = this; if (AutoResize) this.Size = new Size(Math.Max(element.Bounds.Right, this.Size.Width), Math.Max(element.Bounds.Bottom, this.Size.Height)); element.Updated = this.Update; if (ContentChanged != null) ContentChanged(); }
private void CreateList() { _programsSv = new ProgramsMenu() { Location = new Point(PaddingTop, 0), Size = new Size(100, 100), // initial fake size }; this.SizeChanged += (sender, args) => SetSize(); AddElement(_programsSv); }
public virtual void AddElementAfter(UIElement element, UIElement sibling) { if (!base.Children.Contains(element)) { int index = base.Children.IndexOf(sibling); if (index == -1) { index = base.Children.Count - 1; } base.Children.Insert(index + 1, element); element.Parent = this; base.Size = new Size(Math.Max(element.Bounds.Right, base.Size.Width), Math.Max(element.Bounds.Bottom, base.Size.Height)); element.Updated = new Action(this.Update); } }
public virtual void AddElementAt(int index, UIElement element) { this.Children.Insert(index, element); CommonAddElement(element); }
public virtual void AddElement(UIElement element) { this.Children.Add(element); CommonAddElement(element); }
public void PutAtRight(UIElement anchor, int padding) { this.Location = new Point((anchor.Location.X + anchor.Size.Width) + padding, anchor.Location.Y); }
public void PutAtRight(UIElement anchor) { PutAtRight(anchor, 0); }
public void PutAtLeft(UIElement anchor, int padding) { this.Location = new Point(anchor.Location.X - this.Size.Width - padding, anchor.Location.Y); }
public void PutAtLeft(UIElement anchor) { PutAtLeft(anchor, 0); }
private void ShowGames(UIElement target) { this.launchedTile = target; }
public virtual bool IsShowing(UIElement child) { if (this.Parent != null) { if (child.Bounds.IntersectsWith(new Rectangle(0, 0, this.Size.Width, this.Size.Height))) { return this.Parent.IsShowing(this); } else { return false; } } else { return true; } }
public override void AddElement(UIElement element) { base.AddElement(element); _needRepaint = true; }
/// <summary> /// Handler for update event from child. /// Redraw only triggered element, not whole buffer. For /// </summary> /// <param name="element"></param> protected override void OnUpdated(UIElement element) { if (!FreezeUpdate) { if (element == this) _needRepaint = true; else // repaint in buffer only changed element RepaintElement(element); this.Updated(this); } }
public override void AddElementAt(int index, UIElement element) { base.AddElementAt(index, element); this.Relayout(); }
public override void AddElement(UIElement element) { base.AddElement(element); this.Relayout(); }
// draw direct to screen instead of buffer protected override void OnUpdated(UIElement element) { //base.OnUpdated(element); return; DirectDraw(this.VerticalOffset); }
private void RepaintElement(UIElement element) { if (_buffer == null) return; ClearBuffer(_buffer, element.Bounds); element.Draw(_buffer.DrawingGraphics.CreateChild( element.Location, element.TransformationScaling, element.TransformationCenter)); }
private UIElement SetEntranceAnimationFromBottom(UIElement target) { target.EntranceAnimation = new FunctionBasedAnimation(FunctionBasedAnimation.Functions.BounceEntranceSin) { From = target.Location.Y + target.Size.Height + 200 + new Random().Next(200), To = target.Location.Y, OnAnimation = v => target.Location = new Point(target.Location.X, v) }; return target; }
public override void AddElementAt(int index, UIElement element) { base.AddElementAt(index, element); _needRepaint = true; }
private UIElement SetEntranceAnimationFromLeft(UIElement target) { var random = new Random(); var x = target.Location.X; target.EntranceAnimation = new FunctionBasedAnimation(FunctionBasedAnimation.Functions.BounceEntranceSin) { From = x - 1000 + random.Next(1000 - x - 173), To = x, OnAnimation = v => target.Location = new Point(v, target.Location.Y) }; return target; }
//! MetroHome65 - pass update event sender to parent protected virtual void OnUpdated(UIElement element) { if (this.Updated != null) this.Updated(this); }
private void SetExitAnimationToLeft(UIElement target, Action<UIElement> tapAction) { var random = new Random(); var x = target.Location.X; target.ExitAnimation = new FunctionBasedAnimation(FunctionBasedAnimation.Functions.BounceExitSin) { To = -target.Size.Width - random.Next(1000), From = x, OnAnimation = v => target.Location = new Point(v, target.Location.Y) }; target.TapHandler = p => { (target.ExitAnimation as FunctionBasedAnimation).EaseFunction = v => Math.Pow(v, 15); this.Control.AnimateExit(); this.launching = true; tapAction(target); return true; }; }