-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
132 lines (117 loc) · 4.78 KB
/
Program.cs
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
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Events;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using adWin = Autodesk.Windows;
namespace RevitNyanCat
{
public class Program : IExternalApplication
{
private Stopwatch stopwatch;
int modifier = 0;
ImageSource imgbg = new BitmapImage(
new Uri(Path.Combine(
Path.GetDirectoryName(
Assembly.GetExecutingAssembly().Location),
"catgif.gif"),
UriKind.Relative));
public Result OnStartup(UIControlledApplication application)
{
try
{
stopwatch = new Stopwatch();
stopwatch.Start();
// Register events
application.Idling += OnIdling;
}
catch (Exception)
{
return Result.Failed;
}
return Result.Succeeded;
}
public Result OnShutdown(UIControlledApplication application)
{
// Unregister Events
application.Idling -= OnIdling;
return Result.Succeeded;
}
public void OnIdling(object sender, IdlingEventArgs e)
{
int count = 0;
ImageBrush picBrush = new ImageBrush();
picBrush.ImageSource = imgbg;
picBrush.AlignmentX = AlignmentX.Center;
picBrush.AlignmentY = AlignmentY.Center;
picBrush.Stretch = Stretch.None;
picBrush.TileMode = TileMode.None;
adWin.RibbonControl ribbon = adWin.ComponentManager.Ribbon;
if (stopwatch.ElapsedMilliseconds > 100)
{
if (modifier == 7)
{
count = 0;
}
else
{
count += modifier;
}
foreach (adWin.RibbonTab tab in ribbon.Tabs)
{
tab.Title = "Nyan Cat";
foreach (adWin.RibbonPanel panel in tab.Panels)
{
switch (count)
{
case 0:
panel.CustomPanelBackground = new SolidColorBrush(Colors.Red);
panel.CustomPanelTitleBarBackground = new SolidColorBrush(Colors.Red);
break;
case 1:
panel.CustomPanelBackground = new SolidColorBrush(Colors.Orange);
panel.CustomPanelTitleBarBackground = new SolidColorBrush(Colors.Orange);
break;
case 2:
panel.CustomPanelBackground = new SolidColorBrush(Colors.Yellow);
panel.CustomPanelTitleBarBackground = new SolidColorBrush(Colors.Yellow);
panel.CustomPanelBackground = picBrush;
break;
case 3:
panel.CustomPanelBackground = new SolidColorBrush(Colors.Green);
panel.CustomPanelTitleBarBackground = new SolidColorBrush(Colors.Green);
break;
case 4:
panel.CustomPanelBackground = new SolidColorBrush(Colors.Blue);
panel.CustomPanelTitleBarBackground = new SolidColorBrush(Colors.Blue);
break;
case 5:
panel.CustomPanelBackground = new SolidColorBrush(Colors.Indigo);
panel.CustomPanelTitleBarBackground = new SolidColorBrush(Colors.Indigo);
break;
case 6:
panel.CustomPanelBackground = new SolidColorBrush(Colors.Violet);
panel.CustomPanelTitleBarBackground = new SolidColorBrush(Colors.Violet);
break;
}
count += 1;
if (count > 6) { count = 0; }
}
}
if (modifier == 6)
{
modifier = 0;
}
else
{
modifier += 1;
}
}
stopwatch.Reset();
stopwatch.Start();
}
}
}