public void ConvertStringToThickness()
 {
     var c = new ThicknessConverter();
     var value = "40, 30, 20, 10";
     var converted = c.ConvertFrom(null, CultureInfo.InvariantCulture, value);
     Assert.AreEqual(new Thickness(40, 30, 20, 10), converted);
 }
예제 #2
0
        void Borders()
        {
            // <Snippet_Block_Borders>
            Paragraph par = new Paragraph();

            Run run1 = new Run("Child elements in this Block element (Paragraph) will be surrounded by a blue border.");
            Run run2 = new Run("This border will be one quarter inch thick in all directions.");

            par.Inlines.Add(run1);
            par.Inlines.Add(run2);

            par.BorderBrush = Brushes.Blue;
            ThicknessConverter tc = new ThicknessConverter();

            par.BorderThickness = (Thickness)tc.ConvertFromString("0.25in");
            // </Snippet_Block_Borders>
        }
예제 #3
0
 /// <inheritdoc />
 public override void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (d is Panel panel)
     {
         panel.Loaded += (sender, args) =>
         {
             foreach (FrameworkElement child in panel.Children)
             {
                 var thickness = new ThicknessConverter().ConvertFromString(e.NewValue as string);
                 if (thickness != null && thickness is Thickness t)
                 {
                     child.Margin = t;
                 }
             }
         };
     }
 }
예제 #4
0
        private static Thickness GetThicknessFromElement(XElement element, Thickness defaultValue)
        {
            Thickness          margin = defaultValue;
            ThicknessConverter tc     = new ThicknessConverter();

            if (element != null)
            {
                try
                {
                    margin = (Thickness)tc.ConvertFromString(element.Value);
                }
                catch (NotSupportedException)
                {
                }
            }
            return(margin);
        }
예제 #5
0
        public object Convert(object[] values,
                              Type targetType,
                              object parameter,
                              CultureInfo culture)
        {
            if (values[0] != null)
            {
                return(new Border());
            }

            string             thickStr  = values[1] as string;
            ThicknessConverter conv      = new ThicknessConverter();
            Thickness          thickness = (Thickness)conv.ConvertFromString(thickStr);


            return(thickness);
        }
 public override void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
 {
     if (sender is Panel panel)
     {
         ThicknessConverter converter = new ThicknessConverter();
         panel.Loaded += (s, ee) =>
         {
             for (int i = 0; i < panel.Children.Count; i++)
             {
                 UIElement child = panel.Children[i];
                 if (child is FrameworkElement frameworkElement)
                 {
                     frameworkElement.Margin = (Thickness)converter.ConvertFromString(e.NewValue as string);
                 }
             }
         };
     }
     else
     {
         throw new Exception($"The {nameof(ChildMarginProperty)} isn't attached to the correct sender {sender} should be a child of a {nameof(Panel)}.");
     }
 }
예제 #7
0
        static Thickness GetThickness(XmlElement element,
                                      string attr,
                                      Thickness default_value)
        {
            ThicknessConverter convertor = new ThicknessConverter();

            if (element.HasAttribute(attr) == false)
            {
                return(default_value);
            }
            string s = element.GetAttribute(attr);

            try
            {
                Thickness value = (Thickness)convertor.ConvertFromString(s);
                return(value);
            }
            catch (Exception ex)
            {
                throw new Exception($"属性值 {attr} 定义错误({ex.Message}),应为数字,或 n,n,n,n 形态({element.OuterXml})");
            }
        }
예제 #8
0
        private static Theme LoadTheme(string themeXml)
        {
            Theme              theme    = new Theme();
            XDocument          document = XDocument.Load(themeXml);
            XElement           root     = document.Root;
            XElement           element  = null;
            BrushConverter     brush    = new BrushConverter();
            ThicknessConverter tc       = new ThicknessConverter();
            string             value    = string.Empty;

            theme.Name     = root.Element("Name").Value;
            theme.Location = Path.GetDirectoryName(themeXml);
            theme.FileName = themeXml.ToLower().Trim();

            element         = root.Element("images");
            theme.LeftCap   = GetBitmapFromElement(element, theme.Location, "LeftCap");
            theme.Middle    = GetBitmapFromElement(element, theme.Location, "Middle");
            theme.RightCap  = GetBitmapFromElement(element, theme.Location, "RightCap");
            theme.Separator = GetBitmapFromElement(element, theme.Location, "Separator");
            theme.Configure = GetBitmapFromElement(element, theme.Location, "Configure");

            theme.PreviewFileName = root.Element("Preview").Value;

            element = root.Element("Background");
            theme.BackgroundImage = element.Element("Image").Value;
            theme.BackgroundBrush = brush.ConvertFromString(element.Element("Color").Value) as SolidColorBrush;

            element = root.Element("Icon");
            theme.IconBackgroundImage = element.Element("BackgroundImage").Value;
            theme.MaximumIconSize     = Convert.ToDouble(element.Element("MaximumSize").Value);
            theme.MinimumIconSize     = Convert.ToDouble(element.Element("MinimumSize").Value);
            theme.AutoHideAdjustment  = Convert.ToDouble(root.Element("AutoHideAdjustment").Value);

            theme.VerticalAlignment = (VerticalAlignment)Enum.Parse(typeof(VerticalAlignment), root.Element("VerticalAlignment").Value);
            theme.Margin            = GetThicknessFromElement((XElement)root.Element("Margin"), new Thickness(0));

            return(theme);
        }
예제 #9
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var margin = value as string;

            if (string.IsNullOrEmpty(margin))
            {
                return(DependencyProperty.UnsetValue);
            }
            var thicknessConverter = new ThicknessConverter();
            var convertFromString  = thicknessConverter.ConvertFromInvariantString(margin);

            if (convertFromString == null)
            {
                return(DependencyProperty.UnsetValue);
            }
            var thickness = (Thickness)convertFromString;
            var top       = thickness.Top;
            var bottom    = thickness.Bottom;

            thickness.Top    = bottom;
            thickness.Bottom = top;
            return(thickness);
        }
        /// <summary>
        ///     初始化名称标签
        /// </summary>
        private void InitTag()
        {
            var nameInfo = NamePosition.Split('|');

            var tb = Template.FindName("tbTag", this) as TextBlock;

            if (tb == null)
            {
                return;
            }

            tb.Visibility = NameVisible ? Visibility.Visible : Visibility.Hidden;
            if (nameInfo.Length < 3)
            {
                return;
            }
            try
            {
                tb.HorizontalAlignment = String.IsNullOrWhiteSpace(nameInfo[0])
                    ? tb.HorizontalAlignment
                    : (HorizontalAlignment)Enum.Parse(typeof(HorizontalAlignment), nameInfo[0]);
                tb.VerticalAlignment = String.IsNullOrWhiteSpace(nameInfo[1])
                    ? tb.VerticalAlignment
                    : (VerticalAlignment)Enum.Parse(typeof(VerticalAlignment), nameInfo[1]);
                var tc = new ThicknessConverter();
                var convertFromString = tc.ConvertFromString(nameInfo[2]);
                if (convertFromString != null)
                {
                    tb.Margin = String.IsNullOrWhiteSpace(nameInfo[2]) ? tb.Margin : (Thickness)convertFromString;
                }
            }
            catch (Exception)
            {
                // LogManager.Instance.AddLog(LogEventType.Warning, e, "异常日志");
            }
        }
