/// <summary>
        /// Returns the listview for a given section. If it does not exist yet it gets created.
        /// Optionally a simple panel is added as header for this section.
        /// </summary>
        private ListView GetSectionListview(NodeIdWrapper controlNodeId, CollapsingPanel overviewPanel, bool addSectionHeader,
            Overview.DisplayMode displayMode, String caption, String info)
        {
            // Iterate over all sections we have already and find the one with the given control id.
              String objectId = wbOverview.get_node_unique_id(controlNodeId);
              foreach (Control control in overviewPanel.Controls)
              {
            if (control.Tag != null)
            {
              String currentObjectId = (control.Tag as Identifier).objectId;
              if (currentObjectId != null && currentObjectId == objectId)
              {
            ListView listview = control as ListView;
            SetViewMode(listview, displayMode);
            return listview;
              }
            }
              }

              // If we come here then the section does not exist yet, so add it. Start with a header.
              if (addSectionHeader)
              {
            Panel panel = new Panel();
            panel.BorderStyle = BorderStyle.None;
            panel.Padding = new Padding(5, 2, 5, 0);
            panel.BackgroundImage = Resources.header_bar_blue;
            panel.BackgroundImageLayout = ImageLayout.None;

            panel.Height = 24;

            // Insert client controls in reverse order.
            // Info label.
            Label infoLabel = new Label();
            infoLabel.Text = info;
            infoLabel.ForeColor = Color.Gray;
            infoLabel.Font = overviewPanel.Font;
            infoLabel.AutoSize = true;
            infoLabel.Margin = new Padding(10, 0, 0, 0);
            infoLabel.Dock = DockStyle.Left;
            panel.Controls.Add(infoLabel);

            overviewPanel.Controls.Add(panel);

            // Caption label.
            Label captionLabel = new Label();
            captionLabel.Text = caption;
            //captionLabel.Font = new Font(overviewPanel.Font, FontStyle.Bold);
            captionLabel.AutoSize = true;
            captionLabel.Dock = DockStyle.Left;
            captionLabel.ForeColor = Color.Black;
            panel.Controls.Add(captionLabel);

            overviewPanel.Controls.Add(panel);
              }

              // Then the content view.
              ListView sectionListview = new ListView();
              sectionListview.BorderStyle = BorderStyle.None;
              sectionListview.AllowColumnReorder = true;
              sectionListview.ShowItemToolTips = true;

              // Undocumented feature: enabling AutoSize will indeed make the control automatically resize
              // (the docs say it wouldn't) though without considering long captions. For them to work
              // additionally Scrollable can be set to true to show a scrollbar, but only in this special case.
              sectionListview.AutoSize = true;
              sectionListview.MultiSelect = false;
              sectionListview.Scrollable = true;
              sectionListview.Visible = true;
              sectionListview.Font = overviewPanel.Font;
              sectionListview.Tag = CreateIdentifier(controlNodeId);
              sectionListview.Sorting = SortOrder.None; // We do custom sort.

              sectionListview.DoubleClick += new EventHandler(listViewDoubleClick);
              sectionListview.ItemDrag += new ItemDragEventHandler(listViewItemDrag);
              sectionListview.SelectedIndexChanged += new EventHandler(listViewSelectedIndexChanged);
              sectionListview.KeyDown += new KeyEventHandler(listViewKeyDown);
              sectionListview.MouseUp += new MouseEventHandler(listViewMouseUp);
              sectionListview.ColumnClick += new ColumnClickEventHandler(ListviewColumnClick);
              sectionListview.Enter += new EventHandler(ListViewEnter);

              // Renaming of overview nodes
              sectionListview.LabelEdit = true;
              sectionListview.AfterLabelEdit += new LabelEditEventHandler(listViewAfterLabelEdit);
              sectionListview.BeforeLabelEdit += new LabelEditEventHandler(listViewBeforeLabelEdit);

              // Add it to the panel. Usually the layout engine of the panel should take care for
              // the layout of the controls, but just to be sure we set here a dock style.
              overviewPanel.Controls.Add(sectionListview);
              sectionListview.Dock = DockStyle.Top;

              // Set Image Lists
              sectionListview.SmallImageList = IconManagerWrapper.ImageList16;
              sectionListview.LargeImageList = IconManagerWrapper.ImageList48;

              SetViewMode(sectionListview, displayMode);

              sectionListview.Update();
              return sectionListview;
        }
Example #2
0
        private void InitProcessListView(ref ListView TargetListView)
        {
            TargetListView.FullRowSelect = true;
            AddListViewColumns(ref TargetListView);

            TargetListView.Update();
            TargetListView.View = View.Details;
            AddProcessInfo(ref TargetListView);

            TargetListView.EndUpdate();
        }
Example #3
0
        private void ResizeColumns(ListView lvSource)
        {
            int iTotWidth = lvSource.Width;

            lvSource.BeginUpdate();
            lvDetails.Columns[0].Width = lvDetails.Width / 2;
            lvDetails.Columns[1].Width = lvDetails.Width / 2;
            lvSource.EndUpdate();
            lvSource.Update();
        }
 private void UpdateListView(ListView view, ListViewItem item)
 {
     if (view.InvokeRequired)
     {
         view.BeginInvoke(new Action<ListView, ListViewItem>(UpdateListView), view, item);
     }
     else
     {
         view.Items.Add(item);
         if (view.Items.Count > 10)
             view.TopItem = view.Items[view.Items.Count - 10];
         view.Update();
         view.Parent.Update();
     }
 }
Example #5
0
 private void AddItemToListView(ListView lv, ListViewItem lvItem)
 {
     // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
     // If these threads are different, it returns true.
     if (this.labelStatus.InvokeRequired)
     {
         AddItemToListViewCallback d = new AddItemToListViewCallback(AddItemToListView);
         this.Invoke(d, new object[] { lv, lvItem });
     }
     else
     {
         lv.Items.Add(lvItem);
         lv.Update();
     }
 }