Ejemplo n.º 1
0
        //-------


        public TopWindowEventRoot(RenderElement topRenderElement)
        {
            _iTopBoxEventPortal  = _topWinBoxEventPortal = new RenderElementEventPortal(topRenderElement);
            _rootgfx             = topRenderElement.Root;
            _hoverMonitoringTask = new UIHoverMonitorTask(OnMouseHover);
            //
            UIPlatform.RegisterTimerTask(_hoverMonitoringTask);
        }
Ejemplo n.º 2
0
        void GenerateAnimation(PennerAnimationGeneratorDelegate pennerAnimator)
        {
            float startValue       = 0;
            float stopValue        = 300;
            float sec              = 0;
            float completeDuration = 10;

            _animationBoard.ClearChildren();

            List <double> calculatedValues = new List <double>();

            while (sec < completeDuration)
            {
                double currentValue = pennerAnimator(sec, startValue, stopValue, completeDuration);
                //step 0.1 sec (100 ms), until complete at 5 sec
                sec += 0.1f;
                calculatedValues.Add(currentValue);
                //System.Console.WriteLine(currentValue.ToString());
            }

            //create image box that present the results
            int j = calculatedValues.Count;

            for (int i = 0; i < j; ++i)
            {
                Box box = new Box(5, 5);
                box.SetLocation(5 * i, (int)calculatedValues[i]);
                _animationBoard.AddChild(box);
            }

            //-----
            //show animation

            Box sampleBox1 = new Box(600, 20);

            _animationBoard.AddChild(sampleBox1);
            sampleBox1.BackColor = PixelFarm.Drawing.Color.Red;
            int step = 0;

            UIPlatform.RegisterTimerTask(10, tim =>
            {
                //animate the box
                sampleBox1.SetLocation(10, (int)calculatedValues[step]);
                if (step < j - 1)
                {
                    step++;
                }
                else
                {
                    //unregister and remove the task
                    tim.Remove();
                }
            });
        }
Ejemplo n.º 3
0
        protected override void OnStart(AppHost host)
        {
            var sampleButton = new LayoutFarm.CustomWidgets.Box(30, 30);

            host.AddChild(sampleButton);

            sampleButton.MouseDown += ((s, e2) =>
            {
                //click to create custom cursor
                if (!_showCustomCursor)
                {
                    if (_myCursor == null)
                    {
                        using (MemBitmap temp = new MemBitmap(16, 16))
                            using (Tools.BorrowAggPainter(temp, out AggPainter p))
                            {
                                //1. create a simple bitmap for our cursor
                                p.Clear(Color.FromArgb(0, Color.White));
                                p.FillRect(1, 1, 10, 10, Color.FromArgb(150, Color.Green));
                                p.FillRect(3, 3, 4, 4, Color.Yellow);
                                //-------
                                //create cursor file

                                CursorFile curFile = new CursorFile();

                                var iconBmp = new WindowBitmap(temp.Width, temp.Height);
                                iconBmp.RawBitmapData = MemBitmap.CopyImgBuffer(temp);

                                curFile.AddBitmap(iconBmp, 1, 1); //add bitmap with hotspot
                                curFile.Save("myicon.cur");       //save to temp file
                                _myCursor = UIPlatform.CreateCursor(new CursorRequest("myicon.cur", 16));
                            }
                    }
                    e2.CustomMouseCursor = _myCursor;
                    _showCustomCursor = true;
                }
                else
                {
                    _showCustomCursor = false;
                    e2.MouseCursorStyle = MouseCursorStyle.Default;
                }
            });

            sampleButton.MouseMove += ((s, e2) =>
            {
                if (_showCustomCursor && _myCursor != null)
                {
                    e2.CustomMouseCursor = _myCursor;
                }
            });
        }