예제 #11
0
        internal static Style ToWPFStyle(this XElement elem)
        {
            Style style = new Style();

            if (elem != null)
            {
                var setters = elem.Descendants().Select(elm =>
                {
                    Setter setter = null;
                    if (elm.Name == w + "left" || elm.Name == w + "right" || elm.Name == w + "top" || elm.Name == w + "bottom")
                    {
                        ThicknessConverter tk = new ThicknessConverter();
                        Thickness thinkness   = (Thickness)tk.ConvertFrom(elm.Attribute(w + "sz").Value);

                        BrushConverter bc = new BrushConverter();
                        Brush color       = (Brush)bc.ConvertFrom(string.Format("#{0}", elm.Attribute(w + "color").Value));


                        setter = new Setter(Block.BorderThicknessProperty, thinkness);
                        //style.Setters.Add(new Setter(Block.BorderBrushProperty,color));
                    }
                    else if (elm.Name == w + "rFonts")
                    {
                        FontFamilyConverter ffc = new FontFamilyConverter();
                        setter = new Setter(TextElement.FontFamilyProperty, ffc.ConvertFrom(elm.Attribute(w + "ascii").Value));
                    }
                    else if (elm.Name == w + "b")
                    {
                        setter = new Setter(TextElement.FontWeightProperty, FontWeights.Bold);
                    }
                    else if (elm.Name == w + "color")
                    {
                        BrushConverter bc = new BrushConverter();
                        setter            = new Setter(TextElement.ForegroundProperty, bc.ConvertFrom(string.Format("#{0}", elm.Attribute(w_val).Value)));
                    }
                    else if (elm.Name == w + "em" || elm.Name == w + "i")
                    {
                        setter = new Setter(TextElement.FontStyleProperty, FontStyles.Italic);
                    }
                    else if (elm.Name == w + "strike")
                    {
                        setter = new Setter(Inline.TextDecorationsProperty, TextDecorations.Strikethrough);
                    }
                    else if (elm.Name == w + "sz")
                    {
                        FontSizeConverter fsc = new FontSizeConverter();
                        setter = new Setter(TextElement.FontSizeProperty, fsc.ConvertFrom(elm.Attribute(w_val).Value));
                    }
                    else if (elm.Name == w + "ilvl")
                    {
                        Console.WriteLine(elm.Attribute(w_val));
                    }
                    else if (elm.Name == w + "numPr")
                    {
                        Console.WriteLine(elm.Value);
                    }
                    else if (elm.Name == w + "numId")
                    {
                        Console.WriteLine(elm.Attribute(w_val));

                        int value = int.Parse(elm.Attribute(w + "val").Value);
                        if (value == 2)
                        {
                            setter = new Setter(List.MarkerStyleProperty, TextMarkerStyle.Decimal);
                        }
                    }
                    else if (elm.Name == w + "u")
                    {
                        setter = new Setter(Inline.TextDecorationsProperty, TextDecorations.Underline);
                    }
                    else if (elm.Name == w + "jc")
                    {
                        TextAlignment textAlignment = new TextAlignment();
                        string value = elm.Attribute(w + "val").Value;
                        switch (value)
                        {
                        case "left":
                            textAlignment = TextAlignment.Left;
                            break;

                        case "center":
                            textAlignment = TextAlignment.Center;
                            break;

                        case "right":
                            textAlignment = TextAlignment.Right;
                            break;

                        case "justify":
                            textAlignment = TextAlignment.Justify;
                            break;
                        }

                        setter = new Setter(Block.TextAlignmentProperty, textAlignment);
                    }
                    else
                    {
                        Console.WriteLine(elm.Name);
                    }


                    return(setter);
                });


                foreach (SetterBase setter in setters)
                {
                    if (setter != null)
                    {
                        style.Setters.Add(setter);
                    }
                }
            }

            return(style);
        }
예제 #12
0
        private void RadioButton_Checked(object sender, RoutedEventArgs e)
        {
            ThicknessConverter tc   = new ThicknessConverter();
            var         thin        = (Thickness)tc.ConvertFromString("0.5");
            RadioButton radioButton = sender as RadioButton;

            DienKinhDoanh = radioButton.Content.ToString();
            switch (radioButton.Content)
            {
            case "Hộ gia đình":
            {
                HideShowGroupControl(false);
                ReadDataExcel(1);
                RankTable.RowGroups.Clear();

                TableRow row = new TableRow();
                row.Cells.Add(new TableCell(new Paragraph(new Run("Bậc")))
                    {
                        BorderBrush = Brushes.Black, BorderThickness = thin
                    });
                row.Cells.Add(new TableCell(new Paragraph(new Run("Giới hạn")))
                    {
                        BorderBrush = Brushes.Black, BorderThickness = thin
                    });
                row.Cells.Add(new TableCell(new Paragraph(new Run("Đơn giá")))
                    {
                        BorderBrush = Brushes.Black, BorderThickness = thin
                    });
                RankTable.RowGroups.Add(new TableRowGroup());
                RankTable.RowGroups[0].Rows.Add(row);
                foreach (var itemElectricWork in rankE)
                {
                    row = new TableRow();
                    row.Cells.Add(new TableCell(new Paragraph(new Run(itemElectricWork.Key.ToString())))
                        {
                            BorderBrush = Brushes.Black, BorderThickness = thin
                        });
                    row.Cells.Add(new TableCell(new Paragraph(new Run(itemElectricWork.Value.quantityAllowed.ToString())))
                        {
                            BorderBrush = Brushes.Black, BorderThickness = thin
                        });
                    row.Cells.Add(new TableCell(new Paragraph(new Run(itemElectricWork.Value.Price.ToString())))
                        {
                            BorderBrush = Brushes.Black, BorderThickness = thin
                        });
                    RankTable.RowGroups.Add(new TableRowGroup());
                    RankTable.RowGroups[RankTable.RowGroups.Count - 1].Rows.Add(row);
                }
                break;
            }

            case "Diện kinh doanh":
            {
                HideShowGroupControl(true);
                ReadDataExcel(2);
                RankTable.RowGroups.Clear();

                TableRow row = new TableRow();
                row.Cells.Add(new TableCell(new Paragraph(new Run("Thời điểm")))
                    {
                        BorderBrush = Brushes.Black, BorderThickness = thin
                    });
                row.Cells.Add(new TableCell(new Paragraph(new Run("Đơn giá")))
                    {
                        BorderBrush = Brushes.Black, BorderThickness = thin
                    });
                RankTable.RowGroups.Add(new TableRowGroup());
                RankTable.RowGroups[0].Rows.Add(row);
                foreach (var itemElectricWork in rankE)
                {
                    row = new TableRow();
                    row.Cells.Add(new TableCell(new Paragraph(new Run(itemElectricWork.Key.ToString())))
                        {
                            BorderBrush = Brushes.Black, BorderThickness = thin
                        });
                    row.Cells.Add(new TableCell(new Paragraph(new Run(itemElectricWork.Value.Price.ToString())))
                        {
                            BorderBrush = Brushes.Black, BorderThickness = thin
                        });
                    RankTable.RowGroups.Add(new TableRowGroup());
                    RankTable.RowGroups[RankTable.RowGroups.Count - 1].Rows.Add(row);
                }
                break;
            }

            case "Diện sản xuất":
            {
                HideShowGroupControl(true);
                ReadDataExcel(3);
                RankTable.RowGroups.Clear();

                TableRow row = new TableRow();
                row.Cells.Add(new TableCell(new Paragraph(new Run("Thời điểm")))
                    {
                        BorderBrush = Brushes.Black, BorderThickness = thin
                    });
                row.Cells.Add(new TableCell(new Paragraph(new Run("Đơn giá")))
                    {
                        BorderBrush = Brushes.Black, BorderThickness = thin
                    });
                RankTable.RowGroups.Add(new TableRowGroup());
                RankTable.RowGroups[0].Rows.Add(row);
                foreach (var itemElectricWork in rankE)
                {
                    row = new TableRow();
                    row.Cells.Add(new TableCell(new Paragraph(new Run(itemElectricWork.Key.ToString())))
                        {
                            BorderBrush = Brushes.Black, BorderThickness = thin
                        });
                    row.Cells.Add(new TableCell(new Paragraph(new Run(itemElectricWork.Value.Price.ToString())))
                        {
                            BorderBrush = Brushes.Black, BorderThickness = thin
                        });
                    RankTable.RowGroups.Add(new TableRowGroup());
                    RankTable.RowGroups[RankTable.RowGroups.Count - 1].Rows.Add(row);
                }
                break;
            }
            }
        }
