forked from PavelTorgashov/FastColoredTextBox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJokeSample.cs
More file actions
56 lines (52 loc) · 1.77 KB
/
Copy pathJokeSample.cs
File metadata and controls
56 lines (52 loc) · 1.77 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FastColoredTextBoxNS;
namespace Tester
{
public partial class JokeSample : Form
{
public JokeSample()
{
InitializeComponent();
fctb.DefaultStyle = new JokeStyle();
}
private void timer1_Tick(object sender, EventArgs e)
{
fctb.Invalidate();
}
}
/// <summary>
/// This class is used as text renderer
/// </summary>
class JokeStyle : TextStyle
{
public JokeStyle():base(null, null, FontStyle.Regular)
{
}
public override void Draw(Graphics gr, Point position, Range range)
{
foreach (Place p in range)
{
int time = (int)(DateTime.Now.TimeOfDay.TotalMilliseconds/2);
int angle = (int)(time % 360L);
int angle2 = (int)((time - (p.iChar - range.Start.iChar)*20) % 360L)*2;
int x = position.X + (p.iChar - range.Start.iChar) * range.tb.CharWidth;
Range r = range.tb.GetRange(p, new Place(p.iChar+1, p.iLine));
Point point = new Point(x, position.Y + (int)(5 + 5 * Math.Sin(Math.PI * angle2 / 180)));
gr.ResetTransform();
gr.TranslateTransform(point.X + range.tb.CharWidth / 2, point.Y +range.tb.CharHeight / 2);
gr.RotateTransform(angle);
gr.ScaleTransform(0.8f, 0.8f);
gr.TranslateTransform(- range.tb.CharWidth / 2, -range.tb.CharHeight / 2);
base.Draw(gr, new Point(0, 0), r);
}
gr.ResetTransform();
}
}
}