public ThingPropertyPages(Things.IThing T)
 {
     this.InitializeComponent();
     // Use the dummy page to get size deltas, then discard it
     this.DeltaW = this.Width - this.tabDummy.Width;
     this.DeltaH = this.Height - this.tabDummy.Height;
     this.tabPages.TabPages.Clear();
     this.tabDummy.Dispose();
     this.tabDummy = null;
     // Add pages as needed
     foreach (PropertyPages.IThing P in T.GetPropertyPages())
     {
         P.Left = 0;
         P.Top  = 0;
         if (this.tabPages.TabPages.Count == 0)
         {
             // Resize to match the first page (even if not fixed-size)
             this.Width  = P.Width + this.DeltaW;
             this.Height = P.Height + this.DeltaH;
         }
         if (!P.IsFixedSize)
         {
             P.Dock = DockStyle.Fill;
         }
         TabPage TP = new ThemedTabPage(P.TabName);
         TP.UseVisualStyleBackColor = true;
         TP.Controls.Add(P);
         TP.Tag = P;
         this.tabPages.TabPages.Add(TP);
     }
     this.AdjustSize();
 }
Beispiel #2
0
 public Thing(Things.IThing T)
 {
     InitializeComponent();
     this.picIcon.Image    = T.GetIcon() ?? Icons.POLViewer.ToBitmap();
     this.lblText.Text     = T.ToString();
     this.lblTypeName.Text = T.TypeName;
     this.AddFieldEntries(T);
 }
Beispiel #3
0
 private void lstFields_ItemActivate(object sender, EventArgs e)
 {
     if (this.lstFields.SelectedItems != null && this.lstFields.SelectedItems.Count > 0)
     {
         Things.IThing T = this.lstFields.SelectedItems[0].Tag as Things.IThing;
         if (T != null)
         {
             using (ThingPropertyPages TPP = new ThingPropertyPages(T))
                 TPP.ShowDialog(this);
         }
     }
 }
Beispiel #4
0
        private void AddFieldEntries(Things.IThing T)
        {
            List <String> AllFields = T.GetAllFields();

            foreach (string FieldName in AllFields)
            {
                if (T.HasField(FieldName))
                {
                    object V = T.GetFieldValue(FieldName);
                    if (V is string && (V as string).Contains("\n"))
                    {
                        int LineCount = 0;
                        foreach (string Line in (V as string).Split('\n'))
                        {
                            ListViewItem LVI = this.lstFields.Items.Add(String.Format("{0} [{1}]", FieldName, ++LineCount));
                            LVI.Tag = Line;
                            LVI.SubItems.Add(Line);
                        }
                    }
                    else
                    {
                        ListViewItem LVI = this.lstFields.Items.Add(FieldName);
                        LVI.Tag = V;
                        LVI.SubItems.Add(T.GetFieldText(FieldName));
                        if (V is Things.IThing)
                        {
                            LVI.Font = new Font(LVI.Font, FontStyle.Underline);
                        }
                    }
                }
                else
                {
                    this.lstFields.Items.Add(FieldName).ForeColor = SystemColors.GrayText;
                }
            }
        }