private void SaveSettings(bool isCloseApp) { ApplicationSettings settings = new ApplicationSettings(this.Location); settings.HOffset = krbTabControl1.TabHOffset; settings.SelectedTabPageName = krbTabControl1.SelectedTab != null ? krbTabControl1.SelectedTab.Name : null; settings.IsStretchToParent = krbTabControl1.HeaderVisibility; settings.FirstTabItemColor = krbTabControl1.TabGradient.ColorStart; settings.SecondTabItemColor = krbTabControl1.TabGradient.ColorEnd; settings.SelectedTabItemTextColor = krbTabControl1.TabGradient.TabPageSelectedTextColor; settings.Red = krbTabControl1.CaptionRandomizer.Red; settings.Green = krbTabControl1.CaptionRandomizer.Green; settings.Blue = krbTabControl1.CaptionRandomizer.Blue; settings.Alpha = krbTabControl1.CaptionRandomizer.Transparency; settings.IsDrawHeader = krbTabControl1.IsDrawHeader; settings.IsDrawEdgeBorder = krbTabControl1.IsDrawEdgeBorder; settings.IsCaptionVisible = krbTabControl1.IsCaptionVisible; settings.IsRandomizerEnabled = krbTabControl1.CaptionRandomizer.IsRandomizerEnabled; settings.IsDrawTabSeparator = krbTabControl1.IsDrawTabSeparator; settings.BorderStyles = krbTabControl1.BorderStyle; settings.HeaderStyles = krbTabControl1.HeaderStyle; settings.TabPageStyles = krbTabControl1.TabStyles; settings.TabAlingments = krbTabControl1.Alignments; DataSaver.SaveData(settings); if (isCloseApp) Application.Exit(); }
public static void SaveData(ApplicationSettings settings) { DataSaverAttribute attribute = GetAttribute(); if (attribute != null && settings != null) { try { string fileName = null; switch (attribute.TypeSerializer) { case SerializerType.Binary: fileName = String.Format("{0}.{1}", attribute.FileName, "dat"); using (Stream writeStream = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { IFormatter serializer = new BinaryFormatter(); serializer.Serialize(writeStream, settings); } break; default: fileName = String.Format("{0}.{1}", attribute.FileName, "xml"); using (Stream writeStream = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { XmlSerializer serializer = new XmlSerializer(typeof(ApplicationSettings)); serializer.Serialize(writeStream, settings); } break; } MessageBox.Show("The data saving operation is successfully completed."); } catch { MessageBox.Show("Failure: The data saving operation is not completed."); } } else { MessageBox.Show("Failure: The data saving option is not implemented."); } }