public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
        {
            if (!this.HasReadyRenderElement)
            {
                //first time
                RenderElement baseRenderElement = base.GetPrimaryRenderElement(rootgfx);

                //1. add place holder first
                placeHolder      = new CustomTextRun(rootgfx, this.Width - 4, this.Height - 4);
                placeHolder.Text = placeHolderText;
                placeHolder.SetLocation(1, 1);
                placeHolder.TextColor = Color.FromArgb(180, Color.LightGray);

                baseRenderElement.AddChild(placeHolder);

                //2. textbox
                myTextBox = new TextBox(this.Width - 4, this.Height - 4, multiline);
                myTextBox.BackgroundColor = Color.Transparent;
                myTextBox.SetLocation(2, 2);

                textEvListener = new Text.TextSurfaceEventListener();

                myTextBox.TextEventListener = textEvListener;
                textEvListener.KeyDown     += new EventHandler <Text.TextDomEventArgs>(textEvListener_KeyDown);
                baseRenderElement.AddChild(myTextBox);

                return(baseRenderElement);
            }
            else
            {
                return(base.GetPrimaryRenderElement(rootgfx));
            }
        }
Exemple #2
0
        protected virtual void BuildChildrenRenderElement(RenderElement parent)
        {
            parent.HasSpecificHeight = this.HasSpecificHeight;
            parent.HasSpecificWidth  = this.HasSpecificWidth;
            parent.SetController(this);
            parent.SetVisible(this.Visible);
#if DEBUG
            //if (dbugBreakMe)
            //{
            //    renderE.dbugBreak = true;
            //}
#endif
            parent.SetLocation(this.Left, this.Top);
            if (parent is CustomRenderBox)
            {
                ((CustomRenderBox)parent).BackColor = backColor;
            }

            parent.HasSpecificSize = true;
            parent.SetViewport(this.ViewportX, this.ViewportY);
            //------------------------------------------------


            //create visual layer
            int childCount = this.ChildCount;
            for (int m = 0; m < childCount; ++m)
            {
                parent.AddChild(this.GetChild(m));
            }
            //set primary render element
            //---------------------------------
        }
Exemple #3
0
        void SetupHorizontalScrollButtonProperties(RenderElement container)
        {
            var scroll_button = new ScrollBarButton(10, this.Height, this); //create with default value

            scroll_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkBlue);
            int thumbPosX = CalculateThumbPosition() + minmax_boxHeight;

            scroll_button.SetLocation(thumbPosX, 0);
            container.AddChild(scroll_button);
            this.scrollButton = scroll_button;
            //----------------------------

            EvaluateHorizontalScrollBarProperties();
            //----------------------------
            //3. drag


            scroll_button.MouseDrag += (s, e) =>
            {
                //dragging ...
                //find x-diff

                Point pos = scroll_button.Position;

                //if vscroll bar then move only y axis
                int newXPos = (int)(pos.X + e.DiffCapturedX);

                //clamp!
                if (newXPos >= this.Width - (minmax_boxHeight + scrollButton.Width))
                {
                    newXPos = this.Width - (minmax_boxHeight + scrollButton.Width);
                }
                else if (newXPos < minmax_boxHeight)
                {
                    newXPos = minmax_boxHeight;
                }

                //calculate value from position

                int currentMarkAt = (newXPos - minmax_boxHeight);
                this.scrollValue = (float)(onePixelFor * currentMarkAt);
                newXPos          = CalculateThumbPosition() + minmax_boxHeight;
                scroll_button.SetLocation(newXPos, pos.Y);

                if (this.UserScroll != null)
                {
                    this.UserScroll(this, EventArgs.Empty);
                }

                e.StopPropagation();
            };
        }
Exemple #4
0
        void SetupMinButtonProperties(RenderElement container)
        {
            ScrollBarButton min_button;

            if (this.ScrollBarType == ScrollBarType.Horizontal)
            {
                min_button = new ScrollBarButton(minmax_boxHeight, this.Height, this);
            }
            else
            {
                min_button = new ScrollBarButton(this.Width, minmax_boxHeight, this);
            }
            min_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkGray);
            min_button.MouseUp  += (s, e) => this.StepSmallToMin();
            container.AddChild(min_button);
            this.minButton = min_button;
        }
