public override void StartSelectionMode(SelectionMode mode)
        {
            mSavedColor = BrushColor;

            if (mSelectTool != null && mSelectTool.SelectedStrokes.Count > 0)
            {
                mRenderer.InvokeRedrawAllStrokes();
            }

            ManipulationMode manipulation = (mode & SelectionMode.Whole) != 0 ? ManipulationMode.WholeStroke : ManipulationMode.PartialStroke;

            if ((mode & SelectionMode.Manipulate) != 0)
            {
                var manipulationTool = new VectorManipulationTool(this, manipulation);
                manipulationTool.OnTranslate       += OnToolTranslate;
                manipulationTool.TranslateFinished += OnToolTranslateFinished;
                manipulationTool.DrawingFinished   += OnManipulationSelectFinished;
                mSelectTool = manipulationTool;
            }
            else if ((mode & SelectionMode.Erase) != 0)
            {
                var eraseTool = new VectorEraserTool(manipulation);
                eraseTool.DrawingFinished += OnEraseSelectFinished;
                mSelectTool = eraseTool;
            }

            mSelectTool.PointsAdded += OnPointsAdded;
            mActiveTool              = mSelectTool;

            BrushColor = MediaColor.FromArgb(96, 0, 0, 0);
        }
예제 #2
0
 void SetupEditorVariables()
 {
     m_manipulateMode   = (ManipulationMode)PlayerPrefs.GetInt("Editor_ManipulateMode", 0);
     m_drawPathInEditor = PlayerPrefs.GetInt("Editor_DrawPath", 1) == 1;
     m_autoSmooth       = PlayerPrefs.GetInt("Editor_AutoSmooth", 0) == 1;
     m_visualSetting    = new VisualSetting();
 }
예제 #3
0
        private void SetMode(ManipulationMode mode)
        {
            this.mode = mode;

            switch (mode)
            {
            case ManipulationMode.Move:
                transform.Find(LeftIndicator).gameObject.GetComponentInChildren <SpriteRenderer>().sprite  = MoveLeft;
                transform.Find(TopIndicator).gameObject.GetComponentInChildren <SpriteRenderer>().sprite   = MoveUp;
                transform.Find(RightIndicator).gameObject.GetComponentInChildren <SpriteRenderer>().sprite =
                    MoveRight;
                transform.Find(BottomIndicator).gameObject.GetComponentInChildren <SpriteRenderer>().sprite =
                    MoveDown;
                break;

            case ManipulationMode.Scale:
                transform.Find(LeftIndicator).gameObject.GetComponentInChildren <SpriteRenderer>().sprite =
                    ScaleMinus;
                transform.Find(RightIndicator).gameObject.GetComponentInChildren <SpriteRenderer>().sprite =
                    ScalePlus;
                break;

            case ManipulationMode.Rotate:
                transform.Find(LeftIndicator).gameObject.GetComponentInChildren <SpriteRenderer>().sprite =
                    RotateClockwise;
                transform.Find(RightIndicator).gameObject.GetComponentInChildren <SpriteRenderer>().sprite =
                    RotateCounterClock;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(mode), mode, null);
            }
        }
예제 #4
0
    private void TryChangeMode(ManipulationMode mode)
    {
        var manipulator = GetSpatialManipulator();

        if (manipulator == null)
        {
            return;
        }

        if (manipulator.Mode != mode)
        {
            manipulator.Mode = mode;
            TryPlaySound();
        }

        if (mode == ManipulationMode.Scale_1_1)
        {
            changeScale(100.0f);
            BaseSpatialMappingCollisionDetector CollisonDetector;
            CollisonDetector = gameObject.GetComponent <DefaultMappingCollisionDetector>();
            Vector3 maxDetial = CollisonDetector.GetMaxDelta(Vector3.zero);
            if (CollisonDetector.CheckIfCanMoveBy(maxDetial))
            {
                transform.localPosition += maxDetial;
            }
        }


        if (mode == ManipulationMode.Scale_1_100)
        {
            changeScale(1.0f);
        }
    }
