コード例 #1
0
        public MainWindow()
        {
            InitializeComponent();

            //handle visibility
            loadingicon.Visibility = Visibility.Hidden;
            scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;

            KillerStats kStats = loadKillerStats();

            dataList.Width = Constants.DataItemWidth;
            initUIElements(kStats.formatData());
            doStartupPrompts();

            //generate a random background
            Random newRand = new Random();

            background.Source = new BitmapImage(new Uri("Resources/backgrounds/banner_" + newRand.Next(9) + ".png", UriKind.Relative));
        }
コード例 #2
0
        public void ExecuteBatFileAndUpdateUI(KillerStats statsObj)
        {
            Process proc = new Process();

            //oof
            proc.StartInfo.FileName              = System.AppDomain.CurrentDomain.BaseDirectory + Constants.PathToRoot + "cpy.bat";
            proc.StartInfo.Arguments             = Constants.PathToRoot + "settings.ini";
            proc.StartInfo.RedirectStandardError = true;
            proc.StartInfo.CreateNoWindow        = true;
            proc.StartInfo.UseShellExecute       = false;
            proc.EnableRaisingEvents             = true;
            loadingicon.Visibility = Visibility.Visible;
            proc.Start();


            //listen for the process to finish running and alert the main thread to update the visibility
            proc.Exited += (sender, e) => { this.Dispatcher.Invoke(() => {
                    loadingicon.Visibility = Visibility.Hidden;
                    updateKillerStatsFromLogfiles(ref statsObj);
                    initUIElements(statsObj.formatData());
                    //write the new stats to file, overwriting whatever was there
                    writeKillerDataToJSON(statsObj);
                }); };
        }