示例#1
0
 public IModelMapper CreateChildMapper(object model)
 {
     if (FMapper == null)
     {
         return(new LazyModelMapper(model));
     }
     return(FMapper.CreateChildMapper(model));
 }
示例#2
0
        object CreateRow(object entry)
        {
            var row = new DataGridViewRow();

            var childMapper = FMapper.CreateChildMapper(entry);

            if (childMapper.CanMap <IEnumerable <ICell> >())
            {
                row.Tag = entry;

                var cells = childMapper.Map <IEnumerable <ICell> >();

                int cellCount = 0;
                foreach (var cell in cells)
                {
                    var gridViewCell = CreateGridViewCell(cell);

                    cell.ValueChanged += HandleCellValueChanged;

                    if (cell.WrapContent)
                    {
                        gridViewCell.Style.WrapMode = DataGridViewTriState.True;
                    }

                    gridViewCell.Value = cell.Value;

                    row.Cells.Add(gridViewCell);

                    // Following properties can only be set after cell has been added to a row.
                    gridViewCell.ReadOnly = cell.ReadOnly;
                    gridViewCell.Tag      = cell;

                    cellCount++;
                }

                if (row.Cells.Count > 0)
                {
                    return(row);
                }
            }

            var emptyGridViewCell = new DataGridViewTextBoxCell();

            emptyGridViewCell.Value = entry.ToString();
            row.Tag = entry;
            row.Cells.Add(emptyGridViewCell);

            return(row);
        }
示例#3
0
 protected void InitializeForReal(IModelMapper parentMapper)
 {
     FMapper = parentMapper.CreateChildMapper(Model);
     foreach (var mapping in FInstanceMappings)
     {
         FMapper.RegisterMapping(mapping.Key, mapping.Value);
     }
     foreach (var mapping in FDefaultInstanceMappings)
     {
         FMapper.RegisterDefault(mapping.Key, mapping.Value);
     }
     foreach (var mapping in FTypeMappings)
     {
         FMapper.RegisterMapping(mapping[0], mapping[1], mapping[2]);
     }
     OnInitialized();
 }
示例#4
0
        public ProjectViewProvider(IProject project, IModelMapper 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);
            }

            FProject.Loaded   += HandleProjectLoaded;
            FProject.Unloaded += HandleProjectUnloaded;

            // 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;

            // Keep us in sync with the root folder.
            FRootFolder.Added        += FRootFolder_Added;
            FRootFolder.Removed      += FRootFolder_Removed;
            FRootFolder.OrderChanged += FRootFolder_OrderChanged;
        }
示例#5
0
        public override void Reload()
        {
            FTreeView.BeginUpdate();

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

            FRootMapper = new ModelMapper(Input, Registry);

            if (ShowRoot)
            {
                var rootNode = new MapperTreeNode(FRootMapper);
                rootNode.Expand();
                FTreeView.Nodes.Add(rootNode);
            }
            else
            {
                var items = FRootMapper.Map <IParent>();
                if (FSynchronizer != null)
                {
                    FSynchronizer.Dispose();
                }
                FSynchronizer = FTreeView.Nodes.SyncWith(items.Childs, item => new MapperTreeNode(FRootMapper.CreateChildMapper(item)));
            }

            FTreeView.EndUpdate();
        }
示例#6
0
        public MapperTreeNode CreateChildNode(object item)
        {
            var mapper = Mapper.CreateChildMapper(item);

            return(new MapperTreeNode(mapper));
        }