예제 #13
0
        void InitializeButton()
        {
            Application.Current.MainWindow.Height = nRows * 30 + 20;
            Application.Current.MainWindow.Width  = nCols * 30;
            gameLogic = new GameLogic(nRows, nCols, 2);
            int comLV = 3;

            if (File.Exists("setting.cfg"))
            {
                FileStream file = new FileStream("setting.cfg", FileMode.Open, FileAccess.Read);
                comLV = file.ReadByte();
                file.Close();
            }
            else
            {
                FileStream file = new FileStream("setting.cfg", FileMode.OpenOrCreate, FileAccess.Write);
                file.WriteByte((byte)comLV);
                file.Close();
            }
            computer             = new Computer(gameLogic, comLV);
            buttonBoard          = new Button[nRows, nCols];
            undoMoves            = new Stack <Move>();
            redoMoves            = new Stack <Move>();
            xResourceUri         = new Uri("Resources/Cross.png", UriKind.Relative);
            oResourceUri         = new Uri("Resources/Circle.png", UriKind.Relative);
            UndoButton.IsEnabled = false;
            RedoButton.IsEnabled = false;

            GridLengthConverter gridLengthConverter = new GridLengthConverter();
            ThicknessConverter  thicknessConverter  = new ThicknessConverter();

            for (int i = 0; i < nRows; i++)
            {
                RowDefinition rowDefinition = new RowDefinition();
                rowDefinition.Height = (GridLength)gridLengthConverter.ConvertFrom("*");
                mainGrid.RowDefinitions.Add(rowDefinition);
            }

            for (int i = 0; i < nCols; i++)
            {
                ColumnDefinition columnDefinition = new ColumnDefinition();
                columnDefinition.Width = (GridLength)gridLengthConverter.ConvertFrom("*");
                mainGrid.ColumnDefinitions.Add(columnDefinition);
            }

            for (int i = 0; i < nRows; i++)
            {
                for (int j = 0; j < nCols; j++)
                {
                    Button newButton = new Button();
                    newButton.Name = "Button" + i.ToString() + "_" + j.ToString();

                    newButton.BorderThickness = (Thickness)thicknessConverter.ConvertFrom(0.5);
                    newButton.Background      = Brushes.White;
                    newButton.Click          += NextMove;
                    newButton.Focusable       = false;
                    newButton.Style           = this.FindResource("SetButton") as Style;

                    Grid.SetRow(newButton, i);
                    Grid.SetColumn(newButton, j);

                    mainGrid.Children.Add(newButton);
                    buttonBoard[i, j] = newButton;
                }
            }
        }
예제 #14
0
        private void RenderMessage(MessageDTO[] messages)
        {
            Messages.Children.Clear();
            if (messages == null || messages.Length == 0)
            {
                return;
            }
            Service1Client client = new Service1Client();

            foreach (MessageDTO item in messages)
            {
                string SenderLogin = client.GetLoginById(item.SenderId);
                //SenderLogin = (SenderLogin == null) ? "Server" : SenderLogin;
                ThicknessConverter tc = new ThicknessConverter();
                Card card             = new Card {
                    Background          = GetDesignColorBrush(DesignColor.PrimaryDark),
                    Foreground          = new SolidColorBrush(Colors.White),
                    Padding             = (Thickness)tc.ConvertFromString("8px"),
                    UniformCornerRadius = 6,
                    //Content = new TextBlock { Text = $"{item.Text}", TextWrapping = TextWrapping.Wrap }
                };
                if (item.FileName != String.Empty)
                {
                    StackPanel stack = new StackPanel();
                    stack.Children.Add(new TextBox {
                        Text            = ((SenderLogin != UserLoger.Login) ? $"{SenderLogin}: " : "") + $"{item.Text}",
                        TextWrapping    = TextWrapping.Wrap,
                        IsReadOnly      = true, Background = new SolidColorBrush(Colors.Transparent),
                        BorderThickness = (Thickness)tc.ConvertFromString("0px"),
                        BorderBrush     = new SolidColorBrush(Colors.Transparent)
                    });
                    Button        button = new Button();
                    StyleSelector style  = new StyleSelector();
                    button.Style   = (Style)this.TryFindResource("MaterialDesignFloatingActionMiniButton");
                    button.Content = new PackIcon {
                        Kind = PackIconKind.Download
                    };
                    button.Click += new RoutedEventHandler(DownloadFile);
                    button.HorizontalAlignment = HorizontalAlignment.Left;
                    button.Tag = item;
                    TextBlock text = new TextBlock {
                        Text = item.FileName, TextWrapping = TextWrapping.Wrap
                    };
                    text.HorizontalAlignment = HorizontalAlignment.Right;
                    text.Foreground          = (Brush)this.TryFindResource("PrimaryHueLightForegroundBrush");
                    StackPanel stack2 = new StackPanel {
                        Orientation = Orientation.Horizontal
                    };
                    stack2.Background = (Brush)this.TryFindResource("PrimaryHueLightBrush");
                    stack2.Children.Add(button);
                    stack2.Children.Add(text);
                    stack.Children.Add(stack2);
                    card.Content = stack;
                }
                else
                {
                    card.Content = new TextBox
                    {
                        Text            = ((SenderLogin != UserLoger.Login)?$"{SenderLogin}: ":"") + $"{item.Text}",
                        TextWrapping    = TextWrapping.Wrap,
                        IsReadOnly      = true,
                        Background      = new SolidColorBrush(Colors.Transparent),
                        BorderThickness = (Thickness)tc.ConvertFromString("0px"),
                        BorderBrush     = new SolidColorBrush(Colors.Transparent),
                        //TextDecorations =
                    };
                }
                //Paragraph paragraph = new Paragraph(new InlineUIContainer( card ));
                //paragraph.BorderThickness = (Thickness)tc.ConvertFromString("1px");
                card.Margin = (Thickness)tc.ConvertFromString("3px");
                if (SenderLogin == UserLoger.Login)
                {
                    card.HorizontalAlignment = HorizontalAlignment.Right;
                    //paragraph.FlowDirection = FlowDirection.RightToLeft;
                    //paragraph.BorderBrush = Brushes.Red;
                }
                else
                {
                    card.HorizontalAlignment = HorizontalAlignment.Left;
                    //paragraph.FlowDirection = FlowDirection.LeftToRight;
                    //paragraph.BorderBrush = Brushes.Blue;
                }
                Messages.Children.Add(card);
            }
            client.Close();
        }
