예제 #1
0
파일: MousePointer.cs 프로젝트: drme/thw-ui
        /// <summary>
        /// Render cursor at the specified position
        /// </summary>
        internal void Render(Graphics render, int x, int y, Theme theme)
        {
            render.SetColor(white);

            if (null == this.textures[0])
            {
                String themeFolder = theme.ThemeFolder + "/images/cursor_";

                this.textures[(int)MousePointers.PointerStandard] = this.engine.CreateImage(themeFolder + "default");
                this.textures[(int)MousePointers.PointerWait] = this.engine.CreateImage(themeFolder + "clock");
                this.textures[(int)MousePointers.PointerMove] = this.engine.CreateImage(themeFolder + "move");
                this.textures[(int)MousePointers.PointerHResize] = this.engine.CreateImage(themeFolder + "hsize");
                this.textures[(int)MousePointers.PointerVResize] = this.engine.CreateImage(themeFolder + "vsize");
                this.textures[(int)MousePointers.PointerResize1] = this.engine.CreateImage(themeFolder + "resize1");
                this.textures[(int)MousePointers.PointerResize2] = this.engine.CreateImage(themeFolder + "resize2");
                this.textures[(int)MousePointers.PointerText] = this.engine.CreateImage(themeFolder + "text");
                this.textures[(int)MousePointers.PointerHand] = this.engine.CreateImage(themeFolder + "hand");
            }

            if (null != this.textures[(int)this.activeCursor])
            {
                if (MousePointers.PointerStandard == this.activeCursor)
                {
                    render.DrawImage(x, y, 32, 32, this.textures[(int)this.activeCursor]);
                }
                else
                {
                    render.DrawImage(x - 16, y - 16, this.textures[(int)this.activeCursor].Width, this.textures[(int)this.activeCursor].Height, this.textures[(int)this.activeCursor]);
                }
            }
        }
예제 #2
0
파일: CensoredFont.cs 프로젝트: drme/thw-ui
        public override void DrawText(Graphics graphics, int x, int y, string text, int start, int stop)
        {
            if ((null == text) || (text.Length == 0))
            {
                return;
            }

            int renderX = x;

            if (stop < 0)
            {
                stop = (int)(text.Length);
            }

            if (stop > text.Length)
            {
                stop = text.Length;
            }

            if (start < 0)
            {
                start = 0;
            }

            for (int i = start; i < stop; i++)
            {
                graphics.DrawBox(renderX, y, this.size / 2, this.size);

                renderX += this.size / 2 + 2;
            }
        }
예제 #3
0
파일: TabPage.cs 프로젝트: drme/thw-ui
 /// <summary>
 /// Renders tab page. Ignores control and renders only its' child controls.
 /// </summary>
 /// <param name="graphics">graphics to render to.</param>
 /// <param name="X">X coordiante.</param>
 /// <param name="Y">Y coordinate.</param>
 protected override void Render(Graphics graphics, int x, int y)
 {
     if (true == this.Visible)
     {
         RenderControls(graphics, x, y);
     }
 }
예제 #4
0
파일: ToolBar.cs 프로젝트: drme/thw-ui
        /// <summary>
        /// Renders toolbar.
        /// </summary>
        /// <param name="graphics">graphics to render to.</param>
        /// <param name="X">X position.</param>
        /// <param name="Y">Y position.</param>
        protected override void Render(Graphics graphics, int x, int y)
        {
            base.Render(graphics, x, y);

            graphics.SetColor(this.Window.Desktop.Theme.Colors.ControlDark, this.Opacity);

            for (int i = 2; i < this.bounds.Height - 3; i += 2)
            {
                graphics.DrawRectangle(x + this.bounds.X + 4, y + this.bounds.Y + i, 3, 1);
            }
        }
예제 #5
0
파일: FilePicker.cs 프로젝트: drme/thw-ui
        protected override void Render(Graphics graphics, int x, int y)
        {
            if (BorderStyle.None == this.Border)
            {
                this.selectButton.Bounds.UpdateSize(this.Bounds.Width - 16 - 2, 0, 16, this.Bounds.Height - 0);
            }
            else if (BorderStyle.Flat == this.Border)
            {
                this.selectButton.Bounds.UpdateSize(this.Bounds.Width - 16 - 2, 2, 16, this.Bounds.Height - 4);
            }
            else
            {
                this.selectButton.Bounds.UpdateSize(this.Bounds.Width - 16 - 2, 2, 16, this.Bounds.Height - 4);
            }

            base.Render(graphics, x, y);
        }
예제 #6
0
파일: AcButton.cs 프로젝트: drme/thw-ui
        protected override void Render(Graphics graphics, int x, int y)
        {
            bool isOver = (((true == this.isMouseOver) && (this.backColor.A > 0.0f) && (true == this.RenderSelectionOverlay)) || (true == this.HasFocus));

            if (true == isOver)
            {
                x -= 5;
                y -= 5;
                this.Width += 10;
                this.Height += 10;
            }

            base.Render(graphics, x, y);

            if (true == isOver)
            {
                x += 5;
                y += 5;
                this.Width -= 10;
                this.Height -= 10;
            }
        }
예제 #7
0
파일: PropertyRow.cs 프로젝트: drme/thw-ui
        /// <summary>
        /// Renders property row at X, Y position
        /// </summary>
        /// <param name="graphics">graphics api to do rendering</param>
        /// <param name="X">X coordinate</param>
        /// <param name="Y">Y coordiante</param>
        protected override void Render(Graphics graphics, int x, int y)
        {
            if (null == this.parentGrid)
            {
                this.parentGrid = (PropertyGrid)this.Parent.Parent;
            }

            if (true == this.parentGrid.ShowRowsSeparator)
            {
                graphics.SetColor(this.parentGrid.RowSeparatorColor);
                graphics.DrawRectangle(x + this.Bounds.X, y + this.Bounds.Y + this.Bounds.Height, this.Bounds.Width, this.parentGrid.RowSeparatorHeight);
            }

            if (true == this.parentGrid.ShowKeyValueSeparator)
            {
                graphics.SetColor(this.parentGrid.KeyValueSeparatorColor);
                graphics.DrawRectangle(x + this.Bounds.X + this.Bounds.Width / 2, y + this.Bounds.Y, this.parentGrid.KeyValueSeparatorWidth, this.Bounds.Height);
            }

            RenderName(graphics, x, y);

            if (null == this.property)
            {
                return;
            }

            //RenderValue(render, X, Y);

            if (null != this.inputControl)
            {
                this.inputControl.Bounds.UpdateSize(this.Bounds.Width / 2 + 1, 1, this.Bounds.Width / 2-1, this.Bounds.Height-1);
            }
            else
            {
                CreateInputControl();
            }

            //if (false == this.inputControl.HasFocus())
            {
                if (this.property.ToString() != this.inputControl.Text)
                {
                    this.inputControl.Text = this.property.ToString();
                }
            }

            if (true == this.parentGrid.ShowSideBar)
            {
                this.IconImageOffset.X = 16;
                this.TextOffset.X = 16;
            }
            else
            {
                this.IconImageOffset.X = 0;
                this.TextOffset.X = 0;
            }

            RenderControls(graphics, x, y);
        }
예제 #8
0
파일: PropertyGrid.cs 프로젝트: drme/thw-ui
        /// <summary>
        /// Renders property grid at X, Y position.
        /// </summary>
        /// <param name="graphics">graphics api for rendering.</param>
        /// <param name="X">X coordiante.</param>
        /// <param name="Y">Y coordinate.</param>
        protected override void Render(Graphics graphics, int x, int y)
        {
            RenderBackground(graphics, x, y);
            RenderBorder(graphics, x, y);

            if (true == this.ShowSideBar)
            {
                graphics.SetColor(this.Window.Desktop.Theme.Colors.Control);
                graphics.DrawRectangle(x + this.Bounds.X + 1, y + this.Bounds.Y + 1, 14, this.Bounds.Height - 2);
            }

            RenderControls(graphics, x, y);
        }
