public void CreateChartArea(string name, List <DateTime> lsTime, List <string> count)
        {
            //创建一个图标
            Chart chart = new Chart();

            //设置图标的宽度和高度
            chart.Width  = 580;
            chart.Height = 380;
            chart.Margin = new Thickness(100, 5, 10, 5);
            //是否启用打印和保持图片
            chart.ToolBarEnabled = false;
            //设置图标的属性
            chart.ScrollingEnabled = false; //是否启用或禁用滚动
            chart.View3D           = false; //3D效果显示
            //创建一个标题的对象
            Title title = new Title();

            //设置标题的名称
            title.Text    = name;
            title.Padding = new Thickness(0, 10, 5, 0);
            //向图标添加标题
            chart.Titles.Add(title);
            //初始化一个新的Axis
            Axis xaxis = new Axis();

            //设置Axis的属性
            //图表的X轴坐标按什么来分类,如时分秒
            xaxis.IntervalType = IntervalTypes.Months;
            //图表的X轴坐标间隔如2,3,20等,单位为xAxis.IntervalType设置的时分秒。
            xaxis.Interval = 1;
            //设置X轴的时间显示格式为7-10 11:20
            xaxis.ValueFormatString = "d日/MMM";
            //给图标添加Axis
            chart.AxesX.Add(xaxis);
            Axis yAxis = new Axis();

            //设置图标中Y轴的最小值永远为0
            yAxis.AxisMinimum = 0;
            //设置图表中Y轴的后缀
            yAxis.Suffix = "人次";
            chart.AxesY.Add(yAxis);
            // 创建一个新的数据线。
            DataSeries dataSeriesPineapple = new DataSeries();

            // 设置数据线的格式。
            dataSeriesPineapple.RenderAs   = RenderAs.Area;//折线图
            dataSeriesPineapple.XValueType = ChartValueTypes.DateTime;
            // 设置数据点
            DataPoint dataPoint2;

            for (int i = 0; i < lsTime.Count; i++)
            {
                // 创建一个数据点的实例。
                dataPoint2 = new DataPoint();
                // 设置X轴点
                dataPoint2.XValue = lsTime[i];
                //设置Y轴点
                dataPoint2.YValue     = double.Parse(count[i]);
                dataPoint2.MarkerSize = 8;
                //dataPoint2.Tag = tableName.Split('(')[0];
                //设置数据点颜色
                // dataPoint.Color = new SolidColorBrush(Colors.LightGray);
                dataPoint2.MouseLeftButtonDown += new MouseButtonEventHandler(dataPoint_MouseLeftButtonDown);
                //添加数据点
                dataSeriesPineapple.DataPoints.Add(dataPoint2);
            }
            // 添加数据线到数据序列。
            chart.Series.Add(dataSeriesPineapple);
            //将生产的图表增加到Grid,然后通过Grid添加到上层Grid.
            Grid gr = new Grid();

            gr.Children.Add(chart);
            Simon.Children.Add(gr);
        }