Ejemplo n.º 4
0
        public TopWindowEventRoot(RootGraphic rootgfx, TopWindowRenderBox topRenderElement)
        {
            _mouseDownEventArgs = new UIMouseDownEventArgs();
            _mouseMoveEventArgs = new UIMouseMoveEventArgs();
            _mouseUpEventArgs   = new UIMouseUpEventArgs();
            _wheelEventArgs     = new UIMouseWheelEventArgs();


            _topWinBoxEventPortal = new RenderElementEventPortal(topRenderElement);
#if DEBUG
            _topWinBoxEventPortal.dbugRootGraphics = (MyRootGraphic)rootgfx;
#endif
            _iTopBoxEventPortal = _topWinBoxEventPortal;
            _rootgfx            = rootgfx;

            _hoverMonitoringTask          = new UIHoverMonitorTask();
            _hoverMonitoringTask.Interval = 100;//ms
            _hoverMonitoringTask.Enabled  = true;
            UIPlatform.RegisterTimerTask(_hoverMonitoringTask);
        }
Ejemplo n.º 5
0
 protected void SetAsDefaultPlatform()
 {
     s_ui_plaform = this;
 }
Ejemplo n.º 6
0
        static void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.EaseBox box)
        {
            //1. mouse down

            bool mouseUpFromDragging = false;

            System.DateTime mouseDownTime = System.DateTime.MinValue;
            System.DateTime mouseUpTime = System.DateTime.MinValue;
            int             mdown_x = 0, mdown_y = 0;
            double          velo_x = 0;
            double          velo_y = 0;
            int             x_dir  = 0;
            int             y_dir  = 0;

            UI.UITimerTask animateTimer = new UITimerTask(tim =>
            {
                box.SetLocation(box.Left + (int)(velo_x * 10 * x_dir),
                                box.Top + (int)(velo_y * 10 * y_dir));

                velo_x -= 0.1;
                velo_y -= 0.1;

                if (velo_x <= 0)
                {
                    velo_x = 0;
                }
                if (velo_y <= 0)
                {
                    velo_y = 0;
                }
                if (velo_x == 0 && velo_y == 0)
                {
                    tim.Enabled = false;
                }
            });
            animateTimer.IntervalInMillisec = 10;
            UIPlatform.RegisterTimerTask(animateTimer);


            box.MouseDown += (s, e) =>
            {
                mdown_x = box.Left;
                mdown_y = box.Top;
                animateTimer.Enabled = false;

                mouseDownTime       = System.DateTime.Now;
                mouseUpFromDragging = false;
                //
                box.BackColor      = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue);
                e.MouseCursorStyle = MouseCursorStyle.Pointer;
            };
            //2. mouse up
            box.MouseUp += (s, e) =>
            {
                mouseUpTime        = System.DateTime.Now;
                e.MouseCursorStyle = MouseCursorStyle.Default;
                box.BackColor      = Color.LightGray;

                if (mouseUpFromDragging)
                {
                    int mup_x = box.Left;
                    int mup_y = box.Top;

                    System.TimeSpan drag_timespan = mouseUpTime - mouseDownTime;
                    double          ms            = drag_timespan.Milliseconds;

                    double displacement_x = mup_x - mdown_x;
                    double displacement_y = mup_y - mdown_y;
                    velo_x = System.Math.Abs(displacement_x / ms);
                    velo_y = System.Math.Abs(displacement_y / ms);

                    x_dir = (mup_x >= mdown_x) ? 1 : -1;
                    y_dir = (mup_y >= mdown_y) ? 1 : -1;
                    animateTimer.Enabled = true;
                }
            };
            box.MouseDrag += (s, e) =>
            {
                mouseUpFromDragging = true;
                box.BackColor       = KnownColors.FromKnownColor(KnownColor.GreenYellow);
                Point pos = box.Position;
                box.SetLocation(pos.X + e.XDiff, pos.Y + e.YDiff);
                e.MouseCursorStyle = MouseCursorStyle.Pointer;
                e.CancelBubbling   = true;
            };
        }