Esempio n. 1
0
 public bool Equals(KeyCombination kc)
 {
     return kc.Key == Key && kc.Ctrl == Ctrl && kc.Alt == Alt && kc.Shift == Shift;
 }
Esempio n. 2
0
        //
        public static IEnumerable<ExceptionPsHandler> LoadXml()
        {
            List<ExceptionPsHandler> exceptions = new List<ExceptionPsHandler>();
            try
            {
                XDocument xDoc = XDocument.Load(CONFIG_FILENAME);
                XElement root = xDoc.Element("Config");

                int version = int.Parse(root.Element("Version").Value);
                if (version < 17)
                {
                    System.IO.File.Move("pshandler.xml", "pshandler" + version + ".xml");
                    throw new NotSupportedException("Old pshandler.xml config.");
                }

                // Version

                VersionControl(root, version);

                GnuGplV3Agreement = GetBool(root, "GnuGplV3Agreement", ref exceptions, "LoadXml() GnuGplV3Agreement", GnuGplV3Agreement);

                #region Settings

                MinimizeToSystemTray = GetBool(root, "MinimizeToSystemTray", ref exceptions, "LoadXml() MinimizeToSystemTray", MinimizeToSystemTray);
                StartMinimized = GetBool(root, "StartMinimized", ref exceptions, "LoadXml() StartMinimized", StartMinimized);
                SaveGuiLocation = GetBool(root, "SaveGuiLocation", ref exceptions, "LoadXml() SaveGuiLocation", SaveGuiLocation);
                GuiLocationX = GetInt(root, "GuiLocationX", ref exceptions, "LoadXml() GuiLocationX", GuiLocationX);
                GuiLocationY = GetInt(root, "GuiLocationY", ref exceptions, "LoadXml() GuiLocationY", GuiLocationY);
                SaveGuiSize = GetBool(root, "SaveGuiSize", ref exceptions, "LoadXml() SaveGuiSize", SaveGuiSize);
                GuiWidth = GetInt(root, "GuiWidth", ref exceptions, "LoadXml() GuiWidth", GuiWidth);
                GuiHeight = GetInt(root, "GuiHeight", ref exceptions, "LoadXml() GuiHeight", GuiHeight);
                HotkeyExit = KeyCombination.Parse(GetString(root, "HotkeyExit", ref exceptions, "LoadXml() HotkeyExit", HotkeyExit.ToString()));
                PokerStarsThemeTable = PokerStarsThemeTable.Parse(GetString(root, "PokerStarsThemeTable", ref exceptions, "LoadXml() PokerStarsThemeTable", new PokerStarsThemesTable.Unknown().ToString()));
                foreach (XElement xImportFolderPath in root.Elements("ImportFolderPaths").SelectMany(o => o.Elements("ImportFolderPath")))
                    if (!String.IsNullOrEmpty(xImportFolderPath.Value))
                        ImportFolders.Add(xImportFolderPath.Value);

                #endregion

                #region Controller

                AutoclickImBack = GetBool(root, "AutoclickImBack", ref exceptions, "LoadXml() AutoclickImBack", AutoclickImBack);
                AutoclickTimebank = GetBool(root, "AutoclickTimebank", ref exceptions, "LoadXml() AutoclickTimebank", AutoclickTimebank);
                AutoclickYesSeatAvailable = GetBool(root, "AutoclickYesSeatAvailable", ref exceptions, "LoadXml() AutoclickYesSeatAvailable", AutoclickYesSeatAvailable);
                AutocloseTournamentRegistrationPopups = GetBool(root, "AutocloseTournamentRegistrationPopups", ref exceptions, "LoadXml() AutocloseTournamentRegistrationPopups", AutocloseTournamentRegistrationPopups);
                AutocloseHM2ApplyToSimilarTablesPopups = GetBool(root, "AutocloseHM2ApplyToSimilarTablesPopups", ref exceptions, "LoadXml() AutocloseHM2ApplyToSimilarTablesPopups", AutocloseHM2ApplyToSimilarTablesPopups);
                HotkeyHandReplay = KeyCombination.Parse(GetString(root, "HotkeyHandReplay", ref exceptions, "LoadXml() HotkeyHandReplay", HotkeyHandReplay.ToString()));
                HotkeyQuickPreview = KeyCombination.Parse(GetString(root, "HotkeyQuickPreview", ref exceptions, "LoadXml() HotkeyQuickPreview", HotkeyQuickPreview.ToString()));

                #endregion

                #region Randomizer

                EnableRandomizer = GetBool(root, "EnableRandomizer", ref exceptions, "LoadXml() EnableRandomizer", EnableRandomizer);
                RandomizerChance10 = GetInt(root, "RandomizerChance10", ref exceptions, "LoadXml() RandomizerChance10", RandomizerChance10);
                RandomizerChance20 = GetInt(root, "RandomizerChance20", ref exceptions, "LoadXml() RandomizerChance20", RandomizerChance20);
                RandomizerChance30 = GetInt(root, "RandomizerChance30", ref exceptions, "LoadXml() RandomizerChance30", RandomizerChance30);
                RandomizerChance40 = GetInt(root, "RandomizerChance40", ref exceptions, "LoadXml() RandomizerChance40", RandomizerChance40);
                RandomizerChance50 = GetInt(root, "RandomizerChance50", ref exceptions, "LoadXml() RandomizerChance50", RandomizerChance50);
                RandomizerChance60 = GetInt(root, "RandomizerChance60", ref exceptions, "LoadXml() RandomizerChance60", RandomizerChance60);
                RandomizerChance70 = GetInt(root, "RandomizerChance70", ref exceptions, "LoadXml() RandomizerChance70", RandomizerChance70);
                RandomizerChance80 = GetInt(root, "RandomizerChance80", ref exceptions, "LoadXml() RandomizerChance80", RandomizerChance80);
                RandomizerChance90 = GetInt(root, "RandomizerChance90", ref exceptions, "LoadXml() RandomizerChance90", RandomizerChance90);
                HotkeyRandomizerChance10 = KeyCombination.Parse(GetString(root, "HotkeyRandomizerChance10", ref exceptions, "LoadXml() HotkeyRandomizerChance10", new KeyCombination(Key.NumPad1, true, false, false).ToString()));
                HotkeyRandomizerChance20 = KeyCombination.Parse(GetString(root, "HotkeyRandomizerChance20", ref exceptions, "LoadXml() HotkeyRandomizerChance20", new KeyCombination(Key.NumPad2, true, false, false).ToString()));
                HotkeyRandomizerChance30 = KeyCombination.Parse(GetString(root, "HotkeyRandomizerChance30", ref exceptions, "LoadXml() HotkeyRandomizerChance30", new KeyCombination(Key.NumPad3, true, false, false).ToString()));
                HotkeyRandomizerChance40 = KeyCombination.Parse(GetString(root, "HotkeyRandomizerChance40", ref exceptions, "LoadXml() HotkeyRandomizerChance40", new KeyCombination(Key.NumPad4, true, false, false).ToString()));
                HotkeyRandomizerChance50 = KeyCombination.Parse(GetString(root, "HotkeyRandomizerChance50", ref exceptions, "LoadXml() HotkeyRandomizerChance50", new KeyCombination(Key.NumPad5, true, false, false).ToString()));
                HotkeyRandomizerChance60 = KeyCombination.Parse(GetString(root, "HotkeyRandomizerChance60", ref exceptions, "LoadXml() HotkeyRandomizerChance60", new KeyCombination(Key.NumPad6, true, false, false).ToString()));
                HotkeyRandomizerChance70 = KeyCombination.Parse(GetString(root, "HotkeyRandomizerChance70", ref exceptions, "LoadXml() HotkeyRandomizerChance70", new KeyCombination(Key.NumPad7, true, false, false).ToString()));
                HotkeyRandomizerChance80 = KeyCombination.Parse(GetString(root, "HotkeyRandomizerChance80", ref exceptions, "LoadXml() HotkeyRandomizerChance80", new KeyCombination(Key.NumPad8, true, false, false).ToString()));
                HotkeyRandomizerChance90 = KeyCombination.Parse(GetString(root, "HotkeyRandomizerChance90", ref exceptions, "LoadXml() HotkeyRandomizerChance90", new KeyCombination(Key.NumPad9, true, false, false).ToString()));

                #endregion

                #region Hud

                HudEnable = GetBool(root, "HudEnable", ref exceptions, "LoadXml() HudEnable", HudEnable);

                HudTimerEnable = GetBool(root, "HudTimerEnable", ref exceptions, "LoadXml() HudTimerEnable", HudTimerEnable);

                HudTimerShowTimer = GetBool(root, "HudTimerShowTimer", ref exceptions, "LoadXml() HudTimerShowTimer", HudTimerShowTimer);
                HudTimerLocationLocked = GetBool(root, "HudTimerLocationLocked", ref exceptions, "LoadXml() HudTimerLocationLocked", HudTimerLocationLocked);
                HudTimerShowHandCount = GetBool(root, "HudTimerShowHandCount", ref exceptions, "LoadXml() HudTimerShowHandCount", HudTimerShowHandCount);
                HudTimerDiff = GetInt(root, "HudTimerDiff", ref exceptions, "LoadXml() HudTimerDiff", HudTimerDiff);
                HudTimerHHNotFound = GetString(root, "HudTimerHHNotFound", ref exceptions, "LoadXml() HudTimerHHNotFound", HudTimerHHNotFound);
                HudTimerPokerTypeNotFound = GetString(root, "HudTimerPokerTypeNotFound", ref exceptions, "LoadXml() HudTimerPokerTypeNotFound", HudTimerPokerTypeNotFound);
                HudTimerMultiplePokerTypes = GetString(root, "HudTimerMultiplePokerTypes", ref exceptions, "LoadXml() HudTimerMultiplePokerTypes", HudTimerMultiplePokerTypes);

                HudBigBlindEnable = GetBool(root, "HudBigBlindEnable", ref exceptions, "LoadXml() HudBigBlindEnable", HudBigBlindEnable);
                HudBigBlindLocationLocked = GetBool(root, "HudBigBlindLocationLocked", ref exceptions, "LoadXml() HudBigBlindLocationLocked", HudBigBlindLocationLocked);
                HudBigBlindShowBB = GetBool(root, "HudBigBlindShowBB", ref exceptions, "LoadXml() HudBigBlindShowBB", HudBigBlindShowBB);
                HudBigBlindShowAdjustedBB = GetBool(root, "HudBigBlindShowAdjustedBB", ref exceptions, "LoadXml() HudBigBlindShowAdjustedBB", HudBigBlindShowAdjustedBB);
                HudBigBlindShowTournamentM = GetBool(root, "HudBigBlindShowTournamentM", ref exceptions, "LoadXml() HudBigBlindShowTournamentM", HudBigBlindShowTournamentM);
                HudBigBlindMByPlayerCount = GetBool(root, "HudBigBlindMByPlayerCount", ref exceptions, "LoadXml() HudBigBlindMByPlayerCount", HudBigBlindMByPlayerCount);
                HudBigBlindMByTableSize = GetBool(root, "HudBigBlindMByTableSize", ref exceptions, "LoadXml() HudBigBlindMByTableSize", HudBigBlindMByTableSize);
                HudBigBlindShowForOpponents = GetBool(root, "HudBigBlindShowForOpponents", ref exceptions, "LoadXml() HudBigBlindShowForOpponents", HudBigBlindShowForOpponents);
                HudBigBlindShowForHero = GetBool(root, "HudBigBlindShowForHero", ref exceptions, "LoadXml() HudBigBlindShowForHero", HudBigBlindShowForHero);
                HudBigBlindDecimals = GetInt(root, "HudBigBlindDecimals", ref exceptions, "LoadXml() HudBigBlindDecimals", HudBigBlindDecimals);
                HudBigBlindHHNotFound = GetString(root, "HudBigBlindHHNotFound", ref exceptions, "LoadXml() HudBigBlindHHNotFound", HudBigBlindHHNotFound);
                HudBigBlindPrefix = GetString(root, "HudBigBlindPrefix", ref exceptions, "LoadXml() HudBigBlindPrefix", HudBigBlindPrefix);
                HudBigBlindPostfix = GetString(root, "HudBigBlindPostfix", ref exceptions, "LoadXml() HudBigBlindPostfix", HudBigBlindPostfix);

                #endregion

                #region Hud Design

                HudTimerBackground = GetColor(root, "HudTimerBackground", ref exceptions, "LoadXml() HudTimerBackground", HudTimerBackground);
                HudTimerForeground = GetColor(root, "HudTimerForeground", ref exceptions, "LoadXml() HudTimerForeground", HudTimerForeground);
                HudTimerFontFamily = GetFontFamily(root, "HudTimerFontFamily", ref exceptions, "LoadXml() HudTimerFontFamily", HudTimerFontFamily);
                HudTimerFontWeight = GetFontWeight(root, "HudTimerFontWeight", ref exceptions, "LoadXml() HudTimerFontWeight", HudTimerFontWeight);
                HudTimerFontStyle = GetFontStyle(root, "HudTimerFontStyle", ref exceptions, "LoadXml() HudTimerFontStyle", HudTimerFontStyle);
                HudTimerFontSize = GetDouble(root, "HudTimerFontSize", ref exceptions, "LoadXml() HudTimerFontSize", HudTimerFontSize);
                HudTimerMargin = GetThickness(root, "HudTimerMargin", ref exceptions, "LoadXml() HudTimerMargin", HudTimerMargin);
                HudTimerBorderBrush = GetColor(root, "HudTimerBorderBrush", ref exceptions, "LoadXml() HudTimerBorderBrush", HudTimerBorderBrush);
                HudTimerBorderThickness = GetThickness(root, "HudTimerBorderThickness", ref exceptions, "LoadXml() HudTimerBorderThickness", HudTimerBorderThickness);
                HudTimerCornerRadius = GetCornerRadius(root, "HudTimerCornerRadius", ref exceptions, "LoadXml() HudTimerCornerRadius", HudTimerCornerRadius);

                HudBigBlindOpponentsBackground = GetColor(root, "HudBigBlindOpponentsBackground", ref exceptions, "LoadXml() HudBigBlindOpponentsBackground", HudBigBlindOpponentsBackground);
                HudBigBlindOpponentsForeground = GetColor(root, "HudBigBlindOpponentsForeground", ref exceptions, "LoadXml() HudBigBlindOpponentsForeground", HudBigBlindOpponentsForeground);
                HudBigBlindOpponentsFontFamily = GetFontFamily(root, "HudBigBlindOpponentsFontFamily", ref exceptions, "LoadXml() HudBigBlindOpponentsFontFamily", HudBigBlindOpponentsFontFamily);
                HudBigBlindOpponentsFontWeight = GetFontWeight(root, "HudBigBlindOpponentsFontWeight", ref exceptions, "LoadXml() HudBigBlindOpponentsFontWeight", HudBigBlindOpponentsFontWeight);
                HudBigBlindOpponentsFontStyle = GetFontStyle(root, "HudBigBlindOpponentsFontStyle", ref exceptions, "LoadXml() HudBigBlindOpponentsFontStyle", HudBigBlindOpponentsFontStyle);
                HudBigBlindOpponentsFontSize = GetDouble(root, "HudBigBlindOpponentsFontSize", ref exceptions, "LoadXml() HudBigBlindOpponentsFontSize", HudBigBlindOpponentsFontSize);
                HudBigBlindOpponentsMargin = GetThickness(root, "HudBigBlindOpponentsMargin", ref exceptions, "LoadXml() HudBigBlindOpponentsMargin", HudBigBlindOpponentsMargin);
                HudBigBlindOpponentsBorderBrush = GetColor(root, "HudBigBlindOpponentsBorderBrush", ref exceptions, "LoadXml() HudBigBlindOpponentsBorderBrush", HudBigBlindOpponentsBorderBrush);
                HudBigBlindOpponentsBorderThickness = GetThickness(root, "HudBigBlindOpponentsBorderThickness", ref exceptions, "LoadXml() HudBigBlindOpponentsBorderThickness", HudBigBlindOpponentsBorderThickness);
                HudBigBlindOpponentsCornerRadius = GetCornerRadius(root, "HudBigBlindOpponentsCornerRadius", ref exceptions, "LoadXml() HudBigBlindOpponentsCornerRadius", HudBigBlindOpponentsCornerRadius);

                HudBigBlindHeroBackground = GetColor(root, "HudBigBlindHeroBackground", ref exceptions, "LoadXml() HudBigBlindHeroBackground", HudBigBlindHeroBackground);
                HudBigBlindHeroForeground = GetColor(root, "HudBigBlindHeroForeground", ref exceptions, "LoadXml() HudBigBlindHeroForeground", HudBigBlindHeroForeground);
                HudBigBlindHeroFontFamily = GetFontFamily(root, "HudBigBlindHeroFontFamily", ref exceptions, "LoadXml() HudBigBlindHeroFontFamily", HudBigBlindHeroFontFamily);
                HudBigBlindHeroFontWeight = GetFontWeight(root, "HudBigBlindHeroFontWeight", ref exceptions, "LoadXml() HudBigBlindHeroFontWeight", HudBigBlindHeroFontWeight);
                HudBigBlindHeroFontStyle = GetFontStyle(root, "HudBigBlindHeroFontStyle", ref exceptions, "LoadXml() HudBigBlindHeroFontStyle", HudBigBlindHeroFontStyle);
                HudBigBlindHeroFontSize = GetDouble(root, "HudBigBlindHeroFontSize", ref exceptions, "LoadXml() HudBigBlindHeroFontSize", HudBigBlindHeroFontSize);
                HudBigBlindHeroMargin = GetThickness(root, "HudBigBlindHeroMargin", ref exceptions, "LoadXml() HudBigBlindHeroMargin", HudBigBlindHeroMargin);
                HudBigBlindHeroBorderBrush = GetColor(root, "HudBigBlindHeroBorderBrush", ref exceptions, "LoadXml() HudBigBlindHeroBorderBrush", HudBigBlindHeroBorderBrush);
                HudBigBlindHeroBorderThickness = GetThickness(root, "HudBigBlindHeroBorderThickness", ref exceptions, "LoadXml() HudBigBlindHeroBorderThickness", HudBigBlindHeroBorderThickness);
                HudBigBlindHeroCornerRadius = GetCornerRadius(root, "HudBigBlindHeroCornerRadius", ref exceptions, "LoadXml() HudBigBlindHeroCornerRadius", HudBigBlindHeroCornerRadius);

                try
                {
                    foreach (XElement element in GetXElement(root, "HudBigBlindOpponentsColorsByValue", ref exceptions, "LoadXml() HudBigBlindOpponentsColorsByValue", new XElement("HudBigBlindOpponentsColorsByValue")).Elements("ColorByValue"))
                    {
                        ColorByValue colorByValue = ColorByValue.FromXElement(element, ref exceptions, "LoadXml() ColorByValue");
                        if (colorByValue != null && HudBigBlindOpponentsColorsByValue.Count < 3)
                        {
                            HudBigBlindOpponentsColorsByValue.Add(colorByValue);
                        }
                    }
                }
                catch
                {
                }
                try
                {
                    foreach (XElement element in GetXElement(root, "HudBigBlindHeroColorsByValue", ref exceptions, "LoadXml() HudBigBlindHeroColorsByValue", new XElement("HudBigBlindHeroColorsByValue")).Elements("ColorByValue"))
                    {
                        ColorByValue colorByValue = ColorByValue.FromXElement(element, ref exceptions, "LoadXml() ColorByValue");
                        if (colorByValue != null && HudBigBlindHeroColorsByValue.Count < 3)
                        {
                            HudBigBlindHeroColorsByValue.Add(colorByValue);
                        }
                    }
                }
                catch (Exception)
                {
                }

                #endregion

                EnableTableTiler = GetBool(root, "EnableTableTiler", ref exceptions, "LoadXml() EnableTableTiler", EnableTableTiler);
                AutoTileCheckingTimeMs = GetInt(root, "AutoTileCheckingTimeMs", ref exceptions, "LoadXml() AutoTileCheckingTimeMs", 3000);

                #region Preferred Seat / Hud Timer+BigBlind LocationsXY

                for (int tableSize = 0; tableSize < 11; tableSize++)
                {
                    PreferredSeat[tableSize] = GetInt(root, string.Format("PreferredSeat_{0}", tableSize), ref exceptions, string.Format("LoadXml() PreferredSeat_{0}", tableSize), PreferredSeat[tableSize]);
                }

                for (int tableSize = 0; tableSize < 11; tableSize++)
                {
                    try
                    {
                        var xy = GetString(root, string.Format("HudTimerLocationsXY_{0}", tableSize), ref exceptions, string.Format("LoadXml() HudTimerLocationsXY_{0}", tableSize), string.Format("{0} {1}", DefaultHudTimerLocationsX[tableSize], DefaultHudTimerLocationsY[tableSize])).Split(' ');
                        HudTimerLocationsX[tableSize] = double.Parse(xy[0]);
                        HudTimerLocationsY[tableSize] = double.Parse(xy[1]);
                    }
                    catch
                    {
                    }
                }

                for (int tableSize = 0; tableSize < 11; tableSize++)
                {
                    for (int position = 0; position < 10; position++)
                    {
                        try
                        {
                            var xy = GetString(root, string.Format("HudBigBlindLocationsXY_{0}_{1}", tableSize, position), ref exceptions, string.Format("LoadXml() HudBigBlindLocationsXY_{0}_{1}", tableSize, position),
                                string.Format("{0} {1}", DefaultHudBigBlindLocationsX[tableSize][position], DefaultHudBigBlindLocationsX[tableSize][position])).Split(' ');
                            HudBigBlindLocationsX[tableSize][position] = double.Parse(xy[0]);
                            HudBigBlindLocationsY[tableSize][position] = double.Parse(xy[1]);
                        }
                        catch
                        {
                        }
                    }
                }

                #endregion

                App.TableTileManager.FromXElement(root.Element("TableTiles"), ref exceptions, "LoadXml()");
                App.PokerTypeManager.FromXElement(root.Element("PokerTypes"), ref exceptions, "LoadXml()");
            }
            catch (Exception e)
            {
                exceptions.Add(new ExceptionPsHandler(e, "LoadXml() Main Exception"));
            }

            App.PokerTypeManager.SeedDefaultValues();
            App.TableTileManager.SeedDefaultValues();
            CollectRecentColors();

            return exceptions;
        }