示例#1
0
        public static void Main(string[] args)
        {
            TApplication App = new TApplication(800, 600, false, true, true);

            App.AddContent(new TestFrame(), new TestFrame2());
            App.Run();
        }
示例#2
0
        /// <summary>
        /// Implements a *very* simple Main() function for a WPF app with some error handling. This is a replacement
        /// for setting the Startup Object to the application instance in Visual Studio. It instantly kills the application
        /// on unhandled exceptions and is generally kind of crap, so it should be replaced for any mildly interesting
        /// program.
        /// </summary>
        public static int run <TApplication>() where TApplication : Application, new()
        {
            try
            {
                Application app;
                try
                {
                    LogManager.attach(new ConsoleLogListener(LogLevel.DEBUG));
                    app = new TApplication();
                    if (app.StartupUri == null)
                    {
                        throw new InvalidOperationException("StartupUri not set");
                    }
                    app.DispatcherUnhandledException += (_, args) => onError(args.Exception, "Dispatcher unhandled exception");
                }
                catch (Exception e)
                {
                    app = null;
                    onError(e, "Error starting up");
                }

                app.Run();
                return(0);
            }
            finally
            {
                LogManager.dispose();
            }
        }
示例#3
0
        public static void Main(string[] args)
        {
            var App = new TApplication(1890, 1020, false, true, true);

            App.IsFixedTimeStep = false;
            App.graphics.SynchronizeWithVerticalRetrace = false;

            App.AddContent(new World());
            App.Run();
        }
 public SMNatives(NativeData nativeData)
 {
     Globals     = new TGlobals(nativeData);
     Application = new TApplication(nativeData);
     Control     = new TControl(nativeData);
     ElWind      = new TElWind(nativeData);
     SMMain      = new TSMMain(nativeData);
     Database    = new TDatabase(nativeData);
     Registry    = new TRegistry(Database, nativeData);
 }
示例#5
0
 static Unit()
 {
     TApplication.AddFinalization(Finalization);
     try
     {
         WikiHelpViewer   = new TWikiHelpViewer();
         WikiHelpSelector = new TWikiHelpSelector();
         WikiHelpTester   = new TWikiHelpTester();
         HelpIntfs.RegisterViewer(WikiHelpViewer, out WikiHelpViewer.FHelpManager);
         //{Changing to HTML}
         WinHelpViewer.WinHelpTester = WikiHelpTester;
         TApplication.Instance.HelpSystem.AssignHelpSelector(WikiHelpSelector);
     }
     catch
     {
     }
     TestHelp();
 }
示例#6
0
        public void CreateComponents()
        {
            Application = new TApplication(null);
            Application.Initialize();
            Application.Run();

            var el    = Browser.GetElementById("helloWorld");
            var lForm = new TForm(null);

            lForm.Width = 800;
            // el it's a div element in html file, we are using as container for our form
            lForm.Show(el);

            var lFontsPanel = new TPanel(lForm);

            lFontsPanel.Height = 150;
            lFontsPanel.Width  = 800;
            lFontsPanel.Parent = lForm;

            var lFontsCombo = new TComboBox(lForm);

            lFontsCombo.Left  = 30;
            lFontsCombo.Top   = 50;
            lFontsCombo.Width = 130;
            // Add combo inside TPanel
            lFontsCombo.Parent = lFontsPanel;

            lFontsCombo.Items.Add("Arial");
            lFontsCombo.Items.Add("Verdana");
            lFontsCombo.Items.Add("Helvetica");
            lFontsCombo.Items.Add("Times");

            var lFontSize = new TComboBox(lForm);

            lFontSize.Left   = 200;
            lFontSize.Top    = 50;
            lFontSize.Width  = 80;
            lFontSize.Parent = lFontsPanel;
            for (var i = 8; i <= 72; i += 4)
            {
                lFontSize.Items.Add(i.ToString());
            }

            var lLabel = new TLabel(lForm);

            lLabel.Left    = 320;
            lLabel.Top     = 50;
            lLabel.Caption = "Choose font name and size!";
            lLabel.Parent  = lFontsPanel;

            // Assign combo events
            lFontsCombo.OnSelect = (a) => { lLabel.Font.Name = lFontsCombo.Text; };
            lFontSize.OnSelect   = (a) => { lLabel.Font.Size = StrToInt(lFontSize.Text); };

            var lSecondPanel = new TPanel(lForm);

            lSecondPanel.Top    = 220;
            lSecondPanel.Height = 150;
            lSecondPanel.Width  = 800;
            lSecondPanel.Parent = lForm;

            var lCheckBox = new TCheckBox(lForm);

            lCheckBox.Top     = 20;
            lCheckBox.Left    = 30;
            lCheckBox.Caption = "CheckBox control";
            lCheckBox.Parent  = lSecondPanel;

            var lRadioButton = new TRadioButton(lForm);

            lRadioButton.Top     = 80;
            lRadioButton.Left    = 30;
            lRadioButton.Caption = "RadioButton control";
            lRadioButton.Parent  = lSecondPanel;

            var lChangeButton = new TButton(lForm);

            lChangeButton.Left    = 220;
            lChangeButton.Top     = 20;
            lChangeButton.Caption = "Change progress bar mode";
            lChangeButton.Parent  = lSecondPanel;
            lChangeButton.OnClick = @ChangeButtonClick;

            var lIncButton = new TButton(lForm);

            lIncButton.Left    = 220;
            lIncButton.Top     = 80;
            lIncButton.Caption = "Increase progress bar value";
            lIncButton.Parent  = lSecondPanel;
            lIncButton.OnClick = (a) => { fProgress.Position = fProgress.Position + 5; if (fProgress.Position >= fProgress.Max)
                                          {
                                              fProgress.Position = 0;
                                          }
            };

            fProgress        = new TProgressBar(lForm);
            fProgress.Top    = 55;
            fProgress.Left   = 420;
            fProgress.Max    = 100;
            fProgress.Parent = lSecondPanel;
        }
