public WindowGenerateLayout()
        {
            InitializeComponent();

            for (int i = 0; i < _screens.Length; i++)
            {
                var radioButtonCentered = new RadioButtonCentered
                {
                    Text   = string.Format("Screen #{0} ({1} x {2})", i, _screens[i].Bounds.Width, _screens[i].Bounds.Height),
                    Height = 22
                };
                radioButtonCentered.Checked += (sender, args) => GenerateLayout();
                StackPanel_Screens.Children.Add(radioButtonCentered);
            }
            if (StackPanel_Screens.Children.OfType <RadioButtonCentered>().Any())
            {
                StackPanel_Screens.Children.OfType <RadioButtonCentered>().First().IsChecked = true;
            }

            TextBox_XYWidthHeight.TextChanged += (sender, args) => UCScreenPreview_Main_Update();
            SizeChanged += (sender, args) => UCScreenPreview_Main_Update();
            CheckBox_FixedTableSize.Checked += (sender, args) =>
            {
                Label_TableWidth.IsEnabled                = true;
                Label_TableHeight.IsEnabled               = true;
                TextBox_TableWidth.IsEnabled              = true;
                TextBox_TableHeight.IsEnabled             = true;
                RadioButtonCentered_FitByWidth.IsEnabled  = false;
                RadioButtonCentered_FitByHeight.IsEnabled = false;
                GenerateLayout();
            };
            CheckBox_FixedTableSize.Unchecked += (sender, args) =>
            {
                Label_TableWidth.IsEnabled                = false;
                Label_TableHeight.IsEnabled               = false;
                TextBox_TableWidth.IsEnabled              = false;
                TextBox_TableHeight.IsEnabled             = false;
                RadioButtonCentered_FitByWidth.IsEnabled  = true;
                RadioButtonCentered_FitByHeight.IsEnabled = true;
                GenerateLayout();
            };
            TextBox_TableColumns.TextChanged        += (sender, args) => GenerateLayout();
            TextBox_TableRows.TextChanged           += (sender, args) => GenerateLayout();
            RadioButtonCentered_FitByWidth.Checked  += (sender, args) => GenerateLayout();
            RadioButtonCentered_FitByHeight.Checked += (sender, args) => GenerateLayout();
            RadioButtonCentered_HorizontalAlignmentCenter.Checked  += (sender, args) => GenerateLayout();
            RadioButtonCentered_HorizontalAlignmentLeft.Checked    += (sender, args) => GenerateLayout();
            RadioButtonCentered_HorizontalAlignmentRight.Checked   += (sender, args) => GenerateLayout();
            RadioButtonCentered_HorizontalAlignmentStretch.Checked += (sender, args) => GenerateLayout();
            RadioButtonCentered_VerticalAlignmentBottom.Checked    += (sender, args) => GenerateLayout();
            RadioButtonCentered_VerticalAlignmentCenter.Checked    += (sender, args) => GenerateLayout();
            RadioButtonCentered_VerticalAlignmentStretch.Checked   += (sender, args) => GenerateLayout();
            RadioButtonCentered_VerticalAlignmentTop.Checked       += (sender, args) => GenerateLayout();
            TextBox_ScreenMargin.TextChanged += (sender, args) =>
            {
                GenerateLayout();
            };
            TextBox_TableWidth.TextChanged += (sender, args) =>
            {
                if (TextBox_TableWidth.IsFocused)
                {
                    try
                    {
                        var clientWidth = int.Parse(TextBox_TableWidth.Text) - WindowsBorderThicknessInPixelsLeft - WindowsBorderThicknessInPixelsRight;
                        var clientSize  = PokerStarsThemeTable.GetClientSizeByWidth(clientWidth);
                        TextBox_TableHeight.Text = string.Format("{0}", clientSize.Height + WindowsBorderThicknessInPixelsTop + WindowsBorderThicknessInPixelsBottom);
                    }
                    catch (Exception)
                    {
                    }
                }
            };
            TextBox_TableHeight.TextChanged += (sender, args) =>
            {
                if (TextBox_TableHeight.IsFocused)
                {
                    try
                    {
                        var clientHeight = int.Parse(TextBox_TableHeight.Text) - WindowsBorderThicknessInPixelsTop - WindowsBorderThicknessInPixelsBottom;
                        var clientSize   = PokerStarsThemeTable.GetClientSizeByHeight(clientHeight);
                        TextBox_TableWidth.Text = string.Format("{0}", clientSize.Width + WindowsBorderThicknessInPixelsLeft + WindowsBorderThicknessInPixelsRight);
                    }
                    catch (Exception)
                    {
                    }
                }
            };
            TextBox_TableWidth.LostFocus += (sender, args) =>
            {
                var clientWidth = int.Parse(TextBox_TableWidth.Text) - WindowsBorderThicknessInPixelsLeft - WindowsBorderThicknessInPixelsRight;
                if (clientWidth > PokerStarsThemeTable.WIDTH_MAX)
                {
                    TextBox_TableWidth.Text  = string.Format("{0}", PokerStarsThemeTable.WIDTH_MAX + WindowsBorderThicknessInPixelsLeft + WindowsBorderThicknessInPixelsRight);
                    TextBox_TableHeight.Text = string.Format("{0}", PokerStarsThemeTable.HEIGHT_MAX + WindowsBorderThicknessInPixelsTop + WindowsBorderThicknessInPixelsBottom);
                }
                if (clientWidth < PokerStarsThemeTable.WIDTH_MIN)
                {
                    TextBox_TableWidth.Text  = string.Format("{0}", PokerStarsThemeTable.WIDTH_MIN + WindowsBorderThicknessInPixelsLeft + WindowsBorderThicknessInPixelsRight);
                    TextBox_TableHeight.Text = string.Format("{0}", PokerStarsThemeTable.HEIGHT_MIN + WindowsBorderThicknessInPixelsTop + WindowsBorderThicknessInPixelsBottom);
                }
                GenerateLayout();
            };

            TextBox_TableHeight.LostFocus += (sender, args) =>
            {
                var clientHeight = int.Parse(TextBox_TableHeight.Text) - WindowsBorderThicknessInPixelsTop - WindowsBorderThicknessInPixelsBottom;
                if (clientHeight > PokerStarsThemeTable.HEIGHT_MAX)
                {
                    TextBox_TableWidth.Text  = string.Format("{0}", PokerStarsThemeTable.WIDTH_MAX + WindowsBorderThicknessInPixelsLeft + WindowsBorderThicknessInPixelsRight);
                    TextBox_TableHeight.Text = string.Format("{0}", PokerStarsThemeTable.HEIGHT_MAX + WindowsBorderThicknessInPixelsTop + WindowsBorderThicknessInPixelsBottom);
                }
                if (clientHeight < PokerStarsThemeTable.HEIGHT_MIN)
                {
                    TextBox_TableWidth.Text  = string.Format("{0}", PokerStarsThemeTable.WIDTH_MIN + WindowsBorderThicknessInPixelsLeft + WindowsBorderThicknessInPixelsRight);
                    TextBox_TableHeight.Text = string.Format("{0}", PokerStarsThemeTable.HEIGHT_MIN + WindowsBorderThicknessInPixelsTop + WindowsBorderThicknessInPixelsBottom);
                }
                GenerateLayout();
            };
            Grid_Main.MouseLeftButtonDown += (sender, args) =>
            {
                Grid_Main.Focus();
                GenerateLayout();
            };

            Loaded += (sender, args) =>
            {
                var clientRectangle = WinApi.GetClientRectangle(this.GetHandle());
                var windowRectangle = WinApi.GetWindowRectangle(this.GetHandle());

                WindowsBorderThicknessInPixelsLeft   = clientRectangle.Left - windowRectangle.Left;
                WindowsBorderThicknessInPixelsTop    = clientRectangle.Top - windowRectangle.Top;
                WindowsBorderThicknessInPixelsRight  = windowRectangle.Right - clientRectangle.Right;
                WindowsBorderThicknessInPixelsBottom = windowRectangle.Bottom - clientRectangle.Bottom;
                GenerateLayout();
            };

            // seed

            RadioButtonCentered_FitByWidth.IsChecked = true;
            CheckBox_FixedTableSize.IsChecked        = true;
            CheckBox_FixedTableSize.IsChecked        = false;
            TextBox_TableWidth.Text  = string.Format("{0}", PokerStarsThemeTable.WIDTH_DEFAULT + WindowsBorderThicknessInPixelsLeft + WindowsBorderThicknessInPixelsRight);
            TextBox_TableHeight.Text = string.Format("{0}", PokerStarsThemeTable.HEIGHT_DEFAULT + WindowsBorderThicknessInPixelsTop + WindowsBorderThicknessInPixelsBottom);
            RadioButtonCentered_HorizontalAlignmentStretch.IsChecked = true;
            RadioButtonCentered_VerticalAlignmentStretch.IsChecked   = true;
            UCScreenPreview_Main_Update();
        }
