private void Identify_CheckSecretExistsWithDialog_Click(object sender, RoutedEventArgs e)
        {
            LogTextBox.Clear();

            try
            {
                var secretName = InputBox.Show("Secret name:");

                Log("Secret name: {0}", secretName);

                var dialog = new IdentificationDialog();
                dialog.Title        = ".NET SDK Sample";
                dialog.Description  = ((Button)sender).Content.ToString();
                dialog.ParentWindow = new WindowInteropHelper(this).Handle;

                if (dialog.ShowDialog())
                {
                    Log("OK");
                    Log("User name: {0}", dialog.UserName);
                    Log("Authenticated credentials: {0}", String.Join(", ", dialog.AuthenticatedCredentials));

                    var secretExists = dialog.SecretExists(secretName);

                    Log("Secret exists: {0}", secretExists);
                }
                else
                {
                    Log("Cancelled");
                }
            }
            catch (Exception ex)
            {
                Log("Error: {0}", ex.Message);
            }
        }
        private void Authenticate_SpecifiedUser_Click(object sender, RoutedEventArgs e)
        {
            LogTextBox.Clear();

            try
            {
                var userName = InputBox.Show("User name:");

                Log("User name: {0}", userName);

                var dialog = new AuthenticationDialog();
                dialog.Title        = ".NET SDK Sample";
                dialog.Description  = ((Button)sender).Content.ToString();
                dialog.ParentWindow = new WindowInteropHelper(this).Handle;
                dialog.UserName     = userName;

                Log("Show dialog");

                if (dialog.ShowDialog())
                {
                    Log("OK");
                    Log("User name: {0}", dialog.UserName);
                    Log("Authenticated credentials: {0}", String.Join(", ", dialog.AuthenticatedCredentials));
                }
                else
                {
                    Log("Cancelled");
                }
            }
            catch (Exception ex)
            {
                Log("Error: {0}", ex.Message);
            }
        }
        private void Identify_CheckSecretExists_Click(object sender, RoutedEventArgs e)
        {
            LogTextBox.Clear();

            try
            {
                var userName   = InputBox.Show("User name:");
                var secretName = InputBox.Show("Secret name:");

                Log("User name: {0}", userName);
                Log("Secret name: {0}", secretName);

                var dialog = new IdentificationDialog();
                dialog.Title        = ".NET SDK Sample";
                dialog.Description  = ((Button)sender).Content.ToString();
                dialog.ParentWindow = new WindowInteropHelper(this).Handle;
                dialog.UserName     = userName;

                var sercetExists = dialog.SecretExists(secretName);

                Log("Secret exists: {0}", sercetExists);
            }
            catch (Exception ex)
            {
                Log("Error: {0}", ex.Message);
            }
        }
        private void Identify_CustomPolicy_Click(object sender, RoutedEventArgs e)
        {
            LogTextBox.Clear();

            try
            {
                var policy = new ulong[] { 1 | 2, 4 }; // password+fingerprints or smartcards

                Log("Custom policy: {0}", String.Join(", ", policy));

                var dialog = new IdentificationDialog();
                dialog.Title                = ".NET SDK Sample";
                dialog.Description          = ((Button)sender).Content.ToString();
                dialog.ParentWindow         = new WindowInteropHelper(this).Handle;
                dialog.AuthenticationPolicy = policy;

                Log("Show dialog");

                if (dialog.ShowDialog())
                {
                    Log("OK");
                    Log("User name: {0}", dialog.UserName);
                    Log("Authenticated credentials: {0}", String.Join(", ", dialog.AuthenticatedCredentials));
                }
                else
                {
                    Log("Cancelled");
                }
            }
            catch (Exception ex)
            {
                Log("Error: {0}", ex.Message);
            }
        }
