Quintiq file version 2.0
#parent: CustomDrawComponentRoutingConfigurator/CustomDrawDataLayerOperation
Response OnDrawObject (
  Operation object
) id:Response_CustomDrawComponentRoutingConfigurator_CustomDrawDataLayerOperation_OnDrawObject
{
  #keys: '[124808.0.1222257144]'
  Body:
  [*
    // Draw operation
    imagesize := minvalue( region.Height(), region.Width() );
    
    //Initialize borders
    surface.Pen().Style( PenSpecification::StyleSolid() );
    surface.Pen().Width( 1 )
    surface.Pen().Color( ColorScheme.Outline() );
    
    //Initialize filled colors
    //It is safe to use color scheme as the routing config is not user / scenario specific
    colorstart := ColorScheme.RoutingConfigurator_Operation1();
    colorend := ColorScheme.RoutingConfigurator_Operation2();
    
    // Set color to black if operation is being disabled
    if( not object.IsEnabled() )
    {
      colorstart := ColorScheme.RoutingConfiguratorDisabled();
      colorend := ColorScheme.RoutingConfiguratorDisabled();
    }
    
    surface.Brush().LinearGradient( region, colorstart, colorend, 0.0 );
    surface.Fill( region );
    
    surface.Image( region.Left(), region.Top(), imagesize, imagesize, object.Unit().IconName()  + '(32)'  );
    surface.Rect( region.Left(), region.Top(), region.Width(), region.Height(), Color::Black() );
    
    
    //Draw text
    rcv := DataHolderRCView.Data();
    surface.Font().Name( rcv.FontName() );
    surface.Font().Size( rcv.FontSize() );
    surface.TextColor( Color::Black() );
    
    textformat := TextFormat::Construct( TextFormat::AlignCenter(), TextFormat::AlignMiddle() );
    surface.Text( imagesize, 0, region.Width() - imagesize , region.Height(), text, textformat ); // Add offset for images
    
    
    //draw input output drop here!
    //guide to be drawn below the operation
    routing := guard( object.RoutingStep().Routing(), null( Routing ) );
    
    if( not isnull( routing ) and not routing.HasInputOrOutput() )
    {
      surface.Pen().Style( PenSpecification::StyleDotted() );
      surface.Pen().Width( rcv.EdgeThickness() )
      surface.Pen().Color( ColorScheme.RoutingConfigurator_DropHereHelp() );
      surface.Brush().Color( ColorScheme.RoutingConfigurator_DropHereHelp() ); // to paint the solid arrowhead
    
      surface.TextColor( ColorScheme.RoutingConfigurator_DropHereHelp() );
    
      lblx := region.Left();
      lbly := region.Height() + 20;
    
      midh := [Number]( region.Height() / 2 );
      midw := [Number]( region.Width() / 2 );
    
      line := GraphicalLine::LineTo( midw, lbly, midw, midh );
      line.ArrowToEnd( true ).ArrowPos( GraphicalLine::ArrowPosEnd() );
      surface.Draw( line );
    
      surface.Text( lblx, lbly, Translations::MP_Routing_DropHereIO() );
    }
  *]
  CanBindMultiple: false
  DefinitionID: 'Responsedef_CustomDrawDataLayer_OnDrawObject'
  Precondition:
  [*
    return not isnull( DataHolderRCView.Data() );
  *]
}
