public static MainWindowState Load() { MainWindowState state = null; FileStream fs = null; String fileName = "window-state.xml"; if (File.Exists(fileName)) { try { XmlSerializer ser = new XmlSerializer(typeof(MainWindowState)); fs = new FileStream(fileName, FileMode.Open); state = (MainWindowState)ser.Deserialize(fs); } catch (Exception) { } finally { if (fs != null) { fs.Close(); } } } if (state != null) { return(state); } state = new MainWindowState(); return(state); }
public MainWindow() { InitializeComponent(); state = MainWindowState.Load(); this.DataContext = state; drawer = new SineDrawer(SineCanvas, state); SineCanvas.MouseDown += SineCanvas_MouseDown; }
public SineDrawer(Canvas canvas, MainWindowState state) { this.canvas = canvas; this.state = state; }