private void ShowDialog(Element element, int elementIndex)
        {
            this.elementIndex = elementIndex;
            this.element      = element;
            this.element.Canvas.ClipToBounds = false;

            Border elementBorder = new Border();

            elementBorder.BorderBrush = new SolidColorBrush(Colors.Black);
            fieldsBorder                     = new Border();
            fieldsBorder.BorderBrush         = new SolidColorBrush(Colors.Gray);
            fieldsBorder.HorizontalAlignment = HorizontalAlignment.Stretch;
            fieldsBorder.VerticalAlignment   = VerticalAlignment.Stretch;
            fieldsBorder.Margin              = new Thickness(-1 * element.Fields);
            elementBorder.Child              = element.Canvas;
            element.Canvas.Children.Add(fieldsBorder);
            rebuildMargins();

            b_Frame.Background = Data.getBrush(elementBorder);
            if (elementIndex == -1)
            {
                btn_Add.Content = "Додати";
            }
            else
            {
                btn_Add.Content = "Застосувати";
            }
            initializeFields();
            base.ShowDialog();
        }
예제 #2
0
        private void update()
        {
            grid_Content.RowDefinitions.Clear();
            grid_Content.Children.Clear();

            int rowCount = Data.Elements.Count / 3;

            if (rowCount * 3 < Data.Elements.Count)//якщо відбулось округлення
            {
                rowCount++;
            }

            for (int i = 0; i < rowCount; i++)
            {
                RowDefinition rw = new RowDefinition();
                rw.Height = new GridLength(grid_Content.ColumnDefinitions[0].ActualWidth);
                grid_Content.RowDefinitions.Add(rw);
            }

            for (int i = 0; i < Data.Elements.Count; i++)
            {
                Border cellBorder = new Border();

                cellBorder.MouseLeftButtonDown += Element_Double_Click;
                cellBorder.MouseEnter          += Element_MouseEnter;
                cellBorder.MouseLeave          += Element_MouseLeave;
                cellBorder.Margin          = normalThickness;
                cellBorder.BorderThickness = new Thickness(5);
                if (chosenElements.Contains(i))
                {
                    cellBorder.BorderBrush = Data.chosentBorderBrush;
                }
                else
                {
                    cellBorder.BorderBrush = Data.normalBorderBrush;
                }
                cellBorder.Background = Data.getBrush(Data.Elements[i].Canvas);
                grid_Content.Children.Add(cellBorder);
                Grid.SetColumn(cellBorder, i % 3);
                Grid.SetRow(cellBorder, i / 3);
            }
        }