@@ -40,24 +40,46 @@ public MainForm(int id, FormData dat = null)
4040 private void LoadData ( FormData dat = null )
4141 {
4242 //load defaults
43- this . Opacity = 0.95 ;
4443 this . StartPosition = FormStartPosition . WindowsDefaultLocation ;
4544 this . CreationTime = DateTime . Now ;
4645 if ( string . IsNullOrEmpty ( Title ) )
4746 {
4847 Title = string . Format ( "Note {0:##}" , FORM_ID ) ;
4948 }
50- if ( Program . Themes . Count > 1 )
51- {
52- Random rand = new Random ( ) ;
53- CurrentTheme = rand . Next ( Program . Themes . Count - 1 ) + 1 ;
54- }
55- if ( Program . Styles . Count > 1 )
56- {
57- CurrentStyle = 1 ;
58- }
49+
50+ // 如果是新建便签,应用上次保存的默认设置
5951 if ( dat == null )
6052 {
53+ DefaultNoteSettings defaultSettings = REGISTRY . GetDefaultSettings ( ) ;
54+ this . Opacity = defaultSettings . opacity ;
55+
56+ if ( defaultSettings . customTheme != null )
57+ {
58+ this . CustomTheme = defaultSettings . customTheme ;
59+ }
60+ if ( defaultSettings . customStyle != null )
61+ {
62+ this . CustomStyle = defaultSettings . customStyle ;
63+ }
64+
65+ if ( Program . Themes . Count > defaultSettings . theme )
66+ {
67+ CurrentTheme = defaultSettings . theme ;
68+ }
69+ else if ( Program . Themes . Count > 1 )
70+ {
71+ CurrentTheme = 1 ;
72+ }
73+
74+ if ( Program . Styles . Count > defaultSettings . style )
75+ {
76+ CurrentStyle = defaultSettings . style ;
77+ }
78+ else if ( Program . Styles . Count > 1 )
79+ {
80+ CurrentStyle = 1 ;
81+ }
82+
6183 this . Show ( ) ;
6284 return ;
6385 }
@@ -110,6 +132,7 @@ public int CurrentTheme
110132 Save ( ) ;
111133 }
112134 ReloadTheme ( ) ;
135+ SaveAsDefaultSettings ( ) ; // 保存为默认设置
113136 }
114137 }
115138
@@ -129,9 +152,22 @@ public int CurrentStyle
129152 Save ( ) ;
130153 }
131154 ReloadStyle ( ) ;
155+ SaveAsDefaultSettings ( ) ; // 保存为默认设置
132156 }
133157 }
134158
159+ // 保存当前便签的样式设置为默认设置
160+ public void SaveAsDefaultSettings ( )
161+ {
162+ DefaultNoteSettings settings = new DefaultNoteSettings ( ) ;
163+ settings . theme = this . CurrentTheme ;
164+ settings . style = this . CurrentStyle ;
165+ settings . opacity = this . Opacity ;
166+ settings . customTheme = this . CustomTheme ;
167+ settings . customStyle = this . CustomStyle ;
168+ REGISTRY . SaveDefaultSettings ( settings ) ;
169+ }
170+
135171 public void ReloadTheme ( )
136172 {
137173 Theme th = Program . Themes [ _theme ] ;
0 commit comments