mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 17:40:39 +00:00
Initial commit of existing code.
* All renderdoc code up to this point was written by me, history is available by request
This commit is contained in:
@@ -0,0 +1,251 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>The Code Project Open License (CPOL)</title>
|
||||
<Style>
|
||||
BODY, P, TD { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt }
|
||||
H1,H2,H3,H4,H5 { color: #ff9900; font-weight: bold; }
|
||||
H1 { font-size: 14pt;color:black }
|
||||
H2 { font-size: 13pt; }
|
||||
H3 { font-size: 12pt; }
|
||||
H4 { font-size: 10pt; color: black; }
|
||||
PRE { BACKGROUND-COLOR: #FBEDBB; FONT-FAMILY: "Courier New", Courier, mono; WHITE-SPACE: pre; }
|
||||
CODE { COLOR: #990000; FONT-FAMILY: "Courier New", Courier, mono; }
|
||||
.SpacedList li { padding: 5px 0px 5px 0px;}
|
||||
</style>
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF" color=#000000>
|
||||
|
||||
<h1>The Code Project Open License (CPOL) 1.02</h1>
|
||||
<br />
|
||||
|
||||
<center>
|
||||
<div style="text-align: left; border: 2px solid #000000; width: 660; background-color: #FFFFD9; padding: 20px;">
|
||||
|
||||
<h2>Preamble</h2>
|
||||
<p>
|
||||
This License governs Your use of the Work. This License is intended to allow developers
|
||||
to use the Source Code and Executable Files provided as part of the Work in any
|
||||
application in any form.
|
||||
</p>
|
||||
<p>
|
||||
The main points subject to the terms of the License are:</p>
|
||||
<ul>
|
||||
<li>Source Code and Executable Files can be used in commercial applications;</li>
|
||||
<li>Source Code and Executable Files can be redistributed; and</li>
|
||||
<li>Source Code can be modified to create derivative works.</li>
|
||||
<li>No claim of suitability, guarantee, or any warranty whatsoever is provided. The software is
|
||||
provided "as-is".</li>
|
||||
<li>The Article accompanying the Work may not be distributed or republished without the
|
||||
Author's consent</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
This License is entered between You, the individual or other entity reading or otherwise
|
||||
making use of the Work licensed pursuant to this License and the individual or other
|
||||
entity which offers the Work under the terms of this License ("Author").</p>
|
||||
|
||||
<h2>License</h2>
|
||||
<p>
|
||||
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CODE PROJECT OPEN
|
||||
LICENSE ("LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE
|
||||
LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT
|
||||
LAW IS PROHIBITED.</p>
|
||||
<p>
|
||||
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HEREIN, YOU ACCEPT AND AGREE TO BE
|
||||
BOUND BY THE TERMS OF THIS LICENSE. THE AUTHOR GRANTS YOU THE RIGHTS CONTAINED HEREIN
|
||||
IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. IF YOU DO NOT
|
||||
AGREE TO ACCEPT AND BE BOUND BY THE TERMS OF THIS LICENSE, YOU CANNOT MAKE ANY
|
||||
USE OF THE WORK.</p>
|
||||
|
||||
<ol class="SpacedList">
|
||||
<li><strong>Definitions.</strong>
|
||||
|
||||
<ol class="SpacedList" style="list-style-type: lower-alpha;">
|
||||
<li><strong>"Articles"</strong> means, collectively, all articles written by Author
|
||||
which describes how the Source Code and Executable Files for the Work may be used
|
||||
by a user.</li>
|
||||
<li><b>"Author"</b> means the individual or entity that offers the Work under the terms
|
||||
of this License.<strong></strong></li>
|
||||
<li><strong>"Derivative Work"</strong> means a work based upon the Work or upon the
|
||||
Work and other pre-existing works.</li>
|
||||
<li><b>"Executable Files"</b> refer to the executables, binary files, configuration
|
||||
and any required data files included in the Work.</li>
|
||||
<li>"<b>Publisher</b>" means the provider of the website, magazine, CD-ROM, DVD or other
|
||||
medium from or by which the Work is obtained by You.</li>
|
||||
<li><b>"Source Code"</b> refers to the collection of source code and configuration files
|
||||
used to create the Executable Files.</li>
|
||||
<li><b>"Standard Version"</b> refers to such a Work if it has not been modified, or
|
||||
has been modified in accordance with the consent of the Author, such consent being
|
||||
in the full discretion of the Author. </li>
|
||||
<li><b>"Work"</b> refers to the collection of files distributed by the Publisher, including
|
||||
the Source Code, Executable Files, binaries, data files, documentation, whitepapers
|
||||
and the Articles. </li>
|
||||
<li><b>"You"</b> is you, an individual or entity wishing to use the Work and exercise
|
||||
your rights under this License.
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
|
||||
<li><strong>Fair Use/Fair Use Rights.</strong> Nothing in this License is intended to
|
||||
reduce, limit, or restrict any rights arising from fair use, fair dealing, first
|
||||
sale or other limitations on the exclusive rights of the copyright owner under copyright
|
||||
law or other applicable laws.
|
||||
</li>
|
||||
|
||||
<li><strong>License Grant.</strong> Subject to the terms and conditions of this License,
|
||||
the Author hereby grants You a worldwide, royalty-free, non-exclusive, perpetual
|
||||
(for the duration of the applicable copyright) license to exercise the rights in
|
||||
the Work as stated below:
|
||||
|
||||
<ol class="SpacedList" style="list-style-type: lower-alpha;">
|
||||
<li>You may use the standard version of the Source Code or Executable Files in Your
|
||||
own applications. </li>
|
||||
<li>You may apply bug fixes, portability fixes and other modifications obtained from
|
||||
the Public Domain or from the Author. A Work modified in such a way shall still
|
||||
be considered the standard version and will be subject to this License.</li>
|
||||
<li>You may otherwise modify Your copy of this Work (excluding the Articles) in any
|
||||
way to create a Derivative Work, provided that You insert a prominent notice in
|
||||
each changed file stating how, when and where You changed that file.</li>
|
||||
<li>You may distribute the standard version of the Executable Files and Source Code
|
||||
or Derivative Work in aggregate with other (possibly commercial) programs as part
|
||||
of a larger (possibly commercial) software distribution. </li>
|
||||
<li>The Articles discussing the Work published in any form by the author may not be
|
||||
distributed or republished without the Author's consent. The author retains
|
||||
copyright to any such Articles. You may use the Executable Files and Source Code
|
||||
pursuant to this License but you may not repost or republish or otherwise distribute
|
||||
or make available the Articles, without the prior written consent of the Author.</li>
|
||||
</ol>
|
||||
|
||||
Any subroutines or modules supplied by You and linked into the Source Code or Executable
|
||||
Files of this Work shall not be considered part of this Work and will not be subject
|
||||
to the terms of this License.
|
||||
</li>
|
||||
|
||||
<li><strong>Patent License.</strong> Subject to the terms and conditions of this License,
|
||||
each Author hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable (except as stated in this section) patent license to make, have made, use, import,
|
||||
and otherwise transfer the Work.</li>
|
||||
|
||||
<li><strong>Restrictions.</strong> The license granted in Section 3 above is expressly
|
||||
made subject to and limited by the following restrictions:
|
||||
|
||||
<ol class="SpacedList" style="list-style-type: lower-alpha;">
|
||||
<li>You agree not to remove any of the original copyright, patent, trademark, and
|
||||
attribution notices and associated disclaimers that may appear in the Source Code
|
||||
or Executable Files. </li>
|
||||
<li>You agree not to advertise or in any way imply that this Work is a product of Your
|
||||
own. </li>
|
||||
<li>The name of the Author may not be used to endorse or promote products derived from
|
||||
the Work without the prior written consent of the Author.</li>
|
||||
<li>You agree not to sell, lease, or rent any part of the Work. This does not restrict
|
||||
you from including the Work or any part of the Work inside a larger software
|
||||
distribution that itself is being sold. The Work by itself, though, cannot be sold,
|
||||
leased or rented.</li>
|
||||
<li>You may distribute the Executable Files and Source Code only under the terms of
|
||||
this License, and You must include a copy of, or the Uniform Resource Identifier
|
||||
for, this License with every copy of the Executable Files or Source Code You distribute
|
||||
and ensure that anyone receiving such Executable Files and Source Code agrees that
|
||||
the terms of this License apply to such Executable Files and/or Source Code. You
|
||||
may not offer or impose any terms on the Work that alter or restrict the terms of
|
||||
this License or the recipients' exercise of the rights granted hereunder. You
|
||||
may not sublicense the Work. You must keep intact all notices that refer to this
|
||||
License and to the disclaimer of warranties. You may not distribute the Executable
|
||||
Files or Source Code with any technological measures that control access or use
|
||||
of the Work in a manner inconsistent with the terms of this License. </li>
|
||||
<li>You agree not to use the Work for illegal, immoral or improper purposes, or on pages
|
||||
containing illegal, immoral or improper material. The Work is subject to applicable
|
||||
export laws. You agree to comply with all such laws and regulations that may apply
|
||||
to the Work after Your receipt of the Work.
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
|
||||
<li><strong>Representations, Warranties and Disclaimer.</strong> THIS WORK IS PROVIDED
|
||||
"AS IS", "WHERE IS" AND "AS AVAILABLE", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES
|
||||
OR CONDITIONS OR GUARANTEES. YOU, THE USER, ASSUME ALL RISK IN ITS USE, INCLUDING
|
||||
COPYRIGHT INFRINGEMENT, PATENT INFRINGEMENT, SUITABILITY, ETC. AUTHOR EXPRESSLY
|
||||
DISCLAIMS ALL EXPRESS, IMPLIED OR STATUTORY WARRANTIES OR CONDITIONS, INCLUDING
|
||||
WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF MERCHANTABILITY, MERCHANTABLE QUALITY
|
||||
OR FITNESS FOR A PARTICULAR PURPOSE, OR ANY WARRANTY OF TITLE OR NON-INFRINGEMENT,
|
||||
OR THAT THE WORK (OR ANY PORTION THEREOF) IS CORRECT, USEFUL, BUG-FREE OR FREE OF
|
||||
VIRUSES. YOU MUST PASS THIS DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE WORK OR DERIVATIVE
|
||||
WORKS.
|
||||
</li>
|
||||
|
||||
<li><b>Indemnity. </b>You agree to defend, indemnify and hold harmless the Author and
|
||||
the Publisher from and against any claims, suits, losses, damages, liabilities,
|
||||
costs, and expenses (including reasonable legal or attorneys’ fees) resulting from
|
||||
or relating to any use of the Work by You.
|
||||
</li>
|
||||
|
||||
<li><strong>Limitation on Liability.</strong> EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
|
||||
LAW, IN NO EVENT WILL THE AUTHOR OR THE PUBLISHER BE LIABLE TO YOU ON ANY LEGAL
|
||||
THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
|
||||
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK OR OTHERWISE, EVEN IF THE AUTHOR
|
||||
OR THE PUBLISHER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
</li>
|
||||
|
||||
<li><strong>Termination.</strong>
|
||||
|
||||
<ol style="list-style-type: lower-alpha;">
|
||||
<li>This License and the rights granted hereunder will terminate automatically upon
|
||||
any breach by You of any term of this License. Individuals or entities who have
|
||||
received Derivative Works from You under this License, however, will not have their
|
||||
licenses terminated provided such individuals or entities remain in full compliance
|
||||
with those licenses. Sections 1, 2, 6, 7, 8, 9, 10 and 11 will survive any termination
|
||||
of this License. </li>
|
||||
|
||||
<li>If You bring a copyright, trademark, patent or any other infringement claim against
|
||||
any contributor over infringements You claim are made by the Work, your License
|
||||
from such contributor to the Work ends automatically.</li>
|
||||
|
||||
<li>Subject to the above terms and conditions, this License is perpetual (for the duration
|
||||
of the applicable copyright in the Work). Notwithstanding the above, the Author
|
||||
reserves the right to release the Work under different license terms or to stop
|
||||
distributing the Work at any time; provided, however that any such election will
|
||||
not serve to withdraw this License (or any other license that has been, or is required
|
||||
to be, granted under the terms of this License), and this License will continue
|
||||
in full force and effect unless terminated as stated above.
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
|
||||
<li><strong>Publisher</strong>. The parties hereby confirm that the Publisher shall
|
||||
not, under any circumstances, be responsible for and shall not have any liability
|
||||
in respect of the subject matter of this License. The Publisher makes no warranty
|
||||
whatsoever in connection with the Work and shall not be liable to You or any party
|
||||
on any legal theory for any damages whatsoever, including without limitation any
|
||||
general, special, incidental or consequential damages arising in connection to this
|
||||
license. The Publisher reserves the right to cease making the Work available to
|
||||
You at any time without notice</li>
|
||||
|
||||
<li><strong>Miscellaneous</strong>
|
||||
|
||||
<ol class="SpacedList" style="list-style-type: lower-alpha;">
|
||||
<li>This License shall be governed by the laws of the location of the head office of
|
||||
the Author or if the Author is an individual, the laws of location of the principal
|
||||
place of residence of the Author.</li>
|
||||
<li>If any provision of this License is invalid or unenforceable under applicable law,
|
||||
it shall not affect the validity or enforceability of the remainder of the terms
|
||||
of this License, and without further action by the parties to this License, such
|
||||
provision shall be reformed to the minimum extent necessary to make such provision
|
||||
valid and enforceable. </li>
|
||||
<li>No term or provision of this License shall be deemed waived and no breach consented
|
||||
to unless such waiver or consent shall be in writing and signed by the party to
|
||||
be charged with such waiver or consent. </li>
|
||||
<li>This License constitutes the entire agreement between the parties with respect to
|
||||
the Work licensed herein. There are no understandings, agreements or representations
|
||||
with respect to the Work not specified herein. The Author shall not be bound by
|
||||
any additional provisions that may appear in any communication from You. This License
|
||||
may not be modified without the mutual written agreement of the Author and You.
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
</div>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,7 @@
|
||||
This control is almost entirely taken from http://www.codeproject.com/Articles/23746/TreeView-with-Columns by jkristia.
|
||||
|
||||
Minor changes have been made to clean up, rename or reorganise - as well as a few fixes to the non-visual styles rendering path
|
||||
and some additional changes for my use of the control (like having the tree controls in a column other than the first, which mostly
|
||||
'Just Worked' (tm) ).
|
||||
|
||||
So all credit goes to the above author!
|
||||
@@ -0,0 +1,184 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
|
||||
// Taken from http://www.codeproject.com/Articles/23746/TreeView-with-Columns with minor tweaks
|
||||
// and fixes for my purposes.
|
||||
namespace TreelistView
|
||||
{
|
||||
// http://msdn2.microsoft.com/en-us/library/9zky1t4k.aspx
|
||||
|
||||
// Extending Design-Time Support
|
||||
// ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_fxdeveloping/html/d6ac8a6a-42fd-4bc8-bf33-b212811297e2.htm
|
||||
// http://msdn2.microsoft.com/en-us/library/37899azc.aspx
|
||||
|
||||
// description of the property grid
|
||||
// http://msdn2.microsoft.com/en-us/library/aa302326.aspx
|
||||
// http://msdn2.microsoft.com/en-us/library/aa302334.aspx
|
||||
|
||||
// another good one explaining
|
||||
// http://www.codeproject.com/KB/cs/dzcollectioneditor.aspx?print=true
|
||||
public class ColumnCollectionEditor : CollectionEditor
|
||||
{
|
||||
public ColumnCollectionEditor(Type type) : base(type)
|
||||
{
|
||||
}
|
||||
protected override bool CanSelectMultipleInstances()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return base.CreateCollectionItemType();
|
||||
}
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
TreeListView owner = this.Context.Instance as TreeListView;
|
||||
// create new default fieldname
|
||||
string fieldname;
|
||||
string caption;
|
||||
int cnt = owner.Columns.Count;
|
||||
do
|
||||
{
|
||||
fieldname = "fieldname" + cnt.ToString();
|
||||
caption = "Column_" + cnt.ToString();
|
||||
cnt++;
|
||||
}
|
||||
while (owner.Columns[fieldname] != null);
|
||||
return new TreeListColumn(fieldname, caption);
|
||||
}
|
||||
protected override string GetDisplayText(object value)
|
||||
{
|
||||
string Caption = (string)value.GetType().GetProperty("Caption").GetGetMethod().Invoke(value, null);
|
||||
string Fieldname = (string)value.GetType().GetProperty("Fieldname").GetGetMethod().Invoke(value, null);
|
||||
|
||||
if (Caption.Length > 0)
|
||||
return string.Format("{0} ({1})", Caption, Fieldname);
|
||||
return base.GetDisplayText(value);
|
||||
}
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
object result = base.EditValue(context, provider, value);
|
||||
TreeListView owner = this.Context.Instance as TreeListView;
|
||||
owner.Invalidate();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
internal class ColumnConverter : ExpandableObjectConverter
|
||||
{
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destType)
|
||||
{
|
||||
if (destType == typeof(InstanceDescriptor) || destType == typeof(string))
|
||||
return true;
|
||||
else
|
||||
return base.CanConvertTo(context, destType);
|
||||
}
|
||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo info, object value, Type destType)
|
||||
{
|
||||
if (destType == typeof(string))
|
||||
{
|
||||
string Caption = (string)value.GetType().GetProperty("Caption").GetGetMethod().Invoke(value, null);
|
||||
string Fieldname = (string)value.GetType().GetProperty("Fieldname").GetGetMethod().Invoke(value, null);
|
||||
|
||||
return String.Format("{0}, {1}", Caption, Fieldname);
|
||||
}
|
||||
if (destType == typeof(InstanceDescriptor))
|
||||
{
|
||||
ConstructorInfo cinfo = typeof(TreeListColumn).GetConstructor(new Type[] { typeof(string), typeof(string) });
|
||||
|
||||
string Caption = (string)value.GetType().GetProperty("Caption").GetGetMethod().Invoke(value, null);
|
||||
string Fieldname = (string)value.GetType().GetProperty("Fieldname").GetGetMethod().Invoke(value, null);
|
||||
|
||||
return new InstanceDescriptor(cinfo, new object[] {Fieldname, Caption}, false);
|
||||
}
|
||||
return base.ConvertTo(context, info, value, destType);
|
||||
}
|
||||
}
|
||||
class ColumnsTypeConverter : ExpandableObjectConverter
|
||||
{
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(TreeListColumnCollection))
|
||||
return true;
|
||||
return base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
return "(Columns Collection)";
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Designer for the tree view control.
|
||||
/// </summary>
|
||||
class TreeListViewDesigner : ControlDesigner
|
||||
{
|
||||
IComponentChangeService onChangeService;
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
|
||||
onChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (onChangeService != null)
|
||||
onChangeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
|
||||
|
||||
// we need to be notified when columsn have been resized.
|
||||
TreeListView tree = Control as TreeListView;
|
||||
tree.AfterResizingColumn += new MouseEventHandler(OnAfterResizingColumn);
|
||||
}
|
||||
void OnAfterResizingColumn(object sender, MouseEventArgs e)
|
||||
{
|
||||
// This is to notify that component has changed.
|
||||
// This is causing the code InitializeComponent code to be updated
|
||||
RaiseComponentChanged(null, null, null);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
void OnComponentChanged(object sender, ComponentChangedEventArgs e)
|
||||
{
|
||||
// repaint the control when any properties have changed
|
||||
if(Control != null)
|
||||
Control.Invalidate();
|
||||
}
|
||||
protected override bool GetHitTest(Point point)
|
||||
{
|
||||
// if mouse is over node, columns or scrollbar then return true
|
||||
// which will cause the mouse event to be forwarded to the control
|
||||
TreeListView tree = Control as TreeListView;
|
||||
point = tree.PointToClient(point);
|
||||
|
||||
Node node = tree.CalcHitNode(point);
|
||||
if (node != null)
|
||||
return true;
|
||||
|
||||
TreelistView.HitInfo colinfo = tree.CalcColumnHit(point);
|
||||
if ((int)(colinfo.HitType & HitInfo.eHitType.kColumnHeader) > 0)
|
||||
return true;
|
||||
|
||||
if (tree.HitTestScrollbar(point))
|
||||
return true;
|
||||
return base.GetHitTest(point);
|
||||
}
|
||||
|
||||
protected override void PostFilterProperties(IDictionary properties)
|
||||
{
|
||||
//properties.Remove("Cursor");
|
||||
base.PostFilterProperties(properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,624 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
||||
// Taken from http://www.codeproject.com/Articles/23746/TreeView-with-Columns with minor tweaks
|
||||
// and fixes for my purposes.
|
||||
namespace TreelistView
|
||||
{
|
||||
public class HitInfo
|
||||
{
|
||||
public enum eHitType
|
||||
{
|
||||
kColumnHeader = 0x0001,
|
||||
kColumnHeaderResize = 0x0002,
|
||||
}
|
||||
|
||||
public eHitType HitType = 0;
|
||||
public TreeListColumn Column = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DesignTimeVisible(false) prevents the columns from showing in the component tray (bottom of screen)
|
||||
/// If the class implement IComponent it must also implement default (void) constructor and when overriding
|
||||
/// the collection editors CreateInstance the return object must be used (if implementing IComponent), the reason
|
||||
/// is that ISite is needed, and ISite is set when base.CreateInstance is called.
|
||||
/// If no default constructor then the object will not be added to the collection in the initialize.
|
||||
/// In addition if implementing IComponent then name and generatemember is shown in the property grid
|
||||
/// Columns should just be added to the collection, no need for member, so no need to implement IComponent
|
||||
/// </summary>
|
||||
[DesignTimeVisible(false)]
|
||||
[TypeConverter(typeof(ColumnConverter))]
|
||||
public class TreeListColumn
|
||||
{
|
||||
TreeList.TextFormatting m_headerFormat = new TreeList.TextFormatting();
|
||||
TreeList.TextFormatting m_cellFormat = new TreeList.TextFormatting();
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public TreeList.TextFormatting HeaderFormat
|
||||
{
|
||||
get { return m_headerFormat; }
|
||||
}
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public TreeList.TextFormatting CellFormat
|
||||
{
|
||||
get { return m_cellFormat; }
|
||||
}
|
||||
|
||||
TreeListColumnCollection m_owner = null;
|
||||
Rectangle m_calculatedRect;
|
||||
int m_visibleIndex = -1;
|
||||
int m_colIndex = -1;
|
||||
int m_width = 50;
|
||||
string m_fieldName = string.Empty;
|
||||
string m_caption = string.Empty;
|
||||
|
||||
bool m_Moving = false;
|
||||
|
||||
internal TreeListColumnCollection Owner
|
||||
{
|
||||
get { return m_owner; }
|
||||
set { m_owner = value; }
|
||||
}
|
||||
internal Rectangle internalCalculatedRect
|
||||
{
|
||||
get { return m_calculatedRect; }
|
||||
set { m_calculatedRect = value; }
|
||||
}
|
||||
internal int internalVisibleIndex
|
||||
{
|
||||
get { return m_visibleIndex; }
|
||||
set { m_visibleIndex = value; }
|
||||
}
|
||||
internal int internalIndex
|
||||
{
|
||||
get { return m_colIndex; }
|
||||
set { m_colIndex = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool Moving
|
||||
{
|
||||
get { return m_Moving; }
|
||||
set
|
||||
{
|
||||
m_Moving = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public Rectangle CalculatedRect
|
||||
{
|
||||
get { return internalCalculatedRect; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public TreeListView TreeList
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Owner == null)
|
||||
return null;
|
||||
return Owner.Owner;
|
||||
}
|
||||
}
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public Font Font
|
||||
{
|
||||
get { return m_owner.Font; }
|
||||
}
|
||||
public int Width
|
||||
{
|
||||
get { return m_width; }
|
||||
set
|
||||
{
|
||||
if (m_width == value)
|
||||
return;
|
||||
m_width = value;
|
||||
if (m_owner != null && m_owner.DesignMode)
|
||||
m_owner.RecalcVisibleColumsRect();
|
||||
}
|
||||
}
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public string Caption
|
||||
{
|
||||
get { return m_caption; }
|
||||
set
|
||||
{
|
||||
m_caption = value;
|
||||
if (m_owner != null)
|
||||
m_owner.Invalidate();
|
||||
}
|
||||
}
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public string Fieldname
|
||||
{
|
||||
get { return m_fieldName; }
|
||||
set
|
||||
{
|
||||
if (m_owner == null || m_owner.DesignMode == false)
|
||||
throw new Exception("Fieldname can only be set at design time, Use Constructor to set programatically");
|
||||
if (value.Length == 0)
|
||||
throw new Exception("empty Fieldname not value");
|
||||
if (m_owner[value] != null)
|
||||
throw new Exception("fieldname already exist in collection");
|
||||
m_fieldName = value;
|
||||
}
|
||||
}
|
||||
|
||||
public TreeListColumn(string fieldName)
|
||||
{
|
||||
m_fieldName = fieldName;
|
||||
}
|
||||
public TreeListColumn(string fieldName, string caption)
|
||||
{
|
||||
m_fieldName = fieldName;
|
||||
m_caption = caption;
|
||||
}
|
||||
public TreeListColumn(string fieldName, string caption, int width)
|
||||
{
|
||||
m_fieldName = fieldName;
|
||||
m_caption = caption;
|
||||
m_width = width;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public int VisibleIndex
|
||||
{
|
||||
get { return internalVisibleIndex; }
|
||||
set
|
||||
{
|
||||
if (m_owner != null)
|
||||
m_owner.SetVisibleIndex(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public int Index
|
||||
{
|
||||
get { return internalIndex; }
|
||||
}
|
||||
public bool ishot = false;
|
||||
public virtual void Draw(Graphics dc, ColumnHeaderPainter painter, Rectangle r)
|
||||
{
|
||||
painter.DrawHeader(dc, r, this, this.HeaderFormat, ishot, m_Moving);
|
||||
}
|
||||
|
||||
bool m_autoSize = false;
|
||||
float m_autoSizeRatio = 100;
|
||||
int m_autoSizeMinSize;
|
||||
|
||||
[DefaultValue(false)]
|
||||
public bool AutoSize
|
||||
{
|
||||
get { return m_autoSize; }
|
||||
set { m_autoSize = value; }
|
||||
}
|
||||
[DefaultValue(100f)]
|
||||
public float AutoSizeRatio
|
||||
{
|
||||
get { return m_autoSizeRatio; }
|
||||
set { m_autoSizeRatio = value; }
|
||||
}
|
||||
public int AutoSizeMinSize
|
||||
{
|
||||
get { return m_autoSizeMinSize; }
|
||||
set { m_autoSizeMinSize = value; }
|
||||
}
|
||||
int m_calculatedAutoSize;
|
||||
internal int CalculatedAutoSize
|
||||
{
|
||||
get { return m_calculatedAutoSize; }
|
||||
set { m_calculatedAutoSize = value; }
|
||||
}
|
||||
}
|
||||
|
||||
[Description("This is the columns collection")]
|
||||
//[TypeConverterAttribute(typeof(ColumnsTypeConverter))]
|
||||
[Editor(typeof(ColumnCollectionEditor),typeof(System.Drawing.Design.UITypeEditor))]
|
||||
public class TreeListColumnCollection : IList<TreeListColumn>, IList
|
||||
{
|
||||
ColumnHeaderPainter m_painter;
|
||||
TreeList.CollumnSetting m_options;
|
||||
TreeListView m_owner;
|
||||
List<TreeListColumn> m_columns = new List<TreeListColumn>();
|
||||
List<TreeListColumn> m_visibleCols = new List<TreeListColumn>();
|
||||
Dictionary<string, TreeListColumn> m_columnMap = new Dictionary<string,TreeListColumn>();
|
||||
|
||||
[Browsable(false)]
|
||||
public TreeList.CollumnSetting Options
|
||||
{
|
||||
get { return m_options; }
|
||||
}
|
||||
[Browsable(false)]
|
||||
public ColumnHeaderPainter Painter
|
||||
{
|
||||
get { return m_painter; }
|
||||
set { m_painter = value; }
|
||||
}
|
||||
[Browsable(false)]
|
||||
public TreeListView Owner
|
||||
{
|
||||
get { return m_owner; }
|
||||
}
|
||||
[Browsable(false)]
|
||||
public Font Font
|
||||
{
|
||||
get { return m_owner.Font; }
|
||||
}
|
||||
[Browsable(false)]
|
||||
public TreeListColumn[] VisibleColumns
|
||||
{
|
||||
get { return m_visibleCols.ToArray(); }
|
||||
}
|
||||
[Browsable(false)]
|
||||
public int ColumnsWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
int width = 0;
|
||||
foreach (TreeListColumn col in m_visibleCols)
|
||||
{
|
||||
if (col.AutoSize)
|
||||
width += col.CalculatedAutoSize;
|
||||
else
|
||||
width += col.Width;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
}
|
||||
public TreeListColumnCollection(TreeListView owner)
|
||||
{
|
||||
m_owner = owner;
|
||||
m_options = new TreeList.CollumnSetting(owner);
|
||||
m_painter = new ColumnHeaderPainter(owner);
|
||||
}
|
||||
public TreeListColumn this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_columns[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
m_columns[index] = value;
|
||||
}
|
||||
}
|
||||
public TreeListColumn this[string fieldname]
|
||||
{
|
||||
get
|
||||
{
|
||||
TreeListColumn col;
|
||||
m_columnMap.TryGetValue(fieldname, out col);
|
||||
return col;
|
||||
}
|
||||
}
|
||||
public void SetVisibleIndex(TreeListColumn col, int index)
|
||||
{
|
||||
m_visibleCols.Remove(col);
|
||||
if (index >= 0)
|
||||
{
|
||||
if (index < m_visibleCols.Count)
|
||||
m_visibleCols.Insert(index, col);
|
||||
else
|
||||
m_visibleCols.Add(col);
|
||||
}
|
||||
RecalcVisibleColumsRect();
|
||||
}
|
||||
public HitInfo CalcHitInfo(Point point, int horzOffset)
|
||||
{
|
||||
HitInfo info = new HitInfo();
|
||||
info.Column = CalcHitColumn(point, horzOffset);
|
||||
if ((info.Column != null) && (point.Y < Options.HeaderHeight))
|
||||
{
|
||||
info.HitType |= HitInfo.eHitType.kColumnHeader;
|
||||
int right = info.Column.CalculatedRect.Right - horzOffset;
|
||||
if (info.Column.AutoSize == false || info.Column.internalIndex+1 < m_columns.Count)
|
||||
{
|
||||
if (point.X >= right - 4 && point.X <= right)
|
||||
info.HitType |= HitInfo.eHitType.kColumnHeaderResize;
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
public TreeListColumn CalcHitColumn(Point point, int horzOffset)
|
||||
{
|
||||
if (point.X < Options.LeftMargin)
|
||||
return null;
|
||||
foreach (TreeListColumn col in m_visibleCols)
|
||||
{
|
||||
int left = col.CalculatedRect.Left - horzOffset;
|
||||
int right = col.CalculatedRect.Right - horzOffset;
|
||||
if (point.X >= left && point.X <= right)
|
||||
return col;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public void RecalcVisibleColumsRect()
|
||||
{
|
||||
RecalcVisibleColumsRect(false);
|
||||
}
|
||||
public void RecalcVisibleColumsRect(bool isColumnResizing)
|
||||
{
|
||||
if (IsInitializing)
|
||||
return;
|
||||
int x = 0;//m_leftMargin;
|
||||
if (m_owner.RowOptions.ShowHeader)
|
||||
x = m_owner.RowOptions.HeaderWidth;
|
||||
int y = 0;
|
||||
int h = Options.HeaderHeight;
|
||||
int index = 0;
|
||||
foreach(TreeListColumn col in m_columns)
|
||||
{
|
||||
col.internalVisibleIndex = -1;
|
||||
col.internalIndex = index++;
|
||||
}
|
||||
|
||||
// calculate size requierd by fix columns and auto adjusted columns
|
||||
// at the same time calculate total ratio value
|
||||
int widthFixedColumns = 0;
|
||||
int widthAutoSizeColumns = 0;
|
||||
float totalRatio = 0;
|
||||
foreach (TreeListColumn col in m_visibleCols)
|
||||
{
|
||||
if (col.AutoSize)
|
||||
{
|
||||
widthAutoSizeColumns += col.AutoSizeMinSize;
|
||||
totalRatio += col.AutoSizeRatio;
|
||||
}
|
||||
else
|
||||
widthFixedColumns += col.Width;
|
||||
}
|
||||
|
||||
int clientWidth = m_owner.ClientRectangle.Width - m_owner.RowHeaderWidth();
|
||||
// find ratio 'unit' value
|
||||
float remainingWidth = clientWidth - (widthFixedColumns + widthAutoSizeColumns);
|
||||
float ratioUnit = 0;
|
||||
if (totalRatio > 0 && remainingWidth > 0)
|
||||
ratioUnit = remainingWidth / totalRatio;
|
||||
|
||||
for (index = 0; index < m_visibleCols.Count; index++)
|
||||
{
|
||||
TreeListColumn col = m_visibleCols[index];
|
||||
int width = col.Width;
|
||||
if (col.AutoSize)
|
||||
{
|
||||
// if doing column resizing then keep adjustable columns fixed at last width
|
||||
if (m_options.FreezeWhileResizing && isColumnResizing)
|
||||
width = col.CalculatedAutoSize;
|
||||
else
|
||||
width = Math.Max(10, col.AutoSizeMinSize + (int)Math.Round(ratioUnit * col.AutoSizeRatio - 1.0f));
|
||||
col.CalculatedAutoSize = width;
|
||||
}
|
||||
col.internalCalculatedRect = new Rectangle(x, y, width, h);
|
||||
col.internalVisibleIndex = index;
|
||||
x += width;
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
public void Draw(Graphics dc, Rectangle rect, int horzOffset)
|
||||
{
|
||||
foreach (TreeListColumn col in m_visibleCols)
|
||||
{
|
||||
Rectangle r = col.CalculatedRect;
|
||||
r.X -= horzOffset;
|
||||
if (r.Left > rect.Right)
|
||||
break;
|
||||
col.Draw(dc, m_painter, r);
|
||||
}
|
||||
// drwa row header filler
|
||||
if (m_owner.RowOptions.ShowHeader)
|
||||
{
|
||||
Rectangle r = new Rectangle(0, 0, m_owner.RowOptions.HeaderWidth, Options.HeaderHeight);
|
||||
m_painter.DrawHeaderFiller(dc, r);
|
||||
}
|
||||
}
|
||||
public void AddRange(IEnumerable<TreeListColumn> columns)
|
||||
{
|
||||
foreach (TreeListColumn col in columns)
|
||||
Add(col);
|
||||
}
|
||||
/// <summary>
|
||||
/// AddRange(Item[]) is required for the designer.
|
||||
/// </summary>
|
||||
/// <param name="columns"></param>
|
||||
public void AddRange(TreeListColumn[] columns)
|
||||
{
|
||||
foreach (TreeListColumn col in columns)
|
||||
Add(col);
|
||||
}
|
||||
public void Add(TreeListColumn item)
|
||||
{
|
||||
bool designmode = Owner.DesignMode;
|
||||
if (!designmode)
|
||||
{
|
||||
Debug.Assert(m_columnMap.ContainsKey(item.Fieldname) == false);
|
||||
Debug.Assert(item.Owner == null, "column.Owner == null");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_columns.Remove(item);
|
||||
m_visibleCols.Remove(item);
|
||||
}
|
||||
|
||||
item.Owner = this;
|
||||
m_columns.Add(item);
|
||||
m_visibleCols.Add(item);
|
||||
m_columnMap[item.Fieldname] = item;
|
||||
RecalcVisibleColumsRect();
|
||||
//return item;
|
||||
}
|
||||
public void Clear()
|
||||
{
|
||||
m_columnMap.Clear();
|
||||
m_columns.Clear();
|
||||
m_visibleCols.Clear();
|
||||
}
|
||||
public bool Contains(TreeListColumn item)
|
||||
{
|
||||
return m_columns.Contains(item);
|
||||
}
|
||||
[Browsable(false)]
|
||||
public int Count
|
||||
{
|
||||
get { return m_columns.Count; }
|
||||
}
|
||||
[Browsable(false)]
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
#region IList<TreeListColumn> Members
|
||||
|
||||
public int IndexOf(TreeListColumn item)
|
||||
{
|
||||
return m_columns.IndexOf(item);
|
||||
}
|
||||
|
||||
public void Insert(int index, TreeListColumn item)
|
||||
{
|
||||
m_columns.Insert(index, item);
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
if (index >= 0 && index < m_columns.Count)
|
||||
{
|
||||
TreeListColumn col = m_columns[index];
|
||||
SetVisibleIndex(col, -1);
|
||||
m_columnMap.Remove(col.Fieldname);
|
||||
}
|
||||
m_columns.RemoveAt(index);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region ICollection<TreeListColumn> Members
|
||||
|
||||
|
||||
public void CopyTo(TreeListColumn[] array, int arrayIndex)
|
||||
{
|
||||
m_columns.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public bool Remove(TreeListColumn item)
|
||||
{
|
||||
SetVisibleIndex(item, -1);
|
||||
m_columnMap.Remove(item.Fieldname);
|
||||
return m_columns.Remove(item);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region IEnumerable<TreeListColumn> Members
|
||||
|
||||
public IEnumerator<TreeListColumn> GetEnumerator()
|
||||
{
|
||||
return m_columns.GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region IEnumerable Members
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
#region IList Members
|
||||
int IList.Add(object value)
|
||||
{
|
||||
Add((TreeListColumn)value);
|
||||
return Count - 1;
|
||||
}
|
||||
bool IList.Contains(object value)
|
||||
{
|
||||
return Contains((TreeListColumn)value);
|
||||
}
|
||||
int IList.IndexOf(object value)
|
||||
{
|
||||
return IndexOf((TreeListColumn)value);
|
||||
}
|
||||
void IList.Insert(int index, object value)
|
||||
{
|
||||
Insert(index, (TreeListColumn)value);
|
||||
}
|
||||
|
||||
bool IList.IsFixedSize
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
void IList.Remove(object value)
|
||||
{
|
||||
Remove((TreeListColumn)value);
|
||||
}
|
||||
|
||||
object IList.this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region ICollection Members
|
||||
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
public bool IsSynchronized
|
||||
{
|
||||
get { throw new Exception("The method or operation is not implemented."); }
|
||||
}
|
||||
|
||||
public object SyncRoot
|
||||
{
|
||||
get { throw new Exception("The method or operation is not implemented."); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
internal bool DesignMode
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_owner != null)
|
||||
return m_owner.DesignMode;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
internal void Invalidate()
|
||||
{
|
||||
if (m_owner != null)
|
||||
m_owner.Invalidate();
|
||||
}
|
||||
bool IsInitializing = false;
|
||||
internal void BeginInit()
|
||||
{
|
||||
IsInitializing = true;
|
||||
}
|
||||
internal void EndInit()
|
||||
{
|
||||
IsInitializing = false;
|
||||
RecalcVisibleColumsRect();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,334 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
// Taken from http://www.codeproject.com/Articles/23746/TreeView-with-Columns with minor tweaks
|
||||
// and fixes for my purposes.
|
||||
namespace TreelistView.TreeList
|
||||
{
|
||||
[TypeConverterAttribute(typeof(OptionsSettingTypeConverter))]
|
||||
public class TextFormatting
|
||||
{
|
||||
ContentAlignment m_alignment = ContentAlignment.MiddleLeft;
|
||||
Color m_foreColor = SystemColors.ControlText;
|
||||
Color m_backColor = Color.Transparent;
|
||||
Padding m_padding = new Padding(0,0,0,0);
|
||||
public TextFormatFlags GetFormattingFlags()
|
||||
{
|
||||
TextFormatFlags flags = 0;
|
||||
switch (TextAlignment)
|
||||
{
|
||||
case ContentAlignment.TopLeft:
|
||||
flags = TextFormatFlags.Top | TextFormatFlags.Left;
|
||||
break;
|
||||
case ContentAlignment.TopCenter:
|
||||
flags = TextFormatFlags.Top | TextFormatFlags.HorizontalCenter;
|
||||
break;
|
||||
case ContentAlignment.TopRight:
|
||||
flags = TextFormatFlags.Top | TextFormatFlags.Right;
|
||||
break;
|
||||
case ContentAlignment.MiddleLeft:
|
||||
flags = TextFormatFlags.VerticalCenter | TextFormatFlags.Left;
|
||||
break;
|
||||
case ContentAlignment.MiddleCenter:
|
||||
flags = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter;
|
||||
break;
|
||||
case ContentAlignment.MiddleRight:
|
||||
flags = TextFormatFlags.VerticalCenter | TextFormatFlags.Right;
|
||||
break;
|
||||
case ContentAlignment.BottomLeft:
|
||||
flags = TextFormatFlags.Bottom | TextFormatFlags.Left;
|
||||
break;
|
||||
case ContentAlignment.BottomCenter:
|
||||
flags = TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter;
|
||||
break;
|
||||
case ContentAlignment.BottomRight:
|
||||
flags = TextFormatFlags.Bottom | TextFormatFlags.Right;
|
||||
break;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Padding), "0,0,0,0")]
|
||||
public Padding Padding
|
||||
{
|
||||
get { return m_padding; }
|
||||
set { m_padding = value; }
|
||||
}
|
||||
[DefaultValue(typeof(ContentAlignment), "MiddleLeft")]
|
||||
public ContentAlignment TextAlignment
|
||||
{
|
||||
get { return m_alignment; }
|
||||
set { m_alignment = value; }
|
||||
}
|
||||
[DefaultValue(typeof(Color), "ControlText")]
|
||||
public Color ForeColor
|
||||
{
|
||||
get { return m_foreColor; }
|
||||
set { m_foreColor = value; }
|
||||
}
|
||||
[DefaultValue(typeof(Color), "Transparent")]
|
||||
public Color BackColor
|
||||
{
|
||||
get { return m_backColor; }
|
||||
set { m_backColor = value; }
|
||||
}
|
||||
public TextFormatting()
|
||||
{
|
||||
}
|
||||
public TextFormatting(TextFormatting aCopy)
|
||||
{
|
||||
m_alignment = aCopy.m_alignment;
|
||||
m_foreColor = aCopy.m_foreColor;
|
||||
m_backColor = aCopy.m_backColor;
|
||||
m_padding = aCopy.m_padding;
|
||||
}
|
||||
}
|
||||
|
||||
[TypeConverterAttribute(typeof(OptionsSettingTypeConverter))]
|
||||
public class ViewSetting
|
||||
{
|
||||
TreeListView m_owner;
|
||||
BorderStyle m_borderStyle = BorderStyle.None;
|
||||
int m_indent = 16;
|
||||
bool m_showLine = true;
|
||||
bool m_showPlusMinus = true;
|
||||
bool m_showGridLines = true;
|
||||
bool m_rearrangeableColumns = false;
|
||||
bool m_hoverHand = true;
|
||||
|
||||
[Category("Behavior")]
|
||||
[DefaultValue(typeof(int), "16")]
|
||||
public int Indent
|
||||
{
|
||||
get { return m_indent; }
|
||||
set
|
||||
{
|
||||
m_indent = value;
|
||||
m_owner.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Behavior")]
|
||||
[DefaultValue(typeof(bool), "True")]
|
||||
public bool ShowLine
|
||||
{
|
||||
get { return m_showLine; }
|
||||
set
|
||||
{
|
||||
m_showLine = value;
|
||||
m_owner.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Behavior")]
|
||||
[DefaultValue(typeof(bool), "True")]
|
||||
public bool ShowPlusMinus
|
||||
{
|
||||
get { return m_showPlusMinus; }
|
||||
set
|
||||
{
|
||||
m_showPlusMinus = value;
|
||||
m_owner.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Behavior")]
|
||||
[DefaultValue(typeof(bool), "True")]
|
||||
public bool ShowGridLines
|
||||
{
|
||||
get { return m_showGridLines; }
|
||||
set
|
||||
{
|
||||
m_showGridLines = value;
|
||||
m_owner.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Behavior")]
|
||||
[DefaultValue(typeof(bool), "False")]
|
||||
public bool UserRearrangeableColumns
|
||||
{
|
||||
get { return m_rearrangeableColumns; }
|
||||
set
|
||||
{
|
||||
m_rearrangeableColumns = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Behavior")]
|
||||
[DefaultValue(typeof(bool), "True")]
|
||||
public bool HoverHandTreeColumn
|
||||
{
|
||||
get { return m_hoverHand; }
|
||||
set
|
||||
{
|
||||
m_hoverHand = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Appearance")]
|
||||
[DefaultValue(typeof(BorderStyle), "None")]
|
||||
public BorderStyle BorderStyle
|
||||
{
|
||||
get { return m_borderStyle; }
|
||||
set
|
||||
{
|
||||
if (m_borderStyle != value)
|
||||
{
|
||||
m_borderStyle = value;
|
||||
m_owner.internalUpdateStyles();
|
||||
m_owner.Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ViewSetting(TreeListView owner)
|
||||
{
|
||||
m_owner = owner;
|
||||
}
|
||||
}
|
||||
|
||||
[TypeConverterAttribute(typeof(OptionsSettingTypeConverter))]
|
||||
public class CollumnSetting
|
||||
{
|
||||
bool m_FreezeWhileResizing = false;
|
||||
int m_leftMargin = 5;
|
||||
int m_headerHeight = 20;
|
||||
TreeListView m_owner;
|
||||
|
||||
[DefaultValue(false)]
|
||||
public bool FreezeWhileResizing
|
||||
{
|
||||
get { return m_FreezeWhileResizing; }
|
||||
set
|
||||
{
|
||||
m_FreezeWhileResizing = value;
|
||||
}
|
||||
}
|
||||
[DefaultValue(5)]
|
||||
public int LeftMargin
|
||||
{
|
||||
get { return m_leftMargin; }
|
||||
set
|
||||
{
|
||||
m_leftMargin = value;
|
||||
m_owner.Columns.RecalcVisibleColumsRect();
|
||||
m_owner.Invalidate();
|
||||
}
|
||||
}
|
||||
[DefaultValue(20)]
|
||||
public int HeaderHeight
|
||||
{
|
||||
get { return m_headerHeight; }
|
||||
set
|
||||
{
|
||||
m_headerHeight = value;
|
||||
m_owner.Columns.RecalcVisibleColumsRect();
|
||||
m_owner.Invalidate();
|
||||
}
|
||||
}
|
||||
public CollumnSetting(TreeListView owner)
|
||||
{
|
||||
m_owner = owner;
|
||||
}
|
||||
}
|
||||
|
||||
[TypeConverterAttribute(typeof(OptionsSettingTypeConverter))]
|
||||
public class RowSetting
|
||||
{
|
||||
TreeListView m_owner;
|
||||
bool m_showHeader = true;
|
||||
bool m_hoverHighlight = false;
|
||||
int m_headerWidth = 15;
|
||||
int m_itemHeight = 16;
|
||||
[DefaultValue(true)]
|
||||
public bool ShowHeader
|
||||
{
|
||||
get { return m_showHeader; }
|
||||
set
|
||||
{
|
||||
if (m_showHeader == value)
|
||||
return;
|
||||
m_showHeader = value;
|
||||
m_owner.Columns.RecalcVisibleColumsRect();
|
||||
m_owner.Invalidate();
|
||||
}
|
||||
}
|
||||
[DefaultValue(false)]
|
||||
public bool HoverHighlight
|
||||
{
|
||||
get { return m_hoverHighlight; }
|
||||
set
|
||||
{
|
||||
if (m_hoverHighlight == value)
|
||||
return;
|
||||
m_hoverHighlight = value;
|
||||
m_owner.Invalidate();
|
||||
}
|
||||
}
|
||||
[DefaultValue(15)]
|
||||
public int HeaderWidth
|
||||
{
|
||||
get { return m_headerWidth; }
|
||||
set
|
||||
{
|
||||
if (m_headerWidth == value)
|
||||
return;
|
||||
m_headerWidth = value;
|
||||
m_owner.Columns.RecalcVisibleColumsRect();
|
||||
m_owner.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Behavior")]
|
||||
[DefaultValue(typeof(int), "16")]
|
||||
public int ItemHeight
|
||||
{
|
||||
get { return m_itemHeight; }
|
||||
set
|
||||
{
|
||||
m_itemHeight = value;
|
||||
m_owner.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public RowSetting(TreeListView owner)
|
||||
{
|
||||
m_owner = owner;
|
||||
}
|
||||
}
|
||||
|
||||
class OptionsSettingTypeConverter : ExpandableObjectConverter
|
||||
{
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(ViewSetting))
|
||||
return true;
|
||||
if (destinationType == typeof(RowSetting))
|
||||
return true;
|
||||
if (destinationType == typeof(CollumnSetting))
|
||||
return true;
|
||||
if (destinationType == typeof(TextFormatting))
|
||||
return true;
|
||||
return base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string) && value.GetType() == typeof(ViewSetting))
|
||||
return "(View Options)";
|
||||
if (destinationType == typeof(string) && value.GetType() == typeof(RowSetting))
|
||||
return "(Row Header Options)";
|
||||
if (destinationType == typeof(string) && value.GetType() == typeof(CollumnSetting))
|
||||
return "(Columns Options)";
|
||||
if (destinationType == typeof(string) && value.GetType() == typeof(TextFormatting))
|
||||
return "(Formatting)";
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,427 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Taken from http://www.codeproject.com/Articles/23746/TreeView-with-Columns with minor tweaks
|
||||
// and fixes for my purposes.
|
||||
namespace TreelistView
|
||||
{
|
||||
public class VisualStyleItemBackground // can't find system provided visual style for this.
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class RECT
|
||||
{
|
||||
public int left;
|
||||
public int top;
|
||||
public int right;
|
||||
public int bottom;
|
||||
public RECT()
|
||||
{
|
||||
}
|
||||
|
||||
public RECT(Rectangle r)
|
||||
{
|
||||
this.left = r.X;
|
||||
this.top = r.Y;
|
||||
this.right = r.Right;
|
||||
this.bottom = r.Bottom;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("uxtheme.dll", CharSet=CharSet.Auto)]
|
||||
public static extern int DrawThemeBackground(IntPtr hTheme, IntPtr hdc, int partId, int stateId, [In] RECT pRect, [In] RECT pClipRect);
|
||||
|
||||
[DllImport("uxtheme.dll", CharSet=CharSet.Auto)]
|
||||
public static extern IntPtr OpenThemeData(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszClassList);
|
||||
|
||||
[DllImport("uxtheme.dll", CharSet=CharSet.Auto)]
|
||||
public static extern int CloseThemeData(IntPtr hTheme);
|
||||
|
||||
//http://www.ookii.org/misc/vsstyle.h
|
||||
//http://msdn2.microsoft.com/en-us/library/bb773210(VS.85).aspx
|
||||
enum ITEMSTATES
|
||||
{
|
||||
LBPSI_HOT = 1,
|
||||
LBPSI_HOTSELECTED = 2,
|
||||
LBPSI_SELECTED = 3,
|
||||
LBPSI_SELECTEDNOTFOCUS = 4,
|
||||
};
|
||||
|
||||
enum LISTBOXPARTS
|
||||
{
|
||||
LBCP_BORDER_HSCROLL = 1,
|
||||
LBCP_BORDER_HVSCROLL = 2,
|
||||
LBCP_BORDER_NOSCROLL = 3,
|
||||
LBCP_BORDER_VSCROLL = 4,
|
||||
LBCP_ITEM = 5,
|
||||
};
|
||||
|
||||
public enum Style
|
||||
{
|
||||
Normal,
|
||||
Inactive, // when not focused
|
||||
}
|
||||
Style m_style;
|
||||
public VisualStyleItemBackground(Style style)
|
||||
{
|
||||
m_style = style;
|
||||
}
|
||||
public void DrawBackground(Control owner, Graphics dc, Rectangle r, Color col)
|
||||
{
|
||||
/*
|
||||
IntPtr themeHandle = OpenThemeData(owner.Handle, "Explorer");
|
||||
if (themeHandle != IntPtr.Zero)
|
||||
{
|
||||
DrawThemeBackground(themeHandle, dc.GetHdc(), (int)LISTBOXPARTS.LBCP_ITEM, (int)ITEMSTATES.LBPSI_SELECTED, new RECT(r), new RECT(r));
|
||||
dc.ReleaseHdc();
|
||||
CloseThemeData(themeHandle);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
Pen pen = new Pen(col);
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLine(r.Left + 2, r.Top, r.Right - 2, r.Top);
|
||||
path.AddLine(r.Right, r.Top + 2, r.Right, r.Bottom - 2);
|
||||
path.AddLine(r.Right - 2, r.Bottom, r.Left + 2, r.Bottom);
|
||||
path.AddLine(r.Left, r.Bottom - 2, r.Left, r.Top + 2);
|
||||
path.CloseFigure();
|
||||
dc.DrawPath(pen, path);
|
||||
|
||||
//r.Inflate(-1, -1);
|
||||
LinearGradientBrush brush = new LinearGradientBrush(r, Color.FromArgb(120, col), col, 90);
|
||||
dc.FillRectangle(brush, r);
|
||||
// for some reason in some cases the 'white' end of the gradient brush is drawn with the starting color
|
||||
// therefore this redraw of the 'top' line of the rectangle
|
||||
//dc.DrawLine(Pens.White, r.Left + 1, r.Top, r.Right - 1, r.Top);
|
||||
|
||||
pen.Dispose();
|
||||
brush.Dispose();
|
||||
path.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public delegate string CellDataToString(TreeListColumn column, object data);
|
||||
|
||||
public class CellPainter
|
||||
{
|
||||
public static Rectangle AdjustRectangle(Rectangle r, Padding padding)
|
||||
{
|
||||
r.X += padding.Left;
|
||||
r.Width -= padding.Left + padding.Right;
|
||||
r.Y += padding.Top;
|
||||
r.Height -= padding.Top + padding.Bottom;
|
||||
return r;
|
||||
}
|
||||
protected TreeListView m_owner;
|
||||
protected CellDataToString m_converter = null;
|
||||
|
||||
public CellDataToString CellDataConverter
|
||||
{
|
||||
get { return m_converter; }
|
||||
set { m_converter = value; }
|
||||
}
|
||||
|
||||
public CellPainter(TreeListView owner)
|
||||
{
|
||||
m_owner = owner;
|
||||
}
|
||||
public virtual void DrawSelectionBackground(Graphics dc, Rectangle nodeRect, Node node)
|
||||
{
|
||||
Point mousePoint = m_owner.PointToClient(Cursor.Position);
|
||||
Node hoverNode = m_owner.CalcHitNode(mousePoint);
|
||||
|
||||
if (m_owner.NodesSelection.Contains(node) || m_owner.FocusedNode == node)
|
||||
{
|
||||
Color col = m_owner.Focused ? SystemColors.Highlight : SystemColors.ControlLight;
|
||||
|
||||
if (!Application.RenderWithVisualStyles)
|
||||
{
|
||||
// have to fill the solid background only before the node is painted
|
||||
dc.FillRectangle(SystemBrushes.FromSystemColor(col), nodeRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
col = m_owner.Focused ? SystemColors.Highlight : Color.FromArgb(180, SystemColors.ControlDark);
|
||||
|
||||
// have to draw the transparent background after the node is painted
|
||||
VisualStyleItemBackground.Style style = VisualStyleItemBackground.Style.Normal;
|
||||
if (m_owner.Focused == false)
|
||||
style = VisualStyleItemBackground.Style.Inactive;
|
||||
VisualStyleItemBackground rendere = new VisualStyleItemBackground(style);
|
||||
rendere.DrawBackground(m_owner, dc, nodeRect, col);
|
||||
}
|
||||
}
|
||||
else if (hoverNode == node && m_owner.RowOptions.HoverHighlight)
|
||||
{
|
||||
Color col = SystemColors.ControlLight;
|
||||
|
||||
if (!Application.RenderWithVisualStyles)
|
||||
{
|
||||
// have to fill the solid background only before the node is painted
|
||||
dc.FillRectangle(SystemBrushes.FromSystemColor(col), nodeRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
// have to draw the transparent background after the node is painted
|
||||
VisualStyleItemBackground.Style style = VisualStyleItemBackground.Style.Normal;
|
||||
if (m_owner.Focused == false)
|
||||
style = VisualStyleItemBackground.Style.Inactive;
|
||||
VisualStyleItemBackground rendere = new VisualStyleItemBackground(style);
|
||||
rendere.DrawBackground(m_owner, dc, nodeRect, col);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_owner.Focused && (m_owner.FocusedNode == node))
|
||||
{
|
||||
nodeRect.Height += 1;
|
||||
nodeRect.Inflate(-1,-1);
|
||||
ControlPaint.DrawFocusRectangle(dc, nodeRect);
|
||||
}
|
||||
}
|
||||
public virtual void PaintCellBackground(Graphics dc,
|
||||
Rectangle cellRect,
|
||||
Node node,
|
||||
TreeListColumn column,
|
||||
TreeList.TextFormatting format,
|
||||
object data)
|
||||
{
|
||||
Color c = Color.Transparent;
|
||||
|
||||
Point mousePoint = m_owner.PointToClient(Cursor.Position);
|
||||
Node hoverNode = m_owner.CalcHitNode(mousePoint);
|
||||
|
||||
if (format.BackColor != Color.Transparent)
|
||||
c = format.BackColor;
|
||||
|
||||
if (node.BackColor != Color.Transparent)
|
||||
c = node.BackColor;
|
||||
|
||||
if (!m_owner.NodesSelection.Contains(node) && m_owner.FocusedNode != node &&
|
||||
!(hoverNode == node && m_owner.RowOptions.HoverHighlight) &&
|
||||
node.DefaultBackColor != Color.Transparent)
|
||||
c = node.DefaultBackColor;
|
||||
|
||||
if (c != Color.Transparent)
|
||||
{
|
||||
Rectangle r = cellRect;
|
||||
r.X -= Math.Max(0, column.CalculatedRect.Width - cellRect.Width);
|
||||
r.Width += Math.Max(0, column.CalculatedRect.Width - cellRect.Width);
|
||||
SolidBrush brush = new SolidBrush(c);
|
||||
dc.FillRectangle(brush, r);
|
||||
brush.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void PaintCellText(Graphics dc,
|
||||
Rectangle cellRect,
|
||||
Node node,
|
||||
TreeListColumn column,
|
||||
TreeList.TextFormatting format,
|
||||
object data)
|
||||
{
|
||||
if (data != null)
|
||||
{
|
||||
cellRect = AdjustRectangle(cellRect, format.Padding);
|
||||
//dc.DrawRectangle(Pens.Black, cellRect);
|
||||
|
||||
Color color = format.ForeColor;
|
||||
if (m_owner.FocusedNode == node && Application.RenderWithVisualStyles == false && m_owner.Focused)
|
||||
color = SystemColors.HighlightText;
|
||||
TextFormatFlags flags= TextFormatFlags.EndEllipsis | format.GetFormattingFlags();
|
||||
|
||||
Font f = m_owner.Font;
|
||||
Font disposefont = null;
|
||||
|
||||
if(node.Bold && node.Italic)
|
||||
disposefont = f = new Font(f, FontStyle.Bold|FontStyle.Italic);
|
||||
else if (node.Bold)
|
||||
disposefont = f = new Font(f, FontStyle.Bold);
|
||||
else if (node.Italic)
|
||||
disposefont = f = new Font(f, FontStyle.Italic);
|
||||
|
||||
string datastring = "";
|
||||
|
||||
if(m_converter != null)
|
||||
datastring = m_converter(column, data);
|
||||
else
|
||||
datastring = data.ToString();
|
||||
|
||||
TextRenderer.DrawText(dc, datastring, f, cellRect, color, flags);
|
||||
|
||||
if (disposefont != null) disposefont.Dispose();
|
||||
}
|
||||
}
|
||||
public virtual void PaintCellPlusMinus(Graphics dc, Rectangle glyphRect, Node node, TreeListColumn column, TreeList.TextFormatting format)
|
||||
{
|
||||
if (!Application.RenderWithVisualStyles)
|
||||
{
|
||||
// find square rect first
|
||||
int diff = glyphRect.Height-glyphRect.Width;
|
||||
glyphRect.Y += diff/2;
|
||||
glyphRect.Height -= diff;
|
||||
|
||||
// draw 8x8 box centred
|
||||
while (glyphRect.Height > 8)
|
||||
{
|
||||
glyphRect.Height -= 2;
|
||||
glyphRect.Y += 1;
|
||||
glyphRect.X += 1;
|
||||
}
|
||||
|
||||
// make a box
|
||||
glyphRect.Width = glyphRect.Height;
|
||||
|
||||
// clear first
|
||||
SolidBrush brush = new SolidBrush(format.BackColor);
|
||||
if (format.BackColor == Color.Transparent)
|
||||
brush = new SolidBrush(m_owner.BackColor);
|
||||
dc.FillRectangle(brush, glyphRect);
|
||||
brush.Dispose();
|
||||
|
||||
// draw outline
|
||||
Pen p = new Pen(SystemColors.ControlDark);
|
||||
dc.DrawRectangle(p, glyphRect);
|
||||
p.Dispose();
|
||||
|
||||
p = new Pen(SystemColors.ControlText);
|
||||
|
||||
// reduce box for internal lines
|
||||
glyphRect.X += 2; glyphRect.Y += 2;
|
||||
glyphRect.Width -= 4; glyphRect.Height -= 4;
|
||||
|
||||
// draw horizontal line always
|
||||
dc.DrawLine(p, glyphRect.X, glyphRect.Y + glyphRect.Height / 2, glyphRect.X + glyphRect.Width, glyphRect.Y + glyphRect.Height / 2);
|
||||
|
||||
// draw vertical line if this should be a +
|
||||
if(!node.Expanded)
|
||||
dc.DrawLine(p, glyphRect.X + glyphRect.Width / 2, glyphRect.Y, glyphRect.X + glyphRect.Width / 2, glyphRect.Y + glyphRect.Height);
|
||||
|
||||
p.Dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
VisualStyleElement element = VisualStyleElement.TreeView.Glyph.Closed;
|
||||
if (node.Expanded)
|
||||
element = VisualStyleElement.TreeView.Glyph.Opened;
|
||||
|
||||
if (VisualStyleRenderer.IsElementDefined(element))
|
||||
{
|
||||
VisualStyleRenderer renderer = new VisualStyleRenderer(element);
|
||||
renderer.DrawBackground(dc, glyphRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class ColumnHeaderPainter
|
||||
{
|
||||
TreeListView m_owner;
|
||||
public ColumnHeaderPainter(TreeListView owner)
|
||||
{
|
||||
m_owner = owner;
|
||||
}
|
||||
|
||||
public static Rectangle AdjustRectangle(Rectangle r, Padding padding)
|
||||
{
|
||||
r.X += padding.Left;
|
||||
r.Width -= padding.Left + padding.Right;
|
||||
r.Y += padding.Top;
|
||||
r.Height -= padding.Top + padding.Bottom;
|
||||
return r;
|
||||
}
|
||||
public virtual void DrawHeaderFiller(Graphics dc, Rectangle r)
|
||||
{
|
||||
if (!Application.RenderWithVisualStyles)
|
||||
{
|
||||
ControlPaint.DrawButton(dc, r, ButtonState.Flat);
|
||||
return;
|
||||
}
|
||||
VisualStyleElement element = VisualStyleElement.Header.Item.Normal;
|
||||
if (VisualStyleRenderer.IsElementDefined(element))
|
||||
{
|
||||
VisualStyleRenderer renderer = new VisualStyleRenderer(element);
|
||||
renderer.DrawBackground(dc, r);
|
||||
}
|
||||
}
|
||||
public void DrawHeaderText(Graphics dc, Rectangle cellRect, TreeListColumn column, TreeList.TextFormatting format)
|
||||
{
|
||||
Color color = format.ForeColor;
|
||||
TextFormatFlags flags = TextFormatFlags.EndEllipsis | format.GetFormattingFlags();
|
||||
TextRenderer.DrawText(dc, column.Caption, column.Font, cellRect, color, flags);
|
||||
}
|
||||
public virtual void DrawHeader(Graphics dc, Rectangle cellRect, TreeListColumn column, TreeList.TextFormatting format, bool isHot, bool highlight)
|
||||
{
|
||||
Rectangle textRect = AdjustRectangle(cellRect, format.Padding);
|
||||
if (!Application.RenderWithVisualStyles)
|
||||
{
|
||||
ControlPaint.DrawButton(dc, cellRect,
|
||||
m_owner.ViewOptions.UserRearrangeableColumns && highlight ? ButtonState.Pushed : ButtonState.Flat);
|
||||
DrawHeaderText(dc, textRect, column, format);
|
||||
return;
|
||||
}
|
||||
VisualStyleElement element = VisualStyleElement.Header.Item.Normal;
|
||||
if (isHot || highlight)
|
||||
element = VisualStyleElement.Header.Item.Hot;
|
||||
if (VisualStyleRenderer.IsElementDefined(element))
|
||||
{
|
||||
VisualStyleRenderer renderer = new VisualStyleRenderer(element);
|
||||
renderer.DrawBackground(dc, cellRect);
|
||||
|
||||
if (format.BackColor != Color.Transparent)
|
||||
{
|
||||
SolidBrush brush = new SolidBrush(format.BackColor);
|
||||
dc.FillRectangle(brush, cellRect);
|
||||
brush.Dispose();
|
||||
}
|
||||
//dc.DrawRectangle(Pens.Black, cellRect);
|
||||
|
||||
DrawHeaderText(dc, textRect, column, format);
|
||||
}
|
||||
}
|
||||
public virtual void DrawVerticalGridLines(TreeListColumnCollection columns, Graphics dc, Rectangle r, int hScrollOffset)
|
||||
{
|
||||
foreach (TreeListColumn col in columns.VisibleColumns)
|
||||
{
|
||||
int rightPos = col.CalculatedRect.Right - hScrollOffset;
|
||||
if (rightPos < 0)
|
||||
continue;
|
||||
Pen p = new Pen(columns.Owner.GridLineColour);
|
||||
dc.DrawLine(p, rightPos, r.Top, rightPos, r.Bottom);
|
||||
p.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
public class RowPainter
|
||||
{
|
||||
public void DrawHeader(Graphics dc, Rectangle r, bool isHot)
|
||||
{
|
||||
if (!Application.RenderWithVisualStyles)
|
||||
{
|
||||
if (r.Width > 0 && r.Height > 0)
|
||||
{
|
||||
ControlPaint.DrawButton(dc, r, ButtonState.Flat);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VisualStyleElement element = VisualStyleElement.Header.Item.Normal;
|
||||
if (isHot)
|
||||
element = VisualStyleElement.Header.Item.Hot;
|
||||
if (VisualStyleRenderer.IsElementDefined(element))
|
||||
{
|
||||
VisualStyleRenderer renderer = new VisualStyleRenderer(element);
|
||||
renderer.DrawBackground(dc, r);
|
||||
}
|
||||
}
|
||||
public void DrawHorizontalGridLine(Graphics dc, Rectangle r, Color col)
|
||||
{
|
||||
Pen p = new Pen(col);
|
||||
dc.DrawLine(p, r.Left, r.Bottom, r.Right, r.Bottom);
|
||||
p.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user