partial void ButtonOKClicked(AppKit.NSButton sender) { // save path to dictionary in user settings NSUserDefaults user = NSUserDefaults.StandardUserDefaults; user.SetString(TextDictionaryFolderPath.StringValue, NSUserDefaultsKeys.DictionaryFolderPath); user.SetString(TextAnkiMediaCollectionFolderPath.StringValue, NSUserDefaultsKeys.AnkiCollectionPath); View.Window?.Close(); }
void BtnSave_TouchUpInside(object sender, EventArgs e) { if (txtEmail.Text != null) { conf.SetString(txtEmail.Text, CONF_EMAIL); } if (txtToken.Text != null) { conf.SetString(txtToken.Text, CONF_TOKEN); } conf.Synchronize(); alertUser("The data was saved!"); update(); }
public override void ViewDidLoad() { base.ViewDidLoad(); LePreferencias(); txtNome.ShouldReturn += (textField) => { txtNome.ResignFirstResponder(); return(true); }; btnLer.TouchUpInside += (object sender, EventArgs e) => { LePreferencias(); }; btnGravar.TouchUpInside += (object sender, EventArgs e) => { prefs.SetBool(boolSwitch.On, "habilitado"); prefs.SetString(txtNome.Text, "user"); prefs.SetFloat(floatSlider.Value, "slider"); prefs.SetInt(Convert.ToInt32(lblInt.Text), "int"); prefs.SetDouble(dtPicker.Date.SecondsSinceReferenceDate, "data"); }; intStepper.ValueChanged += (object sender, EventArgs e) => { lblInt.Text = intStepper.Value.ToString(); }; }
public override void ViewWillDisappear(bool animated) { base.ViewWillDisappear(animated); btnReturn.TouchUpInside -= btnReturnTouchUpInside; btnMore.TouchUpInside -= btnMoreTouchUpInside; btnSearch.TouchUpInside -= btnSearchTouchUpInside; txtSearch.EditingChanged -= TxtSearchValueChangedHandler; btnVind.TouchUpInside -= btnVindTouchUpInside; _appController.UpdateCounter -= updateCounter; _appController.NavigationController.GotoTotemResultEvent -= gotoResultListHandler; var ser = JsonSerializer.SerializeToString(_appController.Eigenschappen); if (IsProfileNull) { userDefs.SetString(ser, "eigenschappen"); userDefs.Synchronize(); } else { _appController.AddOrUpdateEigenschappenSer(currProfiel.name, ser); } }
public async void InitAppAsync(NSUserDefaults settings) { try { Task <DateTime> lastSyncDateTask; //Init the whole local DB lastSyncDateTask = Manager.Instance.InitLocalDatabase(); //Show app initializing //ShowControllerFromSoryBoard("Init"); //Window.MakeKeyAndVisible(); //Initializing finished LastSyncDate = await lastSyncDateTask; Updater.Updater.Instance.LastSyncDate = LastSyncDate; //update last sync date settings.SetString(LastSyncDate.ToString(), "lastSyncDate"); //Set the root view controller //ShowControllerFromSoryBoard("Root"); (Window.RootViewController as RootViewController).InitStopped(); } catch (Exception ex) { ShowErrorMessage(ex.Message); } }
private void SaveValueToStorage(string value, string key) { NSUserDefaults userDefaults = NSUserDefaults.StandardUserDefaults; userDefaults.SetString(value, key); userDefaults.Synchronize(); }
private void SaveDataToUserDefault(String data, String key) { var userDefault = new NSUserDefaults(); userDefault.SetString(data, key); userDefault.Synchronize(); }
public void SetValue(string key, object anyValue) { Type valueType = anyValue.GetType(); if (valueType == typeof(string)) { UserDefaults.SetString((string)anyValue, key); } else if (valueType == typeof(int)) { UserDefaults.SetInt((int)anyValue, key); } else if (valueType == typeof(bool)) { UserDefaults.SetBool((bool)anyValue, key); } else if (valueType == typeof(float)) { UserDefaults.SetFloat((float)anyValue, key); } else if (valueType == typeof(double)) { UserDefaults.SetDouble((double)anyValue, key); } else if (valueType == typeof(long)) { UserDefaults.SetValueForKey(new NSNumber((long)anyValue), new NSString(key)); } else { Log.Error(INCORRECT_VALUE_TYPE_ERROR); } UserDefaults.Synchronize(); }
public void Test() { var tddHandler = new TDDHandler(); const String stringValue = "external string value"; const Int32 int32Value = 12345; const String stringKeyName = "v2.string"; const String intKeyName = "v2.int"; var classPrefs = new NSUserDefaults(); classPrefs.SetString(stringValue, stringKeyName); ExternalUserDefaultsClassSerializer.SetMyUserDefaults(classPrefs); var fieldPrefs = new NSUserDefaults(); fieldPrefs.SetInt(int32Value, intKeyName); ExternalUserDefaultsFieldSerializer.SetMyUserDefaults(fieldPrefs); ExternalUserDefaultsSettings.IntValue = 0; ExternalUserDefaultsSettings.StringValue = String.Empty; ExternalUserDefaultsSettings.LoadSettings(); Assert.AreEqual(ExternalUserDefaultsSettings.IntValue, int32Value); Assert.AreEqual(ExternalUserDefaultsSettings.StringValue, stringValue); tddHandler.CheckErrors(); }
public AppDelegate() { //defaults.SetString("", Config.WorkSpaceKey); try { ws = defaults.StringForKey(Config.WorkSpaceKey); if (ws == null) { ws = ""; } if (ws.Length == 0) { ws = defaultPath; defaults.SetString(defaultPath, Config.WorkSpaceKey); } else { } } catch (Exception e) { Console.WriteLine(e.Message); } RootPath = ws; Setup(); }
public override bool ShouldChangeCharacters(UITextField textField, NSRange range, string replacementString) { string str = outer.TextField.Text; str = str.Substring(0, (int)range.Location) + replacementString + str.Substring((int)range.Location + (int)range.Length); do { NSUserDefaults defaults = NSUserDefaults.StandardUserDefaults; nint tag = outer.Tag; if (tag == 104) { defaults.SetString(str, "DelayValue"); } else { break; } defaults.Synchronize(); } while(false); return(true); }
public bool SetString(string key, string val) { try { // Apple now recommends you *don't* call Synchronize as it will periodically happen // https://docs.microsoft.com/en-us/xamarin/ios/app-fundamentals/user-defaults _defaults.SetString(val, key); return(true); } catch (Exception e) { Logger.Error($"Error Setting String UserSetting {key} - {e.Message}", e); } return(false); }
public static void setBatteryInterval(string batteryInterval) { NSUserDefaults prefs = NSUserDefaults.StandardUserDefaults; prefs.SetString(batteryInterval, "batteryInterval"); prefs.Synchronize(); }
/// <summary> /// Opens the database. /// </summary> /// <param name='filePath'> /// File path. /// </param> /// <param name='password'> /// Password. /// </param> private void OpenDatabase(string filePath, string password) { try { StartProgress("Opening password database..."); databaseCommands.OpenDatabase(filePath, password); // store the path of this db.. NSUserDefaults userDefaults = NSUserDefaults.StandardUserDefaults; userDefaults.SetString(filePath, "lastdbpath"); } catch (Exception ex) { NSAlert alert = new NSAlert(); alert.AlertStyle = NSAlertStyle.Critical; alert.MessageText = ex.Message; // alert.AddButton("Yes"); // alert.AddButton("No"); alert.RunModal(); return; } finally { EndProgress(); } //SetupSidebar(); TreeGroupModel groups = databaseCommands.FindGroups(); FillGroups(groups); }
public void Set <T>(T obj, string key = "") { key += "0"; var str = SerializeToString(obj); _preferences.SetString(str ?? NULL, key); }
public void SetTimerUserDefaults() { NSUserDefaults defaults = NSUserDefaults.StandardUserDefaults; defaults.SetBool(Running, "running"); defaults.SetString(StartDate.Ticks.ToString(), "ticks"); defaults.Synchronize(); }
private bool EditPreferences(NSUserDefaults defaults, UserModel user) { try { defaults.SetString(user.Email, "user_mail"); defaults.SetBool(user.IsLogged, "is_logged"); defaults.SetString(user.PhotoUrl, "user_photo_url"); defaults.SetInt(user.UserId, "user_user_id"); defaults.SetString(user.Username, "user_username"); return(true); } catch (Exception e) { Debug.WriteLine("AUTHENTICATOR MANAGER", "Catched exception."); throw e; } }
static Analytics() { #if __PC__ if (Settings.Default.GUID == "00000000-0000-0000-0000-000000000000") { Settings.Default.GUID = Guid.NewGuid().ToString(); Settings.Default.Save(); } GUID = Settings.Default.GUID; OperatingSystem os = Environment.OSVersion; trackerEnvironment = new SimpleTrackerEnvironment(os.Platform.ToString(), os.Version.ToString(), os.VersionString); analyticsSession = new AnalyticsSession(); tracker = new SimpleTracker("UA-125850339-2", analyticsSession, trackerEnvironment); AppVersion = MainForm.VERSION; OSVersion = SetWindowsVersion(os.Version.ToString()); bool windowsStoreApp = Application.ExecutablePath.Contains("WindowsApps"); bool debugging = Application.ExecutablePath.Contains("GitRepo"); DeploymentType = windowsStoreApp ? "Windows Store" : debugging ? "Development" : "Zip File"; string resolution = Screen.PrimaryScreen.Bounds.ToString(); #elif __MACOS__ var userDefaults = new NSUserDefaults(); GUID = userDefaults.StringForKey("AnalyticsKey"); if (string.IsNullOrEmpty(GUID)) { GUID = Guid.NewGuid().ToString(); userDefaults.SetString(GUID, "AnalyticsKey"); userDefaults.Synchronize(); } NSProcessInfo info = new NSProcessInfo(); OSVersion = $"MacOSX {info.OperatingSystemVersionString}"; trackerEnvironment = new SimpleTrackerEnvironment("Mac OSX", info.OperatingSystemVersion.ToString(), OSVersion); analyticsSession = new AnalyticsSession(); tracker = new SimpleTracker("UA-125850339-2", analyticsSession, trackerEnvironment); var app = (AppDelegate)NSApplication.SharedApplication.Delegate; AppVersion = FamilyTree.Instance.Version; DeploymentType = "Mac Website"; string resolution = NSScreen.MainScreen.Frame.ToString(); #elif __IOS__ var userDefaults = new NSUserDefaults(); GUID = userDefaults.StringForKey("AnalyticsKey"); if (string.IsNullOrEmpty(GUID)) { GUID = Guid.NewGuid().ToString(); userDefaults.SetString(GUID, "AnalyticsKey"); userDefaults.Synchronize(); } NSProcessInfo info = new NSProcessInfo(); OSVersion = $"MacOSX {info.OperatingSystemVersionString}"; trackerEnvironment = new SimpleTrackerEnvironment("Mac OSX", info.OperatingSystemVersion.ToString(), OSVersion); analyticsSession = new AnalyticsSession(); tracker = new SimpleTracker("UA-125850339-2", analyticsSession, trackerEnvironment); var app = (AppDelegate)UIApplication.SharedApplication.Delegate; AppVersion = FamilyTree.Instance.Version; DeploymentType = "Mac Website"; string resolution = UIScreen.MainScreen.Bounds.ToString(); #endif Resolution = resolution.Length > 11 ? resolution.Substring(9, resolution.Length - 10) : resolution; }
/// <summary> /// This methods handles the click on the local button. It checks if default information is valid, /// if it is valid it loads the Devices main screen, otherwise it goes to the Server connect screen. /// </summary> void ToLocalScreen() { // Check if local serverinformation is present and correct bool validIp = AppDelegate.IsServerValid(defaultIP); userDefaults.SetString(bool.TrueString, strings.defaultsLocalHestia); Globals.LocalLogin = true; if (validIp) // Go to Devices main { SetValuesAndSegueToDevicesMainLocal(); } else // Go to Server select { UIStoryboard devicesMainStoryboard = UIStoryboard.FromName(strings.devices2StoryBoard, null); PresentViewController(devicesMainStoryboard.InstantiateInitialViewController(), true, null); } }
public void SetToDefaults(string key, string value) { if (!String.IsNullOrEmpty(value)) { NSUserDefaults defaults = NSUserDefaults.StandardUserDefaults; defaults.SetString(value, key); defaults.Synchronize(); } }
public override void ViewWillDisappear(bool animated) { base.ViewWillDisappear(animated); btnReturn.TouchUpInside -= btnReturnTouchUpInside; var ser = JsonSerializer.SerializeToString(tvSource.checkedStates); userDefs.SetString(ser, "states"); userDefs.Synchronize(); }
partial void loginAction(NSObject sender) { if (this.usernameTextField.Text.Length > 0 && this.passwordTextField.Text.Length > 0) { NSUserDefaults user = NSUserDefaults.StandardUserDefaults; string username = Constants.PREFIX + this.usernameTextField.Text; user.SetString(this.usernameTextField.Text, "username"); string password = this.passwordTextField.Text; ShowKit.ShowKit.Login(username, password); } }
private bool SelectLocation(string location) { instance = new Instance(location); LocationTextField.StringValue = instance.rootPath; var version = instance.EngineVersion(); EngineLabel.StringValue = version ?? "No Wineskin Detected"; defaults.SetString(location, "location"); SetControlsEnabled(version != null); return(version != null); }
partial void UIButton12_TouchUpInside(UIButton sender) { //Store value on Userdefaults storevalues.SetString(txtString.Text, "stringvalue"); storevalues.SetInt(Int32.Parse(txtInteger.Text), "integervalue"); //Get values form Userdefaults lblString.Text = storevalues.StringForKey("stringvalue"); lblInteger.Text = storevalues.IntForKey("integervalue").ToString(); lblBoolean.Text = storevalues.BoolForKey("swithvalue").ToString();; }
/// <inheritdoc /> public void SetString(string key, string value) { if (value == null) { _standardDefaults.RemoveObject(key); } else { _standardDefaults.SetString(value, key); } _standardDefaults.Synchronize(); }
protected override void AddOrUpdateNative(IEnumerable <KeyValuePair <string, string> > saves) { foreach (var item in saves) { if (this.CanTouch(item.Key)) { prefs.SetString(item.Key, item.Value); } } prefs.Synchronize(); }
public void Set(string key, string value) { if (value == null) { Clear(key); } else { Defaults.SetString(value, key); Defaults.Synchronize(); } }
public void SetString() { // confusing API for .NET developers since the parameters are 'value', 'key' // http://stackoverflow.com/q/12415054/220643 NSUserDefaults defaults = NSUserDefaults.StandardUserDefaults; defaults.RemoveObject("spid"); Assert.Null(defaults.StringForKey("spid"), "StringForKey-1"); defaults.SetString("coucou", "spid"); defaults.Synchronize(); Assert.That(defaults.StringForKey("spid"), Is.EqualTo("coucou"), "StringForKey-2"); }
public static void SetSerializedObject <T> (this NSUserDefaults instance, T data, string defaultName) where T : class { if (data != null) { instance.SetString(data.Serialize(), defaultName); } else { instance.RemoveObject(defaultName); } instance.Synchronize(); }
public static void SetStringOrClear(this NSUserDefaults instance, string data, string defaultName) { if (data.HasValue()) { instance.SetString(data, defaultName); } else { instance.RemoveObject(defaultName); } instance.Synchronize(); }
public override void ViewDidLoad() { base.ViewDidLoad (); _appController.ShowSelected += toggleShowSelected; userDefs = NSUserDefaults.StandardUserDefaults; UIApplication.Notifications.ObserveDidEnterBackground ((sender, args) => { var ser = JsonSerializer.SerializeToString (_appController.Eigenschappen); if (IsProfileNull) { userDefs.SetString (ser, "eigenschappen"); userDefs.Synchronize (); } else { _appController.AddOrUpdateEigenschappenSer (currProfiel.name, ser); } }); }