Exemple #1
0
        private void SetSelection(int startColumn, int endColumn, int pivotColumn, int row)
        {
            if (startColumn < 0)
            {
                startColumn = 0;
            }

            if (endColumn > TOTAL_COLUMN - 1)
            {
                endColumn = TOTAL_COLUMN - 1;
            }

            for (int column = pivotColumn - 2; column <= pivotColumn + 2; column++)
            {
                if (column < 0 || column > TOTAL_COLUMN - 1)
                {
                    continue;
                }

                CustomTextBlock btn = buttons[row, column];

                if (startColumn <= column && column <= endColumn)
                {
                    btn.Background = selectColor;
                }
                else
                {
                    btn.Background = btn.originColor;
                }
            }

            nowSelectedColumn[0] = startColumn;
            nowSelectedColumn[1] = endColumn;
        }
Exemple #2
0
        private void onMouseDown(object sender, RoutedEventArgs e)
        {
            nowSelectedStatusControl?.ResetBackground();

            CustomTextBlock button = sender as CustomTextBlock;
            Border          border = button.Parent as Border;
            int             row    = Grid.GetRow(border);
            int             column = Grid.GetColumn(border);

            nowSelectedStatusControl = this;
            nowSelectedColumn[0]     = nowSelectedColumn[1] = column;
            nowSelectedRow           = row;

            Mouse.Capture(button);
            mouseLeftButtonDown = true;

            SetSelection(column, column, column, row);

            onOneSelected?.Invoke(button.item);
        }
Exemple #3
0
        public void rearrangeGrid()
        {
            TOTAL_COLUMN = ServerClient.getInstance().classTimeTable.Count;
            TOTAL_ROW    = ServerClient.getInstance().classroomList.Count + 2;
            buttons      = new CustomTextBlock[TOTAL_ROW, TOTAL_COLUMN];

            mainGrid.Children.RemoveRange(1, mainGrid.Children.Count - 1);
            //Add Classtime Label
            mainGrid.ColumnDefinitions.Clear();
            for (int col = 0; col < TOTAL_COLUMN; col++)
            {
                ColumnDefinition colDef = new ColumnDefinition();
                colDef.Width = new GridLength(1, GridUnitType.Star);
                mainGrid.ColumnDefinitions.Add(colDef);

                Label classtimeLabel = new Label();
                classtimeLabel.Content    = (col + 1) + "교시";
                classtimeLabel.Background = defaultColorOfOdd;
                classtimeLabel.Width      = 40;
                classtimeLabel.FontSize   = 10;

                Grid.SetRow(classtimeLabel, 1);
                Grid.SetColumn(classtimeLabel, col);

                mainGrid.Children.Add(classtimeLabel);
            }

            if (mainGrid.RowDefinitions.Count > 2)
            {
                mainGrid.RowDefinitions.RemoveRange(2, mainGrid.RowDefinitions.Count - 2);
            }
            for (int row = 2; row < TOTAL_ROW; row++)
            {
                RowDefinition rowDef = new RowDefinition();
                rowDef.Height = new GridLength(1, GridUnitType.Star);
                mainGrid.RowDefinitions.Add(rowDef);

                for (int col = 0; col < TOTAL_COLUMN; col++)
                {
                    CustomTextBlock newBtn = new CustomTextBlock();
                    newBtn.row    = row;
                    newBtn.column = col;

                    if (row % 2 == 0)
                    {
                        newBtn.originColor = defaultColorOfEven;
                        newBtn.Background  = defaultColorOfEven;
                    }
                    else
                    {
                        newBtn.originColor = defaultColorOfOdd;
                        newBtn.Background  = defaultColorOfOdd;
                    }

                    newBtn.VerticalAlignment   = VerticalAlignment.Stretch;
                    newBtn.HorizontalAlignment = HorizontalAlignment.Stretch;

                    newBtn.MouseDown  += new MouseButtonEventHandler(onMouseDown);
                    newBtn.MouseUp    += new MouseButtonEventHandler(onMouseUp);
                    newBtn.MouseEnter += new MouseEventHandler(onMouseEnter);
                    newBtn.MouseLeave += new MouseEventHandler(onMouseLeave);
                    newBtn.MouseMove  += new MouseEventHandler(onMouseMove);

                    Border myBorder1 = new Border();
                    myBorder1.BorderBrush = Brushes.Gray;
                    if (col == 0)
                    {
                        myBorder1.BorderThickness = new Thickness {
                            Top = 0, Bottom = 0, Left = 0, Right = 1
                        }
                    }
                    ;
                    else if (col == TOTAL_COLUMN - 1)
                    {
                        myBorder1.BorderThickness = new Thickness {
                            Top = 0, Bottom = 0, Left = 0, Right = 0
                        }
                    }
                    ;
                    else
                    {
                        myBorder1.BorderThickness = new Thickness {
                            Top = 0, Bottom = 0, Left = 0, Right = 1
                        }
                    };

                    myBorder1.Child   = newBtn;
                    buttons[row, col] = newBtn;

                    Grid.SetRow(myBorder1, row);
                    Grid.SetColumn(myBorder1, col);

                    mainGrid.Children.Add(myBorder1);
                }
            }
        }