public MainWindowViewModel(PecaStarterModel model) { m_model = model; MainPanelViewModel = new MainPanelViewModel(model); MainPanelViewModel.SettingsViewModel.PropertyChanged += (sender, e) => { if (e.PropertyName == "HasNotifyIcon") OnPropertyChanged("HasNotifyIcon"); }; }
public MainPanelViewModel(PecaStarterModel model) { // Models m_model = model.BroadcastModel; // タブ情報の初期化 RelayListViewModel = new RelayListViewModel(model.BroadcastModel, model.YellowPagesList); m_channelViewModel = new ChannelViewModel(model.YellowPagesList, model.Configuration); SettingsViewModel = new SettingsViewModel(model.Configuration); PluginSettingsViewModel = new PluginSettingsViewModel(model.Plugins); BroadcastControlViewModel = new BroadcastControlViewModel(this, model.BroadcastModel, model.Configuration); InitializeEvents(); }
public App() { DispatcherSynchronizationContext.SetSynchronizationContext( new DispatcherSynchronizationContext()); _model = new PecaStarterModel(Title, new ExternalResource(ApplicationName, ApplicationPath)); _viewModel = new MainWindowViewModel(_model); Resources.Add("DataContext", _viewModel); DispatcherUnhandledException += (sender, dispatcherUnhandledExceptionEventArgs) => { Save(_viewModel, _model); if (MessageBox.Show( "未解決のエラーが発生しました。(" + dispatcherUnhandledExceptionEventArgs.Exception.Message + ")プログラムを終了します。", "PecaStarter", MessageBoxButton.OKCancel, MessageBoxImage.Error) != MessageBoxResult.OK) { dispatcherUnhandledExceptionEventArgs.Handled = true; } }; }
private void Save(MainWindowViewModel viewModel, PecaStarterModel model) { viewModel.UpdateModel(); model.Save(); }