예제 #9
0
        protected override void Render(Graphics graphics, int x, int y)
        {
            if (null == this.parentGrid)
            {
                this.parentGrid = (PropertyGrid)this.Parent;
            }

            int hh = 8 + this.parentGrid.FontInfo.Size;

            if (true == this.parentGrid.ShowSideBar)
            {
                // Render TopLine
                graphics.SetColor(this.Window.Desktop.Theme.Colors.Control);
                graphics.DrawRectangle(x + this.Bounds.X, y + this.Bounds.Y, this.Bounds.Width, hh);
            }

            if (true == this.parentGrid.ShowGroupLine)
            {
                graphics.SetColor(this.parentGrid.BorderColor);
                graphics.DrawRectangle(x + this.bounds.X, y + this.bounds.Y + hh - 1, this.bounds.Width, 1);
            }

            if (true == this.parentGrid.ShowPlus)
            {
                // Render Plus
                graphics.SetColor(this.PlusColor);
                graphics.DrawRectangle(this.Bounds.X + x + 3, this.Bounds.Y + y + 4, hh - 7, hh - 7);
                graphics.SetColor(this.Window.Desktop.Theme.Colors.Control);
                graphics.DrawRectangle(this.Bounds.X + x + 4, this.Bounds.Y + y + 5, hh - 9, hh - 9);
                graphics.SetColor(this.PlusColor);
                graphics.DrawRectangle(this.Bounds.X + x + 2 + 3, this.Bounds.Y + y + 4 + 4, 4 + 1, 1);

                if (false == this.expanded)
                {
                    graphics.DrawRectangle(this.Bounds.X + x + 2 + 2 + 3, this.Bounds.Y + y + 1 + 5, 1, 5);
                }

                if (true == this.HasFocus)
                {
                    graphics.SetColor(this.Window.Desktop.Theme.Colors.HighlightBorder, 0.5f);
                    graphics.DrawBox(x + this.bounds.X, y + this.bounds.Y, this.bounds.Width, hh);
                    graphics.SetColor(this.Window.Desktop.Theme.Colors.Highlight, 0.5f);
                    graphics.DrawRectangle(x + this.bounds.X + 1, y + this.bounds.Y + 1, this.bounds.Width - 2, hh - 2);
                }

                // Render text
                graphics.SetColor(this.parentGrid.TextColor);
                if (null != this.parentGrid.FontInfo.Font)
                {
                    this.parentGrid.FontInfo.Font.DrawText(graphics, this.Bounds.X + x + hh, this.Bounds.Y + y + 4, this.controlText);
                }
            }
            else
            {
                if (true == this.HasFocus)
                {
                    graphics.SetColor(this.Window.Desktop.Theme.Colors.HighlightBorder, 0.5f);
                    graphics.DrawBox(x + this.bounds.X, y + this.Bounds.Y, this.bounds.Width, hh);
                    graphics.SetColor(this.Window.Desktop.Theme.Colors.Highlight, 0.5f);
                    graphics.DrawRectangle(x + this.Bounds.X + 1, y + this.Bounds.Y + 1, this.Bounds.Width - 2, hh - 2);
                }

                // Render text
                graphics.SetColor(this.parentGrid.TextColor);
                if (null != this.parentGrid.FontInfo.Font)
                {
                    this.parentGrid.FontInfo.Font.DrawText(graphics, this.Bounds.X + x + 3, this.Bounds.Y + y + 4, this.controlText);
                }
            }

            // Render text
            if ((0 != this.parentGrid.ValueText.Length) && (null != this.parentGrid.FontInfo.Font))
            {
                graphics.SetColor(this.parentGrid.TextColor);
                this.parentGrid.FontInfo.Font.DrawText(graphics, 4 + x + this.Bounds.X + this.Bounds.Width / 2, this.Bounds.Y + y + 4, this.parentGrid.ValueText);
            }

            RenderControls(graphics, x, y);
        }
예제 #10
0
파일: MenuWindow.cs 프로젝트: drme/thw-ui
        /// <summary>
        /// Renders menu window.
        /// </summary>
        /// <param name="graphics">graphics to draw to</param>
        /// <param name="X">X position</param>
        /// <param name="Y">Y position</param>
        protected override void Render(Graphics graphics, int x, int y)
        {
            base.Render(graphics, x, y);

            this.menu.RenderInSeparateWindow(graphics, 2 + this.Bounds.X - this.menu.Bounds.X, 0 + this.Bounds.Y - this.menu.Bounds.Y);
        }
