Пример #1
0
        //--------------------------------------------------------------------------------------------------

        void _OnActionPreview(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (_PointsCompleted)
                {
                case 1:
                    if (_HintLines[0] == null)
                    {
                        _HintLines[0] = new HintLine(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    }
                    _HintLines[0].Set(_CenterPoint, _PointAction.Point, _SketchEditorTool.Sketch.Plane);
                    break;

                case 2:
                    if (_HintLines[1] == null)
                    {
                        _HintLines[1] = new HintLine(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    }
                    _HintLines[1].Set(_CenterPoint, _PointAction.Point, _SketchEditorTool.Sketch.Plane);

                    if (_Segment != null)
                    {
                        _CalcArcRimPoints(_PointAction.Point);
                        _Element.OnPointsChanged(_Points, null);
                    }
                    break;
                }

                _Coord2DHudElement?.SetValues(_PointAction.Point.X, _PointAction.Point.Y);
            }
        }
        //--------------------------------------------------------------------------------------------------

        void _OnActionPreview(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (_PointsCompleted)
                {
                case 1:
                    var p1 = _Points[0];
                    var p2 = _PointAction.Point;
                    if (_PreviewLine == null)
                    {
                        _PreviewLine = new HintLine(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    }
                    _PreviewLine.Set(p1, p2, _SketchEditorTool.Sketch.Plane);
                    break;

                case 2:
                    if (_Segment != null)
                    {
                        _Points[2] = _PointAction.Point;
                        _Element.OnPointsChanged(_Points, null);

                        if (_LabelHudElement == null)
                        {
                            _LabelHudElement = _SketchEditorTool.WorkspaceController.HudManager?.CreateElement <LabelHudElement>(this);
                        }
                        _LabelHudElement?.SetValue("Radius: " + _Segment.Radius(_Points).ToRoundedString());
                    }
                    break;
                }

                _Coord2DHudElement?.SetValues(_PointAction.Point.X, _PointAction.Point.Y);
            }
        }
Пример #3
0
        public override void redoAction(ToolAction action)
        {
            FillToolAction data = (FillToolAction)action;

            fill(data.texture, data.startTile);
            editor.world.initTiles();
        }
        //--------------------------------------------------------------------------------------------------

        void _OnActionPreview(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                if (_Segment != null)
                {
                    _Points[1] = _PointAction.Point;
                    _Element.OnPointsChanged(_Points, null);
                    _SketchEditorTool.WorkspaceController.Invalidate();

                    if (_LabelHudElement == null)
                    {
                        _LabelHudElement = _SketchEditorTool.WorkspaceController.HudManager?.CreateElement <LabelHudElement>(this);
                    }
                    if (_LabelHudElement != null)
                    {
                        _LabelHudElement.Text = "Radius: " + _Segment.Radius(_Points).ToRoundedString();
                    }
                }

                if (_Coord2DHudElement != null)
                {
                    _Coord2DHudElement.CoordinateX = _PointAction.Point.X;
                    _Coord2DHudElement.CoordinateY = _PointAction.Point.Y;
                }
            }
        }
        private bool IsToolActionEnabled(ToolAction action)
        {
            if (_operationInProgress)
            {
                return(false);
            }

            for (int i = 0; i < toolStripMain.Items.Count; i++)
            {
                ToolStripItem btn = toolStripMain.Items[i] as ToolStripItem;

                if (btn == null ||
                    string.IsNullOrEmpty(btn.Tag as string))
                {
                    // Not an action button, continue.
                    continue;
                }

                if ((btn.Tag as string).ToLowerInvariant() == action.ToString().ToLowerInvariant())
                {
                    return(btn.Enabled);
                }
            }

            return(true);
        }
Пример #6
0
        public void Run(Version version, string rootSuffix, ToolAction toolAction, string arg1)
        {
            var obj           = CreateExtensionManager(version, rootSuffix);
            var commandRunner = new CommandRunner(version, rootSuffix, (IVsExtensionManager)obj);

            commandRunner.Run(toolAction, arg1);
        }
Пример #7
0
        //--------------------------------------------------------------------------------------------------

        void _OnActionPreview(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (_PointsFinished)
                {
                case 1:
                    _HintLine.Set(_Points[0], _PointAction.Point, _SketchEditorTool.Sketch.Plane);
                    break;

                case 2:
                    _Points[1] = _PointAction.Point;
                    _Points[2] = _PointAction.Point;
                    _Element.OnPointsChanged(_Points, null);
                    break;

                case 3:
                    _Points[2] = _PointAction.Point;
                    _Element.OnPointsChanged(_Points, null);
                    break;
                }

                _Coord2DHudElement?.SetValues(_PointAction.Point.X, _PointAction.Point.Y);
            }
        }
