private static void Import(IPropertySet values, JsonObject jsonObject) { values.Clear(); foreach (string key in jsonObject.Keys) { IJsonValue jsonValue = jsonObject[key]; switch (jsonValue.ValueType) { case JsonValueType.String: values.Add(key, jsonObject[key].GetString()); break; case JsonValueType.Number: values.Add(key, jsonObject[key].GetNumber()); break; case JsonValueType.Boolean: values.Add(key, jsonObject[key].GetBoolean()); break; case JsonValueType.Null: values.Add(key, null); break; default: throw new Exception("Not supported JsonValueType."); } } }
public MixedRealityCaptureSetting(bool HologramCompositionEnabled, bool VideoStabilizationEnabled, int VideoStabilizationBufferLength, float GlobalOpacityCoefficient) { Properties = (IPropertySet) new PropertySet(); Properties.Add("HologramCompositionEnabled", HologramCompositionEnabled); // Hologramをキャプチャするかどうか Properties.Add("VideoStabilizationEnabled", VideoStabilizationEnabled); // 手ブレ補正を行うかどうか Properties.Add("VideoStabilizationBufferLength", VideoStabilizationBufferLength); // 手ブレ補正に使用するバッファ Properties.Add("GlobalOpacityCoefficient", GlobalOpacityCoefficient); // キャプチャしたHologramの透過度 }
public VideoMRCSettings(bool HologramCompositionEnabled, bool VideoStabilizationEnabled, int VideoStabilizationBufferLength, float GlobalOpacityCoefficient) { Properties = (IPropertySet) new PropertySet(); Properties.Add("HologramCompositionEnabled", HologramCompositionEnabled); Properties.Add("VideoStabilizationEnabled", VideoStabilizationEnabled); Properties.Add("VideoStabilizationBufferLength", VideoStabilizationBufferLength); Properties.Add("GlobalOpacityCoefficient", GlobalOpacityCoefficient); }
/// <summary> /// The add default settings. /// </summary> /// <param name="settings"> /// The settings. /// </param> private static void AddDefaultSettings(IPropertySet settings) { settings.Add("MidThreshold", 8000); settings.Add("LowThreshold", 9000); settings.Add("MidRate", 1024); settings.Add("LowRate", 256); settings.Add("PctDiscount", 75); }
protected override string GetUniqueVisitorId() { if (!_settings.ContainsKey(StorageKeyUniqueId)) { _settings.Add(StorageKeyUniqueId, base.GetUniqueVisitorId()); } return((string)_settings[StorageKeyUniqueId]); }
public static void AddRange <T>(this IPropertySet set, IEnumerable <KeyValuePair <string, T> > otherCollection) { foreach (var keyValuePair in otherCollection) { set.Add(keyValuePair.Key, keyValuePair.Value); } }
/// <summary> /// Add an element to banlist. /// </summary> /// <param name="content">To content to be banned.</param> public void Add(string content) { if (!_values.ContainsKey(content)) { _values.Add(content, content); } }
public void SaveState() { IPropertySet state = ApplicationData.Current.LocalSettings.Values; if (state.ContainsKey(AngleKey)) { state.Remove(AngleKey); } if (state.ContainsKey(TrackingKey)) { state.Remove(TrackingKey); } state.Add(AngleKey, PropertyValue.CreateSingle(_rotationY)); state.Add(TrackingKey, PropertyValue.CreateBoolean(_tracking)); }
/// <inheritdoc/> public void SetValue <T>(string key, T value, bool overwrite = true) { // Convert the value object serializable; if (typeof(T).IsEnum) { Type type = Enum.GetUnderlyingType(typeof(T)); serializable = Convert.ChangeType(value, type); } else if (typeof(T).IsPrimitive || typeof(T) == typeof(string)) { serializable = value; } else if (typeof(T) == typeof(DateTime)) { serializable = Unsafe.As <T, DateTime>(ref value).ToBinary(); } else { ThrowHelper.ThrowArgumentException("Invalid setting type."); return; } // Store the new value if (!SettingsStorage.ContainsKey(key)) { SettingsStorage.Add(key, serializable); } else if (overwrite) { SettingsStorage[key] = serializable; } }
private static void Save <T>(string key, T value, IPropertySet values) { if (values.ContainsKey(key)) { values.Remove(key); } values.Add(key, value); }
/// <summary> /// When the application is about to enter a suspended state, save the user edited properties text. /// This method does not use the SuspensionManager helper class (defined in SuspensionManager.cs). /// </summary> private void SaveDataToPersistedState(object sender, SuspendingEventArgs args) { // Only save state if we have valid data. if (m_fileToken != null) { // Requesting a deferral prevents the application from being immediately suspended. SuspendingDeferral deferral = args.SuspendingOperation.GetDeferral(); // LocalSettings does not support overwriting existing items, so first clear the collection. ResetPersistedState(); m_localSettings.Add("scenario2FileToken", m_fileToken); m_localSettings.Add("scenario2Width", m_displayWidthNonScaled); m_localSettings.Add("scenario2Height", m_displayHeightNonScaled); m_localSettings.Add("scenario2Scale", m_scaleFactor); m_localSettings.Add("scenario2UserRotation", Helpers.ConvertToExifOrientationFlag(m_userRotation) ); m_localSettings.Add("scenario2ExifOrientation", Helpers.ConvertToExifOrientationFlag(m_exifOrientation) ); m_localSettings.Add("scenario2DisableExif", m_disableExifOrientation); deferral.Complete(); } }
protected void Set(String propertyName, Object value) { if (!Properties.ContainsKey(propertyName)) { Properties.Add(propertyName, value); } else { Properties[propertyName] = value; } }
public void createPropertySet(IPropertySet property) { string keyValue = getPropertyLine(); property.Add(m_PinName, PropertyValue.CreateString(keyValue)); // string keyValue = string.Format("PinName={0}; Typ={1}; PinNumber={2}; InitValue={3}; SetValue={4}", m_GPIOName, m_GPIOTyp.ToString(), m_PinNumber, m_InitValue,m_SetValue-SetValue); ; // property.Add(m_GPIOName, PropertyValue.CreateString(keyValue)); }
public static void AddOrUpdate(this IPropertySet propertySet, string key, object value) { if (propertySet.ContainsKey(key)) { propertySet[key] = value; } else { propertySet.Add(key, value); } }
public void PutSetting <T>(string property, T value) { if (_values.ContainsKey(property)) { _values[property] = value; } else { _values.Add(property, value); } }
public void SetValue <T>(string key, T value) { if (!SettingsStorage.ContainsKey(key)) { SettingsStorage.Add(key, value); } else { SettingsStorage[key] = value; } }
private static void SetContent(IPropertySet set, string key, string value) { if (set.ContainsKey(key)) { set[key] = value; } else { set.Add(key, value); } }
private static async Task RealSetDebugSocketAddr(string host, string port) { if (Settings.ContainsKey(DEBUG_HOST_CONFIG)) { Settings[DEBUG_HOST_CONFIG] = host; } else { Settings.Add(DEBUG_HOST_CONFIG, host); } if (Settings.ContainsKey(DEBUG_PORT_CONFIG)) { Settings[DEBUG_PORT_CONFIG] = port; } else { Settings.Add(DEBUG_PORT_CONFIG, port); } await ResetLoggers(); await InitDebugSocket(); }
public static void SetLocal <T>(SettingKeys key, T value) { string serializedValue = JsonConvert.SerializeObject(value); if (!LocalSettings.ContainsKey(key.ToString())) { LocalSettings.Add(key.ToString(), serializedValue); } else { LocalSettings[key.ToString()] = serializedValue; } }
public ApplicationSettings() { if (ApplicationData.Current.RoamingSettings.Containers.ContainsKey("AppSettings")) { _appSettings = ApplicationData.Current.RoamingSettings.Containers["AppSettings"].Values; } else { _appSettings = ApplicationData.Current.RoamingSettings.CreateContainer("AppSettings", ApplicationDataCreateDisposition.Always).Values; } if (!_appSettings.ContainsKey(EnableCommentsKey)) { _appSettings.Add(EnableCommentsKey, true); } //if (!_appSettings.ContainsKey(UserNameKey)) // _appSettings.Add(UserNameKey, ""); ////if (!_appSettings.ContainsKey(PasswordKey)) //// _appSettings.Add(PasswordKey, ""); if (!_appSettings.ContainsKey(CredentialKey)) { _appSettings.Add(CredentialKey, JsonConvert.SerializeObject(new Session { Expries = DateTime.Now.AddYears(-100), Key = "" })); } if (!_appSettings.ContainsKey(BackgroundKey)) { _appSettings.Add(BackgroundKey, JsonConvert.SerializeObject(Colors.White)); } if (!_appSettings.ContainsKey(ForegroundKey)) { _appSettings.Add(ForegroundKey, JsonConvert.SerializeObject(Colors.Black)); } if (!_appSettings.ContainsKey(FontSizeKey)) { _appSettings.Add(FontSizeKey, 19.0); } if (!_appSettings.ContainsKey(SavedAppVersionKey)) { _appSettings.Add(SavedAppVersionKey, "00.00.00.00"); } try { var creds = _Vault.FindAllByResource("lightnovel.cn"); if (creds.Count < 1) { _Cred = null; } else { _Cred = creds[0]; _Cred = _Vault.Retrieve("lightnovel.cn", _Cred.UserName); } } catch (Exception ex) // Not found { Debug.WriteLine(ex.Message); _Cred = null; } }
/// <summary> /// Saves a setting with the given key /// </summary> /// <typeparam name="T">The type of the settisg to save</typeparam> /// <param name="key">The key of the setting to save</param> /// <param name="value">The value of the new setting</param> /// <param name="overwrite">Indicates wheter or not to overwrite an already existing setting</param> public static void Save <T>([NotNull] String key, T value, bool overwrite = true) { if (Settings.ContainsKey(key)) { if (overwrite) { Settings[key] = value; } } else { Settings.Add(key, value); } }
/// <summary> /// Execute single provision task asynchronously. /// </summary> /// <param name="task">Type of the provision task to be performed.</param> /// <returns>Task that represents the asynchronous provision operation.</returns> private async Task RunSingleProvisionTaskAsync(IProvisionTask task) { if (task == null) { throw new ArgumentException(nameof(task)); } await task.ProvisionAsync(); // Update record if (m_provisionHistory.ContainsKey(task.TaskName)) { m_provisionHistory[task.TaskName] = task.RequiredVersion.ToString(); } else { m_provisionHistory.Add(task.TaskName, task.RequiredVersion.ToString()); } }
unsafe public void ProcessFrame(ProcessAudioFrameContext context) { AudioFrame inputFrame = context.InputFrame; using (AudioBuffer inputBuffer = inputFrame.LockBuffer(AudioBufferAccessMode.Read)) using (IMemoryBufferReference inputReference = inputBuffer.CreateReference()) { byte* inputDataInBytes; uint inputCapacity; ((IMemoryBufferByteAccess)inputReference).GetBuffer(out inputDataInBytes, out inputCapacity); float* inputDataInFloat = (float*)inputDataInBytes; // Process audio data int dataInFloatLength = (int)inputBuffer.Length / sizeof(float); for (int i = 0; i < dataInFloatLength; i++) { float inputData = inputDataInFloat[i]; lock (badLock) { if (propertySet.ContainsKey("InputDataRaw")) { propertySet["InputDataRaw"] = inputData; } else { propertySet.Add("InputDataRaw", inputData); } } if (compositionPropertySet != null) { compositionPropertySet.InsertScalar("InputData", inputData * 500); } } } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { Thread.CurrentThread.Name = "Main UI Thread"; Settings = ApplicationData.Current.LocalSettings.Values; if (!Settings.ContainsKey("Server")) { Settings.Add("Server", "localhost"); } if (!Settings.ContainsKey("UserID")) { Settings.Add("UserID", "titom7373"); } if (!Settings.ContainsKey("Password")) { Settings.Add("Password", "PeanutsWalnuts"); } if (!Settings.ContainsKey("Schema")) { Settings.Add("Schema", "IT Tables"); } if (!Settings.ContainsKey("Database")) { Settings.Add("Database", "Inventory"); } //ConfigurationEcnrypterDecrypter.UnEncryptConfig(); ConnectionString = $"Server={Settings["Server"]};Database={Settings["Database"]};User ID={Settings["UserID"]};Password={Settings["Password"]};"; try { using (var conn = new SqlConnection(ConnectionString)) { conn.Open(); conn.Close(); } } catch { //TODO /*DatabaseManagerError dme = new DatabaseManagerError * { * ShowInTaskbar = true * }; * dme.ShowDialog();*/ return; } using (var conn = new SqlConnection(ConnectionString)) { conn.Open(); if (!GetAllNames(conn, "schemas").Contains($"{Settings["Schema"]}")) { using (var comm = new SqlCommand($"CREATE SCHEMA [{Settings["Schema"]}]", conn)) { comm.ExecuteNonQuery(); } } if (!GetAllNames(conn, "schemas").Contains($"{Settings["Schema"]}_BACKUPS")) { using (var comm = new SqlCommand($"CREATE SCHEMA [{Settings["Schema"]}_BACKUPS]", conn)) { comm.ExecuteNonQuery(); } } if (!GetAllNames(conn, "schemas").Contains($"{Settings["Schema"]}_PREFABS")) { using (var comm = new SqlCommand($"CREATE SCHEMA [{Settings["Schema"]}_PREFABS]", conn)) { comm.ExecuteNonQuery(); } } if (!GetAllNames(conn, "schemas").Contains($"{Settings["Schema"]}_COMBOBOXES")) { using (var comm = new SqlCommand($"CREATE SCHEMA [{Settings["Schema"]}_COMBOBOXES]", conn)) { comm.ExecuteNonQuery(); } } if (!GetAllNames(conn, "schemas").Contains("RECYCLED")) { using (var comm = new SqlCommand("CREATE SCHEMA RECYCLED", conn)) { comm.ExecuteNonQuery(); } } conn.Close(); } //SqlDependency.Start(ConnectionString); //Debug.WriteLine("Starting server..."); /*Task.Run(() => * { * StartServer(); * ConnectAsync(); * });*/ //Debug.WriteLine("Connecting to server..."); // Do not repeat app initialization when the Window already has content, // just ensure that the page is active if (!(Window.Current.Content is Frame rootFrame)) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current page is active Window.Current.Activate(); } ExtendAcrylicIntoTitleBar(); }
public ApplicationSettings() { if (ApplicationData.Current.RoamingSettings.Containers.ContainsKey("AppSettings")) { _roamingSettings = ApplicationData.Current.RoamingSettings.Containers["AppSettings"].Values; } else { _roamingSettings = ApplicationData.Current.RoamingSettings.CreateContainer("AppSettings", ApplicationDataCreateDisposition.Always).Values; } if (ApplicationData.Current.LocalSettings.Containers.ContainsKey("AppSettings")) { _localSettings = ApplicationData.Current.LocalSettings.Containers["AppSettings"].Values; } else { _localSettings = ApplicationData.Current.LocalSettings.CreateContainer("AppSettings", ApplicationDataCreateDisposition.Always).Values; } if (!_roamingSettings.ContainsKey(EnableCommentsKey)) { _roamingSettings.Add(EnableCommentsKey, true); } if (!_roamingSettings.ContainsKey(EnableLiveTileKey)) { _roamingSettings.Add(EnableLiveTileKey, true); } if (!_roamingSettings.ContainsKey(EnableAutomaticReadingThemeKey)) { _roamingSettings.Add(EnableAutomaticReadingThemeKey, true); } if (!_roamingSettings.ContainsKey(BackgroundThemeKey)) { _roamingSettings.Add(BackgroundThemeKey, (int)Windows.UI.Xaml.ElementTheme.Default); } if (!_roamingSettings.ContainsKey(UseSystemAccentKey)) { _roamingSettings.Add(UseSystemAccentKey, true); } if (!_localSettings.ContainsKey(ImageLoadingPolicyKey)) { _localSettings.Add(ImageLoadingPolicyKey, (int)ImageLoadingPolicy.Automatic); } if (!_localSettings.ContainsKey(CredentialKey)) { _localSettings.Add(CredentialKey, JsonConvert.SerializeObject(new Session { Expries = DateTime.Now.AddYears(-100), Key = "" })); } if (!_roamingSettings.ContainsKey(FontSizeKey)) { _roamingSettings.Add(FontSizeKey, 19.0); } if (!_roamingSettings.ContainsKey(FontWeightKey)) { _roamingSettings.Add(FontWeightKey, Windows.UI.Text.FontWeights.SemiLight.Weight); } if (!_roamingSettings.ContainsKey(InterfaceLanguageKey)) { _roamingSettings.Add(InterfaceLanguageKey, ""); } if (!_localSettings.ContainsKey(FontFamilyKey)) #if WINDOWS_PHONE_APP { _localSettings.Add(FontFamilyKey, "Segoe WP"); } #else { _localSettings.Add(FontFamilyKey, "Segoe UI"); } #endif if (!_localSettings.ContainsKey(SavedAppVersionKey)) { _localSettings.Add(SavedAppVersionKey, "00.00.00.00"); } if (!_localSettings.ContainsKey(DeviceUserAgentKey)) { _localSettings.Add(DeviceUserAgentKey, ""); } try { var creds = _Vault.FindAllByResource("lightnovel.cn"); if (creds.Count < 1) { _Cred = null; } else { _Cred = creds[0]; _Cred = _Vault.Retrieve("lightnovel.cn", _Cred.UserName); } } catch (Exception ex) // Not found { Debug.WriteLine(ex.Message); _Cred = null; } }
public void Add(KeyValuePair <string, object> item) { _values.Add(item); }
/// <summary> /// Enqueue an on-demand provision task on next launch. /// </summary> /// <typeparam name="T">Type of the on-demand provision task.</typeparam> public void SetTaskOnNextLaunch <T>() where T : IProvisionTask { m_podQueue.Add(Guid.NewGuid().ToString(), typeof(T).AssemblyQualifiedName); }
/// <summary> /// When the application is about to enter a suspended state, save the user edited properties text. /// </summary> private void SaveDataToPersistedState(object sender, SuspendingEventArgs args) { // Only save state if we have valid data. if (m_fileToken != null) { // Requesting a deferral prevents the application from being immediately suspended. SuspendingDeferral deferral = args.SuspendingOperation.GetDeferral(); // LocalSettings does not support overwriting existing items, so first clear the collection. ResetPersistedState(); m_localSettings.Add("scenario1Title", TitleTextbox.Text); m_localSettings.Add("scenario1Keywords", KeywordsTextbox.Text); m_localSettings.Add("scenario1DateTaken", DateTakenTextblock.Text); m_localSettings.Add("scenario1Make", MakeTextblock.Text); m_localSettings.Add("scenario1Model", ModelTextblock.Text); m_localSettings.Add("scenario1Orientation", OrientationTextblock.Text); m_localSettings.Add("scenario1LatDeg", LatDegTextbox.Text); m_localSettings.Add("scenario1LatMin", LatMinTextbox.Text); m_localSettings.Add("scenario1LatSec", LatSecTextbox.Text); m_localSettings.Add("scenario1LatRef", LatRefTextbox.Text); m_localSettings.Add("scenario1LongDeg", LongDegTextbox.Text); m_localSettings.Add("scenario1LongMin", LongMinTextbox.Text); m_localSettings.Add("scenario1LongSec", LongSecTextbox.Text); m_localSettings.Add("scenario1LongRef", LongRefTextbox.Text); m_localSettings.Add("scenario1Exposure", ExposureTextblock.Text); m_localSettings.Add("scenario1FNumber", FNumberTextblock.Text); m_localSettings.Add("scenario1FileToken", m_fileToken); deferral.Complete(); } }