Esempio n. 2
0
        private void ClickOnCell(object sender, MouseButtonEventArgs e)
        {
            #region Генерация поля после первого нажатия на любую клетку
            GameManager.ClickCount++;
            if (GameManager.ClickCount == 1)
            {
                GameManager.Generate(cell, Grid.GetRow((Button)sender), Grid.GetColumn((Button)sender));      // Вызываем генерацию поля и передаём туда клетку, на которую нажали


                for (int m = 0; m < 10; m++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        GameManager.MineAroundCounter(cell, m, k);            // Прохожу по полю и получаю количество мин вокруг для каждой клетки
                    }
                }
            }
            #endregion


            int i = Grid.GetRow((Button)sender), j = Grid.GetColumn((Button)sender);


            // Если не выбран режим установки флагов и была нажата левая кнопа мыши
            #region Нажатие на кнопку в обычном режиме
            if (!GameManager.IsSettingFlags && e.LeftButton == MouseButtonState.Pressed)
            {
                if (cell[i, j].IsMine && !cell[i, j].IsFlagged)             // Если кнопка, на которую мы нажали - мина и она не помечена
                {
                    MessageBox.Show("Вы проиграли");                        // То мы проигрываем
                    Reload();
                }
                else if (!cell[i, j].IsMine && !cell[i, j].IsFlagged)       // Если это не мина и клетка не помечена флагом
                {
                    // Если нажать на открытую клетку
                    if (cell[i, j].IsOpen)
                    {
                        int flagArround = 0;


                        #region Подсчёт отмеченных клеток вокруг
                        if (i == 0)
                        {
                            if (j == 0)
                            {
                                for (int m = i; m <= i + 1; m++)
                                {
                                    for (int k = j; k <= j + 1; k++)
                                    {
                                        if (cell[m, k].IsFlagged)
                                        {
                                            flagArround++;
                                        }
                                    }
                                }
                            }
                            else if (j == 9)
                            {
                                for (int m = i; m <= i + 1; m++)
                                {
                                    for (int k = j - 1; k <= j; k++)
                                    {
                                        if (cell[m, k].IsFlagged)
                                        {
                                            flagArround++;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for (int m = i; m <= i + 1; m++)
                                {
                                    for (int k = j - 1; k <= j + 1; k++)
                                    {
                                        if (cell[m, k].IsFlagged)
                                        {
                                            flagArround++;
                                        }
                                    }
                                }
                            }
                        }
                        else if (i == 9)
                        {
                            if (j == 0)
                            {
                                for (int m = i - 1; m <= i; m++)
                                {
                                    for (int k = j; k <= j + 1; k++)
                                    {
                                        if (cell[m, k].IsFlagged)
                                        {
                                            flagArround++;
                                        }
                                    }
                                }
                            }
                            else if (j == 9)
                            {
                                for (int m = i - 1; m <= i; m++)
                                {
                                    for (int k = j - 1; k <= j; k++)
                                    {
                                        if (cell[m, k].IsFlagged)
                                        {
                                            flagArround++;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for (int m = i - 1; m <= i; m++)
                                {
                                    for (int k = j - 1; k <= j + 1; k++)
                                    {
                                        if (cell[m, k].IsFlagged)
                                        {
                                            flagArround++;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (j == 0)
                            {
                                for (int m = i - 1; m <= i + 1; m++)
                                {
                                    for (int k = j; k <= j + 1; k++)
                                    {
                                        if (cell[m, k].IsFlagged)
                                        {
                                            flagArround++;
                                        }
                                    }
                                }
                            }
                            else if (j == 9)
                            {
                                for (int m = i - 1; m <= i + 1; m++)
                                {
                                    for (int k = j - 1; k <= j; k++)
                                    {
                                        if (cell[m, k].IsFlagged)
                                        {
                                            flagArround++;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for (int m = i - 1; m <= i + 1; m++)
                                {
                                    for (int k = j - 1; k <= j + 1; k++)
                                    {
                                        if (cell[m, k].IsFlagged)
                                        {
                                            flagArround++;
                                        }
                                    }
                                }
                            }
                        }
                        #endregion


                        if (cell[i, j].MineAround == flagArround)               // И количество отмеченных клеток == количеству мин вокруг
                        {
                            GameManager.Around(cell, buttons, i, j);            // То открываем клетки вокруг
                        }
                    }


                    if (cell[i, j].MineAround == 0)                         // Если мин вокруг ноль, то открываем клетки вокруг
                    {
                        GameManager.OpenZero(cell, buttons, i, j);
                    }


                    buttons[i, j].Content = cell[i, j].MineAround;          // Открываем клетку, на которую мы нажали
                    GameManager.ColorChanger(cell, buttons, i, j);          // Устанавливаем соответствующий цвет текста кнопки
                    cell[i, j].IsOpen = true;
                }
            }
            #endregion


            // Если выбран режим установки флагов или нажатие на правую кнопку, при этом клетка не открыта
            #region Нажатие на кнопку в режиме флага
            else if ((GameManager.IsSettingFlags || e.RightButton == MouseButtonState.Pressed) && !cell[i, j].IsOpen)
            {
                FlagAdd(i, j);

                #region Победа
                if (GameManager.MineFlagged == GameManager.MineCount && GameManager.OtherCellsFlagged == 0) // Если количество помеченных мин == изначальному количеству мин и нет помеченных других клеток
                {
                    MessageBox.Show("Вы победили");                                                         // То игрок побеждает
                    Reload();
                }
                #endregion
            }
            #endregion
        }
Esempio n. 3
0
        public void CreateChartPie(string name, List <string> valuex, List <string> valuey)
        {
            //创建一个图标
            Chart chart = new Chart();

            //设置图标的宽度和高度
            chart.Width  = 580;
            chart.Height = 380;
            chart.Margin = new Thickness(100, 5, 10, 5);
            //是否启用打印和保持图片
            chart.ToolBarEnabled = false;

            //设置图标的属性
            chart.ScrollingEnabled = false; //是否启用或禁用滚动
            chart.View3D           = true;  //3D效果显示

            //创建一个标题的对象
            Title title = new Title();

            //设置标题的名称
            title.Text    = name;
            title.Padding = new Thickness(0, 10, 5, 0);

            //向图标添加标题
            chart.Titles.Add(title);


            // 创建一个新的数据线。
            DataSeries dataSeries = new DataSeries();

            // 设置数据线的格式
            dataSeries.RenderAs = RenderAs.Pie;//柱状Stacked

            double sum = 0;

            for (int i = 0; i < strListy.Count; i++)
            {
                sum = sum + double.Parse(valuey[i]);
            }
            // 设置数据点
            DataPoint dataPoint;

            for (int i = 0; i < valuex.Count; i++)
            {
                // 创建一个数据点的实例。
                dataPoint = new DataPoint();
                // 设置X轴点
                dataPoint.AxisXLabel = valuex[i];

                dataPoint.LegendText = "##" + valuex[i];
                //设置Y轴点
                double data = double.Parse(valuey[i]) / sum;
                dataPoint.YValue = data;
                //添加一个点击事件
                dataPoint.MouseLeftButtonDown += new MouseButtonEventHandler(dataPoint_MouseLeftButtonDown);
                //添加数据点
                dataSeries.DataPoints.Add(dataPoint);
            }

            // 添加数据线到数据序列。
            chart.Series.Add(dataSeries);

            //将生产的图表增加到Grid,然后通过Grid添加到上层Grid.
            Grid gr = new Grid();

            gr.Children.Add(chart);
            Simon.Children.Add(gr);
        }
Esempio n. 4
0
        private void SearchBtn_Click(object sender, RoutedEventArgs e)
        {
            //이전 데이터 제거
            searchTable.Children.RemoveRange(8, searchTable.Children.Count - 8);
            String sql;

            if (yearOption)
            {
                sql  = String.Format("SELECT * from (SELECT date, '일정' classify, calendar content FROM calendar WHERE calendar LIKE '%{0}%' UNION ", searchBox.Text);
                sql += String.Format("SELECT date, '보고공문' classify, report content FROM calendar WHERE report LIKE '%{0}%' UNION ", searchBox.Text);
                sql += String.Format("SELECT date, '복무' classify, service content FROM calendar WHERE service LIKE '%{0}%') WHERE date BETWEEN date('now', '-1 year') AND date('now', '+1 year')", searchBox.Text);
            }
            else
            {
                sql  = String.Format("SELECT date, '일정' classify, calendar content FROM calendar WHERE calendar LIKE '%{0}%' UNION ", searchBox.Text);
                sql += String.Format("SELECT date, '보고공문' classify, report content FROM calendar WHERE report LIKE '%{0}%' UNION ", searchBox.Text);
                sql += String.Format("SELECT date, '복무' classify, service content FROM calendar WHERE service LIKE '%{0}%'", searchBox.Text);
            }


            var conn = new SQLiteConnection(App.filePath);

            conn.Open();
            SQLiteCommand    cmd = new SQLiteCommand(sql, conn);
            SQLiteDataReader rdr = cmd.ExecuteReader();

            //검색 결과 수 만큼 행 생성

            int rowCount = 1;

            while (rdr.Read())
            {
                RowDefinition gridRow = new RowDefinition();
                //gridRow.Height = new GridLength(50);
                searchTable.RowDefinitions.Add(gridRow);

                //경계 선 만들기
                Border border1 = new Border();
                Grid.SetRow(border1, rowCount);
                Grid.SetColumn(border1, 0);
                border1.BorderThickness = new Thickness(1, 0, 0, 1);
                border1.Background      = Brushes.Transparent;
                border1.BorderBrush     = Brushes.Black;
                searchTable.Children.Add(border1);

                Border border2 = new Border();
                Grid.SetRow(border2, rowCount);
                Grid.SetColumn(border2, 1);
                border2.BorderThickness = new Thickness(1, 0, 0, 1);
                border2.Background      = Brushes.Transparent;
                border2.BorderBrush     = Brushes.Black;
                searchTable.Children.Add(border2);

                Border border3 = new Border();
                Grid.SetRow(border3, rowCount);
                Grid.SetColumn(border3, 2);
                border3.BorderThickness = new Thickness(1, 0, 0, 1);
                border3.Background      = Brushes.Transparent;
                border3.BorderBrush     = Brushes.Black;
                searchTable.Children.Add(border3);

                Border border4 = new Border();
                Grid.SetRow(border4, rowCount);
                Grid.SetColumn(border4, 3);
                border4.BorderThickness = new Thickness(1, 0, 1, 1);
                border4.Background      = Brushes.Transparent;
                border4.BorderBrush     = Brushes.Black;
                searchTable.Children.Add(border4);

                //텍스트 만들기

                TextBlock dateText     = new TextBlock();
                DateTime  tempDateTime = Convert.ToDateTime(rdr["date"].ToString());
                dateText.Text              = tempDateTime.ToString("yyyy-MM-dd (ddd)");
                dateText.Padding           = new Thickness(5);
                dateText.TextAlignment     = TextAlignment.Center;
                dateText.VerticalAlignment = VerticalAlignment.Center;
                Grid.SetRow(dateText, rowCount);
                Grid.SetColumn(dateText, 0);

                TextBlock classText = new TextBlock();
                classText.Text              = rdr["classify"].ToString();
                classText.Padding           = new Thickness(5);
                classText.TextAlignment     = TextAlignment.Center;
                classText.VerticalAlignment = VerticalAlignment.Center;
                Grid.SetRow(classText, rowCount);
                Grid.SetColumn(classText, 1);

                TextBlock CoincideText = new TextBlock();
                CoincideText.Text         = rdr["content"].ToString();
                CoincideText.Padding      = new Thickness(5);
                CoincideText.TextWrapping = TextWrapping.Wrap;
                CoincideText.TextTrimming = TextTrimming.CharacterEllipsis;
                Grid.SetRow(CoincideText, rowCount);
                Grid.SetColumn(CoincideText, 2);

                Button linkBtn = new Button();

                ////리소스에서 이미지 가져오기
                //System.Drawing.Bitmap image = Properties.Resources._2268137;
                //MemoryStream imgStream = new MemoryStream();
                //image.Save(imgStream, System.Drawing.Imaging.ImageFormat.Bmp);
                //imgStream.Seek(0, SeekOrigin.Begin);
                //BitmapFrame newimg = BitmapFrame.Create(imgStream);
                var converter = new System.Windows.Media.BrushConverter();
                var brush     = (Brush)converter.ConvertFromString("#673AB7");

                linkBtn.Content = new PackIcon {
                    Kind = PackIconKind.Launch, Foreground = brush, Background = System.Windows.Media.Brushes.Transparent
                };
                linkBtn.HorizontalAlignment = HorizontalAlignment.Center;
                linkBtn.VerticalAlignment   = VerticalAlignment.Center;
                linkBtn.Background          = System.Windows.Media.Brushes.Transparent;
                linkBtn.BorderThickness     = new Thickness(0);

                linkBtn.Click += (object eventSender, RoutedEventArgs eventArgs) =>
                {
                    int         index    = 0;
                    CultureInfo provider = CultureInfo.InvariantCulture;
                    DateTime    dtDate   = tempDateTime;
                    _window.calendar.SelectedDate = dtDate;
                    _window.calendar.DisplayDate  = dtDate;
                    switch (classText.Text)
                    {
                    case "일정":
                        index = 0;
                        break;

                    case "보고공문":
                        index = 1;
                        break;

                    case "복무":
                        index = 2;
                        break;
                    }
                    _window.ComboBox.SelectedIndex = index;
                };
                Grid.SetRow(linkBtn, rowCount);
                Grid.SetColumn(linkBtn, 3);


                searchTable.Children.Add(dateText);
                searchTable.Children.Add(CoincideText);
                searchTable.Children.Add(classText);
                searchTable.Children.Add(linkBtn);

                rowCount++;
            }

            rdr.Close();
            conn.Close();
        }
Esempio n. 5
0
        private void CreateChartColumn(string name, List <string> valuex, List <int> valuey)
        {
            //创建一个图标
            Chart chart = new Chart();

            //设置图标的宽度和高度
            chart.Width  = 580;
            chart.Height = 380;
            chart.Margin = new Thickness(100, 5, 10, 5);  //上下左右
            //是否启用打印和保持图片
            chart.ToolBarEnabled = false;

            //设置图标的属性
            chart.ScrollingEnabled = false; //是否启用或禁用滚动
            chart.View3D           = true;  //3D效果显示

            //创建一个标题的对象
            Title title = new Title();

            //设置标题的名称
            title.Text                 = name;
            title.Padding              = new Thickness(0, 10, 5, 0);
            title.MouseLeftButtonDown += new MouseButtonEventHandler(title_MouseLeftButtonDown);

            //向图标添加标题
            chart.Titles.Add(title);

            Axis yAxis = new Axis();

            //设置图标中Y轴的最小值永远为0
            yAxis.AxisMinimum = 0;
            //设置图表中Y轴的后缀
            yAxis.Suffix = "秒";
            chart.AxesY.Add(yAxis);

            // 创建一个新的数据线。
            DataSeries dataSeries = new DataSeries();

            // 设置数据线的格式
            dataSeries.RenderAs = RenderAs.StackedColumn;//柱状Stacked


            // 设置数据点
            MyDataPoint dataPoint;

            for (int i = 0; i < valuex.Count; i++)
            {
                // 创建一个数据点的实例。
                dataPoint = new MyDataPoint();
                // 设置X轴点
                dataPoint.AxisXLabel = valuex[i];
                //设置Y轴点
                dataPoint.YValue = valuey[i];
                //添加一个点击事件
                //dataPoint.MouseLeftButtonDown += new MouseButtonEventHandler(dataPoint_MouseLeftButtonDown);
                //添加数据点
                dataSeries.DataPoints.Add(dataPoint);
            }

            // 添加数据线到数据序列。
            chart.Series.Add(dataSeries);

            //将生产的图表增加到Grid,然后通过Grid添加到上层Grid.
            Grid   gr     = new Grid();
            Button button = new Button();

            button.Content   = "jvhgh";
            button.Padding   = new Thickness(0, 20, 25, 0);
            chart.Href       = "";
            chart.HrefTarget = 0;
            gr.Children.Add(chart);

            Simon.Children.Add(gr);
        }