Пример #8
0
        //--------------------------------------------------------------------------------------------------

        void _OnActionFinished(ToolAction toolAction)
        {
            bool finished     = false;
            var  selectAction = toolAction as SelectSubshapeAction;

            Debug.Assert(selectAction != null);

            if (selectAction.SelectedSubshapeType == SubshapeTypes.Face)
            {
                var face        = TopoDS.Face(selectAction.SelectedSubshape);
                var brepAdaptor = new BRepAdaptor_Surface(face, true);
                if (brepAdaptor.GetGeomType() != GeomAbs_SurfaceType.GeomAbs_Plane)
                {
                    StatusText = "Selected face is not a plane type surface.";
                }
                else
                {
                    selectAction.Stop();
                    Stop();
                    finished = true;

                    FaceAlgo.GetCenteredPlaneFromFace(face, out _Plane);
                    CreateSketch();
                }
            }

            if (!finished)
            {
                selectAction.Reset();
            }

            WorkspaceController.Invalidate();
        }
        //--------------------------------------------------------------------------------------------------

        void _OnActionFinished(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                if (_Segments == null)
                {
                    _Points.Add(0, _PointAction.Point);
                    _MergePointIndices[0] = _PointAction.MergeCandidateIndex;
                    _UpdateCornerPoints(_PointAction.Point);

                    _Segments    = new SketchSegmentLine[4];
                    _Segments[0] = new SketchSegmentLine(0, 1);
                    _Segments[1] = new SketchSegmentLine(1, 2);
                    _Segments[2] = new SketchSegmentLine(2, 3);
                    _Segments[3] = new SketchSegmentLine(3, 0);

                    _Elements = new SketchEditorSegmentElement[4];
                    for (int i = 0; i < _Elements.Length; i++)
                    {
                        _Elements[i]            = new SketchEditorSegmentElement(_SketchEditorTool, -1, _Segments[i], _SketchEditorTool.Transform, _SketchEditorTool.Sketch.Plane);
                        _Elements[i].IsCreating = true;
                        _Elements[i].OnPointsChanged(_Points, null);
                    }

                    _SketchEditorTool.StatusText = "Select second corner or the rectangle.";

                    _PointAction.Reset();
                }
                else
                {
                    _SetSecondPoint(_PointAction.Point, _PointAction.MergeCandidateIndex);
                }
            }
        }
        //--------------------------------------------------------------------------------------------------

        void _FinishPivotPoint(ToolAction toolAction)
        {
            if (!(toolAction is PointAction pointAction))
            {
                return;
            }

            _Point = pointAction.Point.Round();
            pointAction.Stop();

            var axisValueAction = new AxisValueAction(this, new Ax1(_Point, Dir.DZ));

            if (!WorkspaceController.StartToolAction(axisValueAction))
            {
                return;
            }
            axisValueAction.Previewed += _PreviewRadius;
            axisValueAction.Finished  += _FinishRadius;

            _CurrentPhase = Phase.Radius;
            StatusText    = "Select Radius.";

            WorkspaceController.HudManager?.RemoveElement(_Coord2DHudElement);
            _ValueHudElement = WorkspaceController.HudManager?.CreateElement <ValueHudElement>(this);
            if (_ValueHudElement != null)
            {
                _ValueHudElement.Label         = "Radius:";
                _ValueHudElement.Units         = ValueUnits.Length;
                _ValueHudElement.ValueEntered += _ValueEntered;
            }

            WorkspaceController.HudManager?.SetCursor(Cursors.SetRadius);
        }
Пример #11
0
    public void Finish()
    {
        _FryingStatus = FryingStatus.finish;
        t_time        = 0f;

        Transform  toolA   = GameManagement.ToolObjectParent.transform;
        ToolAction t_empty = null;

        foreach (Transform t in toolA)
        {
            ToolAction ta = t.GetComponent <ToolAction>();
            if (ta.UsageFor == Usage.placement)
            {
                if (t_empty == null && ta.tool.CheckGorengan() == null)
                {
                    t_empty = ta;
                }

                if (ta.tool.CheckGorengan() != null && ta.tool.CheckGorengan().ids == _friyingGorengan.ids)
                {
                    t_empty = ta;
                    break;
                }
            }
        }
        if (t_empty != null)
        {
            t_empty.tool.AddGorengan(_friyingGorengan);
        }

        _FryingStatus    = FryingStatus.empty;
        _friyingGorengan = null;
    }
Пример #12
0
    public static void AddGorenganToWajan(Gorengan gorengan)
    {
        bool        isAvailable = false;
        CookingItem item        = GameManagement.CookingItems.Find(x => x.UsageTool == Usage.cooking);

        foreach (Transform obj in GameManagement.ToolObjectParent.transform)
        {
            ToolAction tool_a = obj.GetComponent <ToolAction>();
            if (item.Level >= tool_a.UnlockLevel && tool_a.UsageFor == Usage.cooking)
            {
                Wajan tool = tool_a.tool as Wajan;
                Debug.Log("wajan level : " + item.Level + ", requirement : " + tool_a.UnlockLevel + ", status empty : " + tool.Status());
                if (tool != null && tool.Status() == FryingStatus.empty)
                {
                    GameManagement.Player.ReduceMoney(gorengan.Cost);
                    tool.Use(gorengan);
                    isAvailable = true;
                    break;
                }
            }
        }

        if (!isAvailable)
        {
            GameManagement.WarningText = "Wajan is Full";
        }
    }
        //--------------------------------------------------------------------------------------------------

        void _FinishPivotPoint(ToolAction toolAction)
        {
            if (!(toolAction is PointAction pointAction))
            {
                return;
            }

            _Plane       = WorkspaceController.Workspace.WorkingPlane;
            _PointPlane1 = pointAction.PointOnPlane;
            _PivotPoint  = pointAction.Point;

            pointAction.Stop();
            pointAction = new PointAction(this);
            if (!WorkspaceController.StartToolAction(pointAction))
            {
                return;
            }
            pointAction.Previewed += _PreviewRadius;
            pointAction.Finished  += _FinishRadius;

            _CurrentPhase = Phase.Radius;
            StatusText    = "Select radius.";

            _ValueHudElement = WorkspaceController.HudManager?.CreateElement <ValueHudElement>(this);
            if (_ValueHudElement != null)
            {
                _ValueHudElement.Label         = "Radius:";
                _ValueHudElement.Units         = ValueUnits.Length;
                _ValueHudElement.ValueEntered += _ValueEntered;
            }

            WorkspaceController.HudManager?.SetCursor(Cursors.SetRadius);
        }