예제 #11
0
파일: ProgressBar.cs 프로젝트: drme/thw-ui
        /// <summary>
        /// Renders control.
        /// </summary>
        /// <param name="graphics">graphics to render to</param>
        /// <param name="X">X screen offset</param>
        /// <param name="Y">Y screen offset</param>
        protected override void RenderControls(Graphics graphics, int x, int y)
        {
            int borderSize = 2;

            if (BorderStyle.None == this.Border)
            {
                borderSize = 0;
            }

            int tx = x + this.Bounds.X + borderSize;
            int ty = y + this.Bounds.Y + borderSize;

            int tw = (int)((float)(this.Bounds.Width - borderSize * 2) * this.ProgressValue);

            graphics.SetColor(this.ProgressBarColor);
            graphics.DrawRectangle(tx, ty, tw, this.Bounds.Height - borderSize * 2);
        }
예제 #12
0
파일: PropertyRow.cs 프로젝트: drme/thw-ui
        protected void RenderValue(Graphics graphics, int x, int y)
        {
            IFont font = this.Parent.Parent.FontInfo.Font;

            if (null != font)
            {
                String value = this.property.ToString();

                int len = value.Length;

                while (font.TextLength(value, 0, len) > this.Bounds.Width / 2 - 16)
                {
                    len--;
                }

                font.DrawText(graphics, 4 + x + this.Bounds.X + this.Bounds.Width / 2, y + this.Bounds.Y + 4, value, 0, len);
            }
        }
예제 #13
0
파일: CheckBox.cs 프로젝트: drme/thw-ui
        /// <summary>
        /// Renders crontol border - check box
        /// </summary>
        /// <param name="graphics">graphics to render to</param>
        /// <param name="X">rendering offset X</param>
        /// <param name="Y">rendering offset Y</param>
        protected override void RenderBorder(Graphics graphics, int x, int y)
        {
            if (null == this.settings)
            {
                this.settings = this.Window.Desktop.Theme.GetControlSettings(TypeName);
            }

            int off = 2;
            int dx = 0;

            int size = this.settings.ControlSize;

            if (size <= 0)
            {
                size = this.Bounds.Height;
                dx = 0;
            }
            else
            {
                dx = (this.Bounds.Height - size) / 2;
            }

            //if (BorderStyle.BorderNone == this.Border)
            {
                off = 0;
            }

            off += dx;

            graphics.SetColor(this.settings.ColorBack);

            graphics.DrawRectangle(off + x + this.Bounds.X, off + y + this.Bounds.Y, size, size);

            graphics.SetColor(Colors.White);

            RenderBorderXYWH(graphics, off + x + this.Bounds.X, off + y + this.Bounds.Y, size, size, this.Border);

            this.TextOffset.X = off + size + 5;
        }
예제 #14
0
파일: ScrollPanel.cs 프로젝트: drme/thw-ui
        protected override void RenderControls(Graphics pRender, int x/* = 0*/, int y/* = 0*/)
        {
            this.verticalScrollBar.Opacity = this.Opacity;
            this.horizontalScrollBar.Opacity = this.Opacity;

            this.verticalScrollBar.RenderInternal(pRender, x + this.bounds.X, y + this.bounds.Y + this.topOffset);
            this.horizontalScrollBar.RenderInternal(pRender, x + this.bounds.X, y + this.bounds.Y + this.topOffset);

            int mX = this.verticalScrollBar.Visible ? this.verticalScrollBar.ButtonSize : 0;
            int mY = this.horizontalScrollBar.Visible ? this.horizontalScrollBar.ButtonSize : 0;
            int off = this.borderSize;

            pRender.SetRegion(off + x + this.bounds.X, off + y + this.bounds.Y, this.bounds.Width - 2 * off - mX, this.bounds.Height - 2 * off - mY);
            this.internalPanel.RenderInternal(pRender, x + this.bounds.X, y + this.bounds.Y + this.topOffset);
            pRender.ClearRegion();
        }
예제 #15
0
파일: IFont.cs 프로젝트: drme/thw-ui
 /// <summary>
 /// Renders text at specified location using active color.
 /// </summary>
 /// <param name="graphics">rendering object</param>
 /// <param name="X">X position</param>
 /// <param name="Y">Y position </param>
 /// <param name="text">text to render</param>
 public virtual void DrawText(Graphics graphics, int x, int y, String text)
 {
     DrawText(graphics, x, y, text, 0, -1);
 }
