private void restoreState( IPersistentPairStorage storage) { prefixTextBox.Text = ConvertHelper.ToString( PersistanceHelper.RestoreValue( storage, @"autoTranslateForm.prefixTextBox.Text", prefixTextBox.Text)); prefixCheckBox.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"autoTranslateForm.prefixCheckBox.Checked", prefixCheckBox.Checked)); _ignore = true; referenceLanguageGroupBox.SelectedIndex = Math.Min( ConvertHelper.ToInt32( PersistanceHelper.RestoreValue( storage, @"autoTranslateForm.referenceLanguageComboBoxEdit.SelectedIndex", referenceLanguageGroupBox.SelectedIndex)), referenceLanguageGroupBox.Properties.Items.Count - 1); _ignore = false; refillLanguagesToTranslate(); DevExpressExtensionMethods.RestoreSettings( languagesToTranslateCheckListBox, storage, @"autoTranslateForm.languagesToTranslateCheckListBox"); }
private void saveState( IPersistentPairStorage storage) { using (new SilentProjectStoreGuard(_project)) { PersistanceHelper.SaveValue( storage, @"sendProjectWizardForm.exportProjectFileCheckEdit.Checked", exportProjectFileCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendProjectWizardForm.exportResourceFilesCheckEdit.Checked", exportResourceFilesCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendProjectWizardForm.exportLocalSettingsCheckEdit.Checked", exportLocalSettingsCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendProjectWizardForm.zulReceiversTextEdit.Text", zulReceiversTextEdit.Text); PersistanceHelper.SaveValue( storage, @"sendProjectWizardForm.zulSubjectTextEdit.Text", zulSubjectTextEdit.Text); PersistanceHelper.SaveValue( storage, @"sendProjectWizardForm.zulBodyTextEdit.Text", zulBodyTextEdit.Text); } }
public DynamicSettingsHierarchical( IPersistentPairStorage regular, IPersistentPairStorage parent) { _regular = regular; _parent = parent; }
private static void restoreState( IPersistentPairStorage storage, TreeList c) { var prefix = c.Name; var xml = ConvertHelper.ToString( PersistanceHelper.RestoreValue(storage, prefix + @".TreeList")); if (!string.IsNullOrEmpty(xml)) { // Remove unwanted serialized elements. xml = removeNodes( xml, new[] { @"//property[@name='OptionsBehavior']", @"//property[@name='OptionsMenu']", @"//property[@name='OptionsSelection']", @"//property[@name='OptionsView']" }); using var tfc = new ZetaTemporaryFileCreator(xml); c.RestoreLayoutFromXml( tfc.FilePath, new OptionsLayoutTreeList { AddNewColumns = false, RemoveOldColumns = true, StoreAppearance = false }); } }
private void saveState( IPersistentPairStorage storage) { PersistanceHelper.SaveValue( storage, @"autoTranslateForm.prefixTextBox.Text", prefixTextBox.Text); PersistanceHelper.SaveValue( storage, @"autoTranslateForm.prefixCheckBox.Checked", prefixCheckBox.Checked); PersistanceHelper.SaveValue( storage, @"autoTranslateForm.useExistingTranslationsCheckBox.Checked", useExistingTranslationsCheckBox.Checked); PersistanceHelper.SaveValue( storage, @"autoTranslateForm.useOnlyExistingTranslationsCheckEdit.Checked", useOnlyExistingTranslationsCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"autoTranslateForm.referenceLanguageComboBoxEdit.SelectedIndex", referenceLanguageGroupBox.SelectedIndex); DevExpressExtensionMethods.PersistSettings( languagesToTranslateCheckListBox, storage, @"autoTranslateForm.languagesToTranslateCheckListBox"); }
public FilterSerializer( GridView gridView, IPersistentPairStorage storage, string key) : base(gridView, storage, key) { }
public SortSerializer( GridView gridView, IPersistentPairStorage storage, string key) : base(gridView, storage, key) { }
public DynamicSettingsHierarchical( IPersistentPairStorage regular, IPersistentPairStorage parent ) { _regular = regular; _parent = parent; }
public AllLayoutSerializer( GridView gridView, IPersistentPairStorage storage, string key) { _filterSerializer = new FilterSerializer(gridView, storage, key); _sortSerializer = new SortSerializer(gridView, storage, key); }
public AllLayoutSerializer( GridView gridView, IPersistentPairStorage storage, string key) { _filterSerializer = new FilterSerializer(gridView, storage, key); _sortSerializer = new SortSerializer(gridView, storage, key); }
private static void restoreState( IPersistentPairStorage storage, TextEdit c) { var prefix = c.Name; c.Text = PersistanceHelper.RestoreValue(storage, prefix + @".Text") as string; }
private void saveState( IPersistentPairStorage storage) { using (new SilentProjectStoreGuard(_project)) { FormHelper.SaveValue( storage, @"sendFileToTranslator.destinationFilePathTextEdit.Text", destinationFileTextEdit.Text); DevExpressExtensionMethods.PersistSettings( fileGroupsListBox, storage, @"sendFileToTranslator.fileGroupsListBox"); DevExpressExtensionMethods.PersistSettings( languagesToExportCheckListBox, storage, @"sendFileToTranslator.languagesToExportCheckListBox"); FormHelper.SaveValue( storage, @"sendFileToTranslator.referenceLanguageComboBoxEdit.SelectedIndex", referenceLanguageGroupBox.SelectedIndex); FormHelper.SaveValue( storage, @"sendFileToTranslator.openFileAfterGeneratingCheckEdit.Checked", openFileAfterGeneratingCheckEdit.Checked); FormHelper.SaveValue( storage, @"sendFileToTranslator.openAfterGeneratingCheckEdit.Checked", openAfterGeneratingCheckEdit.Checked); FormHelper.SaveValue( storage, @"sendFileToTranslator.eliminateDuplicateRowsCheckEdit.Checked", eliminateDuplicateRowsCheckEdit.Checked); FormHelper.SaveValue( storage, @"sendFileToTranslator.exportWithoutDestinationTranslationOnlyCheckEdit.Checked", exportWithoutDestinationTranslationOnlyCheckEdit.Checked); FormHelper.SaveValue( storage, @"sendFileToTranslator.exportGroupsAsOneWorkSheetCheckEdit.Checked", exportGroupsAsOneWorkSheetCheckEdit.Checked); FormHelper.SaveValue( storage, @"sendFileToTranslator.exportLanguageColumnsOnlyCheckEdit.Checked", exportLanguageColumnsOnlyCheckEdit.Checked); FormHelper.SaveValue( storage, @"sendFileToTranslator.exportGroupsAsWorkSheetsCheckEdit.Checked", exportGroupsAsWorkSheetsCheckEdit.Checked); } }
protected LayoutSerializerBase( GridView gridView, IPersistentPairStorage storage, string key) { this.gridView = gridView; _storage = storage; _key = key; }
private void restoreState( IPersistentPairStorage storage) { sourceFileTextEdit.Text = ConvertHelper.ToString( PersistanceHelper.RestoreValue( storage, @"receiveFileFromTranslator.sourceFilePathTextEdit.Text")); }
protected LayoutSerializerBase( GridView gridView, IPersistentPairStorage storage, string key) { _gridView = gridView; _storage = storage; _key = key; }
private static void saveState( IPersistentPairStorage storage, TextEdit c) { var prefix = c.Name; PersistanceHelper.SaveValue( storage, prefix + @".Text", c.Text); }
private static void saveState( IPersistentPairStorage storage, CheckEdit c) { var prefix = c.Name; PersistanceHelper.SaveValue( storage, prefix + @".Checked", c.Checked); }
private static void restoreState( IPersistentPairStorage storage, CheckEdit c) { var prefix = c.Name; var o = PersistanceHelper.RestoreValue(storage, prefix + @".Checked"); if (o != null) { var index = ConvertHelper.ToBoolean(o); c.Checked = index; } }
public static void PersistSettings( CheckedListBoxControl c, IPersistentPairStorage storage, string key ) { var indexes = new List<string>(); for ( var i = 0; i < c.Items.Count; ++i ) { if ( c.GetItemChecked( i ) ) { indexes.Add( i.ToString() ); } } PersistanceHelper.SaveValue( storage, key, string.Join( @";", indexes.ToArray() ) ); }
public static void PersistSettingsByName( CheckedListBoxControl c, IPersistentPairStorage storage, string key) { var names = new List <string>(); for (var i = 0; i < c.Items.Count; ++i) { if (c.GetItemChecked(i)) { names.Add(c.GetItem(i).ToString()); } } PersistanceHelper.SaveValue(storage, key, string.Join(@"###{{{}}}###", names.ToArray())); }
private void saveState( IPersistentPairStorage storage) { PersistanceHelper.SaveValue( storage, @"receiveFileFromTranslator.sourceFilePathTextEdit.Text", sourceFileTextEdit.Text); DevExpressExtensionMethods.PersistSettings( fileGroupsListBox, storage, @"receiveFileFromTranslator.fileGroupsListBox"); DevExpressExtensionMethods.PersistSettings( languagesToImportCheckListBox, storage, @"receiveFileFromTranslator.languagesToImportCheckListBox"); }
public static void RestoreSettings( CheckedListBoxControl c, IPersistentPairStorage storage, string key) { var indexes = new List <string>(); for (var i = 0; i < c.Items.Count; ++i) { if (c.GetItemChecked(i)) { indexes.Add(i.ToString()); } } var def = string.Join(@";", indexes.ToArray()); // -- var s = PersistanceHelper.RestoreValue( storage, key, def) as string; if (string.IsNullOrEmpty(s)) { for (var i = 0; i < c.Items.Count; ++i) { c.SetItemChecked(i, false); } } else { var splitted = new List <string>(s.Split(';')); var ris = new List <int>(); splitted.ForEach(x => ris.Add(int.Parse(x))); for (var i = 0; i < c.Items.Count; ++i) { c.SetItemChecked(i, ris.Contains(i)); } } }
private static void restoreState( IPersistentPairStorage storage, GridView c) { var prefix = c.Name; var xml = ConvertHelper.ToString( PersistanceHelper.RestoreValue(storage, prefix + @".GridView")); if (!string.IsNullOrEmpty(xml)) { // Remove unwanted serialized elements. //xml = removeNodes( // xml, // new[] // { // @"//property[@name='OptionsBehavior']", // @"//property[@name='OptionsCustomization']", // @"//property[@name='OptionsDetail']", // @"//property[@name='OptionsFilter']", // @"//property[@name='OptionsHint']", // @"//property[@name='OptionsLayout']", // @"//property[@name='OptionsMenu']", // @"//property[@name='OptionsNavigation']", // @"//property[@name='OptionsPrint']", // @"//property[@name='OptionsSelection']", // @"//property[@name='OptionsView']", // }); using (var tfc = new ZetaTemporaryFileCreator(xml)) { c.RestoreLayoutFromXml( tfc.FilePath, new OptionsLayoutGrid { StoreAllOptions = false, StoreDataSettings = true, StoreVisualOptions = false, StoreAppearance = false }); } } }
public static void RestoreSettings( CheckedListBoxControl c, IPersistentPairStorage storage, string key ) { var indexes = new List<string>(); for ( var i = 0; i < c.Items.Count; ++i ) { if ( c.GetItemChecked( i ) ) { indexes.Add( i.ToString() ); } } var def = string.Join( @";", indexes.ToArray() ); // -- var s = PersistanceHelper.RestoreValue( storage, key, def ) as string; if ( string.IsNullOrEmpty( s ) ) { for ( var i = 0; i < c.Items.Count; ++i ) { c.SetItemChecked( i, false ); } } else { var splitted = new List<string>( s.Split( ';' ) ); var ris = new List<int>(); splitted.ForEach( x => ris.Add( int.Parse( x ) ) ); for ( var i = 0; i < c.Items.Count; ++i ) { c.SetItemChecked( i, ris.Contains( i ) ); } } }
private static void saveState( IPersistentPairStorage storage, ComboBoxEdit c) { var prefix = c.Name; PersistanceHelper.SaveValue( storage, prefix + @".SelectedIndex", c.SelectedIndex); if (c.Properties.TextEditStyle == TextEditStyles.Standard) { PersistanceHelper.SaveValue( storage, prefix + @".Text", c.Text); } }
public static void RestoreSettingsByName( CheckedListBoxControl c, IPersistentPairStorage storage, string key) { var names = new List <string>(); for (var i = 0; i < c.Items.Count; ++i) { if (c.GetItemChecked(i)) { names.Add(c.GetItem(i).ToString()); } } var def = string.Join(@"###{{{}}}###", names.ToArray()); // -- var s = PersistanceHelper.RestoreValue( storage, key, def) as string; if (string.IsNullOrEmpty(s)) { for (var i = 0; i < c.Items.Count; ++i) { c.SetItemChecked(i, false); } } else { var splitted = new List <string>(s.Split(new[] { @"###{{{}}}###" }, StringSplitOptions.RemoveEmptyEntries)); var ris = new List <string>(splitted); for (var i = 0; i < c.Items.Count; ++i) { c.SetItemChecked(i, ris.Contains(c.GetItem(i).ToString())); } } }
private void restoreState( IPersistentPairStorage storage) { exportProjectFileCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendProjectWizardForm.exportProjectFileCheckEdit.Checked", exportProjectFileCheckEdit.Checked)); exportResourceFilesCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendProjectWizardForm.exportResourceFilesCheckEdit.Checked", exportResourceFilesCheckEdit.Checked)); exportLocalSettingsCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"exportLocalSettingsCheckEdit.exportResourceFilesCheckEdit.Checked", exportLocalSettingsCheckEdit.Checked)); zulReceiversTextEdit.Text = ConvertHelper.ToString( PersistanceHelper.RestoreValue( storage, @"sendProjectWizardForm.zulReceiversTextEdit.Text", SendProjectController.VendorReceiverGuiName)); zulSubjectTextEdit.Text = ConvertHelper.ToString( PersistanceHelper.RestoreValue( storage, @"sendProjectWizardForm.zulSubjectTextEdit.Text", zulSubjectTextEdit.Text)); zulBodyTextEdit.Text = ConvertHelper.ToString( PersistanceHelper.RestoreValue( storage, @"sendProjectWizardForm.zulBodyTextEdit.Text", zulBodyTextEdit.Text)); }
private void restoreState( IPersistentPairStorage storage) { exportProjectFileCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendProjectWizardForm.exportProjectFileCheckEdit.Checked", exportProjectFileCheckEdit.Checked)); exportResourceFilesCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendProjectWizardForm.exportResourceFilesCheckEdit.Checked", exportResourceFilesCheckEdit.Checked)); exportLocalSettingsCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"exportLocalSettingsCheckEdit.exportResourceFilesCheckEdit.Checked", exportLocalSettingsCheckEdit.Checked)); zulReceiversTextEdit.Text = ConvertHelper.ToString( PersistanceHelper.RestoreValue( storage, @"sendProjectWizardForm.zulReceiversTextEdit.Text", SendProjectController.VendorReceiverGuiName)); zulSubjectTextEdit.Text = ConvertHelper.ToString( PersistanceHelper.RestoreValue( storage, @"sendProjectWizardForm.zulSubjectTextEdit.Text", zulSubjectTextEdit.Text)); zulBodyTextEdit.Text = ConvertHelper.ToString( PersistanceHelper.RestoreValue( storage, @"sendProjectWizardForm.zulBodyTextEdit.Text", zulBodyTextEdit.Text)); }
private static void saveState( IPersistentPairStorage storage, TreeList c) { var prefix = c.Name; using var tfc = new ZetaTemporaryFileCreator(); c.SaveLayoutToXml( tfc.FilePath, new OptionsLayoutTreeList { AddNewColumns = false, RemoveOldColumns = true, StoreAppearance = false }); PersistanceHelper.SaveValue( storage, prefix + @".TreeList", tfc.FileContentString); }
private static void saveState( IPersistentPairStorage storage, GridView c) { var prefix = c.Name; using var tfc = new ZetaTemporaryFileCreator(); c.SaveLayoutToXml( tfc.FilePath, new OptionsLayoutGrid { StoreAllOptions = false, StoreDataSettings = true, StoreVisualOptions = false, StoreAppearance = false }); PersistanceHelper.SaveValue( storage, prefix + @".GridView", tfc.FileContentString); }
private static void restoreState( IPersistentPairStorage storage, ComboBoxEdit c) { var prefix = c.Name; var o = PersistanceHelper.RestoreValue(storage, prefix + @".SelectedIndex"); if (o != null) { var index = ConvertHelper.ToInt32(o); if (index <= c.Properties.Items.Count - 1) { c.SelectedIndex = index; } } if (c.Properties.TextEditStyle == TextEditStyles.Standard) { c.Text = PersistanceHelper.RestoreValue(storage, prefix + @".Text") as string; } }
/// <summary> /// Called when [restoring sort state]. /// </summary> /// <param name="storage">The storage.</param> protected virtual void OnRestoringSortState( IPersistentPairStorage storage ) { if ( !insideRestoring ) { insideRestoring = true; try { RestoringSortStateEventArgs args = new RestoringSortStateEventArgs(); if ( storage != null ) { args.Storage = storage; } if ( RestoringSortState != null ) { RestoringSortState( this, args ); } FormHelper.RestoreState( args.Storage, this ); lastSortColumnIndex = Convert.ToInt32( FormHelper.RestoreValue( args.Storage, string.Format( @"SortingListViewControl.{0}.LastSortColumnIndex", this.Name ), lastSortColumnIndex ) ); sortAscending = Convert.ToBoolean( FormHelper.RestoreValue( args.Storage, string.Format( @"SortingListViewControl.{0}.SortAscending", this.Name ), sortAscending ) ); } finally { insideRestoring = false; } } }
/// <summary> /// The opposite to "SaveValue". /// </summary> /// <param name="storage">The storage.</param> /// <param name="name">The name.</param> /// <param name="fallBackValue">The fall back value.</param> /// <returns>Returns null if not found.</returns> public static object RestoreValue( IPersistentPairStorage storage, string name, object fallBackValue ) { return storage.RetrieveValue( name, fallBackValue ); }
private void saveState( IPersistentPairStorage storage) { using (new SilentProjectStoreGuard(_project)) { FormHelper.SaveValue( storage, @"sendFileToTranslator.destinationFilePathTextEdit.Text", destinationFileTextEdit.Text); DevExpressExtensionMethods.PersistSettings( fileGroupsListBox, storage, @"sendFileToTranslator.fileGroupsListBox"); DevExpressExtensionMethods.PersistSettings( languagesToExportCheckListBox, storage, @"sendFileToTranslator.languagesToExportCheckListBox"); FormHelper.SaveValue( storage, @"sendFileToTranslator.referenceLanguageComboBoxEdit.SelectedIndex", referenceLanguageGroupBox.SelectedIndex); FormHelper.SaveValue( storage, @"sendFileToTranslator.openFileAfterGeneratingCheckEdit.Checked", openFileAfterGeneratingCheckEdit.Checked); FormHelper.SaveValue( storage, @"sendFileToTranslator.openAfterGeneratingCheckEdit.Checked", openAfterGeneratingCheckEdit.Checked); FormHelper.SaveValue( storage, @"sendFileToTranslator.eliminateDuplicateRowsCheckEdit.Checked", eliminateDuplicateRowsCheckEdit.Checked); FormHelper.SaveValue( storage, @"sendFileToTranslator.exportWithoutDestinationTranslationOnlyCheckEdit.Checked", exportWithoutDestinationTranslationOnlyCheckEdit.Checked); FormHelper.SaveValue( storage, @"sendFileToTranslator.exportGroupsAsOneWorkSheetCheckEdit.Checked", exportGroupsAsOneWorkSheetCheckEdit.Checked); FormHelper.SaveValue( storage, @"sendFileToTranslator.exportLanguageColumnsOnlyCheckEdit.Checked", exportLanguageColumnsOnlyCheckEdit.Checked); FormHelper.SaveValue( storage, @"sendFileToTranslator.exportGroupsAsWorkSheetsCheckEdit.Checked", exportGroupsAsWorkSheetsCheckEdit.Checked); } }
private void restoreState( IPersistentPairStorage storage) { prefixTextBox.Text = ConvertHelper.ToString( PersistanceHelper.RestoreValue( storage, @"autoTranslateForm.prefixTextBox.Text", prefixTextBox.Text)); prefixCheckBox.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"autoTranslateForm.prefixCheckBox.Checked", prefixCheckBox.Checked)); _ignore = true; referenceLanguageGroupBox.SelectedIndex = Math.Min( ConvertHelper.ToInt32( PersistanceHelper.RestoreValue( storage, @"autoTranslateForm.referenceLanguageComboBoxEdit.SelectedIndex", referenceLanguageGroupBox.SelectedIndex)), referenceLanguageGroupBox.Properties.Items.Count - 1); _ignore = false; refillLanguagesToTranslate(); DevExpressExtensionMethods.RestoreSettings( languagesToTranslateCheckListBox, storage, @"autoTranslateForm.languagesToTranslateCheckListBox"); }
/// <summary> /// Saves the state of a control. /// </summary> /// <param name="storage">The storage.</param> /// <param name="c">The c.</param> private static void SaveState( IPersistentPairStorage storage, SplitContainer c ) { int realDistance = 0; if ( c.Orientation == Orientation.Vertical ) { if ( c.FixedPanel == FixedPanel.Panel1 ) { realDistance = c.SplitterDistance; } else { Debug.Assert( c.FixedPanel == FixedPanel.Panel2, @"FixedPanel must be Panel2." ); realDistance = c.Width - c.SplitterDistance; } } else { Debug.Assert( c.Orientation == Orientation.Horizontal, @"Orientation must be horizontal." ); if ( c.FixedPanel == FixedPanel.Panel1 || c.FixedPanel == FixedPanel.None ) { realDistance = c.SplitterDistance; } else { Debug.Assert( c.FixedPanel == FixedPanel.Panel2, @"FixedPanel must be Panel2." ); realDistance = c.Height - c.SplitterDistance; } } // -- string prefix = c.Name; SaveValue( storage, prefix + @"SplitterDistance", c.SplitterDistance ); SaveValue( storage, prefix + @"RealSplitterDistance", realDistance ); }
private void restoreState( IPersistentPairStorage storage) { _ignoreReferenceLanguageChanges = true; destinationFileTextEdit.Text = ConvertHelper.ToString( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.destinationFilePathTextEdit.Text")); DevExpressExtensionMethods.RestoreSettingsByName( fileGroupsListBox, storage, @"sendFileToTranslator.fileGroupsListBox"); DevExpressExtensionMethods.RestoreSettingsByName( languagesToExportCheckListBox, storage, @"sendFileToTranslator.languagesToExportCheckListBox"); referenceLanguageGroupBox.SelectedIndex = Math.Min( ConvertHelper.ToInt32( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.referenceLanguageComboBoxEdit.SelectedIndex", referenceLanguageGroupBox.SelectedIndex)), referenceLanguageGroupBox.Properties.Items.Count - 1); openFileAfterGeneratingCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.openFileAfterGeneratingCheckEdit.Checked", openFileAfterGeneratingCheckEdit.Checked)); openFolderAfterGeneratingCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.openAfterGeneratingCheckEdit.Checked", openFolderAfterGeneratingCheckEdit.Checked)); eliminateDuplicateRowsCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.eliminateDuplicateRowsCheckEdit.Checked", eliminateDuplicateRowsCheckEdit.Checked)); exportWithoutDestinationTranslationOnlyCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.exportWithoutDestinationTranslationOnlyCheckEdit.Checked", exportWithoutDestinationTranslationOnlyCheckEdit.Checked)); exportCompletelyEmptyRowsCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.exportCompletelyEmptyRowsCheckEdit.Checked", exportCompletelyEmptyRowsCheckEdit.Checked)); exportGroupsAsOneWorkSheetCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.exportGroupsAsOneWorkSheetCheckEdit.Checked", exportGroupsAsOneWorkSheetCheckEdit.Checked)); exportGroupsAsWorkSheetsCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.exportGroupsAsWorkSheetsCheckEdit.Checked", exportGroupsAsWorkSheetsCheckEdit.Checked)); exportGroupsAsExcelFilesCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.exportGroupsAsExcelFilesCheckEdit.Checked", exportGroupsAsExcelFilesCheckEdit.Checked)); exportNameColumnCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.exportNameColumnCheckEdit.Checked", exportNameColumnCheckEdit.Checked)); exportCommentColumnCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.exportCommentColumnCheckEdit.Checked", exportCommentColumnCheckEdit.Checked)); exportReferenceLanguageColumnCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.exportReferenceLanguageColumnCheckEdit.Checked", exportReferenceLanguageColumnCheckEdit.Checked)); exportFileGroupColumnCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.exportFileGroupColumnCheckEdit.Checked", exportFileGroupColumnCheckEdit.Checked)); exportEachLanguageIntoSeparateExcelFileCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.exportEachLanguageIntoSeparateExcelFileCheckEdit.Checked", exportEachLanguageIntoSeparateExcelFileCheckEdit.Checked)); useCrypticExcelExportSheetNamesCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.useCrypticExcelExportSheetNamesCheckEdit.Checked", useCrypticExcelExportSheetNamesCheckEdit.Checked)); sendFilesToEMailReceiversCheckEdit.Checked = ConvertHelper.ToBoolean( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.sendFilesToEMailReceivers2CheckEdit.Checked", sendFilesToEMailReceiversCheckEdit.Checked)); zulReceiversTextEdit.Text = ConvertHelper.ToString( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.zulReceiversTextEdit.Text", zulReceiversTextEdit.Text)); zulSubjectTextEdit.Text = ConvertHelper.ToString( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.zulSubjectTextEdit.Text", zulSubjectTextEdit.Text)); zulBodyTextEdit.Text = ConvertHelper.ToString( PersistanceHelper.RestoreValue( storage, @"sendFileToTranslator.zulBodyTextEdit.Text", zulBodyTextEdit.Text)); _ignoreReferenceLanguageChanges = false; // -- referenceLanguageGroupBox_SelectedIndexChanged(null, null); }
/// <summary> /// Restores the state of a control. /// </summary> /// <param name="storage">The storage.</param> /// <param name="c">The c.</param> private static void RestoreState( IPersistentPairStorage storage, SplitContainer c ) { string prefix = c.Name; object o1 = RestoreValue( storage, prefix + @"SplitterDistance" ); object o2 = RestoreValue( storage, prefix + @"RealSplitterDistance" ); if ( o1 != null && o2 != null ) { int distance = Convert.ToInt32( o1 ); int realDistance = Convert.ToInt32( o2 ); if ( c.Orientation == Orientation.Vertical ) { if ( c.FixedPanel == FixedPanel.Panel1 || c.FixedPanel == FixedPanel.None ) { c.SplitterDistance = realDistance; } else { Debug.Assert( c.FixedPanel == FixedPanel.Panel2, @"FixedPanel must be Panel2." ); if ( (c.Width - realDistance) > 0 ) { c.SplitterDistance = c.Width - realDistance; } } } else { Debug.Assert( c.Orientation == Orientation.Horizontal, string.Format( @"Unknown orientation '{0}'.", c.Orientation ) ); if ( c.FixedPanel == FixedPanel.Panel1 ) { c.SplitterDistance = realDistance; } else { Debug.Assert( c.FixedPanel == FixedPanel.Panel2, @"You must set one panel inside a splitter to be fixed." ); if ( (c.Height - realDistance) > 0 ) { c.SplitterDistance = c.Height - realDistance; } } } } }
private static void restoreState( IPersistentPairStorage storage, SplitContainerControl c ) { var prefix = c.Name; var o1 = PersistanceHelper.RestoreValue( storage, prefix + @".SplitterPosition" ); var o2 = PersistanceHelper.RestoreValue( storage, prefix + @".RealSplitterPosition" ); var o3 = PersistanceHelper.RestoreValue( storage, prefix + @".PercentageSplitterPosition" ); var o4 = PersistanceHelper.RestoreValue( storage, prefix + @".PanelVisibility" ); if ( o4!=null) { var s4 = ConvertHelper.ToString( o4, SplitPanelVisibility.Both.ToString()); c.PanelVisibility = (SplitPanelVisibility) Enum.Parse(typeof (SplitPanelVisibility), s4, true); } if ( o3 != null ) { // New method, saving and restoring the percentage. // See http://bytes.com/forum/thread616388.html. var percentageDistance = ConvertHelper.ToDouble( o3, CultureInfo.InvariantCulture ); if ( c.Horizontal ) { var realDistance = (int)(c.Height * (percentageDistance / 100.0)); if ( realDistance > 0 ) { c.SplitterPosition = realDistance; } } else { var realDistance = (int)(c.Width * (percentageDistance / 100.0)); if ( realDistance > 0 ) { c.SplitterPosition = realDistance; } } } else if ( o1 != null && o2 != null ) { var realDistance = Convert.ToInt32( o2 ); if ( c.Horizontal ) { if ( c.FixedPanel == SplitFixedPanel.Panel1 || c.FixedPanel == SplitFixedPanel.None ) { if ( realDistance > 0 ) { c.SplitterPosition = realDistance; } } else { Debug.Assert( c.FixedPanel == SplitFixedPanel.Panel2, @"You must set one panel inside a splitter to be fixed." ); if ( (c.Height - realDistance) > 0 ) { c.SplitterPosition = c.Height - realDistance; } } } else { if ( c.FixedPanel == SplitFixedPanel.Panel1 || c.FixedPanel == SplitFixedPanel.None ) { if ( realDistance > 0 ) { c.SplitterPosition = realDistance; } } else { Debug.Assert( c.FixedPanel == SplitFixedPanel.Panel2, @"FixedPanel must be Panel2." ); if ( (c.Width - realDistance) > 0 ) { c.SplitterPosition = c.Width - realDistance; } } } } }
private void saveState( IPersistentPairStorage storage) { PersistanceHelper.SaveValue( storage, @"receiveFileFromTranslator.sourceFilePathTextEdit.Text", sourceFileTextEdit.Text); DevExpressExtensionMethods.PersistSettings( fileGroupsListBox, storage, @"receiveFileFromTranslator.fileGroupsListBox"); DevExpressExtensionMethods.PersistSettings( languagesToImportCheckListBox, storage, @"receiveFileFromTranslator.languagesToImportCheckListBox"); }
/// <summary> /// Restores the state of a control. /// Works for list views, too (column widths). /// </summary> /// <param name="storage">The storage.</param> /// <param name="c">The c.</param> public static void RestoreState( IPersistentPairStorage storage, Control c ) { RestoreState( storage, c, null ); }
/// <summary> /// Restores the state of a control. /// Works for list views, too (column widths). /// </summary> /// <param name="storage">The storage.</param> /// <param name="c">The c.</param> /// <param name="info">The info.</param> public static void RestoreState( IPersistentPairStorage storage, Control c, RestoreInformation info ) { string prefix = c.Name; object o = null; if ( c is Splitter ) { o = RestoreValue( storage, prefix + @".SplitPosition" ); if ( o != null ) { ((Splitter)c).SplitPosition = Convert.ToInt32( o ); } } else if ( c is Form ) { Form s = c as Form; RestoreState( storage, s, info ); } else if ( c is SplitContainer ) { SplitContainer s = c as SplitContainer; RestoreState( storage, s ); } else if ( c is TabControl ) { o = RestoreValue( storage, prefix + @".SelectedIndex" ); if ( o != null ) { ((TabControl)c).SelectedIndex = Convert.ToInt32( o ); } } else if ( c is ListView ) { ListView listView = c as ListView; o = RestoreValue( storage, prefix + @".Columns.Count" ); if ( o != null ) { int count = Convert.ToInt32( o ); for ( int i = 0; i < count; ++i ) { o = RestoreValue( storage, prefix + @".Columns." + (i + 1) + @".Width" ); if ( o != null && i < listView.Columns.Count ) { listView.Columns[i].Width = Convert.ToInt32( o ); } } } // -- listView.SelectedItems.Clear(); o = RestoreValue( storage, prefix + @".SelectedIndexes.Count" ); if ( o != null ) { int count = Convert.ToInt32( o ); for ( int i = 0; i < count; ++i ) { o = RestoreValue( storage, prefix + @".SelectedIndexes." + (i + 1) + @".Index" ); if ( o != null ) { int index = ConvertHelper.ToInt32( o ); if ( index < listView.Items.Count ) { listView.Items[index].Checked = true; } } } } } else if ( c is TextBox ) { TextBox t = c as TextBox; o = RestoreValue( storage, prefix + @".Text" ); if ( o != null ) { t.Text = o as string; } } else if ( c is CheckBox ) { CheckBox cb = c as CheckBox; o = RestoreValue( storage, prefix + @".CheckState" ); if ( o != null ) { cb.CheckState = (CheckState)Enum.Parse( typeof( CheckState ), o as string, true ); } } else if ( c is RadioButton ) { RadioButton rb = c as RadioButton; o = RestoreValue( storage, prefix + @".Checked" ); if ( o != null ) { rb.Checked = ConvertHelper.ToBoolean( o ); } } else if ( c is DateTimePicker ) { DateTimePicker rb = c as DateTimePicker; o = RestoreValue( storage, prefix + @".Value" ); if ( o != null ) { rb.Value = ConvertHelper.ToDateTime( o ); } o = RestoreValue( storage, prefix + @".Checked" ); if ( o != null ) { rb.Checked = ConvertHelper.ToBoolean( o ); } } else if ( c is CheckedListBox ) { CheckedListBox clb = c as CheckedListBox; o = RestoreValue( storage, prefix + @".CheckedIndices" ); if ( o is string ) { o = StringHelper.DeserializeFromString( o as string ); if ( o is int[] ) { List<int> selectedIndices = new List<int>( o as int[] ); for ( int i = 0; i < clb.Items.Count; i++ ) { if ( selectedIndices.Contains( i ) ) { clb.SetItemChecked( i, true ); } else { clb.SetItemChecked( i, false ); } } } } } else if ( c is ComboBox ) { ComboBox rb = c as ComboBox; o = RestoreValue( storage, prefix + @".SelectedIndex" ); if ( o != null ) { int index = ConvertHelper.ToInt32( o ); if ( index <= rb.Items.Count - 1 ) { rb.SelectedIndex = index; } } if ( rb.DropDownStyle == ComboBoxStyle.DropDown ) { rb.Text = RestoreValue( storage, prefix + @".Text" ) as string; } } else { Debug.Assert( false, string.Format( @"Trying to restore the state of an unknown control type: '{0}'.", c.GetType() ) ); } // -- if ( c is ISaveRestoreState ) { ISaveRestoreState srs = c as ISaveRestoreState; if ( !protectRecursion.Contains( srs ) ) { protectRecursion.Add( srs ); try { srs.OnSaveState( storage, prefix ); } finally { protectRecursion.Remove( srs ); } } } }
/// <summary> /// The opposite to "SerializeValue". /// </summary> /// <param name="storage">The storage.</param> /// <param name="name">The name.</param> /// <param name="fallBackValue">The fall back value.</param> /// <returns>Returns NULL if not found.</returns> public static object DeserializeValue( IPersistentPairStorage storage, string name, object fallBackValue ) { try { object o = RestoreValue( storage, name ); if ( o == null || !(o is string) ) { return fallBackValue; } else { return StringHelper.DeserializeFromString( o.ToString() ); } } catch ( SerializationException x ) { LogCentral.Current.LogDebug( @"Silently caught SerializationException, returning fallback value.", x ); return fallBackValue; } }
/// <summary> /// Saves the state of a control. /// </summary> /// <param name="storage">The storage.</param> /// <param name="c">The c.</param> public static void SaveState( IPersistentPairStorage storage, Control c ) { string prefix = c.Name; SaveValue( storage, prefix + @".Left", c.Left ); SaveValue( storage, prefix + @".Top", c.Top ); SaveValue( storage, prefix + @".Width", c.Width ); SaveValue( storage, prefix + @".Height", c.Height ); if ( c is Splitter ) { SaveValue( storage, prefix + @".SplitPosition", ((Splitter)c).SplitPosition ); } else if ( c is Form ) { Form s = c as Form; SaveState( s ); } else if ( c is SplitContainer ) { SplitContainer s = c as SplitContainer; SaveState( s ); } else if ( c is TabControl ) { SaveValue( storage, prefix + @".SelectedIndex", ((TabControl)c).SelectedIndex ); } else if ( c is ListView ) { ListView listView = c as ListView; SaveValue( storage, prefix + @".Columns.Count", listView.Columns.Count ); for ( int i = 0; i < listView.Columns.Count; ++i ) { SaveValue( storage, prefix + @".Columns." + (i + 1) + @".Width", listView.Columns[i].Width ); } // -- SaveValue( storage, prefix + @".SelectedIndexes.Count", listView.SelectedIndices.Count ); for ( int i = 0; i < listView.SelectedIndices.Count; ++i ) { SaveValue( storage, prefix + @".SelectedIndexes." + (i + 1) + @".Index", listView.SelectedIndices[i] ); } } else if ( c is TextBox ) { TextBox t = c as TextBox; SaveValue( storage, prefix + @".Text", t.Text ); } else if ( c is CheckBox ) { CheckBox cb = c as CheckBox; SaveValue( storage, prefix + @".CheckState", cb.CheckState.ToString() ); } else if ( c is RadioButton ) { RadioButton rb = c as RadioButton; SaveValue( storage, prefix + @".Checked", rb.Checked ); } else if ( c is DateTimePicker ) { DateTimePicker rb = c as DateTimePicker; SaveValue( storage, prefix + @".Value", rb.Value ); SaveValue( storage, prefix + @".Checked", rb.Checked ); } else if ( c is CheckedListBox ) { CheckedListBox clb = c as CheckedListBox; List<int> selectedIndices = new List<int>(); foreach ( int si in clb.CheckedIndices ) { selectedIndices.Add( si ); } string sis = StringHelper.SerializeToString( selectedIndices.ToArray() ); SaveValue( storage, prefix + @".CheckedIndices", sis ); } else if ( c is ComboBox ) { ComboBox rb = c as ComboBox; SaveValue( storage, prefix + @".SelectedIndex", rb.SelectedIndex ); if ( rb.DropDownStyle == ComboBoxStyle.DropDown ) { SaveValue( storage, prefix + @".Text", rb.Text ); } } else { Debug.Assert( false, string.Format( @"Trying to save the state of an unknown control type: '{0}'.", c.GetType() ) ); } // -- if ( c is ISaveRestoreState ) { ISaveRestoreState srs = c as ISaveRestoreState; if ( !protectRecursion.Contains( srs ) ) { protectRecursion.Add( srs ); try { srs.OnSaveState( storage, prefix ); } finally { protectRecursion.Remove( srs ); } } } }
/// <summary> /// The opposite to "SaveValue". /// </summary> /// <param name="storage">The storage.</param> /// <param name="name">The name.</param> /// <returns>Returns null if not found.</returns> public static object RestoreValue( IPersistentPairStorage storage, string name ) { return RestoreValue( storage, name, null ); }
private void restoreState( IPersistentPairStorage storage) { sourceFileTextEdit.Text = ConvertHelper.ToString( PersistanceHelper.RestoreValue( storage, @"receiveFileFromTranslator.sourceFilePathTextEdit.Text")); }
/// <summary> /// Persist a name-value pair inside the registry. /// Does this on a per-user-basis. /// </summary> /// <param name="storage">The storage.</param> /// <param name="name">The name.</param> /// <param name="val">The val.</param> public static void SerializeValue( IPersistentPairStorage storage, string name, object val ) { if ( val == null ) { SaveValue( storage, name, null ); } else { SaveValue( storage, name, StringHelper.SerializeToString( val ) ); } }
private static void saveState( IPersistentPairStorage storage, SplitContainerControl c ) { int realDistance; double percentageDistance; if (c.Horizontal) { if (c.FixedPanel == SplitFixedPanel.Panel1 || c.FixedPanel == SplitFixedPanel.None) { realDistance = c.SplitterPosition; } else { Debug.Assert( c.FixedPanel == SplitFixedPanel.Panel2, @"FixedPanel must be Panel2."); realDistance = c.Height - c.SplitterPosition; } percentageDistance = ((double) c.SplitterPosition/c.Height)*100.0; } else { if (c.FixedPanel == SplitFixedPanel.Panel1 || c.FixedPanel == SplitFixedPanel.None) { realDistance = c.SplitterPosition; } else { Debug.Assert( c.FixedPanel == SplitFixedPanel.Panel2, @"FixedPanel must be Panel2."); realDistance = c.Width - c.SplitterPosition; } percentageDistance = ((double) c.SplitterPosition/c.Width)*100.0; } // -- var prefix = c.Name; if (c.SplitterPosition > 0) { PersistanceHelper.SaveValue(storage, prefix + @".SplitterPosition", c.SplitterPosition); } if (realDistance > 0) { PersistanceHelper.SaveValue(storage, prefix + @".RealSplitterPosition", realDistance); } if (percentageDistance > 0) { PersistanceHelper.SaveValue(storage, prefix + @".PercentageSplitterPosition", percentageDistance.ToString(CultureInfo.InvariantCulture)); } PersistanceHelper.SaveValue( storage, prefix + @".PanelVisibility", c.PanelVisibility.ToString()); }
private void restoreState( IPersistentPairStorage storage) { destinationFileTextEdit.Text = ConvertHelper.ToString( FormHelper.RestoreValue( storage, @"sendFileToTranslator.destinationFilePathTextEdit.Text")); DevExpressExtensionMethods.RestoreSettings( fileGroupsListBox, storage, @"sendFileToTranslator.fileGroupsListBox"); DevExpressExtensionMethods.RestoreSettings( languagesToExportCheckListBox, storage, @"sendFileToTranslator.languagesToExportCheckListBox"); referenceLanguageGroupBox.SelectedIndex = Math.Min( ConvertHelper.ToInt32( FormHelper.RestoreValue( storage, @"sendFileToTranslator.referenceLanguageComboBoxEdit.SelectedIndex", referenceLanguageGroupBox.SelectedIndex)), referenceLanguageGroupBox.Properties.Items.Count - 1); openFileAfterGeneratingCheckEdit.Checked = ConvertHelper.ToBoolean( FormHelper.RestoreValue( storage, @"sendFileToTranslator.openFileAfterGeneratingCheckEdit.Checked", openFileAfterGeneratingCheckEdit.Checked)); openAfterGeneratingCheckEdit.Checked = ConvertHelper.ToBoolean( FormHelper.RestoreValue( storage, @"sendFileToTranslator.openAfterGeneratingCheckEdit.Checked", openAfterGeneratingCheckEdit.Checked)); eliminateDuplicateRowsCheckEdit.Checked = ConvertHelper.ToBoolean( FormHelper.RestoreValue( storage, @"sendFileToTranslator.eliminateDuplicateRowsCheckEdit.Checked", eliminateDuplicateRowsCheckEdit.Checked)); exportWithoutDestinationTranslationOnlyCheckEdit.Checked = ConvertHelper.ToBoolean( FormHelper.RestoreValue( storage, @"sendFileToTranslator.exportWithoutDestinationTranslationOnlyCheckEdit.Checked", exportWithoutDestinationTranslationOnlyCheckEdit.Checked)); exportGroupsAsOneWorkSheetCheckEdit.Checked = ConvertHelper.ToBoolean( FormHelper.RestoreValue( storage, @"sendFileToTranslator.exportGroupsAsOneWorkSheetCheckEdit.Checked", exportGroupsAsOneWorkSheetCheckEdit.Checked)); exportLanguageColumnsOnlyCheckEdit.Checked = ConvertHelper.ToBoolean( FormHelper.RestoreValue( storage, @"sendFileToTranslator.exportLanguageColumnsOnlyCheckEdit.Checked", exportLanguageColumnsOnlyCheckEdit.Checked)); exportGroupsAsWorkSheetsCheckEdit.Checked = ConvertHelper.ToBoolean( FormHelper.RestoreValue( storage, @"sendFileToTranslator.exportGroupsAsWorkSheetsCheckEdit.Checked", exportGroupsAsWorkSheetsCheckEdit.Checked)); }
/// <summary> /// Restores the state of a control. /// </summary> /// <param name="storage">The storage.</param> /// <param name="c">The c.</param> /// <param name="info">The info.</param> private static void RestoreState( IPersistentPairStorage storage, Form c, RestoreInformation info ) { // If child, center to parent. bool centerParent = !c.TopLevel || c.ParentForm != null; bool hasAnythingRestored = false; string prefix = c.Name; object o = null; if ( !centerParent ) { o = RestoreValue( storage, prefix + @".Left" ); if ( o != null ) { hasAnythingRestored = true; c.Left = Convert.ToInt32( o ); } o = RestoreValue( storage, prefix + @".Top" ); if ( o != null ) { hasAnythingRestored = true; c.Top = Convert.ToInt32( o ); } } o = RestoreValue( storage, prefix + @".Width" ); if ( o != null ) { hasAnythingRestored = true; c.Width = Convert.ToInt32( o ); } o = RestoreValue( storage, prefix + @".Height" ); if ( o != null ) { hasAnythingRestored = true; c.Height = Convert.ToInt32( o ); } o = RestoreValue( storage, prefix + @".WindowState" ); if ( o != null ) { hasAnythingRestored = true; FormWindowState state = (FormWindowState)Convert.ToInt32( o ); // Don't allow to start minimized. if ( state != c.WindowState && state != FormWindowState.Minimized ) { if ( c.StartPosition != FormStartPosition.Manual ) { c.StartPosition = FormStartPosition.Manual; } c.WindowState = state; } if ( state == FormWindowState.Minimized ) { c.WindowState = FormWindowState.Maximized; } } // -- // 2007-01-28: Zoom if desired. if ( !hasAnythingRestored && info != null && info.SuggestZoomPercent > 0 ) { double zoom = (double)info.SuggestZoomPercent / 100.0; Size screenSize = SystemInformation.WorkingArea.Size; Size windowSize = c.Size; int width; int height; if ( (double)screenSize.Width / (double)windowSize.Width < (double)screenSize.Height / (double)windowSize.Height ) { // Scale in X. width = (int)((double)screenSize.Width * zoom); double fac = (double)width / (double)c.Width; height = (int)(fac * (double)c.Height); } else { // Scale in Y. height = (int)((double)screenSize.Height * zoom); double fac = (double)height / (double)c.Height; width = (int)(fac * (double)c.Width); } // Only apply if getting larger. if ( width > c.Width && height > c.Height ) { c.Width = width; c.Height = height; } } // -- // If child, center to parent. if ( centerParent ) { c.StartPosition = FormStartPosition.CenterParent; } }
/// <summary> /// The opposite to "SerializeValue". /// </summary> /// <param name="storage">The storage.</param> /// <param name="name">The name.</param> /// <returns>Returns NULL if not found.</returns> public static object DeserializeValue( IPersistentPairStorage storage, string name ) { object o = RestoreValue( storage, name ); if ( o == null || !(o is string) ) { return null; } else { return StringHelper.DeserializeFromString( o.ToString() ); } }
private void saveState( IPersistentPairStorage storage) { using (new SilentProjectStoreGuard(_project)) { PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.destinationFilePathTextEdit.Text", destinationFileTextEdit.Text); DevExpressExtensionMethods.PersistSettingsByName( fileGroupsListBox, storage, @"sendFileToTranslator.fileGroupsListBox"); DevExpressExtensionMethods.PersistSettingsByName( languagesToExportCheckListBox, storage, @"sendFileToTranslator.languagesToExportCheckListBox"); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.referenceLanguageComboBoxEdit.SelectedIndex", referenceLanguageGroupBox.SelectedIndex); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.openFileAfterGeneratingCheckEdit.Checked", openFileAfterGeneratingCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.openAfterGeneratingCheckEdit.Checked", openFolderAfterGeneratingCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.eliminateDuplicateRowsCheckEdit.Checked", eliminateDuplicateRowsCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.exportWithoutDestinationTranslationOnlyCheckEdit.Checked", exportWithoutDestinationTranslationOnlyCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.exportCompletelyEmptyRowsCheckEdit.Checked", exportCompletelyEmptyRowsCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.exportGroupsAsOneWorkSheetCheckEdit.Checked", exportGroupsAsOneWorkSheetCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.exportNameColumnCheckEdit.Checked", exportNameColumnCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.exportCommentColumnCheckEdit.Checked", exportCommentColumnCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.exportReferenceLanguageColumnCheckEdit.Checked", exportReferenceLanguageColumnCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.exportFileGroupColumnCheckEdit.Checked", exportFileGroupColumnCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.exportGroupsAsWorkSheetsCheckEdit.Checked", exportGroupsAsWorkSheetsCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.exportGroupsAsExcelFilesCheckEdit.Checked", exportGroupsAsExcelFilesCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.exportEachLanguageIntoSeparateExcelFileCheckEdit.Checked", exportEachLanguageIntoSeparateExcelFileCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.useCrypticExcelExportSheetNamesCheckEdit.Checked", useCrypticExcelExportSheetNamesCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.sendFilesToEMailReceivers2CheckEdit.Checked", sendFilesToEMailReceiversCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.zulReceiversTextEdit.Text", zulReceiversTextEdit.Text); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.zulSubjectTextEdit.Text", zulSubjectTextEdit.Text); PersistanceHelper.SaveValue( storage, @"sendFileToTranslator.zulBodyTextEdit.Text", zulBodyTextEdit.Text); } }
private void saveState( IPersistentPairStorage storage) { using (new SilentProjectStoreGuard(_project)) { PersistanceHelper.SaveValue( storage, @"sendProjectWizardForm.exportProjectFileCheckEdit.Checked", exportProjectFileCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendProjectWizardForm.exportResourceFilesCheckEdit.Checked", exportResourceFilesCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendProjectWizardForm.exportLocalSettingsCheckEdit.Checked", exportLocalSettingsCheckEdit.Checked); PersistanceHelper.SaveValue( storage, @"sendProjectWizardForm.zulReceiversTextEdit.Text", zulReceiversTextEdit.Text); PersistanceHelper.SaveValue( storage, @"sendProjectWizardForm.zulSubjectTextEdit.Text", zulSubjectTextEdit.Text); PersistanceHelper.SaveValue( storage, @"sendProjectWizardForm.zulBodyTextEdit.Text", zulBodyTextEdit.Text); } }
/// <summary> /// Saves the state of a form. /// </summary> /// <param name="storage">The storage.</param> /// <param name="c">The c.</param> private static void SaveState( IPersistentPairStorage storage, Form c ) { string prefix = c.Name; SaveValue( storage, prefix + @".Left", c.Left ); SaveValue( storage, prefix + @".Top", c.Top ); SaveValue( storage, prefix + @".Width", c.Width ); SaveValue( storage, prefix + @".Height", c.Height ); SaveValue( storage, prefix + @".WindowState", Convert.ToInt32( c.WindowState ) ); }
/// <summary> /// Persist a name-value pair inside the registry. /// Does this on a per-user-basis. /// </summary> /// <param name="storage">The storage.</param> /// <param name="name">The name.</param> /// <param name="val">The val.</param> public static void SaveValue( IPersistentPairStorage storage, string name, object val ) { storage.PersistValue( name, val ); }
private void saveState( IPersistentPairStorage storage) { PersistanceHelper.SaveValue( storage, @"autoTranslateForm.prefixTextBox.Text", prefixTextBox.Text); PersistanceHelper.SaveValue( storage, @"autoTranslateForm.prefixCheckBox.Checked", prefixCheckBox.Checked); PersistanceHelper.SaveValue( storage, @"autoTranslateForm.referenceLanguageComboBoxEdit.SelectedIndex", referenceLanguageGroupBox.SelectedIndex); DevExpressExtensionMethods.PersistSettings( languagesToTranslateCheckListBox, storage, @"autoTranslateForm.languagesToTranslateCheckListBox"); }
// ------------------------------------------------------------------ #endregion #region Private overrides. // ------------------------------------------------------------------ /// <summary> /// Called when [persisting sort state]. /// </summary> /// <param name="storage">The storage.</param> protected virtual void OnPersistingSortState( IPersistentPairStorage storage ) { if ( !insidePersisting ) { insidePersisting = true; try { PersistingSortStateEventArgs args = new PersistingSortStateEventArgs(); if ( storage != null ) { args.Storage = storage; } if ( PersistingSortState != null ) { PersistingSortState( this, args ); } FormHelper.SaveState( args.Storage, this ); FormHelper.SaveValue( args.Storage, string.Format( @"SortingListViewControl.{0}.LastSortColumnIndex", this.Name ), lastSortColumnIndex ); FormHelper.SaveValue( args.Storage, string.Format( @"SortingListViewControl.{0}.SortAscending", this.Name ), sortAscending ); } finally { insidePersisting = false; } } }
private static void saveState( IPersistentPairStorage storage, SplitContainerControl c) { int realDistance; double percentageDistance; if (c.Horizontal) { if (c.FixedPanel == SplitFixedPanel.Panel1 || c.FixedPanel == SplitFixedPanel.None) { realDistance = c.SplitterPosition; } else { if (c.FixedPanel != SplitFixedPanel.Panel2) { throw new Exception(@"FixedPanel must be Panel2."); } realDistance = c.Width - c.SplitterPosition; } percentageDistance = (double)c.SplitterPosition / c.Width * 100.0; } else { if (c.FixedPanel == SplitFixedPanel.Panel1 || c.FixedPanel == SplitFixedPanel.None) { realDistance = c.SplitterPosition; } else { if (c.FixedPanel != SplitFixedPanel.Panel2) { throw new Exception(@"FixedPanel must be Panel2."); } realDistance = c.Height - c.SplitterPosition; } percentageDistance = (double)c.SplitterPosition / c.Height * 100.0; } // -- var prefix = c.Name; if (c.SplitterPosition > 0) { PersistanceHelper.SaveValue(storage, prefix + @".SplitterPosition", c.SplitterPosition); } if (realDistance > 0) { PersistanceHelper.SaveValue(storage, prefix + @".RealSplitterPosition", realDistance); } if (percentageDistance > 0) { PersistanceHelper.SaveValue(storage, prefix + @".PercentageSplitterPosition", percentageDistance.ToString(CultureInfo.InvariantCulture)); } PersistanceHelper.SaveValue( storage, prefix + @".PanelVisibility", c.PanelVisibility.ToString()); }
private static void restoreState( IPersistentPairStorage storage, SplitContainerControl c) { var prefix = c.Name; var o1 = PersistanceHelper.RestoreValue(storage, prefix + @".SplitterPosition"); var o2 = PersistanceHelper.RestoreValue(storage, prefix + @".RealSplitterPosition"); //var o3 = PersistanceHelper.RestoreValue(storage, prefix + @".PercentageSplitterPosition"); var o4 = PersistanceHelper.RestoreValue(storage, prefix + @".PanelVisibility"); if (o4 != null) { var s4 = ConvertHelper.ToString( o4, SplitPanelVisibility.Both.ToString()); c.PanelVisibility = (SplitPanelVisibility) Enum.Parse(typeof(SplitPanelVisibility), s4, true); } /*if (o3 != null) * { * // New method, saving and restoring the percentage. * // See http://bytes.com/forum/thread616388.html. * * var percentageDistance = ConvertHelper.ToDouble(o3, CultureInfo.InvariantCulture); * * if (c.Horizontal) * { * var realDistance = (int) (c.Width*(percentageDistance/100.0)); * if (realDistance > 0) * { * c.SplitterPosition = realDistance; * } * } * else * { * var realDistance = (int) (c.Height*(percentageDistance/100.0)); * if (realDistance > 0) * { * c.SplitterPosition = realDistance; * } * } * } * else*/ if (o1 != null && o2 != null) { var realDistance = Convert.ToInt32(o2); if (c.Horizontal) { if (c.FixedPanel == SplitFixedPanel.Panel1 || c.FixedPanel == SplitFixedPanel.None) { if (realDistance > 0) { c.SplitterPosition = realDistance; } } else { if (c.FixedPanel != SplitFixedPanel.Panel2) { throw new Exception(@"FixedPanel must be Panel2."); } if (c.Width - realDistance > 0) { c.SplitterPosition = c.Width - realDistance; } } } else { if (c.FixedPanel == SplitFixedPanel.Panel1 || c.FixedPanel == SplitFixedPanel.None) { if (realDistance > 0) { c.SplitterPosition = realDistance; } } else { if (c.FixedPanel != SplitFixedPanel.Panel2) { throw new Exception(@"You must set one panel inside a splitter to be fixed."); } if (c.Height - realDistance > 0) { c.SplitterPosition = c.Height - realDistance; } } } } }