Ejemplo n.º 1
0
        public TweakManager()
        {
            TweakStore.InitTweaks(Categorys);

            if (!Load(Categorys))
            {
                foreach (Tweak tweak in GetAllTweaks())
                {
                    tweak.State = TweakEngine.TestTweak(tweak) ? Tweak.States.SelGroupe : Tweak.States.Unsellected;
                }

                Store();
            }

            /*foreach (TweakStore.Category category in Categorys.Values)
             * {
             *  foreach (TweakStore.Group group in category.Groups.Values)
             *  {
             *      foreach (Tweak tweak in group.Tweaks.Values)
             *      {
             *          TweakList.Add(tweak.guid, tweak);
             *      }
             *  }
             * }*/


            Timer          = new DispatcherTimer();
            Timer.Tick    += new EventHandler(OnTimerTick);
            Timer.Interval = new TimeSpan(0, 0, 0, 0, 1000);
            Timer.Start();

            NextTweakCheck = 0;
        }
Ejemplo n.º 2
0
        public bool TestTweak(Tweak tweak, bool fixChanged = false)
        {
            if (!tweak.IsAvailable())
            {
                return(false);
            }

            bool status;

            if (AdminFunc.IsAdministrator() || tweak.usrLevel || !App.client.IsConnected())
            {
                status = TweakEngine.TestTweak(tweak);
            }
            else
            {
                status = App.client.TestTweak(tweak);
            }

            if (tweak.Status != status)
            {
                tweak.Status         = status;
                tweak.LastChangeTime = DateTime.Now;

                Dictionary <string, string> Params = new Dictionary <string, string>();
                Params.Add("Name", tweak.Name);
                Params.Add("Group", tweak.Group);
                Params.Add("Category", tweak.Category);

                if (tweak.Status == false && tweak.State != Tweak.States.Unsellected)
                {
                    if (fixChanged == true && tweak.FixFailed == false)
                    {
                        ApplyTweak(tweak);

                        if (TestTweak(tweak, false) != true)
                        {
                            tweak.FixFailed = true;
                            App.LogError(App.EventIDs.TweakError, Params, App.EventFlags.Notifications, Translate.fmt("msg_tweak_stuck", tweak.Name, tweak.Group));
                        }
                        else
                        {
                            tweak.FixedCount++;
                            App.LogInfo(App.EventIDs.TweakFixed, Params, App.EventFlags.Notifications, Translate.fmt("msg_tweak_fixed", tweak.Name, tweak.Group));
                        }
                    }
                    else
                    {
                        App.LogWarning(App.EventIDs.TweakChanged, Params, App.EventFlags.Notifications, Translate.fmt("msg_tweak_un_done", tweak.Name, tweak.Group));
                    }
                }
            }
            return(status);
        }
Ejemplo n.º 3
0
            public bool IsAvailable()
            {
                switch (Type)
                {
                case TweakType.DisableService: return(ServiceHelper.GetServiceStatus(Key) != ServiceHelper.ServiceState.NotFound);

                case TweakType.DisableTask: return(TweakEngine.IsTaskPresent(Path, Key));

                case TweakType.BlockFile: return(File.Exists(Path));
                }
                return(winVer.TestHost());
            }
Ejemplo n.º 4
0
            public bool IsAvailable()
            {
                switch (Type)
                {
                case TweakType.DisableService: return(ServiceHelper.GetServiceState(Key) != ServiceHelper.ServiceState.NotFound);

                case TweakType.DisableTask: return(TweakEngine.IsTaskPresent(Path, Key));

                case TweakType.BlockFile:
                {
                    string FullPath = Environment.ExpandEnvironmentVariables(Path);
                    bool   ret      = File.Exists(FullPath);
                    return(ret);
                }
                }
                return(winVer.TestHost());
            }
Ejemplo n.º 5
0
        public bool UndoTweak(Tweak tweak)
        {
            if (!tweak.IsAvailable())
            {
                return(false);
            }

            bool success;

            if (AdminFunc.IsAdministrator() || tweak.usrLevel)
            {
                success = TweakEngine.UndoTweak(tweak);
            }
            else
            {
                success = App.client.UndoTweak(tweak);
            }
            //StatusChanged?.Invoke(this, new EventArgs());
            return(success);
        }