Inheritance: System.Windows.Controls.UserControl
Exemple #1
0
        void BuildUI()
        {
            List<SolidColorBrush> brushes = new List<SolidColorBrush>();
            brushes.Add(Application.Current.Resources["TweakEvenBackgroundBrush"] as SolidColorBrush);
            brushes.Add(Application.Current.Resources["TweakOddBackgroundBrush"] as SolidColorBrush);
            SystemTray.ProgressIndicator.IsVisible = true;

            LayoutRoot.Items.Clear();
            var categories = _tweaks.Select(t => t.Category).Distinct().ToList();
            categories.Add("Sounds");
            if (_settings.SortTweaks) categories = categories.OrderBy(t => t).ToList();
            foreach (var category in categories)
            {
                var pivotItem = new PivotItem() { Header = category };
                var content = new StackPanel();

                // Special event notification sounds tweaks
                if (category.Equals("Sounds"))
                {
#if ARM
                    string[] subKeyNames = null;
                    if (Registry.NativeRegistry.GetSubKeyNames(Registry.RegistryHive.HKLM, "Software\\Microsoft\\EventSounds\\Sounds", out subKeyNames))
#else
                    string[] subKeyNames = EmulatorData.NotificationEventValues.Keys.ToArray();
#endif
                    {
                        if (subKeyNames != null)
                        {
                            foreach (var str in subKeyNames)
                            {
#if ARM
                                string readStr = string.Empty;
                                if (Registry.NativeRegistry.ReadString(Registry.RegistryHive.HKLM, string.Concat("SOFTWARE\\Microsoft\\EventSounds\\Sounds\\", str), "Sound", out readStr))
                                {
#else
                                    string readStr = EmulatorData.NotificationEventValues[str];
#endif
                                    var btn = new Button()
                                    {
                                        Content = str,
                                        Tag = str,
                                        Margin = new Thickness(4, 2, 4, 2),
                                        Height = 90
                                    };
                                    btn.Click += button_Click;
                                    btn.IsEnabled = readStr.Length > 3;
                                    content.Children.Add(btn);
#if ARM
                                }
#endif
                            }
                        }
                    }
                }
                else
                {
                    var tweaksByCategory = _tweaks.Where(t => t.Category.Equals(category));
                    if (_settings.SortTweaks) tweaksByCategory = tweaksByCategory.OrderBy(t => t.Name);
                    int i = 0;
                    foreach (var tweak in tweaksByCategory)
                    {
                        tweak.Background = brushes[++i % 2];
                        dynamic tweakControl = null;
                        switch (tweak.Type)
                        {
                            case TweakType.Toggle: tweakControl = new ToggleTweak(tweak); break;
                            case TweakType.Enum: tweakControl = new EnumTweak(tweak); break;
                            case TweakType.Input: tweakControl = new InputTweak(tweak); break;
                            case TweakType.Color: tweakControl = new ColorTweak(tweak); break;
                        }
                        try
                        {
                            tweakControl.DataContext = tweak;
                            content.Children.Add(tweakControl);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, string.Format("Exception on adding tweak \"{0}\"", tweak.Name), MessageBoxButton.OK);
                        }
                    }
                }
                pivotItem.Content = new ScrollViewer() { Content = content };
                LayoutRoot.Items.Add(pivotItem);
            }
            SystemTray.ProgressIndicator.IsVisible = false;
        }
Exemple #2
0
        void BuildUI()
        {
            List<SolidColorBrush> brushes = new List<SolidColorBrush>();
            brushes.Add(Application.Current.Resources["TweakEvenBackgroundBrush"] as SolidColorBrush);
            brushes.Add(Application.Current.Resources["TweakOddBackgroundBrush"] as SolidColorBrush);
            SystemTray.ProgressIndicator.IsVisible = true;

            LayoutRoot.Items.Clear();
            var categories = _tweaks.Select(t => t.Category).Distinct().ToList();
            categories.Add("Sounds");
            if (_settings.SortTweaks) categories = categories.OrderBy(t => t).ToList();
            foreach (var category in categories)
            {
                var pivotItem = new PivotItem() { Header = category };
                var content = new StackPanel();

                // Special event notification sounds tweaks
                if (category.Equals("Sounds"))
                {
#if ARM
                    string[] subKeyNames = null;
                    if (Registry.NativeRegistry.GetSubKeyNames(Registry.RegistryHive.HKLM, "Software\\Microsoft\\EventSounds\\Sounds", out subKeyNames))
#else
                    string[] subKeyNames = EmulatorData.NotificationEventValues.Keys.ToArray();
#endif
                    {
                        if (subKeyNames != null)
                        {
                            foreach (var str in subKeyNames)
                            {
#if ARM
                                string readStr = string.Empty;
                                if (Registry.NativeRegistry.ReadString(Registry.RegistryHive.HKLM, string.Concat("SOFTWARE\\Microsoft\\EventSounds\\Sounds\\", str), "Sound", out readStr))
                                {
#else
                                    string readStr = EmulatorData.NotificationEventValues[str];
#endif
                                    var btn = new Button()
                                    {
                                        Content = str,
                                        Tag = str,
                                        Margin = new Thickness(4, 2, 4, 2),
                                        Height = 90
                                    };
                                    btn.Click += button_Click;
                                    btn.IsEnabled = readStr.Length > 3;
                                    content.Children.Add(btn);
#if ARM
                                }
#endif
                            }
                        }
                    }
                }
                else
                {
                    var tweaksByCategory = _tweaks.Where(t => t.Category.Equals(category));
                    if (_settings.SortTweaks) tweaksByCategory = tweaksByCategory.OrderBy(t => t.Name);
                    int i = 0;
                    foreach (var tweak in tweaksByCategory)
                    {
                        tweak.Background = brushes[++i % 2];
                        dynamic tweakControl = null;
                        switch (tweak.Type)
                        {
                            case TweakType.Toggle: tweakControl = new ToggleTweak(tweak); break;
                            case TweakType.Enum: tweakControl = new EnumTweak(tweak); break;
                            case TweakType.Input: tweakControl = new InputTweak(tweak); break;
                            case TweakType.Color: tweakControl = new ColorTweak(tweak); break;
                        }
                        try
                        {
                            tweakControl.DataContext = tweak;
                            content.Children.Add(tweakControl);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, string.Format("Exception on adding tweak \"{0}\"", tweak.Name), MessageBoxButton.OK);
                        }
                    }
                }
                pivotItem.Content = new ScrollViewer() { Content = content };
                LayoutRoot.Items.Add(pivotItem);
            }
            SystemTray.ProgressIndicator.IsVisible = false;
        }