using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using HistoryWallEditTool.EventArg;

namespace HistoryWallEditTool.Controls
{
    /// <summary>
    /// SettingControlHorizontal.xaml 的互動邏輯
    /// </summary>
    public partial class SettingControlHorizontal : UserControl
    {
        #region Class Members

        private List<Label> extentLabel = null;
        private List<Label> rect = null;
        private List<Label> border = null;
        private Border eventContentRootBorder = null;
        private List<TextBlock> langTextBlocks = null;
        private Grid imgThumbGrid = null;
        private List<Label> langBtnLabels = null;
        private Utilities.UtilityClass.SettingType type;
        private int currentSelectIndex = 0;
        private string[] titleString;
        private string titleName;

        #endregion

        #region Properties

        public Utilities.UtilityClass.SettingType Type
        {
            get { return type; }
            set
            {
                type = value;
                Point pt = new Point(0, 0);
                switch (type)
                {
                    case Utilities.UtilityClass.SettingType.Timeline:
                        {
                            Grid gd1 = uxRootGrid.Children[0] as Grid;
                            Border bd1 = gd1.Children[0] as Border;
                            Grid gd2 = uxRootGrid.Children[1] as Grid;
                            Border bd2 = gd2.Children[0] as Border;
                            bd1.Background = new SolidColorBrush(HistoryWall.TimelineCollect.TextColor);
                            bd2.Background = new SolidColorBrush(HistoryWall.TimelineCollect.BackgroundColor);
                            ColorPicker picker1 = uxColorPickerGrid.Children[0] as ColorPicker;
                            picker1.SelectColor = HistoryWall.TimelineCollect.TextColor;
                            picker1.SelectPoint =
                                HistoryWall.TimelineCollect.TextColorPoint.HasValue ?
                                HistoryWall.TimelineCollect.TextColorPoint.Value : pt;
                            ColorPicker picker2 = uxColorPickerGrid.Children[1] as ColorPicker;
                            picker2.SelectColor = HistoryWall.TimelineCollect.BackgroundColor;
                            picker2.SelectPoint =
                                HistoryWall.TimelineCollect.BackgroundColorPoint.HasValue ?
                                HistoryWall.TimelineCollect.BackgroundColorPoint.Value : pt;
                            if (uxRootGrid.Children.Count > 2)
                            {
                                //Grid gd3 = uxRootGrid.Children[2] as Grid;
                                //Border bd3 = gd3.Children[0] as Border;
                                //bd3.BorderBrush = new SolidColorBrush(MainWindow.TimelineCollect.ThicknessColor);
                                //ColorPicker picker3 = uxColorPickerGrid.Children[2] as ColorPicker;
                                //picker3.SelectColor = MainWindow.TimelineCollect.ThicknessColor;
                                //picker3.SelectPoint =
                                //    MainWindow.TimelineCollect.ThicknessColorPoint.HasValue ?
                                //    MainWindow.TimelineCollect.ThicknessColorPoint.Value : pt;
                            }
                        }
                        break;
                    case Utilities.UtilityClass.SettingType.Event:
                        {
                            Grid gd1 = uxRootGrid.Children[0] as Grid;
                            Border bd1 = gd1.Children[0] as Border;
                            Grid gd2 = uxRootGrid.Children[1] as Grid;
                            Border bd2 = gd2.Children[0] as Border;
                            bd1.Background = new SolidColorBrush(HistoryWall.EventCollect.TextColor);
                            bd2.Background = new SolidColorBrush(HistoryWall.EventCollect.BackgroundColor);
                            ColorPicker picker1 = uxColorPickerGrid.Children[0] as ColorPicker;
                            picker1.SelectColor = HistoryWall.EventCollect.TextColor;
                            picker1.SelectPoint =
                                HistoryWall.EventCollect.TextColorPoint.HasValue ?
                                HistoryWall.EventCollect.TextColorPoint.Value : pt;
                            ColorPicker picker2 = uxColorPickerGrid.Children[1] as ColorPicker;
                            picker2.SelectColor = HistoryWall.EventCollect.BackgroundColor;
                            picker2.SelectPoint =
                                HistoryWall.EventCollect.BackgroundColorPoint.HasValue ?
                                HistoryWall.EventCollect.BackgroundColorPoint.Value : pt;
                            if (uxRootGrid.Children.Count > 2)
                            {
                                Grid gd3 = uxRootGrid.Children[2] as Grid;
                                Border bd3 = gd3.Children[0] as Border;
                                bd3.Background = new SolidColorBrush(HistoryWall.EventCollect.ThicknessColor);
                                ColorPicker picker3 = uxColorPickerGrid.Children[2] as ColorPicker;
                                picker3.SelectColor = HistoryWall.EventCollect.ThicknessColor;
                                picker3.SelectPoint =
                                    HistoryWall.EventCollect.ThicknessColorPoint.HasValue ?
                                    HistoryWall.EventCollect.ThicknessColorPoint.Value : pt;
                            }
                        }
                        break;
                    case Utilities.UtilityClass.SettingType.TimelineExtent:
                        {
                            Grid gd1 = uxRootGrid.Children[0] as Grid;
                            Border bd1 = gd1.Children[0] as Border;
                            Grid gd2 = uxRootGrid.Children[1] as Grid;
                            Border bd2 = gd2.Children[0] as Border;
                            bd1.Background = new SolidColorBrush(HistoryWall.TimelineExtentCollect.TextColor);
                            bd2.Background = new SolidColorBrush(HistoryWall.TimelineExtentCollect.BackgroundColor);
                            ColorPicker picker1 = uxColorPickerGrid.Children[0] as ColorPicker;
                            picker1.SelectColor = HistoryWall.TimelineExtentCollect.TextColor;
                            picker1.SelectPoint =
                                HistoryWall.TimelineExtentCollect.TextColorPoint.HasValue ?
                                HistoryWall.TimelineExtentCollect.TextColorPoint.Value : pt;
                            ColorPicker picker2 = uxColorPickerGrid.Children[1] as ColorPicker;
                            picker2.SelectColor = HistoryWall.TimelineExtentCollect.BackgroundColor;
                            picker2.SelectPoint =
                                HistoryWall.TimelineExtentCollect.BackgroundColorPoint.HasValue ?
                                HistoryWall.TimelineExtentCollect.BackgroundColorPoint.Value : pt;
                            if (uxRootGrid.Children.Count > 2)
                            {
                                Grid gd3 = uxRootGrid.Children[2] as Grid;
                                Border bd3 = gd3.Children[0] as Border;
                                bd3.Background = new SolidColorBrush(HistoryWall.TimelineExtentCollect.ThicknessColor);
                                ColorPicker picker3 = uxColorPickerGrid.Children[2] as ColorPicker;
                                picker3.SelectColor = HistoryWall.TimelineExtentCollect.ThicknessColor;
                                picker3.SelectPoint =
                                    HistoryWall.TimelineExtentCollect.ThicknessColorPoint.HasValue ?
                                    HistoryWall.TimelineExtentCollect.ThicknessColorPoint.Value : pt;
                            }
                        }
                        break;
                    case Utilities.UtilityClass.SettingType.EventContent:
                        {
                            Grid gd1 = uxRootGrid.Children[0] as Grid;
                            Border bd1 = gd1.Children[0] as Border;
                            Grid gd2 = uxRootGrid.Children[1] as Grid;
                            Border bd2 = gd2.Children[0] as Border;
                            bd1.Background = new SolidColorBrush(HistoryWall.EventContentCollect.TextColor);
                            bd2.Background = new SolidColorBrush(HistoryWall.EventContentCollect.BackgroundColor);
                            ColorPicker picker1 = uxColorPickerGrid.Children[0] as ColorPicker;
                            picker1.SelectColor = HistoryWall.EventContentCollect.TextColor;
                            picker1.SelectPoint =
                                HistoryWall.EventContentCollect.TextColorPoint.HasValue ?
                                HistoryWall.EventContentCollect.TextColorPoint.Value : pt;
                            ColorPicker picker2 = uxColorPickerGrid.Children[1] as ColorPicker;
                            picker2.SelectColor = HistoryWall.EventContentCollect.BackgroundColor;
                            picker2.SelectPoint =
                                HistoryWall.EventContentCollect.BackgroundColorPoint.HasValue ?
                                HistoryWall.EventContentCollect.BackgroundColorPoint.Value : pt;
                            if (uxRootGrid.Children.Count > 2)
                            {
                                Grid gd3 = uxRootGrid.Children[2] as Grid;
                                Border bd3 = gd3.Children[0] as Border;
                                bd3.Background = new SolidColorBrush(HistoryWall.EventContentCollect.ThicknessColor);
                                ColorPicker picker3 = uxColorPickerGrid.Children[2] as ColorPicker;
                                picker3.SelectColor = HistoryWall.EventContentCollect.ThicknessColor;
                                picker3.SelectPoint =
                                    HistoryWall.EventContentCollect.ThicknessColorPoint.HasValue ?
                                    HistoryWall.EventContentCollect.ThicknessColorPoint.Value : pt;
                            }
                        }
                        break;
                    case Utilities.UtilityClass.SettingType.BtnSelect:
                        {
                            Grid gd1 = uxRootGrid.Children[0] as Grid;
                            Border bd1 = gd1.Children[0] as Border;
                            Grid gd2 = uxRootGrid.Children[1] as Grid;
                            Border bd2 = gd2.Children[0] as Border;
                            Grid gd3 = uxRootGrid.Children[2] as Grid;
                            Border bd3 = gd3.Children[0] as Border;
                            Grid gd4 = uxRootGrid.Children[3] as Grid;
                            Border bd4 = gd4.Children[0] as Border;
                            bd1.Background = new SolidColorBrush(HistoryWall.BtnSelectCollect.TextColor);
                            bd2.Background = new SolidColorBrush(HistoryWall.BtnSelectCollect.BackgroundColor);
                            bd3.Background = new SolidColorBrush(HistoryWall.BtnSelectCollect.TextColorUnselect);
                            bd4.Background = new SolidColorBrush(HistoryWall.BtnSelectCollect.BackgroundColorUnselect);

                            ColorPicker picker1 = uxColorPickerGrid.Children[0] as ColorPicker;
                            picker1.SelectColor = HistoryWall.BtnSelectCollect.TextColor;
                            picker1.SelectPoint =
                                HistoryWall.BtnSelectCollect.TextColorPoint.HasValue ?
                                HistoryWall.BtnSelectCollect.TextColorPoint.Value : pt;
                            ColorPicker picker2 = uxColorPickerGrid.Children[1] as ColorPicker;
                            picker2.SelectColor = HistoryWall.BtnSelectCollect.BackgroundColor;
                            picker2.SelectPoint =
                                HistoryWall.BtnSelectCollect.BackgroundColorPoint.HasValue ?
                                HistoryWall.BtnSelectCollect.BackgroundColorPoint.Value : pt;
                            ColorPicker picker3 = uxColorPickerGrid.Children[2] as ColorPicker;
                            picker3.SelectColor = HistoryWall.BtnSelectCollect.TextColorUnselect;
                            picker3.SelectPoint =
                                HistoryWall.BtnSelectCollect.TextColorUnselectPoint.HasValue ?
                                HistoryWall.BtnSelectCollect.TextColorUnselectPoint.Value : pt;
                            ColorPicker picker4 = uxColorPickerGrid.Children[3] as ColorPicker;
                            picker4.SelectColor = HistoryWall.BtnSelectCollect.BackgroundColorUnselect;
                            picker4.SelectPoint =
                                HistoryWall.BtnSelectCollect.BackgroundColorUnselectPoint.HasValue ?
                                HistoryWall.BtnSelectCollect.BackgroundColorUnselectPoint.Value : pt;
                        }
                        break;
                }
                this.UpdateLayout();
            }
        }