예제 #2
0
        public WindowTableTileEdit(Window owner, TableTile tableTile = null)
        {
            InitializeComponent();
            Owner = owner;
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            TableTile             = tableTile ?? new TableTile();

            // Hook

            Grid_Main.MouseLeftButtonDown += (sender, args) => Grid_Main.Focus();

            Closing += (sender, args) =>
            {
                if (_windowWindowsInfo != null)
                {
                    _windowWindowsInfo.Close();
                }
                if (_windowGenerateLayout != null)
                {
                    _windowGenerateLayout.Close();
                }
            };

            TextBox_RegexWindowTitle.TextChanged += (sender, args) => UpdateIFilter();
            TextBox_RegexWindowClass.TextChanged += (sender, args) => UpdateIFilter();

            TextBox_XYWidthHeight.TextChanged += (sender, args) => UCScreenPreview_Main_Update();
            CheckBox_SortTournamentsByStartingTime.Checked   += (sender, args) => UCScreenPreview_Main_Update();
            CheckBox_SortTournamentsByStartingTime.Unchecked += (sender, args) => UCScreenPreview_Main_Update();
            CheckBox_EnableAutoTile.Checked += (sender, args) =>
            {
                RadioButton_ToTheTop.IsEnabled        = true;
                RadioButton_ToTheClosest.IsEnabled    = true;
                Label_DisabledToTheTop.Visibility     = Visibility.Collapsed;
                Label_DisabledToTheClosest.Visibility = Visibility.Collapsed;
            };
            CheckBox_EnableAutoTile.Unchecked += (sender, args) =>
            {
                RadioButton_ToTheTop.IsEnabled        = false;
                RadioButton_ToTheClosest.IsEnabled    = false;
                Label_DisabledToTheTop.Visibility     = Visibility.Visible;
                Label_DisabledToTheClosest.Visibility = Visibility.Visible;
            };
            SizeChanged += (sender, args) => UCScreenPreview_Main_Update();
            Loaded      += (sender, args) =>
            {
                string text = TextBox_XYWidthHeight.Text; TextBox_XYWidthHeight.Text = text + "1"; TextBox_XYWidthHeight.Text = text;
                text = TextBox_RegexWindowTitle.Text; TextBox_RegexWindowTitle.Text = text + "1"; TextBox_RegexWindowTitle.Text = text;
                text = TextBox_RegexWindowClass.Text; TextBox_RegexWindowClass.Text = text + "1"; TextBox_RegexWindowClass.Text = text;
            };

            // Seed

            TextBox_Name.Text = TableTile.Name;
            TextBoxHotkey_Hotkey.KeyCombination = TableTile.KeyCombination;
            CheckBox_SortTournamentsByStartingTime.IsChecked = TableTile.SortByStartingHand;
            TextBox_RegexWindowTitle.Text = TableTile.RegexWindowTitle == null ? "" : TableTile.RegexWindowTitle.ToString();
            TextBox_RegexWindowClass.Text = TableTile.RegexWindowClass == null ? "" : TableTile.RegexWindowClass.ToString();
            StringBuilder sb = new StringBuilder(); foreach (var xywh in TableTile.XYWHs)

            {
                sb.Append(string.Format("{0} {1} {2} {3}{4}", xywh.X, xywh.Y, xywh.Width, xywh.Height, Environment.NewLine));
            }
            TextBox_XYWidthHeight.Text = sb.ToString();

            CheckBox_SortTournamentsByStartingTime.IsChecked = TableTile.SortByStartingHand;
            CheckBox_BringToFront.IsChecked   = TableTile.BringToFront;
            CheckBox_EnableAutoTile.IsChecked = TableTile.AutoTile;
            switch (TableTile.AutoTileMethod)
            {
            case AutoTileMethod.ToTheTopSlot:
                RadioButton_ToTheTop.IsChecked = true;
                break;

            case AutoTileMethod.ToTheClosestSlot:
                RadioButton_ToTheClosest.IsChecked = true;
                break;
            }
            TextBox_TableCountEqualOrGreaterThan.Text = string.Format("{0}", TableTile.TableCountEqualOrGreaterThan);
            TextBox_TableCountEqualOrLessThan.Text    = string.Format("{0}", TableTile.TableCountEqualOrLessThan);

            // ToolTips

            GroupBox_XYWidthHeight.ToolTip = "Create slots (one per line): X Y Width Height";
            ToolTipService.SetShowDuration(GroupBox_XYWidthHeight, 60000);

            CheckBox_SortTournamentsByStartingTime.ToolTip = "Older tournaments will target upper slots (cash tables won't be affected).";
            ToolTipService.SetShowDuration(CheckBox_SortTournamentsByStartingTime, 60000);

            Label_RegexWindowTitle.ToolTip = "Regular Expression (Regex) for window's title. You can learn and test regex at: http://rubular.com/ or any other similar site.";
            ToolTipService.SetShowDuration(Label_RegexWindowTitle, 60000);

            Label_RegexWindowClass.ToolTip = "Regular Expression (Regex) for window's class name. You can learn and test regex at: http://rubular.com/ or any other similar site.";
            ToolTipService.SetShowDuration(Label_RegexWindowClass, 60000);

            RadioButton_ToTheTop.ToolTip = new UCToolTipTableTilerAutoTileTop();
            ToolTipService.SetShowDuration(RadioButton_ToTheTop, 60000);

            RadioButton_ToTheClosest.ToolTip = new UCToolTipTableTilerAutoTileClosest();
            ToolTipService.SetShowDuration(RadioButton_ToTheClosest, 60000);

            Label_DisabledToTheTop.ToolTip = new UCToolTipTableTilerAutoTileTop();
            ToolTipService.SetShowDuration(Label_DisabledToTheTop, 60000);

            Label_DisabledToTheClosest.ToolTip = new UCToolTipTableTilerAutoTileClosest();
            ToolTipService.SetShowDuration(Label_DisabledToTheClosest, 60000);

            UCScreenPreview_Main_Update();
        }