Beispiel #1
0
        private void MainFormLoad(object sender, EventArgs e)
        {
            AutoMeasurement.DebugWriter = d => Debug.WriteLine(d);
            AutoMeasurement.Start(new MeasurementConfiguration("UA-319000-8"));

            AllowUsageDataCollectionCheckBox.Checked = AutoMeasurement.VisitorStatus == VisitorStatus.Active;
        }
Beispiel #2
0
        //Service start
        public static void Start(DynamoModel dynamoModel)
        {
            InstrumentationLogger.dynamoModel = dynamoModel;

            if (IsAnalyticsEnabled)
            {
                string appVersion = dynamoModel.AppVersion;

                var mc = new MeasurementConfiguration(ANALYTICS_PROPERTY,
                                                      "Dynamo", appVersion);
                mc.AnonymizeIp = true;

                sessionID  = Guid.NewGuid().ToString();
                loggerImpl = new Log("Dynamo", userID, sessionID);

                AutoMeasurement.Start(mc);
                client = AutoMeasurement.Client;

                if (IS_VERBOSE_DIAGNOSTICS)
                {
                    AutoMeasurement.DebugWriter = d => Debug.WriteLine(d);
                }

                started = true;
            }


            // The following starts the heartbeat, do not remove this
            // because of the unreferenced "heartbeat" variable.

// ReSharper disable UnusedVariable
            var heartbeat = Heartbeat.GetInstance(dynamoModel);
// ReSharper restore UnusedVariable
        }
        public MainWindow()
        {
            if (Properties.Settings.Default.GAEnabled)
            {
                try
                {
                    AutoMeasurement.Instance    = new WinFormAutoMeasurement();
                    AutoMeasurement.DebugWriter = d => Debug.WriteLine(d);
                    AutoMeasurement.Start(new MeasurementConfiguration("UA-75983216-4", Assembly.GetExecutingAssembly().GetName().Name, currentVersion.ToString()));
                }
                catch
                {
                    this.timedActivity = null;
                    Properties.Settings.Default.GAEnabled = false;
                    Properties.Settings.Default.Save();
                }
            }

            //TODO:注意关闭时登出

            /*            this.FormClosing += new FormClosingEventHandler((sender, e) => {
             *              if (this.bfClient != null) this.bfClient.Logout();
             *          });*/

            timedActivity = new CSharpAnalytics.Activities.AutoTimedEventActivity("FormLoad", Properties.Settings.Default.loginMethod.ToString());
            InitializeComponent();
            init();

            if (Properties.Settings.Default.GAEnabled && this.timedActivity != null)
            {
                AutoMeasurement.Client.Track(this.timedActivity);
                this.timedActivity = null;
            }
        }
Beispiel #4
0
        public main()
        {
            currentVersion = currentVersion.Remove(currentVersion.Length - 2);

            if (Properties.Settings.Default.GAEnabled)
            {
                try
                {
                    AutoMeasurement.Instance    = new WinFormAutoMeasurement();
                    AutoMeasurement.DebugWriter = d => Debug.WriteLine(d);
                    AutoMeasurement.Start(new MeasurementConfiguration("UA-75983216-4", Assembly.GetExecutingAssembly().GetName().Name, currentVersion));
                }
                catch
                {
                    this.timedActivity = null;
                    Properties.Settings.Default.GAEnabled = false;
                    Properties.Settings.Default.Save();
                }
            }

            timedActivity = new CSharpAnalytics.Activities.AutoTimedEventActivity("FormLoad", Properties.Settings.Default.loginMethod.ToString());
            InitializeComponent();
            init();
            CheckForUpdate();

            if (Properties.Settings.Default.GAEnabled && this.timedActivity != null)
            {
                AutoMeasurement.Client.Track(this.timedActivity);
                this.timedActivity = null;
            }
        }