예제 #16
0
파일: ImagesCache.cs 프로젝트: drme/thw-ui
        internal IImage CreateImage(String uniqueName, int w, int h, byte[] bytes, Graphics graphics)
        {
            if (true == this.cachedImages.ContainsKey(uniqueName))
            {
                throw new Exception("Image already exists: " + uniqueName);
            }

            IImage image = graphics.CreateImage(w, h, bytes);

            if (null != image)
            {
                image.AddRef();

                image.Name = uniqueName;

                this.cachedImages[uniqueName] = image;

                return image;
            }

            return null;
        }
예제 #17
0
파일: ScrollPanel.cs 프로젝트: drme/thw-ui
        protected override void Render(Graphics graphics, int x, int y)
        {
            CalculateSizes();

            if ( (true == this.horizontalScrollBar.Visible) && (true == this.verticalScrollBar.Visible) )
            {
                int w = this.horizontalScrollBar.ButtonSize;

                graphics.SetColor(this.Window.Desktop.Theme.Colors.Control, this.Opacity);

                graphics.DrawRectangle(x + this.bounds.X + this.bounds.Width - w - this.borderSize, y + this.bounds.Y + this.bounds.Height - w - this.borderSize, w, w);
            }

            base.Render(graphics, x, y);
        }
예제 #18
0
파일: TrackBar.cs 프로젝트: drme/thw-ui
        /// <summary>
        /// Renders control background at X, Y position.
        /// </summary>
        /// <param name="graphics">graphics to render to.</param>
        /// <param name="X">X coordinate.</param>
        /// <param name="Y">Y coordinate.</param>
        protected override void RenderBackground(Graphics graphics, int x, int y)
        {
            base.RenderBackground(graphics, x, y);

            if ( (true == this.TicksVisible) && (0 != this.TicksCount) )
            {
                if (true == this.Vertical)
                {
                    int w = this.Bounds.Width / 2 + this.Bounds.X + x;

                    if (true == this.BottomTicksVisible)
                    {
                        w += 4;
                    }
                    else
                    {
                        w -= 10 + 4;
                    }

                    if (this.TicksCount > 0)
                    {
                        int h = this.Bounds.Height - 1;

                        graphics.SetColor(this.TextColor);

                        float step = 1.0f / this.ticksCount;

                        for (float i = 0; i < 1.001f; i += step)
                        {
                            graphics.DrawRectangle(w, (int)(this.Bounds.Y + y + h * i), 5, 1);
                        }
                    }
                }
                else
                {
                    int h = this.Bounds.Height / 2 + this.Bounds.Y + y;

                    if (true == this.BottomTicksVisible)
                    {
                        h += 4;
                    }
                    else
                    {
                        h -= 10 + 4;
                    }

                    if (this.TicksCount > 0)
                    {
                        int w = this.Bounds.Width - 1;

                        graphics.SetColor(this.TextColor);

                        float step = 1.0f / this.TicksCount;

                        for (float i = 0; i < 1.001f; i += step)
                        {
                            graphics.DrawRectangle((int)(this.Bounds.X + x + w * i), h, 1, 5);
                        }
                    }
                }
            }

            if ((false == this.Vertical) && (null != this.FontInfo.Font))
            {
                int h = this.Bounds.Height / 2 + this.Bounds.Y + y;

                if (true == this.BottomTicksVisible)
                {
                    h += 4 + 5;
                }
                else
                {
                    h -= 4 + 5 + this.FontInfo.Font.TextHeight(this.maxText) + 7;
                }

                this.FontInfo.Font.DrawText(graphics, this.Bounds.X + x, h, this.minText);
                this.FontInfo.Font.DrawText(graphics, this.Bounds.X + x + this.Bounds.Width - this.FontInfo.Font.TextLength(this.maxText), h, this.maxText);
            }
        }