Пример #14
0
    private bool isOrderEnough(List <Order> orders)
    {
        bool ifEnough = true;

        foreach (Order o in orders)
        {
            bool isFoundOrder = false;
            foreach (Transform obj in GameManagement.ToolObjectParent.transform)
            {
                ToolAction tool = obj.GetComponent <ToolAction>();

                if (tool.UsageFor == Usage.placement)
                {
                    if (tool.tool.CheckGorengan() != null && tool.tool.CheckGorengan().ids == o.item.ids && tool.tool.GetTotal() >= o.total)
                    {
                        isFoundOrder = true;
                    }
                }
            }
            if (isFoundOrder == false)
            {
                Debug.Log("is not enough");
                ifEnough = false;
                break;
            }
        }

        return(ifEnough);
    }
        //--------------------------------------------------------------------------------------------------

        void _FinishRadius(ToolAction toolAction)
        {
            toolAction?.Stop();
            var axisValueAction = new AxisValueAction(this, new Ax1(_PivotPoint.Round(), _Plane.Axis.Direction));

            if (!WorkspaceController.StartToolAction(axisValueAction))
            {
                return;
            }
            axisValueAction.Previewed += _PreviewHeight;
            axisValueAction.Finished  += _FinishHeight;

            _CurrentPhase = Phase.Height;
            StatusText    = "Select height.";

            if (_ValueHudElement != null)
            {
                _ValueHudElement.Label = "Height:";
                _ValueHudElement.Value = 0;
            }

            WorkspaceController.HudManager?.RemoveElement(_Coord2DHudElement);
            WorkspaceController.HudManager?.SetCursor(Cursors.SetHeight);

            _PreviewHeight(axisValueAction);
        }
Пример #16
0
    public override void Addlevel()
    {
        Debug.Log("Add level wajan");
        CookingItem item = GameManagement.CookingItems.Find(x => x.UsageTool == Usage.cooking);

        Debug.Log("Add level Wajan Level : " + item.Level + ", Max Level : " + item.MaxLevel);
        if (GameManagement.Player.Money < item.Price || item.Level >= item.MaxLevel)
        {
            if (GameManagement.Player.Money < item.Price)
            {
                GameManagement.WarningText = "Not Enough Money To Upgrade";
            }
            else if (item.Level >= item.MaxLevel)
            {
                GameManagement.WarningText = "Already MAX Level";
            }
            return;
        }

        item.Level++;
        GameObject obj = GameManagement.ToolObjectParent.gameObject;

        GameManagement.Player.ReduceMoney(item.Price);
        foreach (Transform t in obj.transform)
        {
            ToolAction action = t.GetComponent <ToolAction>();
            if (action.UsageFor == Usage.cooking)
            {
                action.CheckUnlockStatus();
            }
        }
    }
Пример #17
0
        //--------------------------------------------------------------------------------------------------

        void _OnActionPreview(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                if (_Segments != null)
                {
                    _SetSecondPoint(_PointAction.Point);
                    foreach (var component in _Elements)
                    {
                        component.OnPointsChanged(_Points, null);
                    }

                    if (_LabelHudElement == null)
                    {
                        _LabelHudElement = _SketchEditorTool.WorkspaceController.HudManager?.CreateElement <LabelHudElement>(this);
                    }
                    if (_LabelHudElement != null)
                    {
                        _LabelHudElement.Text = "Size: " + (_Points[0].X - _Points[2].X).Abs().ToRoundedString()
                                                + " x " + (_Points[0].Y - _Points[2].Y).Abs().ToRoundedString();
                    }
                }

                if (_Coord2DHudElement != null)
                {
                    _Coord2DHudElement.CoordinateX = _PointAction.Point.X;
                    _Coord2DHudElement.CoordinateY = _PointAction.Point.Y;
                }
            }
        }
Пример #18
0
 /// <summary>
 /// Creates the tool actions
 /// </summary>
 private void SetupActions()
 {
     m_zoningAction = new ZoningAction();
     m_zoningAction.OnStart(this);
     m_movingZoneAction = new MovingZoneAction();
     m_movingZoneAction.OnStart(this);
 }
Пример #19
0
    //--------------------------------------------------------------------------------------------------

    void _OnActionFinished(ToolAction toolAction)
    {
        var ta = toolAction as SelectEntityAction <Body>;

        if (ta == null)
        {
            return;
        }

        ta.Stop();

        ModifierBase boolOpShape = null;

        if (ta.SelectedEntity != null)
        {
            boolOpShape = Execute(_SourceBody, new IShapeOperand[] { new BodyShapeOperand(ta.SelectedEntity) });
        }

        Stop();

        if (boolOpShape != null)
        {
            InteractiveContext.Current.UndoHandler.Commit();
            InteractiveContext.Current.WorkspaceController.Selection.SelectEntity(_SourceBody);
        }

        WorkspaceController.Invalidate();
    }
Пример #20
0
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region Selection

        void _OnSelectionChanged(ToolAction toolAction)
        {
            if (CurrentTool != null)
            {
                return;
            }

            if (_MoveAction != null)
            {
                _MoveAction.Stop();
                _MoveAction = null;
            }

            _UpdateSelections();

            if (SelectedSegments.Any() || SelectedPoints.Any())
            {
                _MoveAction = new MoveSketchPointAction(this);
                if (!WorkspaceController.StartToolAction(_MoveAction, false))
                {
                    return;
                }
                _MoveAction.Previewed += _OnMoveActionPreview;
                _MoveAction.Finished  += _OnMoveActionFinished;

                var segPoints = SelectedSegments.SelectMany(seg => seg.Points);
                _MoveAction.SetSketchElements(Sketch, SelectedPoints.Union(segPoints).ToList());
            }

            WorkspaceController.Invalidate();
        }
