private void Button_Click_1(object sender, RoutedEventArgs e) { CommonLightBox dialog = new CommonLightBox(); AppearListViewControl chWindow = new AppearListViewControl(); dialog.Owner = Application.Current.MainWindow; dialog.BindUIElement(chWindow); var appearList = GetAppearList(); var listViewModel = new AppearListViewModel() { DataList = appearList, DisplayOrNoDisplayHeader = "表示する/しない", }; chWindow.DataContext = listViewModel; ShowDialogManager.ShowDialog(dialog); foreach (var item in listViewModel.DataList) { var data = item.ParentObject as TimelineAxis; data.IsDisplayed = item.IsAppeared; } _timelineViewModel.Initialize(); }
/// <summary> /// 引き継いで新規作成 /// </summary> /// <param name="iEditor">テキストを取得するためのIEditorインターフェース</param> /// <returns>正否だけどとりあえずtrueしか返さない</returns> public bool CreateNewPlus(IEditor iEditor) { NewFilePlusControl control = new NewFilePlusControl(); control.Owner = Application.Current.MainWindow; var newFilePlusViewModel = NewFilePlusGenerator.GetNewFilePlusViewModel(); control.DataContext = newFilePlusViewModel; //ダイアログを表示する if (ShowDialogManager.ShowDialog(control) == true) { var transferData = NewFilePlusGenerator.GetTransferData(newFilePlusViewModel); ModelsComposite.CreateNew(iEditor); CurrentFile = ""; // Transferの過程でイベントが発生しても怒られないように、一旦Newの状態を各画面に通知する EventAggregator.OnDataReloaded(this, new DataReloadedEventArgs()); // 引き継ぎ NewFilePlusTransferer.Transfer(transferData); // もっかい画面に通知 EventAggregator.OnDataReloaded(this, new DataReloadedEventArgs()); return(true); } return(true); }
public void ExecuteOnAdd(ObservableCollection <AppearListViewItemModel> dataList) { CommonLightBox dialog = new CommonLightBox(); TagsSelectorView selectorView = new TagsSelectorView(); var tagSelectorViewModel = new TagSelectorViewModel(); SetSelectingTags(tagSelectorViewModel.SelectingTags); selectorView.SetModel(tagSelectorViewModel); dialog.Owner = Application.Current.MainWindow; dialog.BindUIElement(selectorView); dialog.LightBoxKind = CommonLightBox.CommonLightBoxKind.SaveCancel; dialog.IsStretchable = false; selectorView.Height = Application.Current.MainWindow.ActualHeight - 80; selectorView.Width = Application.Current.MainWindow.ActualWidth - 80; selectorView.DataContext = tagSelectorViewModel; if (ShowDialogManager.ShowDialog(dialog) == true) { tagSelectorViewModel.UpdateModelsComposite(); _stickable.SetTagIds(GetSelectingTagIds(tagSelectorViewModel.SelectingTags)); dataList.Clear(); var list = TagToAppearListViewModelConverter.ToAppearListViewItemModel(_stickable.GetTagIds(), _tagManager); foreach (var newItemModel in list) { dataList.Add(newItemModel); } } }
/// <summary> /// ファイル名を指定してファイルを保存する /// </summary> /// <param name="toFile"></param> /// <returns></returns> public bool SaveFile(string toFile) { SaveManager manager = new SaveManager(); if (manager.Save(toFile) == SaveResult.Succeed) { CurrentFile = toFile; Properties.Settings.Default.SavedFolderPath = Path.GetDirectoryName(CurrentFile); Properties.Settings.Default.LastSavedFilePath = CurrentFile; FileBoxModelManager.AddRecentlySavedFile(CurrentFile); Properties.Settings.Default.Save(); EventAggregator.OnSaved(this, new SaveEventArgs()); return(true); } else { ShowDialogManager.ShowMessageBox("保存に失敗しました。保存先を変えるなどして再チャレンジしてみてください", "エラー", MessageBoxButton.OK, MessageBoxImage.Warning); } return(false); }
public void ShowTimelineAxisEvents(TimelineAxis axis) { EventModelManager manager = _eventModelManager; var list = manager.GetEventModel(axis.Id); var eventListViewerViewModel = new EventViewerViewModel() { DataList = new List <EventViewerItemViewModel>() }; foreach (var item in list) { eventListViewerViewModel.DataList.Add(new EventViewerItemViewModel() { StartDateTime = item.StartDateTime, EndDateTime = item.EndDateTime, Name = item.Title, }); } CommonLightBox lightBox = new CommonLightBox(); EventListViewer viewer = new EventListViewer(); viewer.DataContext = eventListViewerViewModel; lightBox.LightBoxKind = CommonLightBox.CommonLightBoxKind.CancelOnly; lightBox.BindUIElement(viewer); lightBox.Owner = Application.Current.MainWindow; if (ShowDialogManager.ShowDialog(lightBox) == true) { StartDateTime = viewer.JumpDateTime; } }
/// <summary> /// パスを指定してファイルを開く /// </summary> /// <param name="editor">テキストを展開するためのIEditorインターフェース</param> /// <param name="filePath">ファイルを開くパス</param> /// <returns>正否</returns> public bool OpenFile(IEditor editor, String filePath) { LoadManager manager = new LoadManager(editor); if (manager.Load(filePath) == LoadResult.Succeed) { CurrentFile = filePath; string lastSavedFilePath = Properties.Settings.Default.LastSavedFilePath; if (lastSavedFilePath != "Default") { Properties.Settings.Default.SavedFolderPath = Path.GetDirectoryName(CurrentFile); Properties.Settings.Default.LastSavedFilePath = CurrentFile; Properties.Settings.Default.Save(); } } else { ShowDialogManager.ShowMessageBox("ファイルを開けませんでした。", "エラー", MessageBoxButton.OK, MessageBoxImage.Error); } EventAggregator.OnDataReloaded(this, new DataReloadedEventArgs()); return(true); }
private AskSaveResult AskSaving() { MessageBoxResult res = ShowDialogManager.ShowMessageBox("そのまえに、データを保存しますか?(「いいえ」を押すと変更内容は破棄されます)", "確認", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); if (res == MessageBoxResult.Cancel) { return(AskSaveResult.Cancel); } if (res == MessageBoxResult.No) { return(AskSaveResult.CanProcess); } // 一旦フォーカスを外します。 var prevFocus = FocusManager.GetFocusedElement(_view); FocusManager.SetFocusedElement(_view, _view); // 溜まってるイベントは全部処理させる WPFUtil.DoEvents(); _writersBattleFieldViewModel.SetTextToModelsComposite(); if (_fileService.SaveFile() == false) { return(AskSaving()); } return(AskSaveResult.CanProcess); }
public DateTime GetEndDateTime() { try { switch (_timeSpanSelect) { case TimespanEnum.Day1: return(_startDateTime.AddDays(1)); case TimespanEnum.Day2: return(_startDateTime.AddDays(2)); case TimespanEnum.Day4: return(_startDateTime.AddDays(4)); case TimespanEnum.Hour1: return(_startDateTime.AddHours(1)); case TimespanEnum.Hour3: return(_startDateTime.AddHours(3)); case TimespanEnum.Hour6: return(_startDateTime.AddHours(6)); case TimespanEnum.Hour12: return(_startDateTime.AddHours(12)); case TimespanEnum.Min15: return(_startDateTime.AddMinutes(15)); case TimespanEnum.Month1: return(_startDateTime.AddMonths(1)); case TimespanEnum.Month2: return(_startDateTime.AddMonths(2)); case TimespanEnum.Month4: return(_startDateTime.AddMonths(4)); case TimespanEnum.Month6: return(_startDateTime.AddMonths(6)); case TimespanEnum.Week1: return(_startDateTime.AddDays(7)); case TimespanEnum.Week2: return(_startDateTime.AddDays(14)); case TimespanEnum.Year1: return(_startDateTime.AddYears(1)); } return(_startDateTime.AddYears(1)); } catch (ArgumentOutOfRangeException) { ShowDialogManager.ShowMessageBox("開始日時をもっと小さな値にして下さい", "警告", MessageBoxButton.OK, MessageBoxImage.Warning); return(_startDateTime); } }
private void SateliteButton_Click(object sender, RoutedEventArgs e) { SateliteSelector sateliteSelector = new SateliteSelector(); CommonLightBox commonLightBox = new CommonLightBox(); commonLightBox.LightBoxKind = CommonLightBox.CommonLightBoxKind.CancelOnly; commonLightBox.BindUIElement(sateliteSelector); commonLightBox.Owner = Application.Current.MainWindow; ShowDialogManager.ShowDialog(commonLightBox); }
private void DeleteEventItem(EventBorderViewModel delModel) { if (delModel != null) { if (ShowDialogManager.ShowMessageBox("このイベントを削除してもいいですか?\n(選択した人物に関わらず同じイベントは全部消えます)", "確認", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { _timelineViewModel.DeleteEvent(delModel); } } }
public void ShowExistEvent(EventModel eventModel) { EventViewModel evtModel = new EventViewModel() { StartDateTime = eventModel.StartDateTime, EndDateTime = eventModel.EndDateTime, Detail = eventModel.Detail, Title = eventModel.Title, AppearListViewItems = GenerateAppearListViewItemModel(eventModel) }; CommonLightBox lightBox = new CommonLightBox(); EventRegister register = new EventRegister(); register.DataContext = evtModel; lightBox.LightBoxKind = CommonLightBox.CommonLightBoxKind.SaveCancel; lightBox.BindUIElement(register); lightBox.Owner = Application.Current.MainWindow; if (ShowDialogManager.ShowDialog(lightBox) == true) { _eventModelManager.Remove(eventModel); var participants = GetParticipants(evtModel.AppearListViewItems); // 参加者がいないイベント作っても意味ないよね if (participants.Count() == 0) { _view.OnEventChanged(_view, new Timeline.EventChangedArgs() { kind = Timeline.EventChangedKind.Delete, model = eventModel }); } else { var addEvent = new EventModel() { StartDateTime = evtModel.StartDateTime, EndDateTime = evtModel.EndDateTime, Title = evtModel.Title, Detail = evtModel.Detail, Participants = GetParticipants(evtModel.AppearListViewItems), SourceObject = eventModel.SourceObject, }; _eventModelManager.Add(addEvent); _view.OnEventChanged(_view, new Timeline.EventChangedArgs() { kind = Timeline.EventChangedKind.Modify, model = addEvent }); } Initialize(); } }
private void OpenFileEventOccured() { FilePath = _viewModel.OpenFilePath; if (!File.Exists(FilePath)) { ShowDialogManager.ShowMessageBox("ファイルが開けません。正しいファイルを指定してください。", "ファイルがありません", MessageBoxButton.OK, MessageBoxImage.Warning); return; } DialogResult = true; }
public void OnDeleteItemButtonPushedHandler(object sender, RoutedEventArgs e) { if (ShowDialogManager.ShowMessageBox("削除してもいいですか?", "確認", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { return; } var model = (AppearListViewItemModel)((sender as Control).DataContext); model.IsAppeared = false; _view.OnModelChanged(model); Initialize(); }
private void deleteButton_Click(object sender, RoutedEventArgs e) { if (_model.SelectingModel == null) { return; } if (ShowDialogManager.ShowMessageBox("ほんとうに削除してもいいですか?", "確認", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { var service = new ItemModelService(); service.RemoveItem(_model.SelectingModel); } }
private void colorbutton_Click(object sender, RoutedEventArgs e) { var userControl = new GeneralColorPicker(); CommonLightBox lightBox = new CommonLightBox(); lightBox.LightBoxKind = CommonLightBox.CommonLightBoxKind.SaveCancel; lightBox.BindUIElement(userControl); lightBox.Owner = Application.Current.MainWindow; userControl.SelectingColor = ((SolidColorBrush)_model.SelectingModel.ColorBrush).Color; if (ShowDialogManager.ShowDialog(lightBox) == true) { _model.SelectingModel.ColorBrush = new SolidColorBrush(userControl.SelectingColor); } }
/// <summary> /// ページ数を計算する /// </summary> public void CalculatePageNumber() { SetTextToModelsComposite(); CommonLightBox dialog = new CommonLightBox(); var pageLineCalcView = new PageLineCalculatorView(); var pageLineCalculatorViewModel = new PageLineCalculatorViewModel(ModelsComposite.NovelSettingModel, ModelsComposite.DocumentModel); pageLineCalcView.BindModel(pageLineCalculatorViewModel); dialog.Owner = Application.Current.MainWindow; dialog.BindUIElement(pageLineCalcView); dialog.LightBoxKind = CommonLightBox.CommonLightBoxKind.SaveOnly; ShowDialogManager.ShowDialog(dialog); }
public bool IsSavable() { if (StartDateTime >= EndDateTime) { ShowDialogManager.ShowMessageBox("終了時刻には開始時刻よりも後の時刻を設定してください。", "警告", MessageBoxButton.OK, MessageBoxImage.Warning); return(false); } if (AppearListViewItems.Count(item => item.IsAppeared == true) == 0) { var res = ShowDialogManager.ShowMessageBox("このイベントに登録されている人が一人もいません。イベントごと削除しますけどだいじょうぶですか?", "確認", MessageBoxButton.YesNo, MessageBoxImage.Question); return(res == MessageBoxResult.Yes); } return(true); }
public void ExecuteOnAdd(ObservableCollection <AppearListViewItemModel> dataList) { CommonLightBox dialog = new CommonLightBox(); AppearListViewControl chWindow = new AppearListViewControl(); dialog.Owner = Application.Current.MainWindow; dialog.BindUIElement(chWindow); var listViewModel = new AppearListViewModel() { DataList = dataList, DisplayOrNoDisplayHeader = "登場する/しない" }; chWindow.DataContext = listViewModel; ShowDialogManager.ShowDialog(dialog); }
public void ShowEventOnVacantCell(TimeBorderViewModel borderModel) { EventViewModel evtModel = new EventViewModel() { StartDateTime = borderModel.StartDateTime, EndDateTime = borderModel.EndDateTime, AppearListViewItems = GenerateAppearListViewItemModel(borderModel) }; CommonLightBox lightBox = new CommonLightBox(); EventRegister register = new EventRegister(); register.DataContext = evtModel; lightBox.LightBoxKind = CommonLightBox.CommonLightBoxKind.SaveCancel; lightBox.BindUIElement(register); lightBox.Owner = Application.Current.MainWindow; lightBox.OnSaveAndQuit += register.OnSaveAndQuit; if (ShowDialogManager.ShowDialog(lightBox) == true) { var participants = GetParticipants(evtModel.AppearListViewItems); // 参加者がいないイベント作っても意味ないよね if (participants.Count() == 0) { return; } var addEvent = new EventModel() { StartDateTime = evtModel.StartDateTime, EndDateTime = evtModel.EndDateTime, Title = evtModel.Title, Detail = evtModel.Detail, Participants = participants, }; _eventModelManager.Add(addEvent); _view.OnEventChanged(_view, new Timeline.EventChangedArgs() { kind = Timeline.EventChangedKind.Add, model = addEvent }); Initialize(); } }
public void OpenFileDialog() { OpenFileDialog ofd = new OpenFileDialog(); ofd.FileName = GetOpenFileName(); ofd.InitialDirectory = GetOpenDirectoryName(); ofd.Filter = "ArtOfWordsファイル(*.kieAow)|*.kieAow"; ofd.FilterIndex = 1; ofd.Title = "開くファイルを選択してください"; ofd.RestoreDirectory = true; //ダイアログを表示する if (ShowDialogManager.ShowDialog(ofd) == true) { OpenFilePath = ofd.FileName; } }
/// <summary> /// ファイルを開く /// </summary> /// <param name="editor">テキストを展開するためのIEditorインターフェース</param> /// <returns>正否</returns> public bool OpenFile(IEditor editor) { FileSelectorControl control = new FileSelectorControl(); control.Owner = Application.Current.MainWindow; var viewModel = new FileSelectorViewModel(control); viewModel.Initialize(NovelsCollectorGenerator.GetRecentlyNovelsCollector(), NovelsCollectorGenerator.GetSemiAutoBackupNovelsCollector(), NovelsCollectorGenerator.GetNovelsBoxCollector()); control.SetViewModel(viewModel); //ダイアログを表示する if (ShowDialogManager.ShowDialog(control) == true) { OpenFile(editor, control.FilePath); return(true); } return(false); }
/// <summary> /// 名前をつけて保存 /// </summary> /// <returns></returns> public bool SaveFileWithName() { //SaveFileDialogクラスのインスタンスを作成 SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = "新しいファイル.kieAow"; sfd.InitialDirectory = GetFolderPath(); sfd.Filter = "ArtOfWordsファイル(*.kieAow)|*.kieAow"; sfd.FilterIndex = 1; sfd.Title = "保存先のファイルを選択してください"; sfd.RestoreDirectory = true; sfd.OverwritePrompt = true; sfd.CheckPathExists = true; if (ShowDialogManager.ShowDialog(sfd) == true) { return(SaveFile(sfd.FileName)); } return(false); }
private void FontButton_Click_1(object sender, RoutedEventArgs e) { var dlg = new emanual.Wpf.Controls.FontDialogEx(); CommonLightBox lightBox = new CommonLightBox(); lightBox.LightBoxKind = CommonLightBox.CommonLightBoxKind.SaveCancel; lightBox.BindUIElement(dlg); lightBox.Owner = Application.Current.MainWindow; dlg.DlgFontFamily = Properties.Settings.Default.TextBoxFontFamily; //dlg.DlgFontWeight = FontWeights.Bold; dlg.DlgFontSize = Properties.Settings.Default.TextBoxFontSize; dlg.DlgLanguage = "ja-jp"; dlg.DlgSampleText = "ここでFontのテストが出来ます"; if (ShowDialogManager.ShowDialog(lightBox) == true) { Properties.Settings.Default.TextBoxFontSize = dlg.DlgFontSize; Properties.Settings.Default.TextBoxFontFamily = dlg.DlgFontFamily; Properties.Settings.Default.Save(); EventAggregator.OnFontSettingChanged(this, 0); } }
private void TextStyleButton_Click_1(object sender, RoutedEventArgs e) { var userControl = new TextBoxColorPicker(); CommonLightBox lightBox = new CommonLightBox(); lightBox.LightBoxKind = CommonLightBox.CommonLightBoxKind.SaveCancel; lightBox.BindUIElement(userControl); lightBox.Owner = Application.Current.MainWindow; userControl.SelectingFontFamily = Properties.Settings.Default.TextBoxFontFamily; //dlg.DlgFontWeight = FontWeights.Bold; userControl.SelectingFontSize = Properties.Settings.Default.TextBoxFontSize; userControl.SelectingFontColor = Properties.Settings.Default.TextBoxFontColor; userControl.SelectingBackgroundColor = Properties.Settings.Default.TextBoxBackgroundColor; if (ShowDialogManager.ShowDialog(lightBox) == true) { Properties.Settings.Default.TextBoxFontColor = userControl.SelectingFontColor; Properties.Settings.Default.TextBoxBackgroundColor = userControl.SelectingBackgroundColor; Properties.Settings.Default.Save(); EventAggregator.OnFontSettingChanged(this, 0); } }
private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { logger.Fatal("Error: InnerException" + e.Exception.InnerException + "\r\nTrace: " + e.Exception.StackTrace); ShowDialogManager.ShowMessageBox(e.Exception.ToString(), "エラー", MessageBoxButton.OK, MessageBoxImage.Error); }