async void DoCreateAccountCommand() { User user = new User { email = Email, username = Username, password = EncryptionService.encrypt(Password), name = Name, lastname = Lastname, image_url = UserImageUrl, created_at = DateTime.Now, updated_at = DateTime.Now }; try { OperationResult result = await _mLearningService.CreateAccount <User>(user, (usr) => usr.id, _selectedUserType); SessionService.LogIn(result.id, Username); SharedPreferences prefs = Constants.GetSharedPreferences(Constants.PreferencesFileName); prefs.PutString(Constants.UserFirstNameKey, Name); prefs.PutString(Constants.UserLastNameKey, Lastname); prefs.PutString(Constants.UserImageUrlKey, UserImageUrl); prefs.Commit(); ClearProperties(); ShowViewModel <MainViewModel>(); RegistrationOK = true; } catch (WebException e) { ConnectionOK = false; } catch (MobileServiceInvalidOperationException ex) { OperationOK = false; } }
private void initData() { mSettings = getSharedPreferences(ExampleUtil.PREFS_NAME, MODE_PRIVATE); string days = mSettings.getString(ExampleUtil.PREFS_DAYS, ""); if (!TextUtils.isEmpty(days)) { initAllWeek(false); string[] sArray = days.Split(",", true); foreach (string day in sArray) { Week = day; } } else { initAllWeek(true); } int startTimeStr = mSettings.getInt(ExampleUtil.PREFS_START_TIME, 0); startTime.CurrentHour = startTimeStr; int endTimeStr = mSettings.getInt(ExampleUtil.PREFS_END_TIME, 23); endTime.CurrentHour = endTimeStr; }
private static void WriteToFile(string fileName, Editor editor) { //================================================================= var sp = new SharedPreferences(fileName); sp.Save(editor); }
public virtual string GetCurrentListId() { SharedPreferences sp = PreferenceManager.GetDefaultSharedPreferences(GetApplicationContext ()); return(sp.GetString(PrefCurrentListId, null)); }
private void SvChanger_Load(object sender, EventArgs e) { string savedModel = SharedPreferences.get <string>(SvChangerModel.KEY, null); SvChangerModel model = savedModel != null?JsonConvert.DeserializeObject <SvChangerModel>(savedModel) : null; if (model != null) { firstTimeTextBox.Text = model.FirstOffsetText; firstSvTextBox.Text = model.FirstSvText; lastSvTextBox.Text = model.LastSvText; increaseModeComboBox.SelectedIndex = model.SvIncreaseMode; increaseMultiplierTextBox.Text = model.SvIncreaseMultiplierText; targetBpmTextBox.Text = model.TargetBpmText; gridSnapTextBox.Text = model.GridSnapText; svOffsetTextBox.Text = model.SvOffsetText; activateTimeModeCheckBox.Checked = model.ActivateBetweenTimeMode; putPointsByNotesCheckBox.Checked = model.PutPointsByNotes; if (model.ActivateBetweenTimeMode) { lastTimeTextBox.Text = model.LastOffsetText; } else { lastTimeTextBox.Text = model.CountText; } } }
private void ReadPortSetup(SharedPreferences sp) { //读取选中的端口 if (_hasPorts) { //判断当前端口的数量,小于则表示是OK。 if (sp.GetInt32("selectedPort", 0) < comboBox_port.Items.Count) { comboBox_port.SelectedIndex = sp.GetInt32("selectedPort", 0); } else { comboBox_port.SelectedIndex = 0; } } //读取设置的波特率 comboBox_baudrate.SelectedIndex = sp.GetInt32("baudRate", 0); //读取设置的校验方式 comboBox_parity.SelectedIndex = sp.GetInt32("parity", 0); //读取设置的数据位 comboBox_databit.SelectedIndex = sp.GetInt32("dataBits", 0); //读取设置的停止位 comboBox_stopbit.SelectedIndex = sp.GetInt32("stopBits", 0); //读取自动发送数据时间间隔 textBox_sendPeriod.Text = sp.GetInt32("intervalTime", 500).ToString(); //读取接收方式 checkBox_receiveHex.Checked = sp.GetBoolean("acceptChar", true); //读取标志变量,即是否在接收框中显示信息。 showInfo = sp.GetBoolean("showInfo", true); button_receivepause.Text = showInfo ? "暂停接收显示" : "继续接收显示"; }
private O2AcademyPrefs() { segment = new Segment(); preferences = new SharedPreferences(); editor = preferences.edit(); loadPreferences(); }
public static bool isSynced(string boardId) { SharedPreferences preferences = mContext.getSharedPreferences(PREFS_NAME, 0); ISet <string> syncedBoards = preferences.getStringSet(PREF_NAME, new HashSet <string>()); return(syncedBoards.Contains(boardId)); }
/// <summary> /// Gets the current value or the default that you specify. /// </summary> /// <typeparam name="T">Vaue of t (bool, int, float, long, string)</typeparam> /// <param name="key">Key for settings</param> /// <param name="defaultValue">default value if not set</param> /// <returns>Value or default</returns> public T GetValueOrDefault <T>(string key, T defaultValue = default(T)) { lock (locker) { Type typeOf = typeof(T); if (typeOf.IsGenericType && typeOf.GetGenericTypeDefinition() == typeof(Nullable <>)) { typeOf = Nullable.GetUnderlyingType(typeOf); } object value = null; var typeCode = Type.GetTypeCode(typeOf); switch (typeCode) { case TypeCode.Boolean: value = SharedPreferences.GetBoolean(key, Convert.ToBoolean(defaultValue)); break; case TypeCode.Int64: value = SharedPreferences.GetLong(key, Convert.ToInt64(defaultValue)); break; case TypeCode.String: value = SharedPreferences.GetString(key, Convert.ToString(defaultValue)); break; case TypeCode.Int32: value = SharedPreferences.GetInt(key, Convert.ToInt32(defaultValue)); break; case TypeCode.UInt16: value = SharedPreferences.GetInt(key, Convert.ToUInt16(defaultValue)); break; case TypeCode.Single: value = SharedPreferences.GetFloat(key, Convert.ToSingle(defaultValue)); break; case TypeCode.Double: value = SharedPreferences.GetFloat(key, Convert.ToSingle(defaultValue)); break; case TypeCode.DateTime: var ticks = SharedPreferences.GetLong(key, -1); if (ticks == -1) { value = defaultValue; } else { value = new DateTime(ticks); } break; } return((null != value) ? (T)value : defaultValue); } }
public override void onSharedPreferenceChanged(SharedPreferences sharedPreferences, string key) { /* Cancel all commands and unbind if agent disabled */ if (ENABLED.Equals(key) && !outerInstance.Enabled) { outerInstance.mPendingCmds.Clear(); outerInstance.scheduleUnbind(); } }
public MvxAndroidSettings() { SharedPreferences = PreferenceManager.GetDefaultSharedPreferences(Application.Context); SharedPreferencesEditor = SharedPreferences.Edit(); SecuredPreferences = Application.Context.GetSharedPreferences(Application.Context.PackageName + ".SecureStorage", FileCreationMode.Private); SecuredPreferencesEditor = SecuredPreferences.Edit(); }
public override void onDestroyView() { base.onDestroyView(); SharedPreferences settings = Activity.getSharedPreferences(MainActivity.PREFS_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.putString(MainActivity.KEY_LOGICAL_NAME_MSR, logicalNameEditText.Text.ToString()); editor.commit(); }
public RsxSettings() { InitializeComponent(); settingsVM = new RsxSettingsViewModel(); preferences = SharedPreferences.Instance; InitializeSettings(); DataContext = settingsVM; }
public GoogleSetting() { InitializeComponent(); googleSettingViewModel = new GoogleSettingViewModel(); preferences = SharedPreferences.Instance; InitializeSettings(); DataContext = googleSettingViewModel; }
public static void restoreSyncedBoards(Firebase boardsRef) { SharedPreferences preferences = mContext.getSharedPreferences(PREFS_NAME, 0); ISet <string> syncedBoards = preferences.getStringSet(PREF_NAME, new HashSet <string>()); foreach (string key in syncedBoards) { Log.i(TAG, "Keeping board " + key + " synced"); boardsRef.child(key).keepSynced(true); } }
private void ReadPIDSetup(SharedPreferences sp) { //保存的车型 radioButton_FourWheel.Checked = sp.GetBoolean("radioButton_carType", true); if (!radioButton_FourWheel.Checked) radioButton_BalanceCar.Checked = true; if (radioButton_FourWheel.Checked) //四轮车PID ReadPIDFourWheel(sp); else if (radioButton_BalanceCar.Checked) //直立车PID参数的获取 ReadPIDBalanceCar(sp); }
private void ReadPIDFourWheel(SharedPreferences sp) { //舵机PID参数 textBox_Steer_P.Text = sp.GetString("Steer_P", "1.0"); textBox_Steer_I.Text = sp.GetString("Steer_I", "1.0"); textBox_Steer_D.Text = sp.GetString("Steer_D", "1.0"); //电机PID参数 textBox_Motor_P.Text = sp.GetString("Motor_P", "1.0"); textBox_Motor_I.Text = sp.GetString("Motor_I", "1.0"); textBox_Motor_D.Text = sp.GetString("Motor_D", "1.0"); }
// =========================================================== // Methods // =========================================================== public bool IsFirstTime(/* final */ String pKey) { /* final */ SharedPreferences prefs = this.GetPreferences(FileCreationMode.Private); if (prefs.GetBoolean(pKey, true)) { prefs.Edit().PutBoolean(pKey, false).Commit(); return(true); } return(false); }
// Overridden from ListPreference protected override string GetPersistedString(string defaultReturnValue) { if (SharedPreferences.Contains(Key)) { var value = GetPersistedInt(0); return(value + ""); } else { return(defaultReturnValue); } }
private void setupUsername() { SharedPreferences prefs = Application.getSharedPreferences("ChatPrefs", 0); mUsername = prefs.getString("username", null); if (mUsername == null) { Random r = new Random(); // Assign a random user name if we don't have one saved. mUsername = "******" + r.Next(100000); prefs.edit().putString("username", mUsername).commit(); } }
public virtual void SetCurrentUserId(string id) { SharedPreferences sp = PreferenceManager.GetDefaultSharedPreferences(GetApplicationContext ()); if (id != null) { sp.Edit().PutString(PrefCurrentUserId, id).Apply(); } else { sp.Edit().Remove(PrefCurrentUserId).Apply(); } }
public bool IsAppUpdated() { int ver = GetVersionCode(); if (ver > SharedPreferences.GetInt("version", 0)) { SharedPreferences.Edit().PutInt("version", ver).Commit(); return(true); } else { return(false); } }
/// <summary> /// 加载保存的歌曲列表。 /// </summary> private void LoadSongListPath() { SharedPreferences mySharedPreferences = new SharedPreferences(@"配置文件夹\songlist.xml", true); int count = mySharedPreferences.GetInt32("songCount", 0); if (count > 0) { List <string> fileNames = new List <string>(); for (int i = 0; i < count; i++) { string item = "song_index" + i.ToString(); fileNames.Add(mySharedPreferences.GetString(item, "")); } AddSong(false, fileNames.ToArray()); } }
private void EqualizeSvForm_Load(object sender, EventArgs e) { string savedModel = SharedPreferences.get <string>(EqualizeSvData.KEY, null); EqualizeSvData model = savedModel != null?JsonConvert.DeserializeObject <EqualizeSvData>(savedModel) : null; if (model != null) { startTimeTextBox.Text = model.StartTime; endTimeTextBox.Text = model.EndTime; targetBpmTextBox.Text = model.TargetBPM; svMultiplierTextBox.Text = model.SvMultiplier; equalizeAllCheckBox.Checked = model.EqualizeAll; useRelativeSvCheckBox.Checked = model.RelativeUse; rememberCheckBox.Checked = model.RememberOptions; } }
async private void LoadUserInfo() { SharedPreferences prefs = Constants.GetSharedPreferences(Constants.PreferencesFileName); UserFirstName = prefs.GetString(Constants.UserFirstNameKey); UserLastName = prefs.GetString(Constants.UserLastNameKey); string image_url = prefs.GetString(Constants.UserImageUrlKey); CacheService cache = CacheService.Init(SessionService.GetCredentialFileName(), Constants.PreferencesFileName, Constants.LocalDbName); /*if (!string.IsNullOrEmpty(image_url)) * { * var tuple = await cache.tryGetResource(image_url); * UserImage = tuple.Item1; * } */ }
public MainApp(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) { Instance = this; SharedPreferences = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); GraphSaverLoader = new Graph.SaverLoader(new AssetsProvider(ApplicationContext)); if (IsAppUpdated()) { var groupName = SharedPreferences.GetString("groupnumber", "-1"); var dictionary = Instance.GroupsDictionary.Task.Result; if (dictionary.TryGetValue(groupName, out int id)) { SharedPreferences.Edit().PutInt("groupid", id).Apply(); } } }
private void ReadPIDBalanceCar(SharedPreferences sp) { //直立PID textBox_Stand_P.Text = sp.GetString("Stand_P", "1.0"); textBox_Stand_I.Text = sp.GetString("Stand_I", "1.0"); textBox_Stand_D.Text = sp.GetString("Stand_D", "1.0"); //速度PID textBox_Speed_P.Text = sp.GetString("Speed_P", "1.0"); textBox_Speed_I.Text = sp.GetString("Speed_I", "1.0"); textBox_Speed_D.Text = sp.GetString("Speed_D", "1.0"); //方向PID textBox_Direction_P.Text = sp.GetString("Direction_P", "1.0"); textBox_Direction_I.Text = sp.GetString("Direction_I", "1.0"); textBox_Direction_D.Text = sp.GetString("Direction_D", "1.0"); }
private void ReadPIDSetup(SharedPreferences sp) { //保存的车型 radioButton_FourWheel.Checked = sp.GetBoolean("radioButton_carType", true); if (!radioButton_FourWheel.Checked) { radioButton_BalanceCar.Checked = true; } if (radioButton_FourWheel.Checked) //四轮车PID { ReadPIDFourWheel(sp); } else if (radioButton_BalanceCar.Checked) //直立车PID参数的获取 { ReadPIDBalanceCar(sp); } }
public static void toggle(Firebase boardsRef, string boardId) { SharedPreferences preferences = mContext.getSharedPreferences(PREFS_NAME, 0); ISet <string> syncedBoards = new HashSet <string>(preferences.getStringSet(PREF_NAME, new HashSet <string>())); if (syncedBoards.Contains(boardId)) { syncedBoards.Remove(boardId); boardsRef.child(boardId).keepSynced(false); } else { syncedBoards.Add(boardId); boardsRef.child(boardId).keepSynced(true); } preferences.edit().putStringSet(PREF_NAME, syncedBoards).commit(); Log.i(TAG, "Board " + boardId + " is now " + (syncedBoards.Contains(boardId) ? "" : "not ") + "synced"); }
async void DoRegisterCommand1() { try { MLearningDB.User newuser = new MLearningDB.User { email = Email, username = RegUsername, password = EncryptionService.encrypt(RegPassword), name = Name, lastname = ":)", image_url = "http://www.clinicatorielli.com/img/icons/no-user.png", created_at = DateTime.Now, updated_at = DateTime.Now }; int idInstitution = 1; newuser.password = EncryptionService.encrypt(newuser.password); bool exists = await _mLearningService.CheckIfExistsNoLocale <MLearningDB.User> (usr => usr.username == newuser.username, (it) => it.updated_at, it => it.id); if (exists) { return; } OperationResult op = await _mLearningService.CreateAndRegisterConsumer(newuser, idInstitution); MLearningDB.User user = new MLearningDB.User { username = newuser.username, password = newuser.password }; SharedPreferences prefs = Constants.GetSharedPreferences(Constants.PreferencesFileName); prefs.PutString(Constants.UserFirstNameKey, Name); prefs.PutString(Constants.UserLastNameKey, Lastname); prefs.PutString(Constants.UserImageUrlKey, UserImageUrl); prefs.Commit(); ClearProperties(); ShowViewModel <MainViewModel>(); } catch (MobileServiceInvalidOperationException e) { ConnectionOK = false; } catch (WebException e) { ConnectionOK = false; } }
private void LoadConfig(string fileName) { var sp = new SharedPreferences(fileName); if (sp.ConfigFileExists) { ReadPortSetup(sp); ReadPIDSetup(sp); ReadDIYNumberSetup(sp); ReadRealTimeSetup(sp); ReadOthers(sp); textBox_receive.Clear(); } else { //载入默认设置 ResetToDefaultSettings(); } }
/// <summary> /// Init the agent. </summary> /// <param name="context"> application context. </param> private EngagementAgent(Context context) { if (!InstanceFieldsInitialized) { InitializeInstanceFields(); InstanceFieldsInitialized = true; } /* Store application context, we'll use this to bind */ mContext = context; /* Create main thread handler */ mHandler = new Handler(Looper.MainLooper); /* Retrieve configuration */ Bundle config = EngagementUtils.getMetaData(context); mReportCrash = config.getBoolean("engagement:reportCrash", true); string settingsFile = config.getString("engagement:agent:settings:name"); int settingsMode = config.getInt("engagement:agent:settings:mode", 0); if (TextUtils.isEmpty(settingsFile)) { settingsFile = "engagement.agent"; } /* Watch preferences */ mSettings = context.getSharedPreferences(settingsFile, settingsMode); mSettingsListener = new OnSharedPreferenceChangeListenerAnonymousInnerClassHelper(this); mSettings.registerOnSharedPreferenceChangeListener(mSettingsListener); /* Install Engagement crash handler if enabled */ if (mReportCrash) { Thread.DefaultUncaughtExceptionHandler = mEngagementCrashHandler; } /* Broadcast intent for Engagement modules */ Intent agentCreatedIntent = new Intent(INTENT_ACTION_AGENT_CREATED); agentCreatedIntent.Package = context.PackageName; context.sendBroadcast(agentCreatedIntent); }
private void ReadPortSetup(SharedPreferences sp) { //读取选中的端口 if (_hasPorts) { //判断当前端口的数量,小于则表示是OK。 if (sp.GetInt32("selectedPort", 0) < comboBox_port.Items.Count) comboBox_port.SelectedIndex = sp.GetInt32("selectedPort", 0); else { comboBox_port.SelectedIndex = 0; } } //读取设置的波特率 comboBox_baudrate.SelectedIndex = sp.GetInt32("baudRate", 0); //读取设置的校验方式 comboBox_parity.SelectedIndex = sp.GetInt32("parity", 0); //读取设置的数据位 comboBox_databit.SelectedIndex = sp.GetInt32("dataBits", 0); //读取设置的停止位 comboBox_stopbit.SelectedIndex = sp.GetInt32("stopBits", 0); //读取自动发送数据时间间隔 textBox_sendPeriod.Text = sp.GetInt32("intervalTime", 500).ToString(); //读取接收方式 checkBox_receiveHex.Checked = sp.GetBoolean("acceptChar", true); //读取标志变量,即是否在接收框中显示信息。 showInfo = sp.GetBoolean("showInfo", true); button_receivepause.Text = showInfo ? "暂停接收显示" : "继续接收显示"; }
private void ReadRealTimeSetup(SharedPreferences sp) { textBox_Realtime_Number.Text = sp.GetString("RealtimeNum", "1"); }
private void Init_pane_Scope() { var sp = new SharedPreferences(SavefileName); panel_Scope.AutoScroll = true; var total = ScopeNumber; for (var i = 0; i < total; i++) { var checkDrawing = new CheckBox(); checkDrawing.Size = new Size(15, 15); checkDrawing.Location = new Point(20 + i%8*77, 10 + i/8*60); checkDrawing.Name = "checkBox_Def" + Convert.ToString(i + 1); checkDrawing.Text = ""; var checkState = string.Format("SCOPE_CheckState{0}", i + 1); checkDrawing.Checked = sp.GetBoolean(checkState, false); checkDrawing.CheckedChanged += CheckDrawingOnCheckedChanged; var txtBoxName = new TextBox(); txtBoxName.Size = new Size(50, 20); //textbox大小 txtBoxName.Location = new Point(41 + i%8*77, 7 + i/8*60); txtBoxName.Name = "txtName" + Convert.ToString(i + 1); txtBoxName.TextAlign = HorizontalAlignment.Center; var txtName_CustomPara = string.Format("SCOPE_TextName{0}", i + 1); var getName = sp.GetString(txtName_CustomPara, @"波形" + Convert.ToString(i + 1)); txtBoxName.Text = getName.Trim() != "" ? getName : string.Format("波形{0}", i + 1); txtBoxName.BackColor = _colorLine[i%8]; txtBoxName.TextChanged += ScopeTextNameChanged; txtBoxName.Enabled = checkDrawing.Checked; var buttonNewForm = new Button(); buttonNewForm.Size = new Size(66, 23); buttonNewForm.Location = new Point(25 + i%8*77, 34 + i/8*60); buttonNewForm.Name = "buttonDraw" + Convert.ToString(i + 1); buttonNewForm.Text = @"独立图像"; buttonNewForm.Click += ButtonNewFormOnClick; buttonNewForm.Enabled = checkDrawing.Checked; panel_Scope.Controls.Add(checkDrawing); panel_Scope.Controls.Add(txtBoxName); panel_Scope.Controls.Add(buttonNewForm); } }
private void InitzedGraph() { var myPane = zedGraph_local.GraphPane; myPane.Title.IsVisible = false; myPane.XAxis.Title.Text = "time"; myPane.YAxis.Title.Text = "Value"; //show grid myPane.XAxis.MajorGrid.IsVisible = true; myPane.YAxis.MajorGrid.IsVisible = true; // Align the Y axis labels so they are flush to the axis myPane.YAxis.Scale.Align = AlignP.Inside; // Manually set the axis range myPane.XAxis.Scale.Min = _xminScale; myPane.XAxis.Scale.Max = _xmaxScale; myPane.YAxis.Scale.Min = _yminScale; myPane.YAxis.Scale.Max = _ymaxScale; // Fill the axis background with a gradient myPane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f); // OPTIONAL: Show tooltips when the mouse hovers over a point zedGraph_local.IsShowPointValues = true; zedGraph_local.PointValueEvent += MyPointValueHandler; for (var i = 0; i < ScopeNumber; i++) { zedGrpahNames[i] = new ZedGrpahName(); coOb[i] = new CallObject(); } var sp = new SharedPreferences(SavefileName); for (var i = 0; i < ScopeNumber; i++) { zedGrpahNames[i].listZed.Add(Convert.ToDouble(zedGrpahNames[i].x), 0); var curve = string.Format("波形{0}", i + 1); //自己定义的变量名称 var txtName_CustomPara = string.Format("SCOPE_TextName{0}", i + 1); var getName = sp.GetString(txtName_CustomPara, @"波形" + Convert.ToString(i + 1)); zedGraph_local.GraphPane.AddCurve(getName.Trim() != "" ? getName : curve, zedGrpahNames[i].listZed, _colorLine[i%8], SymbolType.None); } refleshZedPane(zedGraph_local); }
private void ReadDIYNumberSetup(SharedPreferences sp) { textBox_DIY_Number.Text = sp.GetInt32("DIY_Number", 1).ToString(); }
private void button_electricity_NumConfirm_Click(object sender, EventArgs e) { if (isRealTimeValide()) { var sp = new SharedPreferences(SavefileName); if (sp.ConfigFileExists) { DrawRealTimePannel(sp, false); } SaveConfig(SavefileName); } }
private void InitRealtime() { var sp = new SharedPreferences(SavefileName); if (sp.ConfigFileExists && isRealTimeValide()) { DrawRealTimePannel(sp, true); } }
private void AddControlsToPannel(SharedPreferences sp, int start, int end, bool byInit) { for (var i = start; i < end; i++) { var checkboxSelect = new CheckBox(); checkboxSelect.Size = new Size(50, 20); checkboxSelect.Location = new Point(30 + 70*0, 30*(i + 1)); checkboxSelect.Name = "checkBox_Def" + Convert.ToString(i + 1); checkboxSelect.Text = (i + 1).ToString(); if (byInit) { var checkState = string.Format("DIY_CheckState{0}", i + 1); checkboxSelect.Checked = sp.GetBoolean(checkState, true); } checkboxSelect.CheckedChanged += CheckboxSelectOnCheckedChanged; var txtBoxName = new TextBox(); txtBoxName.Size = new Size(50, 50); //textbox大小 txtBoxName.Location = new Point(30 + 70*1, 30*(i + 1)); txtBoxName.Name = @"txtName" + Convert.ToString(i + 1); txtBoxName.Text = @"Name" + Convert.ToString(i + 1); txtBoxName.TextAlign = HorizontalAlignment.Center; if (byInit) { var txtName_CustomPara = string.Format("DIY_TextName{0}", i + 1); txtBoxName.Text = sp.GetString(txtName_CustomPara, "数据"); } else { txtBoxName.Enabled = false; } var txtBoxValue = new TextBox(); txtBoxValue.Size = new Size(50, 50); //textbox大小 txtBoxValue.Location = new Point(30 + 70*2, 30*(i + 1)); txtBoxValue.Name = "txtValue" + Convert.ToString(i + 1); txtBoxValue.Text = @"1.0"; txtBoxValue.TextAlign = HorizontalAlignment.Center; if (byInit) { var txtValue_CustomPara = string.Format("DIY_TextValue{0}", i + 1); txtBoxValue.Text = sp.GetString(txtValue_CustomPara, "1.0"); } else { txtBoxValue.Enabled = false; } txtBoxValue.TextChanged += DIYTextboxValueChanged; var submitButton = new Button(); submitButton.Size = new Size(50, 20); //textbox大小 submitButton.Location = new Point(30 + 70*3, 30*(i + 1)); submitButton.Name = "buttonSubmit" + Convert.ToString(i + 1); submitButton.Text = @"修改"; submitButton.Click += SubmitButtonOnClick; if (!byInit) { submitButton.Enabled = false; } if (!checkboxSelect.Checked) { txtBoxName.Enabled = false; txtBoxValue.Enabled = false; submitButton.Enabled = false; } panel_add_DIYControls.Controls.Add(checkboxSelect); panel_add_DIYControls.Controls.Add(txtBoxName); panel_add_DIYControls.Controls.Add(txtBoxValue); panel_add_DIYControls.Controls.Add(submitButton); } }
private void DrawCustomParaPannel(bool byInit) { panel_add_DIYControls.AutoScroll = true; panel_add_DIYControls.Controls.Clear(); var total = int.Parse(textBox_DIY_Number.Text); var sp = new SharedPreferences(SavefileName); if (sp.ConfigFileExists) { AddControlsToPannel(sp, 0, total, byInit); } }
private void Init_CustomPara_DynamicControls() { var sp = new SharedPreferences(SavefileName); if (sp.ConfigFileExists && isCustomParaValidate()) { DrawCustomParaPannel(true); } }
private void ReadOthers(SharedPreferences sp) { comboBoxCCDPath.SelectedIndex = sp.GetInt32("comboboxCCDPath", 0); }
private void GetCustomOldNames(List<bool> state, List<string> names, List<string> value) { SharedPreferences sp = new SharedPreferences(SavefileName); int oldNumber = 0; if(sp.ConfigFileExists) oldNumber = sp.GetInt32("DIY_Number", 1); for (var i = 0; i < oldNumber; i++) { var checkboxSelect = (CheckBox)panel_add_DIYControls.Controls.Find("checkBox_Def" + Convert.ToString(i + 1), true)[0]; state.Add(checkboxSelect.Checked); var txtBoxValue = (TextBox) panel_add_DIYControls.Controls.Find("txtValue" + Convert.ToString(i + 1), true)[0]; value.Add(txtBoxValue.Text); var txtBoxName = (TextBox)panel_add_DIYControls.Controls.Find("txtName" + Convert.ToString(i + 1), true)[0]; names.Add(txtBoxName.Text); } }
private void DrawRealTimePannel(SharedPreferences sp, bool byInit) { panel_Electricity.AutoScroll = true; panel_Electricity.Controls.Clear(); var total = int.Parse(textBox_Realtime_Number.Text); for (var i = 0; i < total; i++) { var labelElect = new TextBox(); labelElect.Size = new Size(100, 20); //label大小 labelElect.Location = new Point(30 + 120*0, 30*(i + 1)); labelElect.Name = "txtElectName" + Convert.ToString(i + 1); labelElect.Text = @"实时变量" + Convert.ToString(i + 1); labelElect.TextAlign = HorizontalAlignment.Center; if (byInit) { var elecName = string.Format("textElectName{0}", i + 1); labelElect.Text = sp.GetString(elecName, "1.0"); } var txtBoxValue = new TextBox(); txtBoxValue.Size = new Size(50, 50); txtBoxValue.Location = new Point(30 + 120*1, 30*(i + 1)); txtBoxValue.Name = "txtElectValue" + Convert.ToString(i + 1); txtBoxValue.TextAlign = HorizontalAlignment.Center; if (byInit) { var elecValue = string.Format("txtElectValue{0}", i + 1); txtBoxValue.Text = sp.GetString(elecValue, "1.0"); } panel_Electricity.Controls.Add(labelElect); panel_Electricity.Controls.Add(txtBoxValue); } }