protected override void OnMeasureItem(MeasureItemEventArgs e) { base.OnMeasureItem(e); if (e.Index < 0) { return; } if (Items.Count == 0) { return; } object listItem = this.Items[e.Index]; if (listItem == null) { return; } ListItemViewControl listItemRenderer = GetRenderer(listItem); listItemRenderer.Item = listItem; listItemRenderer.UpdateView(); listItemRenderer.TabStop = false; listItemRenderer.Parent = this; listItemRenderer.Top = -2000; listItemRenderer.PerformAutoScale(); e.ItemHeight = listItemRenderer.Height; e.ItemWidth = listItemRenderer.Width; }
protected override void OnSelectedIndexChanged(EventArgs e) { try { if (this.SelectedIndex < 0) { return; } object selectedItem = Items[this.SelectedIndex]; if (selectedItem == null) { return; } SelectedItemViewControl = Activator.CreateInstance(GetDetailViewType(selectedItem.GetType())) as ListItemViewControl; SelectedItemViewControl.ServiceProvider = this.serviceProvider; SelectedItemViewControl.Item = selectedItem; SelectedItemViewControl.DrawItemState = DrawItemState.Selected; SelectedItemViewControl.ItemChanged += new EventHandler(SelectedItemDetailViewControlItemChanged); SelectedItemViewControl.UpdateView(); if (Editable) { if (activeItemViewControl != null) { this.Controls.Remove(activeItemViewControl); } if (selectedItem != null) { activeItemViewControl = Activator.CreateInstance(GetItemViewType(selectedItem.GetType())) as ListItemViewControl; if (itemLocations.ContainsKey(selectedItem)) { activeItemDetailViewControl.Location = itemLocations[selectedItem]; } activeItemViewControl.DrawItemState = DrawItemState.Selected; activeItemViewControl.UpdateView(); activeItemViewControl.Item = selectedItem; this.Controls.Add(activeItemViewControl); } } } catch (Exception exception) { DesignerHelpers.ShowMessage(serviceProvider, exception.Message, DR.GetString(DR.WorkflowDesignerTitle), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); throw; } base.OnSelectedIndexChanged(e); }
protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Index < 0) { return; } if (Items.Count < 1) { return; } object itemToDraw = Items[e.Index]; if (itemToDraw == null) { return; } ListItemViewControl listItemRenderer = GetRenderer(itemToDraw); listItemRenderer.DrawItemState = e.State; if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { if (Editable) { if (activeItemViewControl != null) { activeItemViewControl.Location = e.Bounds.Location; activeItemViewControl.DrawItemState = e.State; } } } listItemRenderer.Item = itemToDraw; listItemRenderer.UpdateView(); listItemRenderer.TabStop = false; listItemRenderer.Parent = this; listItemRenderer.Top = -2000; Bitmap rendererBitmap = GetRendererBitmap(itemToDraw); itemLocations[itemToDraw] = e.Bounds.Location; listItemRenderer.DrawToBitmap(rendererBitmap, new Rectangle(new Point(0, 0), listItemRenderer.Size)); e.Graphics.DrawImage(rendererBitmap, e.Bounds.Location); }