Exemple #5
0
        void SetupVerticalScrollButtonProperties(RenderElement container)
        {
            var scroll_button = new ScrollBarButton(this.Width, 10, this); //create with default value

            scroll_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkBlue);
            int thumbPosY = CalculateThumbPosition() + _minmax_boxHeight;

            scroll_button.SetLocation(0, thumbPosY);
            container.AddChild(scroll_button);
            _scrollButton = scroll_button;
            //----------------------------
            EvaluateVerticalScrollBarProperties();
            //----------------------------
            //3. drag
            scroll_button.MouseDrag += (s, e) =>
            {
                //dragging ...

                Point pos = scroll_button.Position;
                //if vscroll bar then move only y axis
                int newYPos = (int)(pos.Y + e.DiffCapturedY);
                //clamp!
                if (newYPos >= this.Height - (_minmax_boxHeight + _scrollButton.Height))
                {
                    newYPos = this.Height - (_minmax_boxHeight + _scrollButton.Height);
                }
                else if (newYPos < _minmax_boxHeight)
                {
                    newYPos = _minmax_boxHeight;
                }

                //calculate value from position

                int currentMarkAt = (newYPos - _minmax_boxHeight);
                _scrollValue = (float)(_onePixelFor * currentMarkAt);
                newYPos      = CalculateThumbPosition() + _minmax_boxHeight;
                scroll_button.SetLocation(pos.X, newYPos);
                if (this.UserScroll != null)
                {
                    this.UserScroll(this, EventArgs.Empty);
                }

                e.StopPropagation();
            };
        }
Exemple #6
0
        protected void BuildChildrenRenderElement(RenderElement parent)
        {
            //TODO: review here
            parent.HasSpecificHeight = this.HasSpecificHeight;
            parent.HasSpecificWidth  = this.HasSpecificWidth;
            parent.SetController(this);
            parent.SetVisible(this.Visible);
            parent.SetLocation(this.Left, this.Top);
            parent.HasSpecificWidthAndHeight = true; //?
            parent.SetViewport(this.ViewportLeft, this.ViewportTop);

            int childCount = this.ChildCount;

            for (int m = 0; m < childCount; ++m)
            {
                parent.AddChild(this.GetChild(m));
            }
        }
Exemple #7
0
        protected void BuildChildrenRenderElement(RenderElement parent)
        {
            //TODO: review here
            parent.HasSpecificHeight = this.HasSpecificHeight;
            parent.HasSpecificWidth  = this.HasSpecificWidth;
            parent.SetController(this);
            parent.SetVisible(this.Visible);
            parent.SetLocation(this.Left, this.Top);
            parent.HasSpecificWidthAndHeight = true; //?
            parent.SetViewport(this.ViewportLeft, this.ViewportTop);

            if (ChildCount > 0)
            {
                foreach (UIElement ui in GetChildIter())
                {
                    parent.AddChild(ui);
                }
            }
        }
Exemple #8
0
        void SetupMaxButtonProperties(RenderElement container)
        {
            ScrollBarButton max_button;

            if (this.ScrollBarType == ScrollBarType.Horizontal)
            {
                max_button = new ScrollBarButton(minmax_boxHeight, this.Height, this);
                max_button.SetLocation(this.Width - minmax_boxHeight, 0);
            }
            else
            {
                max_button = new ScrollBarButton(this.Width, minmax_boxHeight, this);
                max_button.SetLocation(0, this.Height - minmax_boxHeight);
            }


            max_button.BackColor = KnownColors.FromKnownColor(KnownColor.Yellow);
            max_button.MouseUp  += (s, e) => this.StepSmallToMax();
            container.AddChild(max_button);
            this.maxButton = max_button;
        }
 public static void AddChild(this RenderElement renderBox, UIElement ui)
 {
     renderBox.AddChild(ui.GetPrimaryRenderElement(renderBox.Root));
 }
Exemple #10
0
        void SetupHorizontalScrollButtonProperties(RenderElement container)
        {
            //TODO: use 'theme-concept' eg. css

            var scroll_button = new ScrollBarButton(SCROLL_BOX_SIZE_LIMIT, this.Height, this); //create with default value

            scroll_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkBlue);
            int thumbPosX = CalculateThumbPosition();

            scroll_button.SetLocation(thumbPosX, 0);
            container.AddChild(scroll_button);
            this.scrollButton = scroll_button;
            //----------------------------

            EvaluateHorizontalScrollBarProperties();
            //----------------------------
            //3. drag


            scroll_button.MouseDrag += (s, e) =>
            {
                //dragging ...

                Point pos = scroll_button.Position;

                int newXPos = (int)(pos.X + e.DiffCapturedX);
                //clamp!
                if (newXPos >= this.Width - (scrollButton.Width))
                {
                    newXPos = this.Width - (scrollButton.Width);
                }
                else if (newXPos < 0)
                {
                    newXPos = 0;
                }

                //calculate value from position

                int currentMarkAt = newXPos;
                this.scrollRangeLogic.SetValue((float)(onePixelFor * currentMarkAt));

                newXPos = CalculateThumbPosition();
                scroll_button.SetLocation(newXPos, pos.Y);
                if (this.UserScroll != null)
                {
                    this.UserScroll(this, EventArgs.Empty);
                }
                e.StopPropagation();
            };
            ////-------------------------------------------
            ////4.
            //scroll_button.MouseLeave += (s, e) =>
            //{
            //    if (e.IsDragging)
            //    {
            //        Point pos = scroll_button.Position;
            //        //if vscroll bar then move only y axis
            //        int newXPos = (int)(pos.X + e.XDiff);
            //        //clamp!
            //        if (newXPos >= this.Width - (minmax_boxHeight + scrollButton.Width))
            //        {
            //            newXPos = this.Width - (minmax_boxHeight + scrollButton.Width);
            //        }
            //        else if (newXPos < minmax_boxHeight)
            //        {
            //            newXPos = minmax_boxHeight;
            //        }

            //        //calculate value from position

            //        int currentMarkAt = (newXPos - minmax_boxHeight);
            //        this.scrollValue = (float)(onePixelFor * currentMarkAt);
            //        newXPos = CalculateThumbPosition() + minmax_boxHeight;
            //        scroll_button.SetLocation(newXPos, pos.Y);
            //        if (this.UserScroll != null)
            //        {
            //            this.UserScroll(this, EventArgs.Empty);
            //        }
            //        e.StopPropagation();
            //    }
            //};
        }
