Exemplo n.º 1
0
 public void SeedDefaultValues()
 {
     if (!_tableTiles.Any())
     {
         Add(TableTile.GetDefaultValues());
     }
 }
Exemplo n.º 2
0
        public ListViewItemTableTile(TableTile tableTile)
        {
            TableTile = tableTile;

            StackPanel sp = new StackPanel { Orientation = Orientation.Horizontal };

            CheckBox checkBox = new CheckBox
            {
                Content = "",
                IsChecked = TableTile.IsEnabled,
                Margin = new Thickness(0, 0, 0, 0)
            };
            checkBox.Checked += (sender, args) => TableTile.IsEnabled = true;
            checkBox.Unchecked += (sender, args) => TableTile.IsEnabled = false;

            Image image = new Image
            {
                Source = new BitmapImage(new Uri(string.Format(@"pack://application:,,,/Images/Resources/Size16x16/application_cascade.png"), UriKind.Absolute)),
                Width = 16,
                Height = 16,
                Margin = new Thickness(5, 0, 0, 0)
            };

            Label label = new Label
            {
                Content = TableTile.Name,
                Padding = new Thickness(0),
                Margin = new Thickness(5, 0, 0, 0)
            };

            sp.Children.Add(checkBox);
            sp.Children.Add(image);
            sp.Children.Add(label);
            Content = sp;
        }
Exemplo n.º 3
0
 public void Remove(TableTile tableTile)
 {
     lock (_lockTableTiles)
     {
         _tableTiles.Remove(tableTile);
     }
 }
Exemplo n.º 4
0
 public void Add(TableTile tableTile)
 {
     lock (_lockTableTiles)
     {
         if (!_tableTiles.Any(o => o.Name.Equals(tableTile.Name)))
         {
             _tableTiles.Add(tableTile);
         }
         _tableTiles.Sort((o0, o1) => string.CompareOrdinal(o0.Name, o1.Name));
     }
 }
Exemplo n.º 5
0
 public void FromXElement(XElement xElement, ref List <ExceptionPsHandler> exceptions, string exceptionHeader)
 {
     foreach (XElement xTableTile in xElement.Elements("TableTile"))
     {
         TableTile tableTile = TableTile.FromXElement(xTableTile, ref exceptions, exceptionHeader);
         if (tableTile != null)
         {
             Add(tableTile);
         }
     }
 }
Exemplo n.º 6
0
 public void Add(TableTile tableTile)
 {
     lock (_lockTableTiles)
     {
         if (!_tableTiles.Any(o => o.Name.Equals(tableTile.Name)))
         {
             _tableTiles.Add(tableTile);
         }
         _tableTiles.Sort((o0, o1) => string.CompareOrdinal(o0.Name, o1.Name));
     }
 }
Exemplo n.º 7
0
        public static TableTile FromXElement(XElement xElement, ref List<ExceptionPsHandler> exceptions, string exceptionHeader)
        {
            var tableTile = new TableTile();

            try
            {
                tableTile.Name = xElement.Element("Name").Value;
            }
            catch (Exception e)
            {
                exceptions.Add(new ExceptionPsHandler(e, exceptionHeader + " TableTile.FromXElement() xElement:" + Environment.NewLine + xElement));
                return null;
            }
            try
            {
                tableTile.IsEnabled = bool.Parse(xElement.Element("IsEnabled").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.KeyCombination = KeyCombination.Parse(xElement.Element("Hotkey").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.SortByStartingHand = bool.Parse(xElement.Element("SortByStartingHand").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.BringToFront = bool.Parse(xElement.Element("BringToFront").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.AutoTile = bool.Parse(xElement.Element("AutoTile").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.AutoTileMethod = ParseAutoTileMethod(xElement.Element("AutoTileMethod").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.RegexWindowTitle = new Regex(xElement.Element("RegexWindowTitle").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.RegexWindowClass = new Regex(xElement.Element("RegexWindowClass").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.XYWHs = xElement.Element("XYWHs") == null ? new Rectangle[0] : xElement.Element("XYWHs").Elements().Select(o =>
                {
                    string[] s = o.Value.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                    return new Rectangle(int.Parse(s[0]), int.Parse(s[1]), int.Parse(s[2]), int.Parse(s[3]));
                }).ToArray();
            }
            catch
            {
            }
            try
            {
                tableTile.TableCountEqualOrGreaterThan = int.Parse(xElement.Element("TableCountEqualOrGreaterThan").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.TableCountEqualOrLessThan = int.Parse(xElement.Element("TableCountEqualOrLessThan").Value);
            }
            catch
            {
            }

            return tableTile;
        }
Exemplo n.º 8
0
        public static TableTile FromXElement(XElement xElement, ref List <ExceptionPsHandler> exceptions, string exceptionHeader)
        {
            var tableTile = new TableTile();

            try
            {
                tableTile.Name = xElement.Element("Name").Value;
            }
            catch (Exception e)
            {
                exceptions.Add(new ExceptionPsHandler(e, exceptionHeader + " TableTile.FromXElement() xElement:" + Environment.NewLine + xElement));
                return(null);
            }
            try
            {
                tableTile.IsEnabled = bool.Parse(xElement.Element("IsEnabled").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.KeyCombination = KeyCombination.Parse(xElement.Element("Hotkey").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.SortByStartingHand = bool.Parse(xElement.Element("SortByStartingHand").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.BringToFront = bool.Parse(xElement.Element("BringToFront").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.AutoTile = bool.Parse(xElement.Element("AutoTile").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.AutoTileMethod = ParseAutoTileMethod(xElement.Element("AutoTileMethod").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.RegexWindowTitle = new Regex(xElement.Element("RegexWindowTitle").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.RegexWindowClass = new Regex(xElement.Element("RegexWindowClass").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.XYWHs = xElement.Element("XYWHs") == null ? new Rectangle[0] : xElement.Element("XYWHs").Elements().Select(o =>
                {
                    string[] s = o.Value.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                    return(new Rectangle(int.Parse(s[0]), int.Parse(s[1]), int.Parse(s[2]), int.Parse(s[3])));
                }).ToArray();
            }
            catch
            {
            }
            try
            {
                tableTile.TableCountEqualOrGreaterThan = int.Parse(xElement.Element("TableCountEqualOrGreaterThan").Value);
            }
            catch
            {
            }
            try
            {
                tableTile.TableCountEqualOrLessThan = int.Parse(xElement.Element("TableCountEqualOrLessThan").Value);
            }
            catch
            {
            }

            return(tableTile);
        }
Exemplo n.º 9
0
 public void Remove(TableTile tableTile)
 {
     lock (_lockTableTiles)
     {
         _tableTiles.Remove(tableTile);
     }
 }
Exemplo n.º 10
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();
        }
Exemplo n.º 11
0
        public void UpdateListView(TableTile tableTileToSelect = null)
        {
            var listView = ListView_TableTiles;
            listView.Items.Clear();
            foreach (var tableTile in App.TableTileManager.GetTableTilesCopy())
            {
                listView.Items.Add(new ListViewItemTableTile(tableTile));
            }

            if (tableTileToSelect != null)
            {
                foreach (var item in listView.Items)
                {
                    if (((ListViewItemTableTile)item).TableTile.Name.Equals(tableTileToSelect.Name))
                    {
                        listView.SelectedItem = item;
                        break;
                    }
                }
            }

            GridView_Name.ResetColumnWidths();
        }
        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();
        }