public BuildConfigXmlGenerator(IBuildConfigXmlClient buildConfigXmlClient = null, bool buildNonStubVersion = false) { _buildConfigXmlClient = buildConfigXmlClient; if (buildNonStubVersion) { BuildConfigXml = new BuildConfigXml(_buildConfigXmlClient, Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); } else { BuildConfigXml = Substitute.For <BuildConfigXml>(_buildConfigXmlClient, Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); } Xml.AppendChild(Xml.CreateXmlDeclaration("1.0", "UTF-8", null)); BuildTypeElement = (XmlElement)Xml.AppendChild(Xml.CreateElement("build-type")); BuildTypeElement.SetAttribute("uuid", Guid.NewGuid().ToString()); NameElement = (XmlElement)BuildTypeElement.AppendChild(Xml.CreateElement("name")); SettingsElement = (XmlElement)BuildTypeElement.AppendChild(Xml.CreateElement("settings")); SettingsElement.SetAttribute("ref", "CPlusPlusTemplate_v1"); ParametersElement = (XmlElement)SettingsElement.AppendChild(Xml.CreateElement("parameters")); }
SettingsElement CreateLanguagePicker(string title) { SettingsElement element = null; var currentCulture = string.IsNullOrWhiteSpace(Settings.LanguageOverride) ? Strings.Default : new CultureInfo(Settings.LanguageOverride).NativeName; element = new SettingsElement(title, () => { var sheet = new ActionSheet(title); sheet.Add(Strings.Default, () => { Settings.LanguageOverride = null; }); cultures.ForEach(x => sheet.Add(x.NativeName, () => { Strings.Culture = x; Settings.LanguageOverride = x.Name; element.Value = x.NativeName; })); sheet.Show(this, TableView); }) { style = UITableViewCellStyle.Value1, Value = currentCulture, }; return(element); }
private SettingsElement createTestElement() { SettingsElement root = new SettingsElement { ScrollbackLines = 300, FontFamily = "Segoe UI", FontSize = 14, DefaultProfile = new UserProfileElement() { Nickname1 = "Nick1", FullName = "FullName", Username = "******" } }; root.Networks.Add(new NetworkElement() { Name = "Memers", Port = 6667, UserProfile = new UserProfileElement() { Nickname1 = "Override", FullName = "Override", Username = "******" } }); return(root); }
public void TestSerialize() { ISettingsSerializer json = SettingsSerializerFactory.Get("JSON"); SettingsElement root = createTestElement(); string output = json.Serialize(root); Assert.IsTrue(output.Contains("FontFamily")); }
public string Serialize(SettingsElement rootElement) { XmlSerializer x = new XmlSerializer(typeof(SettingsElement)); using (StringWriter sw = new StringWriter()) { x.Serialize(sw, rootElement); return(sw.ToString()); } }
public void Load() { if (!File.Exists(_filePath)) { return; } using (var stream = new FileStream(_filePath, FileMode.Open, FileAccess.Read, FileShare.None)) { _settings = (SettingsElement)_serializer.Deserialize(stream); } }
public void Load() { try { string data = File.ReadAllText(SettingsFilePath); RootElement = _serializer.Deserialize(data); } catch (Exception ex) when(ex is FileNotFoundException || ex is DirectoryNotFoundException) { InitializeDefaults(); Save(); } }
public void TestDeserialize() { ISettingsSerializer json = SettingsSerializerFactory.Get("JSON"); SettingsElement root = createTestElement(); SettingsElement deserialized = json.Deserialize(Expected); Assert.IsTrue(deserialized.FontFamily == root.FontFamily); Assert.IsTrue(deserialized.ScrollbackLines == root.ScrollbackLines); Assert.IsTrue(deserialized.DefaultProfile.FullName == root.DefaultProfile.FullName); Assert.IsTrue(deserialized.Networks.First().UserProfile.FullName == root.Networks.First().UserProfile.FullName); }
SettingsElement CreateThemePicker(string title) { SettingsElement element = null; element = new SettingsElement(title, () => { var sheet = new ActionSheet("Theme"); MusicPlayer.iOS.Style.AvailableStyles.ForEach(x => sheet.Add(x.Id, () => { Settings.CurrentStyle = x.Id; element.Value = x.Id; })); sheet.Show(this, TableView); }) { style = UITableViewCellStyle.Value1, Value = Settings.CurrentStyle, }; return(element); }
public virtual void SetParameterValue(string name, string value) { Log.Trace($"XML SetParameterValue for: {BuildConfigId}, {name}: {value}"); var paramElement = (XmlElement)Xml.SelectSingleNode("/build-type/settings/parameters/param[@name='" + name + "']"); if (paramElement == null) { if (ParametersElement == null) { SettingsElement.AppendChild(Xml.CreateElement("parameters")); } var newParamElement = (XmlElement)ParametersElement.AppendChild(Xml.CreateElement("param")); newParamElement.SetAttribute("name", name); newParamElement.SetAttribute("value", value); } else { paramElement.SetAttribute("value", value); } _buildConfigXmlClient.Commit(this, $"TCC {BuildConfigId} Set Parameter {name} = {value}"); }
void setQualityValue(SettingsElement element, StreamQuality quality) { if (element == null) { return; } switch (quality) { case StreamQuality.High: element.Value = Strings.High; break; case StreamQuality.Medium: element.Value = Strings.Medium; break; case StreamQuality.Low: element.Value = Strings.Low; break; } element.Reload(); }
public void InitializeDefaults(bool overwrite = false) { if (Directory.Exists(BasePath)) { if (overwrite == false && File.Exists(SettingsFilePath)) { return; } } this.RootElement = new SettingsElement() { Networks = { new NetworkElement() { Name = "Cobalt", Hostname = "irc.cobaltapp.net", Port = 6667, Channels = { new ChannelElement() { Name = "#flux" } } } }, DefaultProfile = new UserProfileElement() { Nickname1 = $"{Environment.UserName}", Nickname2 = $"{Environment.UserName}_", Username = Environment.UserName, FullName = Environment.UserName, NickservPassword = "******" }, FontFamily = "Segoe UI", FontSize = 14, ScrollbackLines = 300 }; Save(); }
SettingsElement CreateQualityPicker(string title, StreamQuality quality, Action <StreamQuality> setQuality) { SettingsElement element = null; element = new SettingsElement(title, () => { new ActionSheet(title) { { $"{Strings.Low} {Strings.UsesLessData}", () => { setQuality(StreamQuality.Low); setQualityValue(element, StreamQuality.Low); } }, { Strings.Normal, () => { setQuality(StreamQuality.Medium); setQualityValue(element, StreamQuality.Medium); } }, { $"{Strings.High} {Strings.UsesMoreData}", () => { setQuality(StreamQuality.High); setQualityValue(element, StreamQuality.High); } } }.Show(this, TableView); }) { style = UITableViewCellStyle.Value1, Value = quality.ToString(), }; return(element); }
public SettingViewController() : base(UITableViewStyle.Plain, null) { Title = Strings.Settings; accountsSection = new MenuSection("Accounts") { (addNewAccountElement = new SettingsElement("Add Streaming Service", async() => { try{ var vc = new ServicePickerViewController(); this.PresentModalViewController(new UINavigationController(vc), true); var service = await vc.GetServiceTypeAsync(); await ApiManager.Shared.CreateAndLogin(service); UpdateAccounts(); } catch (TaskCanceledException) { } catch (Exception ex) { Console.WriteLine(ex); } })), (lastFmElement = string.IsNullOrEmpty(ApiConstants.LastFmApiKey) ? null : new SettingsSwitch("Last.FM", Settings.LastFmEnabled)), (twitterScrobbleElement = new SettingsSwitch("Auto Tweet", Settings.TwitterEnabled) { Detail = Settings.TwitterDisplay }), new SettingsSwitch("Import iPod Music", Settings.IncludeIpod) { ValueUpdated = ToggleIPod }, new MenuHelpTextElement( "Automatically imports and plays music from your local library. This saves data and space on your phone."), }; Root = new RootElement(Strings.Settings) { accountsSection, new MenuSection(Strings.Playback) { new SettingsSwitch(Strings.EnableLikeOnTheLockScreen, Settings.ThubsUpOnLockScreen) { ValueUpdated = (b => { Settings.ThubsUpOnLockScreen = b; RemoteControlHandler.SetupThumbsUp(); }) }, new MenuHelpTextElement(Strings.EnableLikeHint), new SettingsSwitch(Strings.EnableGaplessPlayback, Settings.ThubsUpOnLockScreen) { ValueUpdated = (b => { Settings.ThubsUpOnLockScreen = b; RemoteControlHandler.SetupThumbsUp(); }) }, new MenuHelpTextElement(Strings.EnableGapplessHint), new SettingsSwitch(Strings.PlayVideosWhenAvailable, Settings.PreferVideos) { ValueUpdated = (b => { Settings.PreferVideos = b; }) }, new MenuHelpTextElement(Strings.PlaysMusicVideoHint), new SettingsSwitch(Strings.PlayCleanVersionsOfSongs, Settings.FilterExplicit) { ValueUpdated = (b => { Settings.FilterExplicit = b; }) }, new MenuHelpTextElement(Strings.PlayesCleanVersionOfSongsHint), }, new MenuSection(Strings.Streaming) { new SettingsSwitch(Strings.DisableAllAccess, Settings.DisableAllAccess) { ValueUpdated = (on) => { Settings.DisableAllAccess = on; } }, new MenuHelpTextElement(Strings.DisableAllAccessHint), (CreateQualityPicker(Strings.CellularAudioQuality, Settings.MobileStreamQuality, (q) => Settings.MobileStreamQuality = q)), (CreateQualityPicker(Strings.WifiAudioQuality, Settings.WifiStreamQuality, (q) => Settings.WifiStreamQuality = q)), (CreateQualityPicker(Strings.VideoQuality, Settings.VideoStreamQuality, (q) => Settings.VideoStreamQuality = q)), (CreateQualityPicker(Strings.OfflineAudioQuality, Settings.DownloadStreamQuality, (q) => Settings.DownloadStreamQuality = q)), new MenuHelpTextElement(Strings.QualityHints) }, new MenuSection(Strings.Feedback) { new SettingsElement(Strings.SendFeedback, SendFeedback) { TextColor = iOS.Style.DefaultStyle.MainTextColor }, new SettingsElement($"{Strings.PleaseRate} {AppDelegate.AppName}", RateAppStore) { TextColor = iOS.Style.DefaultStyle.MainTextColor }, (ratingMessage = new MenuHelpTextElement(Strings.NobodyHasRatedYet)) }, new MenuSection(Strings.Settings) { CreateThemePicker("Theme"), new SettingsElement(Strings.ResyncDatabase, () => { Settings.ResetApiModes(); ApiManager.Shared.ReSync(); }), new MenuHelpTextElement(Strings.ResyncDatabaseHint), new SettingsElement(Strings.DownloadQueue, () => NavigationController.PushViewController(new DownloadViewController(), true)), (songsElement = new SettingsElement(Strings.SongsCount)) } }; if (lastFmElement != null) { lastFmElement.ValueUpdated = async b => { if (!b) { Settings.LastFmEnabled = false; ScrobbleManager.Shared.LogOut(); return; } var success = false; try { success = await ScrobbleManager.Shared.LoginToLastFm(); } catch (TaskCanceledException ex) { lastFmElement.Value = Settings.LastFmEnabled = false; TableView.ReloadData(); return; } Settings.LastFmEnabled = success; if (success) { return; } lastFmElement.Value = false; ReloadData(); App.ShowAlert($"{Strings.ErrorLoggingInto} Last.FM", Strings.PleaseTryAgain); }; } twitterScrobbleElement.ValueUpdated = async b => { if (!b) { Settings.TwitterEnabled = false; Settings.TwitterDisplay = ""; Settings.TwitterAccount = ""; twitterScrobbleElement.Detail = ""; return; } var store = new ACAccountStore(); var accountType = store.FindAccountType(ACAccountType.Twitter); var success = false; var result = await store.RequestAccessAsync(accountType); success = result.Item1; if (!success) { Settings.TwitterEnabled = false; twitterScrobbleElement.Value = false; ReloadData(); return; } var accounts = store.FindAccounts(accountType); if ((accounts?.Length ?? 0) == 0) { Settings.TwitterEnabled = false; twitterScrobbleElement.Value = false; ReloadData(); return; } if (accounts?.Length == 1) { Settings.TwitterEnabled = true; var a = accounts[0]; Settings.TwitterAccount = a.Identifier; twitterScrobbleElement.Detail = Settings.TwitterDisplay = a.UserFullName; ReloadData(); return; } var sheet = new ActionSheet("Twitter"); foreach (var a in accounts) { sheet.Add(a.Identifier, () => { Settings.TwitterEnabled = true; Settings.TwitterAccount = a.Identifier; twitterScrobbleElement.Detail = Settings.TwitterDisplay = a.UserFullName; ReloadData(); }); } sheet.Add(Strings.Nevermind, null, true); sheet.Show(this, TableView); }; }
public BuildConfigXmlGenerator WithTemplateId(string templateId) { SettingsElement = (XmlElement)BuildTypeElement.AppendChild(Xml.CreateElement("settings")); SettingsElement.SetAttribute("ref", templateId); return(this); }
private void SetDefaults() { _settings = new SettingsElement(); _settings.Audio = new AudioSettingsElement(); _settings.Audio.EffectsVolume = 100; }
public async Task <string> SerializeAsync(SettingsElement rootElement) { return(await Task.Run(() => Serialize(rootElement))); }
public AppConfiguration() { Settings = new SettingsElement(); Brokers = new BrokerElementCollection(); }
public SettingViewController() : base(UITableViewStyle.Plain, null) { Title = Strings.Settings; accountsSection = new MenuSection(Strings.Accounts) { (addNewAccountElement = new SettingsElement(Strings.AddStreamingService, async() => { try{ var vc = new ServicePickerViewController(); this.PresentModalViewController(new UINavigationController(vc), true); var service = await vc.GetServiceTypeAsync(); await ApiManager.Shared.CreateAndLogin(service); UpdateAccounts(); } catch (TaskCanceledException) { } catch (Exception ex) { Console.WriteLine(ex); } })), (lastFmElement = string.IsNullOrEmpty(ApiConstants.LastFmApiKey) ? null : new SettingsSwitch("Last.FM", Settings.LastFmEnabled)), (twitterScrobbleElement = new SettingsSwitch(Strings.AutoTweet, Settings.TwitterEnabled) { Detail = Settings.TwitterDisplay }), new SettingsSwitch(Strings.ImportIPodMusic, Settings.IncludeIpod) { ValueUpdated = ToggleIPod }, new MenuHelpTextElement(Strings.ImportIpodHint), }; Root = new RootElement(Strings.Settings) { accountsSection, new MenuSection(Strings.Playback) { new SettingsSwitch(Strings.EnableLikeOnTheLockScreen, Settings.ThubsUpOnLockScreen) { ValueUpdated = (b => { Settings.ThubsUpOnLockScreen = b; RemoteControlHandler.SetupThumbsUp(); }) }, new MenuHelpTextElement(Strings.EnableLikeHint), new SettingsSwitch(Strings.EnableGaplessPlayback, Settings.EnableGaplessPlayback) { ValueUpdated = (b => { Settings.EnableGaplessPlayback = b; }) }, new MenuHelpTextElement(Strings.EnableGapplessHint), new SettingsSwitch(Strings.PlayVideosWhenAvailable, Settings.PreferVideos) { ValueUpdated = (b => { Settings.PreferVideos = b; }) }, new MenuHelpTextElement(Strings.PlaysMusicVideoHint), new SettingsSwitch(Strings.PlayCleanVersionsOfSongs, Settings.FilterExplicit) { ValueUpdated = (b => { Settings.FilterExplicit = b; }) }, new MenuHelpTextElement(Strings.PlayesCleanVersionOfSongsHint), }, new MenuSection(Strings.Streaming) { new SettingsSwitch(Strings.DisableAllAccess, Settings.DisableAllAccess) { ValueUpdated = (on) => { Settings.DisableAllAccess = on; } }, new MenuHelpTextElement(Strings.DisableAllAccessHint), (CreateQualityPicker(Strings.CellularAudioQuality, Settings.MobileStreamQuality, (q) => Settings.MobileStreamQuality = q)), (CreateQualityPicker(Strings.WifiAudioQuality, Settings.WifiStreamQuality, (q) => Settings.WifiStreamQuality = q)), (CreateQualityPicker(Strings.VideoQuality, Settings.VideoStreamQuality, (q) => Settings.VideoStreamQuality = q)), (CreateQualityPicker(Strings.OfflineAudioQuality, Settings.DownloadStreamQuality, (q) => Settings.DownloadStreamQuality = q)), new MenuHelpTextElement(Strings.QualityHints) }, new MenuSection(Strings.Feedback) { new SettingsElement(Strings.SendFeedback, SendFeedback) { TextColor = iOS.Style.DefaultStyle.MainTextColor }, new SettingsElement($"{Strings.PleaseRate} {AppDelegate.AppName}", RateAppStore) { TextColor = iOS.Style.DefaultStyle.MainTextColor }, (ratingMessage = new MenuHelpTextElement(Strings.NobodyHasRatedYet)) }, new MenuSection(Strings.Settings) { CreateLanguagePicker(Strings.Language), CreateThemePicker(Strings.Theme), new SettingsElement(Strings.ResyncDatabase, () => { Database.Main.ResetDatabase(); Settings.ResetApiModes(); ApiManager.Shared.ReSync(); }), new MenuHelpTextElement(Strings.ResyncDatabaseHint), new SettingsSwitch(Strings.DisableAutoLock, Settings.DisableAutoLock) { ValueUpdated = (b => { Settings.PreferVideos = b; AutolockPowerWatcher.Shared.CheckStatus(); }) }, new MenuHelpTextElement(Strings.DisableAutoLockHelpText), new SettingsElement(Strings.DownloadQueue, () => NavigationController.PushViewController(new DownloadViewController(), true)), (songsElement = new SettingsElement(Strings.SongsCount)), new SettingsElement(Strings.Version) { Value = Device.AppVersion(), }, new StringElement(""), new StringElement(""), new StringElement(""), new StringElement(""), } }; if (lastFmElement != null) { lastFmElement.ValueUpdated = async b => { if (!b) { Settings.LastFmEnabled = false; ScrobbleManager.Shared.LogOut(); return; } var success = false; try { success = await ScrobbleManager.Shared.LoginToLastFm(); } catch (TaskCanceledException ex) { lastFmElement.Value = Settings.LastFmEnabled = false; TableView.ReloadData(); return; } Settings.LastFmEnabled = success; if (success) { return; } lastFmElement.Value = false; ReloadData(); App.ShowAlert(string.Format(Strings.ErrorLoggingInto, "Last.FM"), Strings.PleaseTryAgain); }; } twitterScrobbleElement.ValueUpdated = async b => { if (!b) { Settings.TwitterEnabled = false; Settings.TwitterDisplay = ""; Settings.TwitterAccount = ""; twitterScrobbleElement.Detail = ""; ScrobbleManager.Shared.LogOutOfTwitter(); return; } var success = await ScrobbleManager.Shared.LoginToTwitter(); if (!success) { Settings.TwitterEnabled = false; twitterScrobbleElement.Value = false; ReloadData(); return; } Settings.TwitterEnabled = true; twitterScrobbleElement.Detail = Settings.TwitterDisplay; ReloadData(); }; }
public Task <string> SerializeAsync(SettingsElement rootElement) { throw new NotImplementedException(); }
public string Serialize(SettingsElement rootElement) { return(JsonConvert.SerializeObject(rootElement)); }