예제 #19
0
파일: TrackBar.cs 프로젝트: drme/thw-ui
        /// <summary>
        /// Renders control at X, Y position
        /// </summary>
        /// <param name="graphics">graphic to render to</param>
        /// <param name="X">X coordinate</param>
        /// <param name="Y">Y coordinate</param>
        protected override void Render(Graphics graphics, int x, int y)
        {
            if (false == this.vertical)
            {
                this.backPanel.Bounds.UpdateSize(0, this.bounds.Height / 2 - 2, this.bounds.Width, 4);
                int w = this.Bounds.Width - this.buttonSize;
                this.sliderButton.Bounds.UpdateSize((int)(w * this.position), this.bounds.Height / 2 - this.buttonSize, this.buttonSize, this.buttonSize * 2);
            }
            else
            {
                this.backPanel.Bounds.UpdateSize(this.bounds.Width / 2 - 2, 0, 4, this.bounds.Height);
                int h = this.Bounds.Height - this.buttonSize;
                this.sliderButton.Bounds.UpdateSize(this.bounds.Width / 2 - this.buttonSize, (int)(h * this.position), this.buttonSize * 2, this.buttonSize);
            }

            base.Render(graphics, x, y);
        }
예제 #20
0
        /// <summary>
        /// Render letter
        /// </summary>
        /// <param name="render">graphics to render to.</param>
        /// <param name="X">X position.</param>
        /// <param name="Y">Y position.</param>
        /// <returns></returns>
        public int Render(Graphics render, int x, int y)
        {
            if (false == this.loaded) // branch prediction will do the job.
            {
                Load(false);
            }

            if (null != this.image)
            {
                render.DrawImage(x + this.offsetX, y + this.offsetY, this.textureWidth, this.textureHeight, this.image, this.uvs);
            }

            return this.width;
        }
예제 #21
0
파일: PropertyRow.cs 프로젝트: drme/thw-ui
        protected override void RenderControls(Graphics graphics, int x, int y)
        {
            base.RenderControls(graphics, x, y);

            if (true == this.HasFocus)
            {
                RenderSelection(graphics, x, y);
            }
            else if ( (null != this.inputControl) && (true == this.inputControl.HasFocus) )
            {
                graphics.SetColor(this.Window.Desktop.Theme.Colors.Highlight, 0.5f);
                graphics.DrawRectangle(x + this.bounds.X + 1, y + this.bounds.Y + 1, this.bounds.Width / 2 - 1, this.bounds.Height - 2);

                graphics.SetColor(this.Window.Desktop.Theme.Colors.HighlightBorder, 0.5f);
                graphics.DrawBox(x + this.Bounds.X, y + this.Bounds.Y, this.Bounds.Width / 2, this.Bounds.Height);
            }
        }
예제 #22
0
파일: IFont.cs 프로젝트: drme/thw-ui
 /// <summary>
 /// Renders text (substring from start till end) at specified location using active color.
 /// </summary>
 /// <param name="graphics">rendering object</param>
 /// <param name="X">X position</param>
 /// <param name="Y">Y position </param>
 /// <param name="text">text to render</param>
 /// <param name="start">starting symbol of the text</param>
 /// <param name="stop">ending symbol of the text</param>
 public abstract void DrawText(Graphics graphics, int x, int y, String text, int start, int stop);
예제 #23
0
파일: PropertyRow.cs 프로젝트: drme/thw-ui
        /// <summary>
        /// Renders property row key text and icon.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        protected void RenderName(Graphics graphics, int x, int y)
        {
            IFont font = this.Parent.Parent.FontInfo.Font;

            if (null != font)
            {
                String name = (null != this.property) ? this.property.Text : this.controlText;

                graphics.SetColor(this.Parent.Parent.TextColor);

                int len = name.Length;

                while (font.TextLength(name, 0, len) > this.Bounds.Width / 2 - 16)
                {
                    len--;
                }

                int xOffset = 0;

                if (this.parentGrid.RowHeight > 0)
                {
                    xOffset = this.parentGrid.RowHeight;
                }

                RenderText(graphics, x + xOffset, y, ContentAlignment.MiddleLeft, name);
            }

            RenderIcon(graphics, x, y);
        }
예제 #24
0
파일: BitmapLetter.cs 프로젝트: drme/thw-ui
        public int Render(Graphics graphics, int x, int y)
        {
            graphics.DrawImage(x, y, this.width, this.height, this.texture, this.texCoords);

            return this.letterWidth;
        }
