public object Convert(object[] values,
                              Type targetType,
                              object parameter,
                              CultureInfo culture)
        {
            ThicknessConverter conv = new ThicknessConverter();
            string             thickStr;
            Thickness          thickness;

            if (values[0] != null)
            {
                if (values.Length >= 3)
                {
                    thickStr = values[2] as string;
                    if (conv.IsValid(thickStr))
                    {
                        thickness = (Thickness)conv.ConvertFromString(thickStr);
                        return(thickness);
                    }
                }
            }
            else
            {
                thickStr = values[1] as string;
                if (conv.IsValid(thickStr))
                {
                    thickness = (Thickness)conv.ConvertFromString(thickStr);
                    return(thickness);
                }
            }

            return(new Thickness(0));
        }
Exemple #2
0
        private static void ApplyBodyFormating(TableCell tc)
        {
            tc.BorderBrush = Brushes.DarkGray;
            ThicknessConverter conv = new ThicknessConverter();

            tc.BorderThickness = (Thickness)conv.ConvertFromString("0.02in");
            tc.Padding         = (Thickness)conv.ConvertFromString("0.03in");
        }
        public static void NamePositionChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var item = sender as DesignerContainer;

            ;
            if (item == null)
            {
                return;
            }

            var nameInfo = e.NewValue.ToString().Split('|');
            var tb       = item.Template.FindName("tbTag", item) as TextBlock;

            try
            {
                if (tb != null)
                {
                    tb.HorizontalAlignment = (HorizontalAlignment)Enum.Parse(typeof(HorizontalAlignment), nameInfo[0]);
                    tb.VerticalAlignment   = (VerticalAlignment)Enum.Parse(typeof(VerticalAlignment), nameInfo[1]);
                    var tc = new ThicknessConverter();
                    var convertFromString = tc.ConvertFromString(nameInfo[2]);
                    if (convertFromString != null)
                    {
                        var t = (Thickness)convertFromString;
                        tb.Margin = t;
                    }
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }
Exemple #4
0
 private static Thickness GetThemeThickness(string element, string attribute, Thickness fallback)
 {
     try {
         return((Thickness)_thicknessConverter.ConvertFromString(GetThemeValue(element, attribute)));
     }
     catch {
         return(fallback);
     }
 }
Exemple #5
0
 private void SetPaddingProperty()
 {
     if (controlProperties.HasPadding)
     {
         newItem = Convert.ChangeType(newItem, type);
         ThicknessConverter tc = new ThicknessConverter();
         newItem.Padding = (Thickness)tc.ConvertFromString(controlProperties.Padding);
     }
 }
Exemple #6
0
        // <Snippet1>
        private void changeThickness(object sender, SelectionChangedEventArgs args)
        {
            ListBoxItem        li = ((sender as ListBox).SelectedItem as ListBoxItem);
            ThicknessConverter myThicknessConverter = new ThicknessConverter();
            Thickness          th1 = (Thickness)myThicknessConverter.ConvertFromString(li.Content.ToString());

            border1.BorderThickness = th1;
            bThickness.Text         = "Border.BorderThickness =" + li.Content.ToString();
        }
        public void LoadGraph(Graph graph)
        {
            MainWindowViewModel.IdImage = 0;
            MainWindowViewModel.IdEdge  = 0;
            _thicknessConverter         = new ThicknessConverter();

            Vertexes = _graphContext.Vertexes.Where(n => n.GraphId == _graphId).ToList();
            Edges    = _graphContext.Edges.Where(n => n.GraphId == _graphId).ToList();

            var startVertexList = Edges.GroupBy(n => n.StartVertexId).Select(n => n.FirstOrDefault()).ToList();

            _connectedVertexesIdDict = new Dictionary <int, List <int> >();

            //dodawanie wierzcholkow polaczonych ze soba do slownika
            foreach (var vertex in startVertexList)
            {
                _connectedVertexesIdDict.Add(
                    vertex.StartVertexId,
                    new List <int>(Edges.Where(n => n.StartVertexId == vertex.StartVertexId).Select(n => n.EndVertexId).ToList()));
            }

            foreach (var vertex in Vertexes)
            {
                graph.Vertexes.Add(new Vertex
                {
                    Margin   = (Thickness)_thicknessConverter.ConvertFromString(vertex.Margin_string),
                    Position = Point.Parse(vertex.Position_string),
                    IdVertex = vertex.IdVertex,
                });
                MainWindowViewModel.IdImage++;
            }

            foreach (var selected in _connectedVertexesIdDict.Keys)
            {
                var selectedVertex = graph.Vertexes.FirstOrDefault(n => n.IdVertex == selected);
                foreach (var conVer in _connectedVertexesIdDict[selected])
                {
                    var connectedVertex = graph.Vertexes.FirstOrDefault(n => n.IdVertex == conVer);
                    var edge            = new Edge()
                    {
                        StartVertexId = selected,
                        EndVertexId   = conVer,
                        IdEdge        = MainWindowViewModel.IdEdge
                    };
                    edge.CalculateStartEndPoint(graph);
                    graph.Edges.Add(edge);
                    MainWindowViewModel.IdEdge++;
                    selectedVertex.ConnectedEdges.Add(edge);
                    selectedVertex.ConnectedVertexes.Add(connectedVertex);

                    connectedVertex.ConnectedEdges.Add(edge);
                    connectedVertex.ConnectedVertexes.Add(selectedVertex);
                    MainWindowViewModel.IdEdge++;
                }
            }
        }
        public void AddLine(string text, String margin = "0")
        {
            Paragraph pr = new Paragraph()
            {
                Margin = (Thickness)tConv.ConvertFromString(margin)
            };

            pr.Inlines.Add(text);
            Blocks.Add(pr);
        }
Exemple #9
0
        private void ChangeMargin(object sender, SelectionChangedEventArgs args)
        {
            ListBoxItem        li = ((sender as ListBox).SelectedItem as ListBoxItem);
            ThicknessConverter myThicknessConverter = new ThicknessConverter();
            Thickness          th1 = (Thickness)myThicknessConverter.ConvertFromString(li.Content.ToString());

            text1.Margin = th1;
            String st1 = (String)myThicknessConverter.ConvertToString(text1.Margin);

            gridVal.Text = "The Margin property is set to " + st1 + ".";
        }
Exemple #10
0
        private void SetMarginProperty()
        {
            if (!controlProperties.HasMargin)
            {
                return;
            }

            newItem = Convert.ChangeType(newItem, type);
            ThicknessConverter tc = new ThicknessConverter();

            newItem.Margin = (Thickness)tc.ConvertFromString(controlProperties.Margin);
        }
Exemple #11
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);
        }
        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>
        }