예제 #5
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            border = GetTemplateChild("Border") as Border;

            (GetTemplateChild("PART_LEFT_BTN") as Border).PointerPressed += (sender, e) => {
                mode = UIControls.ManipulationMode.ScaleLeft;
            };

            (GetTemplateChild("PART_RIGHT_BTN") as Border).PointerPressed += (sender, e) => {
                mode = UIControls.ManipulationMode.ScaleRight;
            };

            context          = DataContext as ISequenceElement;
            context.OnScale += (scale) =>
            {
                frameScale = scale;
                SetBeginFrame(frame);
                SetFrameSize(frameSize);
            };

            frameScale = context.FrameScale;
            frame      = context.StartFrame;
            frameSize  = context.FramesDuration;

            SetBeginFrame(frame);
            SetFrameSize(frameSize);
        }
예제 #6
0
        /// <summary>
        /// private Event Handlers
        /// </summary>
        private void UpdateStateMachine()
        {
            var handsPressedCount     = handsPressedLocationsMap.Count;
            ManipulationMode newState = currentState;

            switch (currentState)
            {
            case ManipulationMode.None:
            case ManipulationMode.Move:
                Color  color = new Color(255, 255, 255, 1.0f);
                string text  = "finger:";
                if (handsPressedCount == 0)
                {
                    //color = new Color(0, 255, 0, 1.0f);
                    //GetComponent<Renderer>().material.color = white;
                    //cameraText.material.color = color;
                    text     = text + "0";
                    newState = ManipulationMode.None;
                }
                else if (handsPressedCount == 1 && enableOneHandMovement)
                {
                    color = new Color(0, 0, 255, 1.0f);
                    //GetComponent<Renderer>().material.color = blue;
                    newState = ManipulationMode.Move;
                    text     = text + "1";
                }
                else if (handsPressedCount > 1)
                {
                    //Debug.Log("2!!");
                    color = new Color(255, 0, 0, 1.0f);
                    //GetComponent<Renderer>().material.color = red;
                    newState = manipulationMode;
                    text     = text + "2";
                }
                Debug.Log(color);
                cameraText.material.color = color;
                cameraText.text           = text;
                break;

            case ManipulationMode.Scale:
            case ManipulationMode.Rotate:
            case ManipulationMode.MoveAndScale:
            case ManipulationMode.MoveAndRotate:
            case ManipulationMode.RotateAndScale:
            case ManipulationMode.MoveScaleAndRotate:
                // TODO: if < 2, make this go to start state ('drop it')
                if (handsPressedCount == 0)
                {
                    newState = ManipulationMode.None;
                }
                else if (handsPressedCount == 1)
                {
                    newState = ManipulationMode.Move;
                }
                break;
            }

            InvokeStateUpdateFunctions(currentState, newState);
            currentState = newState;
        }
 private void ChangeManipulationType(ManipulationMode manipulationMode)
 {
     if (gameObject == ObjectStateManager.Instance.SelectedObject)
     {
         SpatialManipulator spatialManipulator = GetManipulator();
         if (spatialManipulator == null)
         {
             return;
         }
         if (spatialManipulator.Mode != manipulationMode)
         {
             if (manipulationMode == ManipulationMode.NONE)
             {
                 spatialManipulator.ResetPosition();
                 return;
             }
             spatialManipulator.Mode = manipulationMode;
             Debug.Log("NEW manipulation mode: " + spatialManipulator.Mode);
         }
     }
     else
     {
         Debug.Log("This object is currently not selected!");
     }
 }
예제 #8
0
 public static void SetManipulationMode(DependencyObject element, ManipulationMode manipulationMode)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(ManipulationModeProperty, manipulationMode);
 }