예제 #25
0
파일: CheckBox.cs 프로젝트: drme/thw-ui
        /// <summary>
        /// Renders contorl ant tick
        /// </summary>
        /// <param name="graphics">graphics context to render to</param>
        /// <param name="X">control offset X</param>
        /// <param name="Y">control offset Y</param>
        protected override void Render(Graphics graphics, int x, int y)
        {
            base.Render(graphics, x, y);

            RenderCheck(graphics, x, y);
        }
예제 #26
0
파일: ImageObject.cs 프로젝트: drme/thw-ui
        public void Render(Graphics graphics, int x, int y, int w, int h, Color color, float opacity, ImageLayout layout)
        {
            if (false == this.missing)
            {
                if (null == this.image)
                {
                    this.image = this.engine.CreateImage(this.Name);

                    if (null == this.image)
                    {
                        this.missing = true;

                        return;
                    }
                }

                if ((0.0f == this.image.Width) || (0.0f == this.image.Height))
                {
                    return;
                }

                if ((null == color) || (opacity <= 0.0f) || (opacity == 1.0f && (color.A <= 0.0f)))
                {
                    return;
                }

                graphics.SetColor(color, opacity);

                switch (layout)
                {
                    case ImageLayout.ImageLayoutNone: // +
                        {
                            graphics.SetRegion(x, y, w, h);
                            graphics.DrawImage(x, y, this.image.Width, this.image.Height, this.image);
                            graphics.ClearRegion();
                        }
                        break;
                    case ImageLayout.ImageLayoutCenter: // +
                        {
                            int offX = (w - this.image.Width) / 2;
                            int offY = (h - this.image.Height) / 2;
                            graphics.SetRegion(x, y, w, h);
                            graphics.DrawImage(x + offX, y + offY, this.image.Width, this.image.Height, this.image);
                            graphics.ClearRegion();
                        }
                        break;
                    case ImageLayout.ImageLayoutStretch:
                        graphics.DrawImage(x, y, w, h, this.image);
                        break;
                    case ImageLayout.ImageLayoutTile: // +
                        {
                            float u = (float)(w) / (float)(this.image.Width);
                            float v = (float)(h) / (float)(this.image.Height);
                            graphics.DrawImage(x, y, w, h, this.image, u, v);
                        }
                        break;
                    case ImageLayout.ImageLayoutZoom: // +
                        {
                            float ri = (float)(this.image.Width) / (float)(this.image.Height);

                            int newW = w;
                            int newH = (int)((float)(newW) / ri);
                            int px = x;
                            int py = y + (h - newH) / 2;

                            if (newH > h)
                            {
                                newH = h;
                                newW = (int)((float)(newH) * ri);
                                px = x + (w - newW) / 2;
                                py = y;
                            }

                            graphics.DrawImage(px, py, newW, newH, this.image);
                        }
                        break;
                    case ImageLayout.ImageLayoutFillWidth:
                        {
                            int dy = (int)((w - h) / 2);

                            graphics.SetRegion(x, y, w, h);

                            graphics.DrawImage(x, y - dy, w, h + dy * 2, this.image);

                            graphics.ClearRegion();
                        }
                        break;
                    default:
                        break;
                }
            }
        }
예제 #27
0
파일: CheckBox.cs 프로젝트: drme/thw-ui
        /// <summary>
        /// Renders checkbox tick
        /// </summary>
        /// <param name="graphics">graphics t orender to</param>
        /// <param name="X">X position</param>
        /// <param name="Y">Y position</param>
        protected void RenderCheck(Graphics graphics, int x, int y)
        {
            if (true == this.Checked)
            {
                if (null == this.tick)
                {
                    this.tick = this.Engine.CreateImage(this.Window.Desktop.Theme.ThemeFolder + "/images/checkbox_tick");
                }

                if (null != this.tick)
                {
                    int off = (this.Bounds.Height - this.tick.Height) / 2;

                    graphics.DrawImage(off + x + this.Bounds.X, off + y + this.Bounds.Y, this.tick.Width, this.tick.Height, this.tick);
                }
            }
        }
