Example #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // 開檔
            string[] lines = System.IO.File.ReadAllLines(@"D:\temp\data.txt");

            // 分析每一行
            foreach (string line in lines)
            {
                // 用│符號拆開
                string[] parts = line.Split('│');

                // 建立ToDoBall
                ToDoBall ball = new ToDoBall();
                ball.BallNames = parts[1];

                // 是否打勾
                if (parts[0] == "O")
                {
                    ball.Checked = true;
                }
                else
                {
                    ball.Checked = false;
                }

                // 放進清單裡
                ToDoThings.Children.Add(ball);
            }
        }
Example #2
0
        private void Button_MouseDown(object sender, MouseButtonEventArgs e)
        {
            // 新增事件標籤
            ToDoBall ball = new ToDoBall();

            // 放入ToDoThings
            ToDoThings.Children.Add(ball);

            // 根據種類變換標籤顏色
            if (Study.IsChecked == true)
            {
                ball.Background = Brushes.LightBlue;
            }

            if (Home.IsChecked == true)
            {
                ball.Background = Brushes.LightCyan;
            }

            if (Club.IsChecked == true)
            {
                ball.Background = Brushes.Khaki;
            }

            if (Work.IsChecked == true)
            {
                ball.Background = Brushes.Pink;
            }

            if (Others.IsChecked == true)
            {
                ball.Background = Brushes.Beige;
            }

            STalk();
        }