Beispiel #5
0
        public GingerCoreNETWindow()
        {
            InitializeComponent();

            mSolutionRepository = WorkSpace.Instance.SolutionRepository;
            LogTextBox.Clear();
            ElapsedLabel.Visibility = Visibility.Collapsed;
            MemKBLabel.Visibility   = Visibility.Collapsed;

            Actions.Add(new MyAction()
            {
                Name = "Report.Error", Action = () => ReporterError()
            });
            Actions.Add(new MyAction()
            {
                Name = "Get all Files", Action = () => GetAllFiles()
            });
            Actions.Add(new MyAction()
            {
                Name = "Get All BFs", Action = () => GetBFs()
            });
            Actions.Add(new MyAction()
            {
                Name = "Get All BFs + keep refs", Action = () => GetBFsKeepRef()
            });
            Actions.Add(new MyAction()
            {
                Name = "Get All BFs and Drill down", Action = () => GetAllBFsandDrilldown()
            });
            Actions.Add(new MyAction()
            {
                Name = "Get All BFs and Save", Action = () => GetAllBFsandSave()
            });
            Actions.Add(new MyAction()
            {
                Name = "GetEnvironments", Action = () => GetEnvironments()
            });
            Actions.Add(new MyAction()
            {
                Name = "Run C# Code", Action = () => RunCShrapCode()
            });
            Actions.Add(new MyAction()
            {
                Name = "Repository Item Base Report", Action = () => RepositoryItemBaseReport()
            });
            Actions.Add(new MyAction()
            {
                Name = "Test crash on non UI thread", Action = () => TestCrash()
            });
            Actions.Add(new MyAction()
            {
                Name = "LongPath Test", Action = () => LongPathTest()
            });
            ActionsListBox.ItemsSource     = Actions;
            MainDataGrid.MouseDoubleClick += MainDataGrid_MouseDoubleClick;
        }
 public void Start()
 {
     Stop();
     _distanceCalculator = new DistanceCalculator(Convert.ToDouble(TimeTextBox.Text));
     _globalHook         = Hook.GlobalEvents();
     _globalHook.KeyUp  += OnKeyUp;
     _step = 0;
     LogTextBox.Clear();
     Log(string.Format("当前时间系数为:{0}\r\n", TimeTextBox.Text));
     Log("等待点击第一个点:");
 }
Beispiel #7
0
        public LogView(
            LogViewModel viewModel,
            SubjectMemorySink memorySink)
        {
            InitializeComponent();
            ViewModel = viewModel;

            this.WhenActivated(d =>
            {
                LogTextBox.Clear();
                memorySink.LogSubject.ObserveOnDispatcher().Subscribe(str => LogTextBox.AppendText(str)).DisposeWith(d);
            });
        }
Beispiel #8
0
 private void ClearLog()
 {
     if (this.InvokeRequired)
     {
         Invoke(new Action(() => ClearLog()));
     }
     else
     {
         if (!LogTextBox.IsDisposed)
         {
             LogTextBox.Clear();
         }
     }
 }
Beispiel #9
0
 /// <summary>
 /// Clear log window contents
 /// </summary>
 public void Clear()
 {
     if (LogTextBox != null)
     {
         Utilities.CallActionSafelyAndWait(LogTextBox, new Action(() =>
         {
             LogTextBox.Clear();
             LogTextBox.ScrollToCaret();
         }));
     }
     if (DebugLogTextBox != null)
     {
         Utilities.CallActionSafelyAndWait(DebugLogTextBox, new Action(() =>
         {
             DebugLogTextBox.Clear();
             DebugLogTextBox.ScrollToCaret();
         }));
     }
 }
