view MetroWpf/MetroWpf/Presentation/Menu/MenuViewModel.cs @ 17:7721a1270363

New files added during dev
author stevenh7776 stevenhollidge@hotmail.com
date Wed, 14 Mar 2012 01:23:57 +0700
parents
children 6109bc268b90
line wrap: on
line source

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Messaging;
using MetroWpf.Messages;

namespace MetroWpf.Presentation.Menu
{
  public class MenuViewModel : ViewModelBase
  {
    private Screen selectedTabIndex;
    public Screen SelectedTabIndex
    {
      get { return selectedTabIndex; }
      set
      {
        if (selectedTabIndex == value)
          return;

        selectedTabIndex = value;
        RaisePropertyChanged("SelectedTabIndex");
      }
    }

    private bool showStocks;
    public bool ShowStocks
    {
      get { return showStocks; }
      set
      {
        if (showStocks == value)
          return;

        showStocks = value;
        RaisePropertyChanged("ShowStocks");
      }
    }

    private bool showFxRates;
    public bool ShowFxRates
    {
      get { return showFxRates; }
      set
      {
        if (showFxRates == value)
          return;

        showFxRates = value;
        RaisePropertyChanged("ShowFxRates");
      }
    }

    private bool showLogin;
    public bool ShowLogin
    {
      get { return showLogin; }
      set
      {
        if (showLogin == value)
          return;

        showLogin = value;
        RaisePropertyChanged("ShowLogin");
      }
    }

    private bool showUserProfile;
    public bool ShowUserProfile
    {
      get { return showUserProfile; }
      set
      {
        if (showUserProfile == value)
          return;

        showUserProfile = value;
        RaisePropertyChanged("ShowUserProfile");
      }
    }

    private bool showSettings;
    public bool ShowSettings
    {
      get { return showSettings; }
      set
      {
        if (showSettings == value)
          return;

        showSettings = value;
        RaisePropertyChanged("ShowSettings");
      }
    }

    private bool showAbout;
    public bool ShowAbout
    {
      get { return showAbout; }
      set
      {
        if (showAbout == value)
          return;

        showAbout = value;
        RaisePropertyChanged("ShowAbout");
      }
    }

    private bool showHelp;
    public bool ShowHelp
    {
      get { return showHelp; }
      set
      {
        if (showHelp == value)
          return;

        showHelp = value;
        RaisePropertyChanged("ShowHelp");
      }
    }

    public MenuViewModel()
    {
      Init();
    }

    private void Init()
    {
      Messenger.Default.Register<NavigationMessage>(
        this,
        message => ChangeDisplayScreen(message.DisplayScreen));

      ChangeDisplayScreen(Screen.Login);
    }

    private void ChangeDisplayScreen(Screen screen)
    {
      switch (screen)
      {
        case Screen.Login:
          ShowStocks = false;
          ShowFxRates = false;
          ShowLogin = true;
          ShowUserProfile = false;
          ShowSettings = false;
          ShowAbout = false;
          ShowHelp = false;
          break;
        case Screen.UserProfile:
          ShowLogin = false;
          ShowUserProfile = true;
          ShowSettings = false;
          ShowAbout = false;
          ShowHelp = false;
          break;
        case Screen.Settings:
          ShowLogin = false;
          ShowUserProfile = false;
          ShowSettings = true;
          ShowAbout = false;
          ShowHelp = false;
          break;
        case Screen.About:
          ShowLogin = false;
          ShowUserProfile = false;
          ShowSettings = false;
          ShowAbout = true;
          ShowHelp = false;
          break;
        case Screen.Help:
          ShowLogin = false;
          ShowUserProfile = false;
          ShowSettings = false;
          ShowAbout = false;
          ShowHelp = true;
          break;
      }

      SelectedTabIndex = screen;
    }
  }
}