コード例 #1
0
        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);
        }
コード例 #2
0
 private GenericInputDialog()
 {
     InitializeComponent();
     RootGrid.DataContext = this;
     TBox.Focus();
     Keyboard.Focus(TBox);
 }
コード例 #3
0
        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());
                    }
                }
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 protected void OpenFile()
 {
     try
     {
         TBox.Clear();
         TBox.Text = File.ReadAllText(filename);
     }
     catch (IOException ex)
     {
         MessageBox.Show(ex.Message, "Simple Editor", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
コード例 #6
0
ファイル: Var.cs プロジェクト: willemdijkgraaf/ClojureClr
        /// <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));
        }
コード例 #7
0
 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;
     }
 }
コード例 #8
0
ファイル: Var.cs プロジェクト: willemdijkgraaf/ClojureClr
        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);
        }
コード例 #9
0
ファイル: Var.cs プロジェクト: willemdijkgraaf/ClojureClr
        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));
        }
コード例 #10
0
        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];// полный путь
        }
コード例 #11
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);
        }
コード例 #12
0
 private void Butt1_Click(object sender, RoutedEventArgs e)
 {
     TBox.Clear();
 }
コード例 #13
0
 private void TBox_TextChanged
     (object sender, TextChangedEventArgs e)
 {
     TBox.Select(this.TBox.Text.Length, 0);
 }