using System.Collections;
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Diagnostics;
using System.Reflection;
using System.IO;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Neo.ApplicationFramework.Common;
using Neo.ApplicationFramework.Common.Runtime;
using Neo.ApplicationFramework.Common.Service;
using Neo.ApplicationFramework.Common.TypeConverters;
using Neo.ApplicationFramework.Common.Utilities;
using Neo.ApplicationFramework.Tools.ToolManager;
using Neo.ApplicationFramework.Interfaces;
using Neo.ApplicationFramework.Attributes;
using System.Threading;

[assembly: AssemblyVersion("1.20.545.0")]
[assembly: NeoDesignerVersion("1.20.545.0")]

namespace Neo.ApplicationFramework.Generated
{
    public class Globals : GlobalsBase
    {
        private static readonly log4net.ILog m_Log = log4net.LogManager.GetLogger(typeof(Globals));
        private static string[] m_Arguments;

        static Globals()
        {
            
        }

        public Globals()
        {
            m_ProjectSettings.MainScreenTitle = "AKI_04T_Simple_Config";
            m_ProjectSettings.Topmost = true;
            m_ProjectSettings.StartupLocation = new Point(0, 0);
            m_ProjectSettings.MaximizeOnStartup = false;
            m_ProjectSettings.MainScreenSize = new Size(320,240);
            m_ProjectSettings.BorderStyle = ScreenBorderStyle.ThreeDBorder;
            m_ProjectSettings.InputDelay = 1000;
            m_ProjectSettings.IsOnScreenKeyboardEnabled = true;
            m_ProjectSettings.KeyboardLayout = "US";
            m_SystemSettings.AutomaticallyTurnOfBacklight = false;
            m_SystemSettings.BacklightTimeout = 900;    
            m_SystemSettings.KeepBacklightOnIfNotifierWindowIsVisible = false;                                      
            m_SystemSettings.Com1RS485 = false;
            m_SystemSettings.KeyBeep = true;
            m_SystemSettings.TimeZoneDisplayName = "(GMT-06:00) Central Time (US & Canada)";
            m_SystemSettings.RegionLCID = 1033;
            m_SystemSettings.AdjustForDaylightSaving = true;
            m_SystemSettings.FtpServerEnabled = false;
            m_SystemSettings.FtpServerAllowAnonymous = false;
            m_SystemSettings.FtpServerDefaultDir = @"";
            m_SystemSettings.NTLMUser = @"";
            m_SystemSettings.NTLMPassword = @"";
            m_SystemSettings.SystemFont = new System.Drawing.Font("Tahoma", 10, System.Drawing.FontStyle.Regular);
            m_SystemSettings.VncServerEnabled = false;
            m_SystemSettings.VncTcpPort = 5900;
            m_SystemSettings.VncHttpTcpPort = 5800;
            m_SystemSettings.VncViewOnlyPassword = @"";
            m_SystemSettings.VncFullAccessPassword = @"";
            m_SystemSettings.SIPInputMethodClsid = new Guid("42429667-ae04-11d0-a4f8-00aa00a749b9");
            m_SystemSettings.IsKeyPanel = false;
            m_SystemSettings.AlarmButtonShowScreenTarget = @"";
            m_SystemSettings.ProjectGuid = new Guid("f090f802-3457-44c4-839e-94adce08ad30");

            SetSerialPortMode();
            SetKeyBeep();
            SetSystemInputPanelLayout();
            ConfigureFtpServer();
            StartVncServerCe();
        }

        /// <summary>
        /// Neo generated code - do not modify
        /// the contents of this method(s) with the code editor.
        /// </summary>        
                    public static IScreenAdapter Units
                    {
                        get
                        {
                            return GetObject<Units>().Adapter;
                        }
                    }           
                    public static IScreenAdapter Status
                    {
                        get
                        {
                            return GetObject<Status>().Adapter;
                        }
                    }           
                    public static IScreenAdapter analog
                    {
                        get
                        {
                            return GetObject<analog>().Adapter;
                        }
                    }           
                    public static IScreenAdapter Opmode
                    {
                        get
                        {
                            return GetObject<Opmode>().Adapter;
                        }
                    }           
                    public static IScreenAdapter Screensaver
                    {
                        get
                        {
                            return GetObject<Screensaver>().Adapter;
                        }
                    }           
                    public static IScreenAdapter Menu
                    {
                        get
                        {
                            return GetObject<Menu>().Adapter;
                        }
                    }           
                    public static IScreenAdapter Homing
                    {
                        get
                        {
                            return GetObject<Homing>().Adapter;
                        }
                    }           
                    public static IScreenAdapter MT
                    {
                        get
                        {
                            return GetObject<MT>().Adapter;
                        }
                    }           
                    public static IScreenAdapter Background1
                    {
                        get
                        {
                            return GetObject<Background1>().Adapter;
                        }
                    }           
                    public static Security Security
                    {
                        get
                        {
                            return GetObject<Security>();
                        }
                    }           
                    public static Tags Tags
                    {
                        get
                        {
                            return GetObject<Tags>();
                        }
                    }           
                    public static MultipleLanguages MultipleLanguages
                    {
                        get
                        {
                            return GetObject<MultipleLanguages>();
                        }
                    }           
                    public static Expressions Expressions
                    {
                        get
                        {
                            return GetObject<Expressions>();
                        }
                    }           
                    public static AlarmServer AlarmServer
                    {
                        get
                        {
                            return GetObject<AlarmServer>();
                        }
                    }   
        [MTAThread]
        static void Main(string[] args)
        {   
			if (!CheckIfApplicationCanRun())
				return;
            UserStartupMessage.SendUserStartupMessageToBeijerShell("Loading Files");
            if (!StopWatchCF.Silent)
                StopWatchCF.Send("Starting Project");
            StopWatchCF.SetTimeStamp("***** Project Startup Time *****");
            while (ProcessExplorer.WaitForAttachDebugger)
            {
                Thread.Sleep(1000);
            }
            IsCompiledForCE = true;   

            Instance = new Globals();

            PrestartOnScreenKeyboard();     

            try
            {
                m_Arguments = args;

                INativeAPI nativeAPI = ObjectCreatorHelper.Create<INativeAPI>(TypeNames.NativeAPI, TypeNames.NativeAPICF);
                CreateMutex(nativeAPI);

                if (Marshal.GetLastWin32Error() != (int)CREATEMUTEX.ERROR_ALREADY_EXISTS)
                {
                    nativeAPI.CeSetThreadQuantum(new IntPtr(65), 25);
                    InterpreterArguments(args);
                    ExecutablePath = typeof(Globals).Module.FullyQualifiedName;
                    RegisterDrivers();
                    
                    NeoApplication.Initialize();

                    m_ToolManager.OnToolAdded += OnToolAdded;
                    m_ToolManager.Start();

                    Instanciate(new string[] {"Security","Tags","MultipleLanguages","AlarmServer","Expressions","Database","ProjectImages"});
                    InitAndRun();
                    NeoApplication.Run(Menu.AdaptedObject);
                    CloseRunningOnScreenKeyboard();
                    CloseRunningVncserverCe();
                }
            }
            catch(Exception ex)
            {
                GenerateCrashReport(ex);
                ManageUnhandledException(ex, true);
                m_ShowUnhandledException = false;

                throw; //Preserves stacktrace and triggers Dr Watson to create dump file.
            }
        }

        private static void OnToolAdded(object sender, EventArgs e)
        {
            if (sender is ICommandLineService)
            {
                ServiceContainerCF.GetService<ICommandLineService>().Arguments = m_Arguments;
            }
        }
    }
}