Ejemplo n.º 1
0
 public void SetSelection(IUiBase item)
 {
     if (customControl != null)
     {
         customControl.SelectedItem = item;
     }
 }
Ejemplo n.º 2
0
        public UiBase AddNew()
        {
            // update current, if necessary
            SelectionChanged(null);

            // add new item
            IUiBase newItem = null;

            try {
                newItem = service.Create();
            } catch (Exception ex) {
                Trace.TraceError("Add new item : " + ex.Message);
            }

            if (newItem == null)
            {
                view.ShowMessage("Add Item", "Could not create a new line", MessageActions.Ok);
                return(null);
            }

            // select the new item
            var newIndex = service.GetIndex(newItem);

            Debug.Assert(newIndex >= 0);
            RefreshData();

            //SetDetailDataSourceIndex(newIndex);
            view.SelectedItem = newItem;
            return(newItem as UiBase);
        }
Ejemplo n.º 3
0
        public void SetChildFilter(IUiBase parent)
        {
            this.SearchValue = string.Empty;
            this.parent      = parent;
            HasParent        = parent != null;
            var dataSource = service.GetList(GetListParent());

            RefreshService(dataSource);
        }
Ejemplo n.º 4
0
        public bool Update(IUiBase item)
        {
            //var index = GetIndex(item);
            var updated = service.Update(GetOriginal(item as TUiItem));

            //item.IsDirty = false;
            item.IsLocked = !updated;
            return(updated);
        }
Ejemplo n.º 5
0
 public void SetDetailSelection(IUiBase item)
 {
     //var detail = item as UiProjectItemDetail;
     //Debug.Assert(detail != null);
     //foreach (UiProjectItemsCategory category in this.projectGrid.Items)
     //    if (category.Details.Contains(detail)) {
     //        //MainContent.MainGrid.SelectedItem = item;   // TODO : add property
     //        customControl.SelectedItem = item;
     //        break;
     //    }
 }
Ejemplo n.º 6
0
 public override int GetIndex(IUiBase item)
 {
     if (item is UiProjectItemsCategory)
     {
         return(base.GetIndex(item));
     }
     else
     {
         return(UiProjectItemDetail.Service.GetIndex(item));
     }
 }
Ejemplo n.º 7
0
        //public IUiBase GetSelected() { return SelectedIndex < 0 ? null : cache[SelectedIndex]; }

        public virtual int GetIndex(IUiBase item)
        {
            var uiItem = item as TUiItem;

            if (uiItem == null)
            {
                return(-1);
            }
            var search = GetOriginal(uiItem);

            return(GetIndex(search));
        }
Ejemplo n.º 8
0
        public virtual void SetDataType(Type type, UiBase parent)
        {
            CloseCurrentService();

            CurrentType           = type;
            this.associatedParent = parent;

            if (type == typeof(UiClient))
            {
                UiClient.InitService();
                SelectService(UiClient.Service, typeof(UiClient), parent);
                return;
            }

            if (type == typeof(UiEmployee))
            {
                UiEmployee.InitService();
                SelectService(UiEmployee.Service, typeof(UiEmployee), parent);
                return;
            }

            if (type == typeof(UiProjectItemsCategory))
            {
                // only as DetailController
                UiProjectItemsCategory.InitService();
                SelectService(UiProjectItemsCategory.Service, typeof(UiProjectItemsCategory), parent);
                return;
            }

            if (type == typeof(UiProject))
            {
                UiProject.InitService();
                SelectService(UiProject.Service, typeof(UiProject), parent, new[] { "Budgets" });
                return;
            }

            if (type == typeof(UiMaterial))
            {
                UiMaterial.InitService();
                SelectService(UiMaterial.Service, typeof(UiMaterial), parent);
                return;
            }

            if (type == typeof(UiProjectCategory))
            {
                UiProjectCategory.InitService();
                SelectService(UiProjectCategory.Service, typeof(UiProjectCategory), parent);
                return;
            }

            // TODO : throw an exception
        }
Ejemplo n.º 9
0
            public override ICollection GetList(IUiBase parent, string searchValue = null)
            {
                if (parent == null || !(parent is UiProject))
                {
                    return(new List <ProjectItemCategory>());
                }

                var result     = base.GetList(parent);
                var projectKey = (parent as UiProject).Id;

                foreach (UiProjectItemsCategory item in cache)
                {
                    //item.Details = (UiProjectItemDetail.Service as UiProjectItemDetail.TheService).GetList(projectKey, item.original.Key);   // TODO : pass the project!
                    item.Details = new ObservableCollection <UiProjectItemDetail>((UiProjectItemDetail.Service as UiProjectItemDetail.TheService).GetList(projectKey, item.original.Key));   // TODO : pass the project!
                }
                return(result);
            }
Ejemplo n.º 10
0
        protected virtual void SelectionChanged(IUiBase item)
        {
            if (service.SelectedItem == item)
            {
                return;                                 // re-selected the same item
            }
            var oldSelection = service.SelectedItem;

            if (oldSelection != null)
            {
                oldSelection.PropertyChanged -= Selection_PropertyChanged;
                if (oldSelection.IsDirty)
                {
                    if (!oldSelection.Update())
                    {
                        view.ShowMessage("Delete", "Could not update the line", MessageActions.Ok);
                        // move selection back to it
                        view.SelectedItem = item;
                        return;
                    }
                }

                //view.SetRowStatus(service.GetIndex(oldSelection), oldSelection.IsLocked ? RowStatus.Locked : RowStatus.Normal);   // not for wpf
            }

            // set new selection
            service.SelectedItem = item;

            if (item == null)
            {
                view.SelectedItem = null;
                return;
            }

            // TODO pass the object, not the index
            //var index = service.GetIndex(item);
            //view.DetailDataSourceIndex = index;
            view.SelectedItem     = item;
            item.PropertyChanged += Selection_PropertyChanged;
            view.GridReadOnly     = item.IsLocked;
        }
Ejemplo n.º 11
0
 private void SetDetailDataSource(IUiBase selection)
 {
     view.DetailSelection = selection;
 }
Ejemplo n.º 12
0
 public virtual ICollection GetList(IUiBase parent, string searchValue = null)
 {
     return(GetList(service.GetList(parent == null ? null : (parent as UiBase).GetService().GetOriginal(parent), searchValue)));
 }
Ejemplo n.º 13
0
 public bool Lock(IUiBase item, bool locked)
 {
     return(!(item is TUiItem) || service.Lock(GetOriginal(item as TUiItem), locked));
 }
Ejemplo n.º 14
0
 public IUiBase Delete(IUiBase item)
 {
     return(service.Delete(GetOriginal(item as TUiItem)) == null ?
            null :
            item);
 }