private void SqlEditor_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { try { // Feed the text from text editor to the query builder when user exits the editor. QBuilder.SQL = SqlEditor.Text; ErrorBox.Show(null, QBuilder.SyntaxProvider); _lastValidSql = QBuilder.FormattedSQL; } catch (SQLParsingException ex) { // Set caret to error position SqlEditor.CaretIndex = ex.ErrorPos.pos; // Report error ErrorBox.Show(ex.Message, QBuilder.SyntaxProvider); _errorPosition = ex.ErrorPos.pos; } }
private void btnCreateVersion_Click(object sender, RoutedEventArgs e) { try { Version ver = new Version(TxtVersion.Text); _VesionFactory.CreateVersion( TxtSourceDir.Text, ver, TxtLocation.Text, TxtExcludeExt.Text, TxtLocales.Text, TxtUpdaterLocations.Text); } catch (Exception exc) { ErrorBox.Show("Error", exc); } }
public static void ShowException(Exception exception) { var viewModel = new ErrorBoxViewModel { Message = exception.Message, Exception = exception.ToString() }; var window = new ErrorBox { DataContext = viewModel, WindowStartupLocation = WindowStartupLocation.CenterOwner }; window.ShowDialog(MainWindowView.Instance); //ShowMessage(exception.ToString()); //ShowDialog(new TextViewModel(exception.ToString())); }
private void learnModuleComplete(Object sender, RunWorkerCompletedEventArgs e) { object result = e.Result; if (result is string) { showGraph.Enabled = true; moduleID.BackColor = Color.Red; moduleID.Text = result as string; //toolStripStatusLabel1.Text += " [FAILED]"; ErrorBox eb = new ErrorBox(); eb.ShowDialog(); } else { IModule module = result as IModule; moduleID.BackColor = Color.YellowGreen; moduleID.Text = module.ModuleID.ToString("X8"); Room.Module = module; if (Room.Module.type == 1) { Room.Module.NewTime = !module.NewTime; } //FormMain.calibration.openValve(valve); moduleIst.Text = String.Format("{0:F1} °C", Room.Module.Temperature); moduleSoll.Text = String.Format("{0:F1} °C", Math.Round(2 * Room.Module.SetPoint) / 2.0D); //toolStripStatusLabel1.Text += " [OK]"; FormMain mainforms = (FormMain)(this.FindForm()); if (((FormMain)mainforms).flowLayoutPanel3.Controls.Count != 0) { ((FormMain)mainforms).flowLayoutPanel3.Controls[0].Hide(); } } moduleID.BackColor = Color.YellowGreen; moduleAnlernen.Enabled = true; /* * HeaterPanelLearningEventHandler eventHandler = HeaterPanelLearning; * * if (eventHandler != null) * eventHandler(false); */ }
private void SqlTextBox_OnLostFocus(object sender, RoutedEventArgs e) { try { // Update the query builder with manually edited query text: QBuilder.SQL = SqlTextBox.Text; // Hide error banner if any ErrorBox.Show(null, QBuilder.SyntaxProvider); } catch (SQLParsingException ex) { // Set caret to error position SqlTextBox.SelectionStart = ex.ErrorPos.pos; _errorPosition = ex.ErrorPos.pos; // Show banner with error text ErrorBox.Show(ex.Message, QBuilder.SyntaxProvider); } }
// private void Resize (object sender, VideoResizeEventArgs e) // { // screen = Video.SetVideoModeWindowOpenGL(e.Width, e.Height, true); // if (screen.Width != e.Width || screen.Height != e.Height) // { // //this.InitGL(); // this.Reshape(); // } // } /// <summary> /// Starts lesson /// </summary> public void Run() { #if Release try { #endif Reshape(); InitGL(); Thread.CurrentThread.Priority = ThreadPriority.Highest; Events.Run(); #if Release } catch (Exception ex) { ErrorBox.DisplayError(ex); } #endif }
private void StartClick(object sender, EventArgs e) { if (_fuzzOn) { return; } _options.MatchPattern = _textPattern.Text; _options.ReversePattern = _reversePattern.Checked; GenerateRequestsToFuzz(); ErrorBox error = new ErrorBox(); if (!String.IsNullOrWhiteSpace(_fileSelector.Text)) { _outputFile = new TrafficViewerFile(); _outputFile.Save(_fileSelector.Text); if (!File.Exists(_fileSelector.Text)) { error.Show("Invalid result file location"); return; } _options.OutputFile = _fileSelector.Text; } else { _outputFile = TrafficViewer.Instance.TrafficViewerFile; _outputFile.SetState(AccessorState.Tailing); } if (!int.TryParse(_textNumThreads.Text, out _numThreads)) { error.Show("Invalid number of threads specified"); return; } _options.NumberOfThreads = _numThreads; _options.Save(); GenerateAndRunPayloads(); }
public void Execute(ITrafficDataAccessor curDataAccessor, List <TVRequestInfo> selectedRequests, IHttpClientFactory curHttpClientFactory) { if (selectedRequests.Count < 1) { ErrorBox.ShowDialog(Resources.SelectOneRequest); return; } TVRequestInfo req = selectedRequests[0]; byte[] request = curDataAccessor.LoadRequestData(req.Id); HttpRequestInfo reqInfo = new HttpRequestInfo(request); reqInfo.IsSecure = req.IsHttps; var csrfSetupForm = new CSRFSetupForm(reqInfo, curDataAccessor); csrfSetupForm.Show(); }
public string GetAsciiArray(string filename, int numberOfBytesInARow = 10) { var buffer = new byte[numberOfBytesInARow]; var sb = new StringBuilder(); try { if (System.IO.File.Exists(filename)) { using (var fs = System.IO.File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { int offset = 0, db; while ((db = fs.Read(buffer, offset, numberOfBytesInARow)) > 0) { offset += db; for (var i = 0; i < db; i++) { sb.Append($"0x{$"{buffer[i]:x2}".ToUpper()}"); if (i < numberOfBytesInARow - 1) { sb.Append(", "); } else { sb.AppendLine(","); } } } fs.Close(); } } else { throw new FileNotFoundException(FileNotFound, filename); } } catch (Exception ex) { ErrorBox.Show(ex); } return(sb.ToString()); }
private void button1_Click(object sender, EventArgs e) { if (File.Exists(_fileSelector.Text)) { if (_checkEncode.Checked) { _value = Convert.ToBase64String(File.ReadAllBytes(_fileSelector.Text)); } else { _value = File.ReadAllText(_fileSelector.Text); } this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { ErrorBox.ShowDialog(Resources.InvalidFilePath); } }
private void LoadFile(string path) { bool loaded = true; _testFile = new CustomTestsFile(); if (File.Exists(path)) { loaded = _testFile.Load(path); } if (!loaded) { ErrorBox.ShowDialog("Could not load file"); return; } _grid.SetValues((List <string>)_testFile.GetOption(CUSTOM_TESTS)); runAutomaticallyToolStripMenuItem.Checked = _testFile.AutoRunTests; _testRunner.SetTestFile(_testFile); }
private void AddRule_Click(object sender, RoutedEventArgs e) { try { RuleBuilder builder = RuleBuilder.CreateBuilder(); builder.Conditions() .ConditionsOperation((OperationType)Enum.Parse(typeof(OperationType), (ctrOpeartionTypesCB.SelectedValue as TextBlock).Text)); list.ForEach(temp => builder.Conditions().Add(ConditionSign.Identity, temp.Term)); Rule rule = builder.OutputTerm((ctrOutputTermCB.SelectedValue as Term)) .Build(); RulesService.Instance.AddRule(rule); Close(); } catch (Exception exp) { ErrorBox.Show(exp.Message); } }
public override bool Run(IWin32Window owner) { try { base.Log.Verbose(string.Format("Running {0} plugin.", PluginName)); // Get the user config directory. string userConfigDir = null; try { var host = base.Services.GetService <IHostService>(true); userConfigDir = host.UserConfigDirectory; } catch (Exception ex) { base.Log.Error(string.Format( "Could not retrieve the User Configuration Directory: {0}", ex.Message), ex); } using (var form = new GenerateSelfSignedCertForm()) { if (userConfigDir != null) { form.GetUserConfigDirectory = () => userConfigDir; } form.ShowDialog(owner); } return(true); } catch (Exception ex) { base.Log.Error(ex); var message = string.Format( "There was an error while executing plugin {0}:\r\n\r\n{1}", PluginName, ex.Message); ErrorBox.Show(owner, message); return(false); } }
async void OnOpenFileAsync() { long maxSize = 25 * 1024 * 1024; var openDialog = new OpenDialog("Open", "Open a file") { AllowsMultipleSelection = false, DirectoryPath = GetOpenFileDialogDirectory() }; Application.Run(openDialog); if (openDialog.Canceled) { return; } var fi = new FileInfo(openDialog.FilePath.ToString()); if (!fi.Exists) { return; } var fileName = Path.GetFileName(openDialog.FilePath.ToString()); if (fi.Length > maxSize) { ErrorBox.Show($"File {fileName} has a size of {GetBytesReadable(fi.Length)} but allowed are only {GetBytesReadable(maxSize)}."); return; } if (MessageBox.Query("Send File?", $"{fileName}, {GetBytesReadable(fi.Length)}", Strings.Ok, Strings.Cancel) == 0) { var fileBytes = File.ReadAllBytes(openDialog.FilePath.ToString()); await this.messagesViewModel.SendMessage(MessageType.File, $"{fileName}, {GetBytesReadable(fi.Length)}", fileBytes); _openFileDialogDirectory = openDialog.DirectoryPath.ToString(); } }
/// <summary> /// 產生資料到畫面上,請透過 GenerateDataModel 產生資料結構。 /// </summary> protected void RenderTreeView(bool reserveSelection) { if (reserveSelection) { ReserveTreeSelection(); } KeyCatalog userroot = new KeyCatalog(RootCaption, KCFactory); Task task = Task.Factory.StartNew((x) => { GenerateTreeStruct(x as KeyCatalog); }, userroot); task.ContinueWith(x => { if (x.Exception != null) { ErrorBox.Show(x.Exception.Message, x.Exception); } ATree.Nodes.Clear(); KeyCatalog rkc = x.AsyncState as KeyCatalog; if (ShowRoot) { KeyCatalog root = new KeyCatalog("", KCFactory); root.Subcatalogs.Add(rkc); RenderNodes(root, ATree.Nodes, RestoreLevel); } else { RenderNodes(rkc, ATree.Nodes, RestoreLevel); } foreach (Node n in ATree.Nodes) { n.Expand(); } }, UISyncContext); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); if (e.Args.Length > 0) { try { VersionFactory vf = new VersionFactory(); vf.CreateVersion( e.Args[0].Substring(1, e.Args[0].Length - 1), new Version(e.Args[1].Substring(1, e.Args[1].Length - 1)), e.Args[2].Substring(1, e.Args[2].Length - 1), e.Args[3].Substring(1, e.Args[3].Length - 1), e.Args[4].Substring(1, e.Args[4].Length - 1), e.Args[5].Substring(1, e.Args[5].Length - 1) ); Shutdown(); } catch (Exception exc) { string args = String.Empty; foreach (var item in e.Args) { args += Environment.NewLine + item; } ErrorBox.Show("Error", args, String.Empty); ErrorBox.Show("Error", exc); Shutdown(-1 * e.Args.Length); } } else { MainWindow mw = new MainWindow(); MainWindow = mw; mw.Closed += (s, ea) => Shutdown(); mw.Show(); } }
public Bitmap AddText(Image image, Font font, string text, Rectangle region) { if (image == null) { return(null); } var bmp = new Bitmap(image); try { var result = bmp.Clone(new Rectangle(0, 0, bmp.Width, bmp.Height), PixelFormat.Format32bppArgb); WriteTextToBitmapWithShadow(result, region, text, font); return(result); } catch (Exception ex) { ErrorBox.Show(ex, Timeout.Infinite); } return(bmp); }
private void OpenProject_Click(object sender, RoutedEventArgs e) { try { string projectName = (string)ctrProjectsLB.SelectedItem; string filePath = Directory.GetFiles(Properties.Settings.Default.ProjectsFolder, $"{projectName}.fis", SearchOption.AllDirectories).FirstOrDefault(); if (String.IsNullOrEmpty(filePath)) { throw new ArgumentException(nameof(filePath)); } ProjectService.OpenProject(filePath); (Window.GetWindow(this) as MainWindow).OpenPage(new ProjectPage(projectName)); } catch (Exception exp) { ErrorBox.Show(exp.Message); } }
private void Integrate(object dt) { FileIOPermission permission = new FileIOPermission(PermissionState.Unrestricted); permission.AllFiles = FileIOPermissionAccess.AllAccess; permission.Deny(); #if Release try { #endif Integrate((float)dt); #if Release } catch (ThreadAbortException) { Console.WriteLine("ThreadAbortException in Integrate"); } catch (ThreadInterruptedException) { Console.WriteLine("ThreadInterruptedException in Integrate"); } catch (Exception ex) { ErrorBox.DisplayError(ex); } #endif }
private void Browse_Click(object sender, RoutedEventArgs e) { try { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Fis files|*.fis"; ofd.Title = "Select a fis File"; if (ofd.ShowDialog() == true) { string fileName = System.IO.Path.GetFileNameWithoutExtension(ofd.FileName); ProjectService.OpenProject(ofd.FileName); (Window.GetWindow(this) as MainWindow).OpenPage(new ProjectPage(fileName)); } } catch (Exception exp) { ErrorBox.Show(exp.Message); } }
/// <summary> /// Switches to current instance. /// </summary> private static void SwitchToCurrentInstance() { IntPtr hWnd = GetCurrentInstanceWindowHandle(); if (hWnd != IntPtr.Zero) { // Restore window if minimised. Do not restore if already in // normal or maximized window state, since we don't want to // change the current state of the window. if (IsIconic(hWnd) != 0) { ShowWindow(hWnd, SW_RESTORE); } // Set foreground window. SetForegroundWindow(hWnd); } else // We couldn't find the other instance's window handle... { ErrorBox.Show("Another instance of this application is already running."); } }
/// <summary> /// Returns the current proxy based on the user selection /// </summary> /// <param name="proxy"></param> /// <returns></returns> private IHttpProxy GetCurrentProxy() { IHttpProxy proxy; string currentSelection = _availableProxies.Text; //proxies not yet initialized if (_initializedProxies.Count == 0 || String.IsNullOrWhiteSpace(currentSelection)) { return(null); } if (_initializedProxies.ContainsKey(currentSelection)) { proxy = _initializedProxies[currentSelection]; } else { ErrorBox.ShowDialog("Unrecognized proxy"); proxy = null; } return(proxy); }
private void removeToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult dr = ErrorBox.Show("The plugin \"" + this.treeView1.SelectedNode.Text + "\" will be\r\nremoved completely. Are you sure?", Application.ProductName, ErrorBoxButtons.YesNo, ErrorBoxIcon.Question); if (dr == DialogResult.Yes) { try { AvailablePlugin selectedPlugin = Global.Plugins.AvailablePlugins.Find(this.treeView1.SelectedNode.Text); if (selectedPlugin != null) { string assembly = null; for (int i = 0; i < selectedPlugin.AssemblyPath.Length; i++) { if (selectedPlugin.AssemblyPath[i] == '\\') { assembly = selectedPlugin.AssemblyPath.Remove(0, i + 1); } } assembly = assembly.Remove(assembly.Length - 4, 4); Global.Plugins.ClosePlugins(); //System.IO.File.Delete(Application.StartupPath + @"/plugins/" + assembly + @"/" + assembly + ".txt"); System.IO.File.Delete(Application.StartupPath + @"/plugins/" + assembly + @"/" + assembly + ".dll"); //System.IO.Directory.Delete(Application.StartupPath + @"/plugins/" + assembly); } else { MessageBox.Show("Can't find plugin directory!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("Error removing plugin! Original error:\r\n" + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
//포트 오픈 실행 private void SerialPortOpen() { try { //시리얼 포트에 내용 적용 serialPort1.PortName = com_str; serialPort1.Open(); //포트관련 설정 serialPort1.BaudRate = baudrate; serialPort1.Parity = Parity_to_Serial(parity_str); serialPort1.StopBits = StopBit_to_Serial(stopbit); serialPort1.DataBits = databit; PortInfo_Box.Text += "Port Open" + "\r\n"; ErrorBox.Clear(); } catch (Exception e) { ErrorBox.Text = string.Format("Error: {0}", e); PortInfo_Box.Text += "Error\r\n"; } }
private void TextBox_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { try { // Update the query builder with manually edited query text: QueryBuilder1.SQL = TextBox1.Text; // Hide error banner if any ErrorBox.Show(null, QueryBuilder1.SyntaxProvider); _lastValidSql = QueryBuilder1.FormattedSQL; } catch (SQLParsingException ex) { // Set caret to error position TextBox1.SelectionStart = ex.ErrorPos.pos; // Show banner with error text ErrorBox.Show(ex.Message, QueryBuilder1.SyntaxProvider); _errorPosition = ex.ErrorPos.pos; } }
protected void OnUpdateCompleted(bool successfulCheck, bool hasNewVersion, string message) { _WorkItem.UpdateRunning = false; _WorkItem.NotifyUpdateCompleted(); _Updater = null; //Updater can consume a lot of memory GC.Collect(); Kernel32.GropWorkingSet(); if (_SilentUpdate) { _SilentUpdate = false; return; } var wnd = _WorkItem.FindActiveWindow(); if (!successfulCheck) { ErrorBox.Show( Strings.APP_TITLE, Strings.UPDATE_CHECK_FAILED, message ); return; } if (!hasNewVersion) { MsgBox.Show( wnd, Strings.APP_TITLE, String.Format(Strings.NO_NEW_VERSION, Strings.APP_TITLE), false); } }
/// <summary> /// Runs this plugin passing it the specified Windows forms parent object. /// </summary> /// <param name="owner">The Windows forms parent object.</param> /// <returns> /// <c>true</c> if the execution was successful; otherwise, <c>false</c>. /// </returns> public override bool Run(IWin32Window owner) { try { base.Log.Verbose(string.Format("Running {0} plugin.", PluginName)); using (var form = new PluginMainForm()) { form.Plugin = this; form.ShowDialog(owner); } return(true); } catch (Exception ex) { base.Log.Error(ex); var message = string.Format( "There was an error while executing plugin {0}:\r\n\r\n{1}", PluginName, ex.Message); ErrorBox.Show(owner, message); return(false); } }
/// <summary> /// Redraws the control in response to a WinForms paint message. /// </summary> /// protected override void OnPaint(PaintEventArgs e) { try { string beginDrawError = BeginDraw(); if (string.IsNullOrEmpty(beginDrawError)) { // Draw the control using the GraphicsDevice. WinUpdate(); Global.Timer.Update(); GraphicsManager.Reset(); WinRender(); EndDraw(); } else { // If BeginDraw failed, show an error message using System.Drawing. PaintUsingSystemDrawing(e.Graphics, beginDrawError); } } catch (Exception err) { using (ErrorBox error = new ErrorBox(err)) error.ShowDialog(); } }
public override void doIterations() { try { base.doIterations(); // Fury Iteration BloodSurge BS = GetWrapper <BloodSurge>().ability as BloodSurge; AbilWrapper HS = GetWrapper <HeroicStrike>(); AbilWrapper CL = GetWrapper <Cleave>(); OnAttack _HS = HS.ability as OnAttack; OnAttack _CL = CL.ability as OnAttack; float ovdRage, hsRageUsed, clRageUsed; float oldBS, oldHS, oldCL; do { oldBS = BS.Activates; oldHS = HS.allNumActivates; oldCL = CL.allNumActivates; ovdRage = FreeRageOverDur; hsRageUsed = ovdRage * percHS; clRageUsed = ovdRage * percCL; WhiteAtks.HSOverridesOverDur = HS.numActivates = Math.Min(hsRageUsed / _HS.FullRageCost, WhiteAtks.MhActivatesNoHS); WhiteAtks.CLOverridesOverDur = CL.numActivates = Math.Min(clRageUsed / _CL.FullRageCost, WhiteAtks.MhActivatesNoHS - WhiteAtks.HSOverridesOverDur); BS.hsActivates = HS.allNumActivates; } while (Math.Abs(1f - (BS.Activates != 0 ? oldBS / BS.Activates : 1f)) > 0.005f || Math.Abs(1f - (HS.allNumActivates <= 0 ? oldHS / HS.allNumActivates : 1f)) > 0.005f || Math.Abs(1f - (CL.allNumActivates <= 0 ? oldCL / CL.allNumActivates : 1f)) > 0.005f); } catch (Exception ex) { ErrorBox eb = new ErrorBox("Error in performing Fury Iterations", ex.Message, "doIterations()", "No Additional Info", ex.StackTrace); eb.Show(); } }
private void runToolStripMenuItem1_Click(object sender, EventArgs e) { var attackTargetList = _testFile.GetAttackTargetList(); if (attackTargetList.Count == 0) //if still not set { string pattern = _testRunner.GetPatternOfRequestsToTest(); if (String.IsNullOrWhiteSpace(pattern)) { ErrorBox.ShowDialog(Resources.ErrorTestPatternMissing); return; } else { attackTargetList.Add("Default", new AttackTarget("Default", "Enabled", pattern)); _testFile.SetAttackTargetList(attackTargetList); } } SaveCurrent(); StartUI(); backgroundWorker1.RunWorkerAsync(); }