Beispiel #1
0
        private void GraphItemList_DrawItem(object sender, DrawListViewItemEventArgs e)
        {
            GXGraphItem item = GraphItemList.Items[e.ItemIndex].Tag as GXGraphItem;

            if (item.Enabled)
            {
                // Draw the background for an unselected item.
                using (SolidBrush brush = new SolidBrush(item.Color))
                {
                    e.Graphics.FillRectangle(brush, e.Bounds.Left + 5, e.Bounds.Top + 1, 15, 15);
                }
            }
            else
            {
                e.Graphics.DrawImage(GraphItemList.SmallImageList.Images[0], e.Bounds.Left + 5, e.Bounds.Top + 1, 15, 15);
            }
            e.DrawDefault = true;
        }
Beispiel #2
0
        public GXGraphItemForm(GXGraphItemCollection items, List <GXKeyValuePair <GXDLMSObject, GXDLMSCaptureObject> > columns, GXDLMSDevice device)
        {
            InitializeComponent();
            GraphItemEditor_SizeChanged(null, null);
            GraphItemList.OwnerDraw = true;
            Items = items;
            int            pos    = 0;
            List <string>  colors = GetColors();
            GXManufacturer man    = device.Manufacturers.FindByIdentification(device.Manufacturer);

            foreach (var it in columns)
            {
                GXDLMSObject obj   = it.Key;
                int          index = it.Value.AttributeIndex;
                if (!GXHelpers.IsNumeric(obj.GetDataType(index)) || (index > 0 && ((index & 0x8) != 0 || (index & 0x10) != 0)))
                {
                    continue;
                }
                GXGraphItem item = items.Find(obj.LogicalName, index);
                if (item == null)
                {
                    item                = new GXGraphItem();
                    item.LogicalName    = obj.LogicalName;
                    item.Color          = Color.FromName(colors[pos++]);
                    item.AttributeIndex = index;
                    items.Add(item);
                }
                string     desc = obj.Description;
                GXObisCode code = man.ObisCodes.FindByLN(obj.ObjectType, obj.LogicalName, null);
                if (code != null)
                {
                    desc = code.Description;
                }
                ListViewItem tmp = GraphItemList.Items.Add(obj.LogicalName + " " + desc);
                tmp.Tag = item;
            }
        }
 public GXGraphItemForm(GXGraphItemCollection items, List<GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject>> columns, GXDLMSDevice device)
 {
     InitializeComponent();
     GraphItemEditor_SizeChanged(null, null);
     GraphItemList.OwnerDraw = true;
     Items = items;
     int pos = 0;
     List<string> colors = GetColors();
     GXManufacturer man = device.Manufacturers.FindByIdentification(device.Manufacturer);
     foreach (var it in columns)
     {
         GXDLMSObject obj = it.Key;
         int index = it.Value.AttributeIndex;
         if (!GXHelpers.IsNumeric(obj.GetDataType(index)) || (index > 0 && ((index & 0x8) != 0 || (index & 0x10) != 0)))
         {
             continue;
         }
         GXGraphItem item = items.Find(obj.LogicalName, index);
         if (item == null)
         {
             item = new GXGraphItem();
             item.LogicalName = obj.LogicalName;
             item.Color = Color.FromName(colors[pos++]);
             item.AttributeIndex = index;
             items.Add(item);
         }
         string desc = obj.Description;
         GXObisCode code = man.ObisCodes.FindByLN(obj.ObjectType, obj.LogicalName, null);
         if (code != null)
         {
             desc = code.Description;
         }
         ListViewItem tmp = GraphItemList.Items.Add(obj.LogicalName + " " + desc);
         tmp.Tag = item;
     }
 }