Exemplo n.º 1
0
        private void Listview1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Card card = (Card)listview1.SelectedItem;

            RichText1.Document.Blocks.Clear();
            RichText1.AppendText(card.Effect);
        }
Exemplo n.º 2
0
 public void AppendText(string text)
 {
     Application.Current.Dispatcher.Invoke(() => {
         RichText1.AppendText($"{text}\n");
         RichText1.ScrollToEnd();
     });
 }
Exemplo n.º 3
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            RichText1.Document.Blocks.Clear();

            int testTimes = 100000000;

            int[] arr = new int[testTimes];
            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = i;
            }

            System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();

            watch.Reset();
            watch.Start();
            //代码
            int s = 0;
            int n = arr.Length * 2;

            for (int i = 0; i < n; i++)
            {
                if (i >= 0 && i < arr.Length)
                {
                    s += arr[i];
                }
            }

            watch.Stop();

            RichText1.AppendText("方法1:" + watch.ElapsedMilliseconds.ToString() + Environment.NewLine + Environment.NewLine);

            watch.Reset();
            watch.Start();
            //代码

            s = 0;
            int m = n < arr.Length ? n : arr.Length;

            for (int i = 0; i < m; i++)
            {
                s += arr[i];
            }

            watch.Stop();

            RichText1.AppendText("方法2:" + watch.ElapsedMilliseconds.ToString() + Environment.NewLine + Environment.NewLine);
        }