예제 #15
0
        private System.Windows.Controls.GroupBox AddImageTemplate(string title, int count, string isEnabled = "True", string targetExtension = "",
                                                                  int sizeX = 100, int sizeY = 100, string backgroundColor = "#FFFFFFFF")
        {
            ThicknessConverter thicknessConverter = new ThicknessConverter();
            BrushConverter     brushConverter     = new BrushConverter();

            System.Windows.Controls.GroupBox groupBox = new System.Windows.Controls.GroupBox();
            groupBox.Header = title;
            groupBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            groupBox.Margin = (Thickness)thicknessConverter.ConvertFromString("0,0,0,10");
            groupBox.Tag    = "Image";

            StackPanel parentStackPanel = new StackPanel();

            parentStackPanel.Margin = (Thickness)thicknessConverter.ConvertFromString("15");


            StackPanel childStackPanel_01 = new StackPanel();

            childStackPanel_01.Orientation = System.Windows.Controls.Orientation.Horizontal;
            childStackPanel_01.Margin      = (Thickness)thicknessConverter.ConvertFromString("0,0,0,10");

            System.Windows.Controls.Label typeLabel = new System.Windows.Controls.Label();
            typeLabel.Content           = "種類 : ";
            typeLabel.VerticalAlignment = VerticalAlignment.Center;

            System.Windows.Controls.Label textLabel = new System.Windows.Controls.Label();
            textLabel.Content = "画像";

            System.Windows.Controls.CheckBox isEnabledCheckbox = new System.Windows.Controls.CheckBox();
            isEnabledCheckbox.Content           = "有効";
            isEnabledCheckbox.Margin            = (Thickness)thicknessConverter.ConvertFromString("50,0,0,0");
            isEnabledCheckbox.VerticalAlignment = VerticalAlignment.Center;

            if (isEnabled == "True")
            {
                isEnabledCheckbox.IsChecked = true;
            }
            else
            {
                isEnabledCheckbox.IsChecked = false;
            }

            childStackPanel_01.Children.Add(typeLabel);
            childStackPanel_01.Children.Add(textLabel);
            childStackPanel_01.Children.Add(isEnabledCheckbox);


            StackPanel childStackPanel_02 = new StackPanel();

            childStackPanel_02.Orientation = System.Windows.Controls.Orientation.Horizontal;
            childStackPanel_02.Margin      = (Thickness)thicknessConverter.ConvertFromString("0,0,0,10");

            System.Windows.Controls.Label extLabel = new System.Windows.Controls.Label();
            extLabel.Content           = "対象拡張子";
            extLabel.Width             = 90;
            extLabel.VerticalAlignment = VerticalAlignment.Center;

            System.Windows.Controls.TextBox extTextBox = new System.Windows.Controls.TextBox();
            extTextBox.Width                    = 200;
            extTextBox.Margin                   = (Thickness)thicknessConverter.ConvertFromString("10,0,0,0");
            extTextBox.Padding                  = (Thickness)thicknessConverter.ConvertFromString("5,2");
            extTextBox.VerticalAlignment        = VerticalAlignment.Center;
            extTextBox.VerticalContentAlignment = VerticalAlignment.Center;
            extTextBox.Text = targetExtension;

            childStackPanel_02.Children.Add(extLabel);
            childStackPanel_02.Children.Add(extTextBox);


            StackPanel childStackPanel_03 = new StackPanel();

            childStackPanel_03.Orientation = System.Windows.Controls.Orientation.Horizontal;
            childStackPanel_03.Margin      = (Thickness)thicknessConverter.ConvertFromString("0");

            System.Windows.Controls.Label sizeLabel = new System.Windows.Controls.Label();
            sizeLabel.Content           = "サイズ (x:y)";
            sizeLabel.Width             = 90;
            sizeLabel.VerticalAlignment = VerticalAlignment.Center;

            System.Windows.Controls.TextBox width_1TextBox = new System.Windows.Controls.TextBox();
            width_1TextBox.Width                    = 60;
            width_1TextBox.Margin                   = (Thickness)thicknessConverter.ConvertFromString("10,0,0,0");
            width_1TextBox.Padding                  = (Thickness)thicknessConverter.ConvertFromString("5,2");
            width_1TextBox.VerticalAlignment        = VerticalAlignment.Center;
            width_1TextBox.VerticalContentAlignment = VerticalAlignment.Center;
            width_1TextBox.Text = sizeX.ToString();

            System.Windows.Controls.Label width_Label = new System.Windows.Controls.Label();
            width_Label.Content           = "x";
            width_Label.VerticalAlignment = VerticalAlignment.Center;

            System.Windows.Controls.TextBox width_2TextBox = new System.Windows.Controls.TextBox();
            width_2TextBox.Width                    = 60;
            width_2TextBox.Margin                   = (Thickness)thicknessConverter.ConvertFromString("0,0,0,0");
            width_2TextBox.Padding                  = (Thickness)thicknessConverter.ConvertFromString("5,2");
            width_2TextBox.VerticalAlignment        = VerticalAlignment.Center;
            width_2TextBox.VerticalContentAlignment = VerticalAlignment.Center;
            width_2TextBox.Text = sizeY.ToString();

            childStackPanel_03.Children.Add(sizeLabel);
            childStackPanel_03.Children.Add(width_1TextBox);
            childStackPanel_03.Children.Add(width_Label);
            childStackPanel_03.Children.Add(width_2TextBox);


            StackPanel childStackPanel_04 = new StackPanel();

            childStackPanel_04.Orientation = System.Windows.Controls.Orientation.Horizontal;
            childStackPanel_04.Margin      = (Thickness)thicknessConverter.ConvertFromString("0,10,0,0");

            System.Windows.Controls.Label bgcLabel = new System.Windows.Controls.Label();
            bgcLabel.Content           = "背景色";
            bgcLabel.Width             = 90;
            bgcLabel.VerticalAlignment = VerticalAlignment.Center;

            System.Windows.Controls.Button colorChangeButton = new System.Windows.Controls.Button();
            colorChangeButton.Name       = "T" + count.ToString() + "_ColorSample";
            colorChangeButton.Content    = "";
            colorChangeButton.Background = (Brush)brushConverter.ConvertFromString(backgroundColor);
            colorChangeButton.Margin     = (Thickness)thicknessConverter.ConvertFromString("10,0,0,0");
            colorChangeButton.Width      = 40;
            colorChangeButton.SetResourceReference(System.Windows.Controls.Control.TemplateProperty, "colorButton");
            colorChangeButton.VerticalAlignment = VerticalAlignment.Center;
            colorChangeButton.Click            += ChangeColor;

            childStackPanel_04.Children.Add(bgcLabel);
            //childStackPanel_04.Children.Add(colorNameLabel);
            childStackPanel_04.Children.Add(colorChangeButton);

            StackPanel childStackPanel_05 = new StackPanel();

            childStackPanel_05.Orientation = System.Windows.Controls.Orientation.Horizontal;
            childStackPanel_05.Margin      = (Thickness)thicknessConverter.ConvertFromString("0,15,0,0");

            System.Windows.Controls.Button delButton = new System.Windows.Controls.Button();
            delButton.Content = "テンプレートを削除";
            delButton.Name    = "delButton_" + count.ToString();

            delButton.SetResourceReference(System.Windows.Controls.Control.TemplateProperty, "delButton");

            delButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            delButton.Width  = 120;
            delButton.Height = 25;
            delButton.Click += DeleteTemplate_Click;

            System.Windows.Controls.Button moveUpButton = new System.Windows.Controls.Button();
            moveUpButton.Name                = "moveToUp_" + count.ToString();
            moveUpButton.Content             = "↑";
            moveUpButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            moveUpButton.Margin              = (Thickness)thicknessConverter.ConvertFromString("90,0,0,0");
            moveUpButton.Width               = 40;
            moveUpButton.Height              = 25;
            moveUpButton.Click              += MoveToUp;

            System.Windows.Controls.Button moveBottomButton = new System.Windows.Controls.Button();
            moveBottomButton.Name                = "moveToBottom_" + count.ToString();
            moveBottomButton.Content             = "↓";
            moveBottomButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            moveBottomButton.Margin              = (Thickness)thicknessConverter.ConvertFromString("10,0,0,0");
            moveBottomButton.Width               = 40;
            moveBottomButton.Height              = 25;
            moveBottomButton.Click              += MoveToBottom;

            childStackPanel_05.Children.Add(delButton);
            childStackPanel_05.Children.Add(moveUpButton);
            childStackPanel_05.Children.Add(moveBottomButton);


            parentStackPanel.Children.Add(childStackPanel_01);
            parentStackPanel.Children.Add(childStackPanel_02);
            parentStackPanel.Children.Add(childStackPanel_03);
            parentStackPanel.Children.Add(childStackPanel_04);
            parentStackPanel.Children.Add(childStackPanel_05);

            groupBox.Content = parentStackPanel;

            return(groupBox);
        }
예제 #16
0
 /// <summary>
 /// Prevents a default instance of the <see cref="ModernIconKindToIconConverter"/> class from being created.
 /// </summary>
 private ModernIconKindToIconConverter()
 {
     this.thicknessConverter = new ThicknessConverter();
 }
예제 #17
0
 /// <summary>
 /// Returns the string representation of the <see cref="Thickness"/> structure.
 /// structure.
 /// </summary>
 /// <returns>
 /// A <see cref="String"/> that represents the <see cref="Thickness"/> value.
 /// </returns>
 public override string ToString()
 {
     return(ThicknessConverter.ToString(this, null));
 }
예제 #18
0
        public static Section Generate(Sess Session)
        {
            Section reg = new Section();

            Paragraph topBit = new Paragraph();

            Image parisLogoImage = new Image();

            parisLogoImage.Source = new BitmapImage(new Uri("C:\\Users\\steven.smith\\Source\\Repos\\WPFParisTraining\\Images\\Paris Logo.png", UriKind.RelativeOrAbsolute));
            //parisLogoImage.Source = new BitmapImage(new Uri("pack://application:,,,/WPFParisTraining;Images/Paris_Logo", UriKind.RelativeOrAbsolute));
            parisLogoImage.Width = 100;
            parisLogoImage.HorizontalAlignment = HorizontalAlignment.Left;
            // var img = new BitmapImage(new Uri("pack://application:,,,/(your project name);component/Resources/PangoIcon.png", UriKind.RelativeOrAbsolute));

            Image pennineLogoImage = new Image();

            pennineLogoImage.Source = new BitmapImage(new Uri("C:\\Users\\steven.smith\\Source\\Repos\\WPFParisTraining\\Images\\trust colour logo.png", UriKind.RelativeOrAbsolute));
            pennineLogoImage.Width  = 200;
            pennineLogoImage.HorizontalAlignment = HorizontalAlignment.Right;



            Table regtable = new Table();

            reg.Blocks.Add(regtable);

            regtable.CellSpacing = 0;
            regtable.Background  = Brushes.White;
            regtable.BorderBrush = Brushes.Black;
            ThicknessConverter tc = new ThicknessConverter();

            regtable.BorderThickness = (Thickness)tc.ConvertFromString("0.05in");

            double[] widths          = { 120, 150, 120, 200, 75, 350 };
            int      numberOfColumns = 6;

            for (int x = 0; x < numberOfColumns; x++)
            {
                regtable.Columns.Add(new TableColumn());
                regtable.Columns[x].Width = new GridLength(widths[x]);
                //regtable.Columns[x].Background = (x % 2 == 1) ? Brushes.LightGray : Brushes.White;
            }

            TableRowGroup top = new TableRowGroup();

            top.Rows.Add(new TableRow());
            top.Rows[0].Cells.Add(new TableCell(new BlockUIContainer(parisLogoImage)));
            top.Rows[0].Cells[0].RowSpan = 3;
            top.Rows[0].Cells.Add(new TableCell(new Paragraph(new Run("Paris Training Register"))));
            top.Rows[0].Cells[1].ColumnSpan = 4;
            top.Rows[0].Cells[1].FontWeight = FontWeights.Bold;
            top.Rows[0].Cells[1].FontSize   = 36;
            top.Rows[0].Cells.Add(new TableCell(new BlockUIContainer(pennineLogoImage)));
            top.Rows.Add(new TableRow());
            top.Rows[1].Cells.Add(new TableCell(new Paragraph(new Run(((DateTime)Session.Strt).ToLongDateString()))));
            top.Rows[1].Cells[0].ColumnSpan = 4;
            top.Rows[1].Cells.Add(new TableCell(new Paragraph(new Run("Start Time: "))));
            top.Rows.Add(new TableRow());
            top.Rows[2].Cells.Add(new TableCell(new Paragraph(new Run(Session.Course.CourseName))));
            top.Rows[2].Cells[0].ColumnSpan = 4;
            top.Rows[2].Cells[0].FontSize   = 24;
            top.Rows[2].Cells.Add(new TableCell(new Paragraph(new Run("End Time: "))));
            top.Rows.Add(new TableRow());
            top.Rows[3].Cells.Add(new TableCell(new Paragraph(new Run(String.Format("Trainer: {0}", Session.Trainer.SimpleName)))));
            top.Rows[3].Cells[0].ColumnSpan = 2;
            top.Rows[3].Cells.Add(new TableCell(new Paragraph(new Run(String.Format("Location: {0}", Session.Location.LocationName)))));
            top.Rows[3].Cells[1].ColumnSpan = 4;
            top.Rows.Add(new TableRow());
            top.Rows[4].Cells.Add(new TableCell());

            regtable.RowGroups.Add(top);

            TableRowGroup header = new TableRowGroup();

            header.Rows.Add(new TableRow());
            header.Rows[0].FontWeight = FontWeights.Bold;
            header.Rows[0].Cells.Add(new TableCell(new Paragraph(new Run("Name"))));
            //header.Rows[0].Cells[0].BorderBrush = Brushes.Red;
            //header.Rows[0].Cells[0].BorderThickness = (Thickness)tc.ConvertFromString("0.02in");
            header.Rows[0].Cells[0].Padding = (Thickness)tc.ConvertFromString("0.05in");
            header.Rows[0].Cells.Add(new TableCell(new Paragraph(new Run("Job Title"))));
            header.Rows[0].Cells[1].Padding = (Thickness)tc.ConvertFromString("0.05in");
            header.Rows[0].Cells.Add(new TableCell(new Paragraph(new Run("Main Team"))));
            header.Rows[0].Cells[2].Padding = (Thickness)tc.ConvertFromString("0.05in");
            header.Rows[0].Cells.Add(new TableCell(new Paragraph(new Run("Signature"))));
            header.Rows[0].Cells[3].Padding = (Thickness)tc.ConvertFromString("0.05in");
            header.Rows[0].Cells.Add(new TableCell(new Paragraph(new Run("Declaration Recieved"))));
            header.Rows[0].Cells[4].FontSize = 10;
            header.Rows[0].Cells[4].Padding  = (Thickness)tc.ConvertFromString("0.05in");
            header.Rows[0].Cells.Add(new TableCell(new Paragraph(new Run("Comments"))));
            header.Rows[0].Cells[5].Padding = (Thickness)tc.ConvertFromString("0.05in");


            regtable.RowGroups.Add(header);

            TableRowGroup data = new TableRowGroup();

            int numberOfRows = 0;

            foreach (Attendance a in Session.Attendances)
            {
                data.Rows.Add(new TableRow());
                data.Rows[numberOfRows].Cells.Add(BodyTableCell(new Paragraph(new Run(a.Staff.FullName))));
                data.Rows[numberOfRows].Cells.Add(BodyTableCell(new Paragraph(new Run(a.Staff.JobTitle))));
                data.Rows[numberOfRows].Cells.Add(BodyTableCell(new Paragraph(new Run((a.Staff.MainTeam == null)?"":a.Staff.MainTeam.TeamName))));
                data.Rows[numberOfRows].Cells.Add(BodyTableCell(new Paragraph(new Run((a.Outcome != 0)?a.Status.StatusDesc:""))));
                data.Rows[numberOfRows].Cells.Add(BodyTableCell(new Paragraph(new Run((a.Staff.RA == null || a.Staff.RA.Declaration == null)?"":((DateTime)a.Staff.RA.Declaration).ToShortDateString()))));
                data.Rows[numberOfRows].Cells.Add(BodyTableCell(new Paragraph(new Run(a.Comments))));
                data.Rows[numberOfRows].Background = (numberOfRows % 2 == 1)?Brushes.Transparent : Brushes.LightGray;
                numberOfRows++;
            }


            for (int x = 0; x < Session.AvailablePlaces; x++)
            {
                data.Rows.Add(new TableRow());
                data.Rows[numberOfRows].Cells.Add(BodyTableCell());
                data.Rows[numberOfRows].Cells.Add(BodyTableCell());
                data.Rows[numberOfRows].Cells.Add(BodyTableCell());
                data.Rows[numberOfRows].Cells.Add(BodyTableCell());
                data.Rows[numberOfRows].Cells.Add(BodyTableCell());
                data.Rows[numberOfRows].Cells.Add(BodyTableCell());
                data.Rows[numberOfRows].Background = (numberOfRows % 2 == 1) ? Brushes.Transparent : Brushes.LightGray;
                numberOfRows++;
            }

            regtable.RowGroups.Add(data);

            TableRowGroup footer = new TableRowGroup();

            footer.Rows.Add(new TableRow());
            footer.Rows[0].FontSize = 10;
            footer.Rows[0].Cells.Add(new TableCell(new Paragraph(new Run(String.Format("Session ID: {0}", Session.ID)))));
            footer.Rows[0].Cells[0].ColumnSpan = 3;
            footer.Rows[0].Cells.Add(new TableCell(new Paragraph(new Run(String.Format("Total Places: {0}", Session.MaxP)))));
            footer.Rows[0].Cells.Add(new TableCell(new Paragraph(new Run(String.Format("Booked: {0}", Session.Bookings)))));
            footer.Rows[0].Cells.Add(new TableCell(new Paragraph(new Run(String.Format("Available: {0}", Session.AvailablePlaces)))));
            footer.Rows.Add(new TableRow());
            footer.Rows[1].Cells.Add(new TableCell());

            regtable.RowGroups.Add(footer);

            return(reg);
        }
