|
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
//http://zetcode.com/tutorials/monowinformstutorial/introduction/
namespace MonoUIPerf
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private const long TicksPerMiliSecond = TimeSpan.TicksPerSecond / 1000;
private System.Windows.Forms.Label label1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
int _result = 0;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(300, 100);
this.label1.TabIndex = 0;
this.label1.Text = "UI test for Mono";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(300, 100);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static int Main()
{
Form1 f = new Form1();
Application.Run(f);
return f._result;
}
protected override void OnActivated(EventArgs e)
{
base.OnActivated(e);
if (Environment.GetCommandLineArgs().Length == 1)
{
System.GC.Collect(2, GCCollectionMode.Forced);
System.GC.WaitForPendingFinalizers();
}
else if (this.WindowState == FormWindowState.Normal)
{
DateTime mainEntryTime = DateTime.UtcNow;
string launchtime = Environment.GetCommandLineArgs()[1];
DateTime launchTime = System.DateTime.FromFileTimeUtc(long.Parse(launchtime));
long diff = (mainEntryTime.Ticks - launchTime.Ticks) / TicksPerMiliSecond;
// string txt = label1.Text ;
//
// txt += " Activated";
// label1.Text = txt;
_result = (int)diff;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Decebal Mihailescu is a software engineer with interest in .Net, C# and C++.