Beispiel #10
0
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            IStatementParser parser = null;

            switch (StatementTypeComboBox.SelectionBoxItem.ToString())
            {
            case "DES Visa":
                parser = new StatementParserForDejardingsVisa();
                break;

            case "RBC Chequing":
                parser = new StatementParserForRbcChecking();
                break;

            case "RBC Visa":
                parser = new StatementParserForRbcVisa();
                break;
            }

            if (parser == null)
            {
                MessageBox.Show("Statement type is not supported.");
                return;
            }

            LogTextBox.Clear();
            Log("Started...");
            var path = InputFolderTextBox.Text;

            //Saving the path
            var s = new Settings
            {
                Path          = path,
                StatementType = StatementTypeComboBox.SelectedItem.ToString(),
            };

            s.Save();

            ProcessFiles(Path.Combine(InputFolderTextBox.Text), parser, GeneratePdfTextFilesCheckBox.IsChecked == true);

            Log("Done.");
        }
        private void Authenticate_CusmonUserNameType_Click(object sender, RoutedEventArgs e)
        {
            LogTextBox.Clear();

            try
            {
                var userName = InputBox.Show("User name:");

                var userNameTypeValues = new Dictionary <string, int>();
                userNameTypeValues["SAM (domain\\user_name)"] = 3;
                userNameTypeValues["DpAccount (user_name)"]   = 9;
                var userNameType = ChooseBox.Show <int>("User name type:", userNameTypeValues);

                Log("User name: {0}", userName);
                Log("User name: {0}", userNameType);

                var dialog = new AuthenticationDialog();
                dialog.Title        = ".NET SDK Sample";
                dialog.Description  = ((Button)sender).Content.ToString();
                dialog.ParentWindow = new WindowInteropHelper(this).Handle;
                dialog.UserName     = userName;
                dialog.UserNameType = userNameType;

                Log("Show dialog");

                if (dialog.ShowDialog())
                {
                    Log("OK");
                    Log("User name: {0}", dialog.UserName);
                    Log("Authenticated credentials: {0}", String.Join(", ", dialog.AuthenticatedCredentials));
                }
                else
                {
                    Log("Cancel");
                }
            }
            catch (Exception ex)
            {
                Log("Error: {0}", ex.Message);
            }
        }
        private void Authenticate_CusmonPolicyModified_Click(object sender, RoutedEventArgs e)
        {
            LogTextBox.Clear();

            try
            {
                var dialog = new AuthenticationDialog();
                dialog.Title        = ".NET SDK Sample";
                dialog.Description  = ((Button)sender).Content.ToString();
                dialog.ParentWindow = new WindowInteropHelper(this).Handle;
                dialog.UserName     = Environment.UserDomainName + "\\" + Environment.UserName;

                var policy = dialog.ReadAuthPolicy();
                Log("Original policy: {0}", String.Join(", ", policy));

                policy = policy.Where(p => (p & 1) != p).ToArray(); // remove password
                Log("Modified policy: {0}", String.Join(", ", policy));

                dialog.AuthenticationPolicy = policy;

                Log("Show dialog");

                if (dialog.ShowDialog())
                {
                    Log("OK");
                    Log("User name: {0}", dialog.UserName);
                    Log("Authenticated credentials: {0}", String.Join(", ", dialog.AuthenticatedCredentials));
                }
                else
                {
                    Log("Cancel");
                }
            }
            catch (Exception ex)
            {
                Log("Error: {0}", ex.Message);
            }
        }
