1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public class Form1 : Form
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(12, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(260, 240);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// button1
//
this.button1.Location = new System.Drawing.Point(197, 258);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 288);
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button button1;
public Form1()
{
InitializeComponent();
}
private Bitmap bmp;
private Graphics PrintHandler;
private void button1_Click(object sender, EventArgs e)
{
Pen p = new Pen(Color.Red, 1);
Pen p2 = new Pen(Color.Blue, 2);
this.bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
pictureBox1.Image = bmp;
PrintHandler = Graphics.FromImage(pictureBox1.Image);
double durchmesser = 11d;
double Vx = 21.213;
double Vy = -18.134;
double yVorzeichenVerschiebung = Vy;
double xStart = (durchmesser - 1d) / 2d;
double yStart = 0d - yVorzeichenVerschiebung + (durchmesser - 1d) / 2d;
double xStop = Vx;
double yStop = durchmesser / 2d;
Point startPoint = new Point((int)xStart, (int)yStart);
Point endPoint = new Point((int)xStop, (int)yStop);
PrintHandler.DrawLine(p2, startPoint, endPoint);
if (yVorzeichenVerschiebung == 0)
{
/*e.Graphics.DrawLine(p2, endPoint, new Point(endPoint.X - 10, endPoint.Y));
e.Graphics.DrawLine(p2, endPoint, new Point(endPoint.X, endPoint.Y - 10));*/
/*e.Graphics.DrawLine(p2, endPoint, new Point(endPoint.X - 10, endPoint.Y));
e.Graphics.DrawLine(p2, endPoint, new Point(endPoint.X, endPoint.Y - 10));*/
//Console.Out.WriteLine(1);
}
else
{
// Ansatz über winkel klappt irgendwie nicht...
/*double test;
test = Math.Tan(Math.PI * 45 / 180) * Math.Sqrt(Math.Pow(endPoint.X, 2d) * Math.Pow(endPoint.Y, 2d));
*/
PrintHandler.DrawLine(p2, endPoint, new Point(endPoint.X - 10, endPoint.Y - 10));
PrintHandler.DrawLine(p2, endPoint, new Point(endPoint.X - 5, endPoint.Y + 10));
}
}
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
|