Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            // Citrix / Terminal Server / Remote Desktop connections can be limited to e.g. 1024x768, so that TimeMerge's height won't fit inside.
            // If so, a restricted MaxHeight will make the scrollbars appear, so that the app remains usable (does not overlap Taskbar).
            this.MaxHeight = System.Windows.SystemParameters.WorkArea.Height;

            _mainWindowVM = new TimeMerge.ViewModel.MainViewModel();
            _mainWindowVM.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(mainWindowVM_PropertyChanged);
            this.DataContext = _mainWindowVM;

            this.Closed += new EventHandler(MainWindow_Closed);

            if (Application.Current != null)
            {
                m_AppRestarter = (Application.Current as App).GetAppRestarter();
            }

            // Set up "Minimize" button: will hide app window to system tray
            this.minimizeButton.Click += minimizeButton_Click;
            // Enable "minimize to tray" behavior for this Window
            TimeMerge.Utils.MinimizeToTray.Enable(this);

            // Set up "Close" button and also how to handle "ApplicationCommands.Close"
            this.closeButton.Command = ApplicationCommands.Close;
            this.CommandBindings.Add(new CommandBinding(
                                         ApplicationCommands.Close,
                                         (sender, e) => m_AppRestarter.ShutDown(),
                                         (sender, e) => e.CanExecute = true));

            // Set up "Refresh" button for a keyboard shortcut of 'F5'
            var refreshKeyGesture = new KeyGesture(Key.F5);
            var refreshKeyBinding = new KeyBinding(_mainWindowVM.JumpToYearMonthCommand, refreshKeyGesture);

            this.InputBindings.Add(refreshKeyBinding);

            // Set up "Minimize" button for a keyboard shortcut of 'ESC'
            var minimizeKeyGesture = new KeyGesture(Key.Escape);
            var minimizeKeyBinding = new KeyBinding(new RelayCommand((param) => { minimizeWindow(); }), minimizeKeyGesture);

            this.InputBindings.Add(minimizeKeyBinding);

            _mainWindowVM.HomeOfficeDayNotificationCommand = new RelayCommand((param) => homeOfficeStartedTrayBalloonNotification(param));
            _mainWindowVM.Init(); // only after handler for HomeOfficeDayNotificationCommand has been installed
            installEventHandlers();

            _windowTitleServer = new TimeBalanceServer(_mainWindowVM);
            _windowTitleServer.TimeBalanceChanged += new EventHandler <TimeBalanceServer.TimeBalanceChangedEventArgs>(_windowTitleServer_TimeBalanceChanged);

            ensureDeskBandInfoFormatterCreated();
            _mainWindowVM.MonthViewModel.NotifyPropertyChanged("BalanceWholeMonth");
        }
Exemplo n.º 2
0
 public void OnWebRequestCompleted()
 {
     m_AppRestarter.ShutDown();
 }