Esempio n. 1
0
        private void Demo()
        {
            Background = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.reWalls)) { Stretch = Stretch.Fill };

            ImageBrush bar = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.Bar));

            // left panel
            Panel panelNavigation = new Panel(10, 10, 150, 460);
            panelNavigation.Background = new LinearGradientBrush(Color.Bisque, Color.Black, 0, 500, 1000, 500);
            panelNavigation.Background.Opacity = 120;
            panelNavigation.Border = new Pen(Color.Black, 1);
            Children.Add(panelNavigation);

            Panel tlb = new Panel(1, 1, panelNavigation.Width - 2, 25);
            tlb.Background = bar;
            tlb.Children.Add(new Label(10, 5, fontCourierNew10, "Navigation") { ForeColor = Color.CornflowerBlue });
            tlb.TouchDown += delegate(object sender, TouchEventArgs e) { TouchCapture.Capture(tlb); p = e.Point; };
            tlb.TouchMove += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == tlb) { panelNavigation.Translate(e.Point.X - p.X, e.Point.Y - p.Y); p = e.Point; } };
            tlb.TouchUp += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == tlb) TouchCapture.ReleaseCapture(); };
            panelNavigation.Children.Add(tlb);

            //int d = 15;
            //int x = 0;
            ////int y = 5;
            //RadioButtonGroup rbgNavigation = new RadioButtonGroup(10, 30, 15, panelNavigation.Height - 40);
            //panelNavigation.Children.Add(rbgNavigation);
            //rbgNavigation.AddRadioButton(new RadioButton(x, 5, d, true));
            //rbgNavigation.AddRadioButton(new RadioButton(x, 25, d));
            //rbgNavigation.AddRadioButton(new RadioButton(x, 45, d));
            //rbgNavigation.AddRadioButton(new RadioButton(x, 65, d));
            //rbgNavigation.AddRadioButton(new RadioButton(x, 85, d));
            //rbgNavigation.AddRadioButton(new RadioButton(x, 105, d));

            //panelNavigation.Children.Add(new Label(30, 35, fontCourierNew10, "Checkboxes") { ForeColor = Color.White });
            //panelNavigation.Children.Add(new Label(30, 55, fontCourierNew10, "Buttons") { ForeColor = Color.White });

            int x = 5;
            int w = panelNavigation.Width - 2 * x;
            int h = 18;
            int y = 35;
            int step = h + 5;

            //Font fnt = fontRegular;
            Font fnt = fontCourierNew10;
            panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Checkbox", Color.White) { BackgroundUnpressed = bar }); y += step;
            panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Button", Color.White) { BackgroundUnpressed = bar }); y += step;
            panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Image", Color.White) { BackgroundUnpressed = bar }); y += step;
            panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Label", Color.White) { BackgroundUnpressed = bar }); y += step;
            panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Level", Color.White) { BackgroundUnpressed = bar }); y += step;
            panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "MultiImage", Color.White) { BackgroundUnpressed = bar }); y += step;
            panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Panel", Color.White) { BackgroundUnpressed = bar }); y += step;
            panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "ProgressBar", Color.White) { BackgroundUnpressed = bar }); y += step;
            panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "RadioButton", Color.White) { BackgroundUnpressed = bar }); y += step;
            panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Slider", Color.White) { BackgroundUnpressed = bar }); y += step;
            panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "TextBlock", Color.White) { BackgroundUnpressed = bar }); y += step;
            //panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "", Color.White) { BackgroundUnpressed = bar }); y += step;
            //panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "", Color.White) { BackgroundUnpressed = bar }); y += step;

            foreach (Control ctrl in panelNavigation.Children)
            {
                if (ctrl is Button)
                    (ctrl as Button).Click += new EventHandler(Button_Click);
            }

            // title
            TextBlock txtTitle = new TextBlock(200, panelNavigation.Y, 590, 60, fontTitle, "MFE graphics");
            txtTitle.ForeColor = Color.CornflowerBlue;
            txtTitle.TextAlignment = TextAlignment.Center;
            txtTitle.TextVerticalAlignment = VerticalAlignment.Center;
            Children.Add(txtTitle);

            // right panel
            int yy = txtTitle.Height + 10;
            panelPresentation = new Panel(txtTitle.X, panelNavigation.Y + yy, txtTitle.Width, panelNavigation.Height - yy);
            panelPresentation.Background = new SolidColorBrush(Color.Black);
            panelPresentation.Background.Opacity = 50;
            panelPresentation.Border = new Pen(Color.Black, 1);
            Children.Add(panelPresentation);

            tlb2 = new Panel(1, 1, panelPresentation.Width - 2, 25);
            tlb2.Background = bar;
            tlb2.Children.Add(lblActiveDemo = new Label(10, 5, fontCourierNew10, "Presentation: [Please select control type on the left]") { ForeColor = Color.CornflowerBlue });
            tlb2.TouchDown += delegate(object sender, TouchEventArgs e) { TouchCapture.Capture(tlb2); p = e.Point; };
            tlb2.TouchMove += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == tlb2) { panelPresentation.Translate(e.Point.X - p.X, e.Point.Y - p.Y); p = e.Point; } };
            tlb2.TouchUp += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == tlb2) TouchCapture.ReleaseCapture(); };
            panelPresentation.Children.Add(tlb2);
        }
Esempio n. 2
0
        private Control GetTouchTarget(Point p)
        {
            Control result = null;

            //dt = DateTime.Now;
            if (TouchCapture.Captured != null)
                result = TouchCapture.Captured;
            else if (desktop.Children.Contains(cw))
                return cw;
            //else if (modalWindow != null)
            //    res = FindTouchTarget(modalWindow, p);
            else
                result = FindTouchTarget(desktop, p);
            //ts = DateTime.Now - dt;

            lastEventTarget = result;
            return result;
        }
Esempio n. 3
0
        private Control FindTouchTarget(Control root, Point p)
        {
            return root.GetValidChildFromScreenPoint(p);

            if (lastEventTarget != null)
            {
                // old:
                Control target = lastEventTarget.GetValidChildFromScreenPoint(p);
                if (target != null)
                    return target;
                else if (lastEventTarget.ContainsScreenPoint(p))
                    return lastEventTarget;
                else
                {
                    Control par = lastEventTarget.GetValidParentFromScreenPoint(p);
                    return par != null ? par.GetValidChildFromScreenPoint(p) : (root != null ? root.GetValidChildFromScreenPoint(p) : null);
                }

                // new:
                //var par = lastEventTarget.GetValidParentFromScreenPoint(p);
                //return par != null ? par.GetValidChildFromScreenPoint(p) : (root != null ? root.GetValidChildFromScreenPoint(p) : null);
            }
            else
                return root.GetValidChildFromScreenPoint(p);
        }
Esempio n. 4
0
 public void PointToClient(ref Point p)
 {
     p.X -= ScreenArea.X;
     p.Y -= ScreenArea.Y;
 }
Esempio n. 5
0
        public void PointToScreen(ref Point p)
        {
            Control client = this;
            while (client != null)
            {
                p.X += client.X;
                p.Y += client.Y;

                client = client.Parent;
            }
        }
Esempio n. 6
0
        public Control GetValidParentFromScreenPoint(Point p)
        {
            Control ppp = this;
            Control pp = null;
            do
            {
                pp = ppp;
                ppp = pp.Parent;
            } while (ppp != null && !ppp.ContainsScreenPoint(p));

            return ppp;
        }
Esempio n. 7
0
        //this.GetValidChildFromScreenRect = function (r) {
        //    var targetCtrl = null;
        //    var sa = this.GetScreenArea();
        //    if (visible && enabled && sa.IntersectsScreenRect(r)) {
        //        targetCtrl = this;
        //        for (var i = children.length - 1; i >= 0; i--) {
        //            var child = children[i];
        //            if (child.GetScreenArea().Intersects(sa)) {
        //                var target = child.GetValidChildFromScreenRect(r);
        //                if (target) {
        //                    targetCtrl = target;
        //                    break;
        //                }
        //            }
        //        }
        //    }
        //    return targetCtrl;
        //}
        public Control GetValidChildFromScreenPoint(Point p)
        {
            Control targetCtrl = null;
            var sa = ScreenArea;

            if (isVisible && isEnabled && sa.Contains(p))
            {
                targetCtrl = this;

                for (int i = children.Count - 1; i >= 0; i--)
                {
                    var child = children[i];
                    if (child.ScreenArea.Intersects(sa))
                    {
                        Control target = child.GetValidChildFromScreenPoint(p);
                        if (target != null)
                        {
                            targetCtrl = target;
                            break;
                        }
                    }
                }
            }

            return targetCtrl;
        }
Esempio n. 8
0
 //this.SetLocation = function (x, y) {
 //    if (area.X != x || area.Y != y) {
 //        area.X = x;
 //        area.Y = y;
 //        this.OnLocationChange(x, y);
 //        this.Invalidate();
 //    }
 //}
 //this.SetSize = function (w, h) {
 //    if (area.Width != w || area.Height != h) {
 //        area.Width = w;
 //        area.Height = h;
 //        this.OnSizeChange(w, h);
 //        this.Invalidate();
 //    }
 //}
 //this.AddChild = function (ctrl) {
 //    if (ctrl) {
 //        children.push(ctrl);
 //        ctrl.SetParent(me);
 //    }
 //}
 //this.ClearChildren = function () {
 //    children = [];
 //    this.Invalidate();
 //}
 public bool ContainsScreenPoint(Point p)
 {
     return ScreenArea.Contains(p);
 }
Esempio n. 9
0
        protected override void OnTouchMove(TouchEventArgs e)
        {
            if (TouchCapture.Captured == this)
            {
                if (orientation == Orientation.Horizontal)
                    Value += e.Point.X - p.X;
                else
                    Value -= e.Point.Y - p.Y;

                p = e.Point;
            }
        }
Esempio n. 10
0
 protected override void OnTouchDown(TouchEventArgs e)
 {
     Point pp = e.Point;
     PointToClient(ref pp);
     if (thumbArea.Contains(pp))
     {
         TouchCapture.Capture(this);
         p = e.Point;
     }
     else if (trackArea.Contains(pp))
     {
         if (orientation == Orientation.Horizontal)
         {
             if (pp.X < thumbArea.X)
                 Value -= largeChange;
             else
                 Value += largeChange;
         }
         else
         {
             if (pp.Y < thumbArea.Y)
                 Value += largeChange;
             else
                 Value -= largeChange;
         }
     }
 }