|
|
发表于 2005-12-15 17:29:00
|
显示全部楼层
Re: .net 图形引擎 LL3D正式出炉
呵呵,CreateWindow是他自己写的函数
/// <summary>
/// Creates a window with the specified title, icon, menu, and starting position. If Init hasn't been
/// called, this will call with default params. Instead of calling this, you can call SetWindow
/// to use an existing window
/// </summary>
public void CreateWindow(string windowTitle, System.Drawing.Icon icon,
System.Windows.Forms.MainMenu menu, int x, int y)
{
if (State.IsInsideDeviceCallback)
throw new InvalidOperationException("You cannot create a window from inside a callback.");
State.WasWindowCreateCalled = true;
// Are we inited?
if (!State.IsInited)
{
// If Init was already called and failed, fail again
if (State.WasInitCalled)
{
throw new InvalidOperationException("Initialize was already called and failed.");
}
// Call initialize with default params
Initialize(true, true, true);
}
// Is there already a window created?
if (State.WindowFocus == null)
{
// Override the window's initial size and position if there were cmd line args
if (State.OverrideStartX != -1)
{
State.DefaultStartingLocation = System.Windows.Forms.FormStartPosition.Manual;
x = State.OverrideStartX;
}
if (State.OverrideStartY != -1)
{
State.DefaultStartingLocation = System.Windows.Forms.FormStartPosition.Manual;
y = State.OverrideStartY;
}
// Create the new window
GraphicsWindow renderWindow = new GraphicsWindow(this);
// Hook the events
HookEvents(renderWindow);
// Are we in the default start location?
if (State.DefaultStartingLocation == System.Windows.Forms.FormStartPosition.WindowsDefaultLocation)
{
State.IsWindowCreatedWithDefaultPositions = true;
renderWindow.StartPosition = System.Windows.Forms.FormStartPosition.WindowsDefaultLocation;
}
else
{
State.IsWindowCreatedWithDefaultPositions = false;
renderWindow.Location = new System.Drawing.Point(x, y);
}
// Calculate the window size
System.Drawing.Size windowSize = DefaultStartingSize;
if (State.OverrideWidth != 0)
windowSize.Width = State.OverrideWidth;
if (State.OverrideHeight != 0)
windowSize.Height = State.OverrideHeight;
// Set the size
renderWindow.ClientSize = windowSize;
// Store the window title
State.WindowTitle = windowTitle;
renderWindow.Text = windowTitle;
// Set current cursor
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
// Get the window's rectangles
renderWindow.Visible = false;
renderWindow.CreateControl();
State.ClientRectangle = renderWindow.ClientRectangle;
State.WindowBoundsRectangle = renderWindow.Bounds;
// Update state
State.WasWindowCreated = true;
State.WindowFocus = renderWindow;
State.WindowDeviceFullScreen = renderWindow;
State.WindowDeviceWindowed = renderWindow;
}
}
/// <summary>
/// Calls into CreateWindow with default paramters
/// </summary>
public void CreateWindow(string windowTitle)
{
CreateWindow(windowTitle, LoadFirstIconFromResource(), null, -1, -1);
}
/// <summary> |
|