public static ProgramSetting Load(string path) { FileInfo fileInfo = new FileInfo(path); ProgramSetting setting = new ProgramSetting(); if (!fileInfo.Exists) { setting.Save(); } else { Dictionary <string, object> loaded; using (FileStream fs = fileInfo.Open(FileMode.Open)) { BinaryFormatter formatter = new BinaryFormatter(); loaded = formatter.Deserialize(fs) as Dictionary <string, object>; } foreach (KeyValuePair <string, object> pair in loaded) { if (setting.mSettingDict.Keys.Contains(pair.Key)) { setting.mSettingDict[pair.Key] = pair.Value; } else { setting.mSettingDict.Add(pair.Key, pair.Value); } } } return(setting); }
public WorkWindow(EventClient client, ProgramSetting setting) { InitializeComponent(); if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) { return; } Setting = setting; Client = client; mControls = new UserControl[] { AttByClass, AttByDay, InqAbsentees, InqIndividual, InqOver, StuList, Accounts, AcceptedAccounts, InqAll }; ChildManager = new ChildWindowManager(this); }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { mSetting = ProgramSetting.Load(); mChildManager = new ChildWindowManager(this); if ((bool)mSetting["RememberID"]) { SaveIDCheck.IsChecked = true; IDText.Text = (mSetting["ID"] as string) ?? ""; } mChildManager.TryToShow <LoadingWindow>(new EventHandler((o, ev) => { this.Dispatcher.Invoke(() => { SetState(); }); }), "서버에 연결 중입니다...", (WaitCallback)Connect); } catch (Exception ex) { MessageBox.Show($"로그인 준비를 하는 과정에서 오류가 발생하였습니다.\n{ex.Message}"); } }