예제 #9
0
 public void TypeGotActivated(ManipulationMode mode)
 {
     activeInteractionType = mode;
     adjustManipulationMode();
     if (isShowingFeedback)
     {
         cursorfeedback.ActivateManipulationModeFeedback(mode);
     }
 }
예제 #10
0
        public bool OnTouch(View v, MotionEvent e)
        {
            this.Parent.RequestDisallowInterceptTouchEvent(_saveScale != 1);

            _scaleDetector.OnTouchEvent(e);
            _doubleTapDetector.OnTouchEvent(e);

            var currentPoint = new System.Drawing.PointF(e.GetX(), e.GetY());

            switch (e.Action)
            {
            case MotionEventActions.Down:
                _previousPoint     = currentPoint;
                _manipulationStart = currentPoint;
                _manipulationMode  = ManipulationMode.Drag;
                break;

            case MotionEventActions.Move:
                if (_manipulationMode == ManipulationMode.Drag)
                {
                    var deltaX = currentPoint.X - _previousPoint.X;
                    var deltaY = currentPoint.Y - _previousPoint.Y;

                    var fixTransX = GetFixDragTrans(deltaX, _viewWidth, _originalWidth * _saveScale);
                    var fixTransY = GetFixDragTrans(deltaY, _viewHeight, _originalHeight * _saveScale);

                    _matrix.PostTranslate(fixTransX, fixTransY);
                    FixTrans();

                    _previousPoint.X = currentPoint.X;
                    _previousPoint.Y = currentPoint.Y;
                }
                break;

            case MotionEventActions.Up:
                _manipulationMode = ManipulationMode.None;

                var diffX = (int)Math.Abs(currentPoint.X - _manipulationStart.X);
                var diffY = (int)Math.Abs(currentPoint.Y - _manipulationStart.Y);

                if (diffX < BindableImageView.DeltaClick && diffY < BindableImageView.DeltaClick)
                {
                    PerformClick();
                }

                break;

            case MotionEventActions.PointerUp:
                _manipulationMode = ManipulationMode.None;
                break;
            }

            ImageMatrix = _matrix;
            Invalidate();

            return(true);
        }
예제 #11
0
 void Start()
 {
     Mode                    = ManipulationMode.Inactive;
     lineRenderer            = GetComponent <LineRenderer>();
     proxyNode               = GetComponent <ProxyNode>();
     leap                    = GetComponent <InteractionBehaviour>();
     graspedPoseHandler      = new ProxyGraspedPoseHandler(leap);
     leap.graspedPoseHandler = graspedPoseHandler;
 }
        /// <summary>
        /// private Event Handlers
        /// </summary>
        private void UpdateStateMachine()
        {
            //  GameObject menu = GameObject.Find("Menu");
            var handsPressedCount = handsPressedLocationsMap.Count;

            /*   if  (handsPressedCount > 1)
             *     {
             *        menu.SetActive(false);
             * }
             * else
             * {
             *     menu.SetActive(true);
             * }
             */
            ManipulationMode newState = currentState;

            switch (currentState)
            {
            case ManipulationMode.None:
            case ManipulationMode.Move:
                if (handsPressedCount == 0)
                {
                    newState = ManipulationMode.None;
                }
                else if (handsPressedCount == 1 && enableOneHandMovement)
                {
                    newState = ManipulationMode.Move;
                }
                else if (handsPressedCount > 1)
                {
                    newState = manipulationMode;
                }
                break;

            case ManipulationMode.Scale:
            case ManipulationMode.Rotate:
            case ManipulationMode.MoveAndScale:
            case ManipulationMode.MoveAndRotate:
            case ManipulationMode.RotateAndScale:
            case ManipulationMode.MoveScaleAndRotate:
                // TODO: if < 2, make this go to start state ('drop it')
                if (handsPressedCount == 0)
                {
                    newState = ManipulationMode.None;
                }
                else if (handsPressedCount == 1)
                {
                    newState = ManipulationMode.Move;
                }
                break;
            }

            InvokeStateUpdateFunctions(currentState, newState);
            currentState = newState;
        }
예제 #13
0
 private void OnManipulationModeChange(ManipulationMode from, ManipulationMode to)
 {
     // Disable all the hands when the ManipulationMode goes out of the (hands) Inside
     if (from == ManipulationMode.Inside && to != ManipulationMode.Inside)
     {
         foreach (var mark in proxyNode.Marks)
         {
             mark.LeftHand.Disable();
             mark.RightHand.Disable();
         }
     }
 }
예제 #14
0
    private void ChangeMode(ManipulationMode newMode)
    {
        if (newMode == Mode)
        {
            return;
        }
        var oldMode = Mode;

        Mode = newMode;
        OnModeChange?.Invoke(oldMode, newMode);
        //Debug.Log(newMode);
    }
예제 #15
0
    public void ActivateManipulationModeFeedback(ManipulationMode mode)
    {
        switch (mode)
        {
        case ManipulationMode.Scale: ChangeFeedback(scaleFeedback); break;

        case ManipulationMode.Rotate: ChangeFeedback(rotateFeedback); break;

        case ManipulationMode.Move: ChangeFeedback(moveFeedback); break;

        default: ChangeFeedback(null); break;
        }
    }
예제 #16
0
    private void TryChangeMode(ManipulationMode mode)
    {
        var manipulator = GetSpatialManipulator();

        if (manipulator == null)
        {
            return;
        }

        if (manipulator.Mode != mode)
        {
            manipulator.Mode = mode;
            TryPlaySound();
        }
    }
예제 #17
0
        /// <summary>
        /// private Event Handlers
        /// </summary>
        private void UpdateStateMachine()
        {
            var handsPressedCount     = handsPressedLocationsMap.Count;
            ManipulationMode newState = currentState;

            switch (currentState)
            {
            case ManipulationMode.None:
            case ManipulationMode.Move:
                if (handsPressedCount == 0)
                {
                    newState = ManipulationMode.None;
                }
                else if (handsPressedCount == 1 && enableOneHandMovement)
                {
                    newState = ManipulationMode.Move;
                }
                else if (handsPressedCount > 1)
                {
                    newState = manipulationMode;
                }

                break;

            case ManipulationMode.Scale:
            case ManipulationMode.Rotate:
            case ManipulationMode.MoveAndScale:
            case ManipulationMode.MoveAndRotate:
            case ManipulationMode.RotateAndScale:
            case ManipulationMode.MoveScaleAndRotate:
                // TODO: if < 2, make this go to start state ('drop it')
                if (handsPressedCount == 0)
                {
                    newState = ManipulationMode.None;
                }
                else if (handsPressedCount == 1)
                {
                    newState = ManipulationMode.Move;
                }

                break;
            }

            InvokeStateUpdateFunctions(currentState, newState);
            currentState = newState;
        }
예제 #18
0
        /// <summary>
        /// Updates the state machine based on the current state and anything that might have changed with the hands.
        /// </summary>
        private void UpdateStateMachine()
        {
            var handsPressedCount     = handsPressedLocationsMap.Count;
            ManipulationMode newState = currentState;

            //Debug.Log("\n\n---> Hands presssed count: " + handsPressedCount.ToString());

            switch (currentState)
            {
            case ManipulationMode.None:
            case ManipulationMode.Move:
                if (handsPressedCount == 0)
                {
                    newState = ManipulationMode.None;
                }
                else if (handsPressedCount == 1)
                {
                    newState = enableOneHandMovement ? ManipulationMode.Move : ManipulationMode.None;
                }
                else if (handsPressedCount > 1)
                {
                    newState = manipulationMode;
                }
                break;

            case ManipulationMode.Scale:
            case ManipulationMode.Rotate:
            case ManipulationMode.MoveAndScale:
            case ManipulationMode.MoveAndRotate:
            case ManipulationMode.RotateAndScale:
            case ManipulationMode.MoveScaleAndRotate:
                if (handsPressedCount == 0)
                {
                    newState = ManipulationMode.None;
                }
                else if (handsPressedCount == 1)
                {
                    newState = enableOneHandMovement ? ManipulationMode.Move : ManipulationMode.None;
                }
                break;
            }

            InvokeStateUpdateFunctions(currentState, newState);
            currentState = newState;
        }