예제 #28
0
파일: ImagesCache.cs 프로젝트: drme/thw-ui
        /// <summary>
        /// Creates requested image. If image file not found creates dotted texture.
        /// </summary>
        internal IImage CreateImage(String fileName, UIEngine engine, Graphics graphics)
        {
            if (null == fileName)
            {
                var img = new Image(fileName, new byte[2 * 2 * 4], 2, 2, 32);

                return graphics.CreateImage((int)img.Width, (int)img.Height, img.Bytes);
            }

            IImage image = null;
            Object file = null;

            try
            {
                this.cachedImages.TryGetValue(fileName, out image);

                if (null != image)
                {
                    return image;
                }

                if (true == fileName.StartsWith("#shell32,"))
                {
                    image = engine.GetIcon(int.Parse(fileName.Substring("#shell32,".Length)), true, null);

                    if (null != image)
                    {
                        return image;
                    }
                }

                image = graphics.CreateImage(fileName);

                if (null != image)
                {
                    return image;
                }

                byte[] imageData = null;
                uint size = 0;

                if (true == engine.OpenFile(fileName, out imageData, out size, out file))
                {
                    image = graphics.CreateImage(imageData, fileName);
                }
                else if (true == engine.OpenFile(fileName + ".png", out imageData, out size, out file))
                {
                    image = graphics.CreateImage(imageData, fileName + ".png");
                }
                else if (true == engine.OpenFile(fileName + ".jpg", out imageData, out size, out file))
                {
                    image = graphics.CreateImage(imageData, fileName + ".jpg");
                }
                else if (true == engine.OpenFile(fileName + ".tga", out imageData, out size, out file))
                {
                    image = graphics.CreateImage(imageData, fileName + ".tga");

                    if (null == image)
                    {
                        IImageLoader imageLoader = new TgaImageLoader(engine);

                        Image img = imageLoader.CreateImage(fileName);

                        if (null != img)
                        {
                            image = graphics.CreateImage((int)img.Width, (int)img.Height, img.Bytes);
                        }
                    }
                }

                return image;
            }
            finally
            {
                if (null != image)
                {
                    image.Name = fileName;

                    image.AddRef();

                    this.cachedImages[fileName] = image;
                }

                if (null != file)
                {
                    engine.CloseFile(ref file);
                }
            }
        }
예제 #29
0
        protected override void Render(Graphics graphics, int x, int y)
        {
            this.statusPanel.Y = this.graphics.Viewport.Height - 73;
            this.statusPanel.Width = this.graphics.Viewport.Width;
            this.infoPanel.X = this.graphics.Viewport.Width - this.infoPanel.Width;

            base.Render(graphics, x, y);
        }
예제 #30
0
파일: MenuRibbon.cs 프로젝트: drme/thw-ui
        protected override void Render(Graphics graphics, int x, int y)
        {
            this.menuButton.Width = this.Width - 80;
            this.menuButton.X = 40;
            this.menuButton.Y = this.Height - 100;

            int y1 = this.Height - 150;

            foreach (var button in this.Controls)
            {
                if ((button != this.menuButton))
                {
                    button.Width = this.Width-80;
                    button.Height = 28;
                    button.FontInfo.Name = "Calibri";
                    button.FontInfo.Bold = true;
                    button.FontInfo.Size = 18;
                    button.TextColor = Colors.White;
                    button.BackColor = Colors.None;
                    button.Border = BorderStyle.None;
                    button.X = 40;
                    button.Y = y1;
                    button.Visible = this.Active;

                    y1 -= 50;
                }
            }

            graphics.SetColor(Colors.Red);

            if (this.Active == true)
            {
                var rx = (int)(5.0 * Math.Sin(Math.PI * 2 * DateTime.Now.Millisecond / 1000));
                var rw = this.Width - 20 + (int)(5.0 * Math.Cos(Math.PI * 2 * DateTime.Now.Millisecond / 1000));

                graphics.DrawBox(this.Bounds.X + x + rx, this.Bounds.Y + y + 0, rw, this.Height);
            }
            else
            {
                var rx = (this.Width - 15) / 2 + (int)(5.0 * Math.Sin(Math.PI * 2 * DateTime.Now.Millisecond / 1000));
                var rw = 15 + (int)(5.0 * Math.Cos(Math.PI * 2 * DateTime.Now.Millisecond / 1000));

                graphics.DrawBox(this.Bounds.X + x + rx, this.Bounds.Y + y + 0, rw, this.Height);
            }

            base.Render(graphics, x, y);
        }