예제 #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SplashScreen"/> class.
        /// </summary>
        public SplashScreen()
            : base(DataWindowMode.Custom)
        {
            var assembly        = Assembly.GetEntryAssembly();
            var titleAttributes = assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), true);

            InitializeComponent();
            if (titleAttributes.Length > 0)
            {
                AppName.Text = ((AssemblyTitleAttribute)titleAttributes[0]).Title;
            }
            var copyrightAttributes = assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), true);

            if (copyrightAttributes.Length > 0)
            {
                Copyright.Text = ((AssemblyCopyrightAttribute)copyrightAttributes[0]).Copyright;
            }
            var configPath = AppEnvironment.AppPath + @"\Resources\Images\SplashScreen\SplashScreenInfo.xml";

            if (File.Exists(configPath))
            {
                //product name
                var info        = XElement.Load(configPath);
                var productName = info.Element("ProductName");
                if (productName != null)
                {
                    if (!productName.Elements().Any())
                    {
                        AppName.Text = productName.Value;
                    }
                    else
                    {
                        var text = productName.Element("Text");
                        if (text != null)
                        {
                            AppName.Text = text.Value;
                        }
                        var fontFile = productName.Element("FontFileDir");

                        var font = productName.Element("FontFamily");

                        if (!String.IsNullOrEmpty(font?.Value))
                        {
                            if (fontFile != null)
                            {
                                var fontFileUri = new Uri("file:///" + AppEnvironment.AppPath + "/" + fontFile.Value + "/");
                                AppName.FontFamily = new FontFamily(fontFileUri, "./#" + font.Value);
                            }
                            else
                            {
                                AppName.FontFamily = new FontFamily(font.Value.Trim());
                            }
                        }

                        var size = productName.Element("FontSize");
                        if (!String.IsNullOrEmpty(size?.Value))
                        {
                            var myFontSizeConverter = new FontSizeConverter();
                            var convertFromString   = myFontSizeConverter.ConvertFromString(size.Value.Trim());
                            if (convertFromString != null)
                            {
                                AppName.FontSize = (Double)convertFromString;
                            }
                        }
                        var weight = productName.Element("FontWeight");
                        if (!String.IsNullOrEmpty(weight?.Value))
                        {
                            var convertFromString = new FontWeightConverter().ConvertFromString(weight.Value);
                            if (convertFromString != null)
                            {
                                AppName.FontWeight = (FontWeight)convertFromString;
                            }
                        }
                        var style = productName.Element("FontStyle");
                        if (!String.IsNullOrEmpty(style?.Value))
                        {
                            var convertFromString = new FontStyleConverter().ConvertFromString(style.Value);
                            if (convertFromString != null)
                            {
                                AppName.FontStyle = (FontStyle)convertFromString;
                            }
                        }
                        var color = productName.Element("Color");
                        if (!String.IsNullOrEmpty(color?.Value))
                        {
                            var fromString = new BrushConverter().ConvertFromString(color.Value);
                            if (fromString != null)
                            {
                                var convertFromString = (Brush)fromString;
                                AppName.Foreground = convertFromString;
                            }
                        }
                        var outLineColor = productName.Element("OutlineColor");
                        if (!String.IsNullOrEmpty(outLineColor?.Value))
                        {
                            var fromString = ColorConverter.ConvertFromString(outLineColor.Value);
                            if (fromString != null)
                            {
                                var convertFromString = (Color)fromString;
                                AppNameOutline.Color = convertFromString;
                            }
                        }
                        var margin = productName.Element("Margin");
                        if (!String.IsNullOrEmpty(margin?.Value))
                        {
                            var fromString = new ThicknessConverter().ConvertFromString(margin.Value);
                            if (fromString != null)
                            {
                                var convertFromString = (Thickness)fromString;
                                AppName.Margin = convertFromString;
                            }
                        }
                        var horizontalAlignment = productName.Element("HorizontalAlignment");
                        if (!String.IsNullOrEmpty(horizontalAlignment?.Value))
                        {
                            HorizontalAlignment convertFromString;
                            var r = Enum.TryParse(horizontalAlignment.Value, out convertFromString);
                            if (r)
                            {
                                AppName.HorizontalAlignment = convertFromString;
                            }
                        }
                    }
                }

                //sub title
                var subTitle = info.Element("SubTitle");
                if (subTitle != null)
                {
                    if (!subTitle.Elements().Any())
                    {
                        SubTitle.Text = subTitle.Value;
                    }
                    else
                    {
                        var text = subTitle.Element("Text");
                        if (text != null)
                        {
                            SubTitle.Text = text.Value;
                        }
                        else
                        {
                            SubTitle.Height = 0;
                        }
                        var fontFile = subTitle.Element("FontFileDir");

                        var font = subTitle.Element("FontFamily");

                        if (!String.IsNullOrEmpty(font?.Value))
                        {
                            if (fontFile != null)
                            {
                                var fontFileUri =
                                    new Uri("file:///" + AppEnvironment.AppPath + "/" + fontFile.Value + "/");
                                SubTitle.FontFamily = new FontFamily(fontFileUri, "./#" + font.Value);
                            }
                            else
                            {
                                SubTitle.FontFamily = new FontFamily(font.Value.Trim());
                            }
                        }

                        var size = subTitle.Element("FontSize");
                        if (!String.IsNullOrEmpty(size?.Value))
                        {
                            var myFontSizeConverter = new FontSizeConverter();
                            var convertFromString   = myFontSizeConverter.ConvertFromString(size.Value.Trim());
                            if (convertFromString != null)
                            {
                                SubTitle.FontSize = (Double)convertFromString;
                            }
                        }
                        var weight = subTitle.Element("FontWeight");
                        if (!String.IsNullOrEmpty(weight?.Value))
                        {
                            var convertFromString = new FontWeightConverter().ConvertFromString(weight.Value);
                            if (convertFromString != null)
                            {
                                SubTitle.FontWeight = (FontWeight)convertFromString;
                            }
                        }
                        var style = subTitle.Element("FontStyle");
                        if (!String.IsNullOrEmpty(style?.Value))
                        {
                            var convertFromString = new FontStyleConverter().ConvertFromString(style.Value);
                            if (convertFromString != null)
                            {
                                SubTitle.FontStyle = (FontStyle)convertFromString;
                            }
                        }
                        var color = subTitle.Element("Color");
                        if (!String.IsNullOrEmpty(color.Value))
                        {
                            var fromString = new BrushConverter().ConvertFromString(color.Value);
                            if (fromString != null)
                            {
                                var convertFromString = (Brush)fromString;
                                SubTitle.Foreground = convertFromString;
                            }
                        }
                        var outLineColor = subTitle.Element("OutlineColor");
                        if (!String.IsNullOrEmpty(outLineColor?.Value))
                        {
                            var fromString = (Color)ColorConverter.ConvertFromString(outLineColor.Value);
                            if (fromString != null)
                            {
                                var convertFromString = fromString;
                                SubTitleOutline.Color = convertFromString;
                            }
                        }
                        var margin = subTitle.Element("Margin");
                        if (!String.IsNullOrEmpty(margin?.Value))
                        {
                            var fromString = new ThicknessConverter().ConvertFromString(margin.Value);
                            if (fromString != null)
                            {
                                var convertFromString = (Thickness)fromString;
                                SubTitle.Margin = convertFromString;
                            }
                        }
                        var horizontalAlignment = subTitle.Element("HorizontalAlignment");
                        if (!String.IsNullOrEmpty(horizontalAlignment?.Value))
                        {
                            HorizontalAlignment convertFromString;
                            var r = Enum.TryParse(horizontalAlignment.Value, out convertFromString);
                            if (r)
                            {
                                SubTitle.HorizontalAlignment = convertFromString;
                            }
                        }
                    }
                }
                else
                {
                    SubTitle.Height = 0;
                }

                //copy right
                var copyright = info.Element("Copyright");
                if (!string.IsNullOrEmpty(copyright?.Value))
                {
                    Copyright.Text = copyright.Value;
                }
                else
                {
                    Copyright.Height = 0;
                }
                //info positon
                var infoPosition = info.Element("Margin");
                if (!string.IsNullOrEmpty(infoPosition?.Value))
                {
                    var fromString = new ThicknessConverter().ConvertFromString(infoPosition.Value);
                    if (fromString != null)
                    {
                        var convertFromString = (Thickness)fromString;
                        statusPanel.Margin = convertFromString;
                    }
                }
                var width = info.Element("Width");
                if (!string.IsNullOrEmpty(width?.Value))
                {
                    double fromString;
                    var    r = double.TryParse(width.Value, out fromString);
                    if (r)
                    {
                        statusPanel.Width = fromString;
                    }
                }
            }

            CustomiseSplashScreen();
        }
