/// <summary>Binds the view to its controller</summary>
        public override void BindTo(ViewController controller)
        {
            bool bind = controller != null;
            SearchViewController svController = (bind ? controller : this.Controller) as SearchViewController;
            if (svController != null)
            {
                if (SearchButton != null)
                {
                    if (bind) SearchButton.Click += svController.Search;
                    else SearchButton.Click -= svController.Search;
                }
                if (ResetButton != null)
                {
                    if (bind) ResetButton.Click += svController.Reset;
                    else ResetButton.Click -= svController.Reset;
                }
                if (SelectButton != null)
                {
                    if (bind) SelectButton.Click += svController.Select;
                    else SelectButton.Click -= svController.Select;
                }

                BindDataObject(CriteriaPanel, bind ? svController.Criteria : null);
                BindDataObject(ResultsGrid, bind ? svController.List : null);
            }
            base.BindTo(controller);
        }
 /// <summary>Binds the view to its controller</summary>
 public override void BindTo(ViewController controller)
 {
     bool bind = controller != null;
     DetailsViewController dtlController = (bind ? controller : Controller) as DetailsViewController;
     if (dtlController != null)
     {
         if (SaveButton != null)
         {
             SaveButton.Command = bind ? new RelayCommand<object>(
                 p => dtlController.Save(this, EventArgs.Empty),
                 p => dtlController.CanSave()) : null;
         }
         if (DeleteButton != null)
         {
             DeleteButton.Command = bind ? new RelayCommand<object>(
                 p => dtlController.Delete(this, EventArgs.Empty),
                 p => dtlController.CanDelete()) : null;
         }
         BindDataObject(this, bind ? dtlController.DetailsObject : null);
     }
     base.BindTo(controller);
 }
 /// <summary>
 /// Subscribes to child view's events
 /// </summary>
 /// <param name="child">Child view</param>
 protected virtual void SubscribeToChildEvents(ViewController child)
 {
     child.Closed += OnChildClosed;
     DetailsViewController details = child as DetailsViewController;
     if (details != null)
     {
         details.Saved += OnChildSaved;
         details.Deleted += OnChildDeleted;
     }
     SearchViewController search = child as SearchViewController;
     if (search != null)
     {
         search.Selected += OnChildSelection;
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Binds the view to its controller, or unbinds the current controller if null is passed.
 /// </summary>
 public virtual void BindTo(ViewController controller)
 {
     bool bind = controller != null;
     ViewController vc = bind ? controller : this.Controller;
     if (vc != null)
     {
         if (CloseButton != null)
         {
             if (bind) CloseButton.Click += vc.Close;
             else CloseButton.Click -= vc.Close;
         }
     }
     this.Controller = controller;
 }