#if NET_2_0
private string image_key = String.Empty;
private string selected_image_key = String.Empty;
+ private int state_image_index = -1;
+ private string state_image_key = String.Empty;
#endif
internal TreeNodeCollection nodes;
internal TreeViewAction check_reason = TreeViewAction.Unknown;
int indent_level = IndentLevel;
int roots = (TreeView.ShowRootLines ? 1 : 0);
int cb = (TreeView.CheckBoxes ? 19 : 0);
+#if NET_2_0
+ if (!TreeView.CheckBoxes && StateImage != null)
+ cb = 19;
+#endif
int imgs = (TreeView.ImageList != null ? TreeView.ImageList.ImageSize.Width + 3 : 0);
return ((indent_level + roots) * TreeView.Indent) + cb + imgs - TreeView.hbar_offset;
}
internal int GetImageX ()
{
+#if NET_2_0
+ return GetLinesX () + (TreeView.CheckBoxes || StateImage != null ? 19 : 0);
+#else
return GetLinesX () + (TreeView.CheckBoxes ? 19 : 0);
+#endif
}
// In theory we should be able to track this instead of computing
get { return selected_image_key; }
set { selected_image_key = value; }
}
+
+ [Localizable (true)]
+ [DefaultValue (-1)]
+ [RelatedImageList ("TreeView.StateImageList")]
+ [TypeConverter (typeof (NoneExcludedImageIndexConverter))]
+ [RefreshProperties (RefreshProperties.Repaint)]
+ [Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ public int StateImageIndex {
+ get { return state_image_index; }
+ set {
+ if (state_image_index != value) {
+ state_image_index = value;
+ state_image_key = string.Empty;
+ InvalidateWidth ();
+ }
+ }
+ }
+
+ [Localizable (true)]
+ [DefaultValue ("")]
+ [RelatedImageList ("TreeView.StateImageList")]
+ [TypeConverter (typeof (ImageKeyConverter))]
+ [RefreshProperties (RefreshProperties.Repaint)]
+ [Editor ("System.Windows.Forms.Design.ImageIndexEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
+ public string StateImageKey {
+ get { return state_image_key; }
+ set {
+ if (state_image_key != value) {
+ state_image_key = value;
+ state_image_index = -1;
+ InvalidateWidth ();
+ }
+ }
+ }
#endif
[Bindable(true)]
return true;
}
}
+
+#if NET_2_0
+ internal Image StateImage {
+ get {
+ if (TreeView != null) {
+ if (state_image_index >= 0)
+ return TreeView.StateImageList.Images[state_image_index];
+ if (state_image_key != string.Empty)
+ return TreeView.StateImageList.Images[state_image_key];
+ }
+
+ return null;
+ }
+ }
+#endif
#endregion // Internal & Private Methods and Properties
}
private string image_key;
private bool right_to_left_layout;
private string selected_image_key;
+ private ImageList state_image_list;
#endif
private bool full_row_select;
private bool hot_tracking;
}
}
+#if NET_2_0
+ [DefaultValue (null)]
+ public ImageList StateImageList {
+ get { return state_image_list; }
+ set {
+ state_image_list = value;
+ Invalidate ();
+ }
+ }
+#endif
+
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[Bindable(false)]
}
}
+#if NET_2_0
+ private void DrawNodeState (TreeNode node, Graphics dc, int x, int y)
+ {
+ if (node.Checked) {
+ if (StateImageList.Images[1] != null)
+ dc.DrawImage (StateImageList.Images[1], new Rectangle (x, y, 16, 16));
+ } else {
+ if (StateImageList.Images[0] != null)
+ dc.DrawImage (StateImageList.Images[0], new Rectangle (x, y, 16, 16));
+ }
+ }
+#endif
+
private void DrawNodeCheckBox (TreeNode node, Graphics dc, int x, int middle)
{
Pen pen = ThemeEngine.Current.ResPool.GetSizedPen(Color.Black, 2);
if ((show_root_lines || node.Parent != null) && show_plus_minus && child_count > 0)
DrawNodePlusMinus (node, dc, node.GetLinesX () - Indent + 5, middle);
+#if NET_2_0
+ if (checkboxes && state_image_list == null)
+ DrawNodeCheckBox (node, dc, CheckBoxLeft (node) - 3, middle);
+
+ if (checkboxes && state_image_list != null)
+ DrawNodeState (node, dc, CheckBoxLeft (node) - 3, y);
+
+ if (!checkboxes && node.StateImage != null)
+ dc.DrawImage (node.StateImage, new Rectangle (CheckBoxLeft (node) - 3, y, 16, 16));
+#else
if (checkboxes)
DrawNodeCheckBox (node, dc, CheckBoxLeft (node) - 3, middle);
+#endif
if (show_lines)
DrawNodeLines (node, dc, clip, dash, node.GetLinesX (), y, middle);