-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFancyTextComponent.cs
More file actions
135 lines (115 loc) · 3.56 KB
/
Copy pathFancyTextComponent.cs
File metadata and controls
135 lines (115 loc) · 3.56 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
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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Xml;
using LiveSplit.Model;
using LiveSplit.UI;
namespace LiveSplit.UI.Components
{
public enum FancyTextColorMode
{
Solid,
Gradient
}
public enum FancyTextGradientMode
{
ExistingColors,
NewGradient
}
public enum FancyTextGradientDirection
{
Horizontal,
Vertical,
DiagonalDown,
DiagonalUp
}
public enum FancyTextAlignment
{
Left,
Center,
Right
}
public enum FancyTextScopeMode
{
ThisComponentOnly,
AllComponents,
SelectedComponents
}
public enum FancyTextShadowMode
{
Behind,
OutsideOnly
}
public class FancyTextComponent : IComponent
{
private readonly FancyTextSettings _settings;
public FancyTextComponent(LiveSplitState state)
{
_settings = new FancyTextSettings(state, this);
FancyTextRuntime.InstallHooks(state);
}
internal FancyTextComponent(LiveSplitState state, FancyTextSettings settings)
{
_settings = settings ?? new FancyTextSettings(state, this);
_settings.AttachOwner(this);
FancyTextRuntime.InstallHooks(state);
}
public string ComponentName
{
get
{
string name = _settings.InstanceName;
return string.IsNullOrWhiteSpace(name)
? "Fancy Text"
: "Fancy Text - " + name;
}
}
// FancyText is a controller. It should not consume layout space.
public float VerticalHeight { get { return 0f; } }
public float MinimumHeight { get { return 0f; } }
public float HorizontalWidth { get { return 0f; } }
public float MinimumWidth { get { return 0f; } }
public float PaddingTop { get { return 0f; } }
public float PaddingBottom { get { return 0f; } }
public float PaddingLeft { get { return 0f; } }
public float PaddingRight { get { return 0f; } }
public IDictionary<string, Action> ContextMenuControls { get { return null; } }
public Control GetSettingsControl(LayoutMode mode)
{
_settings.NotifyLayoutMode(mode);
return _settings;
}
public XmlNode GetSettings(XmlDocument document)
{
return _settings.GetSettings(document);
}
public void SetSettings(XmlNode settings)
{
_settings.SetSettings(settings);
}
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode)
{
FancyTextRuntime.InstallHooks(state);
FancyTextRuntime.Publish(this, state, _settings);
invalidator?.Invalidate(0, 0, width, height);
}
public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion)
{
DrawControllerLayer(g, state);
}
public void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion)
{
DrawControllerLayer(g, state);
}
public void Dispose()
{
FancyTextRuntime.Unpublish(this);
}
private void DrawControllerLayer(Graphics g, LiveSplitState state)
{
FancyTextRuntime.InstallHooks(state);
FancyTextRuntime.Publish(this, state, _settings);
}
}
}