1. Your custom class that derives from Element will need to override the new CreateElementInfo() method, to return your custom CircuitElementInfo:
public class Module : Element
{
…
protected override CircuitElementInfo CreateElementInfo()
{
return new ModuleElementInfo();
}
}
public class ModuleElementInfo : CircuitElementInfo
{
/// <summary>
/// Gets or sets whether this circuit element should be displayed in an enabled state.
/// The default is 'true'.</summary>
public bool Enabled = true;
}
2. You can then create a “disabled theme” in your class that derives from D2dCircuitRenderer, and switch to the disabled theme when drawing disabled circuit elements.
private class CustomCircuitRenderer : D2dCircuitRenderer<Module, Connection, ICircuitPin>
{
public CustomCircuitRenderer(D2dDiagramTheme theme, IDocumentRegistry documentRegistry) :
base(theme, documentRegistry)
{
m_disabledTheme = new D2dDiagramTheme();
m_disabledTheme.FillBrush = D2dFactory.CreateSolidBrush(SystemColors.ControlDark);
m_disabledTheme.TextBrush = D2dFactory.CreateSolidBrush(SystemColors.InactiveCaption);
D2dGradientStop[] gradstops =
{
new D2dGradientStop(Color.DarkGray, 0),
new D2dGradientStop(Color.DimGray, 1.0f),
};
m_disabledTheme.FillGradientBrush = D2dFactory.CreateLinearGradientBrush(gradstops);
// Set the pin colors
m_disabledTheme.RegisterCustomBrush("boolean", D2dFactory.CreateSolidBrush(Color.LightGray));
}
public override void Draw(Module element, DiagramDrawingStyle style, D2dGraphics g)
{
if (!((ModuleElementInfo)element.ElementInfo).Enabled)
{
D2dDiagramTheme defaultTheme = Theme;
Theme = m_disabledTheme;
base.Draw(element, style, g);
Theme = defaultTheme;
return;
}
base.Draw(element, style, g);
}
private readonly D2dDiagramTheme m_disabledTheme;
}
Here is the result using the above test code in CircuitEditor:
Hope that helps! Please let me know how it goes.
--
You received this message because you are subscribed to the Google Groups "Authoring Tools Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to authoring-tools-fr...@googlegroups.com.
Visit this group at http://groups.google.com/group/authoring-tools-framework.
For more options, visit https://groups.google.com/d/optout.
On Wednesday, February 11, 2015 at 6:37:13 PM UTC-8, vorp wrote: