protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.New)
            {
                _keyName = "Color";
                if (NavigationContext.QueryString.ContainsKey("keyName")) _keyName = NavigationContext.QueryString["keyName"];

                _numColors = _defaultAccentColors.Length;
                _colorEntries = new RegistryEntry[2, _numColors];
                for (int i = 0; i < 2; i++)
                    for (int j = 0; j < _defaultAccentColors.Length; j++)
                        _colorEntries[i, j] = new RegistryEntry(string.Format(AccentThemePath, i, j), _keyName, RegDataType.REG_DWORD, _keyName.Equals("Color") ? _defaultAccentColors[j] : _defaultComplementaryColors[j], "", 0, 255);

            #if false
                for (int i = 0; i < 2; i++)
                {
                    string s = string.Empty;
                    for (int j = 0; j < _defaultAccentColors.Length; j++)
                    {
                        uint v = _accentEntries[i, j].Value;
                        s += string.Format("{0}, ", v);
                    }
                    Debug.WriteLine(s);
                }
            #endif

                ReadButton_Click(this, null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.New)
            {
                if (!RegistryEntry.IsInteropUnlocked())
                {
                    MessageBox.Show("RPC component is failed to initialize!\n" +
                                    "Sorry but this application is designed to work with Nokia/Microsoft and Samsung handsets ONLY...\n" +
                                    "Press <OK> to terminate application", "Error", MessageBoxButton.OK);
                    App.Current.Terminate();
                }

                if (_settings.RunCount++ == 5)
                {
                    if (MessageBox.Show("Would you like to support this project by installing and rating \"5 stars\" my apps from the store? "+
                                        "It will take less than 5 minutes of your time...\n\n" +
                                        "I hope you will like these apps ☺\n\n" +
                                        "Press [OK] to open store or [Cancel] to igonre this note", "Developer's note", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                    {
                        await Launcher.LaunchUriAsync(new Uri("ms-windows-store:search?keyword=senssoft"));
                    }
                }

                if (_settings.CheckTweaks) CheckTweakListUpdate();
                ParseTweaksXml();
                BuildUI();
            }
            else if (e.NavigationMode == NavigationMode.Back && PhoneApplicationService.Current.State.ContainsKey("reload") && PhoneApplicationService.Current.State["reload"].ToString().Equals("True"))
            {
                if (_settings.CheckTweaks) CheckTweakListUpdate();
                ParseTweaksXml();
                BuildUI();
            }
        }
Beispiel #3
0
        void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
#if ARM
                string str = string.Empty;
                if (Registry.NativeRegistry.ReadString(Registry.RegistryHive.HKLM, string.Concat("SOFTWARE\\Microsoft\\EventSounds\\Sounds\\", ((Button)sender).Tag), "Sound", out str))
#else
                string str = EmulatorData.NotificationEventValues[((Button)sender).Tag as string];
#endif
                {
                    var ringtoneChooser = new RingtoneChooser() { SelectedRingtone = str };
                    var msgBox = new CustomMessageBox()
                    {
                        Tag = ((Button)sender).Tag,
                        Caption = string.Format("choose sound notification\nfor event \"{0}\"", ((Button)sender).Tag),
                        Content = ringtoneChooser,
                        LeftButtonContent = "choose",
                        RightButtonContent = "cancel",
                        IsFullScreen = true,
                    };

                    // Set background only for custom theme (not for default)
                    if ((Application.Current.Resources["PageHeaderBackgroundBrush"] as SolidColorBrush) !=
                        (Application.Current.Resources["PhoneBackgroundColor"] as SolidColorBrush))
                    {
                        msgBox.Background = Application.Current.Resources["PageHeaderBackgroundBrush"] as SolidColorBrush;
                    }

                    msgBox.Dismissed += (object boxSender, DismissedEventArgs ea) =>
                        {
                            if (ea.Result == 0)
                            {
                                var tag = ((CustomMessageBox)boxSender).Tag as string;
                                var value = ((RingtoneChooser)((CustomMessageBox)boxSender).Content).SelectedRingtone;
                                var regEntry = new RegistryEntry(@"HKLM\SOFTWARE\Microsoft\EventSounds\Sounds\"+tag, "Sound", RegDataType.REG_SZ);
                                regEntry.Value = value.Equals("none") ? string.Empty : value;
                            }
                        };

                    msgBox.Show();
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.New)
            {
                _keyName = "Color";
                if (NavigationContext.QueryString.ContainsKey("keyName"))
                {
                    _keyName = NavigationContext.QueryString["keyName"];
                }

                _numColors    = _defaultAccentColors.Length;
                _colorEntries = new RegistryEntry[2, _numColors];
                for (int i = 0; i < 2; i++)
                {
                    for (int j = 0; j < _defaultAccentColors.Length; j++)
                    {
                        _colorEntries[i, j] = new RegistryEntry(string.Format(AccentThemePath, i, j), _keyName, RegDataType.REG_DWORD, _keyName.Equals("Color") ? _defaultAccentColors[j] : _defaultComplementaryColors[j], "", 0, 255);
                    }
                }

#if false
                for (int i = 0; i < 2; i++)
                {
                    string s = string.Empty;
                    for (int j = 0; j < _defaultAccentColors.Length; j++)
                    {
                        uint v = _accentEntries[i, j].Value;
                        s += string.Format("{0}, ", v);
                    }
                    Debug.WriteLine(s);
                }
#endif

                ReadButton_Click(this, null);
            }
        }
Beispiel #5
0
        public Tweak(XElement xml)
        {
            if (xml.Attribute("category") == null) throw new AttributeMissingException("category", "tweak");
            if (xml.Attribute("name") == null) throw new AttributeMissingException("name", "tweak");
            if (xml.Attribute("type") == null) throw new AttributeMissingException("type","tweak");

            Category = xml.Attribute("category").Value;
            Name = xml.Attribute("name").Value;
            try { Type = (TweakType)Array.IndexOf(TweakNames.TweakTypeNames, xml.Attribute("type").Value); }
            catch { throw new Exception(string.Format("Error: unknown \"type\" value for the tweak \"{0}\"", Name)); }
            Description = xml.Attribute("description") != null ? xml.Attribute("description").Value : string.Empty;
            RequireReboot = (xml.Attribute("reboot") != null && xml.Attribute("reboot").Value.Equals("true")) ? 1 : 0;
            InputHelper = xml.Attribute("helper") != null ? xml.Attribute("helper").Value : string.Empty;

            var xmlEntries = xml.Descendants("entry");
            if (xmlEntries == null || xmlEntries.Count() == 0) throw new Exception(string.Format("Error: no registry entries found for the tweak \"{0}\"", Name));

            foreach (var xmlEntry in xmlEntries)
            {
                if (xmlEntry.Attribute("path") == null) throw new AttributeMissingException("path", "entry");
                if (xmlEntry.Attribute("name") == null) throw new AttributeMissingException("name", "entry");
                if (xmlEntry.Attribute("type") == null) throw new AttributeMissingException("type", "entry");

                string entryPath = xmlEntry.Attribute("path").Value;
                string entryName = xmlEntry.Attribute("name").Value;
                string entryType = xmlEntry.Attribute("type").Value;
                string entryComparer = xmlEntry.Attribute("comparer") != null ? xmlEntry.Attribute("comparer").Value : string.Empty;
                Int64 min = Int64.MinValue;
                Int64 max = Int64.MaxValue;
                if (Type == TweakType.Input)
                {
                    if (xmlEntry.Attribute("min") != null) Int64.TryParse(xmlEntry.Attribute("min").Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out min);
                    if (xmlEntry.Attribute("max") != null) Int64.TryParse(xmlEntry.Attribute("max").Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out max);
                }

                RegDataType dataType = RegistryEntry.DataTypeFromString(entryType);
                if (dataType == RegDataType.REG_UNKNOWN) throw new Exception(string.Format("Error, invalid data type \"{0}\" for the entry value", entryType));

                var defValue = xmlEntry.Attribute("default") != null ? DataConverter.FromString(xmlEntry.Attribute("default").Value, dataType) : null;

                var regEntry = new RegistryEntry(entryPath, entryName, dataType, defValue, entryComparer, min, max);

                var values = new List<RegValue>();
                var xmlValues = xmlEntry.Descendants("value");
                if (xmlValues == null) throw new Exception("Error: no values found for the registry entry");
                else if (xmlValues.Count() > 1 && Type == TweakType.Input) throw new Exception(string.Format("Error: too many values for the tweak type {0}", Type));
                else
                {
                    foreach (var xmlValue in xmlValues)
                    {
                        string valueDisplayName = (xmlValue.Attribute("name") != null) ? xmlValue.Attribute("name").Value : string.Empty;
                        values.Add(new RegValue(DataConverter.FromString(xmlValue.Value, dataType), valueDisplayName));
                    }
                }

                Entries.Add(new TweakEntry(regEntry, values));
            }
        }
Beispiel #6
0
 public TweakEntry(RegistryEntry regEntry, List<RegValue> values)
 {
     RegEntry = regEntry; Values = values;
 }
Beispiel #7
0
        public Tweak(XElement xml)
        {
            if (xml.Attribute("category") == null)
            {
                throw new AttributeMissingException("category", "tweak");
            }
            if (xml.Attribute("name") == null)
            {
                throw new AttributeMissingException("name", "tweak");
            }
            if (xml.Attribute("type") == null)
            {
                throw new AttributeMissingException("type", "tweak");
            }

            Category = xml.Attribute("category").Value;
            Name     = xml.Attribute("name").Value;
            try { Type = (TweakType)Array.IndexOf(TweakNames.TweakTypeNames, xml.Attribute("type").Value); }
            catch { throw new Exception(string.Format("Error: unknown \"type\" value for the tweak \"{0}\"", Name)); }
            Description = xml.Attribute("description") != null?xml.Attribute("description").Value : string.Empty;

            RequireReboot = (xml.Attribute("reboot") != null && xml.Attribute("reboot").Value.Equals("true")) ? 1 : 0;
            InputHelper   = xml.Attribute("helper") != null?xml.Attribute("helper").Value : string.Empty;

            var xmlEntries = xml.Descendants("entry");

            if (xmlEntries == null || xmlEntries.Count() == 0)
            {
                throw new Exception(string.Format("Error: no registry entries found for the tweak \"{0}\"", Name));
            }

            foreach (var xmlEntry in xmlEntries)
            {
                if (xmlEntry.Attribute("path") == null)
                {
                    throw new AttributeMissingException("path", "entry");
                }
                if (xmlEntry.Attribute("name") == null)
                {
                    throw new AttributeMissingException("name", "entry");
                }
                if (xmlEntry.Attribute("type") == null)
                {
                    throw new AttributeMissingException("type", "entry");
                }

                string entryPath     = xmlEntry.Attribute("path").Value;
                string entryName     = xmlEntry.Attribute("name").Value;
                string entryType     = xmlEntry.Attribute("type").Value;
                string entryComparer = xmlEntry.Attribute("comparer") != null?xmlEntry.Attribute("comparer").Value : string.Empty;

                Int64 min = Int64.MinValue;
                Int64 max = Int64.MaxValue;
                if (Type == TweakType.Input)
                {
                    if (xmlEntry.Attribute("min") != null)
                    {
                        Int64.TryParse(xmlEntry.Attribute("min").Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out min);
                    }
                    if (xmlEntry.Attribute("max") != null)
                    {
                        Int64.TryParse(xmlEntry.Attribute("max").Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out max);
                    }
                }

                RegDataType dataType = RegistryEntry.DataTypeFromString(entryType);
                if (dataType == RegDataType.REG_UNKNOWN)
                {
                    throw new Exception(string.Format("Error, invalid data type \"{0}\" for the entry value", entryType));
                }

                var defValue = xmlEntry.Attribute("default") != null?DataConverter.FromString(xmlEntry.Attribute("default").Value, dataType) : null;

                var regEntry = new RegistryEntry(entryPath, entryName, dataType, defValue, entryComparer, min, max);

                var values    = new List <RegValue>();
                var xmlValues = xmlEntry.Descendants("value");
                if (xmlValues == null)
                {
                    throw new Exception("Error: no values found for the registry entry");
                }
                else if (xmlValues.Count() > 1 && Type == TweakType.Input)
                {
                    throw new Exception(string.Format("Error: too many values for the tweak type {0}", Type));
                }
                else
                {
                    foreach (var xmlValue in xmlValues)
                    {
                        string valueDisplayName = (xmlValue.Attribute("name") != null) ? xmlValue.Attribute("name").Value : string.Empty;
                        values.Add(new RegValue(DataConverter.FromString(xmlValue.Value, dataType), valueDisplayName));
                    }
                }

                Entries.Add(new TweakEntry(regEntry, values));
            }
        }
Beispiel #8
0
 public TweakEntry(RegistryEntry regEntry, List <RegValue> values)
 {
     RegEntry = regEntry; Values = values;
 }
Beispiel #9
0
        void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
#if ARM
                string str = string.Empty;
                if (Registry.NativeRegistry.ReadString(Registry.RegistryHive.HKLM, string.Concat("SOFTWARE\\Microsoft\\EventSounds\\Sounds\\", ((Button)sender).Tag), "Sound", out str))
#else
                string str = EmulatorData.NotificationEventValues[((Button)sender).Tag as string];
#endif
                {
                    var ringtoneChooser = new RingtoneChooser() { SelectedRingtone = str };
                    var msgBox = new CustomMessageBox()
                    {
                        Tag = ((Button)sender).Tag,
                        Caption = string.Format("choose sound notification\nfor event \"{0}\"", ((Button)sender).Tag),
                        Content = ringtoneChooser,
                        LeftButtonContent = "choose",
                        RightButtonContent = "cancel",
                        IsFullScreen = true,
                    };

                    // Set background only for custom theme (not for default)
                    if ((Application.Current.Resources["PageHeaderBackgroundBrush"] as SolidColorBrush) !=
                        (Application.Current.Resources["PhoneBackgroundColor"] as SolidColorBrush))
                    {
                        msgBox.Background = Application.Current.Resources["PageHeaderBackgroundBrush"] as SolidColorBrush;
                    }

                    msgBox.Dismissed += (object boxSender, DismissedEventArgs ea) =>
                        {
                            if (ea.Result == 0)
                            {
                                var tag = ((CustomMessageBox)boxSender).Tag as string;
                                var value = ((RingtoneChooser)((CustomMessageBox)boxSender).Content).SelectedRingtone;
                                var regEntry = new RegistryEntry(@"HKLM\SOFTWARE\Microsoft\EventSounds\Sounds\"+tag, "Sound", RegDataType.REG_SZ);
                                regEntry.Value = value.Equals("none") ? string.Empty : value;
                            }
                        };

                    msgBox.Show();
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }