Exemplo n.º 1
0
 public static Rule Convert(WD_Rule wdRule)
 {
     return(new Rule
     {
         Action = new PlacementAction
         {
             Placement = WD_Dock.Convert(wdRule.Dock),
         },
         Trigger = WD_Trigger.Convert(wdRule.Trigger),
     });
 }
Exemplo n.º 2
0
        public static RuleTrigger Convert(WD_Trigger wdTrigger)
        {
            RuleTrigger trigger;

            switch (wdTrigger.Type)
            {
            case WD_TriggerType.Area:
                trigger = new AreaTrigger
                {
                    Area = new Rectangle(wdTrigger.Values[0], wdTrigger.Values[1], wdTrigger.Values[2] - wdTrigger.Values[0], wdTrigger.Values[3] - wdTrigger.Values[1]),
                };
                break;

            case WD_TriggerType.Edge:
                EdgePosition edgePosition;
                switch (wdTrigger.Position)
                {
                case WD_TriggerPosition.Left: edgePosition = EdgePosition.Left; break;

                case WD_TriggerPosition.Top: edgePosition = EdgePosition.Top; break;

                case WD_TriggerPosition.Right: edgePosition = EdgePosition.Right; break;

                case WD_TriggerPosition.Bottom: edgePosition = EdgePosition.Bottom; break;

                default: throw new NotSupportedException();
                }
                trigger = new EdgeTrigger
                {
                    Position = edgePosition,
                    From     = wdTrigger.Values[0],
                    To       = wdTrigger.Values[1],
                };
                break;

            case WD_TriggerType.Corner:
                CornerPosition cornerPosition;
                switch (wdTrigger.Position)
                {
                case WD_TriggerPosition.TopLeft: cornerPosition = CornerPosition.TopLeft; break;

                case WD_TriggerPosition.TopRight: cornerPosition = CornerPosition.TopRight; break;

                case WD_TriggerPosition.BottomLeft: cornerPosition = CornerPosition.BottomLeft; break;

                case WD_TriggerPosition.BottomRight: cornerPosition = CornerPosition.BottomRight; break;

                default: throw new NotSupportedException();
                }
                trigger = new CornerTrigger
                {
                    Position = cornerPosition,
                };
                break;

            default: throw new NotSupportedException();
            }

            trigger.DisplayIndex = wdTrigger.Monitor + 1;
            return(trigger);
        }