메인 뷰모델
Inheritance: ViewModelBase
Ejemplo n.º 1
0
		public StartPage()
		{
			this.InitializeComponent();
			this.navigationHelper = new NavigationHelper(this);
			this.navigationHelper.LoadState += navigationHelper_LoadState;
			this.navigationHelper.SaveState += navigationHelper_SaveState;

			if (_viewModel == null)
				_viewModel = DataContext as MainViewModel;


			// 메신저 연결.
			Messenger.Default.Register<GenericMessage<LbMessage>>(this, message =>
			{
				var frame = (Frame)Window.Current.Content;
				if (!(frame.Content is StartPage))
					return;
				switch (message.Content.MessageType)
				{
					case LbMessageType.EVT_SHOW_STARTING:
						{
							Debug.WriteLine("* StartPage Received Message: " + message.Content.MessageType.ToString());
							if (!(((Frame)Window.Current.Content).Content is ShowPage))
							{
								this.Frame.Navigate(typeof(ShowPage), message.Content.Data);
							}
						}
						break;
				}
			});
		}
Ejemplo n.º 2
0
        public ShowPage()
        {
            this.InitializeComponent();
            this.navigationHelper = new NavigationHelper(this);
            this.navigationHelper.LoadState += navigationHelper_LoadState;
            this.navigationHelper.SaveState += navigationHelper_SaveState;

            if (_vm == null)
                _vm = DataContext as MainViewModel;

            // 메신저 등록
            Messenger.Default.Register<GenericMessage<LbMessage>>(this, message =>
            {
                // Debug.WriteLine("* ShowPage.xaml.cs Received Message: " + message.Content.MessageType.ToString());
                switch (message.Content.MessageType)
                {
                    case LbMessageType.EVT_PAGE_READY:
                        loadFrame(_vm.CurrentPage.View);
                        break;
                    case LbMessageType.EVT_TICK:
                        // 팁을 보이고 있다면 판단하여 숨긴다.
                        if (GridTipBanner.Visibility == Visibility.Visible && !_vm.IsPreview && _counterForTipShowing > 0)
                        {
                            --_counterForTipShowing;
                            if (_counterForTipShowing <= 0)
                            {
                                _counterForTipShowing = 0;
                                GridTipBanner.Visibility = Visibility.Collapsed;
                            }
                        }
                        break;
                }
            });
        }
Ejemplo n.º 3
0
		public CreatePage()
		{
			this.InitializeComponent();

			var model = DataContext as MainViewModel;
			if (model != null)
				_viewModel = model;

			//var viewSource = new CollectionViewSource { Source = _viewModel.ActiveBoard.Board.Pages };
			//ListViewPages.ItemsSource = viewSource.View;

			// 메신저 연결.
			Messenger.Default.Register<GenericMessage<LbMessage>>(this, message =>
			{
				var frame = (Frame)Window.Current.Content;
				if (!(frame.Content is CreatePage))
					return;
				switch (message.Content.MessageType)
				{
					case LbMessageType.EVT_SHOW_STARTING:
						{
							Debug.WriteLine("* CreatePage Received Message: " + message.Content.MessageType.ToString());
							if (!(((Frame)Window.Current.Content).Content is ShowPage))
							{
								this.Frame.Navigate(typeof(ShowPage), message.Content.Data);
							}
						}
						break;
					case LbMessageType.EVT_PAGE_CREATING:
						if (BorderTemplateSelection.Visibility == Visibility.Visible)
							ToggleButtonAddPage.IsChecked = false;
						break;
					case LbMessageType.EVT_PAGE_STARTED:
						if (!PreviewLock)
						{
							lockPreview();
						}
						else
						{
							// TODO: 사용자에게 preview중인걸 알리기.
						}
						break;
					case LbMessageType.ERROR:
						{
							if (message.Content.Data is LbError && (LbError)message.Content.Data == LbError.NothingToPlay)
							{
								new MessageDialog(_loader.GetString("ErrorNothingToPlay")).ShowAsync();
							}
						}
						break;
				}

			});
		}
		public RecentOpenedPage()
		{
			this.InitializeComponent();

			if (_viewModel == null)
				_viewModel = DataContext as MainViewModel;

			// Setup the navigation helper
			this.navigationHelper = new NavigationHelper(this);
			this.navigationHelper.LoadState += navigationHelper_LoadState;
			this.navigationHelper.SaveState += navigationHelper_SaveState;

			// Setup the logical page navigation components that allow
			// the page to only show one pane at a time.
			this.navigationHelper.GoBackCommand = new RelayCommand(() => this.GoBack(), () => this.CanGoBack());
			this.itemListView.SelectionChanged += itemListView_SelectionChanged;

			// Start listening for Window size changes 
			// to change from showing two panes to showing a single pane
			Window.Current.SizeChanged += Window_SizeChanged;
			this.InvalidateVisualState();


			// 메신저 연결.
			Messenger.Default.Register<GenericMessage<LbMessage>>(this, message =>
			{
				var frame = (Frame)Window.Current.Content;
				if (!(frame.Content is RecentOpenedPage))
					return;
				switch (message.Content.MessageType)
				{
					case LbMessageType.EVT_SHOW_STARTING:
						{
							Debug.WriteLine("* RecentOpenedPage Received Message: " + message.Content.MessageType.ToString());
							if (!(((Frame)Window.Current.Content).Content is ShowPage))
							{
								this.Frame.Navigate(typeof(ShowPage), message.Content.Data);
							}
						}
						break;
					case LbMessageType.ERROR:
						{
							if (message.Content.Data is LbError && (LbError)message.Content.Data == LbError.NothingToPlay)
							{
								new MessageDialog(_loader.GetString("ErrorNothingToPlay")).ShowAsync();
							}
						}
						break;
					case LbMessageType.EVT_PAGE_STARTED:
						break;
				}
			});

		}
Ejemplo n.º 5
0
		/// <summary>
		/// Populates the page with content passed during navigation.  Any saved state is also
		/// provided when recreating a page from a prior session.
		/// </summary>
		/// <param name="navigationParameter">The parameter value passed to
		/// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
		/// </param>
		/// <param name="pageState">A dictionary of state preserved by this page during an earlier
		/// session.  This will be null the first time a page is visited.</param>
		protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
		{
			if (_viewModel == null)
				_viewModel = DataContext as MainViewModel;

			if (_viewModel == null)
				throw new InvalidOperationException("CreatePage.LoadState viewModel is null");
		}