コード例 #1
0
        private IList <InterfaceDescriptionEditorItem> GetViewItemsFromInterfaceDescription(IoDescription interfaceDescription)
        {
            if (interfaceDescription == null)
            {
                return(null);
            }
            List <InterfaceDescriptionEditorItem> items = new List <InterfaceDescriptionEditorItem>();

            int rowCounter = 0;

            while (rowCounter < interfaceDescription.Size)
            {
                InterfaceDescriptionEditorItem editorItem = new InterfaceDescriptionEditorItem();
                IoDescriptionItem descItem = interfaceDescription.GetItemAtAddress(rowCounter);
                if (descItem != null)
                {
                    editorItem.Row         = descItem.Address;
                    editorItem.RowSpan     = descItem.Size;
                    editorItem.Column      = 0;
                    editorItem.ColSpan     = 8;
                    editorItem.Text        = descItem.Name;
                    editorItem.IsEmptyItem = false;
                }
                else
                {
                    editorItem.Row     = rowCounter;
                    editorItem.RowSpan = 1;
                    editorItem.Column  = 0;
                    editorItem.ColSpan = 8;
                }
                items.Add(editorItem);
                rowCounter += editorItem.RowSpan;
            }
            return(items);
        }
コード例 #2
0
        private SortedList <int, ItemRectContainer> CreateItemRectangles(IoDescription ioDesc)
        {
            lock (syncLock)
            {
                SortedList <int, ItemRectContainer> rectList = new SortedList <int, ItemRectContainer>();
                ItemRectContainer rectContainer;
                int size;

                if (ioDesc == null || ioDesc.Size <= 0)
                {
                    return(rectList);
                }

                for (int address = 0, index = 0; address < ioDesc.Size; address++, index++)
                {
                    IoDescriptionItem item = ioDesc.GetItemAtAddress(address);
                    if (item == null)
                    {
                        size = 1;
                    }
                    else
                    {
                        size = item.Size;
                    }

                    Rectangle rect = new Rectangle(
                        vericalSpacerSize,
                        (address * byteHeight) + (index) /*+ horizontalSpacerSize*/,
                        byteWidth,
                        (byteHeight * size));

                    rectContainer          = new ItemRectContainer();
                    rectContainer.Item     = item;
                    rectContainer.ItemRect = rect;
                    rectContainer.Index    = index;
                    rectContainer.Address  = address;

                    rectList.Add(rect.Top, rectContainer);
                    address += (size - 1);
                }
                ItemRectContainer sel = null;

                if (selectedItemRects.Count == 1)
                {
                    if (selectedItemRects[0].Item != null)
                    {
                        sel = rectList.Values.FirstOrDefault(x => x.Item == selectedItemRects[0].Item);
                    }
                    else
                    {
                        sel = rectList.Values.FirstOrDefault(x => x.Address == selectedItemRects[0].Address);
                    }
                }

                this.selectedItemRects.Clear();

                if (sel != null)
                {
                    this.selectedItemRects.Add(sel);
                }

                return(rectList);
            }
        }