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; }
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); }