Пример #21
0
        //--------------------------------------------------------------------------------------------------

        void _FinishBaseRect(ToolAction toolAction)
        {
            toolAction?.Stop();

            var axisPosition    = ElSLib.Value(_PointPlane2.X, _PointPlane2.Y, _Plane);
            var axisValueAction = new AxisValueAction(this, new Ax1(axisPosition, _Plane.Axis.Direction));

            axisValueAction.Previewed += _PreviewHeight;
            axisValueAction.Finished  += _FinishHeight;

            if (!WorkspaceController.StartToolAction(axisValueAction))
            {
                return;
            }

            WorkspaceController.HudManager?.RemoveElement(_Coord2DHudElement);
            _CurrentPhase = Phase.Height;
            StatusText    = "Select height.";

            WorkspaceController.HudManager?.RemoveElement(_MultiValueHudElement);
            _ValueHudElement = WorkspaceController.HudManager?.CreateElement <ValueHudElement>(this);
            if (_ValueHudElement != null)
            {
                _ValueHudElement.Label         = "Height:";
                _ValueHudElement.ValueEntered += _ValueEntered;
                _ValueHudElement.Units         = ValueUnits.Length;
            }

            WorkspaceController.HudManager?.SetCursor(Cursors.SetHeight);

            _PreviewHeight(axisValueAction);
        }
        //--------------------------------------------------------------------------------------------------

        void _OnActionPreview(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                if (_Segments != null)
                {
                    _UpdateCornerPoints(_PointAction.Point);
                    foreach (var component in _Elements)
                    {
                        component.OnPointsChanged(_Points, null);
                    }

                    if (_ValueHudElement == null && _SketchEditorTool.WorkspaceController.HudManager != null)
                    {
                        _ValueHudElement                    = _SketchEditorTool.WorkspaceController.HudManager?.CreateElement <MultiValueHudElement>(this);
                        _ValueHudElement.Label1             = "Size X:";
                        _ValueHudElement.Units1             = ValueUnits.Length;
                        _ValueHudElement.Label2             = "Size Y:";
                        _ValueHudElement.Units2             = ValueUnits.Length;
                        _ValueHudElement.MultiValueEntered += _ValueHudElement_MultiValueEntered;
                    }
                    _ValueHudElement?.SetValue1(_Points[2].X - _Points[0].X);
                    _ValueHudElement?.SetValue2(_Points[2].Y - _Points[0].Y);
                }

                _Coord2DHudElement?.SetValues(_PointAction.PointOnWorkingPlane.X, _PointAction.PointOnWorkingPlane.Y);
            }
        }
Пример #23
0
        //--------------------------------------------------------------------------------------------------

        void _FinishPivotPoint(ToolAction toolAction)
        {
            if (!(toolAction is PointAction pointAction))
            {
                return;
            }

            _ClearPreviews();

            _Plane       = WorkspaceController.Workspace.WorkingPlane;
            _PointPlane1 = pointAction.PointOnPlane;

            pointAction.Stop();
            pointAction            = new PointAction(this);
            pointAction.Previewed += _PreviewBaseRect;
            pointAction.Finished  += _FinishBaseRect;
            if (!WorkspaceController.StartToolAction(pointAction))
            {
                return;
            }

            _CurrentPhase = Phase.BaseRect;
            StatusText    = "Select opposite corner point.";

            _MultiValueHudElement = WorkspaceController.HudManager?.CreateElement <MultiValueHudElement>(this);
            if (_MultiValueHudElement != null)
            {
                _MultiValueHudElement.Label1             = "Length:";
                _MultiValueHudElement.Units1             = ValueUnits.Length;
                _MultiValueHudElement.Label2             = "Width:";
                _MultiValueHudElement.Units2             = ValueUnits.Length;
                _MultiValueHudElement.MultiValueEntered += _MultiValueEntered;
            }
        }
Пример #24
0
        private void PerformAction(ToolAction action)
        {
            BaseMdiChildForm child = this.ActiveMdiChildForm;

            if (child == null)
            {
                return;
            }

            switch (action)
            {
            case ToolAction.Inquiry:
                PerformInquiry(child, child.AuthCollection["R"]);
                break;

            case ToolAction.Add:
                PerformAdd(child, child.AuthCollection["C"]);
                break;

            case ToolAction.Delete:
                PerformDelete(child, child.AuthCollection["D"]);
                break;

            case ToolAction.Save:
                PerformSave(child, child.AuthCollection["S"]);
                break;
            }
        }
Пример #25
0
        //--------------------------------------------------------------------------------------------------

        void _OnActionPreview(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (_PointsCompleted)
                {
                case 1:
                    var p1 = _Points[0];
                    var p2 = _PointAction.Point;
                    _PreviewLine ??= new HintLine(_SketchEditorTool.WorkspaceController, HintStyle.ThinDashed | HintStyle.Topmost);
                    _PreviewLine.Set(p1, p2, _SketchEditorTool.Sketch.Plane);
                    break;

                case 2:
                    if (_Segment != null)
                    {
                        _Points[2] = _PointAction.Point;
                        _Element.OnPointsChanged(_Points, null);

                        if (_ValueHudElement == null && _SketchEditorTool.WorkspaceController.HudManager != null)
                        {
                            _ValueHudElement               = _SketchEditorTool.WorkspaceController.HudManager?.CreateElement <ValueHudElement>(this);
                            _ValueHudElement.Label         = "Radius:";
                            _ValueHudElement.Units         = ValueUnits.Length;
                            _ValueHudElement.ValueEntered += _ValueHudElement_RadiusEntered;
                        }
                        _ValueHudElement?.SetValue(_Segment.Radius(_Points));
                    }
                    break;
                }

                _Coord2DHudElement?.SetValues(_PointAction.PointOnWorkingPlane.X, _PointAction.PointOnWorkingPlane.Y);
            }
        }
Пример #26
0
        //--------------------------------------------------------------------------------------------------

        void _OnActionFinished(ToolAction toolAction)
        {
            if (toolAction == _PointAction)
            {
                switch (_PointsCompleted)
                {
                case 0:
                    _Points.Add(0, _PointAction.Point);
                    _MergePointIndices[0] = _PointAction.MergeCandidateIndex;
                    _PointsCompleted++;

                    _SketchEditorTool.StatusText = "Select end point for circular arc.";

                    _PointAction.Reset();
                    break;

                case 1:
                    if (_Points[0].Distance(_PointAction.Point) < 0.001)
                    {
                        // Minimum length not met
                        _PointAction.Reset();
                        return;
                    }

                    _Points.Add(1, _PointAction.Point);
                    _MergePointIndices[1] = _PointAction.MergeCandidateIndex;
                    _PointsCompleted++;

                    _Points.Add(2, _PointAction.Point);
                    _Segment = new SketchSegmentArc(0, 1, 2);

                    _Element            = new SketchEditorSegmentElement(_SketchEditorTool, -1, _Segment, _SketchEditorTool.Transform, _SketchEditorTool.Sketch.Plane);
                    _Element.IsCreating = true;
                    _Element.OnPointsChanged(_Points, null);

                    _SketchEditorTool.StatusText = "Select rim point for circular arc.";

                    _PointAction.Reset();
                    break;

                case 2:
                    if (_Points[0].Distance(_PointAction.Point) < 0.001 ||
                        _Points[1].Distance(_PointAction.Point) < 0.001)
                    {
                        // Minimum length not met
                        _PointAction.Reset();
                        return;
                    }

                    _PointAction.Stop();

                    _Points[2]            = _PointAction.Point;
                    _MergePointIndices[2] = _PointAction.MergeCandidateIndex;

                    _SketchEditorTool.FinishSegmentCreation(_Points, _MergePointIndices, new SketchSegment[] { _Segment }, null);
                    break;
                }
            }
        }
Пример #27
0
    // Apply input to effect garden
    private void ApplyAction(ToolAction a)
    {
        // Apply tool action to appropriate effect
        Vector3 v = transform.position;

        switch (a)
        {
        // TODO: Expand area of effect

        case ToolAction.Dig:
            ApplyDig(v);
            break;

        case ToolAction.Fill:
            ApplyFill(v);
            break;

        case ToolAction.Soften:
            Instantiate(dirtCloud, transform.position, Quaternion.identity, effectContainer);
            gardenBoard.ApplyAction(v, a);
            break;

        case ToolAction.Grass:
            Instantiate(grassCloud, transform.position, Quaternion.identity, effectContainer);
            gardenBoard.ApplyAction(v, a);
            break;

        case ToolAction.Remove:
            gardenBoard.ApplyAction(v, a);
            break;

        case ToolAction.Wet:
            gardenBoard.ApplyAction(v, a);
            break;

        case ToolAction.Dry:
            gardenBoard.ApplyAction(v, a);
            break;

        case ToolAction.Heat:
            gardenBoard.ApplyAction(v, a);
            break;

        case ToolAction.Chill:
            gardenBoard.ApplyAction(v, a);
            break;

        case ToolAction.Plant_Seed:
            // garden.TryAddUnit(seedPrefabs[seedIndex], transform.position, Quaternion.identity);
            break;

        case ToolAction.Swap_Seed:
            seedIndex = (seedIndex + 1) % seedPrefabs.Length;
            break;

        default:
            break;
        }
    }
Пример #28
0
            public void ToolActionNoArg(string option, ToolAction toolAction)
            {
                var consoleContext = new TestConsoleContext();

                var commandLine = Program.ParseCommandLine(consoleContext, option);

                Assert.That(commandLine.ToolAction, Is.EqualTo(toolAction));
            }
Пример #29
0
 public static bool IsValid(ToolAction value)
 {
     if (value >= ToolAction.None)
     {
         return(value <= ToolAction.DragOutside);
     }
     return(false);
 }
Пример #30
0
 internal CommandLine(ToolAction toolAction, string version, string[] skus, string rootSuffix, string arg)
 {
     ToolAction = toolAction;
     Version    = version;
     Skus       = skus;
     RootSuffix = rootSuffix;
     Arg        = arg;
 }
