Laden...

Forenbeiträge von Contace Ingesamt 5 Beiträge

01.11.2018 - 16:12 Uhr

Hallo,

ich danke euch erstma allen für den tollen Support hier.

Ich hab mal mein resultat was ich bis jetzt habe angehängt.

Grüße

30.10.2018 - 08:46 Uhr

Hallo chilic,

danke für deinen Support.

Könntest Du den Code dazu bitte reinstellen.

Ich weiß nicht was Du mit nochmal genau meinst.

Grüße

29.10.2018 - 23:47 Uhr

Hab das Problem behoben.

Wie könnte ich jetzt mehrere Kreise mit Nummern erstellen ?

Grüße

29.10.2018 - 23:32 Uhr

mein bisheriges ergebniss im Anhang.

Grüße

29.10.2018 - 23:29 Uhr

Hallo,

ich wollte einen kreis mit nummern entwickeln, komme jedoch nicht weiter.

Das eigentliche resultat sollte wie im Anhang aussehen.

Mein aktueller Stand.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class DrawStringAlignACircle : System.Windows.Forms.Form
{
    private System.ComponentModel.Container components = null;

    public DrawStringAlignACircle()
    {
        InitializeComponent();
        BackColor = SystemColors.Window;
        ForeColor = SystemColors.WindowText;
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        Graphics g = e.Graphics;
        SetScale(g);
        DrawFace(g);
        base.OnPaint(e);
    }
    private void InitializeComponent()
    {
        this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
        this.ClientSize = new System.Drawing.Size(800, 600);

    }

    [STAThread]
    static void Main()
    {
        Application.Run(new DrawStringAlignACircle());
    }

    private void SetScale(Graphics g)
    {
        g.TranslateTransform(Width / 2, Height / 2);

        float inches = Math.Min(Width / g.DpiX, Height / g.DpiX);

        g.ScaleTransform(inches * g.DpiX / 2000, inches * g.DpiY / 2000);
    }

    private void DrawFace(Graphics g)
    {
        Brush brush = new SolidBrush(ForeColor);
        Font font = new Font("Arial", 15);

        float x, y;

        const int numHours = 100;
        const int deg = 360 / numHours;
        const int FaceRadius = 700;

        for (int i = 1; i <= numHours; i++)
        {
            x = GetCos(i * deg + 90) * FaceRadius;
            y = GetSin(i * deg - 90) * FaceRadius;

            StringFormat format = new StringFormat();
            format.Alignment = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;

            g.DrawString(i.ToString(), font, brush, -x, -y, format);

        }
        brush.Dispose();
        font.Dispose();
    }

    private static float GetSin(float degAngle)
    {
        return (float)Math.Sin(Math.PI * degAngle / 180f);
    }

    private static float GetCos(float degAngle)
    {
        return (float)Math.Cos(Math.PI * degAngle / 180f);
    }

}