public AddEditINoteWindow(NotePageViewModel viewModel) { InitializeComponent(); ViewModel = viewModel; NoteFrame.Navigate(new NotePage(ViewModel as NotePageViewModel)); Messenger.Default.Register(this, new Action <string>(ProcessMessage)); }
public MainWindow(MainWindowViewModel viewModel) { InitializeComponent(); ViewModel = viewModel; NoteFrame.Navigate(new NotePage(new NotePageViewModel(ViewModel.Service, (ViewModel as MainWindowViewModel).CurrentBook, (ViewModel as MainWindowViewModel).CurrentNote))); Messenger.Default.Register(this, new Action <string>(ProcessMessage)); }
// needed because the ActualWidth and ActualHeight properties dont post updates when its changed // see: https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.frameworkelement.actualwidth private void UpdateNotePopupSizeAndPosition() { InvalidateArrange(); InvalidateMeasure(); if (ActualWidth < 768) { NotePopup.HorizontalOffset = 0; NotePopup.VerticalOffset = -48;// CommandBar Height NoteFrame.Width = (ActualWidth <= 0 ? App.RootFrame.ActualWidth : ActualWidth) - NotePopup.HorizontalOffset; NoteFrame.Height = (ActualHeight <= 0 ? App.RootFrame.ActualHeight : ActualHeight) - NotePopup.VerticalOffset; NoteFrame.ClearValue(FrameworkElement.MaxHeightProperty); } else { var ttv = NoteQuickBoxContainer.TransformToVisual(Content); Point point = ttv.TransformPoint(new Point(0, 0)); NotePopup.HorizontalOffset = point.X; NotePopup.VerticalOffset = point.Y; NoteFrame.Width = (NoteQuickBoxContainer.ActualWidth <= 0 ? App.RootFrame.ActualWidth : NoteQuickBoxContainer.ActualWidth); NoteFrame.ClearValue(FrameworkElement.HeightProperty); ttv = NoteQuickBoxContainer.TransformToVisual(ContentRoot); point = ttv.TransformPoint(new Point(0, 0)); NoteFrame.MaxHeight = Math.Max(0, ContentRoot.ActualHeight - NotePopup.VerticalOffset - point.Y); } }
private void HidePopupAnimation_Completed(object sender, object e) { while (NoteFrame.CanGoBack) { NoteFrame.GoBack(); } NoteFrame.BackStack.Clear(); NotePopup.IsOpen = false; }
public void ProcessMessage(string message) { if (message.Equals("CreateNote")) { new AddEditINoteWindow( new NotePageViewModel( ViewModel.Service, (ViewModel as MainWindowViewModel).CurrentBook)) .ShowDialog(); } else if (message.Equals("EditNote")) { new AddEditINoteWindow( new NotePageViewModel( ViewModel.Service, (ViewModel as MainWindowViewModel).CurrentBook, (ViewModel as MainWindowViewModel).CurrentNote) ).Show(); } else if (message.Equals("EditCategory")) { new AddEditBookElement( new AddEditBookElementViewModel( ViewModel.Service, (ViewModel as MainWindowViewModel).SelectedCategory )).ShowDialog(); } else if (message.Equals("CreateCategory")) { new AddEditBookElement(new AddEditBookElementViewModel(ViewModel.Service, new Category(String.Empty))).ShowDialog(); } else if (message.Equals("EditBook")) { new AddEditBookElement( new AddEditBookElementViewModel( ViewModel.Service, (ViewModel as MainWindowViewModel).CurrentBook )).ShowDialog(); } else if (message.Equals("CreateBook")) { new AddEditBookElement(new AddEditBookElementViewModel(ViewModel.Service, new Book(String.Empty))).ShowDialog(); } else if (message.Equals("AboutPage")) { MessageBox.Show("Hello! \n I am Ruslan Humeniuk.\n I am KPI student and this is my first WPF project"); } else if (message.Equals("UpdateMain")) { this.InitializeComponent(); } else if (message.Equals("UpdateNoteFrame")) { NoteFrame.Navigate(new NotePage(new NotePageViewModel(ViewModel.Service, (ViewModel as MainWindowViewModel).CurrentBook, (ViewModel as MainWindowViewModel).CurrentNote))); } }
public void OpenNote(object parameter) { UpdateNotePopupSizeAndPosition(); NoteOpening?.Invoke(this, EventArgs.Empty); ShowPopupAnimation.Begin(); while (NoteFrame.CanGoBack) { NoteFrame.GoBack(); } NoteFrame.BackStack.Clear(); NoteFrame.Navigate(typeof(NoteEditPage), parameter); NotePopup.IsOpen = true; NoteOpened?.Invoke(this, new GenericEventArgs(parameter)); }