private void btnRemoveSettings_Click(object sender, RoutedEventArgs e)
 {
     MiscOperations.SetRegistryStartup(false);
     MiscOperations.RemoveConfig();
     WinForms.Application.Exit();
     System.Diagnostics.Process.GetCurrentProcess().Kill();
 }
        public App()
        {
            this.Startup += App_Startup;
            this.Exit    += App_Exit;

            // TODO search on up to date solution
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;

            // Init ConfigMgnr
            var test = ConfigMgnr.I.ConfigPath;

            MiscOperations.CreateStreamLaunchFile(ConfigMgnr.I.FolderPath);
            MiscOperations.CreateFavoriteConfig(ConfigMgnr.I.FolderPath);
            MiscOperations.SetRegistryStartup(ConfigMgnr.I.StartWithWindows);

            // Dynamically set colors from config
            try {
                if (!ConfigMgnr.I.Color_MainPanel.Equals("0"))
                {
                    Resources["Color_MainPanel"] = (SolidColorBrush)(new BrushConverter().ConvertFrom(ConfigMgnr.I.Color_MainPanel));
                }
                if (!ConfigMgnr.I.Color_SubPanel.Equals("0"))
                {
                    Resources["Color_SubPanel"] = (SolidColorBrush)(new BrushConverter().ConvertFrom(ConfigMgnr.I.Color_SubPanel));
                }
                if (!ConfigMgnr.I.Color_DefaultText.Equals("0"))
                {
                    Resources["Color_DefaultText"] = (SolidColorBrush)(new BrushConverter().ConvertFrom(ConfigMgnr.I.Color_DefaultText));
                }
                if (!ConfigMgnr.I.Color_Highlight.Equals("0"))
                {
                    Resources["Color_Highlight"] = (SolidColorBrush)(new BrushConverter().ConvertFrom(ConfigMgnr.I.Color_Highlight));
                }
                if (!ConfigMgnr.I.Color_BtnBG.Equals("0"))
                {
                    Resources["Color_BtnBG"] = (SolidColorBrush)(new BrushConverter().ConvertFrom(ConfigMgnr.I.Color_BtnBG));
                }
            }
            catch (Exception) {
                // Should be fine :)
            }
        }
Exemplo n.º 3
0
        public async Task <UpdateResult> Update()
        {
            // If no token assigned, don't do anything
            if (ConfigMgnr.I.Token.Equals("0"))
            {
                return(UpdateResult.Nothing);
            }

            // Get user id if not assigned
            if (ConfigMgnr.I.User.Equals("0"))
            {
                var ussr = Helix.HelixAPI.GetUser(ConfigMgnr.I.Token);
                if (ussr.Result.IsOk)
                {
                    ConfigMgnr.I.User = ussr.Result.User[0].Id;
                }
            }

            if (currentFollows == null)
            {
                var tempF = await HelixAPI.GetFollows(ConfigMgnr.I.User);

                if (!tempF.IsOk)
                {
                    return(UpdateResult.Nothing);
                }
                currentFollows = tempF;
            }

            // Get live streams from follows
            var tempS = await HelixAPI.GetStreams(currentFollows.GenerateUserIds());

            if (!tempS.IsOk)
            {
                return(UpdateResult.Nothing);
            }
            var s = await AddGames(tempS);

            // First check
            if (currentStreams == null)
            {
                currentStreams = s;
                return(UpdateResult.Update);
            }

            // Compare
            FavouriteGroup kingOfTheFill      = null;
            FavouriteGroup contenderOfTheFill = null;
            bool           foundNew           = false;

            foreach (var item in s.Stream)
            {
                if (!currentStreams.Stream.Exists(x => x.Channel.Equals(item.Channel)))
                {
                    foundNew = true;
                    if (MiscOperations.TryGetFavourite(item.Channel, out contenderOfTheFill))
                    {
                        if (kingOfTheFill == null || kingOfTheFill.Priority < contenderOfTheFill.Priority)
                        {
                            kingOfTheFill = contenderOfTheFill;
                        }
                    }
                }
            }

            // Results
            currentStreams = s;

            if (!foundNew)
            {
                return(UpdateResult.Nothing);
            }
            if (kingOfTheFill != null)
            {
                currentFavorites = kingOfTheFill;
                return(UpdateResult.Favorite);
            }
            return(UpdateResult.Update);
        }
        private void chkWin_Checked(object sender, RoutedEventArgs e)
        {
            ConfigMgnr.I.StartWithWindows = (bool)chkWin.IsChecked;

            MiscOperations.SetRegistryStartup((bool)chkWin.IsChecked);
        }