📄 buddyselectiontree.cs
字号:
namespace Imps.Client.Pc.BizControls
{
using Imps.Client;
using Imps.Client.Core;
using Imps.Client.Pc.Theme;
using Imps.Utils;
using System;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows.Forms;
public class BuddySelectionTree : ContactTreeCtrl
{
private PaintTreeColumn _buddyCheckBoxCol;
private ImageList _chekStateList;
private PaintTreeColumn _groupCheckBoxCol;
private PaintTreeColumn _groupNameCol;
private PaintTreeColumn _onLineStatisticCol;
public event NodeAfterCheck NodeAferCheck;
public BuddySelectionTree()
{
Image input = ImpsResources.GetImage("Images.checkbox.png");
this._chekStateList = ThemeManager.GetImageList(input, 3, 1, false);
base._indent = 11;
base.KeyDown += new KeyEventHandler(this.BuddySelectionTree_KeyDown);
base.ShowPlusMinus = false;
}
public int AddBuddyGroup(BuddySelectionGroupNode gNode)
{
gNode.Owner = this;
return base.AddBuddyGroup(gNode);
}
public int AddBuddyNode(BuddySelectionGroupNode group, BuddySelectionBuddyNode buddy)
{
buddy.Owner = this;
TreeNode node = group;
buddy.NeedCaculate = true;
int num = 0;
if (node == null)
{
num = base.Nodes.Add((TreeNode) buddy);
}
else
{
TreeNode node2 = buddy;
node2.Tag = buddy.Tag;
num = node.Nodes.Add(node2);
}
base._nickNameTextCol = buddy.Columns[2];
base._moodPhraseTextCol = buddy.Columns[3];
ColumnCollection columns = base.ParseStringToColumnCollection(base._nickNameTextCol);
if (columns != null)
{
buddy.NickNameCols = columns;
base._nickNameCols = columns;
}
ColumnCollection columns2 = base.ParseStringToColumnCollection(base._moodPhraseTextCol);
if (columns2 != null)
{
buddy.MoodPhraseCols = columns2;
base._moodPhraseCols = columns2;
}
int nHeight = 1;
if (base._contactShowMode == ShowMode.SingleRow)
{
nHeight = 1;
}
else
{
nHeight = 2;
}
base.setItemHeight(base.Handle, buddy, nHeight);
base._modifyColumnRectTopOnly = false;
return num;
}
private void adjustColumnRect(Graphics g, PaintTreeNode paintNode, Rectangle bounds)
{
if (!(paintNode is BuddySelectionGroupNode))
{
base.adjustSingleRowColumnRectangles(g, paintNode as ContactBuddyNode, bounds);
}
}
private void BuddySelectionTree_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
this.NodeClick(base.SelectedNode);
}
}
private void CalculateColumnRect(Graphics g, PaintTreeNode paintNode, Rectangle bounds)
{
Rectangle checkBoxRectangle;
int top = bounds.Top;
int height = bounds.Height;
ContactBuddyNode buddyNode = paintNode as ContactBuddyNode;
if (buddyNode == null)
{
checkBoxRectangle = new Rectangle(0, 0, 0, 0);
checkBoxRectangle.X = bounds.Left;
checkBoxRectangle.Y = top + base._nDiagnosedY;
checkBoxRectangle = this.GetCheckBoxRectangle(new Point(checkBoxRectangle.X, checkBoxRectangle.Y));
this._groupCheckBoxCol.ColumnRec = checkBoxRectangle;
Rectangle rectangle2 = new Rectangle(this._groupCheckBoxCol.ColumnRec.Right, this._groupCheckBoxCol.ColumnRec.Top, 0, 0);
SizeF ef = g.MeasureString(this._groupNameCol.ColumnText, this._groupNameCol.ColumnFont);
rectangle2.Width = (int) Math.Ceiling((double) ef.Width);
if (rectangle2.Width > (base.ClientRectangle.Width - 0x24))
{
rectangle2.Width = base.ClientRectangle.Width - 0x24;
}
rectangle2.Height = height;
this._groupNameCol.ColumnRec = rectangle2;
checkBoxRectangle.X = this._groupNameCol.ColumnRec.Right;
checkBoxRectangle.Y = this._groupNameCol.ColumnRec.Top;
ef = g.MeasureString(this._onLineStatisticCol.ColumnText, this._onLineStatisticCol.ColumnFont);
checkBoxRectangle.Width = (int) Math.Ceiling((double) ef.Width);
if ((checkBoxRectangle.X + checkBoxRectangle.Width) > base.ClientRectangle.Width)
{
checkBoxRectangle.X = (base.ClientRectangle.Width - checkBoxRectangle.Width) - 1;
this._groupNameCol.ColumnRec.Width = ((base.ClientRectangle.Width - checkBoxRectangle.Width) - 1) - 0x24;
}
checkBoxRectangle.Height = height;
this._onLineStatisticCol.ColumnRec = checkBoxRectangle;
}
else if (base.NeedReCaculate(buddyNode))
{
checkBoxRectangle = new Rectangle(0, 0, 0, 0);
if (paintNode.get_Level() == 0)
{
checkBoxRectangle.X = bounds.Left - base._groupIndent;
}
else
{
checkBoxRectangle.X = bounds.Left - base._indent;
}
checkBoxRectangle.Y = top;
checkBoxRectangle = this.GetCheckBoxRectangle(new Point(checkBoxRectangle.X, checkBoxRectangle.Y));
this._buddyCheckBoxCol.ColumnRec = checkBoxRectangle;
AmigoImage image = base._onLineStatusImgCol.image;
checkBoxRectangle.X = this._buddyCheckBoxCol.ColumnRec.Right + 2;
checkBoxRectangle.Width = image.Width;
checkBoxRectangle.Height = image.Height;
base._onLineStatusImgCol.ColumnRec = checkBoxRectangle;
checkBoxRectangle.X = checkBoxRectangle.Right;
checkBoxRectangle.Width = 1;
base._nickNameTextCol.ColumnRec = checkBoxRectangle;
checkBoxRectangle.X = checkBoxRectangle.Right;
checkBoxRectangle.Width = 1;
base._moodPhraseTextCol.ColumnRec = checkBoxRectangle;
}
}
public void CheckNodebox(TreeNode node)
{
base.Invalidate();
}
private void DragImage(Graphics g, Rectangle rect, Image image)
{
rect.Y += (base._itemHeight - rect.Height) / 2;
TreeDrawHelper.DrawImage(g, rect, image, false);
}
private void DrawCheckBox(Graphics g, Rectangle rect, CheckState state)
{
Image image = this._chekStateList.Images[(int) state];
this.DragImage(g, rect, image);
}
private string EllipsisDisplay(StringBuilder str)
{
str.Replace('\r', ' ');
str.Replace('\n', ' ');
return str.ToString();
}
private Rectangle GetCheckBoxRectangle(Point pt)
{
return new Rectangle(pt, new Size(12, 12));
}
protected override int GetNickNameLeft(Rectangle rect)
{
return base._nickNameTextCol.ColumnRec.X;
}
private void NodeClick(TreeNode eventNode)
{
BuddySelectionGroupNode node = eventNode as BuddySelectionGroupNode;
if (node != null)
{
if (node.CheckState == CheckState.Checked)
{
node.CheckState = CheckState.Unchecked;
}
else
{
node.CheckState = CheckState.Checked;
}
if (this.NodeAferCheck != null)
{
BuddySelectionTreeCheckEventArgs e = new BuddySelectionTreeCheckEventArgs(node, node.CheckState);
this.NodeAferCheck(this, e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -