Ejemplo n.º 1
0
        void category_Click(object sender, RoutedEventArgs e)
        {
            TweakPresets.Category cat = (TweakPresets.Category)(sender as ToggleButton).Tag;

            foreach (ToggleButton curBtn in this.catGrid.Children)
            {
                curBtn.IsChecked  = curBtn == sender;
                curBtn.Background = new SolidColorBrush(((bool)curBtn.IsChecked) ? Color.FromArgb(255, 230, 240, 255) : Color.FromArgb(255, 235, 235, 235));
            }

            this.groupGrid.Children.Clear();
            this.groupGrid.RowDefinitions.Clear();

            this.tweakGrid.Children.Clear();
            this.tweakGrid.RowDefinitions.Clear();

            foreach (TweakPresets.Group group in cat.Groups.Values)
            {
                if (!showAll && !group.IsAvailable())
                {
                    continue;
                }

                TweakGroup item;
                if (!Groups.TryGetValue(group.Name, out item))
                {
                    item = new TweakGroup(group);
                    Groups.Add(group.Name, item);
                    //item.MouseDown += new MouseButtonEventHandler(group_Click);
                    item.Click  += new RoutedEventHandler(group_Click);
                    item.Toggle += new RoutedEventHandler(group_Toggle);
                    //item.ReqSU += new RoutedEventHandler(req_su);

                    item.label.Content       = group.Name;
                    item.Tag                 = group;
                    item.VerticalAlignment   = VerticalAlignment.Top;
                    item.HorizontalAlignment = HorizontalAlignment.Stretch;
                    item.Margin              = new Thickness(1, 1, 1, 1);

                    if (!group.IsAvailable())
                    {
                        item.toggle.IsEnabled = false;
                    }
                }

                item.Update(); // note: this tests all tweaks in the groupe

                this.groupGrid.Children.Add(item);
                RowDefinition row = new RowDefinition();
                row.Height = new GridLength(item.Height + 2);
                this.groupGrid.RowDefinitions.Add(row);
                Grid.SetRow(item, groupGrid.RowDefinitions.Count - 1);
                //Grid.SetColumn(item, 1);
            }
        }
Ejemplo n.º 2
0
        void category_dblClick(object sender, RoutedEventArgs e)
        {
            TweakPresets.Category cat = (TweakPresets.Category)(sender as ToggleButton).Tag;
            if (MessageBox.Show(string.Format("Apply all {0} tweaks?", cat.Name), "Private Win10", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
            {
                return;
            }

            if (!TestAdmin())
            {
                return;
            }

            foreach (TweakPresets.Group group in cat.Groups.Values)
            {
                ToggleGroup(group, TweakList.Tweak.States.SelGroupe, true);
            }

            UpdateView();
        }
Ejemplo n.º 3
0
        public bool Load(string FilePath, Dictionary <string, TweakPresets.Category> Categorys)
        {
            if (!File.Exists(FilePath))
            {
                return(false);
            }

            try
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(FilePath);

                double fileVersion = 0.0;
                double.TryParse(xDoc.DocumentElement.GetAttribute("Version"), out fileVersion);
#if false
                if (fileVersion != xmlVersion)
                {
                    if (fileVersion != 0 && fileVersion < xmlVersion)
                    {
                        FileOps.MoveFile(FilePath, App.dataPath + @"\Tweaks_old.xml", true);
                        Priv10Logger.LogWarning(App.EventIDs.AppWarning, null, App.EventFlags.Notifications, Translate.fmt("msg_tweaks_updated", App.dataPath + @"\Tweaks_old.xml"));
                    }
                    else
                    {
                        Priv10Logger.LogError("Failed to load tweaklist, unknown file version {0}, expected {1}", fileVersion, xmlVersion);
                    }
                    return(false);
                }
#endif

                int TotalCount = 0;
                int ErrorCount = 0;

                foreach (XmlNode node in xDoc.DocumentElement.ChildNodes)
                {
                    TotalCount++;
                    Tweak tweak = new Tweak();
                    if (!tweak.Load(node))
                    {
                        ErrorCount++;
                        continue;
                    }

                    TweakPresets.Category tweak_cat;
                    if (!Categorys.TryGetValue(tweak.Category, out tweak_cat))
                    {
                        tweak_cat = new TweakPresets.Category(tweak.Category);
                        Categorys.Add(tweak.Category, tweak_cat);
                    }

                    tweak_cat.Add(tweak);
                }

#if false
                if (ErrorCount != 0)
                {
                    Priv10Logger.LogError("Failed to load {0} tweak entries out of {1}", ErrorCount, TotalCount);
                }
                Priv10Logger.LogInfo("TweakManager loaded {0} entries", TotalCount - ErrorCount);
#endif
            }
            catch (Exception err)
            {
                AppLog.Exception(err);
                return(false);
            }
            return(true);
        }