Esempio n. 1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            MainWindow window = new MainWindow();

            // Create the ViewModel to which 
            // the main window binds.
            string path = "Data/customers.xml";
            var viewModel = new MainWindowViewModel(path);

            // When the ViewModel asks to be closed, 
            // close the window.
            EventHandler handler = null;
            handler = delegate
            {
                viewModel.RequestClose -= handler;
                window.Close();
            };
            viewModel.RequestClose += handler;

            // Allow all controls in the window to 
            // bind to the ViewModel by setting the 
            // DataContext, which propagates down 
            // the element tree.
            window.DataContext = viewModel;

            window.Show();
        }
Esempio n. 2
0
		protected override void OnStartup( StartupEventArgs e )
		{
			base.OnStartup( e );

			MainWindow window = new MainWindow( );

			string path = @"C:\Trabajos\Conferencias\RUN 09 - Arquitecturas de presentacion con WPF\Samples\MvvmDemoApp_Spanish\DemoApp\bin\Debug\customers.xml";
			var viewModel = new MainWindowViewModel( path );

			EventHandler handler = null;
			handler = delegate
			{
				viewModel.RequestClose -= handler;
				window.Close( );
			};
			viewModel.RequestClose += handler;

			window.DataContext = viewModel;

			window.Show( );

			if ( e.Args != null && e.Args.GetUpperBound( 0 ) == 0 )
			{
				if ( e.Args[ 0 ] == ViewAllCustomerArg )
				{
					viewModel.ShowAllCustomers( );
				}
				else
				{
					string[] customerData = Path.GetFileNameWithoutExtension( e.Args[ 0 ].Replace( "/doc", String.Empty ) ).Split( '_' );

					if ( customerData.GetUpperBound( 0 ) == 0 )
						viewModel.ShowCustomer( customerData[ 0 ], null );
					else
						viewModel.ShowCustomer( customerData[ 0 ], customerData[ 1 ] );
				}
			}
		}
Esempio n. 3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            MainWindow _mainWindow = new MainWindow();
            // Create the ViewModel to which
            // the main _mainWindow binds.
            string path = "Data/customers.xml";

            MainWindowViewModel _mainWindowViewModel = new MainWindowViewModel(path);



            #region MainWindow KeyDown
            //Delegate to handle KeyDown events-----------------------
            KeyEventHandler KeyDown = delegate(object sender, KeyEventArgs arg)
            {
                if (arg.Key == Key.F4)
                {
                    _mainWindowViewModel.OnToggleButtonClicked();
                }
            };

            //Hook to capture KeyDown events
            _mainWindow.KeyDown += KeyDown;

            #endregion MainWindow KeyDown



            // When the ViewModel asks to be closed,
            // close the _mainWindow.
            EventHandler handler = null;
            handler = delegate
            {
                try
                {
                    Diag.UpdateLog("(1)\t" + GetType().FullName + ";\t" + System.Reflection.MethodBase.GetCurrentMethod().Name);
                }
                catch (Exception ex)
                {
                    Diag.UpdateLog("(1)\t" + GetType().FullName + ";\t" + System.Reflection.MethodBase.GetCurrentMethod().Name + ";\t" + ex.Message);
                }

                _mainWindowViewModel.WSVMRequestClose -= handler;
                _mainWindowViewModel.MainWindowViewModelRequestClose -= handler;
                _mainWindow.KeyDown -= KeyDown;
                _mainWindow.Close();
            };

            _mainWindowViewModel.WSVMRequestClose += handler;
            _mainWindowViewModel.MainWindowViewModelRequestClose += handler;



            // Allow all controls in the _mainWindow to
            // bind to the ViewModel by setting the
            // DataContext, which propagates down
            // the element tree.
            _mainWindow.DataContext = _mainWindowViewModel;

            _mainWindow.Show();
        }