public SPListItem AddItem(String text, Uri uri) { SPListItem c = new SPListItem(this.Parent); c.Text = text; c.Uri = uri; this.Children.Add(c); return c; }
public SPListItem AddItem(String text, Uri uri, Image icon) { SPListItem c = new SPListItem(this); c.Text = text; c.Uri = uri; c.Icon = icon; this.Items.Add(c); return c; }
public SPListItem AddItem(String text, Uri uri) { SPListItem c = new SPListItem(this); c.Text = text; c.Uri = uri; this.Items.Add(c); return c; }
private void touchItem(SPListItem Item, MouseEventArgs e, ref int level, ref int pos) { if (e.Y > pos && e.Y < pos + ItemHeight) { // If clicked on expander if (e.X < level + 17 && Item.Children.Count > 0) { Item.Expanded = !Item.Expanded; pos += ItemHeight; expanding = true; return; } Item.Touched = true; } pos += ItemHeight; // If has subitems draw them if (Item.Expanded) foreach (SPListItem subItem in Item.Children) { level += 16; touchItem(subItem, e, ref level, ref pos); level -= 16; } }
void SPListView_DragOver(object sender, DragEventArgs e) { BufferedGraphicsContext bgc = new BufferedGraphicsContext(); BufferedGraphics bg = bgc.Allocate(this.CreateGraphics(), new Rectangle(0, 0, this.Width, this.Height)); this.Draw(bg.Graphics); Point c = PointToClient(new Point(e.X, e.Y)); if (c.Y < (ItemHeight * 4)) { e.Effect = DragDropEffects.None; return; } else { e.Effect = DragDropEffects.All; } Point cPoint = PointToClient(new Point(e.X, e.Y)); HoveredElement = GetItemUnderCursor(cPoint); if ( HoveredElement != WinkElement && HoveredElement != null) if (winkTimer != null) { winkTimer.Stop(); winkTimer = null; } if (HoveredElement != null) { if (cPoint.Y > HoveredElement.AbsoluteY + 4 && cPoint.Y < HoveredElement.AbsoluteY + HoveredElement.Height - 4) { if(HoveredElement != null) try { if (HoveredElement.AppInstance.AllowsDrop(e.Data)) { WinkElement = HoveredElement; if (winkTimer == null) { winkTimer = new Timer(); winkTimer.Tick += winkTimer_Tick; winkTimer.Interval = 3000; winkTimer.Start(); } bg.Graphics.DrawRectangle(new Pen(Color.White), new Rectangle(0, HoveredElement.AbsoluteY, this.Width, HoveredElement.Height)); } } catch (Exception ex) { } } else { bg.Graphics.DrawLine(new Pen(Color.White), new Point(0, HoveredElement.AbsoluteY + HoveredElement.Height), new Point(this.Width, HoveredElement.AbsoluteY + HoveredElement.Height)); } } bg.Render(); }
/// <summary> /// Draw item and sub-Items /// </summary> /// <param name="Item"></param> /// <param name="pos"></param> /// <param name="level"></param> private void drawItem(Graphics g, SPListItem Item, ref int pos, ref int level) { Item.Draw(g, ref level, ref pos); // pos += 16; // If has subitems draw them #if(False) if (Item.Expanded) foreach (SPListItem subItem in Item.Children) { level += 16; drawItem(g, subItem, ref pos, ref level); level -= 16; if (Item.Selected) { // g.DrawImage(Properties.Resources.menu_selection, 0, pos, this.Width * 500, Properties.Resources.menu_selection.Height); g.FillRectangle(new SolidBrush(SelectedStyle.BackColor), new Rectangle(0, pos, this.Width * 500, 16)); foreColor = SelectedStyle.ForeColor; } else if (Item.Touched) { g.FillRectangle(new SolidBrush(Color.Gray), 0, pos, this.Width, ItemHeight); } else { g.DrawString(Item.Text, new Font("MS Sans Serif", 8), new SolidBrush(Color.FromArgb(10, 10, 10)), new Point(level + 32, pos + 3)); } g.DrawString(Item.Text, new Font("MS Sans Serif", 8), new SolidBrush(foreColor), new Point(level + 32, pos + 2)); if (Item.Icon != null) { g.DrawImage(Item.Icon, level + 16, pos + 1, 16, 16); } // If has subItems create expander if (Item.Children.Count > 0) { // Image expander = Item.Expanded ? Properties.Resources.ic_expander_open : Properties.Resources.ic_expander_closed; // g.DrawImage(expander, level, pos, 16, 16); } } #endif pos += ItemHeight; // If has subitems draw them if (Item.Expanded) foreach (SPListItem subItem in Item.Children) { level += 16; drawItem(g, subItem, ref pos, ref level); level -= 16; } }
private void deselectTouchItem(SPListItem item) { item.Touched = false; foreach (SPListItem subItem in item.Children) { deselectTouchItem(subItem); } }
private void checkItem(SPListItem Item, MouseEventArgs e, ref int level, ref int pos) { if (e.Y > pos && e.Y < pos + ItemHeight) { SelectedItemEventArgs args = new SelectedItemEventArgs(); args.Item = Item; if (ItemSelecting != null) ItemSelecting(this, args); if (!args.Cancel) { Item.Selected = true; if(this.ItemSelected != null) this.ItemSelected(this, args); } } pos += ItemHeight; // If has subitems draw them if (Item.Expanded) foreach (SPListItem subItem in Item.Children) { level += 16; checkItem(subItem, e, ref level, ref pos); level -= 16; } }
public SPListItem InsertItem(int pos, Uri uri, bool delivery) { SPListItem c = new SPListItem(this, uri.ToString()); this.Items.Insert(pos, c); if(!delivery) if (this.ItemInserted != null) { this.ItemInserted(this, new ItemInsertEventArgs() { Uri = uri, Position = pos }); } return c; }
public SPListItem AddItem(String text, Uri uri, Spider.SPListItem.ListIcon icon) { SPListItem c = new SPListItem(this); c.Text = text; c.Uri = uri; c.Icon = icon; this.Items.Add(c); this.Refresh(); return c; }
public SPListItem AddItem(String text, Uri uri, bool delivery) { SPListItem c = new SPListItem(this, uri.ToString(), text); c.Text = text; c.Uri = uri; this.Items.Add(c); this.Refresh(); return c; }
public SPListItem AddItem(int index, Uri uri) { SPListItem c = new SPListItem(this, uri.ToString()); this.Items.Insert(index, c); return c; }
public SPListItem AddItem(Uri uri, bool delivery) { SPListItem c = new SPListItem(this, uri.ToString()); this.Items.Add(c); if(!delivery) if (this.ItemInserted != null) { this.ItemInserted(this, new ItemInsertEventArgs() { Uri = uri, Position = -1}); } return c; }
/// <summary> /// Draw item and sub-Items /// </summary> /// <param name="Item"></param> /// <param name="pos"></param> /// <param name="level"></param> private void drawItem(Graphics g, SPListItem Item, ref int pos, ref int level) { Color foreColor = Item.CustomColor ? Item.Color : Program.Skin.ForegroundColor; if (Item.Text.StartsWith("#")) { foreColor = Color.FromArgb(150,150,150); g.DrawString(Item.Text.ToUpper().Replace("#", ""), new Font("MS Sans Serif", 8), new SolidBrush(Color.FromArgb(50,50,50)), new Point(4, pos + 0)); g.DrawString(Item.Text.ToUpper().Replace("#", ""), new Font("MS Sans Serif", 8), new SolidBrush(foreColor), new Point(4, pos + 1)); } else { if (Item.Selected) { g.DrawImage(Resources.menu_selection, 0, pos, this.Width * 500, Resources.menu_selection.Height); foreColor = Program.Skin.SelectedForeColor; } else if (Item.Touched) { g.FillRectangle(new SolidBrush(Color.Gray), 0, pos, this.Width, ItemHeight); } else { g.DrawString(Item.Text, new Font("MS Sans Serif", 8), new SolidBrush(Color.FromArgb(10, 10, 10)), new Point(level + 32, pos + 3)); } g.DrawString(Item.Text, new Font("MS Sans Serif", 8), new SolidBrush(foreColor), new Point(level+32, pos + 2)); if (Item.Icon != null) { g.DrawImage(Item.Icon, level+16, pos +1, 16, 16); } // If has subItems create expander if (Item.Children.Count > 0) { Image expander = Item.Expanded ? Resources.ic_expander_open : Resources.ic_expander_closed; g.DrawImage(expander, level, pos, 16, 16); } } pos += ItemHeight; // If has subitems draw them if(Item.Expanded) foreach (SPListItem subItem in Item.Children) { level += 16; drawItem(g, subItem, ref pos, ref level); level -= 16; } }
public SPListItem InsertItem(int pos, Uri uri) { SPListItem c = new SPListItem(this, uri.ToString()); this.Items.Insert(pos, c); return c; }
public SPListItem AddItem(Uri uri, bool unknown) { SPListItem c = new SPListItem(this, uri.ToString()); this.Items.Add(c); return c; }