Inheritance: System.EventArgs
Ejemplo n.º 1
0
        protected void ActivateItem(IEnumerable<ViewModel> items)
        {
            if (items == null || items.Count() == 0) return;

            var openingArgs = new ItemsOpeningEventArgs(DataContext, ViewModelFactory.GetWorkspace(DataContext) as ObjectEditorWorkspace, items);

            OnItemsOpening(this, openingArgs);

            // abort handling the event if it is already handled
            if (openingArgs.Handled == true)
                return;

            foreach (var item in openingArgs.Items)
            {
                var dovm = item as DataObjectViewModel;
                if (dovm != null && dovm.Object.GetObjectClass(FrozenContext).IsSimpleObject)
                {
                    // Open in a Dialog
                    var dlg = ViewModelFactory.CreateViewModel<SimpleDataObjectEditorTaskViewModel.Factory>().Invoke(DataContext, Parent, item);
                    ViewModelFactory.ShowDialog(dlg);
                }
                else
                {
                    ViewModelFactory.ShowModel(item, true);
                }
            }

            OnItemsOpened(this, new ItemsOpenedEventArgs(openingArgs.Items));
        }
Ejemplo n.º 2
0
 protected void OnItemsOpening(object workspace, ItemsOpeningEventArgs args)
 {
     var temp = ItemsOpening;
     if (temp != null)
     {
         temp(workspace, args);
     }
 }
Ejemplo n.º 3
0
        protected void ActivateForeignItems(IViewModelFactoryScope newScope, IZetboxContext newCtx, IEnumerable<IDataObject> items)
        {
            if (newScope == null) throw new ArgumentNullException("newScope");
            if (newCtx == null) throw new ArgumentNullException("newCtx");
            if (items == null || items.Count() == 0) return;

            var newWorkspace = ObjectEditor.WorkspaceViewModel.Create(newScope.Scope, newCtx);
            newScope.ViewModelFactory.ShowModel(newWorkspace, RequestedWorkspaceKind, true);

            // ShowForeignObject may take a while
            newScope.ViewModelFactory.CreateDelayedTask(newWorkspace, () =>
            {
                var newViewModels = items.Select(i => DataObjectViewModel.Fetch(newScope.ViewModelFactory, newCtx, this, newCtx.Find(DataContext.GetInterfaceType(i), i.ID)));
                var openingArgs = new ItemsOpeningEventArgs(newCtx, newWorkspace, newViewModels);

                OnItemsOpening(newWorkspace, openingArgs);

                // abort handling the event if it is already handled
                if (openingArgs.Handled == true)
                    return;

                foreach (var newItem in openingArgs.Items)
                {
                    newWorkspace.ShowModel(newItem);
                }

                OnItemsOpened(newWorkspace, new ItemsOpenedEventArgs(openingArgs.Items));

                newWorkspace.SelectedItem = newWorkspace.Items.FirstOrDefault();
            }).Trigger();
        }