예제 #19
0
        private void OnTwoHandManipulationStarted(ManipulationMode newState)
        {
#if UNITY_2017_2_OR_NEWER
            if ((newState & ManipulationMode.Rotate) > 0)
            {
                rotateLogic.Setup(handsPressedLocationsMap, hostTransform);
            }

            if ((newState & ManipulationMode.Move) > 0)
            {
                moveLogic.Setup(GetHandsCentroid(), hostTransform);
            }

            if ((newState & ManipulationMode.Scale) > 0)
            {
                scaleLogic.Setup(handsPressedLocationsMap, hostTransform);
            }
#endif // UNITY_2017_2_OR_NEWER
        }
예제 #20
0
    void Update()
    {
        Debug.Log("Current Mode: " + manipulator.Mode);
        if (manipulator.Mode != lastMode)
        {
            switch (manipulator.Mode)
            {
            case ManipulationMode.MOVEMENT:
                manipulateButtonImage.sprite = moveImage;
                break;

            case ManipulationMode.ROTATION:
                manipulateButtonImage.sprite = rotateImage;
                break;

            case ManipulationMode.SCALING:
                manipulateButtonImage.sprite = scaleImage;
                break;
            }
        }

        lastMode = manipulator.Mode;
    }
예제 #21
0
        /// <summary>
        /// adds a self manipulate to the object
        /// all devices should go through here bevore manipulation
        /// </summary>
        /// <param name="go"></param>
        public void prepareGameobjectForManipulation(GameObject go, ManipulationMode manipulationMode, bool invisibleIfNotInManipulationMode = false)
        {
            SelfManipulate manip = go.GetComponent <SelfManipulate>();

            if (manip == null)
            {
                manip = go.AddComponent <SelfManipulate>();
            }



            manip.myBoundingBox       = boundingBoxBasicPrefab;
            manip.manipulationMode    = manipulationMode;
            manip.constraintZMovement = constraintZMovement;
            manip.invisibleIfNotInManipulationMode = invisibleIfNotInManipulationMode;

            //if there changes anything in the hierarchy, reeact to new elements
            if (IsToggleEditOn)
            {
                manip.active       = true;
                manip.setInvisible = false;
            }
        }
예제 #22
0
 public static void SetManipulationMode(DependencyObject element, ManipulationMode manipulationMode)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(ScrollViewer.ManipulationModeProperty, manipulationMode);
 }
 protected VectorSelectionTool(ManipulationMode mode)
 {
     ManipulationMode = mode;
 }
예제 #24
0
        private void InvokeStateUpdateFunctions(ManipulationMode oldState, ManipulationMode newState)
        {
            if (newState != oldState)
            {
                switch (newState)
                {
                case ManipulationMode.None:
                    OnManipulationEnded();
                    break;

                case ManipulationMode.Move:
                    OnOneHandMoveStarted();
                    break;

                case ManipulationMode.Scale:
                case ManipulationMode.Rotate:
                case ManipulationMode.MoveAndScale:
                case ManipulationMode.MoveAndRotate:
                case ManipulationMode.RotateAndScale:
                case ManipulationMode.MoveScaleAndRotate:
                    OnTwoHandManipulationStarted(newState);
                    break;
                }

                switch (oldState)
                {
                case ManipulationMode.None:
                    OnManipulationStarted();
                    break;

                case ManipulationMode.Move:
                    break;

                case ManipulationMode.Scale:
                case ManipulationMode.Rotate:
                case ManipulationMode.MoveAndScale:
                case ManipulationMode.MoveAndRotate:
                case ManipulationMode.RotateAndScale:
                case ManipulationMode.MoveScaleAndRotate:
                    OnTwoHandManipulationEnded();
                    break;
                }
            }
            else
            {
                switch (newState)
                {
                case ManipulationMode.None:
                    break;

                case ManipulationMode.Move:
                    OnOneHandMoveUpdated();
                    break;

                case ManipulationMode.Scale:
                case ManipulationMode.Rotate:
                case ManipulationMode.MoveAndScale:
                case ManipulationMode.MoveAndRotate:
                case ManipulationMode.RotateAndScale:
                case ManipulationMode.MoveScaleAndRotate:
                    OnTwoHandManipulationUpdated();
                    break;
                }
            }
        }
