Exemple #1
0
        public static int AddItemToGroup(XPListView lst, int index, int groupID)
        {
            LVITEM apiItem;
            int    ptrRetVal;

            try
            {
                if (lst == null)
                {
                    return(0);
                }

                apiItem          = new LVITEM();
                apiItem.mask     = LVIF_GROUPID;
                apiItem.iItem    = index;
                apiItem.iGroupId = groupID;

                ptrRetVal = (int)SendMessage(lst.Handle, ListViewAPI.LVM_SETITEM, 0, ref apiItem);

                return(ptrRetVal);
            }
            catch (Exception ex)
            {
                throw new System.Exception("An exception in ListViewAPI.AddItemToGroup occured: " + ex.Message);
            }
        }
Exemple #2
0
        public static int AddListViewGroup(XPListView lst, string text, int index)
        {
            LVGROUP apiGroup;
            int     ptrRetVal;

            try
            {
                if (lst == null)
                {
                    return(-1);
                }

                apiGroup           = new LVGROUP();
                apiGroup.mask      = LVGF_GROUPID | LVGF_HEADER | LVGF_STATE;
                apiGroup.pszHeader = text;
                apiGroup.cchHeader = apiGroup.pszHeader.Length;
                apiGroup.iGroupId  = index;
                apiGroup.stateMask = LVGS_NORMAL;
                apiGroup.state     = LVGS_NORMAL;
                apiGroup.cbSize    = Marshal.SizeOf(typeof(LVGROUP));

                ptrRetVal = (int)SendMessage(lst.Handle, ListViewAPI.LVM_INSERTGROUP, -1, ref apiGroup);
                return(ptrRetVal);
            }
            catch (Exception ex)
            {
                throw new System.Exception("An exception in ListViewAPI.AddListViewGroup occured: " + ex.Message);
            }
        }
Exemple #3
0
        public static void RedrawItems(XPListView lst, bool update)
        {
            int ptrRetVal;

            try
            {
                if (lst != null)
                {
                    return;
                }

                int param = lst.Items.Count - 1;
                ptrRetVal = (int)SendMessage(lst.Handle, LVM_REDRAWITEMS, 0, ref param);

                if (update)
                {
                    UpdateItems(lst);
                }

                lst.Refresh();
            }
            catch (Exception ex)
            {
                throw new System.Exception("An exception in ListViewAPI.RedrawItems occured: " + ex.Message);
            }
        }
Exemple #4
0
        public static void SetListViewImage(XPListView lst, string ImagePath, ImagePosition Position)
        {
            int x = 0;
            int y = 0;

            GetImageLocation(Position, ref x, ref y);

            try
            {
                LVBKIMAGE apiItem = new LVBKIMAGE();
                apiItem.pszImage       = ImagePath + Convert.ToChar(0);
                apiItem.cchImageMax    = ImagePath.Length;
                apiItem.ulFlags        = LVBKIF_SOURCE_URL | LVBKIF_STYLE_NORMAL;
                apiItem.xOffsetPercent = x;
                apiItem.yOffsetPercent = y;

                // Set the background colour of the ListView to 0XFFFFFFFF (-1) so it will be transparent
                int clear = CLR_NONE;
                SendMessage(lst.Handle, LVM_SETTEXTBKCOLOR, 0, ref clear);

                SendMessage(lst.Handle, LVM_SETBKIMAGE, 0, ref apiItem);
            }
            catch (Exception ex)
            {
                throw new System.Exception("An exception in ListViewAPI.SetListViewImage occured: " + ex.Message);
            }
        }
Exemple #5
0
        public static void ClearListViewGroup(XPListView lst)
        {
            int ptrRetVal;

            try
            {
                if (lst == null)
                {
                    return;
                }

                int param = 0;
                ptrRetVal = (int)SendMessage(lst.Handle, LVM_REMOVEALLGROUPS, 0, ref param);
            }
            catch (Exception ex)
            {
                throw new System.Exception("An exception in ListViewAPI.ClearListViewGroup occured: " + ex.Message);
            }
        }
Exemple #6
0
        public static int RemoveListViewGroup(XPListView lst, int index)
        {
            int ptrRetVal;

            try
            {
                if (lst != null)
                {
                    return(-1);
                }

                int param = 0;
                ptrRetVal = (int)SendMessage(lst.Handle, LVM_REMOVEGROUP, index, ref param);

                return(ptrRetVal);
            }
            catch (Exception ex)
            {
                throw new System.Exception("An exception in ListViewAPI.RemoveListViewGroup occured: " + ex.Message);
            }
        }
Exemple #7
0
        public static void UpdateItems(XPListView lst)
        {
            int ptrRetVal;

            try
            {
                if (lst != null)
                {
                    return;
                }

                for (int i = 0; i < lst.Items.Count - 1; i++)
                {
                    int param = 0;
                    ptrRetVal = (int)SendMessage(lst.Handle, LVM_UPDATE, i, ref param);
                }
            }
            catch (Exception ex)
            {
                throw new System.Exception("An exception in ListViewAPI.UpdateItems occured: " + ex.Message);
            }
        }
 public XPListViewItemCollection(XPListView owner) : base(((ListView)owner)) {}
 public XPListViewGroupCollection(XPListView owner)
 {
     _owner = owner;
 }
Exemple #10
0
    public static int AddListViewGroup(XPListView lst, string text, int index)
    {
      LVGROUP apiGroup;
      int ptrRetVal;

      try
      {
        if (lst == null)
        {
          return -1;
        }

        apiGroup = new LVGROUP();
        apiGroup.mask = LVGF_GROUPID | LVGF_HEADER | LVGF_STATE;
        apiGroup.pszHeader = text;
        apiGroup.cchHeader = apiGroup.pszHeader.Length;
        apiGroup.iGroupId = index;
        apiGroup.stateMask = LVGS_NORMAL;
        apiGroup.state = LVGS_NORMAL;
        apiGroup.cbSize = Marshal.SizeOf(typeof (LVGROUP));

        ptrRetVal = (int)SendMessage(lst.Handle, ListViewAPI.LVM_INSERTGROUP, -1, ref apiGroup);
        return ptrRetVal;
      }
      catch (Exception ex)
      {
        throw new System.Exception("An exception in ListViewAPI.AddListViewGroup occured: " + ex.Message);
      }
    }
Exemple #11
0
 public XPListViewItemCollection(XPListView owner) : base(((ListView)owner))
 {
 }
Exemple #12
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
   this.components = new System.ComponentModel.Container();
   this.imageList = new System.Windows.Forms.ImageList(this.components);
   this.buttonStart = new System.Windows.Forms.Button();
   this.buttonTest = new System.Windows.Forms.Button();
   this.timerLearn = new System.Windows.Forms.Timer(this.components);
   this.propertyGrid = new System.Windows.Forms.PropertyGrid();
   this.listButtons = new XPListview.XPListView();
   this.columnButton = new System.Windows.Forms.ColumnHeader();
   this.SuspendLayout();
   // 
   // imageList
   // 
   this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
   this.imageList.ImageSize = new System.Drawing.Size(16, 16);
   this.imageList.TransparentColor = System.Drawing.Color.Transparent;
   // 
   // buttonStart
   // 
   this.buttonStart.Anchor =
     ((System.Windows.Forms.AnchorStyles)
      ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
   this.buttonStart.Location = new System.Drawing.Point(8, 392);
   this.buttonStart.Name = "buttonStart";
   this.buttonStart.Size = new System.Drawing.Size(75, 23);
   this.buttonStart.TabIndex = 1;
   this.buttonStart.Text = "&Learn";
   this.buttonStart.Click += new System.EventHandler(this.buttonStart_Click);
   // 
   // buttonTest
   // 
   this.buttonTest.Anchor =
     ((System.Windows.Forms.AnchorStyles)
      ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
   this.buttonTest.Location = new System.Drawing.Point(144, 392);
   this.buttonTest.Name = "buttonTest";
   this.buttonTest.Size = new System.Drawing.Size(75, 23);
   this.buttonTest.TabIndex = 6;
   this.buttonTest.Text = "&Test";
   this.buttonTest.Click += new System.EventHandler(this.buttonTest_Click);
   // 
   // timerLearn
   // 
   this.timerLearn.Interval = 1000;
   this.timerLearn.Tick += new System.EventHandler(this.timerLearn_Tick);
   // 
   // propertyGrid
   // 
   this.propertyGrid.Anchor =
     ((System.Windows.Forms.AnchorStyles)
      (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
        | System.Windows.Forms.AnchorStyles.Right)));
   this.propertyGrid.LineColor = System.Drawing.SystemColors.ScrollBar;
   this.propertyGrid.Location = new System.Drawing.Point(224, 8);
   this.propertyGrid.Name = "propertyGrid";
   this.propertyGrid.PropertySort = System.Windows.Forms.PropertySort.Categorized;
   this.propertyGrid.Size = new System.Drawing.Size(368, 408);
   this.propertyGrid.TabIndex = 9;
   this.propertyGrid.ToolbarVisible = false;
   this.propertyGrid.PropertyValueChanged +=
     new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGrid_PropertyValueChanged);
   // 
   // listButtons
   // 
   this.listButtons.Anchor =
     ((System.Windows.Forms.AnchorStyles)
      ((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
         | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
   this.listButtons.Columns.AddRange(new System.Windows.Forms.ColumnHeader[]
                                       {
                                         this.columnButton
                                       });
   this.listButtons.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
   this.listButtons.HideSelection = false;
   this.listButtons.LabelEdit = true;
   this.listButtons.Location = new System.Drawing.Point(8, 8);
   this.listButtons.MultiSelect = false;
   this.listButtons.Name = "listButtons";
   this.listButtons.Size = new System.Drawing.Size(208, 376);
   this.listButtons.SmallImageList = this.imageList;
   this.listButtons.TabIndex = 0;
   this.listButtons.UseCompatibleStateImageBehavior = false;
   this.listButtons.View = System.Windows.Forms.View.Details;
   this.listButtons.DoubleClick += new System.EventHandler(this.listButtons_DoubleClick);
   this.listButtons.SelectedIndexChanged += new System.EventHandler(this.listButtons_SelectedIndexChanged);
   // 
   // columnButton
   // 
   this.columnButton.Text = "Button";
   this.columnButton.Width = 175;
   // 
   // Form1
   // 
   this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
   this.ClientSize = new System.Drawing.Size(600, 421);
   this.Controls.Add(this.listButtons);
   this.Controls.Add(this.propertyGrid);
   this.Controls.Add(this.buttonTest);
   this.Controls.Add(this.buttonStart);
   this.Name = "Form1";
   this.Text = "ServerBlaster Learn";
   this.Load += new System.EventHandler(this.Form1_Load);
   this.ResumeLayout(false);
 }
Exemple #13
0
    public static void SetListViewImage(XPListView lst, string ImagePath, int XTileOffsetPercent, int YTileOffsetPercent)
    {
      try
      {
        LVBKIMAGE apiItem = new LVBKIMAGE();
        apiItem.pszImage = ImagePath + Convert.ToChar(0);
        apiItem.cchImageMax = ImagePath.Length;
        apiItem.ulFlags = LVBKIF_SOURCE_URL | LVBKIF_STYLE_TILE;
        apiItem.xOffsetPercent = XTileOffsetPercent;
        apiItem.yOffsetPercent = YTileOffsetPercent;

        // Set the background colour of the ListView to 0XFFFFFFFF (-1) so it will be transparent
        int clear = CLR_NONE;
        SendMessage(lst.Handle, LVM_SETTEXTBKCOLOR, 0, ref clear);

        SendMessage(lst.Handle, LVM_SETBKIMAGE, 0, ref apiItem);
      }
      catch (Exception ex)
      {
        throw new System.Exception("An exception in ListViewAPI.SetListViewImage occured: " + ex.Message);
      }
    }
Exemple #14
0
    public static void UpdateItems(XPListView lst)
    {
      int ptrRetVal;

      try
      {
        if (lst != null)
        {
          return;
        }

        for (int i = 0; i < lst.Items.Count - 1; i++)
        {
          int param = 0;
          ptrRetVal = (int)SendMessage(lst.Handle, LVM_UPDATE, i, ref param);
        }
      }
      catch (Exception ex)
      {
        throw new System.Exception("An exception in ListViewAPI.UpdateItems occured: " + ex.Message);
      }
    }
Exemple #15
0
    public static void RedrawItems(XPListView lst, bool update)
    {
      int ptrRetVal;

      try
      {
        if (lst != null)
        {
          return;
        }

        int param = lst.Items.Count - 1;
        ptrRetVal = (int)SendMessage(lst.Handle, LVM_REDRAWITEMS, 0, ref param);

        if (update)
        {
          UpdateItems(lst);
        }

        lst.Refresh();
      }
      catch (Exception ex)
      {
        throw new System.Exception("An exception in ListViewAPI.RedrawItems occured: " + ex.Message);
      }
    }
Exemple #16
0
    public static void ClearListViewGroup(XPListView lst)
    {
      int ptrRetVal;

      try
      {
        if (lst == null)
        {
          return;
        }

        int param = 0;
        ptrRetVal = (int)SendMessage(lst.Handle, LVM_REMOVEALLGROUPS, 0, ref param);
      }
      catch (Exception ex)
      {
        throw new System.Exception("An exception in ListViewAPI.ClearListViewGroup occured: " + ex.Message);
      }
    }
Exemple #17
0
    public static int RemoveListViewGroup(XPListView lst, int index)
    {
      int ptrRetVal;

      try
      {
        if (lst != null)
        {
          return -1;
        }

        int param = 0;
        ptrRetVal = (int)SendMessage(lst.Handle, LVM_REMOVEGROUP, index, ref param);

        return ptrRetVal;
      }
      catch (Exception ex)
      {
        throw new System.Exception("An exception in ListViewAPI.RemoveListViewGroup occured: " + ex.Message);
      }
    }
 public XPListViewGroupCollection(XPListView owner)
 {
   _owner = owner;
 }
Exemple #19
0
    public static int AddItemToGroup(XPListView lst, int index, int groupID)
    {
      LVITEM apiItem;
      int ptrRetVal;

      try
      {
        if (lst == null)
        {
          return 0;
        }

        apiItem = new LVITEM();
        apiItem.mask = LVIF_GROUPID;
        apiItem.iItem = index;
        apiItem.iGroupId = groupID;

        ptrRetVal = (int)SendMessage(lst.Handle, ListViewAPI.LVM_SETITEM, 0, ref apiItem);

        return ptrRetVal;
      }
      catch (Exception ex)
      {
        throw new System.Exception("An exception in ListViewAPI.AddItemToGroup occured: " + ex.Message);
      }
    }