Пример #31
0
        private void HandleAction(ToolAction action)
        {
            try
            {
                if (!IsToolActionEnabled(action))
                    return;

                updateUiTimer.Stop();

                List<string> selItems = opmShellList.SelectedPaths;
                switch (action)
                {
                    case ToolAction.ToolActionNewFolder:
                        opmShellList.CreateNewFolder();
                        return;

                    case ToolAction.ToolActionBack:
                        opmShellList.ExploreBack();
                        return;

                    case ToolAction.ToolActionFwd:
                        opmShellList.ExploreForward();
                        return;

                    case ToolAction.ToolActionUp:
                        NavigateUp();
                        return;

                    case ToolAction.ToolActionSearch:
                        SearchWizard.Tasks.Task taskSearch = new SearchWizard.Tasks.Task();
                        taskSearch.SearchPath = opmShellList.Path;
                        if (SearchWizardMain.Execute(taskSearch) == DialogResult.OK)
                        {
                            switch (taskSearch.Action)
                            {
                                case ToolAction.ToolActionProTONEEnqueue:
                                    {
                                        if (taskSearch.MatchingItems.Count > 0)
                                        {
                                            RemoteControlHelper.SendPlayerCommand(
                                                OPMedia.Runtime.ProTONE.RemoteControl.CommandType.EnqueueFiles,
                                                taskSearch.MatchingItems.ToArray());
                                        }
                                    }
                                    break;

                                case ToolAction.ToolActionProTONEPlay:
                                    {
                                        if (taskSearch.MatchingItems.Count > 0)
                                        {
                                            RemoteControlHelper.SendPlayerCommand(
                                                OPMedia.Runtime.ProTONE.RemoteControl.CommandType.PlayFiles,
                                                taskSearch.MatchingItems.ToArray());
                                        }
                                    }
                                    break;

                                case ToolAction.ToolActionJumpToItem:
                                    if (taskSearch.MatchingItems.Count > 0)
                                    {
                                        opmShellList.JumpToItem(taskSearch.MatchingItems[0], false);
                                    }
                                    break;

                                case ToolAction.ToolActionTaggingWizard:
                                    {
                                        TaggedFileProp.TaggingWizard.Task taskTagging = new TaggedFileProp.TaggingWizard.Task();
                                        foreach (string item in taskSearch.MatchingItems)
                                        {
                                            if (Directory.Exists(item))
                                            {
                                                taskTagging.Files.AddRange(Directory.EnumerateFiles(item, "*.mp?", SearchOption.AllDirectories));
                                            }
                                            else if (File.Exists(item))
                                            {
                                                taskTagging.Files.Add(item);
                                            }
                                        }
                                        
                                        TaggingWizardMain.Execute(FindForm(), taskTagging);
                                        ReloadProperties();
                                    }
                                    break;

                                case ToolAction.ToolActionCopy:
                                    _fileTask = new FEFileTaskForm(FileTaskType.Copy, taskSearch.MatchingItems, opmShellList.Path);
                                    break;

                                case ToolAction.ToolActionCut:
                                    _fileTask = new FEFileTaskForm(FileTaskType.Move, taskSearch.MatchingItems, opmShellList.Path);
                                    break;

                                case ToolAction.ToolActionDelete:
                                    _fileTask = new FEFileTaskForm(FileTaskType.Delete, taskSearch.MatchingItems, opmShellList.Path);
                                    break;

                                case ToolAction.ToolActionLaunch:
                                    if (taskSearch.MatchingItems.Count > 0)
                                    {
                                        opmShellList.OpenItem(taskSearch.MatchingItems[0]);
                                    }
                                    break;
                            }
                        }
                        return;

                    case ToolAction.ToolActionReload:
                        GlobalReload();
                        return;

                    case ToolAction.ToolActionTaggingWizard:
                        {
                            TaggedFileProp.TaggingWizard.Task taskTagging = new TaggedFileProp.TaggingWizard.Task();
                            foreach(string item in opmShellList.SelectedPaths)
                            {
                                if (Directory.Exists(item))
                                {
                                    taskTagging.Files.AddRange(Directory.EnumerateFiles(item, "*.mp?", SearchOption.AllDirectories));
                                }
                                else if (File.Exists(item))
                                {
                                    taskTagging.Files.Add(item);
                                }
                            }
                            
                            TaggingWizardMain.Execute(FindForm(), taskTagging);
                            ReloadProperties();
                        }
                        return;

                    case ToolAction.ToolActionCdRipper:
                        {
                            OPMedia.Addons.Builtin.Navigation.FileExplorer.CdRipperWizard.Tasks.Task task =
                                new Navigation.FileExplorer.CdRipperWizard.Tasks.Task();

                            task.OutputFolder = opmShellList.Path;

                            CdRipperWizardMain.Execute(task);
                            ReloadNavigation();
                        }
                        break;

                    case ToolAction.ToolActionCopy:
                        _fileTask = new FEFileTaskForm(FileTaskType.Copy, opmShellList.SelectedPaths, opmShellList.Path);
                        return;

                    case ToolAction.ToolActionCut:
                        _fileTask = new FEFileTaskForm(FileTaskType.Move, opmShellList.SelectedPaths, opmShellList.Path);
                        return;

                    case ToolAction.ToolActionPaste:
                        if (_fileTask != null)
                        {
                            _fileTask.DestFolder = opmShellList.Path;
                        }
                        break;

                    case ToolAction.ToolActionDelete:
                        if (!opmShellList.IsInEditMode)
                        {
                            _fileTask = new FEFileTaskForm(FileTaskType.Delete, opmShellList.SelectedPaths, opmShellList.Path);
                        }
                        break;

                    case ToolAction.ToolActionRename:
                        Rename();
                        return;

                    case ToolAction.ToolActionFavoritesAdd:
                        {
                            List<string> favorites = new List<string>(ProTONEConfig.GetFavoriteFolders("FavoriteFolders"));
                            if (favorites.Contains(opmShellList.Path))
                                return;

                            favorites.Add(opmShellList.Path);
                            ProTONEConfig.SetFavoriteFolders(favorites, "FavoriteFolders");
                        }
                        return;

                    case ToolAction.ToolActionFavoritesManage:
                        new FavoriteFoldersManager("FavoriteFolders").ShowDialog();
                        return;

                    case ToolAction.ToolActionProTONEEnqueue:
                        {
                            List<String> items = opmShellList.SelectedPaths;
                            if (items.Count > 0)
                            {
                                RemoteControlHelper.SendPlayerCommand(
                                    OPMedia.Runtime.ProTONE.RemoteControl.CommandType.EnqueueFiles,
                                    items.ToArray());
                            }
                        }
                        break;

                    case ToolAction.ToolActionProTONEPlay:
                        {
                            List<String> items = opmShellList.SelectedPaths;
                            if (items.Count > 0)
                            {
                                RemoteControlHelper.SendPlayerCommand(
                                    OPMedia.Runtime.ProTONE.RemoteControl.CommandType.PlayFiles,
                                    items.ToArray());
                            }
                        }
                        break;

                }

                if (_fileTask != null)
                {
                    RaiseNavigationAction(NavActionType.ActionCancelAutoPreview, null, null);

                    try
                    {
                        opmShellList.EnableAutoRefresh(false);
                        DialogResult dlg = _fileTask.ShowDialog();
                    }
                    finally
                    {
                        if (_fileTask.RequiresRefresh)
                        {
                            opmShellList.RefreshList(true);
                        }

                        opmShellList.EnableAutoRefresh(true);
                        _fileTask = null;
                    }
                }
            }
            finally
            {
                updateUiTimer.Start();
            }
        }
Пример #32
0
 internal void Run(ToolAction toolAction, string arg)
 {
     switch (toolAction)
     {
         case ToolAction.Install:
             RunInstall(arg);
             break;
         case ToolAction.Uninstall:
             RunUninstall(arg);
             break;
         case ToolAction.List:
             RunList(arg);
             break;
         case ToolAction.Help:
             CommonUtil.PrintHelp();
             break;
         default:
             throw new Exception(string.Format("Not implemented {0}", toolAction));
     }
 }
Пример #33
0
 public void Run(Version version, string rootSuffix, ToolAction toolAction, string arg1)
 {
     var obj = CreateExtensionManager(version, rootSuffix);
     var commandRunner = new CommandRunner(version, rootSuffix, (IVsExtensionManager)obj);
     commandRunner.Run(toolAction, arg1);
 }
Пример #34
0
        private void HandleAction(ToolAction action)
        {
            if (!IsToolActionEnabled(action))
                return;

            switch (action)
            {
                case ToolAction.ToolActionNew:
                    _sub = Subtitle.Empty;
                    lvSubtitles.Subtitle = _sub;
                    break;

                case ToolAction.ToolActionOpen:
                    {
                        OPMOpenFileDialog dlg = CommonDialogHelper.NewOPMOpenFileDialog();
                        dlg.Title = Translator.Translate("TXT_OPEN_SUBTITLE");
                        dlg.Filter = "Subtitle files (*.srt, *.sub)|*.srt;*.sub||";//Translator.Translate("TXT_CATALOG_FILTER");
                        dlg.InitialDirectory = AppSettings.SUB_LastOpenedFolder;

                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            _sub = new Subtitle(dlg.FileName);

                            AppSettings.SUB_LastOpenedFolder = Path.GetDirectoryName(dlg.FileName);

                            lvSubtitles.Subtitle = _sub;

                            List<string> items = new List<string>();
                            items.Add(dlg.FileName);

                            base.RaiseNavigationAction(NavActionType.ActionDoubleClickFile, items, _sub);

                            if (_sub.Elements != null && _sub.Elements.Count > 0)
                            {
                                lvSubtitles.Select();
                                lvSubtitles.Focus();
                                lvSubtitles.Items[0].Selected = true;
                                //base.RaiseNavigationAction(NavActionType.ActionReloadPreview, items, _sub.Elements[0]);
                            }
                        }
                    }
                    break;
                
                case ToolAction.ToolActionSave:
                    if (_sub.IsEmpty)
                    {
                        goto saveas;
                    }
                    else
                    {
                        _sub.Save();
                    }
                    break;

                case ToolAction.ToolActionSaveAs:
                saveas:
                    {
                        OPMSaveFileDialog dlg = CommonDialogHelper.NewOPMSaveFileDialog();
                        dlg.Title = Translator.Translate("TXT_SAVE_SUBTITLE");
                        dlg.Filter = "Subtitle files (*.srt, *.sub)|*.srt;*.sub||";//Translator.Translate("TXT_CATALOG_FILTER");
                        dlg.AddExtension = true;
                        dlg.DefaultExt = "srt";
                        dlg.InitialDirectory = AppSettings.SUB_LastOpenedFolder;

                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            _sub.SaveToFile(dlg.FileName);

                            AppSettings.SUB_LastOpenedFolder = Path.GetDirectoryName(dlg.FileName);
                        }
                    }
                    break;
                
                case ToolAction.ToolActionDelete:
                    break;
                
                case ToolAction.ToolActionBack:
                    break;
                
                case ToolAction.ToolActionFwd:
                    break;
                
                case ToolAction.ToolActionSearch:
                    break;
                
                case ToolAction.ToolActionRename:
                    break;
            }
        }
Пример #35
0
        private bool IsToolActionEnabled(ToolAction action)
        {
            if (_operationInProgress)
                return false;

            for (int i = 0; i < contextMenuStrip.Items.Count; i++)
            {
                ToolStripItem btn = contextMenuStrip.Items[i] as ToolStripItem;

                if (btn == null ||
                    string.IsNullOrEmpty(btn.Tag as string))
                {
                    // Not an action button, continue.
                    continue;
                }

                if ((btn.Tag as string).ToLowerInvariant() == action.ToString().ToLowerInvariant())
                {
                    return btn.Enabled;
                }
            }

            for (int i = 0; i < toolStripMain.Items.Count; i++)
            {
                ToolStripItem btn = toolStripMain.Items[i] as ToolStripItem;

                if (btn == null ||
                    string.IsNullOrEmpty(btn.Tag as string))
                {
                    // Not an action button, continue.
                    continue;
                }

                if ((btn.Tag as string).ToLowerInvariant() == action.ToString().ToLowerInvariant())
                {
                    return btn.Enabled;
                }
            }

            return true;
        }
Пример #36
0
        private void HandleAction(ToolAction action)
        {
            if (!IsToolActionEnabled(action))
                return;

            switch (action)
            {
                case ToolAction.ToolActionNew:
                    CreateNewThemeFile();
                    break;
                case ToolAction.ToolActionOpen:
                    OpenTheme();
                    break;

                case ToolAction.ToolActionSave:
                    if (_themeFile != null)
                    {
                        if (_themeFile.IsSaved)
                            SaveThemeFileNoDialog();
                        else
                            // New theme, never saved before.
                            SaveThemeFileWithDialog();
                    }
                    break;

                case ToolAction.ToolActionSaveAs:
                    SaveThemeFileWithDialog();
                    break;

                case ToolAction.ToolActionNewTheme:
                    CreateNewTheme();
                    break;

                case ToolAction.ToolActionDeleteTheme:
                    DeleteSelectedTheme();
                    break;
            }
        }
Пример #37
0
 internal CommandLine(ToolAction toolAction, string rootSuffix, string arg)
 {
     ToolAction = toolAction;
     RootSuffix = rootSuffix;
     Arg = arg;
 }
Пример #38
0
        private void HandleAction(ToolAction action)
        {
            if (!IsToolActionEnabled(action))
                return;

            switch (action)
            {
                case ToolAction.ToolActionReload:
                    GlobalReload();
                    break;

                case ToolAction.ToolActionNew:
                    CreateNewCatalog();
                    break;
                case ToolAction.ToolActionOpen:
                    OpenCatalog();
                    break;

                case ToolAction.ToolActionSave:
                    if (_cat != null && _cat.IsInDefaultLocation)
                    {
                        goto case ToolAction.ToolActionSaveAs;
                    }
                    else
                    {
                        SaveCatalogNoDialog();
                    }
                    break;

                case ToolAction.ToolActionSaveAs:
                    SaveCatalogWithDialog();
                    break;

                case ToolAction.ToolActionDelete:
                    List<string> sel = GetSelectedVPaths();
                    foreach (string vpath in sel)
                    {
                        CatalogItem item = _cat.GetByVPath(vpath);
                        if (item != null)
                        {
                            if (item.IsFolder)
                            {
                                // Only folders in tree view
                                tvCatalog.RemoveItem(item);
                            }

                            lvCatalogFolder.RemoveItem(item);

                            item.Delete();
                        }
                    }
                    break;

                case ToolAction.ToolActionMerge:
                    MergeCatalog();
                    break;

                case ToolAction.ToolActionCatalog:
                    {
                        Task task = null;

                        if (_cat != null)
                        {
                            task = new Task();
                            task.CatalogPath = _cat.Path;
                        }

                        if (ImportWizardMain.Execute(ref task) == DialogResult.OK)
                        {
                            _cat = new Catalog((task as Task).CatalogPath);
                            DisplayCatalog();
                        }
                    }
                    break;

                case ToolAction.ToolActionBack:
                    ExploreBack();
                    break;

                case ToolAction.ToolActionFwd:
                    ExploreForward();
                    break;

                case ToolAction.ToolActionUp:
                    NavigateUp();
                    break;

                case ToolAction.ToolActionSearch:
                    SearchWizard.Tasks.Task taskSearch = new SearchWizard.Tasks.Task();
                    taskSearch.Catalog = _cat;
                    taskSearch.SearchPath = (_curFolder != null) ? _curFolder.VPath : null;
                    if (SearchWizardMain.Execute(taskSearch) == DialogResult.OK)
                    {
                        switch (taskSearch.Action)
                        {
                            case ToolAction.ToolActionProTONEEnqueue:
                                RunProTONEActionOnVPaths(taskSearch.MatchingItems,
                                    OPMedia.Runtime.ProTONE.RemoteControl.CommandType.EnqueueFiles);
                                break;

                            case ToolAction.ToolActionProTONEPlay:
                                RunProTONEActionOnVPaths(taskSearch.MatchingItems,
                                    OPMedia.Runtime.ProTONE.RemoteControl.CommandType.PlayFiles);
                                break;

                            case ToolAction.ToolActionJumpToItem:
                                if (taskSearch.MatchingItems.Count > 0)
                                {
                                    JumpToItem(taskSearch.MatchingItems[0]);
                                }
                                break;

                            case ToolAction.ToolActionDelete:
                                foreach (string vpath in taskSearch.MatchingItems)
                                {
                                    CatalogItem item = _cat.GetByVPath(vpath);
                                    if (item != null)
                                    {
                                        if (item.IsFolder)
                                        {
                                            // Only folders in tree view
                                            tvCatalog.RemoveItem(item);
                                        }

                                        lvCatalogFolder.RemoveItem(item);

                                        item.Delete();
                                    }
                                }
                                break;
                        }
                    }
                    break;

                case ToolAction.ToolActionProTONEEnqueue:
                    RunProTONEActionOnVPaths(GetSelectedVPaths(),
                        OPMedia.Runtime.ProTONE.RemoteControl.CommandType.EnqueueFiles);
                    break;

                case ToolAction.ToolActionProTONEPlay:
                    RunProTONEActionOnVPaths(GetSelectedVPaths(),
                        OPMedia.Runtime.ProTONE.RemoteControl.CommandType.PlayFiles);
                    break;

                case ToolAction.ToolActionRename:
                    lvCatalogFolder.Rename();
                   break;
            }
        }