Exemple #11
0
        void SetupHorizontalScrollButtonProperties(RenderElement container)
        {
            var scroll_button = new ScrollBarButton(10, this.Height, this); //create with default value
            scroll_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkBlue);
            int thumbPosX = CalculateThumbPosition() + minmax_boxHeight;
            scroll_button.SetLocation(thumbPosX, 0);
            container.AddChild(scroll_button);
            this.scrollButton = scroll_button;
            //----------------------------

            EvaluateHorizontalScrollBarProperties();
            //----------------------------
            //3. drag


            scroll_button.MouseDrag += (s, e) =>
            {
                //dragging ...
                //find x-diff                 

                Point pos = scroll_button.Position;
                //if vscroll bar then move only y axis 
                int newXPos = (int)(pos.X + e.DiffCapturedX);
                //clamp!
                if (newXPos >= this.Width - (minmax_boxHeight + scrollButton.Width))
                {
                    newXPos = this.Width - (minmax_boxHeight + scrollButton.Width);
                }
                else if (newXPos < minmax_boxHeight)
                {
                    newXPos = minmax_boxHeight;
                }

                //calculate value from position 

                int currentMarkAt = (newXPos - minmax_boxHeight);
                this.scrollValue = (float)(onePixelFor * currentMarkAt);
                newXPos = CalculateThumbPosition() + minmax_boxHeight;
                scroll_button.SetLocation(newXPos, pos.Y);
                if (this.UserScroll != null)
                {
                    this.UserScroll(this, EventArgs.Empty);
                }

                e.StopPropagation();
            };
        }
Exemple #12
0
        void SetupMaxButtonProperties(RenderElement container)
        {
            ScrollBarButton max_button;
            if (this.ScrollBarType == ScrollBarType.Horizontal)
            {
                max_button = new ScrollBarButton(minmax_boxHeight, this.Height, this);
                max_button.SetLocation(this.Width - minmax_boxHeight, 0);
            }
            else
            {
                max_button = new ScrollBarButton(this.Width, minmax_boxHeight, this);
                max_button.SetLocation(0, this.Height - minmax_boxHeight);
            }


            max_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkGray);
            max_button.MouseUp += (s, e) => this.StepSmallToMax();
            container.AddChild(max_button);
            this.maxButton = max_button;
        }
Exemple #13
0
        protected virtual void BuildChildrenRenderElement(RenderElement parent)
        {
            parent.HasSpecificHeight = this.HasSpecificHeight;
            parent.HasSpecificWidth = this.HasSpecificWidth;
            parent.SetController(this);
            parent.SetVisible(this.Visible);
#if DEBUG
            //if (dbugBreakMe)
            //{
            //    renderE.dbugBreak = true;
            //}
#endif
            parent.SetLocation(this.Left, this.Top);
            if (parent is CustomRenderBox)
            {
                ((CustomRenderBox)parent).BackColor = backColor;
            }

            parent.HasSpecificSize = true;
            parent.SetViewport(this.ViewportX, this.ViewportY);
            //------------------------------------------------


            //create visual layer 
            int childCount = this.ChildCount;
            for (int m = 0; m < childCount; ++m)
            {
                parent.AddChild(this.GetChild(m));
            }
            //set primary render element
            //---------------------------------

        }
Exemple #14
0
 void SetupMinButtonProperties(RenderElement container)
 {
     ScrollBarButton min_button;
     if (this.ScrollBarType == ScrollBarType.Horizontal)
     {
         min_button = new ScrollBarButton(minmax_boxHeight, this.Height, this);
     }
     else
     {
         min_button = new ScrollBarButton(this.Width, minmax_boxHeight, this);
     }
     min_button.BackColor = KnownColors.FromKnownColor(KnownColor.Green);
     min_button.MouseUp += (s, e) => this.StepSmallToMin();
     container.AddChild(min_button);
     this.minButton = min_button;
 }