yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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() );
  *]
}