コード例 #1
0
        private void DownloadVideos(ActionType action)
        {
            if (CheckboxChecked())
            {
                PopulateUrlDownloadList();
                foreach (var url in UrlDowloadList)
                {
                    var title = playlistVideos.Find(url).Title;

                    progbarwin = new ProgressBarWindow(action, title, downloadPath)
                    {
                        Owner = this
                    };
                    progbarwin.Show();
                    progbarwin.Start(action, title, url, downloadPath);
                    progbarwin.Close();
                }
                var remove = System.Windows.MessageBox.Show("Downloads completed. Some of your videos may not have been downloaded due to copyrights." + "\n\n" + "Do you want to remove all downloaded videos from your YouTube playlist?", "Update Playlist", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (remove == MessageBoxResult.Yes)
                {
                    RemoveDownloads();
                    RepopulateVideoList();
                }
            }
            else
            {
                System.Windows.MessageBox.Show("Please select a video to download.", "Selection Required", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
コード例 #2
0
        private void ThreadStartingPoint()
        {
            var tempWindow = new ProgressBarWindow();

            tempWindow.Show();
            Dispatcher.Run();
        }
コード例 #3
0
        private void OpenProgressBarButton(object sender, RoutedEventArgs e)
        {
            this.Visibility = Visibility.Hidden;
            ProgressBarWindow progresBarWindow = new ProgressBarWindow();

            progresBarWindow.Show();
        }
        private void btnUpLoad_Click(object sender, RoutedEventArgs e)
        {
            pbw = new ProgressBarWindow(vm_fsup.Vm_ProgressBar);
            pbw.vm_Progress.Refresh();
            pbw.Show();
            Thread myThread = new Thread(new ThreadStart(Save));

            myThread.Start();
        }
        private void SaveMenuItem_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Title            = "Збереження";
            saveFileDialog.FileName         = "Звіт";
            saveFileDialog.DefaultExt       = ".docx";
            saveFileDialog.Filter           = "Word files (.doc)|*.docx";
            saveFileDialog.InitialDirectory = Environment.CurrentDirectory + @"\saves";
            if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                ReportController reportController = new ReportController
                {
                    WeatherController      = _weatherController,
                    SunConditionController = _sunConditionController,
                    DeviceController       = _deviceController,
                    DeviceOpt2Controller   = ElectricalLoadScheduleView.OptimizationView.Device2ZoneOptController,
                    DeviceOpt3Controller   = ElectricalLoadScheduleView.OptimizationView.Device3ZoneOptController,
                    HouseController        = _houseController,
                    WindEnergyController   = _windEnergyController,
                    HeatPumpController     = _heatPumpController,
                    HeatStoreController    = _heatStoreController
                };
                reportController.CopyData();
                reportController.Report.ImgDirectory = _imagesDirectory;
                MeteorogicalAnalysisView.SaveCharts(_weatherChartPaths);
                reportController.Report.Weather.ImgPaths = _weatherChartPaths;

                ElectricalLoadScheduleView.SaveCharts(_elLoadChartPaths, _elLoadOpt2ChartPaths, _elLoadOpt3ChartPaths);
                reportController.Report.ElectricalLoadSchedule.ImgPaths     = _elLoadChartPaths;
                reportController.Report.Opt2ElectricalLoadSchedule.ImgPaths = _elLoadOpt2ChartPaths;
                reportController.Report.Opt3ElectricalLoadSchedule.ImgPaths = _elLoadOpt3ChartPaths;

                reportController.Report.ThermalEnergy.CommonImgPaths     = _commonHeatingPaths;
                reportController.Report.ThermalEnergy.IndividualImgPaths = _individualHeatingPaths;
                ThermalEnergy.SaveCharts(_commonHeatingPaths, _individualHeatingPaths);

                reportController.Report.Wind.ImgPaths = _windEnergyPaths;
                WindEnergyView.SaveCharts(_windEnergyPaths);

                reportController.Report.HeatPump.ImgPaths = _heatPumpPaths;
                HeatPumpView.SaveCharts(_heatPumpPaths);

                reportController.Report.HeatStore.ImgPaths = _heatStorePaths;
                HeatStoreView.SaveCharts(_heatStorePaths);

                ReportWordController reportWordController = new ReportWordController
                {
                    Report = reportController.Report
                };

                string            path = System.IO.Path.GetFullPath(saveFileDialog.FileName);
                ProgressBarWindow progressBarWindow = new ProgressBarWindow(reportWordController, path);
                progressBarWindow.Show();
            }
        }
コード例 #6
0
 private void MethodTwoCaller(IProgress <int> progress)
 {
     Dispatcher.Invoke(() =>
     {
         pbWindowTwo       = new ProgressBarWindow("Running Method Two");
         pbWindowTwo.Owner = this;
         pbWindowTwo.Show();
     });
     Utility.TimeConsumingMethodTwo(progress);
 }
コード例 #7
0
 private void MethodTwoCaller(object sender, DoWorkEventArgs e)
 {
     Dispatcher.Invoke(() =>
     {
         pbWindowTwo       = new ProgressBarWindow("Running Method Two");
         pbWindowTwo.Owner = this;
         pbWindowTwo.Show();
     });
     Utility.TimeConsumingMethodTwo(sender);
 }
コード例 #8
0
    private async Task MethodTwoCaller()
    {
        ProgressBarWindow pbWindowTwo =
            new ProgressBarWindow("Running Method Two")
        {
            Owner = this
        };

        pbWindowTwo.Show();
        await Utility.TimeConsumingMethodTwo(i => pbWindowTwo.SetProgressUpdate(i));
    }
コード例 #9
0
        private void Bw_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                string email = "";
                string senha = "";

                Dispatcher.Invoke(() =>
                {
                    LoginBtn.IsEnabled = false;

                    progressBarWindow = new ProgressBarWindow("Realizando Login");
                    progressBarWindow.Show();
                });

                Dispatcher.Invoke(() =>
                {
                    email = EmailUC.Text;
                    senha = PasswordUC.Password;
                });

                if (DesktopLoginControlService.Logar(email, senha))
                {
                    Dispatcher.Invoke(() => { PasswordUC.Password = string.Empty; });

                    foreach (int i in Dispatcher.Invoke(() => Application.Current.Windows.OfType <MainWindow>().First().StartSession()))
                    {
                        Thread.Sleep(50);
                        (sender as BackgroundWorker).ReportProgress(i);
                    }
                }
            }
            catch (FieldException ex)
            {
                StandardMessageBoxes.MensagemDeErroCampoFormulario(ex.Message);
            }
            catch (Exception ex)
            {
                StandardMessageBoxes.MensagemDeErro(ex.Message);
            }
            finally
            {
                Dispatcher.Invoke(() =>
                {
                    progressBarWindow.Close();
                    LoginBtn.IsEnabled = true;
                });
            }
        }
コード例 #10
0
        //Метод отображения прогрессбара
        public void ShowProgWindow()

        {
            progressBarViewModel = new ProgressBarViewModel(this);
            progressBarWindow    = new ProgressBarWindow(progressBarViewModel);
            string nameTreadCurrentNew = Thread.CurrentThread.Name;

            progressBarWindow.Show();

            progressBarWindow.Closed += new EventHandler(progressBarWindow.MetroWindow_Closed);

            _progressWindowWaitHandle.Set();

            System.Windows.Threading.Dispatcher.Run();
        }
コード例 #11
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            MessageBoxWindow mbw = new MessageBoxWindow();

            mbw.vm_MessageBoxWindow = new AMS.ViewModel.ViewModelMessageBoxWindow(AMS.Model.Enum.MessageBoxType.Ask,
                                                                                  string.Format("确定使用当前播放时间?\n{0}到{1}", vm_PlaylistInfo.EffectDate, vm_PlaylistInfo.EndDate));
            mbw.ShowDialog();
            if (mbw.vm_MessageBoxWindow.Result)
            {
                pbw = new ProgressBarWindow(vm_PlaylistInfo.Vm_ProgressBar);
                pbw.vm_Progress.Refresh();
                pbw.Show();
                Thread myThread = new Thread(new ThreadStart(Save));
                myThread.Start();
            }
        }
コード例 #12
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Save_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxWindow mbw = new MessageBoxWindow();

            mbw.vm_MessageBoxWindow = new AMS.ViewModel.ViewModelMessageBoxWindow(AMS.Model.Enum.MessageBoxType.Ask,
                                                                                  string.Format("确定使用当前播放时间?"));
            mbw.ShowDialog();
            if (mbw.vm_MessageBoxWindow.Result)
            {
                pbw = new ProgressBarWindow(viewModel.Vm_ProgressBar);
                pbw.vm_Progress.Refresh();
                pbw.Show();
                Thread myThread = new Thread(new ThreadStart(Save));
                myThread.Start();
            }
        }
コード例 #13
0
ファイル: BEA.cs プロジェクト: OcelotGamingDev/Switch-Toolbox
            private void ExportAll(object sender, EventArgs args)
            {
                FolderSelectDialog fsd = new FolderSelectDialog();

                if (fsd.ShowDialog() == DialogResult.OK)
                {
                    progressBar      = new ProgressBarWindow();
                    progressBar.Task = "Extracing Files...";
                    progressBar.Refresh();
                    progressBar.Value         = 0;
                    progressBar.StartPosition = FormStartPosition.CenterScreen;
                    progressBar.Show();

                    ExportAll(fsd.SelectedPath, progressBar);
                }
            }
