예제 #1
0
#pragma warning restore

        public MapperTreeNode(ModelMapper mapper)
            : base()
        {
            Mapper = mapper;

            FNamed = mapper.Map <INamed>();

            Text            = FNamed.Name;
            Tag             = mapper.Model;
            FNamed.Renamed += Item_Renamed;

            if (mapper.CanMap <IParent>())
            {
                var items = mapper.Map <IParent>();
                if (items.Childs != null)
                {
                    // Keep Nodes and items in sync
                    FSynchronizer         = Nodes.SyncWith(items.Childs, CreateChildNode);
                    FSynchronizer.Synced += synchronizer_Synced;
                }
            }
            if (mapper.CanMap <ISelectable>())
            {
                FSelectable = mapper.Map <ISelectable>();
                Checked     = FSelectable.Selected;
                FSelectable.SelectionChanged += Item_SelectionChanged;
            }
        }
예제 #2
0
 public static void SetByCommand(this IEditableProperty property, object newValue, ModelMapper mapper)
 {
     if (mapper.CanMap <ICommandHistory>())
     {
         property.SetByCommand(newValue, mapper.Map <ICommandHistory>());
     }
 }
예제 #3
0
 public DefaultColumnProvider(ModelMapper mapper)
 {
     if (mapper.CanMap <IEnumerable>())
     {
         FEnumerable = mapper.Map <IEnumerable>();
     }
     else
     {
         FEnumerable = Empty.Enumerable;
     }
 }
예제 #4
0
        public DefaultDecoratableProvider(ModelMapper mapper)
        {
            FMapper = mapper;

            if (FMapper.CanMap <INamed>())
            {
                Text = FMapper.Map <INamed>().Name;
            }
            else
            {
                Text = FMapper.Model.ToString();
            }
        }
예제 #5
0
        void FHierarchyViewerClick(ModelMapper sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (sender == null)
            {
                if (e.Button == MouseButtons.Middle)
                {
                    FHierarchyViewer.ViewAll();
                }
            }
            else
            {
                var nodeView = sender.Model as NodeView;
                if (e.Button == MouseButtons.Left && nodeView != null)
                {
                    nodeView.Selected = true;
                    if (FActivePatchNode.Window != null && FActivePatchNode.Window.IsVisible)
                    {
                        FHDEHost.SelectNodes(new INode2[1] {
                            nodeView.Node
                        });

                        if (FNodeView != null && !FNodeFilter.ScopeIsLocal)
                        {
                            if (sender.CanMap <ICamera>())
                            {
                                var camera = sender.Map <ICamera>();
                                var parent = nodeView.Parent;
                                if (parent == null)
                                {
                                    parent = FNodeView;
                                }

                                camera.View(parent);
                            }
                        }
                    }
                }
                else if (e.Button == MouseButtons.Right && nodeView != null)
                {
                    if (nodeView.Node == FActivePatchNode)
                    {
                        FHDEHost.ShowEditor(FActivePatchNode.Parent);
                    }
                    else
                    {
                        OpenPatch(nodeView.Node);
                    }
                }
            }
        }
예제 #6
0
        public DefaultAddMenuEntry(ModelMapper mapper, IIDItem model)
            : base(model.Mapper.Map <ICommandHistory>())
        {
            if (mapper.CanMap <IAddMenuProvider>())
            {
                foreach (var a in mapper.Map <IAddMenuProvider>().GetEnumerator())
                {
                    Add(a);
                }
            }

            FMapper = mapper;
            FModel  = model;
        }
예제 #7
0
 public DefaultParentProvider(ModelMapper mapper)
 {
     if (mapper.CanMap <IEnumerable>())
     {
         Childs = mapper.Map <IEnumerable>();
     }
     else
     if (mapper.Model is IEnumerable)
     {
         Childs = mapper.Model as IEnumerable;
     }
     else
     {
         Childs = null;
     }
 }
예제 #8
0
        public ProjectViewProvider(IProject project, ModelMapper mapper)
        {
            FProject = project;

            FDocumentsMapper = mapper.CreateChildMapper(FProject.Documents);
            if (FDocumentsMapper.CanMap <IDroppable>())
            {
                FDroppable = FDocumentsMapper.Map <IDroppable>();
            }

            // Create a fake model, which shows documents in folders
            FFolderMap = new Dictionary <string, Folder>();

            // First create our root folder.
            FRootFolder = new Folder(string.Empty);
            FFolderMap[FRootFolder.Name] = FRootFolder;

            // Now create all folders.
            foreach (var doc in FProject.Documents)
            {
                FProject_Documents_Added(FProject.Documents, doc);
            }

            // Keep changes in project in sync with our folder model.
            FProject.Documents.Added       += FProject_Documents_Added;
            FProject.Documents.Removed     += FProject_Documents_Removed;
            FProject.Documents.ItemRenamed += FProject_ItemRenamed;
            FProject.References.Added      += HandleProjectReferenceAdded;
            FProject.References.Removed    += HandleProjectReferenceRemoved;

            // Keep us in sync with the root folder.
            FRootFolder.Added        += FRootFolder_Added;
            FRootFolder.Removed      += FRootFolder_Removed;
            FRootFolder.OrderChanged += FRootFolder_OrderChanged;

            FProject.Renamed += FProject_Renamed;
        }
예제 #9
0
        public virtual IEnumerator <IMenuEntry> GetEnumerator()
        {
            var idItem = FMapper.Model as IIDItem;

            if (idItem == null)
            {
                yield break;
            }

            var commandHistory = idItem.Mapper.Map <ICommandHistory>();

            if (FMapper.CanMap <AddMenuEntry>())
            {
                var addMenuEntry = FMapper.Map <AddMenuEntry>();
                if (addMenuEntry.HasSubMenuEntries)
                {
                    yield return(addMenuEntry);

                    yield return(new MenuSeparator());
                }
            }

            yield return(new UndoMenuEntry(commandHistory));

            yield return(new RedoMenuEntry(commandHistory));

            yield return(new MenuSeparator());

            if (FMapper.CanMap <IRenameable>())
            {
                var renameable = FMapper.Map <IRenameable>();
                if (FMapper.CanMap <ILabelEditor>())
                {
                    yield return(new RenameMenuEntry(commandHistory, renameable, FMapper.Map <ILabelEditor>()));
                }
                else
                {
                    yield return(new RenameMenuEntry(commandHistory, renameable));
                }
                yield return(new MenuSeparator());
            }

            if (FMapper.CanMap <IEditableProperty>())
            {
                var renameable = FMapper.Map <IEditableProperty>();
                yield return(new SetPropertyMenuEntry(commandHistory, renameable));

                yield return(new MenuSeparator());
            }

            if (idItem.Owner is IEditableIDList)
            {
                var owner = idItem.Owner as IEditableIDList;
                commandHistory = idItem.Owner.Mapper.Map <ICommandHistory>();

                if (owner.CanRemove(idItem))
                {
                    yield return(new RemoveMenuEntry <IEditableIDList, IIDItem>(commandHistory, owner, idItem));
                }
            }
        }
예제 #10
0
        public override void Reload()
        {
            FDataGridView.Rows.Clear();
            FDataGridView.Columns.Clear();

            if (FMapper != null)
            {
                FMapper.Dispose();
            }

            if (FRowSynchronizer != null)
            {
                FRowSynchronizer.Dispose();
            }

            FMapper = new ModelMapper(Input, Registry);

            if (FMapper.CanMap <IEnumerable <Column> >())
            {
                try
                {
                    var columns = FMapper.Map <IEnumerable <Column> >();

                    foreach (var col in columns)
                    {
                        var column = new DataGridViewColumn(new DataGridViewTextBoxCell());
                        column.Name = col.Name;
                        switch (col.AutoSizeMode)
                        {
                        case AutoSizeColumnMode.AllCells:
                            column.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                            break;

                        case AutoSizeColumnMode.ColumnHeader:
                            column.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
                            break;

                        case AutoSizeColumnMode.DisplayedCells:
                            column.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
                            break;

                        case AutoSizeColumnMode.Fill:
                            column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                            break;

                        default:
                            column.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
                            break;
                        }
                        FDataGridView.Columns.Add(column);
                    }

                    if (FDataGridView.Columns.Count > 0)
                    {
                        var entries = FMapper.Map <IEnumerable>();
                        FRowSynchronizer = FDataGridView.Rows.SyncWith(entries, CreateRow, (r) => {});
                    }
                }
                catch (Exception e)
                {
                    Shell.Instance.Logger.Log(e);
                }
            }
        }
예제 #11
0
        public MapperHierarchyNode(ModelMapper mapper, ICanvas canvas, IGraphElement parent, HierarchyViewer viewer)
            : base()
        {
            Mapper  = mapper;
            FCanvas = canvas;
            FViewer = viewer;

            MouseClick       += FViewer.MouseClickHandler;
            MouseDoubleClick += FViewer.MouseDoubleClickHandler;
            Tag = mapper.Model;

            //graphelements
            FBackground = canvas.CreateRectangle(this);
            FPoly       = canvas.CreatePoly(this);
            FText       = canvas.CreateText(null, "");
            FIcon       = FCanvas.CreateRectangle(null);

            parent.Add(FBackground);
            FBackground.Add(FPoly);
            FBackground.Add(FText);
            FBackground.Add(FIcon);

            //compute level of depth
            IGraphElement p = FBackground;

            while (p.Parent != null)
            {
                FDepth++;
                p = p.Parent;
            }
            FDepth -= 1;

            //init static properties via Mapper
            if (Mapper.CanMap <ISelectable>())
            {
                FSelectable = Mapper.Map <ISelectable>();
                FSelectable.SelectionChanged += selectable_SelectionChanged;
                Selected = FSelectable.Selected;
            }

            if (Mapper.CanMap <IDecoratable>())
            {
                FDecoratable = Mapper.Map <IDecoratable>();
                FDecoratable.DecorationChanged += decorated_DecorationChanged;
            }

            if (Mapper.CanMap <ILinkSource>())
            {
                FLinkSource = Mapper.Map <ILinkSource>();

                FLinkSourceRectangle = FCanvas.CreateRectangle(null);
                FBackground.Add(FLinkSourceRectangle);
                FLinkOffset = FTextOffset;
            }

            if (Mapper.CanMap <ILinkSink>())
            {
                FLinkSink = Mapper.Map <ILinkSink>();

                FLinkSinkRectangle = FCanvas.CreateRectangle(null);
                FBackground.Add(FLinkSinkRectangle);
            }

            if (Mapper.CanMap <INamed>())
            {
                FNamed          = Mapper.Map <INamed>();
                FNamed.Renamed += named_Renamed;
                SetCaption(FNamed.Name);
            }

            if (Mapper.CanMap <IParent>())
            {
                var node = Mapper.Map <IParent>();
                if (node.Childs != null)
                {
                    // Keep Nodes and items in sync
                    FSynchronizer         = FSubTree.SyncWith(node.Childs, CreateChildNode);
                    FSynchronizer.Synced += synchronizer_Synced;
                }
            }

            //init dynamic properties via Mapper
            UpdateColors();
            UpdateIcon();
            UpdateLinkSink();
            UpdateLinkSource();
        }
예제 #12
0
        public virtual IEnumerator <IMenuEntry> GetEnumerator()
        {
            var idItem = FMapper.Model as IIDItem;

            if (idItem == null)
            {
                yield break;
            }

            var commandHistory = idItem.Mapper.Map <ICommandHistory>();

            // IPersistent objects must be loaded before they can be edited.
            var persistent = idItem as IPersistent;

            if (persistent != null && !persistent.IsLoaded)
            {
                yield return(new LoadMenuEntry(commandHistory, persistent, FLogger));

                yield break;
            }

            if (FMapper.CanMap <AddMenuEntry>())
            {
                var addMenuEntry = FMapper.Map <AddMenuEntry>();
                if (addMenuEntry.HasSubMenuEntries)
                {
                    yield return(addMenuEntry);

                    yield return(new MenuSeparator());
                }
            }

            yield return(new UndoMenuEntry(commandHistory));

            yield return(new RedoMenuEntry(commandHistory));

            yield return(new MenuSeparator());

            if (FMapper.CanMap <IRenameable>())
            {
                var renameable = FMapper.Map <IRenameable>();
                if (FMapper.CanMap <ILabelEditor>())
                {
                    yield return(new RenameMenuEntry(commandHistory, renameable, FMapper.Map <ILabelEditor>()));
                }
                else
                {
                    yield return(new RenameMenuEntry(commandHistory, renameable));
                }
                yield return(new MenuSeparator());
            }

            if (FMapper.CanMap <IEditableProperty>())
            {
                var renameable = FMapper.Map <IEditableProperty>();
                yield return(new SetPropertyMenuEntry(commandHistory, renameable));

                yield return(new MenuSeparator());
            }

            if (idItem.Owner is IEditableIDList)
            {
                var owner = idItem.Owner as IEditableIDList;
                commandHistory = idItem.Owner.Mapper.Map <ICommandHistory>();

                if (owner.CanRemove(idItem))
                {
                    yield return(new RemoveMenuEntry <IEditableIDList, IIDItem>(commandHistory, owner, idItem));
                }
            }

            if (persistent != null)
            {
                yield return(new MenuSeparator());

                yield return(new UnloadMenuEntry(commandHistory, persistent, FLogger));
            }
        }