Exemple #1
0
        public App()
        {
            ReRunCheck();

            //必须按优先级依次添加
            serviceCollection = new ServiceCollection();
            serviceCollection.AddInstance(this);
            //数据统计
            serviceCollection.Add <StatisticService>();
            //系统资源
            serviceCollection.Add <SystemResourcesService>();
            //内存缓存
            serviceCollection.Add <CacheService>();
            //配置文件
            serviceCollection.Add <ConfigService>();
            //主题
            serviceCollection.Add <ThemeService>();
            //扩展显示器
            serviceCollection.Add <ScreenService>();
            //主要
            serviceCollection.Add <MainService>();
            //托盘
            serviceCollection.Add <TrayService>();
            //休息
            serviceCollection.Add <ResetService>();
            //声音
            serviceCollection.Add <SoundService>();



            WindowManager.serviceCollection = serviceCollection;


            Startup += new StartupEventHandler(onStartup);
        }
Exemple #2
0
        //private Mutex mutex;

        //[DllImport("user32.dll")]
        //[return: MarshalAs(UnmanagedType.Bool)]
        //static extern bool SetForegroundWindow(IntPtr hWnd);

        public App()
        {
            using (Process p = Process.GetCurrentProcess())
                p.PriorityClass = ProcessPriorityClass.High;
            Startup += new StartupEventHandler(App_Startup); // Can be called from XAML

            //// Try to grab mutex
            //bool createdNew;
            //mutex = new Mutex(true, "MetromTablet", out createdNew);

            //if (!createdNew)
            //{
            //	// Bring other instance to front and exit.
            //	Process current = Process.GetCurrentProcess();
            //	foreach (Process process in Process.GetProcessesByName(current.ProcessName))
            //	{
            //		if (process.Id != current.Id)
            //		{
            //			SetForegroundWindow(process.MainWindowHandle);
            //			break;
            //		}
            //	}
            //	Application.Current.Shutdown();
            //}
            //else
            //{
            //	// Add Event handler to exit event.
            //	Exit += CloseMutexHandler;
            //}
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="App"/> class.
 /// </summary>
 /// <exception cref="T:System.InvalidOperationException">More than one instance of the <see cref="T:System.Windows.Application"/> class is created per <see cref="T:System.AppDomain"/>.</exception>
 public App()
 {
     AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
     DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
     Startup += new StartupEventHandler(App_Startup);
     InitializeComponent();
 }
Exemple #4
0
        private static void InitializeUiDispatcher(CultureInfo uiCulture)
        {
            using (var uiThreadStartedSignal = new ManualResetEvent(false))
            {
                var thread = new Thread(() =>
                {
                    var app = new Application {
                        ShutdownMode = ShutdownMode.OnExplicitShutdown
                    };
                    StartupEventHandler startupHandler = null;
                    startupHandler = (s, e) =>
                    {
                        // ReSharper disable once AccessToDisposedClosure (calling thread wouldn't exit from 'using' until we call 'Set')
                        uiThreadStartedSignal.Set();
                        app.Startup -= startupHandler;
                    };
                    app.Startup += startupHandler;
                    app.Run();
                });
                thread.CurrentUICulture = uiCulture;
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();

                uiThreadStartedSignal.WaitOne();
            }
        }
 public static void Raise(this StartupEventHandler handler, object sender, StartupEventArgs e)
 {
     if (handler != null)
     {
         handler(sender, e);
     }
 }
        // Ensure SetLicenseKey is called once, before any SciChartSurface instance is created
        // Check this code into your version-control and it will enable SciChart
        // for end-users of your application.
        //
        // You can test the Runtime Key is installed correctly by Running your application
        // OUTSIDE Of Visual Studio (no debugger attached). Trial watermarks should be removed.


        public App()
        {
            SciChartSurface.SetRuntimeLicenseKey(@"<LicenseContract>
  <Customer>Redler technologies</Customer>
  <OrderId>ABT141014-5754-30127</OrderId>
  <LicenseCount>1</LicenseCount>
  <IsTrialLicense>false</IsTrialLicense>
  <SupportExpires>01/12/2015 00:00:00</SupportExpires>
  <ProductCode>SC-WPF-BSC</ProductCode>
  <KeyCode>lwAAAQEAAADYej6WZT7WAYsAQ3VzdG9tZXI9UmVkbGVyIHRlY2hub2xvZ2llcztPcmRlcklkPUFCVDE0MTAxNC01NzU0LTMwMTI3O1N1YnNjcmlwdGlvblZhbGlkVG89MTItSmFuLTIwMTU7UHJvZHVjdENvZGU9U0MtV1BGLUJTQztOdW1iZXJEZXZlbG9wZXJzT3ZlcnJpZGU9MYHBQsFtvhmNUsAF1tPpbfJI0MXhteDAzO1I1uzwGcNIr/3e8pkIaMWJiXsaX6Q0Ew==</KeyCode>
</LicenseContract>");

#if LOAD_FROM_DB
            Operations Op = Operations.GetInstance;
            Operations.GetInstance.readDataBase();
#endif
            LeftPanelViewModel.GetInstance.LogText = "";
            EventRiser.Instance.LoggerEvent       += LeftPanelViewModel.GetInstance.Instance_LoggerEvent;

            //EventRiser.Instance.RiseEevent(string.Format($"App Started"));

            Startup += new StartupEventHandler(App_Startup);                                        // Can be called from XAML

            DispatcherUnhandledException += App_DispatcherUnhandledException;                       //Example 2

            TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;         //Example 4

            System.Windows.Forms.Application.ThreadException += WinFormApplication_ThreadException; //Example 5
        }
Exemple #7
0
 public App()
 {
     Startup += new StartupEventHandler(App_Startup);
     AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
     {
     };
 }
Exemple #8
0
 public App()
 {
     Startup += new StartupEventHandler(App_Startup);
     AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
     {
     };
 }
Exemple #9
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            Startup += new StartupEventHandler(App_Startup);

            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard Silverlight initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Disable the application idle detection by setting the UserIdleDetectionMode property of the
                // application's PhoneApplicationService object to Disabled.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
        }
Exemple #10
0
        public static void RunApplicationOnStart(StartupEventHandler onStart)
        {
            var application = new App();

            application.InitializeComponent();
            application.Startup += onStart;
            application.Run();
        }
Exemple #11
0
        public App()
        {
            Startup += new StartupEventHandler(App_Startup);                                // Can be called from XAML

            DispatcherUnhandledException += App_DispatcherUnhandledException;               //Example 2

            TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; //Example 4
        }
 public static void Run(Form f, StartupEventHandler startupHandler, StartupNextInstanceEventHandler StartupNextInstanceHandler)
 {
     SingleInstanceApplication app = new SingleInstanceApplication();
     app.MainForm = f;
     app.Startup += startupHandler;
     app.StartupNextInstance += StartupNextInstanceHandler;
     app.Run(Environment.GetCommandLineArgs());
 }
Exemple #13
0
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// startupeventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this StartupEventHandler startupeventhandler, Object sender, StartupEventArgs e, AsyncCallback callback)
        {
            if (startupeventhandler == null)
            {
                throw new ArgumentNullException("startupeventhandler");
            }

            return(startupeventhandler.BeginInvoke(sender, e, callback, null));
        }
Exemple #14
0
        public App()
        {
            Startup += new StartupEventHandler(App_Startup);                                        // Can be called from XAML

            DispatcherUnhandledException += App_DispatcherUnhandledException;                       //Example 2

            TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;         //Example 4

            System.Windows.Forms.Application.ThreadException += WinFormApplication_ThreadException; //Example 5
        }
Exemple #15
0
        /// <summary>
        /// Called by Silverlight host when it instantiates our application
        /// </summary>
        public DynamicApplication()
        {
            if (_Current != null) {
                throw new Exception("Only one instance of DynamicApplication can be created");
            }

            _Current = this;
            _UIThreadId = Thread.CurrentThread.ManagedThreadId;

            Startup += new StartupEventHandler(DynamicApplication_Startup);
        }
Exemple #16
0
        /// <summary>
        /// Called by Silverlight host when it instantiates our application
        /// </summary>
        public DynamicApplication()
        {
            if (_Current != null) {
                throw new Exception("Only one instance of DynamicApplication can be created");
            }

            _Current = this;
            _UIThreadId = Thread.CurrentThread.ManagedThreadId;
            _HtmlPageUri = HtmlPageUri;

            Settings.ReportUnhandledErrors = true;

            AppManifest = new DynamicAppManifest();
            LanguagesConfig = DynamicLanguageConfig.Create(AppManifest.Assemblies);

            Startup += new StartupEventHandler(DynamicApplication_Startup);
        }
        /// <summary>
        /// Called by Silverlight host when it instantiates our application
        /// </summary>
        public DynamicApplication()
        {
            if (_Current != null)
            {
                throw new Exception("Only one instance of DynamicApplication can be created");
            }

            _Current     = this;
            _UIThreadId  = Thread.CurrentThread.ManagedThreadId;
            _HtmlPageUri = HtmlPageUri;

            Settings.ReportUnhandledErrors = true;

            AppManifest     = new DynamicAppManifest();
            LanguagesConfig = DynamicLanguageConfig.Create(AppManifest.Assemblies);

            Startup += new StartupEventHandler(DynamicApplication_Startup);
        }
        App()
        {
            taskArray[0] = Task.Run( 
                () =>
                {
                    m_Runtime = new Composer.Bridge.ComposerRuntime();
                });

            taskArray[1] = Task.Run(() =>
            {
                m_Definitiion = ComposerJobDefinitionFactory.CreateFromFile("composer_gui.json");

                //m_definition = ComposerJobDefinitionFactory.CreateFromFile("composer_gui.json");
                //var d = new ComposerJobDefinition(@"c:\", @"d:\", @"e:\");
                //ComposerJobDefinitionFactory.WriteToFile("composer_gui.json", d);
            }

            );

            Startup += new StartupEventHandler(this.ApplicationStartupHandler);
            Exit += new ExitEventHandler(this.ApplicationExitHandler);
        }
Exemple #19
0
        public App()
        {
            AccentColor = ((Color)Application.Current.Resources["PhoneAccentColor"]).ToString().Replace("#", "");

            UnhandledException += new EventHandler<ApplicationUnhandledExceptionEventArgs>(Application_UnhandledException);
            Startup += new StartupEventHandler(App_Startup);

            InitializeComponent();

            RootFrame = new PhoneApplicationFrame();
            var ct = (ControlTemplate)this.Resources["TransitioningFrame"];
            RootFrame.Template = ct;
            RootFrame.Navigated += new System.Windows.Navigation.NavigatedEventHandler(RootFrame_Navigated);
            // debugging

            foreach (PropertyInfo property in typeof(ResourceStrings).GetProperties(BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static))
            {
                if (property.PropertyType == typeof(string))
                {
                    Application.Current.Resources.Add(property.Name, property.GetValue(null, null));
                }
            }
        }
Exemple #20
0
        public App()
        {
            AccentColor = ((Color)Application.Current.Resources["PhoneAccentColor"]).ToString().Replace("#", "");

            UnhandledException += new EventHandler <ApplicationUnhandledExceptionEventArgs>(Application_UnhandledException);
            Startup            += new StartupEventHandler(App_Startup);

            InitializeComponent();

            RootFrame = new PhoneApplicationFrame();
            var ct = (ControlTemplate)this.Resources["TransitioningFrame"];

            RootFrame.Template   = ct;
            RootFrame.Navigated += new System.Windows.Navigation.NavigatedEventHandler(RootFrame_Navigated);
            // debugging

            foreach (PropertyInfo property in typeof(ResourceStrings).GetProperties(BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static))
            {
                if (property.PropertyType == typeof(string))
                {
                    Application.Current.Resources.Add(property.Name, property.GetValue(null, null));
                }
            }
        }
Exemple #21
0
 public App() : base()
 {
     startupEventHandler += startEvent;
 }
Exemple #22
0
 public App()
 {
     Startup += new StartupEventHandler(App_Startup);
 }
Exemple #23
0
 public App()
 {
     Startup += new StartupEventHandler(App_Startup);
     DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
 }
Exemple #24
0
 public App()
 {
     DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
     Startup += new StartupEventHandler(App_Startup);
     TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
 }
Exemple #25
0
 public App()
 {
     Startup += new StartupEventHandler(run_App);
 }
Exemple #26
0
 public App()
 {
     Startup += new StartupEventHandler(App_Startup);
     InitializeComponent();
 }
 public App() {
     Startup += new StartupEventHandler(App_Startup);
     InitializeComponent();
 }
Exemple #28
0
 public App()
 {
     DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
     TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
     Startup += new StartupEventHandler(App_Startup);
 }
Exemple #29
0
 public App()
 {
     //首先注册开始和退出事件
     Startup += new StartupEventHandler(App_Startup);
     Exit    += new ExitEventHandler(App_Exit);
 }
Exemple #30
0
 public SingleInstanceController()
 {
     IsSingleInstance     = true;
     Startup             += new StartupEventHandler(SingleInstanceController_Startup);
     StartupNextInstance += this_StartupNextInstance;
 }
Exemple #31
0
 public App()
 {
     Startup += new StartupEventHandler(App_Startup);
     Exit    += new ExitEventHandler(App_Exit);
 }
Exemple #32
0
 public App_Run()
 {
     Debug.WriteLine("App constructor");
     Startup += new StartupEventHandler(App_Startup);
 }
Exemple #33
0
 public App()
 {
     Startup += new StartupEventHandler(App_Startup);
     _mLog    = (Log) new LogFactory().GetLog("App", false);
 }
Exemple #34
0
 public App()
 {
     DispatcherUnhandledException          += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
     TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
     Startup += new StartupEventHandler(App_Startup);
 }
Exemple #35
0
 public Application()
 {
     Startup += new StartupEventHandler(App_Startup);
 }
Exemple #36
0
 /// <summary>
 /// Alkalmazás példányosítása.
 /// </summary>
 public App()
 {
     Startup += new StartupEventHandler(App_Startup);
 }
Exemple #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="App"/> class.
 /// </summary>
 /// <exception cref="T:System.InvalidOperationException">More than one instance of the <see cref="T:System.Windows.Application"/> class is created per <see cref="T:System.AppDomain"/>.</exception>
 public App()
 {
     DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Application_DispatcherUnhandledException);
     Startup += new StartupEventHandler(Application_Startup);
     InitializeComponent();
 }