Beispiel #1
0
        void ListViewModel_ObjectCreated(IDataObject obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            // Same like choose
            var mdl = DataObjectViewModel.Fetch(ViewModelFactory, DataContext, ViewModelFactory.GetWorkspace(DataContext), obj);

            Choose(new[] { mdl });
        }
Beispiel #2
0
        protected override List <PropertyGroupViewModel> CreatePropertyGroups()
        {
            var result = base.CreatePropertyGroups();

            var relListMdl = ViewModelFactory.CreateViewModel <InstanceListViewModel.Factory>().Invoke(DataContext, this, () => DataContext, typeof(Relation).GetObjectClass(FrozenContext), () => DataContext.GetQuery <Relation>());

            relListMdl.EnableAutoFilter = false;
            relListMdl.AddFilter(new ConstantValueFilterModel("A.Type = @0 || B.Type = @0", this.Object));
            relListMdl.Commands.Add(ViewModelFactory.CreateViewModel <SimpleCommandViewModel.Factory>().Invoke(DataContext, this, "New Relation", "Creates a new Relation", CreateRelation, null, null));

            var lblMdl     = ViewModelFactory.CreateViewModel <LabeledViewContainerViewModel.Factory>().Invoke(DataContext, this, "Relations", "", relListMdl);
            var propGrpMdl = ViewModelFactory.CreateViewModel <SinglePropertyGroupViewModel.Factory>().Invoke(DataContext, this, "Relations", new ViewModel[] { lblMdl });

            result.Add(propGrpMdl);
            return(result);
        }
Beispiel #3
0
        private void HandleResult(object result, object callback)
        {
            IDataObject obj = result as IDataObject;

            if (obj != null && obj.Context == DataContext)
            {
                this.ViewModelFactory.ShowModel(DataObjectViewModel.Fetch(this.ViewModelFactory, DataContext, ViewModelFactory.GetWorkspace(DataContext), obj), true);
            }
            else if (result != null)
            {
                ViewModelFactory.ShowMessage(result.ToString(), "Result");
            }

            if (callback is Action)
            {
                ((Action)callback)();
            }
        }
Beispiel #4
0
        protected override List <PropertyGroupViewModel> CreatePropertyGroups()
        {
            var result = base.CreatePropertyGroups();

            if (_dataType is ObjectClass || _dataType is CompoundObject)
            {
                var singleMdl = result.Single(n => n.Name == "Properties");
                var preview   = ViewModelFactory.CreateViewModel <PropertiesPrewiewViewModel.Factory>().Invoke(DataContext, this, _dataType);
                var lblMdl    = ViewModelFactory.CreateViewModel <LabeledViewContainerViewModel.Factory>().Invoke(DataContext, this, "Preview", "", preview);
                var grpMdl    = ViewModelFactory.CreateViewModel <MultiplePropertyGroupViewModel.Factory>().Invoke(DataContext, this, "Properties", singleMdl.PropertyModels.Concat(new[] { lblMdl }).ToArray());

                var idx = result.IndexOf(singleMdl);
                result.Remove(singleMdl);
                result.Insert(idx, grpMdl);
            }

            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// Initializes a new instance of the SelectionTaskModel class. This is protected since there
        /// is no ViewModelDescriptor for this class. Instead, either use the
        /// <see cref="DataObjectSelectionTaskViewModel"/> or inherit this for a specific type yourself and
        /// add your own ViewModelDescriptor and View.
        /// </summary>
        /// <param name="appCtx"></param>
        /// <param name="dataCtx"></param>
        /// <param name="parent">Parent ViewModel</param>
        /// <param name="type"></param>
        /// <param name="qry"></param>
        /// <param name="callback"></param>
        /// <param name="additionalActions"></param>
        public DataObjectSelectionTaskViewModel(
            IViewModelDependencies appCtx, IZetboxContext dataCtx, ViewModel parent,
            ObjectClass type,
            Func <IQueryable> qry,
            Action <IEnumerable <DataObjectViewModel> > callback,
            IList <CommandViewModel> additionalActions)
            : base(appCtx, dataCtx, parent)
        {
            _callback                         = callback;
            _additionalActions                = new ReadOnlyCollection <CommandViewModel>(additionalActions ?? new CommandViewModel[] { });
            ListViewModel                     = ViewModelFactory.CreateViewModel <InstanceListViewModel.Factory>().Invoke(dataCtx, this, () => dataCtx, type, qry);
            ListViewModel.AllowAddNew         = true;
            ListViewModel.ObjectCreated      += ListViewModel_ObjectCreated;
            ListViewModel.ItemsDefaultAction += ListViewModel_ItemsDefaultAction;
            ListViewModel.ViewMethod          = InstanceListViewMethod.Details;

            foreach (var cmd in _additionalActions)
            {
                ListViewModel.Commands.Add(cmd);
            }
        }
Beispiel #6
0
        private void DisplayErrors()
        {
            _errors.Clear();
            foreach (var error in Parent.GetErrors())
            {
                IDataObject obj = error as IDataObject;
                if (obj == null && error is ViewModel)
                {
                    var vmdl = (ViewModel)error;
                    if (vmdl.Parent is DataObjectViewModel)
                    {
                        obj = ((DataObjectViewModel)vmdl.Parent).Object;
                    }
                }

                _errors.Add(ViewModelFactory.CreateViewModel <ErrorDescriptor.Factory>().Invoke(
                                DataContext, this,
                                obj == null ? null : DataObjectViewModel.Fetch(ViewModelFactory, DataContext, this, obj),
                                new List <string>()
                {
                    error.Error
                }));
            }
        }
Beispiel #7
0
        public void CreateRelation()
        {
            var rel = _class.CreateRelation();

            ViewModelFactory.ShowModel(DataObjectViewModel.Fetch(ViewModelFactory, DataContext, this, rel), true);
        }
Beispiel #8
0
 public void GotoObject()
 {
     ViewModelFactory.ShowModel(Item, true);
 }