예제 #20
0
        /// <summary>
        /// Создание таблицы переходов
        /// </summary>
        private void TitleJumpTable(int CountInputI, int CountOutputI, int CountCycleI, int CountJumpI, Table table)
        {
            // Add Table to Doc
            document.Blocks.Add(table);
            // Properties Table
            table.CellSpacing = 10;
            table.Background  = Brushes.White;
            table.BorderBrush = Brushes.Black;
            ThicknessConverter thicknessConverter = new ThicknessConverter();

            table.BorderThickness = (Thickness)thicknessConverter.ConvertFromString("1");
            // Create Column Table
            for (int i = 0; i <= Math.Pow(2, CountInputI); i++)
            {
                table.Columns.Add(new TableColumn());
                if (i > 0)
                {
                    if (i % 2 == 0)
                    {
                        table.Columns[i].Background = Brushes.LightBlue;
                    }
                    else
                    {
                        table.Columns[i].Background = Brushes.LightCoral;
                    }
                }
            }
            // Create and add an empty TableRowGroup to hold the table's Rows.
            table.RowGroups.Add(new TableRowGroup());
            // Add the first (title) row.
            table.RowGroups[0].Rows.Add(new TableRow());
            // Alias the current working row for easy reference.
            TableRow currentRow = table.RowGroups[0].Rows[0];

            // Global formatting for the title row.
            currentRow.Background = Brushes.Silver;
            currentRow.FontSize   = 10;
            currentRow.FontWeight = FontWeights.Bold;
            // Add the header row with content,
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Таблица переходов и выходов"))));
            // and set the row to span all columns.
            currentRow.Cells[0].ColumnSpan = Convert.ToInt32(Math.Pow(2, CountInputI));
            // Add the second (header) row.
            table.RowGroups[0].Rows.Add(new TableRow());
            currentRow = table.RowGroups[0].Rows[1];
            // Global formatting for the header row.
            currentRow.FontSize   = 10;
            currentRow.FontWeight = FontWeights.Bold;
            // Add cells with content to the second row.
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("S"))));
            for (int i = 0b_00; i < Math.Pow(2, CountInputI); i++)
            {
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run(Convert.ToString(i, toBase: 2)))));
            }
            for (int i = 1; i <= CountJumpI; i++)
            {
                table.RowGroups[0].Rows.Add(new TableRow());
                currentRow = table.RowGroups[0].Rows[i + 1];
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run(i.ToString()))));
            }
        }
