示例#1
0
        /// <summary>
        /// Creates a new command.
        /// </summary>
        /// <param name="execute">The execution logic.</param>
        /// <param name="canExecute">The execution status logic.</param>
        public RelayCommand(Action <object> execute, Predicate <object> canExecute)
        {
            Diag.DataBindingPresentation();

            if (execute == null)
            {
                throw new ArgumentNullException("execute");
            }

            _execute    = execute;
            _canExecute = canExecute;


            try
            {
                Diag.UpdateLog("(5) " + this.GetType().FullName + ";\t" + System.Reflection.MethodBase.GetCurrentMethod().Name + ";\t" +
                               _execute.Method.Name + ";\t" +
                               _execute.Method.ToString() + ";\t" +
                               _execute.Target.ToString());
            }
            catch (Exception ex)
            {
                Diag.UpdateLog("(5) " + this.GetType().FullName + ";\t" + System.Reflection.MethodBase.GetCurrentMethod().Name + ";\t" + ex.Message);
            }
        }
示例#2
0
        /// <summary>
        /// Creates a new command that can always execute.
        /// </summary>
        /// <param name="execute">The execution logic.</param>
        public RelayCommand(Action <object> execute) : this(execute, null)
        {
            Diag.DataBindingPresentation();

            try
            {
                Diag.UpdateLog("(4) " + this.GetType().FullName + ";\t" + System.Reflection.MethodBase.GetCurrentMethod().Name + ";\t" + execute.ToString());
            }
            catch (Exception ex)
            {
                Diag.UpdateLog("(4) " + this.GetType().FullName + ";\t" + System.Reflection.MethodBase.GetCurrentMethod().Name + ";\t" + ex.Message);
            }
        }
示例#3
0
        static App()
        {
            Diag.UpdateLog(true, "--------------------------------------------------------------------------");
            Diag.DataBindingPresentation();
            // This code is used to test the app when using other cultures.
            //
            //System.Threading.Thread.CurrentThread.CurrentCulture =
            //    System.Threading.Thread.CurrentThread.CurrentUICulture =
            //        new System.Globalization.CultureInfo("it-IT");


            // Ensure the current culture passed into bindings is the OS culture.
            // By default, WPF uses en-US as the culture, regardless of the system settings.
            //
            FrameworkElement.LanguageProperty.OverrideMetadata(
                typeof(FrameworkElement),
                new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
        }
示例#4
0
 //[DebuggerStepThrough]
 public void Execute(object parameter)
 {
     Diag.UpdateLog("(341567) Relay Command Execute()\t" + this.ToString());
     _execute.Invoke(parameter);
 }
示例#5
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();
        }
示例#6
0
 public MainWindow()
 {
     InitializeComponent();
     Diag.DataBindingPresentation();
 }