Beispiel #5
0
        public MainWindow()
        {
            InitializeComponent();

            AutoMeasurement.Instance    = new WpfAutoMeasurement();
            AutoMeasurement.DebugWriter = d => Debug.WriteLine(d);
            AutoMeasurement.Start(new MeasurementConfiguration("UA-319000-8"));

            AllowUsageDataCollectionCheckBox.IsChecked = AutoMeasurement.VisitorStatus == VisitorStatus.Active;
        }
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            // CSharpAnalytics initialization
            AutoMeasurement.DebugWriter = d => Debug.WriteLine(d);
            AutoMeasurement.Start(new MeasurementConfiguration("UA-319000-8"), args);

            var rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active

            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                // Associate the frame with a SuspensionManager key
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        // Something went wrong restoring state.
                        // Assume there is no state and continue
                    }
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }
            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(GroupedItemsPage), "AllGroups"))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            // CSharpAnalytics init complete
            AutoMeasurement.Attach(rootFrame);

            // Ensure the current window is active
            Window.Current.Activate();
        }
Beispiel #7
0
        private static void InitGoogleAnalytics()
        {
#if SQUIRREL
            string versionExtension = "-squirrel";
#elif !DEBUG
            string versionExtension = "-store";
#endif

#if !DEBUG
            AutoMeasurement.Instance = new WpfAutoMeasurement();
            AutoMeasurement.Start(new MeasurementConfiguration(Common.Secrets.GoogleAnalyticsId, "PCExtension", Assembly.GetExecutingAssembly().GetName().Version.ToString() + versionExtension));

            AutoMeasurement.Client.TrackScreenView("MainWindow");
#endif
        }
Beispiel #8
0
        public AutoStart()
        {
            InitializeComponent();


            //Analytics
            AutoMeasurement.Instance = new WinFormAutoMeasurement();
            AutoMeasurement.Start(new MeasurementConfiguration("UA-117174081-1"));

            AutoMeasurement.Client.TrackScreenView("Main screen");

            programsFile = filesManager.programsFile;

            //Initialize datagridview
            dataGridView1.Columns.Add("id", "ID");
            dataGridView1.Columns.Add("path", "File path");
            dataGridView1.Columns.Add("name", "File name");

            //We don't want the id column to be visible, but for debugging purposes it might come in handy,
            //So we hide it
            dataGridView1.Columns["id"].Visible = false;

            //Make sure all files exist
            filesManager.CheckFiles();

            //Load programs file
            XmlDocument doc = new XmlDocument();

            doc.Load(programsFile);

            //Get data from programs file
            foreach (XmlNode node in doc.SelectNodes("/Programs/Program"))
            {
                id   = node.Attributes["id"].InnerText;
                name = node.SelectSingleNode("name").InnerText;
                path = node.SelectSingleNode("path").InnerText;
                ProgramList.programList.Add(new string[] { id, path, name });
            }

            //Populate datagridview
            foreach (string[] program in ProgramList.programList)
            {
                dataGridView1.Rows.Add(program[0], program[1], program[2]);
            }
        }
Beispiel #9
0
        public main()
        {
            currentVersion = currentVersion.Remove(currentVersion.Length - 2);

            if (Properties.Settings.Default.GAEnabled)
            {
                try
                {
                    AutoMeasurement.Instance    = new WinFormAutoMeasurement();
                    AutoMeasurement.DebugWriter = d => Debug.WriteLine(d);
                    AutoMeasurement.Start(new MeasurementConfiguration("UA-75983216-4", Assembly.GetExecutingAssembly().GetName().Name, currentVersion));
                }
                catch
                {
                    this.timedActivity = null;
                    Properties.Settings.Default.GAEnabled = false;
                    Properties.Settings.Default.Save();
                }
            }

            timedActivity = new CSharpAnalytics.Activities.AutoTimedEventActivity("FormLoad", Properties.Settings.Default.loginMethod.ToString());
            InitializeComponent();
            init();
            CheckForUpdate();

            //string[] lines = System.IO.File.ReadAllLines(@"C:\POP\12.txt");
            //string[] lines = System.IO.File.ReadAllLines(@"\\vmware-host\Shared Folders\POP\2.txt");
            //string[] words = lines[0].Split((char)9);
            //this.accountInput.Text = words[0];
            //this.passwdInput.Text = words[1];
            this.accountInput.Text = "alanting0004";
            this.passwdInput.Text  = "sf7778101";

            /*if (words[0] == "" || words[1] == "")
             * {
             *  this.loginButton.Enabled = true;
             * }
             * else {*/
            this.loginButton.Enabled = false;
            this.loginWorker.RunWorkerAsync(0);
            //}
        }
 // Code to execute when the application is launching (eg, from Start)
 // This code will not execute when the application is reactivated
 private void Application_Launching(object sender, LaunchingEventArgs e)
 {
     AutoMeasurement.DebugWriter = d => Debug.WriteLine(d);
     AutoMeasurement.Start(new MeasurementConfiguration("UA-319000-8"), e);
     AutoMeasurement.Attach(RootFrame);
 }
