Spring – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | using System; |
2 | using System.Drawing; |
||
3 | using System.Text; |
||
4 | using System.Threading.Tasks; |
||
5 | using System.Windows.Forms; |
||
6 | using WindowsInput; |
||
7 | using Gma.System.MouseKeyHook; |
||
8 | using Spring.Main; |
||
9 | using Spring.Utilities; |
||
10 | |||
11 | namespace Spring.Tutorial |
||
12 | { |
||
13 | public partial class Tutorial : Form |
||
14 | { |
||
15 | #region Public Enums, Properties and Fields |
||
16 | |||
17 | public IKeyboardMouseEvents KeyboardMouseEvents { get; set; } |
||
18 | |||
19 | public InputSimulator InputSimulator { get; } |
||
20 | |||
21 | public MainForm Form { get; } |
||
22 | |||
23 | public int Slide { get; set; } |
||
24 | |||
25 | #endregion |
||
26 | |||
27 | #region Constructors, Destructors and Finalizers |
||
28 | |||
29 | public Tutorial() |
||
30 | { |
||
31 | InitializeComponent(); |
||
32 | Utilities.WindowState.FormTracker.Track(this); |
||
33 | |||
34 | InputSimulator = new InputSimulator(); |
||
35 | } |
||
36 | |||
37 | public Tutorial(MainForm springMainForm, IKeyboardMouseEvents keyboardMouseEvents) : this() |
||
38 | { |
||
39 | Form = springMainForm; |
||
40 | KeyboardMouseEvents = keyboardMouseEvents; |
||
41 | |||
42 | KeyboardMouseEvents.KeyUp += KeyboardMouseEvents_KeyUp; |
||
43 | } |
||
44 | |||
45 | /// <summary> |
||
46 | /// Clean up any resources being used. |
||
47 | /// </summary> |
||
48 | /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |
||
49 | protected override void Dispose(bool disposing) |
||
50 | { |
||
51 | if (disposing && components != null) |
||
52 | { |
||
53 | KeyboardMouseEvents.KeyUp -= KeyboardMouseEvents_KeyUp; |
||
54 | |||
55 | components.Dispose(); |
||
56 | } |
||
57 | |||
58 | base.Dispose(disposing); |
||
59 | } |
||
60 | |||
61 | #endregion |
||
62 | |||
63 | #region Event Handlers |
||
64 | |||
65 | private void Form_Move(object sender, EventArgs e) |
||
66 | { |
||
67 | RelocateTutorial(); |
||
68 | } |
||
69 | |||
70 | private async void KeyboardMouseEvents_KeyUp(object sender, KeyEventArgs e) |
||
71 | { |
||
72 | switch (e.KeyCode) |
||
73 | { |
||
74 | case Keys.Space: |
||
75 | await NextSlide(); |
||
76 | |||
77 | break; |
||
78 | |||
79 | case Keys.Escape: |
||
80 | Close(); |
||
81 | |||
82 | break; |
||
83 | } |
||
84 | } |
||
85 | |||
86 | private async void Tutorial_Load(object sender, EventArgs e) |
||
87 | { |
||
88 | RelocateTutorial(); |
||
89 | await NextSlide(); |
||
90 | } |
||
91 | |||
92 | private void RichTextBox1_KeyDown(object sender, KeyEventArgs e) |
||
93 | { |
||
94 | e.SuppressKeyPress = true; |
||
95 | } |
||
96 | |||
97 | #endregion |
||
98 | |||
99 | #region Private Methods |
||
100 | |||
101 | private void RelocateTutorial() |
||
102 | { |
||
103 | var springLocation = Form.Location; |
||
104 | Location = new Point(springLocation.X + Form.Size.Width, springLocation.Y); |
||
105 | } |
||
106 | |||
107 | private async Task NextSlide() |
||
108 | { |
||
109 | try |
||
110 | { |
||
111 | ++Slide; |
||
112 | |||
113 | var rtf = Encoding.UTF8.GetString(await Helpers.LoadResource($"Spring.Tutorial.Slides.{Slide}.rtf")); |
||
114 | |||
115 | richTextBox1.Rtf = rtf; |
||
116 | } |
||
117 | catch |
||
118 | { |
||
119 | Close(); |
||
120 | } |
||
121 | } |
||
122 | |||
123 | #endregion |
||
124 | } |
||
125 | } |