Let us see how to create a splash window class and register it property with the assistance of RevitAddinCoder. Click on the Splash Window tool button of the RevitAddinCoder,
or the Splash Window menu item like the following,
then the Splash Window coder window shows up:
If the Splash Window width and height, its time and image, and where to register the class are specified like the above, and the active project is a C# one, the following C# Splash Window class will be created.
using System;
using System.Windows.Forms;
using System.Drawing;
namespace RevitAddinCS1
{
public class RawSplashWindow
{
private Form form = null;
private Timer timer = null;
public RawSplashWindow(int width, int height, int interval_milisecs, Image image)
{
form = new Form();
form.Width = width;
form.Height = height;
form.BackgroundImage = image;
form.BackgroundImageLayout = ImageLayout.Stretch;
form.StartPosition = FormStartPosition.CenterScreen;
form.FormBorderStyle = FormBorderStyle.None;
form.TopMost = true;
timer = new Timer();
timer.Interval = interval_milisecs;
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
form.Show();
}
private void timer_Tick(object sender, EventArgs args)
{
timer.Stop();
form.Close();
}
}
}
And the following C# registration code will be created as well.
public Result OnStartup(UIControlledApplication uiApp)
{
new RawSplashWindow(600, 400, 10000, System.Drawing.Image.FromStream(this.GetType().Assembly.GetManifestResourceStream("RevitAddinCS1.Resources.Splash.bmp")));
…
…
}
If the active project is a VB.NET one, the following VB.NET code will be created.
Imports System.Windows.Forms
Imports System.Drawing
Public Class RawSplashWindow
Private form As Form = Nothing
Private timer As Timer = Nothing
Public Sub New(ByVal width As Integer, ByVal height As Integer, ByVal interval_milisecs As Integer, ByVal image As Image)
form = New Form()
form.Width = width
form.Height = height
form.BackgroundImage = image
form.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch
form.StartPosition = FormStartPosition.CenterScreen
form.FormBorderStyle = FormBorderStyle.None
form.TopMost = True
timer = New Timer()
timer.Interval = interval_milisecs
AddHandler timer.Tick, New EventHandler(AddressOf timer_Tick)
timer.Start()
form.Show()
End Sub
Private Sub timer_Tick(ByVal sender As Object, ByVal args As EventArgs)
timer.Stop()
form.Close()
End Sub
End Class
And the following registration code in VB.NET will be created as well.
Public Function OnStartup(ByVal uiApp As UIControlledApplication) As Result Implements IExternalApplication.OnStartup
Dim sw As New RawSplashWindow(600, 400, 10000, System.Drawing.Image.FromStream(Me.GetType().Assembly.GetManifestResourceStream("RevitAddinVB1.Splash.bmp")))
…
…
End Function
Splash Window of RevitAddinCoder can create all the code automatically in no time.
Recent Comments