Ejemplo n.º 1
0
 /// <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);
     }
 }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        public TilesCanvas(UIElement background)
        {
            _background = background;

            Size = new Size(100, 100).ToPixels();
            SizeChanged += (s, e) => CreateBuffer();
        }
Ejemplo n.º 4
0
 public DecoratorElement(UIElement target)
 {
     Target = target;
     base.Children.Add(target);
     target.Parent = this;
     target.Updated = this.Update;
     this.SizeChanged += HandleSizeChanged;;
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
 // 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);
     }
 }
Ejemplo n.º 7
0
        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;
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
Archivo: Canvas.cs Proyecto: flts/fleux
 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();
 }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
 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);
     }
 }
Ejemplo n.º 12
0
 public virtual void AddElementAt(int index, UIElement element)
 {
     this.Children.Insert(index, element);
     CommonAddElement(element);
 }
Ejemplo n.º 13
0
 public virtual void AddElement(UIElement element)
 {
     this.Children.Add(element);
     CommonAddElement(element);
 }
Ejemplo n.º 14
0
 public void PutAtRight(UIElement anchor, int padding)
 {
     this.Location = new Point((anchor.Location.X + anchor.Size.Width) + padding, anchor.Location.Y);
 }
Ejemplo n.º 15
0
 public void PutAtRight(UIElement anchor)
 {
     PutAtRight(anchor, 0);
 }
Ejemplo n.º 16
0
 public void PutAtLeft(UIElement anchor, int padding)
 {
     this.Location = new Point(anchor.Location.X - this.Size.Width - padding, anchor.Location.Y);
 }
Ejemplo n.º 17
0
 public void PutAtLeft(UIElement anchor)
 {
     PutAtLeft(anchor, 0);
 }
Ejemplo n.º 18
0
 private void ShowGames(UIElement target)
 {
     this.launchedTile = target;
 }
Ejemplo n.º 19
0
 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;
     }
 }
Ejemplo n.º 20
0
        public override void AddElement(UIElement element)
        {
            base.AddElement(element);

            _needRepaint = true;
        }
Ejemplo n.º 21
0
        /// <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);
            }
        }
Ejemplo n.º 22
0
 public override void AddElementAt(int index, UIElement element)
 {
     base.AddElementAt(index, element);
     this.Relayout();
 }
Ejemplo n.º 23
0
 public override void AddElement(UIElement element)
 {
     base.AddElement(element);
     this.Relayout();
 }
Ejemplo n.º 24
0
 // draw direct to screen instead of buffer
 protected override void OnUpdated(UIElement element)
 {
     //base.OnUpdated(element); return;
     DirectDraw(this.VerticalOffset);
 }
Ejemplo n.º 25
0
        private void RepaintElement(UIElement element)
        {
            if (_buffer == null) return;

            ClearBuffer(_buffer, element.Bounds);
            element.Draw(_buffer.DrawingGraphics.CreateChild(
                element.Location, element.TransformationScaling, element.TransformationCenter));
        }
Ejemplo n.º 26
0
 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;
 }
Ejemplo n.º 27
0
        public override void AddElementAt(int index, UIElement element)
        {
            base.AddElementAt(index, element);

            _needRepaint = true;
        }
Ejemplo n.º 28
0
 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;
 }
Ejemplo n.º 29
0
 //! MetroHome65 - pass update event sender to parent
 protected virtual void OnUpdated(UIElement element)
 {
     if (this.Updated != null)
         this.Updated(this);
 }
Ejemplo n.º 30
0
 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;
     };
 }