Beispiel #13
0
        public void DoCleanLogs()
        {
            bool timerEnabled = timer1.Enabled;

            if (timerEnabled)
            {
                timer1.Stop();
            }
            try
            {
                Logging.clear();
                lastOffset = 0;
                LogTextBox.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (timerEnabled)
            {
                timer1.Start();
            }
        }
Beispiel #14
0
 /// <summary>
 /// テキストボックスの文字列を全削除する
 /// </summary>
 public void Clear()
 {
     MainForm.BeginInvoke(new Action(() => { LogTextBox.Clear(); }));
 }
 public void ClearLog()
 {
     LogTextBox.Clear();
 }
Beispiel #16
0
 /// <summary>
 /// Clears log text box
 /// </summary>
 private void ClearLog()
 {
     LogTextBox.Clear();
 }
Beispiel #17
0
        public GingerCoreNETWindow()
        {
            InitializeComponent();

            mSolutionRepository = WorkSpace.Instance.SolutionRepository;
            LogTextBox.Clear();
            ElapsedLabel.Visibility = Visibility.Collapsed;
            MemKBLabel.Visibility   = Visibility.Collapsed;

            Actions.Add(new MyAction()
            {
                Name = "Report.Error", Action = () => ReporterError()
            });
            Actions.Add(new MyAction()
            {
                Name = "Get all Files", Action = () => GetAllFiles()
            });
            Actions.Add(new MyAction()
            {
                Name = "Get All BFs", Action = () => GetBFs()
            });
            Actions.Add(new MyAction()
            {
                Name = "Get All BFs + keep refs", Action = () => GetBFsKeepRef()
            });
            Actions.Add(new MyAction()
            {
                Name = "Get All BFs and Drill down", Action = () => GetAllBFsandDrilldown()
            });
            Actions.Add(new MyAction()
            {
                Name = "Get All BFs and Save", Action = () => GetAllBFsandSave()
            });
            Actions.Add(new MyAction()
            {
                Name = "Get All BFs and Copy", Action = () => GetBFsAndCopy()
            });
            Actions.Add(new MyAction()
            {
                Name = "Create 100 Big BFs", Action = () => Create100BigBFs()
            });
            Actions.Add(new MyAction()
            {
                Name = "Clear Business Flows Cache", Action = () => ClearBusinessFlowsCache()
            });
            Actions.Add(new MyAction()
            {
                Name = "GetEnvironments", Action = () => GetEnvironments()
            });
            Actions.Add(new MyAction()
            {
                Name = "Start Ginger Grid", Action = () => StartGingerGrid()
            });
            Actions.Add(new MyAction()
            {
                Name = "List Ginger Grid Nodes", Action = () => ListGingerGridNodes()
            });
            Actions.Add(new MyAction()
            {
                Name = "Open GingerGrid Window", Action = () => OpenGingerGridWindows()
            });
            Actions.Add(new MyAction()
            {
                Name = "Run Goto URL On all Nodes", Action = () => RunGotoURLOnallNodes()
            });
            Actions.Add(new MyAction()
            {
                Name = "Run Selenium Actions", Action = () => RunSeleniumActions()
            });
            Actions.Add(new MyAction()
            {
                Name = "List Plugins", Action = () => ListPlugins()
            });
            Actions.Add(new MyAction()
            {
                Name = "Run C# Code", Action = () => RunCShrapCode()
            });
            Actions.Add(new MyAction()
            {
                Name = "Run Selenium Driver Core Plugin", Action = () => RunSeleniumDriverCorePlugin()
            });
            Actions.Add(new MyAction()
            {
                Name = "Open Applications", Action = () => OpenApplciations()
            });
            Actions.Add(new MyAction()
            {
                Name = "Open BF With Old Actions", Action = () => OpenBFWithOldActions()
            });
            Actions.Add(new MyAction()
            {
                Name = "Run Action", Action = () => RunAction()
            });
            Actions.Add(new MyAction()
            {
                Name = "Repository Item Base Report", Action = () => RepositoryItemBaseReport()
            });
            ActionsListBox.ItemsSource     = Actions;
            MainDataGrid.MouseDoubleClick += MainDataGrid_MouseDoubleClick;
        }
Beispiel #18
0
        private void OnFinished(Status status)
        {
            if (status == Status.BurnFinish)
            {
                // continue next step
                currentstatus = Status.TestFinish;
                label3.Text   = "测试";
                process       = null;

                if (ValidateCurrent("$$OK FLASHING"))
                {
                    ProcessStartInfo startInfo = new ProcessStartInfo("bsl.exe");
                    startInfo.Arguments              = "reset";
                    startInfo.WindowStyle            = ProcessWindowStyle.Minimized;
                    startInfo.RedirectStandardOutput = true;
                    //startInfo.RedirectStandardError = true;
                    //startInfo.RedirectStandardInput = true;
                    startInfo.UseShellExecute = false;
                    startInfo.CreateNoWindow  = true;
                    //startInfo.WindowStyle = ProcessWindowStyle.Minimized;

                    resetprocess = Process.Start(startInfo);
                    resetprocess.EnableRaisingEvents = true;
                    resetprocess.Exited             += process_Exited;
                    resetprocess.OutputDataReceived += process_OutputDataReceived2;
                    resetprocess.BeginOutputReadLine();

                    return;
                }
                else
                {
                    ResultLabel.Text = "FAIL";
                    fs.WriteLine("FAIL {0} {1} {2}", MacAddrTextBox.Text, BoardIdTextBox.Text, OperatorTextBox.Text);
                }
            }
            else if (status != Status.Done)
            {
                currentstatus = Status.Done;
                if (status == Status.Fail)
                {
                    // warning
                    ResultLabel.Text = "出错了";
                    fs.WriteLine("FAIL {0} {1} {2}", MacAddrTextBox.Text, BoardIdTextBox.Text, OperatorTextBox.Text);
                }
                else
                {
                    ResultLabel.Text = "测试通过";
                    fs.WriteLine("OK {0} {1} {2}", MacAddrTextBox.Text, BoardIdTextBox.Text, OperatorTextBox.Text);
                }
            }
            fs.Close();
            // save the result
            timer2.Enabled = false;

            // enable the control, get ready for next
            RunButton.Enabled       = true;
            MacAddrTextBox.ReadOnly = false;
            label3.Text             = "测试通过,下一个";

            MacAddrTextBox.Focus();
            MacAddrTextBox.SelectAll();
            LogTextBox.Clear();
        }
Beispiel #19
0
 private void ClearLogMenuItem_Click(object sender, RoutedEventArgs e)
 {
     Logging.Clear();
     _currentOffset = 0;
     LogTextBox.Clear();
 }
Beispiel #20
0
        private void StartUpdate_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.UserLogin    = UserLogin.Text;
            Properties.Settings.Default.UserPassword = Cryptography.EncryptPassword(UserLogin.Text, UserPassword.Text);

            LogTextBox.Clear();
            MainUpdateSettings.Visible = false;
            SPUpdateSettings.Visible   = false;
            UpdateReady = false;
            CompliteChecker.Start();

            new Task(() =>
            {
                void AppendLog(string text)
                => Invoke(new Action <string>(LogTextBox.AppendText), new object[] { text });

                try
                {
                    if (UpdateSharePoint.Checked || UpdateMSSQL.Checked)
                    {
                        AppendLog("Получение списка сортрудников Active Directory ");
                        var adEmployeeList = ADRepository.GetEmployeeList();
                        AppendLog($"({adEmployeeList.Count} записей)\r\n\r\n");

                        if (UpdateMSSQL.Checked)
                        {
                            AppendLog("Получение списка сортрудников MSSQL ");
                            var sqlEmployeeList = SqlRepository.GetEmployeeList();
                            AppendLog($"({sqlEmployeeList.Count} записей)\r\n");

                            AppendLog($"Поиск различий Active Directory и MSSQL\r\n");
                            (var createEmployeeList, var updateEmployeeList, var deleteEmployeeList) = DefiningDifferences(adEmployeeList, sqlEmployeeList);
                            AppendLog($"\tДобавить: {createEmployeeList.Count}\r\n"
                                      + $"\tИзменить: {updateEmployeeList.Count}\r\n"
                                      + $"\tУдалить: {deleteEmployeeList.Count}\r\n");

                            AppendLog($"Обновление данных MSSQL ");
                            SqlRepository.UpdateEmployeeList(createEmployeeList, updateEmployeeList, deleteEmployeeList);
                            AppendLog($"(Выполнено)\r\n\r\n");
                        }

                        if (UpdateSharePoint.Checked)
                        {
                            AppendLog("Получение списка сортрудников SharePoint ");
                            var spEmployeeList = SPRepository.GetEmployeeList();
                            AppendLog($"({spEmployeeList.Count} записей)\r\n");

                            AppendLog($"Поиск различий Active Directory и SharePoint:\r\n");
                            (var createEmployeeList, var updateEmployeeList, var deleteEmployeeList) = DefiningDifferences(adEmployeeList, spEmployeeList);
                            AppendLog($"\tДобавить: {createEmployeeList.Count}\r\n"
                                      + $"\tИзменить: {updateEmployeeList.Count}\r\n"
                                      + $"\tУдалить: {deleteEmployeeList.Count}\r\n");

                            AppendLog($"Обновление данных SharePoint ");
                            SPRepository.UpdateEmployeeList(createEmployeeList, updateEmployeeList, deleteEmployeeList);
                            AppendLog($"(Выполнено)\r\n\r\n");
                        }
                    }
                    else
                    {
                        AppendLog("Выполнение прервано, так как не указано ни одного хранилища данных.\r\n\r\n");
                    }
                }
                catch (Exception ex)
                {
                    AppendLog("Ошибка при выполнении:\r\n\t" + ex.Message + "\r\n\r\n" + "Трассировка: \r\n\t" + ex.StackTrace);
                }
                finally
                {
                    AppendLog($"Выполнение завершено\r\n");
                    UpdateReady = true;
                }
            }).Start();
        }
Beispiel #21
0
 private void MapErrorMessageChanged(object sender, EventArgs e)
 {
     LogTextBox.Clear(); // Should be a list of messages
     LogTextBox.AppendText(MapControl.ErrorMessage + "\n");
 }
Beispiel #22
0
 public WpfMailSender()
 {
     InitializeComponent();
     LogTextBox.Clear();
 }
Beispiel #23
0
 private void ClearButton_Click(object sender, System.EventArgs e)
 {
     LogTextBox.Clear();
 }
Beispiel #24
0
 private void LogCleanMenuItem_Click(object sender, EventArgs e)
 {
     LogTextBox.Clear();
 }
Beispiel #25
0
 private void btnClearLog_Click(object sender, RoutedEventArgs e)
 {
     LogTextBox.Clear();
 }
        private void Start_OnClick(object sender, RoutedEventArgs e)
        {
            list0 = CustomerHelper.fun1();

            //获取设置
            cpuCount    = AppConfigHelper.GetAppConfigInt("CpuCount");
            threadCount = AppConfigHelper.GetAppConfigInt("ThreadCount");
            //清空当前列表
            ListQueue.Clear();
            //清空进度条
            this.pb.Maximum = 0;
            this.tb.Text    = "0%";
            this.pb.Value   = 0;

            var foldPath     = "";
            var newfoldPath  = "";
            var waterMarkImg = "";

            if (TabControl0.SelectedIndex == 0 || TabControl0.SelectedIndex == 2)
            {
                foldPath    = FileDir.Text;
                newfoldPath = NewFileDir.Text;
                cmdPath     = CommonStatic.FFmpegPath;
                if (TabControl0.SelectedIndex == 2)
                {
                    foldPath     = FileDir2.Text;
                    newfoldPath  = NewFileDir2.Text;
                    waterMarkImg = WaterMarkTextBox.Text.Trim();
                }
            }
            else if (TabControl0.SelectedIndex == 1)
            {
                foldPath    = FileDir1.Text;
                newfoldPath = NewFileDir1.Text;
                cmdPath     = CommonStatic.Qtpath;
            }

            if (TabControl0.SelectedIndex == 2 && string.IsNullOrEmpty(waterMarkImg))
            {
                System.Windows.Forms.MessageBox.Show("请选择要添加水印的图片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (string.IsNullOrEmpty(foldPath))
            {
                System.Windows.Forms.MessageBox.Show("请选择要转换的视频的路径", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (string.IsNullOrEmpty(newfoldPath))
            {
                System.Windows.Forms.MessageBox.Show("请输入要转换的视频的新路径", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (TabControl0.SelectedIndex == 1 || TabControl0.SelectedIndex == 2)
            {
                //在 【将元信息设置到第一帧】 模式下,生成文件的路径不能够和源文件路径一样,否则会出错
                if (foldPath == newfoldPath)
                {
                    System.Windows.Forms.MessageBox.Show("【生成文件路径】不能够和【源文件路径】一样。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            DirectoryInfo thisOne = new DirectoryInfo(foldPath);

            DeepFileDir(thisOne);

            if (ListQueue.Count == 0)
            {
                System.Windows.Forms.MessageBox.Show("该路径下未找到MP4格式的视频", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            LogTextBox.Clear();
            LogTextBox.Text = "该目录下共找到 " + ListQueue.Count + " 个视频,开始进行转换......\n";
            iAmount         = ListQueue.Count;
            iCount          = 0;
            iNow            = 0;
            Thread thread = new Thread(ThreadStart);

            thread.IsBackground = true;
            thread.Start();

            Select.IsEnabled = false;
            Start.IsEnabled  = false;

            Select1.IsEnabled = false;
            Start1.IsEnabled  = false;

            pb.Maximum = ListQueue.Count;
        }
Beispiel #27
0
 private async Task CheckAndClean(bool clean)
 {
     LogTextBox.Clear();
     MainTabControl.SelectedTab = LogsTabPage;
     var cancellationToken = new CancellationToken(false);
     var so     = ControlsHelper.MainTaskScheduler;
     var unused = Task.Factory.StartNew(() =>
     {
         AddLogLine("Enumerating Devices...");
         var devices = DeviceDetector.GetDevices();
         var offline = devices.Where(x => !x.IsPresent && x.IsRemovable && !x.Description.Contains("RAS Async Adapter")).ToArray();
         var problem = devices.Where(x => x.Status.HasFlag(DeviceNodeStatus.DN_HAS_PROBLEM)).Except(offline).ToArray();
         var unknown = devices.Where(x => x.Description.Contains("Unknown")).Except(offline).Except(problem).ToArray();
         var list    = new List <string>();
         if (offline.Length > 0)
         {
             list.Add(string.Format("{0} offline devices.", offline.Length));
         }
         if (problem.Length > 0)
         {
             list.Add(string.Format("{0} problem devices.", problem.Length));
         }
         if (unknown.Length > 0)
         {
             list.Add(string.Format("{0} unknown devices.", unknown.Length));
         }
         var message = string.Join("\r\n", list);
         if (list.Count == 0)
         {
             AddLogLine("No offline, problem or unknown devices found.");
         }
         else if (clean)
         {
             foreach (var item in list)
             {
                 AddLogLine(item);
             }
             var result = DialogResult.No;
             ControlsHelper.Invoke(new Action(() =>
             {
                 var form = new JocysCom.ClassLibrary.Controls.MessageBoxForm
                 {
                     StartPosition = FormStartPosition.CenterParent
                 };
                 ControlsHelper.CheckTopMost(form);
                 result = form.ShowForm(
                     "Do you want to remove offline, problem or unknown devices?\r\n\r\n" + message,
                     "Do you want to remove devices?",
                     MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                 form.Dispose();
             }));
             if (result != DialogResult.Yes)
             {
                 return;
             }
             var devList = new List <DeviceInfo>();
             devList.AddRange(offline);
             devList.AddRange(problem);
             devList.AddRange(unknown);
             for (var i = 0; i < devList.Count; i++)
             {
                 var item = devList[i];
                 AddLogLine("Removing Device: {0}/{1} - {2}", i + 1, list.Count, item.Description);
                 try
                 {
                     var exception = DeviceDetector.RemoveDevice(item.DeviceId);
                     if (exception != null)
                     {
                         AddLogLine(exception.Message);
                     }
                     //System.Windows.Forms.Application.DoEvents();
                 }
                 catch (Exception ex)
                 {
                     AddLogLine(ex.Message);
                 }
             }
         }
         AddLogLine("Done");
     }, CancellationToken.None, TaskCreationOptions.LongRunning, so).ConfigureAwait(true);
 }
        private void StartOnXml_OnClick(object sender, RoutedEventArgs e)
        {
            if (TabControl0.SelectedIndex == 2 && string.IsNullOrEmpty(waterMarkImg))
            {
                System.Windows.Forms.MessageBox.Show("请选择要添加水印的图片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //获取设置
            cpuCount    = AppConfigHelper.GetAppConfigInt("CpuCount");
            threadCount = AppConfigHelper.GetAppConfigInt("ThreadCount");
            //清空当前列表
            ListQueue.Clear();
            //清空进度条
            this.pb.Maximum = 0;
            this.tb.Text    = "0%";
            this.pb.Value   = 0;

            //先从根目录下查找xml
            XmlDocument xmldoc = new XmlDocument();

            try
            {
                string xmlPath = System.AppDomain.CurrentDomain.BaseDirectory + "watermark.xml";
                xmldoc.Load(xmlPath);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("xml文件加载出错", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LogHelper.AddErrorLog(ex.ToString());
                return;
            }
            //获取节点列表
            XmlNodeList topNode = xmldoc.DocumentElement.ChildNodes;

            foreach (XmlElement element in topNode)
            {
                var str         = element.InnerText;
                var item        = new VideoMp4();
                var oldFilePath = str; // newFilePath.Substring(0,newFilePath.LastIndexOf("."))
                var filename    = oldFilePath.Substring(oldFilePath.LastIndexOf("\\")).Replace("\\", "");
                var fileformat  = filename.Substring(filename.LastIndexOf("."));
                var newfilename = filename.Substring(0, filename.LastIndexOf(".")) + "_znykt_cnki" + fileformat;
                var newFilePath = oldFilePath.Substring(0, oldFilePath.LastIndexOf("\\")) + "\\" + newfilename;
                item.CmdString   = string.Format(" -y -i \"{0}\" -vf \"movie={1},scale=170:60[watermark];[in][watermark]overlay=main_w-overlay_w-10:10[out]\" \"{2}\"", oldFilePath, waterMarkImg, newFilePath);
                item.NewFileName = newfilename;
                item.NewFilePath = newFilePath;
                item.OldFilePath = oldFilePath;
                item.OldfileName = filename;
                ListQueue.Enqueue(item);
            }

            if (ListQueue.Count == 0)
            {
                System.Windows.Forms.MessageBox.Show("该路径下未找到MP4格式的视频", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            LogTextBox.Clear();
            LogTextBox.Text = "该目录下共找到 " + ListQueue.Count + " 个视频,开始进行转换......\n";
            iAmount         = ListQueue.Count;
            iCount          = 0;
            iNow            = 0;
            Thread thread = new Thread(ThreadStart);

            thread.IsBackground = true;
            thread.Start();

            Select.IsEnabled = false;
            Start.IsEnabled  = false;

            Select1.IsEnabled = false;
            Start1.IsEnabled  = false;

            pb.Maximum = ListQueue.Count;
        }
Beispiel #29
0
 /// <summary>
 /// Clears the current content in the Log window in the Addon form.
 /// </summary>
 public static void ClearLogWindow()
 {
     LogTextBox.Clear();
 }
 private void CleatLogButton_Click(object sender, RoutedEventArgs e)
 {
     LogTextBox.Clear();
 }