예제 #25
0
 protected override void OnManipulationCompleted(ManipulationCompletedRoutedEventArgs e)
 {
     base.OnManipulationCompleted(e);
     mode = UIControls.ManipulationMode.Move;
 }
예제 #26
0
 public void SetManipulationMode(ManipulationMode mode)
 {
     manipulationMode = mode;
 }
예제 #27
0
 public void OnScaleBegin()
 {
     _manipulationMode = ManipulationMode.Zoom;
 }
 public VectorManipulationTool(VectorStrokeHandler strokeHandler, ManipulationMode mode)
     : base(mode)
 {
     mStrokeHandler = strokeHandler;
 }
예제 #29
0
        private void DrawButtons()
        {
            EditorGUI.BeginChangeCheck();
            m_manipulateMode = (ManipulationMode)EditorGUILayout.EnumPopup(
                "Mode to manipulate node", m_manipulateMode);
            if (EditorGUI.EndChangeCheck())
            {
                PlayerPrefs.SetInt("Editor_ManipulateMode", (int)m_manipulateMode);
                SceneView.RepaintAll();
            }

            EditorGUI.BeginChangeCheck();
            m_drawPathInEditor = GUILayout.Toggle(m_drawPathInEditor, "Draw path in Editor", GUILayout.Width(Screen.width));
            if (EditorGUI.EndChangeCheck())
            {
                PlayerPrefs.SetInt("Editor_DrawPath", m_drawPathInEditor ? 1 : 0);
            }

            EditorGUI.BeginChangeCheck();
            m_autoSmooth = GUILayout.Toggle(m_autoSmooth, "Smooth another handle in the BezierPoint", GUILayout.Width(Screen.width));
            if (EditorGUI.EndChangeCheck())
            {
                PlayerPrefs.SetInt("Editor_AutoSmooth", m_autoSmooth ? 1 : 0);
            }

            isAutoConnectProperty.boolValue = GUILayout.Toggle(isAutoConnectProperty.boolValue, "Connect first and last nodes?", GUILayout.Width(Screen.width));

            drawDebugPathProperty.boolValue = GUILayout.Toggle(drawDebugPathProperty.boolValue,
                                                               "Use LineRenderer to draw path in game?", GUILayout.Width(Screen.width));

            if (GUILayout.Button(addPointContent))
            {
                Undo.RecordObject(Target, "Added a waypoint");

                BezierPoint point = new BezierPoint(
                    Vector3.zero,
                    Quaternion.identity,
                    true);;
                Target.AddPoint(point);

                if (Target.Points.Count > 1)
                {
                    Vector3 dir = -SceneView.lastActiveSceneView.camera.transform.right;
                    if (Target.Points.Count > 2)
                    {
                        Vector3 prevDir = (Target.Points[Target.Points.Count - 2].Position - Target.Points[Target.Points.Count - 3].Position);
                        dir *= prevDir.magnitude;
                        if (Vector3.Dot(prevDir, dir) < 0)
                        {
                            dir *= -1;
                        }
                    }
                    Target.SetAnchorPosition(Target.Points.Count - 1,
                                             Target.Points[Target.Points.Count - 2].Position + dir);
                    Target.SetAnchorRotation(Target.Points.Count - 1,
                                             Quaternion.LookRotation(dir));
                }

                SceneView.RepaintAll();
            }

            if (GUILayout.Button(clearAllPointsContent))
            {
                //TODO: Use Target.RemoveAll() later
                Target.Points.Clear();

                SceneView.RepaintAll();
            }

            if (GUILayout.Button(savePathData))
            {
                string savePath = EditorUtility.SaveFilePanel(
                    "Save path into file",
                    Application.dataPath,
                    Target.name,
                    "json");

                if (savePath.Length != 0)
                {
                    JsonSerializationHelper.WriteJsonList <BezierPoint>(savePath, Target.Points);
                }
            }

            if (GUILayout.Button(loadPathData))
            {
                // Simple version
                //string loadPath = EditorUtility.OpenFilePanel(
                //    "Load path from file",
                //    Application.dataPath,
                //    "json,*");

                // More customized
                string loadPath = EditorUtility.OpenFilePanelWithFilters(
                    "Load path from file",
                    Application.dataPath,
                    new string[] { "Json files", "json", "All files", "*" });
                if (loadPath.Length != 0)
                {
                    Target.SetPoints(JsonSerializationHelper.ReadJsonList <BezierPoint>(loadPath));
                }
                Target.UpdateAnchorTransforms();

                SceneView.RepaintAll();
            }

            GUILayout.Space(10);
        }
 public VectorEraserTool(ManipulationMode mode)
     : base(mode)
 {
 }
        private void SaveManipulationSetting(ManipulationMode mode, bool newState)
        {
            DataControlFieldCollection columns = ((GridView) base.Component).Columns;
            bool flag = false;
            ArrayList list = new ArrayList();
            foreach (DataControlField field in columns)
            {
                CommandField field2 = field as CommandField;
                if (field2 != null)
                {
                    switch (mode)
                    {
                        case ManipulationMode.Edit:
                            field2.ShowEditButton = newState;
                            break;

                        case ManipulationMode.Delete:
                            field2.ShowDeleteButton = newState;
                            break;

                        case ManipulationMode.Select:
                            field2.ShowSelectButton = newState;
                            break;
                    }
                    if (((!newState && !field2.ShowEditButton) && (!field2.ShowDeleteButton && !field2.ShowInsertButton)) && !field2.ShowSelectButton)
                    {
                        list.Add(field2);
                    }
                    flag = true;
                }
            }
            foreach (object obj2 in list)
            {
                columns.Remove((DataControlField) obj2);
            }
            if (!flag && newState)
            {
                CommandField field3 = new CommandField();
                switch (mode)
                {
                    case ManipulationMode.Edit:
                        field3.ShowEditButton = newState;
                        break;

                    case ManipulationMode.Delete:
                        field3.ShowDeleteButton = newState;
                        break;

                    case ManipulationMode.Select:
                        field3.ShowSelectButton = newState;
                        break;
                }
                columns.Insert(0, field3);
            }
            if (!newState)
            {
                PropertyDescriptor descriptor;
                GridView component = (GridView) base.Component;
                switch (mode)
                {
                    case ManipulationMode.Edit:
                        descriptor = TypeDescriptor.GetProperties(typeof(GridView))["AutoGenerateEditButton"];
                        descriptor.SetValue(base.Component, newState);
                        return;

                    case ManipulationMode.Delete:
                        descriptor = TypeDescriptor.GetProperties(typeof(GridView))["AutoGenerateDeleteButton"];
                        descriptor.SetValue(base.Component, newState);
                        return;

                    case ManipulationMode.Select:
                        TypeDescriptor.GetProperties(typeof(GridView))["AutoGenerateSelectButton"].SetValue(base.Component, newState);
                        break;

                    default:
                        return;
                }
            }
        }