public static int GetCorruptionChecksum() { int[,] values = TBox.Get2DArrayOfInts(path, '\t'); int sum = 0; for (int i = 0; i < values.GetLength(0); i++) { int lowest = values[i, 0]; int highest = lowest; for (int j = 0; j < values.GetLength(1); j++) { if (lowest > values[i, j]) { lowest = values[i, j]; } if (highest < values[i, j]) { highest = values[i, j]; } } sum += highest - lowest; } return(sum); }
private GenericInputDialog() { InitializeComponent(); RootGrid.DataContext = this; TBox.Focus(); Keyboard.Focus(TBox); }
private void Button_Click(object sender, RoutedEventArgs e) { //применяем твики для которых посталены чекбоксы for (int i = 0; i < count; i++) { bool isChecked = (bool)checks[i].IsChecked; if (isChecked) { TBox.AppendText(regTweaks[i].SaveNewValue()); if (regTweaks[i].CmdExist) { //запуск процесса с смд Process cmd = new Process(); cmd.StartInfo.FileName = "cmd.exe"; //cmd.StartInfo.Arguments = "/C " + regTweaks[i].Cmd; cmd.StartInfo.RedirectStandardOutput = true; cmd.StartInfo.CreateNoWindow = true; cmd.StartInfo.UseShellExecute = false; cmd.Start(); cmd.StandardInput.WriteLine("/C " + regTweaks[i].Cmd); cmd.StandardInput.Flush(); cmd.StandardInput.Close(); cmd.WaitForExit(); TBox.AppendText(cmd.StandardOutput.ReadToEnd()); } } } }
public static int GetCorruptionCheckSumDiv() { int[,] values = TBox.Get2DArrayOfInts(path, '\t'); int sum = 0; for (int i = 0; i < values.GetLength(0); i++) { int firstComparer = values[i, 0]; for (int j = 0; j < values.GetLength(1); j++) { firstComparer = values[i, j]; int secondComparer = values[i, j]; for (int l = 0; l < values.GetLength(1); l++) { secondComparer = values[i, l]; if ((firstComparer != secondComparer) && firstComparer % secondComparer == 0) { sum += firstComparer / secondComparer; } } } } return(sum); }
protected void OpenFile() { try { TBox.Clear(); TBox.Text = File.ReadAllText(filename); } catch (IOException ex) { MessageBox.Show(ex.Message, "Simple Editor", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
/// <summary> /// Gets the (immutable) value the reference is holding. /// </summary> /// <returns>The value</returns> public override object deref() { TBox b = getThreadBinding(); if (b != null) { return(b.Val); } return(_root); //if (hasRoot()) // return _root; //throw new InvalidOperationException(String.Format("Var {0}/{1} is unbound.", _ns,_sym)); }
private void OnBaseKeyDown(object s, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.A) { TBox.SelectAll(); e.SuppressKeyPress = true; } if (e.Control && e.KeyCode == Keys.C) { TBox.Copy(); e.SuppressKeyPress = true; } }
public static Associative getThreadBindings() { Frame f = CurrentFrame; IPersistentMap ret = PersistentHashMap.EMPTY; for (ISeq bs = f.Bindings.seq(); bs != null; bs = bs.next()) { IMapEntry e = (IMapEntry)bs.first(); Var v = (Var)e.key(); TBox b = (TBox)e.val(); ret = ret.assoc(v, b.Val); } return(ret); }
public object set(object val) { Validate(getValidator(), val); TBox b = getThreadBinding(); if (b != null) { if (Thread.CurrentThread != b.Thread) { throw new InvalidOperationException(String.Format("Can't set!: {0} from non-binding thread", sym)); } return(b.Val = val); } throw new InvalidOperationException(String.Format("Can't change/establish root binding of: {0} with set", _sym)); }
private void MainWindow_Loaded(object s, RoutedEventArgs e) { for (int i = 0; i < count; i++) // цикл для создания визуальнх компоненнтов { TBox.AppendText(inifiles[i] + "\n"); regTweaks[i] = ReadiniFile(inifiles[i]); //заполнение массива с твиками tbarray[i] = new TextBlock { Text = regTweaks[i].Name + "\t" }; //заполнение массива с текстблоками checks[i] = new CheckBox { Margin = new Thickness(5, 5, 5, 5) }; //заполнение массива с чекбоксами if (regTweaks[i].ValueExist) { if (regTweaks[i].NewValue.ToString() != regTweaks[i].KeyValue.ToString()) { checks[i].IsChecked = true; tbarray[i].Text += regTweaks[i].ValueName; } else { checks[i].IsEnabled = false; tbarray[i].Text += "уже выполнено"; } } else { checks[i].IsChecked = true; tbarray[i].Text += "не найдено"; } stackpan1.Children.Add(tbarray[i]); stackpan1.Children.Add(checks[i]); } //System.IO.Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName); //имя без расширения //System.Environment.GetCommandLineArgs()[0];// полный путь }
// восстановление образа public TBox Find(TBox BS, int T = 1000) { TBox B = new TBox(BS); TBox B2 = new TBox(B); for (int t = 0; t < T; t++) { for (int j = 0; j < N; j++) { double d = 0; for (int i = 0; i < N; i++) { d += w[j, i] * B[i]; } if (d > 0) { B2[j] = 1; } else { B2[j] = -1; } } B = new TBox(B2); if (Boxes.Find(B)) { return(B); } } return(null); }
private void Butt1_Click(object sender, RoutedEventArgs e) { TBox.Clear(); }
private void TBox_TextChanged (object sender, TextChangedEventArgs e) { TBox.Select(this.TBox.Text.Length, 0); }