Beispiel #1
0
 /// <summary>
 /// Removes an item from an editable list
 /// business object.
 /// </summary>
 /// <param name="sender">Object invoking this method.</param>
 /// <param name="e">
 /// ExecuteEventArgs, where MethodParameter contains
 /// the item to be removed from the list.
 /// </param>
 public void RemoveItem(object sender, ExecuteEventArgs e)
 {
     try
     {
         var item = e.MethodParameter;
         SetError(null);
         var obj = ObjectInstance as System.Collections.IList;
         if (obj != null)
         {
             IsBusy = true;
             obj.Remove(item);
             var trackable = ObjectInstance as ITrackStatus;
             if (trackable != null)
             {
                 IsBusy = trackable.IsBusy;
             }
             else
             {
                 IsBusy = false;
             }
         }
         RefreshCanOperationsValues();
     }
     catch (Exception ex)
     {
         this.Error = ex;
     }
 }
Beispiel #2
0
        /// <summary>
        /// Adds a new item to the Model (if it
        /// is a collection).
        /// </summary>
        public virtual void AddNew(object sender, ExecuteEventArgs e)
        {
#if SILVERLIGHT
            BeginAddNew();
#else
            DoAddNew();
#endif
        }
Beispiel #3
0
        public void ProcessItemsTrigger(object sender, Csla.Xaml.ExecuteEventArgs e)
        {
            // copy selected items into known list type
            var selection = new List <Data>();

            foreach (Data item in (System.Collections.IEnumerable)e.MethodParameter)
            {
                selection.Add(item);
            }

            // display detail form
            var form = new DetailPage();
            var vm   = form.Resources["ViewModel"] as DetailModel;

            if (vm != null)
            {
                vm.SelectedItems = selection;
            }
            MainPageModel.ShowForm(form);
        }
Beispiel #4
0
        public void ProcessItemsExecute(object sender, Csla.Xaml.ExecuteEventArgs e)
        {
            // copy selected items into known list type
            var listBox   = ((System.Windows.Controls.Control)e.TriggerSource).Tag as System.Windows.Controls.ListBox;
            var selection = new List <Data>();

            foreach (var item in listBox.SelectedItems)
            {
                selection.Add((Data)item);
            }

            // process selection
            var form = new DetailPage();
            var vm   = form.Resources["ViewModel"] as DetailModel;

            if (vm != null)
            {
                vm.SelectedItems = selection;
            }
            MainPageModel.ShowForm(form);
        }
Beispiel #5
0
        /// <summary>
        /// Removes an item from the list if the object
        /// implements IBindingList and AllowRemove is true.
        /// </summary>
        /// <param name="sender">Object invoking this method.</param>
        /// <param name="e">
        /// ExecuteEventArgs, where MethodParameter contains
        /// the item to be removed from the list.
        /// </param>
        public void RemoveItem(object sender, ExecuteEventArgs e)
        {
            var item = e.MethodParameter;
            // only do something if the object implements
            // IBindingList
            IBindingList list;

            Csla.Core.BusinessBase bb = item as Csla.Core.BusinessBase;
            if (bb != null)
            {
                list = bb.Parent as IBindingList;
            }
            else
            {
                list = this.Data as IBindingList;
            }
            if (list != null && list.AllowRemove)
            {
                list.Remove(item);
            }
        }
Beispiel #6
0
 public void ShowItem(object sender, Csla.Xaml.ExecuteEventArgs e)
 {
     SelectedData = (Data)e.MethodParameter;
 }
Beispiel #7
0
 /// <summary>
 /// Removes an item from an editable list
 /// business object.
 /// </summary>
 /// <param name="sender">Object invoking this method.</param>
 /// <param name="e">
 /// ExecuteEventArgs, where MethodParameter contains 
 /// the item to be removed from the list.
 /// </param>
 public void RemoveItem(object sender, ExecuteEventArgs e)
 {
   try
   {
     var item = e.MethodParameter;
     SetError(null);
     var obj = ObjectInstance as System.Collections.IList;
     if (obj != null)
     {
       IsBusy = true;
       obj.Remove(item);
       var trackable = ObjectInstance as ITrackStatus;
       if (trackable != null)
         IsBusy = trackable.IsBusy;
       else
         IsBusy = false;
     }
     RefreshCanOperationsValues();
   }
   catch (Exception ex)
   {
     this.Error = ex;
   }
 }
Beispiel #8
0
 /// <summary>
 /// Marks the Model for deletion (if it is an
 /// editable root object).
 /// </summary>
 public virtual void Delete(object sender, ExecuteEventArgs e)
 {
     DoDelete();
 }
Beispiel #9
0
 /// <summary>
 /// Removes an item from the Model (if it
 /// is a collection).
 /// </summary>
 public virtual void Remove(object sender, ExecuteEventArgs e)
 {
     DoRemove(e.MethodParameter);
 }
Beispiel #10
0
 /// <summary>
 /// Cancels changes made to the model
 /// if ManagedObjectLifetime is true.
 /// </summary>
 public virtual void Cancel(object sender, ExecuteEventArgs e)
 {
     DoCancel();
 }
Beispiel #11
0
 /// <summary>
 /// Saves the Model, first committing changes
 /// if ManagedObjectLifetime is true.
 /// </summary>
 public virtual void Save(object sender, ExecuteEventArgs e)
 {
     BeginSave();
 }
Beispiel #12
0
 /// <summary>
 /// Removes an item from the list if the object
 /// implements IBindingList and AllowRemove is true.
 /// </summary>
 /// <param name="sender">Object invoking this method.</param>
 /// <param name="e">
 /// ExecuteEventArgs, where MethodParameter contains 
 /// the item to be removed from the list.
 /// </param>
 public void RemoveItem(object sender, ExecuteEventArgs e)
 {
   var item = e.MethodParameter;
   // only do something if the object implements
   // IBindingList
   IBindingList list;
   Csla.Core.BusinessBase bb = item as Csla.Core.BusinessBase;
   if (bb != null)
     list = bb.Parent as IBindingList;
   else
     list = this.Data as IBindingList;
   if (list != null && list.AllowRemove)
     list.Remove(item);
 }