示例#7
0
 static void Main()
 {
     TApplication.Run <MagnetoApplication, MainForm>();
 }
示例#8
0
        public void HelloWorld()
        {
            Application = new TApplication(null);
            Application.Initialize();
            Application.Run();

            // Create form
            var lForm = new TForm(null);

            lForm.Width = 800;
            // we can display the form in an existing div element. If Show parameter is nil, a new div is created
            lForm.Show(null);

            var lTopLabel = new TLabel(lForm);

            lTopLabel.Left    = 1;
            lTopLabel.Parent  = lForm;
            lTopLabel.Caption = "Write the item caption on the edit and press Add New button to add to ListBox:";

            var lButton = new TButton(lForm);

            lButton.Left    = 50;
            lButton.Top     = 50;
            lButton.Caption = "Add New";
            lButton.Parent  = lForm;

            var lEdit = new TEdit(lForm);

            lEdit.Left   = 150;
            lEdit.Top    = 50;
            lEdit.Parent = lForm;

            var lListBox = new TListBox(lForm);

            lListBox.Left        = 350;
            lListBox.Top         = 50;
            lListBox.Parent      = lForm;
            lListBox.Width       = 250;
            lListBox.MultiSelect = true;

            lButton.OnClick = (s) => { lListBox.Items.Add(lEdit.Text); };

            var lChangeLabel = new TLabel(lForm);

            lChangeLabel.Top     = 165;
            lChangeLabel.Parent  = lForm;
            lChangeLabel.Caption = "Press button to change label font:";

            var lChangeButton = new TButton(lForm);

            lChangeButton.Left    = 50;
            lChangeButton.Top     = 200;
            lChangeButton.Caption = "Change font";
            lChangeButton.Parent  = lForm;

            var lLabel = new TLabel(lForm);

            lLabel.Left    = 150;
            lLabel.Top     = 200;
            lLabel.Caption = "Sample text!";
            lLabel.Parent  = lForm;

            lChangeButton.OnClick = (s) => { lLabel.Font.Name = "Verdana"; lLabel.Font.Size = 24; };

            var lMemo = new TMemo(lForm);

            lMemo.Left   = 50;
            lMemo.Top    = 300;
            lMemo.Width  = 250;
            lMemo.Height = 150;
            lMemo.Parent = lForm;

            var lMemoButton = new TButton(lForm);

            lMemoButton.Left    = 350;
            lMemoButton.Top     = 325;
            lMemoButton.Caption = "Add text";
            lMemoButton.Parent  = lForm;
            var lList = TStringList.Create();

            lList.Add("one line");
            lList.Add("another one");
            lMemoButton.OnClick = (s) => { lMemo.Lines.AddStrings(lList); };

            var lDisplayButton = new TButton(lForm);

            lDisplayButton.Top     = lMemoButton.Top;
            lDisplayButton.Left    = 450;
            lDisplayButton.Caption = "Show memo text";
            lDisplayButton.Parent  = lForm;
            lDisplayButton.OnClick = (s) => { ShowMessage(lMemo.Lines.Text); };
        }