Exemplo n.º 1
0
        public void InitButtons()
        {
            Vector2 buttonPosition = new Vector2(FormSize.X - 15f, 5f) + FormPos;
            Color   buttonColor    = new Color(new Vector4(new Vector3(0.3f) + ColorBackground.ToVector3() * 0.6f, 1.0f));

            if (CanClose)
            {
                BtnClose = new ButtonSimple("btClose", buttonPosition, "button_close", FormStyle);
                BtnClose.OnMouseRelease += new EventHandler(closeButton_onMouseRelease);
            }

            if (CanMini)
            {
                BtnMini = new ButtonSimple("btMinimize", buttonPosition - new Vector2(25, 0f), "button_minimize", FormStyle);
                BtnMini.OnMouseRelease += new EventHandler(minimizeButton_onMouseRelease);
            }

            if (CanMaxi)
            {
                BtnMaxi = new ButtonSimple("btMaximize", buttonPosition - new Vector2(15, 0f), "button_maximize", FormStyle);
                BtnMaxi.OnMouseRelease += new EventHandler(maximizeButton_onMouseRelease);
            }

            BtnRestore = new ButtonSimple("btRestore", buttonPosition - new Vector2(15, 0f), "button_restore", FormStyle);
            BtnRestore.OnMouseRelease += new EventHandler(maximizeButton_onMouseRelease);
        }
Exemplo n.º 2
0
        public virtual void Draw()
        {
            if (Visible == false)
            {
                return;
            }

            EngineCore.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend);

            if (mDrawOrder != Form.CurrentDrawOrder && mCanLostFocus == true && mModifyAlpha == true)
            {
                mAlpha = mFormAlpha * 0.7f;
            }
            else
            {
                mAlpha = mFormAlpha;
            }

            Color dynamicColor = new Color(new Vector4(ColorBackground.ToVector3().X, ColorBackground.ToVector3().Y, ColorBackground.ToVector3().Z, mAlpha));

            DrawWindowParts(EngineCore.SpriteBatch, dynamicColor);

            DrawButtons();

            Color dynamicTextColor = new Color(new Vector4(ColorForeground.ToVector3().X, ColorForeground.ToVector3().Y, ColorForeground.ToVector3().Z, mAlpha));

            if (HideTitle == false)
            {
                if (FormStyle.TitleShadow == true)
                {
                    EngineCore.SpriteBatch.DrawString(FormFont, FormTitle, FormPos + new Vector2(FormTitlePos.X + 1f, FormTitlePos.Y + 1f), new Color(new Vector4(Color.White.ToVector3().X, Color.White.ToVector3().Y, Color.White.ToVector3().Z, mAlpha)));
                }
                EngineCore.SpriteBatch.DrawString(FormFont, FormTitle, FormPos + new Vector2(FormTitlePos.X, FormTitlePos.Y), dynamicTextColor);
            }

            Controls.Draw(EngineCore.SpriteBatch, mAlpha);

            EngineCore.SpriteBatch.End();
        }
