Ejemplo n.º 1
0
 public void OnTreeThemeChanged(TreeViewTheme theme)
 {
     if (TreeThemeChanged != null)
     {
         TreeThemeChanged(this, theme);
     }
 }
Ejemplo n.º 2
0
        // Aga.Controls is basically just TreeViewAdv and all the utility stuff
        // needed to make it work.  These are extensions added to try to help do
        // normal things like insert and remove nodes because the way the
        // TreeViewAdv control works is very strange.
        //
        // TreeViewAdv uses two layers of nodes.  One set of nodes (class
        // TreeNodeAdv) is used to return user selection information and the other
        // set of nodes (class Node) is used to create the tree and store data in.
        // Both sets confusingly hold navigation information.  The Tag property
        // of each (TreeNodeAdv) points to one (Node) which holds the data, so
        // each time you check the selection of nodes you get a list of
        // (TreeNodeAdv)s but you can only add (Node)s to the tree.

        // This is not actually an extension method, but it is needed to work with
        // TreeViewAdv and is not form-specific so I placed it here.
        public static void ColoredTextNode_DrawText(object sender, DrawEventArgs e)
        {
            TreeViewTheme theme = (e.Node.Tree as WTTreeView).Theme;
            // When a text node is drawn, this callback is called to determine
            // the colors to use.  It is not necessary to set or modify any colors
            // in e (DrawEventArgs) unless custom colors are desired.  The color of
            // nodes usually depends on whether they are selected or active.  That
            // information is stored in e.Context.DrawSelectionMode.

            // e.Node is a TreeNodeAdv navigation node.  e.Node.Tag points to the
            // actual data node which must be of type Node or a descendant of
            // Node.  It is ColoredTextNode in this program.
            ColoredTextNode node = e.Node.Tag as ColoredTextNode;

            // The node is drawn with different colors depending on whether it is
            // selected and whether or not the control is active.  The state is
            // provided in e.Context.DrawSelection.
            //if (e.Context.DrawSelection == DrawSelectionMode.None)
            //{
            //    e.TextColor = theme.ForeColor;
            //    e.BackgroundBrush = theme.BackBrush;
            //}
            if (e.Context.DrawSelection == DrawSelectionMode.None)
            {
                e.TextColor       = (e.Node.Tag as ColoredTextNode).ForeColor;
                e.BackgroundBrush = theme.BackBrush;
            }
            else if (e.Context.DrawSelection == DrawSelectionMode.Active)
            {
                e.TextColor       = theme.HighlightForeColor;
                e.BackgroundBrush = theme.HighlightBackBrush;
            }
            else if (e.Context.DrawSelection == DrawSelectionMode.Inactive)
            {
                e.TextColor       = theme.InactiveForeColor;
                e.BackgroundBrush = theme.InactiveBackBrush;
            }
            else if (e.Context.DrawSelection == DrawSelectionMode.FullRowSelect)
            {
                e.TextColor       = theme.HighlightForeColor;
                e.BackgroundBrush = theme.BackBrush;
            }

            if (!e.Context.Enabled)
            {
                e.TextColor = theme.DisabledForeColor;
            }

            // Apply a custom font if the node has one
            if (node.Font != null)
            {
                e.Font = node.Font;
            }
        }
Ejemplo n.º 3
0
 public void OnTreeThemeChanged(InventoryList ilist, TreeViewTheme theme)
 {
     Tree.Theme = theme;
 }