private void BrowseForm_Load(object sender, EventArgs e) { var info = DetailsPropertyGrid.GetType().GetProperty("Controls"); var collection = info.GetValue(DetailsPropertyGrid, null) as Control.ControlCollection; foreach (var control in collection) { var ctyp = control.GetType(); if (ctyp.Name == "PropertyGridView") { var prop = ctyp.GetField("labelRatio"); var val = prop.GetValue(control); prop.SetValue(control, 4.0); //somehow this sets the width of the property grid's label column... } } FolderTextBox.Text = Settings.Default.GTAFolder; DataHexLineCombo.Text = "16"; DataTextBox.SetTabStopWidth(3); HideTexturesTab(); try { GTA5Keys.LoadFromPath(Settings.Default.GTAFolder); KeysLoaded = true; UpdateStatus("Ready to scan..."); } catch { UpdateStatus("Keys not loaded! This should not happen."); } }
//on button click open serialport with set settings private void Button1_Click(object sender, EventArgs e) { try { //serial settings from app input serialPort.PortName = comboBoxComport.Text; serialPort.BaudRate = Convert.ToInt32(comboBoxBaudrate.Text); //hardcoded default serial settings serialPort.DataBits = 8; serialPort.Parity = Parity.None; serialPort.StopBits = StopBits.One; serialPort.Handshake = Handshake.None; serialPort.RtsEnable = false; serialPort.DtrEnable = true; serialPort.Open(); //tell the program that what the data receive handler is serialPort.DataReceived += new SerialDataReceivedEventHandler(SerialPort1_DataReceived); //change default button status to connect status. CONNECTEDSTATUS.Text = "CONNECTED"; ButtonOpen.Enabled = false; ButtonClose.Enabled = true; //add incoming data to DataBox and add CR+LF DataTextBox.AppendText(Environment.NewLine); DataTextBox.AppendText(String.Format("COMPORT OPEN", Environment.NewLine)); } //if failed catch the error and display error catch (Exception err) { MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ShowData(string s) { this.Dispatcher.Invoke(new Action(delegate { DataTextBox.AppendText($"[{DateTime.Now.ToString("HH:mm:ss.ffff")}]{s}\r\n"); DataTextBox.ScrollToEnd(); })); }
//if button 2 is clicked close the serialport and change status back private void Button2_Click(object sender, EventArgs e) { if (serialPort.IsOpen) { serialPort.Close(); ButtonOpen.Enabled = true; ButtonClose.Enabled = false; CONNECTEDSTATUS.Text = "DISCONNECTED"; DataTextBox.AppendText(Environment.NewLine); DataTextBox.AppendText(String.Format("COMPORT CLOSED", Environment.NewLine)); } }
/// <summary> /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. /// </summary> protected override void CreateChildControls() { Controls.Clear(); _hfGroupGuid = new HiddenField(); _hfGroupGuid.ID = this.ID + "_hfGroupGuid"; _hfGroupId = new HiddenField(); _hfGroupId.ID = this.ID + "_hfGroupId"; _hfGroupTypeId = new HiddenField(); _hfGroupTypeId.ID = this.ID + "_hfGroupTypeId"; _lblGroupName = new Literal(); _lblGroupName.ID = this.ID + "_lblGroupName"; _tbGroupName = new DataTextBox(); _tbGroupName.ID = this.ID + "_tbGroupName"; _tbGroupName.Label = "Group Name"; _cbIsActive = new RockCheckBox(); _cbIsActive.ID = this.ID + "_cbIsActive"; _cbIsActive.Text = "Active"; _ddlGroupRequirement = new RockDropDownList(); _ddlGroupRequirement.ID = this.ID + "_ddlGroupRequirement"; _ddlGroupRequirement.Label = "Group Requirement"; _ddlGroupRequirement.Help = "The requirement to add to this group. To add more than a single requirement, use the Group Viewer."; // set label when they exit the edit field _tbGroupName.Attributes["onblur"] = string.Format("javascript: $('#{0}').text($(this).val());", _lblGroupName.ID); _tbGroupName.SourceTypeName = "Rock.Model.Group, Rock"; _tbGroupName.PropertyName = "Name"; _phGroupAttributes = new PlaceHolder(); _phGroupAttributes.ID = this.ID + "_phGroupAttributes"; Controls.Add(_hfGroupGuid); Controls.Add(_hfGroupId); Controls.Add(_hfGroupTypeId); Controls.Add(_lblGroupName); Controls.Add(_tbGroupName); Controls.Add(_cbIsActive); Controls.Add(_ddlGroupRequirement); Controls.Add(_phGroupAttributes); // Locations Grid CreateLocationsGrid(); }
private void AddTestError(string error) { try { if (InvokeRequired) { Invoke(new Action(() => { AddTestError(error); })); } else { DataTextBox.AppendText(error); } } catch { } }
public void RefreshModInfo() { try { Mod m = selectedMod.Key; if (selectedMod.Value == ModDirection.Apply) { buttonPatchRom.Text = "Apply Mod"; } else if (selectedMod.Value == ModDirection.Remove) { buttonPatchRom.Text = "Remove Mod"; } else if (selectedMod.Value == ModDirection.Upgrade) { buttonPatchRom.Text = "Upgrade Mod"; } DataTextBox.Text = "FileName: " + m.FileName + Environment.NewLine; DataTextBox.AppendText( "Mod Identifier: " + m.ModIdent + Environment.NewLine); DataTextBox.AppendText( "Version: " + m.ModBuild + Environment.NewLine); DataTextBox.AppendText( "Author: " + m.ModAuthor + Environment.NewLine); DataTextBox.AppendText( "Description: " + m.ModInfo + Environment.NewLine); } catch (System.Exception excpt) { string derp = excpt.Message; DataTextBox.Clear(); buttonPatchRom.Enabled = false; buttonPatchRom.Text = "Select a patch"; } }
public void RefreshModInfo() { try { Mod m = sharpTuner.activeImage.ModList[selectedModIndex]; if (!sharpTuner.activeImage.ModList[selectedModIndex].isApplied) { buttonPatchRom.Text = "Apply Mod"; } else { buttonPatchRom.Text = "Remove Mod"; } DataTextBox.Text = "FileName: " + m.FileName + Environment.NewLine; DataTextBox.AppendText( "Mod Identifier: " + m.ModIdent + Environment.NewLine); DataTextBox.AppendText( "Version: " + m.ModBuild + Environment.NewLine); DataTextBox.AppendText( "Author: " + m.ModAuthor + Environment.NewLine); DataTextBox.AppendText( "Description: " + m.ModInfo + Environment.NewLine); } catch (System.Exception excpt) { string derp = excpt.Message; DataTextBox.Clear(); buttonPatchRom.Enabled = false; buttonPatchRom.Text = "Select a patch"; } }
private void CreateScenarioDataField_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { // remove binding BindingOperations.ClearAllBindings(DataTextBox); if (DataContext != null && DataContext is CellData) { var myCellData = DataContext as CellData; //set text binding var textBinding = new Binding() { Source = myCellData, Path = new PropertyPath("Content"), Mode = BindingMode.OneWayToSource, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; textBinding.ValidationRules.Add(new NumberValidationRule()); DataTextBox.SetBinding(TextBox.TextProperty, textBinding); //set icon if (DataContext is InputCellData) { DataIcon.Source = Resources["InputCellIcon"] as ImageSource; } else if (DataContext is IntermediateCellData) { DataIcon.Source = Resources["IntermediateCellIcon"] as ImageSource; } else if (DataContext is ResultCellData) { DataIcon.Source = Resources["OutputCellIcon"] as ImageSource; } else { DataIcon.Source = Resources["InputCellIcon"] as ImageSource; } } }
/////////////////////////////////////////////// ///Memory and closing functions. /////////////////////////////////////////////// /// <summary> /// Releases input file and calls garbage collector. /// </summary> private void Cleanup() { FilterStartButton.Enabled = false; try { //Garbage collector. GC.Collect(); GC.WaitForPendingFinalizers(); //Original file cleanup Marshal.ReleaseComObject(input.fullRange); Marshal.ReleaseComObject(input.currentSheet); input.currentWorkbook.Close(); Marshal.ReleaseComObject(input.currentWorkbook); DataTextBox.Clear(); ListBox.Clear(); IsFileLoaded = false; } catch (Exception ex) { MessageBox.Show("Error: No hay documento para cerrar."); } }
private void BinarySearchForm_Load(object sender, EventArgs e) { FileSearchFolderTextBox.Text = Settings.Default.CompiledScriptFolder; DataHexLineCombo.Text = "16"; DataTextBox.SetTabStopWidth(3); if (RpfMan == null) { Task.Run(() => { GTA5Keys.LoadFromPath(GTAFolder.CurrentGTAFolder, Settings.Default.Key); RpfMan = new RpfManager(); RpfMan.Init(GTAFolder.CurrentGTAFolder, UpdateStatus, UpdateStatus, false, false); RPFScanComplete(); }); } else { RPFScanComplete(); } }
private void ScenarioDataField_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { // remove binding BindingOperations.ClearAllBindings(DataTextBox); if (DataContext != null && DataContext is ScenarioData) { var scenarioData = DataContext as ScenarioData; //set text binding var textBinding = new Binding { Source = scenarioData, Path = new PropertyPath("Value"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; DataTextBox.SetBinding(TextBox.TextProperty, textBinding); //set icon if (DataContext is InputData) { DataIcon.Source = Resources["InputCellIcon"] as ImageSource; } else if (DataContext is InvariantData) { DataIcon.Source = Resources["IntermediateCellIcon"] as ImageSource; } else if (DataContext is ConditionData) { DataIcon.Source = Resources["OutputCellIcon"] as ImageSource; } } }
//print handler for text got from serialPort1_DataReceived function private void DisplayText(object o, EventArgs e) { //print text to datatextbox DataTextBox.AppendText(rxString); DataTextBox.ScrollToCaret(); }
private void openFileDialog1_FileOk(object sender, CancelEventArgs e) { try { string name = openFileDialog1.SafeFileName; if (name.Contains(".xlsx")) { _Application excel = new _Excel.Application(); Workbook wb; Worksheet ws; string path = "C:/Users/Geeth Sandaru/Downloads/" + name; wb = excel.Workbooks.Open(path); ws = wb.Worksheets[3]; //string deptTmp = ws.Cells[2, 1].Value2; int deptNo = 2; string text = ws.Cells[2, 1].Value2.ToString(); DataTextBox.Text = text + "\n"; string year = "", month = "", day = "", date = ""; int x = 7; int y = 6; while (x < 483) { if (ws.Cells[x, 1].Value2 != null) { string tmp = ws.Cells[x, 1].Value2.ToString(); if (!tmp.Equals(date)) { date = tmp; year = date.Substring(0, 4); month = date.Substring(5, 2); day = date.Substring(8, 2); double bagNo = ws.Cells[x, 2].Value2; double totalQty = ws.Cells[x, 4].Value2; DataTextBox.AppendText(year + "/" + month + "/" + day + " - " + bagNo + " - " + totalQty + "\n"); while (y < 1610) { if (ws.Cells[x, y].Value2 != null) { double qty = ws.Cells[x, y].Value2; string size = ws.Cells[4, y].Value2.ToString(); string color = ws.Cells[3, y].Value2.ToString(); string article = ""; int tmpY = y; do { try { article = ws.Cells[2, tmpY].Value2.ToString(); } catch (Exception) { article = "exc"; tmpY--; } } while (article.Equals("exc")); DataTextBox.AppendText(" " + size + " - " + color + " - " + article + " -- " + qty + "\n"); //DataTextBox.AppendText(" " + size + " - " + color + " -- " + qty + "\n"); } y++; } y = 6; } else { double bagNo = ws.Cells[x, 2].Value2; double totalQty = ws.Cells[x, 4].Value2; DataTextBox.AppendText("same" + " - " + bagNo + " - " + totalQty + "\n"); while (y < 1610) { if (ws.Cells[x, y].Value2 != null) { double qty = ws.Cells[x, y].Value2; string size = ws.Cells[4, y].Value2.ToString(); string color = ws.Cells[3, y].Value2.ToString(); string article = ""; int tmpY = y; do { try { article = ws.Cells[2, tmpY].Value2.ToString(); } catch (Exception) { article = "exc"; tmpY--; } } while (article.Equals("exc")); DataTextBox.AppendText(" " + size + " - " + color + " - " + article + " -- " + qty + "\n"); //DataTextBox.AppendText(" " + size + " - " + color + " -- " + qty + "\n"); } y++; } y = 6; } } x++; } //MySqlDataReader readerDept = DBConnection.getData("select * from department where deptName='" + deptTmp + "'"); /* * if (/*readerDept.HasRows true) * { * string date = ws.Cells[7, 1].Value2.ToString(); * double totalQty = ws.Cells[7, 4].Value2; * double dayBagNo = ws.Cells[7, 2].Value2; * * string day = date.Substring(1, date.IndexOf('/') - 1); * string tmpMonth = date.Substring(date.IndexOf('/') + 1); * string month = tmpMonth.Substring(0, tmpMonth.IndexOf('/')); * string year = tmpMonth.Substring((tmpMonth.IndexOf('/') + 1), 4); * * DateTime d = new DateTime(Int32.Parse(year), Int32.Parse(month), Int32.Parse(day)); * int q = (int)totalQty; * int bNo = (int)dayBagNo; * Department dept = new Department((int)deptNo); * * Bag bag = new Bag(d, q, dept, bNo); * * if (/*Database.isBagExists(bag) false) * { * MessageBox.Show("Bag already exists!", "File reader", MessageBoxButtons.OK, MessageBoxIcon.Error); * } * else * { * DataTextBox.Text = "Bag deptNo : " + deptNo + "\nBag sent date : " + date + "\nQuantity : " + totalQty + "\nBagNo : " + dayBagNo + "\n"; * DataTextBox.AppendText("\nyear : " + year + " " + d.Year); * DataTextBox.AppendText("\nmonth : " + month + " " + d.Month); * DataTextBox.AppendText("\nday : " + day + " " + d.Day + "\n\n"); * * for (int i = 0; i < (int)totalQty; i++) * { * string color = ws.Cells[(i + 5), 1].Value2; * string size = ws.Cells[(i + 5), 2].Value2; * string article = ws.Cells[(i + 5), 3].Value2; * * string tmp = "\nItem " + (i + 1) + " : " + color + " " + size + " " + article; * * DataTextBox.AppendText(tmp); * * bag.addItem(i, color, size, article); * } * * try * { * MySqlDataReader reader = DBConnection.getData("select * from department"); * * while (reader.Read()) * { * int dNo = reader.GetInt32("deptNo"); * string deptName = reader.GetString("deptName"); * * string tmp2 = "\nDept : " + dNo + " " + deptName; * * DataTextBox.AppendText(tmp2); * } * * reader.Close(); * * Database.saveBag(bag); * } * catch (Exception exc) * { * DataTextBox.AppendText("\n" + exc.Message); * DataTextBox.AppendText("\n\n" + exc.StackTrace); * } * finally * { * wb.Close(); * excel.Quit(); * * Marshal.ReleaseComObject(wb); * Marshal.ReleaseComObject(excel); * } * } * } * else * { * MessageBox.Show("Wrong Department name in the Excel file!", "File reader", MessageBoxButtons.OK, MessageBoxIcon.Error); * }*/ } } catch (Exception exception) { MessageBox.Show("Something wrong with the excel file!\n" + exception.StackTrace, "File reader", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Set the focus to this data text box /// </summary> public void SetFocus() { DataTextBox.Focus(); }
/// <summary> /// Set the focus to this data text box /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SetFocus(object sender, EventArgs e) { DataTextBox.Focus(); }
private void ClearDataTextBoxButton_Click(object sender, EventArgs e) { //clear text in datatextbox on button press DataTextBox.Clear(); }
private void ClearDataButton_Click(object sender, RoutedEventArgs e) { DataTextBox.Clear(); }
private void DisplayFileContentsText(RpfFileEntry rfe, byte[] data, int length, int offset) { if (data == null) { Cursor = Cursors.Default; DataTextBox.Text = "[Error extracting file! " + rfe.File.LastError + "]"; return; } int selline = -1; int selstartc = -1; int selendc = -1; if (DataHexRadio.Checked) { int charsperln = int.Parse(DataHexLineCombo.Text); int lines = (data.Length / charsperln) + (((data.Length % charsperln) > 0) ? 1 : 0); StringBuilder hexb = new StringBuilder(); StringBuilder texb = new StringBuilder(); StringBuilder finb = new StringBuilder(); if (offset > 0) { selline = offset / charsperln; } for (int i = 0; i < lines; i++) { int pos = i * charsperln; int poslim = pos + charsperln; hexb.Clear(); texb.Clear(); hexb.AppendFormat("{0:X4}: ", pos); for (int c = pos; c < poslim; c++) { if (c < data.Length) { byte b = data[c]; hexb.AppendFormat("{0:X2} ", b); if (char.IsControl((char)b)) { texb.Append("."); } else { texb.Append(Encoding.ASCII.GetString(data, c, 1)); } } else { hexb.Append(" "); texb.Append(" "); } } if (i == selline) { selstartc = finb.Length; } finb.AppendLine(hexb.ToString() + "| " + texb.ToString()); if (i == selline) { selendc = finb.Length - 1; } } DataTextBox.Text = finb.ToString(); } else { string text = Encoding.UTF8.GetString(data); DataTextBox.Text = text; if (offset > 0) { selstartc = offset; selendc = offset + length; } } if ((selstartc > 0) && (selendc > 0)) { DataTextBox.SelectionStart = selstartc; DataTextBox.SelectionLength = selendc - selstartc; DataTextBox.ScrollToCaret(); } }
/// <summary> /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. /// </summary> protected override void CreateChildControls() { Controls.Clear(); _lblGroupTypeName = new Label(); _lblGroupTypeName.ClientIDMode = ClientIDMode.Static; _lblGroupTypeName.ID = this.ID + "_lblGroupTypeName"; _tbGroupTypeName = new DataTextBox(); _tbGroupTypeName.ID = this.ID + "_tbGroupTypeName"; _tbGroupTypeName.Label = _rowLabel; // set label when they exit the edit field _tbGroupTypeName.Attributes["onblur"] = string.Format("javascript: $('#{0}').text($(this).val());", _lblGroupTypeName.ClientID); _tbGroupTypeName.SourceTypeName = "Rock.Model.GroupType, Rock"; _tbGroupTypeName.PropertyName = "Name"; _ddlGroupTypeInheritFrom = new RockDropDownList(); _ddlGroupTypeInheritFrom.ID = this.ID + "_ddlGroupTypeInheritFrom"; _ddlGroupTypeInheritFrom.Label = "Inherit from"; _ddlGroupTypeInheritFrom.Items.Add(Rock.Constants.None.ListItem); var groupTypeCheckinFilterList = new GroupTypeService(new RockContext()).Queryable() //.Where( a => a.GroupTypePurposeValue.Guid == new Guid( Rock.SystemGuid.DefinedValue.GROUPTYPE_PURPOSE_CHECKIN_FILTER ) ) .OrderBy(a => a.Order).ThenBy(a => a.Name) .Select(a => new { a.Id, a.Name }).ToList(); foreach (var groupType in groupTypeCheckinFilterList) { _ddlGroupTypeInheritFrom.Items.Add(new ListItem(groupType.Name, groupType.Id.ToString())); } _ddlGroupTypeInheritFrom.AutoPostBack = true; _ddlGroupTypeInheritFrom.SelectedIndexChanged += _ddlGroupTypeInheritFrom_SelectedIndexChanged; _phGroupTypeAttributes = new PlaceHolder(); _phGroupTypeAttributes.ID = this.ID + "_phGroupTypeAttributes"; _ddlAttendanceRule = new RockDropDownList(); _ddlAttendanceRule.ID = this.ID + "_ddlAttendanceRule"; _ddlAttendanceRule.Label = "Check-in Rule"; _ddlAttendanceRule.Help = "The rule that check in should use when a person attempts to check in to a group of this type. If 'None' is selected, user will not be added to group and is not required to belong to group. If 'Add On Check In' is selected, user will be added to group if they don't already belong. If 'Already Belongs' is selected, user must already be a member of the group or they will not be allowed to check in."; _ddlAttendanceRule.BindToEnum <Rock.Model.AttendanceRule>(); _ddlPrintTo = new RockDropDownList(); _ddlPrintTo.ID = this.ID + "_ddlPrintTo"; _ddlPrintTo.Label = "Print To"; _ddlPrintTo.Help = "When printing check-in labels, should the device's printer or the location's printer be used? Note: the device has a similar setting which takes precedence over this setting."; _ddlPrintTo.Items.Add(new ListItem("Device Printer", "1")); _ddlPrintTo.Items.Add(new ListItem("Location Printer", "2")); Controls.Add(_lblGroupTypeName); Controls.Add(_ddlGroupTypeInheritFrom); Controls.Add(_ddlAttendanceRule); Controls.Add(_ddlPrintTo); Controls.Add(_tbGroupTypeName); Controls.Add(_phGroupTypeAttributes); // Check-in Labels grid CreateCheckinLabelsGrid(); }