Exemplo n.º 3
0
 private void buttonOK_Click(object sender, EventArgs e)
 {
     if (tabControlBackgroundType.SelectedIndex == 0)
     {
         if (listViewImages.SelectedItems.Count > 0)
         {
             string image = (string)listViewImages.SelectedItems[0].Tag;
             if (!string.IsNullOrEmpty(image))
             {
                 Background   = new ImageBackground(image);
                 DialogResult = DialogResult.OK;
             }
         }
         else
         {
             MessageBox.Show("Kein Bild gewählt!", "Bildmanager", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     else if (tabControlBackgroundType.SelectedIndex == 1)
     {
         Background   = new ColorBackground(pictureBoxColor.BackColor);
         DialogResult = DialogResult.OK;
     }
 }
 void OnSerializingMethod(StreamingContext sc)
 {
     BackgroundImages = new string[] { BackgroundImage };
     BackgroundColor  = ColorBackground.ToString();
 }
Exemplo n.º 5
0
        public void DrawCanvas(SKCanvas canvas, double hour, double minute, double second, int width = 512, int height = 512, bool bDrawBackImage = false)
        {
            DateTime swStart = DateTime.Now;

            canvas.Clear();
            int x = Math.Min(width, height);

            // Clock background
            fillPaint.Color = ColorBackground.ToSKColor();
            if (bDrawBackImage && ColorBackground.A > 0)
            {
                canvas.DrawCircle(width / 2, height / 2, x / 2, fillPaint);
            }

            //Background image
            if (bDrawBackImage && !string.IsNullOrEmpty(BackgroundImage))
            {
                //this is only for widget-preview!!!
                try
                {
                    /*if (BackgroundImage.EndsWith(".svg"))
                     * {
                     *
                     *  // load the SVG
                     *  var svg = new SKSvg();
                     *  svg.Load(BackgroundImage);
                     *
                     *  float scale = (float)x / Math.Max(svg.Picture.CullRect.Width, svg.Picture.CullRect.Height);
                     *  var matrix = new SKMatrix
                     *  {
                     *      ScaleX = scale,
                     *      ScaleY = scale,
                     *      TransX = (width - x) / 2,
                     *      TransY = (height - x) / 2,
                     *      Persp2 = 1,
                     *  };
                     *
                     *  canvas.DrawPicture(svg.Picture, ref matrix);
                     * }
                     * else*/
                    {
                        if (bmpBackCache == null)
                        {
                            using (var bitmap = SKBitmap.Decode(BackgroundImage))
                            {
                                bmpBackCache = bitmap.Resize(new SKImageInfo(x, x), SKFilterQuality.High);
                            }
                        }

                        if (bmpBackCache != null)
                        {
                            canvas.DrawBitmap(bmpBackCache, (width - bmpBackCache.Width) / 2, (height - bmpBackCache.Height) / 2);
                        }
                    }
                }
                catch { }
            }

            // Set scale to draw on a 1000*1000 points base
            canvas.Translate(width > height ? (width - height) / 2 : 0, height > width ? (height - width) / 2 : 0);
            canvas.Scale(Math.Min(width / 1000f, height / 1000f));

            // Hour and minute marks
            if (TickMarkStyle != TickMarkStyle.None && ColorTickMarks.A > 0)
            {
                var tickPaint = new SKPaint
                {
                    Color       = ColorTickMarks.ToSKColor(),
                    StrokeCap   = SKStrokeCap.Round,
                    IsAntialias = true
                };

                if (ColorTickMarks.IsEmpty)
                {
                    tickPaint.Color = ClockPath.GetBestColor(ColorTickMarks, ClockfaceInfo != null && !BackImageAllowsBackColor ? ClockfaceInfo.MainColor + " " + ClockfaceInfo.HandColorsBanned : ColorBackground.HexString, ClockfaceInfo?.HandColorSuggestion).ToSKColor();
                }

                switch (TickMarkStyle)
                {
                case TickMarkStyle.Dotts:
                    tickPaint.Style = SKPaintStyle.Fill;
                    canvas.Translate(500, 500);
                    for (int angle = 0; angle < 360; angle += 6)
                    {
                        canvas.DrawCircle(0, -460, angle % 30 == 0 ? 20 : 10, tickPaint);
                        canvas.RotateDegrees(6);
                    }
                    canvas.Translate(-500, -500);
                    break;

                case TickMarkStyle.Circle:
                    tickPaint.Style       = SKPaintStyle.Stroke;
                    tickPaint.StrokeWidth = 20;
                    canvas.DrawCircle(500, 500, 470, tickPaint);

                    break;

                case TickMarkStyle.LinesSquare:
                    tickPaint.StrokeCap = SKStrokeCap.Square;
                    goto case TickMarkStyle.LinesRound;

                case TickMarkStyle.LinesButt:
                    tickPaint.StrokeCap = SKStrokeCap.Butt;
                    goto case TickMarkStyle.LinesRound;

                case TickMarkStyle.LinesRound:
                    tickPaint.Style = SKPaintStyle.Stroke;
                    canvas.Translate(500, 500);
                    for (int angle = 0; angle < 360; angle += 6)
                    {
                        if (angle % 30 == 0)
                        {
                            tickPaint.StrokeWidth = 20;
                            canvas.DrawLine(0, -450, 0, -470, tickPaint);
                        }
                        else
                        {
                            tickPaint.StrokeWidth = 10;
                            canvas.DrawLine(0, -455, 0, -465, tickPaint);
                        }
                        canvas.RotateDegrees(6);
                    }
                    canvas.Translate(-500, -500);
                    break;
                }
            }


            if (!FlowHourHand)
            {
                hour = Math.Truncate(hour);
            }
            if (!FlowMinuteHand)
            {
                minute = Math.Truncate(minute);
            }
            if (!FlowSecondHand)
            {
                second = Math.Truncate(second);
            }

            // Hour hand
            if (ShowHourHand && HourPathList != null)
            {
                canvas.RotateDegrees((float)(30 * hour), 500, 500);

                drawClockPaths(canvas, HourPathList, ColorHourHandStroke, ColorHourHandFill);

                canvas.RotateDegrees((float)(-30 * hour), 500, 500);
            }

            // Minute hand
            if (ShowMinuteHand && MinutePathList != null)
            {
                canvas.RotateDegrees((float)(6 * minute), 500, 500);

                drawClockPaths(canvas, MinutePathList, ColorMinuteHandStroke, ColorMinuteHandFill);

                canvas.RotateDegrees((float)(-6 * minute), 500, 500);
            }

            // Second hand
            if (ShowSecondHand && SecondPathList != null)
            {
                canvas.RotateDegrees((float)(6 * second), 500, 500);

                drawClockPaths(canvas, SecondPathList, ColorSecondHandStroke, ColorSecondHandFill);

                canvas.RotateDegrees((float)(-6 * second), 500, 500);
            }

            if (CapPathList != null)
            {
                drawClockPaths(canvas, CapPathList, ColorCenterCapStroke, ColorCenterCapFill);
            }

            TimeSpan tsDraw = DateTime.Now - swStart;

            iAllCount++;
            tsAllSum += tsDraw;
            if (tsMin > tsDraw)
            {
                tsMin = tsDraw;
            }
            if (tsMax < tsDraw)
            {
                tsMax = tsDraw;
            }
        }
 void OnSerializingMethod(StreamingContext sc)
 {
     BackgroundColor = ColorBackground.ToString();
 }