Esempio 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);
     }
 }
Esempio 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();
        }
Esempio n. 3
0
        public TilesCanvas(UIElement background)
        {
            _background = background;

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

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

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