public List<Container> CalculateLoadScheme(List<Container> containers, ObservableCollection<Vehicle> selectedVehicles, TextBox textBox, int maxTonnage) { // BtnCalculate_click int tempMaxTonnage; var widthBetweenVehicles = 1000; var tempPoint = new Point3D(0, 0, 0); textBox.Clear(); textBox.AppendText("Протокол расчета схемы загрузки:\n"); var tempList = RotateContainers(containers); foreach (var vehicle in selectedVehicles) { LocateContainers locateContainers = new LocateContainers(vehicle); tempMaxTonnage = maxTonnage == 0 ? vehicle.Tonnage : maxTonnage; tempList = locateContainers.DownloadContainers(tempList, tempMaxTonnage); SetFirstPoint(tempPoint,vehicle); tempPoint.Y = tempPoint.Y + widthBetweenVehicles + vehicle.Width;// TODO tempPoint.Z = tempPoint.Z + widthBetweenVehicles + vehicle.Width; PutCargoInfoInTextBox(vehicle, textBox); CheckOverweight(vehicle, textBox, tempMaxTonnage); VehicleAxisMass vehicleAxisMass = new VehicleAxisMass(vehicle, vehicle.Mass); PutVehAxisMassInfoInTextBox(vehicleAxisMass.AxisMassCalculate(), textBox); } PutWasteContainersInfoInTextBox(tempList, textBox); CheckErrors(tempList, textBox, selectedVehicles, containers); return tempList; }
private void RemoveAndClearItem(TextBox tb, ListBox lb) { if (lb.Items.Contains(tb.Text)) { lb.Items.Remove(tb.Text); tb.Clear(); } }
private static void RemoveAndClearItem(TextBox tb, ItemsControl lb) { if (lb.Items.Contains(tb.Text)) { lb.Items.Remove(tb.Text); tb.Clear(); } }
void checkNumBox(TextBox box) { int convertedText = 0; if (!int.TryParse(box.Text, out convertedText)) { box.Clear(); } }
//DEC TO BIN private void bin(int dec, TextBox text) { text.Clear(); for(int i=15;i>=0;i--) { if (i == 7) text.Text += " "; text.Text += Convert.ToString((dec >> i) % 2); } }
public static void Limpiar(TextBox t1, TextBox t2 = null, TextBox t3 = null) { t1.Clear(); if (t2 != null) t2.Clear(); if (t3 != null) t3.Clear(); t1.Focus(); }
public void ButtonCode(int GBATotal, int NDSTotal, bool GBA, bool NDS, TextBox ButtonInput, TextBox ButtonOutput, TextBox NDSTst, TextBox GBATst) { //NOT_GBA and NOT_NDS will hold the //16-bit values of NOT_GBATotal and NOT_NDSTotal string D2 = "D2000000 00000000"; ushort NOT_GBA = (ushort)~GBATotal; ushort NOT_NDS = (ushort)~NDSTotal; if (GBATotal != 0) GBA = true; if (NDSTotal != 0) NDS = true; if (GBA == true) { ButtonOutput.Text = "94000130 " + NOT_GBA.ToString("X") + "0000\n" + ButtonInput.Text + '\n' + D2; GBATst.Text = "GBA tst Value: 0x" + GBATotal.ToString("X4"); } else GBATst.Clear(); if (NDS == true) { ButtonOutput.Text = "927FFFA8 " + NOT_NDS.ToString("X") + "0000\n" + ButtonInput.Text + '\n' + D2; NDSTst.Text = "NDS tst Value: 0x" + NDSTotal.ToString("X4"); } else NDSTst.Clear(); if (GBA == true && NDS == true) { ButtonOutput.Text = "927FFFA8 " + NOT_NDS.ToString("X") + "0000\n94000130 " + NOT_GBA.ToString("X") + "0000\n" + ButtonInput.Text + '\n' + D2; } else if (GBA == false && NDS == false) { ButtonOutput.Clear(); GBATst.Clear(); NDSTst.Clear(); } }
void checkTextBox(TextBox box) { if (box.Text.Intersect(forbiddenChars).Any()) { box.Clear(); } if (box.Text.Intersect(smallChars).Any()) { box.Text = box.Text.ToUpper(); box.SelectionStart = box.Text.Length; box.SelectionLength = 0; } }
/// <summary> /// 清空应用该附加属性的父TextBox内容函数 /// </summary> /// <param name="sender">发送对象</param> /// <param name="e">路由事件参数</param> public static void ClearTextClicked(object sender, RoutedEventArgs e) { System.Windows.Controls.Button btn = sender as System.Windows.Controls.Button; if (btn != null) { var parent = VisualTreeHelper.GetParent(btn); while (!(parent is System.Windows.Controls.TextBox)) { parent = VisualTreeHelper.GetParent(parent); } System.Windows.Controls.TextBox txt = parent as System.Windows.Controls.TextBox; if (txt != null) { txt.Clear(); } } }
/// <summary> /// key up del gridProductosInventario /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void key_KeyUp(object sender, KeyEventArgs e) { try { if (e.Key == Key.Tab || e.Key == Key.Enter) { TextBox tb = (sender as TextBox); if (tb != null) { if (tb.Text == "0.00") { tb.Clear(); } } } } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
public ApplicationCanvas() { r.Fill = Brushes.LightGray; r.AttachTo(this); r.MoveTo(4, 4); this.SizeChanged += (s, e) => r.SizeTo(this.Width - 8.0, this.Height - 8.0); var label1 = new TextBlock { Text = "Enter a list of names separated by commas", }.AttachTo(this).MoveTo(8, 8); var users = new TextBox { AcceptsReturn = true, TextWrapping = System.Windows.TextWrapping.Wrap, Width = 500, Height = 50, Text = "_martin, mike, mac, ken, neo, zen, jay, morpheous, trinity, Agent Smith, _psycho", }.AttachTo(this).MoveTo(8, 8 + 32); var label2 = new TextBlock { Text = "Enter a partial name to be found from the list above.", }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8); var filter = new TextBox { Width = 500, Text = "psy", }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 16); var label3 = new TextBlock { Text = "Enter a partial name to make the entry special", }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 58); var filter2 = new TextBox { Width = 500, Text = "a", }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 16 + 58); var label4 = new TextBlock { Text = "Results", }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 58 + 58); var result = new TextBox { AcceptsReturn = true, TextWrapping = System.Windows.TextWrapping.Wrap, Background = Brushes.Transparent, BorderThickness = new Thickness(0), Width = 500, Height = 50, Text = "?", TextAlignment = System.Windows.TextAlignment.Right, IsReadOnly = true, }.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 16 + 58 + 58); Action Update = delegate { var user_filter = filter.Text.Trim().ToLower(); var user_filter2 = filter2.Text.Trim().ToLower(); result.Clear(); var __users = users.Text.Split(','); var query = from i in __users where i.ToLower().Contains(user_filter) let name = i.Trim() let isspecial = i.ToLower().Contains(user_filter2) orderby isspecial ascending, name.Length descending, name select new { isspecial, length = name.Length, name }; foreach (var v in query) { var m = "match: " + v; if (v.isspecial) m = m.ToUpper(); result.AppendText(m + Environment.NewLine); } }; Update(); users.TextChanged += delegate { Update(); }; filter.TextChanged += delegate { Update(); }; filter2.TextChanged += delegate { Update(); }; }
public static void WriteError(this System.Windows.Controls.TextBox box, string text) { box.Clear(); box.Foreground = ColorCode.ERROR; box.AppendText(text); }
public static void Write(this System.Windows.Controls.TextBox box, string text) { box.Clear(); box.Foreground = Brushes.Black; box.AppendText(text); }
bool checkLanguage(TextBox box) { bool result = true; if (language == Alphabet.English) { if (box.Text.Intersect(Cezar.ALPHABET_RU).Any()) { box.Clear(); result = false; } } if (language == Alphabet.Russian) { if (box.Text.Intersect(Cezar.ALPHABET_EN).Any()) { box.Clear(); result = false; } } return result; }
//function sending workers to rest private void rest(TextBox text) { int freePositions = Convert.ToInt32(tbNumber.Text) + 1; if (text.IsEnabled == true) { load.amountWorkers = load.amountWorkers - 1; text.IsEnabled = false; auxFill(); tbNumber.Text = Convert.ToString(freePositions); text.Clear(); } else MessageBox.Show("This position is not filled!"); }
private static void AddItemFromTextBox(TextBox tb, ItemsControl lb) { lb.Items.Add(tb.Text); tb.Clear(); }
//aux function for a damage timer, its sending workers to rest private void auxRestAfterDamage(TextBox text) { //during breakdown int freePositions = Convert.ToInt32(tbNumber.Text) + 1; load.amountWorkers = load.amountWorkers - 1; text.IsEnabled = false; auxFill(); tbNumber.Text = Convert.ToString(freePositions); text.Clear(); }
public static void Clean(TextBox textbox) { textbox.Clear(); }
private decimal Parse(TextBox txt) { decimal var; try { if (!String.IsNullOrWhiteSpace(txt.Text)) { // Try to parse param if it's not null var = decimal.Parse(txt.Text); } else { var = 0m; } } catch { // Clear and focus on error location. Prompt user as to where the error occurred using the ToolTip txt.Clear(); txt.Focus(); throw new Exception("Error! Value of " + txt.ToolTip.ToString() + " required as a decimal"); } return var; }
private void ConstructObjects() { var lbStation = new Label(); lbStation.Content = "選擇站別 ( * ) :"; var bStation = new Border(); bStation.Width = 300; bStation.Height = 40; bStation.Background = Brushes.White; bStation.BorderBrush = Brushes.White; bStation.BorderThickness = new Thickness(5); var cbstation = new ComboBox(); cbstation.Items.Add(StationName.gStationA); cbstation.Items.Add(StationName.gStationB); cbstation.Items.Add(StationName.gStationC); //cbstation.Items.Add(StationName.gStationD); cbstation.Items.Add(StationName.gStationE); cbstation.Items.Add(StationName.gStationF); cbstation.Items.Add(StationName.gStationG); bStation.Child = cbstation; cbstation.SelectionChanged += cbstation_SelectionChanged; var spName = new StackPanel(); spName.HorizontalAlignment = HorizontalAlignment.Left; var lbUsername = new Label(); lbUsername.Content = "操作人員 ( * ) :"; var txtboxUsername = new TextBox(); txtboxUsername.Height = 30; txtboxUsername.Width = 150; txtboxUsername.KeyUp += txtboxUsername_KeyUp; spName.Children.Add(lbUsername); spName.Children.Add(txtboxUsername); var lbLogin = new Label(); lbLogin.Content = SigknowDBServer.gServer; var buttonLogin = new Button(); buttonLogin.Content = "登入"; buttonLogin.Click += buttonLogin_Click; buttonLogin.Height = 30; buttonLogin.Width = 50; var spServer = new StackPanel(); spServer.HorizontalAlignment = HorizontalAlignment.Left; var lbServer = new Label(); lbServer.Content = "資料庫網址 ( * ) :"; var txtboxServer = new TextBox(); txtboxServer.Height = 30; txtboxServer.Width = 150; txtboxServer.KeyUp += txtboxServer_KeyUp; var buttonServer = new Button(); buttonServer.Content = "設定"; buttonServer.Click += buttonServer_Click; buttonServer.Height = 30; buttonServer.Width = 50; Utils.changeTextboxLang2Eng(txtboxServer); var lbReport = new Label(); lbReport.Content = ""; spServer.Children.Add(lbServer); spServer.Children.Add(txtboxServer); var buttonReport = new Button(); buttonReport.Content = "匯出資料"; buttonReport.Click += buttonReport_Click; buttonReport.Height = 30; buttonReport.Width = 100; StackPanel spMainBody = new StackPanel(); spMainBody.HorizontalAlignment = HorizontalAlignment.Left; spMainBody.Children.Add(spServer); spMainBody.Children.Add(buttonServer); spMainBody.Children.Add(lbStation); spMainBody.Children.Add(bStation); spMainBody.Children.Add(spName); spMainBody.Children.Add(lbLogin); spMainBody.Children.Add(buttonLogin); spMainBody.Children.Add(lbReport); spMainBody.Children.Add(buttonReport); txtboxServer.Clear(); txtboxServer.Focus(); Content = spMainBody; }
//checks whether textbox content > 255 when 3 characters have been entered. //clears if > 255, switches to next textbox otherwise private void handleTextChange(TextBox currentBox, TextBox rightNeighborBox) { if (currentBox.Text.Length == 3) { try { Convert.ToByte(currentBox.Text); } catch (Exception exception) when (exception is FormatException || exception is OverflowException) { currentBox.Clear(); currentBox.Focus(); SystemSounds.Beep.Play(); MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (currentBox.CaretIndex != 2 && currentBox != fourthBox) { rightNeighborBox.CaretIndex = rightNeighborBox.Text.Length; rightNeighborBox.SelectAll(); rightNeighborBox.Focus(); } } }
void printToBox(TextBox box, byte[] array) { box.Clear(); foreach (byte num in array) { if (num == 0 || num == 4) continue; box.Text += num + " "; } }
private void AddItemFromTextbox(TextBox tb, ListBox lb) { lb.Items.Add(tb.Text); tb.Clear(); }
void printToBox(TextBox box, int[] array) { box.Clear(); foreach (byte num in array) { //if (num == 0) continue; box.Text += num + " "; } }
//文本字符串处理 private void tbstringfun(TextBox TB, int math, string ct) { switch (math) { //插入处理 case 0: selectPos = TB.SelectionStart; TB.Text = TB.Text.Substring(0, selectPos) + ct + TB.Text.Substring(selectPos); selectPos += 1; TB.Focus(); TB.Select(selectPos, 0); break; //替换处理 case 1: selectPos = TB.SelectionStart; TB.Text = TB.Text.Substring(0, selectPos - 1) + ct + TB.Text.Substring(selectPos); TB.Focus(); TB.Select(selectPos, 0); break; //删除一个字符 case 2: if (!string.IsNullOrEmpty(TB.Text)) { selectPos = TB.SelectionStart; if (selectPos != 0) { TB.Text = TB.Text.Substring(0, selectPos - 1) + TB.Text.Substring(selectPos); selectPos -= 1; TB.Focus(); TB.Select(selectPos, 0); } } break; //清除文本 case 3: TB.Clear(); break; } }
private void DrawSudoku(GenerateSudoku sudoku) { ContextMenu menu = new ContextMenu(); menu.Background = Brushes.White; for (int i = 0; i <= 9; i++) { MenuItem item = new MenuItem(); item.Header = i.ToString(); menu.Items.Add(item); item.Click += item_Click; } for (int i = 0; i < sudoku.n * sudoku.n; i++) { for (int j = 0; j < sudoku.n * sudoku.n; j++) { TextBox txtBox = new TextBox(); txtBox.Name = "n" + i.ToString() + j.ToString(); txtBox.Height = 30; txtBox.Width = 30; txtBox.FontSize = 16; txtBox.Foreground = Brushes.Black; txtBox.FontWeight = FontWeights.Bold; txtBox.BorderThickness = new Thickness(1.0); txtBox.TextAlignment = TextAlignment.Center; txtBox.Text = sudoku.removed_arr[i, j].ToString(); Grid.SetColumn(txtBox, i); Grid.SetRow(txtBox, j); grdSudoku.Children.Add(txtBox); txtBox.IsReadOnly = true; txtBox.SelectionBrush = Brushes.White; txtBox.BorderBrush = Brushes.White; if (txtBox.Text == "0") { txtBox.Clear(); txtBox.ContextMenu = menu; txtBox.ContextMenuClosing += tb_ContextMenuClosing; txtBox.SelectionBrush = Brushes.Green; } } } }