コード例 #14
0
        private void testmenu_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxWindow mbw = new MessageBoxWindow();

            mbw.vm_MessageBoxWindow = new AMS.ViewModel.ViewModelMessageBoxWindow(AMS.Model.Enum.MessageBoxType.Ask, "是否显示优惠券栏?");
            mbw.ShowDialog();

            mpt = new MediaPlayerTest();
            mpt.vm_playlist.PlayModel  = AMS.Model.AMS_PlayList.Parse(AMS.Model.AMS_PlayList.ToXml((LBList.SelectedItem as AMS.ViewModel.ViewModelPlayListShow).ModelList));
            mpt.vm_playlist.IsShowSlip = mbw.vm_MessageBoxWindow.Result;

            pbw = new ProgressBarWindow(mpt.vm_playlist.Vm_Progressbar);
            pbw.vm_Progress.Refresh();
            pbw.Show();

            Thread myThread = new Thread(new ThreadStart(Save));

            myThread.Start();
        }
コード例 #15
0
 private void btnDownLoad_Click(object sender, RoutedEventArgs e)
 {
     if (lstFileSharingInfo.SelectedIndex < 0)
     {
         vm_fs.ErrorMessage = "请选择需要下载的文件!";
         return;
     }
     System.Windows.Forms.FolderBrowserDialog foldBrowerDialog = new System.Windows.Forms.FolderBrowserDialog();
     foldBrowerDialog.ShowDialog();
     if (!string.IsNullOrEmpty(foldBrowerDialog.SelectedPath))
     {
         downloadpath = foldBrowerDialog.SelectedPath;
         selectindex  = lstFileSharingInfo.SelectedIndex;
         pbw          = new ProgressBarWindow(vm_fs.Vm_ProgressBar);
         pbw.vm_Progress.Refresh();
         pbw.Show();
         Thread myThread = new Thread(new ThreadStart(Down));
         myThread.Start();
     }
 }
コード例 #16
0
        public void CreateNewThread()
        {
            t = ((App)Application.Current).SyncThread;
            ProgressBarWindow pbw;

            if ((t == null) || (!t.IsAlive))
            {
                t = new Thread(delegate()
                {
                    pbw          = new ProgressBarWindow();
                    pbw.Closing += OnProgressBarWindowClosed;
                    pbw.Show();
                    System.Windows.Threading.Dispatcher.Run();
                });
                t.SetApartmentState(ApartmentState.STA);
                t.IsBackground = true;
                t.Start();
                ((App)Application.Current).SyncThread = t;
            }
        }
コード例 #17
0
        public void CheckReport()
        {
            //举例:
            //SelectListInt =[1,0]
            //SelectListFunctionName=[FindUnitError,FindNotExplainComponentNo]
            //表示算法只算FindUnitError,不算FindNotExplainComponentNo
            var controlClass = RegisterMethod();

            var config = XDocument.Load(@"Option.config");

            //Bug:修改配置文件后,读取结果不变
            foreach (var e in config.Elements("configuration").Descendants())
            {
                try
                {
                    controlClass.SelectListInt.Add(Convert.ToInt32(e.Value.ToString()));
                }
                catch (Exception)
                {
                    //TODO:增加读不出数据的异常处理
                    controlClass.SelectListInt.Add(0);
                }

                try
                {
                    controlClass.SelectListContent.Add(e.Attribute("Content").Value.ToString());
                }
                catch (Exception)
                {
                    //TODO:增加读不出数据的异常处理
                    controlClass.SelectListContent.Add("方法名称读取失败");
                }
            }

            var w = new ProgressBarWindow();

            w.Top  = 0.4 * (App.ScreenHeight - w.Height);
            w.Left = 0.4 * (App.ScreenWidth - w.Width);

            var progressBarDataBinding = new ProgressBarDataBinding
            {
                V = 0,
            };

            w.progressBarNumberTextBlock.DataContext = progressBarDataBinding;
            w.progressBar.DataContext = progressBarDataBinding;
            w.progressBarContentTextBlock.DataContext = progressBarDataBinding;

            var progressSleepTime = 500;    //进度条停顿时间

            var thread = new Thread(new ThreadStart(() =>
            {
                w.progressBar.Dispatcher.BeginInvoke((ThreadStart) delegate { w.Show(); });
                int invokeF = 0;    //已调用函数
                for (int i = 0; i < controlClass.SelectListInt.Count; i++)
                {
                    if (controlClass.SelectListInt[i] != 0)
                    {
                        progressBarDataBinding.V       = invokeF * 100 / controlClass.SelectListInt.Sum();
                        progressBarDataBinding.Content = $"正在校核:{controlClass.SelectListContent[i]}";
                        controlClass.SelectListFunctionName[i]?.Invoke();
                        invokeF++;
                        Thread.Sleep(progressSleepTime);
                    }
                }
                progressBarDataBinding.V       = 100;
                progressBarDataBinding.Content = $"正在校核:正在完成中";
                GenerateResultReport();
                _doc.Save("标出错误或警告的报告.doc");
                Thread.Sleep(progressSleepTime);
                MessageBox.Show($"校核已完成!共校核出:" +
                                $"\r错误{reportError.Count}个" +
                                $"\r警告{reportWarnning.Count}个" +
                                $"\r信息{reportInfo.Count}条");
                w.progressBar.Dispatcher.BeginInvoke((ThreadStart) delegate { w.Close(); });
            }));

            thread.Start();
        }