Example #1
0
        // Check what kind of entities can be created using the dragsource data
        private bool CheckDropTarget(DragEventArgs e, out EntityViewModel entityVM)
        {
            EntityViewModel evm = null;
             entityVM = null;

             if (_draggedEntites == null)
            return false;

             HitTestResult htr = VisualTreeHelper.HitTest(TreeWorkArea, e.GetPosition(TreeWorkArea));

             var tvItem = htr.VisualHit.FindVisualParent<TreeViewItem>();

             if ( null == tvItem )
            return false;

             evm = tvItem.Header as EntityViewModel;

             if ( null == evm )
            return false;

             entityVM = evm;

             return _draggedEntites.All((en) => evm.Entity.Schema.SupportedEntityTypes.Contains(en));
        }
Example #2
0
        ContextMenu GetContextMenu(EntityViewModel evm)
        {
            ContextMenu menu = new ContextMenu();

             IEnumerable<string> entities;

             if (evm is PackageViewModel)
             {
            entities = from e in EntitySchema.SchemaNames
                       where e != EasyInstall.EntityTypes.PACKAGEENTITY
                       select e;
             }
             else
             {
            entities = evm.Entity.Schema.SupportedEntityTypes;
             }

             // Add Entity Creation menu Items
             if (entities.Count() > 0)
             {
            MenuItem mi = new MenuItem();
            mi.Header = "Add";

            foreach (var entity in entities)
            {
               MenuItem submi = new MenuItem();
               submi.Header = entity;
               submi.Command = EasyInstall.ViewModels.Commands.GetRoutedCommandForEntity(entity);
               submi.CommandParameter = evm;
               mi.Items.Add(submi);
            }

            menu.Items.Add(mi);
            menu.Items.Add(new Separator());
             }

             // Add Delete current
             if (!(evm is PackageViewModel))
             {
            MenuItem mi = new MenuItem();
            mi.Header = "Remove";
            mi.Command = EasyInstall.ViewModels.Commands.RemoveEntity;
            mi.CommandParameter = evm;
            menu.Items.Add(mi);
             }

             if ( evm is PackageViewModel )
             {
            MenuItem mi = new MenuItem();
            mi.Header = "Build";
            mi.Command = EasyInstall.ViewModels.Commands.BuildPackage;
            mi.CommandParameter = evm;
            menu.Items.Add(mi);
             }

             if (evm.Entity.SubEntities.Count() > 0)
             {
            MenuItem mi = new MenuItem();
            mi.Header = "Remove Children";
            mi.Command = EasyInstall.ViewModels.Commands.RemoveAllEntities;
            mi.CommandParameter = evm;
            menu.Items.Add(mi);
             }

             return menu;
        }
Example #3
0
        private void TreeWorkArea_Selected(object sender, RoutedEventArgs e)
        {
            TreeWorkArea.Tag = e.OriginalSource;
             CurrentEntity = (e.OriginalSource as TreeViewItem).Header as EntityViewModel;

             Resources["SelectedEntity"] = CurrentEntity;
        }
Example #4
0
        void GetEntityAtCursor(Point p, out TreeViewItem item, out EntityViewModel evm)
        {
            evm = null;

             HitTestResult htr = VisualTreeHelper.HitTest(TreeWorkArea, p);

             item = htr.VisualHit.FindVisualParent<TreeViewItem>();

             if (item != null)
             {
            evm = item.Header as EntityViewModel;
             }
        }