Exemple #13
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)}.");
     }
 }
Exemple #15
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})");
            }
        }
        /// <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, "异常日志");
            }
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            double v;

            if (value is string)
            {
                v = double.Parse((string)value, enus);
            }
            else if (value is double)
            {
                v = (double)value;
            }
            else if (value is float)
            {
                v = (float )value;
            }
            else if (value is long)
            {
                v = (long  )value;
            }
            else if (value is int)
            {
                v = (int   )value;
            }
            else if (value is short)
            {
                v = (short )value;
            }
            else if (value is byte)
            {
                v = (byte  )value;
            }
            else if (value is sbyte)
            {
                v = (sbyte )value;
            }
            else if (value is ushort)
            {
                v = (ushort)value;
            }
            else if (value is uint)
            {
                v = (uint  )value;
            }
            else if (value is ulong)
            {
                v = (ulong )value;
            }
            else if (value is Decimal)
            {
                v = Decimal.ToDouble((Decimal)value);
            }
            else
            {
                v = 0; Debug.WriteLine("WARNING: Invalid type of value! " + GetType().FullName);
            }

            switch (parameter as string)
            {
            case "Left": return(new Thickness(v, 0, 0, 0));

            case "Top": return(new Thickness(0, v, 0, 0));

            case "Right": return(new Thickness(0, 0, v, 0));

            case "Bottom": return(new Thickness(0, 0, 0, v));

            case "-Left": return(new Thickness(-v, 0, 0, 0));

            case "-Top": return(new Thickness(0, -v, 0, 0));

            case "-Right": return(new Thickness(0, 0, -v, 0));

            case "-Bottom": return(new Thickness(0, 0, 0, -v));

            default:
//					// ConverterParameter='0 * 0 0'
//					string s=((string) parameter).Replace("*", v.ToString(enus));

                // ConverterParameter='0 -{0} 0 0'      <-- OK
                // ConverterParameter='0 -{0:+23} 0 0'  <-- Not implemented
                string s     = (string)parameter;
                Match  match = Regex.Match(s, @"(\{)((?>\{(?<d>)|\}(?<-d>)|.?)*(?(d)(?!)))(\})", RegexOptions.Compiled);
                //TODO: parse and use additional arguments
                s = s.Replace(match.Value, v.ToString(enus));

                return(converter.ConvertFromString(s));
            }
        }
        /// <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()))));
            }
        }
Exemple #19
0
        public static object GetDPValueFromStr(this DependencyProperty dp, string str)
        {
            if (str == null)
            {
                return(null);
            }

            Type type = dp.PropertyType;

            if (type.IsEnum)
            {
                return(Enum.Parse(type, str));
            }

            if (type == typeof(double))
            {
                return(double.Parse(str));
            }

            if (type == typeof(float))
            {
                return(float.Parse(str));
            }

            if (type == typeof(decimal))
            {
                return(decimal.Parse(str));
            }

            if (type == typeof(string))
            {
                return(str);
            }

            if (type == typeof(bool))
            {
                return(bool.Parse(str));
            }

            if (type == typeof(byte))
            {
                return(byte.Parse(str));
            }

            if (type == typeof(int))
            {
                return(int.Parse(str));
            }

            if (type == typeof(char))
            {
                return(char.Parse(str));
            }

            if (type == typeof(Brush))
            {
                if (string.IsNullOrEmpty(str))
                {
                    return(null);
                }

                Color color = (Color)ColorConverter.ConvertFromString(str);

                return(new SolidColorBrush(color));
            }

            if (type == typeof(Thickness))
            {
                return(_thicknessConverter.ConvertFromString(str));
            }

            if (type == typeof(FontFamily))
            {
                return(_fontFamilyConverter.ConvertFromString(str));
            }

            if (type == typeof(FontWeight))
            {
                return(_fontWeightConverter.ConvertFromString(str));
            }

            if (type == typeof(Point))
            {
                return(_pointConverter.ConvertFromString(str));
            }

            return(str);
        }
Exemple #20
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);
        }
Exemple #21
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);
        }
        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();
        }
        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;
            }
            }
        }
Exemple #24
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);
        }