예제 #21
0
        private System.Windows.Controls.GroupBox AddTextTemplate(string title, int count, string isEnabled = "True",
                                                                 string targetExtension = "", string defaultText = "", int charasetIndex = 0)
        {
            ThicknessConverter thicknessConverter = new ThicknessConverter();

            System.Windows.Controls.GroupBox groupBox = new System.Windows.Controls.GroupBox();
            groupBox.Header = title;
            groupBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            groupBox.Margin = (Thickness)thicknessConverter.ConvertFromString("0,0,0,10");
            groupBox.Tag    = "Text";

            StackPanel parentStackPanel = new StackPanel();

            parentStackPanel.Margin = (Thickness)thicknessConverter.ConvertFromString("15");


            StackPanel childStackPanel_01 = new StackPanel();

            childStackPanel_01.Orientation = System.Windows.Controls.Orientation.Horizontal;
            childStackPanel_01.Margin      = (Thickness)thicknessConverter.ConvertFromString("0,0,0,10");

            System.Windows.Controls.Label typeLabel = new System.Windows.Controls.Label();
            typeLabel.Content           = "種類 : ";
            typeLabel.VerticalAlignment = VerticalAlignment.Center;

            System.Windows.Controls.Label textLabel = new System.Windows.Controls.Label();
            textLabel.Content = "テキスト";

            System.Windows.Controls.CheckBox isEnabledCheckbox = new System.Windows.Controls.CheckBox();
            isEnabledCheckbox.Content           = "有効";
            isEnabledCheckbox.Margin            = (Thickness)thicknessConverter.ConvertFromString("50,0,0,0");
            isEnabledCheckbox.VerticalAlignment = VerticalAlignment.Center;

            if (isEnabled == "True")
            {
                isEnabledCheckbox.IsChecked = true;
            }
            else
            {
                isEnabledCheckbox.IsChecked = false;
            }

            childStackPanel_01.Children.Add(typeLabel);
            childStackPanel_01.Children.Add(textLabel);
            childStackPanel_01.Children.Add(isEnabledCheckbox);


            StackPanel childStackPanel_02 = new StackPanel();

            childStackPanel_02.Orientation = System.Windows.Controls.Orientation.Horizontal;
            childStackPanel_02.Margin      = (Thickness)thicknessConverter.ConvertFromString("0,0,0,10");

            System.Windows.Controls.Label extLabel = new System.Windows.Controls.Label();
            extLabel.Content           = "対象拡張子";
            extLabel.Width             = 90;
            extLabel.VerticalAlignment = VerticalAlignment.Center;

            System.Windows.Controls.TextBox extTextBox = new System.Windows.Controls.TextBox();
            extTextBox.Width                    = 200;
            extTextBox.Margin                   = (Thickness)thicknessConverter.ConvertFromString("10,0,0,0");
            extTextBox.Padding                  = (Thickness)thicknessConverter.ConvertFromString("5,2");
            extTextBox.VerticalAlignment        = VerticalAlignment.Center;
            extTextBox.VerticalContentAlignment = VerticalAlignment.Center;
            extTextBox.Text = targetExtension;

            childStackPanel_02.Children.Add(extLabel);
            childStackPanel_02.Children.Add(extTextBox);


            System.Windows.Controls.TextBox textBox = new System.Windows.Controls.TextBox();
            textBox.AcceptsReturn = true;
            textBox.VerticalScrollBarVisibility   = ScrollBarVisibility.Visible;
            textBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            textBox.Padding = (Thickness)thicknessConverter.ConvertFromString("5,2");
            textBox.Height  = 120;
            textBox.Text    = defaultText;


            StackPanel childStackPanel_03 = new StackPanel();

            childStackPanel_03.Orientation = System.Windows.Controls.Orientation.Horizontal;
            childStackPanel_03.Margin      = (Thickness)thicknessConverter.ConvertFromString("0,10,0,0");

            System.Windows.Controls.Label charasetLabel = new System.Windows.Controls.Label();
            charasetLabel.Content           = "文字コード";
            charasetLabel.Width             = 90;
            charasetLabel.VerticalAlignment = VerticalAlignment.Center;

            System.Windows.Controls.ComboBox comboBox = new System.Windows.Controls.ComboBox();
            comboBox.SelectedIndex     = 0;
            comboBox.Width             = 100;
            comboBox.Margin            = (Thickness)thicknessConverter.ConvertFromString("10,0,0,0");
            comboBox.VerticalAlignment = VerticalAlignment.Center;

            ComboBoxItem comboBoxItem_01 = new ComboBoxItem();

            comboBoxItem_01.Content = "UTF-8";
            ComboBoxItem comboBoxItem_02 = new ComboBoxItem();

            comboBoxItem_02.Content = "UTF-16";
            ComboBoxItem comboBoxItem_03 = new ComboBoxItem();

            comboBoxItem_03.Content = "Shift_JIS";

            comboBox.Items.Add(comboBoxItem_01);
            comboBox.Items.Add(comboBoxItem_02);
            comboBox.Items.Add(comboBoxItem_03);

            comboBox.SelectedIndex = charasetIndex;

            childStackPanel_03.Children.Add(charasetLabel);
            childStackPanel_03.Children.Add(comboBox);


            StackPanel childStackPanel_04 = new StackPanel();

            childStackPanel_04.Orientation = System.Windows.Controls.Orientation.Horizontal;
            childStackPanel_04.Margin      = (Thickness)thicknessConverter.ConvertFromString("0,15,0,0");

            System.Windows.Controls.Button delButton = new System.Windows.Controls.Button();
            delButton.Content = "テンプレートを削除";
            delButton.Name    = "delButton_" + count.ToString();

            delButton.SetResourceReference(System.Windows.Controls.Control.TemplateProperty, "delButton");

            delButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            delButton.Width  = 120;
            delButton.Height = 25;
            delButton.Click += DeleteTemplate_Click;

            System.Windows.Controls.Button moveUpButton = new System.Windows.Controls.Button();
            moveUpButton.Name                = "moveToUp_" + count.ToString();
            moveUpButton.Content             = "↑";
            moveUpButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            moveUpButton.Margin              = (Thickness)thicknessConverter.ConvertFromString("90,0,0,0");
            moveUpButton.Width               = 40;
            moveUpButton.Height              = 25;
            moveUpButton.Click              += MoveToUp;

            System.Windows.Controls.Button moveBottomButton = new System.Windows.Controls.Button();
            moveBottomButton.Name                = "moveToBottom_" + count.ToString();
            moveBottomButton.Content             = "↓";
            moveBottomButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            moveBottomButton.Margin              = (Thickness)thicknessConverter.ConvertFromString("10,0,0,0");
            moveBottomButton.Width               = 40;
            moveBottomButton.Height              = 25;
            moveBottomButton.Click              += MoveToBottom;

            childStackPanel_04.Children.Add(delButton);
            childStackPanel_04.Children.Add(moveUpButton);
            childStackPanel_04.Children.Add(moveBottomButton);


            parentStackPanel.Children.Add(childStackPanel_01);
            parentStackPanel.Children.Add(childStackPanel_02);
            parentStackPanel.Children.Add(textBox);
            parentStackPanel.Children.Add(childStackPanel_03);
            parentStackPanel.Children.Add(childStackPanel_04);

            groupBox.Content = parentStackPanel;

            return(groupBox);
        }