        public string TitleName
        {
            get { return titleName; }
            set
            {
                titleName = value;
                uxTitleLbl.SetResourceReference(ContentProperty, titleName);
            }
        }

        public string[] TitleString
        {
            get { return titleString; }
            set
            {
                titleString = value;
                AddControls();
            }
        }

        #endregion

        #region Contrustor

        public SettingControlHorizontal()
        {
            InitializeComponent();
        }

        #endregion

        #region Events & EventHandler

        private void colorPicker_OnColorChanged(object sender, ColorEventArgs e)
        {
            Grid gd = uxRootGrid.Children[currentSelectIndex] as Grid;
            Border bd = gd.Children[0] as Border;
            SolidColorBrush colorBrush = new SolidColorBrush(e.SelectedColor);
            bd.Background = colorBrush;
            switch (type)
            {
                case Utilities.UtilityClass.SettingType.BtnSelect:
                    switch (currentSelectIndex)
                    {
                        case 0:
                            if (HistoryWall.MainBackCollect.DefaultLangIndex == 0)
                            {
                                langBtnLabels[0].Foreground = langBtnLabels[4].Foreground = colorBrush;
                            }
                            else if (HistoryWall.MainBackCollect.DefaultLangIndex == 1)
                            {
                                langBtnLabels[1].Foreground = langBtnLabels[4].Foreground = colorBrush;
                            }
                            else if (HistoryWall.MainBackCollect.DefaultLangIndex == 2)
                            {
                                langBtnLabels[2].Foreground = langBtnLabels[4].Foreground = colorBrush;
                            }
                            else if (HistoryWall.MainBackCollect.DefaultLangIndex == 3)
                            {
                                langBtnLabels[3].Foreground = langBtnLabels[4].Foreground = colorBrush;
                            }
                            break;
                        case 1:
                            if (HistoryWall.MainBackCollect.DefaultLangIndex == 0)
                            {
                                langBtnLabels[0].Background = langBtnLabels[4].Background = colorBrush;
                            }
                            else if (HistoryWall.MainBackCollect.DefaultLangIndex == 1)
                            {
                                langBtnLabels[1].Background = langBtnLabels[4].Background = colorBrush;
                            }
                            else if (HistoryWall.MainBackCollect.DefaultLangIndex == 2)
                            {
                                langBtnLabels[2].Background = langBtnLabels[4].Background = colorBrush;
                            }
                            else if (HistoryWall.MainBackCollect.DefaultLangIndex == 3)
                            {
                                langBtnLabels[3].Background = langBtnLabels[4].Background = colorBrush;
                            }
                            break;
                        case 2:
                            if (HistoryWall.MainBackCollect.DefaultLangIndex == 0)
                            {
                                langBtnLabels[1].Foreground = colorBrush;
                                langBtnLabels[2].Foreground = colorBrush;
                                langBtnLabels[3].Foreground = colorBrush;
                            }
                            else if (HistoryWall.MainBackCollect.DefaultLangIndex == 1)
                            {
                                langBtnLabels[0].Foreground = colorBrush;
                                langBtnLabels[2].Foreground = colorBrush;
                                langBtnLabels[3].Foreground = colorBrush;
                            }
                            else if (HistoryWall.MainBackCollect.DefaultLangIndex == 2)
                            {
                                langBtnLabels[0].Foreground = colorBrush;
                                langBtnLabels[1].Foreground = colorBrush;
                                langBtnLabels[3].Foreground = colorBrush;
                            }
                            else if (HistoryWall.MainBackCollect.DefaultLangIndex == 3)
                            {
                                langBtnLabels[0].Foreground = colorBrush;
                                langBtnLabels[1].Foreground = colorBrush;
                                langBtnLabels[2].Foreground = colorBrush;
                            }
                            break;
                        case 3:
                            if (HistoryWall.MainBackCollect.DefaultLangIndex == 0)
                            {
                                langBtnLabels[1].Background = colorBrush;
                                langBtnLabels[2].Background = colorBrush;
                                langBtnLabels[3].Background = colorBrush;
                            }
                            else if (HistoryWall.MainBackCollect.DefaultLangIndex == 1)
                            {
                                langBtnLabels[0].Background = colorBrush;
                                langBtnLabels[2].Background = colorBrush;
                                langBtnLabels[3].Background = colorBrush;
                            }
                            else if (HistoryWall.MainBackCollect.DefaultLangIndex == 2)
                            {
                                langBtnLabels[0].Background = colorBrush;
                                langBtnLabels[1].Background = colorBrush;
                                langBtnLabels[3].Background = colorBrush;
                            }
                            else if (HistoryWall.MainBackCollect.DefaultLangIndex == 3)
                            {
                                langBtnLabels[0].Background = colorBrush;
                                langBtnLabels[1].Background = colorBrush;
                                langBtnLabels[2].Background = colorBrush;
                            }
                            break;
                    }
                    break;
                case Utilities.UtilityClass.SettingType.Event:
                case Utilities.UtilityClass.SettingType.EventContent:
                case Utilities.UtilityClass.SettingType.Timeline:
                case Utilities.UtilityClass.SettingType.TimelineExtent:
                    if (rect != null)
                    {
                        switch (currentSelectIndex)
                        {
                            case 0:
                                for (int i = 0; i < rect.Count; i++)
                                {
                                    rect[i].Foreground = colorBrush;
                                }
                                break;
                            case 1:
                                for (int i = 0; i < rect.Count; i++)
                                {
                                    rect[i].Background = colorBrush;
                                }
                                break;
                            case 2:
                                for (int i = 0; i < rect.Count; i++)
                                {
                                    rect[i].BorderBrush = colorBrush;
                                }
                                break;
                        }
                    }
                    else if (border != null)
                    {
                        switch (currentSelectIndex)
                        {
                            case 0:
                                for (int i = 0; i < border.Count; i++)
                                {
                                    border[i].Foreground = colorBrush;
                                }
                                break;
                            case 1:
                                for (int i = 0; i < border.Count; i++)
                                {
                                    border[i].Background = colorBrush;
                                }
                                break;
                            case 2:
                                for (int i = 0; i < border.Count; i++)
                                {
                                    border[i].BorderBrush = colorBrush;
                                }
                                break;
                        }
                    }
                    else if (eventContentRootBorder != null)
                    {
                        switch (currentSelectIndex)
                        {
                            case 0:
                                for (int i = 0; i < langTextBlocks.Count; i++)
                                {
                                    langTextBlocks[i].Foreground = colorBrush;
                                }
                                break;
                            case 1:
                                eventContentRootBorder.Background = colorBrush;
                                break;
                            case 2:
                                {
                                    for (int i = 1; i < imgThumbGrid.Children.Count; i++)
                                    {
                                        Rectangle rectangle = imgThumbGrid.Children[i] as Rectangle;
                                        rectangle.Stroke = colorBrush;
                                        if (i == 7)
                                        {
                                            rectangle.Fill = colorBrush;
                                        }
                                    }
                                }
                                break;
                        }
                    }
                    else if (extentLabel != null)
                    {
                        switch (currentSelectIndex)
                        {
                            case 0:
                                extentLabel[1].Foreground = colorBrush;
                                break;
                            case 1:
                                for (int i = 0; i < extentLabel.Count; i++)
                                {
                                    extentLabel[i].Background = colorBrush;
                                }
                                break;
                            case 2:
                                for (int i = 0; i < extentLabel.Count; i++)
                                {
                                    extentLabel[i].BorderBrush = colorBrush;
                                }
                                break;
                        }
                    }
                    break;
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DisableAllControl();
            Button btn = sender as Button;
            Grid gd = btn.Parent as Grid;
            Border bd = gd.Children[0] as Border;
            bd.BorderBrush = Brushes.Gray;
            currentSelectIndex = uxRootGrid.Children.IndexOf(gd);
            ColorPicker picker = uxColorPickerGrid.Children[currentSelectIndex] as ColorPicker;
            picker.Visibility = Visibility.Visible;
        }

        private void CloseBtn_Click(object sender, RoutedEventArgs e)
        {
            List<Color> saveColor = new List<Color>();
            List<Point> savePoint = new List<Point>();
            for (int i = 0; i < uxColorPickerGrid.Children.Count; i++)
            {
                ColorPicker colorPicker = uxColorPickerGrid.Children[i] as ColorPicker;
                saveColor.Add(colorPicker.SelectColor);
                savePoint.Add(colorPicker.SelectPoint);
            }
            Grid gd = this.Parent as Grid;
            SettingWindow settingWindow = gd.Parent as SettingWindow;
            settingWindow.Close();
        }

        #endregion

        #region Methods

        public void SetterEventControl(Grid parentGrid)
        {
            List<Label> rectangles = new List<Label>();
            for (int i = 0; i < parentGrid.Children.Count; i++)
            {
                rectangles.Add(parentGrid.Children[i] as Label);
            }
            rect = rectangles;
        }

        public void SetTimelineControl(StackPanel sp)
        {
            List<Label> borders = new List<Label>();
            for (int i = 0; i < sp.Children.Count; i++)
            {
                borders.Add(sp.Children[i] as Label);
            }
            border = borders;
        }

        public void SetEventContentControl(Border border, StackPanel textPanel, Grid imgGrid)
        {
            eventContentRootBorder = border;
            List<TextBlock> textblocks = new List<TextBlock>();
            for (int i = 0; i < textPanel.Children.Count; i++)
            {
                TextBlock tb = textPanel.Children[i] as TextBlock;
                textblocks.Add(tb);
            }
            langTextBlocks = textblocks;
            imgThumbGrid = imgGrid;
        }

        public void SetExtentTimelineControl(StackPanel extentPanel)
        {
            List<Label> labels = new List<Label>();
            for (int i = 0; i < extentPanel.Children.Count; i++)
            {
                Label lbl = extentPanel.Children[i] as Label;
                labels.Add(lbl);
            }
            extentLabel = labels;
        }

        public void SetLangControl(StackPanel textPanel)
        {
            List<TextBlock> textblocks = new List<TextBlock>();
            for (int i = 0; i < textPanel.Children.Count; i++)
            {
                TextBlock tb = textPanel.Children[i] as TextBlock;
                textblocks.Add(tb);
            }
            langTextBlocks = textblocks;
        }

        public void SetButtonControl(Grid btnGrid)
        {
            List<Label> labels = new List<Label>();
            for (int i = 0; i < btnGrid.Children.Count; i++)
            {
                Label lbl = btnGrid.Children[i] as Label;
                labels.Add(lbl);
            }
            langBtnLabels = labels;
        }

        private void DisableAllControl()
        {
            for (int i = 0; i < uxRootGrid.Children.Count; i++)
            {
                Grid gd = uxRootGrid.Children[i] as Grid;
                Border bd = gd.Children[0] as Border;
                bd.BorderBrush = Brushes.LightGray;
            }
            for (int i = 0; i < uxColorPickerGrid.Children.Count; i++)
            {
                ColorPicker picker = uxColorPickerGrid.Children[i] as ColorPicker;
                picker.Visibility = Visibility.Collapsed;
            }
        }

        private void AddControls()
        {
            for (int i = 0; i < titleString.Length; i++)
            {
                if (titleString[i] != "fc_ThicknessColor")
                {
                    Label lbl = new Label();
                    lbl.SetResourceReference(ContentProperty, titleString[i]);
                    lbl.Height = 40;
                    lbl.FontSize = 18;
                    lbl.Foreground = new SolidColorBrush(Color.FromArgb(255, 188, 182, 168));
                    lbl.VerticalAlignment = VerticalAlignment.Top;
                    lbl.HorizontalAlignment = HorizontalAlignment.Left;
                    lbl.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
                    lbl.Margin = new Thickness(50, 90 + i * 80, 0, 0);
                    uxTextGrid.Children.Add(lbl);
                    Grid gd = new Grid();
                    gd.Width = 175;
                    gd.Height = 40;
                    gd.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                    gd.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                    gd.Margin = new Thickness(50, 130 + i * 80, 0, 0);
                    Border bd = new Border();
                    bd.CornerRadius = new CornerRadius(10);
                    bd.BorderThickness = new Thickness(2);
                    bd.BorderBrush = Brushes.LightGray;
                    Button btn = new Button();
                    btn.Opacity = 0.0;
                    btn.FocusVisualStyle = null;
                    btn.Click += Button_Click;
                    gd.Children.Add(bd);
                    gd.Children.Add(btn);
                    uxRootGrid.Children.Add(gd);
                    ColorPicker colorPicker = new ColorPicker(true);
                    colorPicker.OnColorChanged += colorPicker_OnColorChanged;
                    colorPicker.Visibility = Visibility.Collapsed;
                    uxColorPickerGrid.Children.Add(colorPicker);
                }
            }

            #region select first control

            Grid grid = uxRootGrid.Children[0] as Grid;
            Border border = grid.Children[0] as Border;
            border.BorderBrush = Brushes.Gray;
            ColorPicker picker = uxColorPickerGrid.Children[currentSelectIndex] as ColorPicker;
            picker.Visibility = Visibility.Visible;

            #endregion

            this.UpdateLayout();
        }

        #endregion
    }
}