Beispiel #11
0
        private void MainThread()
        {
            //Setup References
            //Watchdog.WatchdogStartup();
            if (!_debugmode)
            {
                Text = @"Chromatics " + _currentVersionX;
            }
            else
            {
                Text = @"Chromatics " + _currentVersionX + @" (BETA)";
            }

            //Setup Event Listeners
            FormClosing += OnFormClosing;
            Resize      += ChromaticsForm_Resize;
            Application.ApplicationExit += OnApplicationExit;
            exitToolStripMenuItem.Click += exitToolStripMenuItem_Click;
            mi_effectsenable.Click      += enableeffects_Click;
            mi_arxenable.Click          += enablearx_Click;
            mi_showwindow.Click         += showwindow_Click;
            mi_winstart.Click           += mi_winstart_Click;
            mi_updatecheck.Click        += mi_updatecheck_Click;

            _mGlobalHook          = Hook.GlobalEvents();
            _mGlobalHook.KeyDown += Kh_KeyDown;
            _mGlobalHook.KeyUp   += Kh_KeyUp;

            try
            {
                var lgsApp = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Logitech\\Logitech Gaming Software", false);
                if (lgsApp != null)
                {
                    _lgsInstall = lgsApp.GetValue("InstallDir").ToString();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            //Bind
            if (!_debugmode)
            {
                WriteConsole(ConsoleTypes.System, @"Starting Chromatics Version " + _currentVersionX);
            }
            else
            {
                WriteConsole(ConsoleTypes.System, @"Starting Chromatics Version " + _currentVersionX + " (BETA)");
            }


            //Load Functions
            LoadDevices();
            LoadChromaticsSettings();
            LoadColorMappings();


            //Check Administrator permissions
            if (!IsAdministrator())
            {
                WriteConsole(ConsoleTypes.Error,
                             @"Chromatics is not running as Administrator. Please restart with administrative privileges.");

                if (chk_lccauto.Checked)
                {
                    tooltip_main.SetToolTip(gB_lcc,
                                            @"Logitech Conflict Mode requires Chromatics to be run with Administrative privileges. Please restart with administrative privileges.");
                }

                gB_lcc.Enabled = false;
                btn_ffxivcachereset.Enabled = false;
            }
            else
            {
                var enviroment = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName;

                if (!ChromaticsSettings.ChromaticsSettingsMemoryCache)
                {
                    if (File.Exists(enviroment + @"/signatures-x64.json"))
                    {
                        FileSystem.DeleteFile(enviroment + @"/signatures-x64.json");
                    }

                    if (File.Exists(enviroment + @"/structures-x64.json"))
                    {
                        FileSystem.DeleteFile(enviroment + @"/structures-x64.json");
                    }
                }

                if (ChromaticsSettings.ChromaticsSettingsLanguage != ChromaticsSettings.ChromaticsSettingsPreviousLanguage)
                {
                    if (File.Exists(enviroment + @"/signatures-x64.json"))
                    {
                        FileSystem.DeleteFile(enviroment + @"/signatures-x64.json");
                    }

                    if (File.Exists(enviroment + @"/structures-x64.json"))
                    {
                        FileSystem.DeleteFile(enviroment + @"/structures-x64.json");
                    }

                    if (File.Exists(enviroment + @"/actions.json"))
                    {
                        FileSystem.DeleteFile(enviroment + @"/actions.json");
                    }

                    if (File.Exists(enviroment + @"/statuses.json"))
                    {
                        FileSystem.DeleteFile(enviroment + @"/statuses.json");
                    }

                    if (File.Exists(enviroment + @"/zones.json"))
                    {
                        FileSystem.DeleteFile(enviroment + @"/zones.json");
                    }

                    WriteConsole(ConsoleTypes.Ffxiv, @"Language change detected. Clearing Cache..");
                    ChromaticsSettings.ChromaticsSettingsPreviousLanguage = ChromaticsSettings.ChromaticsSettingsLanguage;
                }

                if (!ChromaticsSettings.FirstRun)
                {
                    if (File.Exists(enviroment + @"/signatures-x64.json"))
                    {
                        FileSystem.DeleteFile(enviroment + @"/signatures-x64.json");
                    }

                    if (File.Exists(enviroment + @"/structures-x64.json"))
                    {
                        FileSystem.DeleteFile(enviroment + @"/structures-x64.json");
                    }

                    if (File.Exists(enviroment + @"/actions.json"))
                    {
                        FileSystem.DeleteFile(enviroment + @"/actions.json");
                    }

                    if (File.Exists(enviroment + @"/statuses.json"))
                    {
                        FileSystem.DeleteFile(enviroment + @"/statuses.json");
                    }

                    if (File.Exists(enviroment + @"/zones.json"))
                    {
                        FileSystem.DeleteFile(enviroment + @"/zones.json");
                    }

                    ChromaticsSettings.FirstRun = true;
                    SaveChromaticsSettings(0);
                }
            }

            //Check Updater
            try
            {
                string enviroment = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName;
                if (!File.Exists(enviroment + @"/updater.exe"))
                {
                    if (File.Exists(enviroment + @"/_updater.exe"))
                    {
                        FileSystem.RenameFile(enviroment + @"/_updater.exe", "updater.exe");
                        WriteConsole(ConsoleTypes.System, @"Updated Chromatics Updater to latest version.");
                    }
                }
                else
                {
                    if (File.Exists(enviroment + @"/_updater.exe"))
                    {
                        File.Delete(enviroment + @"/updater.exe");
                        FileSystem.RenameFile(enviroment + @"/_updater.exe", "updater.exe");
                        WriteConsole(ConsoleTypes.System, @"Updated Chromatics Updater to latest version.");
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            //Setup GUI
            InitDeviceDataGrid();
            InitColorMappingGrid();
            InitSettingsGui();
            SetupTooltips();
            CenterPictureBox(pB_logo1, pB_logo1.Image);
            notify_master.ContextMenuStrip = contextMenuStrip1;

            Localization.SetKeyRegion(ChromaticsSettings.ChromaticsSettingsQwertyMode);

            try
            {
                if (ChromaticsSettings.ChromaticsSettingsDebugOpt)
                {
                    AutoMeasurement.Instance = new WinFormAutoMeasurement();
                    AutoMeasurement.Start(new MeasurementConfiguration("UA-92921709-2", "Chromatics", _currentVersionX));
                }
            }
            catch (Exception ex)
            {
                WriteConsole(ConsoleTypes.Error, @"Unable to hook debug reporting. Ex: " + ex.Message);
            }

            if (ChromaticsSettings.ChromaticsSettingsDesktopNotifications)
            {
                notify_master.BalloonTipText = @"Chromatics will automatically attach to Final Fantasy XIV";
                notify_master.ShowBalloonTip(2000);
            }

            new Task(() => { CheckUpdates(0); }).Start();

            //Setup Device Interfaces
            InitializeSdk();
            InitDevicesGui();

            if (LogitechSdkCalled == 1 && Process.GetProcessesByName("LCore").Length > 0)
            {
                if (gB_lcc.Enabled)
                {
                    //Check Logitech Enviroment
                    try
                    {
                        if (File.Exists(_lgsInstall + @"\SDK\LED\x64\LogitechLed.dll"))
                        {
                            if (chk_lccauto.Checked)
                            {
                                ToggleLccMode(true);

                                chk_lccenable.CheckedChanged -= chk_lccenable_CheckedChanged;
                                chk_lccenable.Checked         = true;
                                chk_lccenable.CheckedChanged += chk_lccenable_CheckedChanged;
                            }
                            else
                            {
                                WriteConsole(ConsoleTypes.Error,
                                             @"Logitech: Chromatics has detected that the LGS internal SDK library is causing a conflict between FFXIV and Chromatics. Please make sure to enable 'Logitech Conflict Mode' under the settings tab and check that 'LED Illumination' is disabled for 'ffxiv_dx11' within LGS.");
                            }
                        }
                        else
                        {
                            WriteConsole(ConsoleTypes.Logitech, @"Logitech Conflict Mode is already enabled.");

                            chk_lccenable.CheckedChanged -= chk_lccenable_CheckedChanged;
                            chk_lccenable.Checked         = true;
                            chk_lccenable.CheckedChanged += chk_lccenable_CheckedChanged;
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);

                        if (chk_lccauto.Checked)
                        {
                            WriteConsole(ConsoleTypes.Error,
                                         @"Logitech Conflict Mode failed to automatically start. Error: " + ex.Message);

                            chk_lccenable.CheckedChanged -= chk_lccenable_CheckedChanged;
                            chk_lccenable.Checked         = false;
                            chk_lccenable.CheckedChanged += chk_lccenable_CheckedChanged;
                        }
                    }
                }
                else
                {
                    if (File.Exists(_lgsInstall + @"\SDK\LED\x64\LogitechLed.dll"))
                    {
                        WriteConsole(ConsoleTypes.Error,
                                     "Logitech: Chromatics has detected that the LGS internal SDK library is causing a conflict between FFXIV and Chromatics. Please make sure to enable 'Logitech Conflict Mode' under the settings tab and check that 'LED Illumination' is disabled for 'ffxiv_dx11' within LGS.");
                    }
                }
            }
            else
            {
                if (Process.GetProcessesByName("lghub").Length == 0)
                {
                    tooltip_main.SetToolTip(gB_lcc,
                                            "Logitech SDK not loaded. Please open LGS Software and restart Chromatics as Administrator.");
                }

                gB_lcc.Enabled = false;
            }


            //Setup LCD Interfaces

            if (ChromaticsSettings.ChromaticsSettingsLcdEnabled)
            {
                _lcd = LogitechLcdInterface.InitializeLcdSdk();

                if (_lcd != null)
                {
                    LcdSdk       = true;
                    LcdSdkCalled = 1;
                    WriteConsole(ConsoleTypes.Logitech, @"LCD SDK Loaded");
                }
            }


            if (chk_arxtoggle.Checked)
            {
                _arx = LogitechArxInterface.InitializeArxSdk();

                if (_arx != null)
                {
                    ArxSdk       = true;
                    ArxState     = 0;
                    ArxSdkCalled = 1;
                    WriteConsole(ConsoleTypes.Arx, @"ARX SDK Loaded");

                    //Load Plugins
                    LoadArxPlugins();
                }
            }


            //Finish GUI Setup
            InitSettingsArxGui();
            Startup = true;

            //Ambience

            /*
             * if (IsAdministrator())
             *  AmbienceInterface.StartAmbience();
             */

            var gameLanguage = "English";

            switch (ChromaticsSettings.ChromaticsSettingsLanguage)
            {
            case 0:
                //English
                gameLanguage = "English";
                break;

            case 1:
                //Chinese
                gameLanguage = "Chinese";
                break;

            case 2:
                //Japanese
                gameLanguage = "Japanese";
                break;

            case 3:
                //French
                gameLanguage = "French";
                break;

            case 4:
                //German
                gameLanguage = "German";
                break;

            case 5:
                //Korean
                gameLanguage = "Korean";
                break;
            }

            WriteConsole(ConsoleTypes.Ffxiv, @"Game Language set to " + gameLanguage + @".");

            //Split off MemoryReader to a Task
            MemoryTask = new Task(() =>
            {
                _call = CallFfxivAttach(_attachcts.Token);
            }, _memoryTask.Token);

            MemoryTasks.Add(MemoryTask);
            MemoryTasks.Run(MemoryTask);
        }
Beispiel #12
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active.
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page.
                rootFrame = new Frame();

                // Associate the frame with a SuspensionManager key.
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                // TODO: Change this value to a cache size that is appropriate for your application.
                rootFrame.CacheSize = 1;

                // Set the default language
                rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate.
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        // Something went wrong restoring state.
                        // Assume there is no state and continue.
                    }
                }

                // Place the frame in the current Window.
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // Removes the turnstile navigation for startup.
                if (rootFrame.ContentTransitions != null)
                {
                    this.transitions = new TransitionCollection();
                    foreach (var c in rootFrame.ContentTransitions)
                    {
                        this.transitions.Add(c);
                    }
                }

                rootFrame.ContentTransitions = null;
                rootFrame.Navigated         += this.RootFrame_FirstNavigated;

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter.
                if (!rootFrame.Navigate(typeof(HubPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }

                AutoMeasurement.DebugWriter = d => Debug.WriteLine(d);
                AutoMeasurement.Start(new MeasurementConfiguration("UA-319000-8"), e);
                AutoMeasurement.Attach(rootFrame);
            }

            // Ensure the current window is active.
            Window.Current.Activate();
        }
Beispiel #13
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            // CSharpAnalytics initialization
            AutoMeasurement.DebugWriter = d => System.Diagnostics.Debug.WriteLine(d);
            AutoMeasurement.Start(new MeasurementConfiguration("UA-319000-8"), e);

#if DEBUG
            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active

            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                //Associate the frame with a SuspensionManager key
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");
                // Set the default language
                rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        //Something went wrong restoring state.
                        //Assume there is no state and continue
                    }
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }
            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(GroupedItemsPage), e.Arguments);
            }

            // CSharpAnalytics init complete
            AutoMeasurement.Attach(rootFrame);

            // Ensure the current window is active
            Window.Current.Activate();
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            string id   = null;
            string name = null;
            string path = null;

            //Analytics
            AutoMeasurement.Instance = new WinFormAutoMeasurement();
            AutoMeasurement.Start(new MeasurementConfiguration("UA-117174081-1"), "", new TimeSpan(1));

            AutoMeasurement.Client.TrackScreenView("Console");

            directoryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "AutoStart");
            programsFile  = Path.Combine(directoryPath, "Programs.xml");
            idFile        = Path.Combine(directoryPath, "ID.txt");

            Console.Title = "AutoStart";//Set console title

            //Write explanation of this console
            Console.ForegroundColor = ConsoleColor.Green;

            for (int i = 0; i < "AutoStart will now start programs".Length; i++)
            {
                Console.Write("AutoStart will now start programs."[i]);
                Thread.Sleep(5);
            }
            Console.WriteLine("");

            Console.ForegroundColor = ConsoleColor.White;

            //Some information
            Console.WriteLine(" ");
            for (int i = 0; i < ("Opening programs database file").Length; i++)
            {
                Console.Write(("Opening programs database file")[i]);
                Thread.Sleep(5);
            }

            Console.WriteLine(" ");
            for (int i = 0; i < ("Now opening programs...").Length; i++)
            {
                Console.Write(("Now opening programs...")[i]);
                Thread.Sleep(5);
            }

            Console.WriteLine("");
            Console.WriteLine("");

            Task <bool> checkUpdate = CheckUpdate();

            XmlDocument doc = new XmlDocument();

            doc.Load(programsFile);

            foreach (XmlNode node in doc.SelectNodes("/Programs/Program"))
            {
                id   = node.Attributes["id"].InnerText;
                name = node.SelectSingleNode("name").InnerText;
                path = node.SelectSingleNode("path").InnerText;

                Console.ForegroundColor = ConsoleColor.Cyan;
                for (int i = 0; i < ("Opening: " + name).Length; i++)
                {
                    Console.Write(("Opening: " + name)[i]);
                    Thread.Sleep(1);
                }

                Console.WriteLine(" ");
                Console.ForegroundColor = ConsoleColor.White;
                for (int i = 0; i < ("with id: " + id).Length; i++)
                {
                    Console.Write(("with id: " + id)[i]);
                    Thread.Sleep(1);
                }

                Console.WriteLine(" ");
                for (int i = 0; i < ("and path: " + path).Length; i++)
                {
                    Console.Write(("and path: " + path)[i]);
                    Thread.Sleep(1);
                }

                Console.WriteLine(" ");
                for (int i = 0; i < ("Now starting...").Length; i++)
                {
                    Console.Write(("Now starting...")[i]);
                    Thread.Sleep(1);
                }

                Process.Start(path);

                Console.WriteLine(" ");
                Console.WriteLine(" ");
            }

            Console.ForegroundColor = ConsoleColor.Green;
            for (int i = 0; i < ("AutoStart succesfully started all programs!").Length; i++)
            {
                Console.Write(("AutoStart succesfully started all programs!")[i]);
                Thread.Sleep(5);
            }
            Console.WriteLine(" ");
            Console.WriteLine(" ");
            Console.WriteLine("Checking for updates...");

            checkUpdate.Wait();

            bool updateAvailable = checkUpdate.Result;

            if (updateAvailable)
            {
                if (MessageBox.Show("A new version of AutoStart is available, would you like to download the update?",
                                    "Update AutoStart", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    Process.Start("http://www.danielvd.tk/autostart/?msg=thankyou");
                    Process.Start("http://www.danielvd.tk/autostart/download.php");
                }
            }
        }