📄 contacttreectrl.cs
字号:
namespace Imps.Client.Pc.BizControls
{
using Imps.Client.Core;
using Imps.Client.Pc;
using Imps.Client.Resource;
using Imps.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class ContactTreeCtrl : PaintTreeCtrl
{
private Image _backGroundImg;
protected Color _bkColor;
protected SolidBrush _brush;
protected int _buddyColumnHeight = 0x10;
protected PaintTreeColumn _buddyImgCol;
protected Rectangle _clientRectangle;
protected Rectangle _clipedRectangle;
protected ShowMode _contactShowMode;
protected PaintTreeColumn _crbtToBuddyImgCol;
protected PaintTreeColumn _crbtToBuddyTextCol;
protected PaintTreeColumn _crbtToMeImgCol;
protected PaintTreeColumn _crbtToMeTextCol;
private Image _defaultMobileStatusImage = ImpsIcons.PhoneStutusOnline;
private Image _defaultOnlineStatusImage = ImpsPresenceIcons.Instance.OnlineIcon;
private Image _defaultToMeImage = ImpsIcons.CrbtToBuddy;
private Image _defaultUpdateInfoImage = (File.Exists(ThemeManager.GetImagePath(TreePara.UpdateInfoImageFileName)) ? Image.FromFile(ThemeManager.GetImagePath(TreePara.UpdateInfoImageFileName)) : null);
protected int _doubleRowIdent = 0x22;
protected const int _gifFrameInterval = 100;
protected int _groupIndent = 15;
private PaintTreeColumn _groupNameCol;
protected int _indent = 0x24;
protected int _itemHeight = 20;
protected PaintTreeColumn _mobileStatusImgCol;
protected bool _modifyColumnRectTopOnly;
protected ColumnCollection _moodPhraseCols;
protected int _moodPhraseInterval = 10;
protected PaintTreeColumn _moodPhraseTextCol;
protected int _nDiagnosedY;
protected ColumnCollection _nickNameCols;
protected PaintTreeColumn _nickNameTextCol;
protected int _OffsetY;
private PaintTreeColumn _onLineStatisticCol;
protected PaintTreeColumn _onLineStatusImgCol;
public bool _paintSelected = true;
private bool _RePaintFullClient;
private int _scolledVal;
protected Color _selectBorderColor;
protected Color _selectionColor;
protected StringFormat _sf;
protected PaintTreeColumn _statusTextCol;
private bool _suspened;
protected PaintTreeColumn _updateBuddyInfoImgCol;
private ImageList imageList1;
public bool IsDebug;
private Win32.tagSCROLLINFO m_scrollInfo = new Win32.tagSCROLLINFO();
public Image PlusImg;
public Rectangle PlusImgRect;
public Image StreamCollapseImg;
public Image StreamExpandImg;
public event OnContactMouseWheelEventHandler OnContactMouseWheel;
public event OnEndVScrollEventHandler OnEndVScroll;
public event OnVScrollLineChangeEventHandler OnVScrollLineChange;
public ContactTreeCtrl()
{
this.m_scrollInfo.cbSize = Marshal.SizeOf(this.m_scrollInfo);
this.m_scrollInfo.fMask = 0x17;
this._bkColor = Color.White;
this._selectBorderColor = Color.FromArgb(0x83, 150, 0xc3);
this._selectionColor = Color.FromArgb(0xd1, 0xea, 0xf2);
this.InitializeComponent();
base.ShowPlusMinus = false;
base.SetStyle(ControlStyles.UserPaint, true);
base.ItemHeight = this._itemHeight;
base.set_ShowNodeToolTips(false);
this.StreamExpandImg = this.imageList1.Images[1];
this.StreamCollapseImg = this.imageList1.Images[0];
}
public int AddBuddyGroup(ContactGroupNode gNode)
{
gNode.Text = "GroupText";
int num = base.Nodes.Add((TreeNode) gNode);
this._modifyColumnRectTopOnly = false;
return num;
}
public int AddBuddyNode(ContactGroupNode group, ContactBuddyNode buddy)
{
TreeNode node = group;
buddy.Text = "BuddyText";
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);
}
this._nickNameTextCol = buddy.Columns[3];
this._moodPhraseTextCol = buddy.Columns[4];
ColumnCollection columns = this.ParseStringToColumnCollection(this._nickNameTextCol);
if (columns != null)
{
buddy.NickNameCols = columns;
this._nickNameCols = columns;
}
ColumnCollection columns2 = this.ParseStringToColumnCollection(this._moodPhraseTextCol);
if (columns2 != null)
{
buddy.MoodPhraseCols = columns2;
this._moodPhraseCols = columns2;
}
int nHeight = 1;
if (this._contactShowMode == ShowMode.SingleRow)
{
nHeight = 1;
}
else
{
nHeight = 2;
}
this.setItemHeight(base.Handle, buddy, nHeight);
this._modifyColumnRectTopOnly = false;
return num;
}
private void adjustColumnRect(Graphics g, PaintTreeNode paintNode, Rectangle bounds)
{
if (paintNode is ContactGroupNode)
{
if (this._groupNameCol.ColumnRec.Right >= base.ClientRectangle.Right)
{
this._groupNameCol.ColumnRec.Width = (base.ClientRectangle.Right - this._groupNameCol.ColumnRec.Left) - 1;
}
this._onLineStatisticCol.ColumnRec.X = this._groupNameCol.ColumnRec.Right;
if (this._onLineStatisticCol.ColumnRec.Right >= base.ClientRectangle.Right)
{
this._onLineStatisticCol.ColumnRec.Width = (base.ClientRectangle.Right - this._onLineStatisticCol.ColumnRec.Left) - 1;
}
}
else
{
ContactBuddyNode buddyNode = paintNode as ContactBuddyNode;
if (this._contactShowMode == ShowMode.SingleRow)
{
this.adjustSingleRowColumnRectangles(g, buddyNode, bounds);
}
else
{
bounds.Y += this._nDiagnosedY;
this.adjustDoubleRowColumnRectangles(g, buddyNode, bounds);
}
buddyNode.NeedCaculate = false;
}
}
private void adjustDoubleRowColumnRectangles(Graphics g, ContactBuddyNode buddyNode, Rectangle bounds)
{
int y = bounds.Y;
int columnCount = this._nickNameCols.ColumnCount;
int x = bounds.X - this._indent;
int num3 = 0;
int num4 = 0;
int num5 = this._buddyColumnHeight;
bool flag = false;
if ((this._crbtToMeTextCol.ColumnText.Length == 0) && (this._crbtToBuddyTextCol.ColumnText.Length == 0))
{
flag = true;
}
if (buddyNode.NickNameCols.ColumnCount != 0)
{
x = this._nickNameCols[0].ColumnRec.X;
num3 = this._nickNameTextCol.ColumnRec.X;
x = num3;
num4 = x;
foreach (PaintTreeColumn column in this._nickNameCols)
{
int num6;
column.ColumnRec.Y = y;
if (column.ColumnType == PaintTreeColumnType.IMAGE)
{
num6 = 0x10;
column.ColumnRec.Height = 0x10;
}
else
{
num6 = (int) Math.Ceiling((double) g.MeasureString(column.ColumnText, column.ColumnFont).Width);
column.ColumnRec.Height = num5;
}
column.ColumnRec.Width = num6;
column.ColumnRec.X = num3;
num3 += num6;
num4 += num6;
}
}
int num7 = this._mobileStatusImgCol.ColumnRec.Left - this._onLineStatusImgCol.ColumnRec.Right;
if (this._nickNameTextCol.ColumnText.Length == 0)
{
this._moodPhraseTextCol.ColumnRec.X = this._nickNameTextCol.ColumnRec.X;
}
else
{
int num8 = num4 - x;
if (num7 >= num8)
{
this._nickNameTextCol.ColumnRec.Width = num8;
if (flag)
{
this._moodPhraseTextCol.ColumnRec.X = this._nickNameTextCol.ColumnRec.X;
}
else
{
this._moodPhraseTextCol.ColumnRec.X = num4;
}
}
else
{
this._nickNameTextCol.ColumnRec.Width = num7;
if (flag)
{
this._moodPhraseTextCol.ColumnRec.X = this._nickNameTextCol.ColumnRec.X;
}
else
{
this._moodPhraseTextCol.ColumnRec.X = x + num7;
}
}
}
int num9 = buddyNode.MoodPhraseCols.ColumnCount;
int num10 = 0;
num3 = this._moodPhraseTextCol.ColumnRec.X;
int num11 = num3;
if (num9 != 0)
{
num10 = num3;
num3 = this._moodPhraseTextCol.ColumnRec.X;
num11 = num10;
foreach (PaintTreeColumn column2 in this._moodPhraseCols)
{
int num12;
column2.ColumnRec.Y = y;
if (column2.ColumnType == PaintTreeColumnType.IMAGE)
{
num12 = 0x10;
column2.ColumnRec.Height = 0x10;
}
else
{
num12 = (int) Math.Ceiling((double) g.MeasureString(column2.ColumnText, column2.ColumnFont).Width);
column2.ColumnRec.Height = num5;
}
column2.ColumnRec.Width = num12;
column2.ColumnRec.X = num3;
num3 += num12;
num11 += num12;
}
}
if (flag)
{
num7 = this._mobileStatusImgCol.ColumnRec.Left - this._onLineStatusImgCol.ColumnRec.Right;
}
else
{
num7 -= this._nickNameTextCol.ColumnRec.Width;
}
if (this._moodPhraseTextCol.ColumnText.Length == 0)
{
this._moodPhraseTextCol.ColumnRec.Width = 0;
}
else
{
int num13 = num11 - num10;
if (num7 >= num13)
{
this._moodPhraseTextCol.ColumnRec.Width = num13;
}
else
{
this._moodPhraseTextCol.ColumnRec.Width = num7;
}
}
Rectangle columnRec = this._crbtToMeTextCol.ColumnRec;
num7 = this._crbtToBuddyImgCol.ColumnRec.Left - this._crbtToMeImgCol.ColumnRec.Right;
int bottom = this._moodPhraseTextCol.ColumnRec.Bottom;
int height = this._moodPhraseTextCol.ColumnRec.Height;
this._crbtToBuddyImgCol.ColumnRec.Y = bottom;
this._crbtToMeTextCol.ColumnRec.Y = bottom;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -