private IEnumerator Attach(GameObject target, Transform parent, InteractionSource source)
    {
        yield return(ControllerHelpers.AttachModel(target, parent, source, GLTFMaterial, GLTFMaterial));

        if (AnimateControllerModel)
        {
            var newControllerInfo = new MotionControllerInfo()
            {
            };
            newControllerInfo.LoadInfo(target.GetComponentsInChildren <Transform>(), this);
            controllerInfoForAnimation.Add(source.id, newControllerInfo);
            TraceHelper.Log("Controller added for animation");
        }

        if (ShowDebugAxis)
        {
            if (source.handedness == InteractionSourceHandedness.Left)
            {
                axisRendererLeft = target.AddComponent <AxisRenderer>();
            }
            else
            {
                axisRendererRight = target.AddComponent <AxisRenderer>();
            }
        }
    }
示例#2
0
        private IEnumerator Attach(GameObject target, Transform parent, InteractionSource source)
        {
            yield return(WinMRSnippets.ControllerHelpers.AttachModel(target, parent, source, GLTFMaterial, GLTFMaterial));

            inProgressSources.Remove(source.id);
            FinishControllerSetup(target, source.handedness.ToString(), source.id);

            if (ShowDebugAxis)
            {
                //Deactivate target so we can call Init and set parent property on component without Awake/Start running
                target.SetActive(false);
                AxisRenderer axisRenderer = null;
                if (source.handedness == InteractionSourceHandedness.Left)
                {
                    axisRenderer = axisRendererLeft = target.AddComponent <AxisRenderer>();
                }
                else
                {
                    axisRenderer = axisRendererRight = target.AddComponent <AxisRenderer>();
                }
                axisRenderer.Init(false, parent);
                target.SetActive(true);
            }

#if SKIPNPUTMODULE
            WinMRSnippets.Samples.Input.MotionControllerInputModule.Instance.AddController(source.id);
            WinMRSnippets.Samples.Input.MotionControllerInputModule.Instance.AddController(source.id);
#endif
        }
        private IEnumerator Attach(GameObject target, Transform parent, InteractionSource source)
        {
            yield return(ControllerHelpers.AttachModel(target, parent, source, GLTFMaterial, GLTFMaterial));

            inProgressSources.Remove(source.id);
            FinishControllerSetup(target, source.handedness.ToString(), source.id);

            if (ShowDebugAxis)
            {
                TraceHelper.LogOnUnityThread("Attaching Debug Axis to " + source.handedness);
                if (source.handedness == InteractionSourceHandedness.Left)
                {
                    axisRendererLeft = target.AddComponent <AxisRenderer>();
                }
                else
                {
                    axisRendererRight = target.AddComponent <AxisRenderer>();
                }
            }

#if SKIPNPUTMODULE
            WinMRSnippets.Samples.Input.MotionControllerInputModule.Instance.AddController(source.id);
            WinMRSnippets.Samples.Input.MotionControllerInputModule.Instance.AddController(source.id);
#endif
        }
示例#4
0
        private void UpdateDebugAxis(InteractionSourceState state)
        {
            Vector3 pointerForward = Vector3.zero, gripForward = Vector3.zero, gripPosition = Vector3.zero, pointerPosition = Vector3.zero;
            bool    hasPointerPosition = false, hasGripPosition = false, hasGripRotation = false,
                    hasPointerRotation = false, hasPointerForward = false, hasGripForward = false;
            Quaternion pointerRotation = Quaternion.identity, gripRotation = Quaternion.identity;
            Ray        pointerRay;

            //          TraceHelper.Log("Updating debug axis");

            if (
#if !UNITY_5
                (hasPointerPosition = state.sourcePose.TryGetPosition(out pointerPosition, InteractionSourceNode.Pointer)) &&
                (hasPointerForward = state.sourcePose.TryGetForward(out pointerForward, InteractionSourceNode.Pointer)) &&
                (hasPointerRotation = state.sourcePose.TryGetRotation(out pointerRotation, InteractionSourceNode.Pointer)) &&
                (hasGripForward = state.sourcePose.TryGetForward(out gripForward, InteractionSourceNode.Grip)) &&
                (hasGripPosition = state.sourcePose.TryGetPosition(out gripPosition, InteractionSourceNode.Grip)) &&
                (hasGripRotation = state.sourcePose.TryGetRotation(out gripRotation, InteractionSourceNode.Grip))
#else
                (hasPointerPosition = hasPointerForward = state.sourcePose.TryGetPointerRay(out pointerRay)) &&
                //(hasGripForward = state.sourcePose.TryGetForward(out gripForward )) &&
                (hasGripPosition = state.sourcePose.TryGetPosition(out gripPosition)) &&
                (hasGripRotation = state.sourcePose.TryGetRotation(out gripRotation))
#endif
                )
            {
#if UNITY_5
                if (hasPointerPosition && hasPointerForward)
                {
                    pointerPosition = pointerRay.origin;
                    pointerForward  = pointerRay.direction;
                }
#endif
                AxisRenderer axis = (state.IsLeftHand() ? axisRendererLeft : axisRendererRight);
                if (axis != null)
                {
                    if (hasPointerPosition && hasPointerRotation)
                    {
                        axis.SetWorldValues(pointerPosition, pointerForward, pointerRotation, AxisRenderer.ControllerElement.Pointer);
                    }
                    if (hasGripPosition && hasGripRotation)
                    {
                        axis.SetWorldValues(gripPosition, gripForward, gripRotation, AxisRenderer.ControllerElement.Grip);
                    }
                }
            }

            //TraceHelper.Assert(hasPointerForward && hasGripForward && hasGripPosition &&
            //                     hasPointerPosition && hasGripRotation && hasPointerRotation, "Show debug axis should not fail");


#if SKIPNPUTMODULE
            WinMRSnippets.Samples.Input.MotionControllerInputModule.Instance.SetPosition(state.source.id, pointerPosition);
            WinMRSnippets.Samples.Input.MotionControllerInputModule.Instance.SetForwardPointer(state.source.id, pointerForward);
            WinMRSnippets.Samples.Input.MotionControllerInputModule.Instance.SetButtonStates(state.source.id,
                                                                                             state.selectPressed, state.grasped, state.menuPressed);
#endif
        }
    void UpdateDebugAxis(bool show)
    {
        int devices     = imDevices.Count;
        int axisDevices = ((axisRendererRight == null) ? 0 : 1) + ((axisRendererLeft == null) ? 0 : 1);

        if (show && (devices == axisDevices))
        {
            return;
        }
        if (!show && axisDevices == 0)
        {
            return;
        }

        if (!show)
        {
            if (axisRendererLeft != null)
            {
                Destroy(axisRendererLeft);
                axisRendererLeft = null;
            }

            if (axisRendererRight != null)
            {
                Destroy(axisRendererRight);
                axisRendererRight = null;
            }
        }
        else
        {
            var         states = InteractionManager.GetCurrentReading();
            List <uint> ids    = new List <uint>();
            foreach (var state in states)
            {
                uint id = state.source.id;
                if (!ids.Contains(id))
                {
                    Transform transform;
                    if (imDevices.TryGetValue(id, out transform))
                    {
                        GameObject target = transform.gameObject;
                        if (state.source.handedness == InteractionSourceHandedness.Left)
                        {
                            axisRendererLeft = target.AddComponent <AxisRenderer>();
                        }
                        else
                        {
                            axisRendererRight = target.AddComponent <AxisRenderer>();
                        }

                        ids.Add(id);
                    }
                }
            }
        }
    }
示例#6
0
    private IEnumerator Attach(GameObject target, Transform parent, XRNode nodeType)
    {
        yield return(ControllerHelpers.AttachModel(target, parent, nodeType, GLTFMaterial, GLTFMaterial));

        if (ShowDebugAxis)
        {
            if (nodeType == XRNode.LeftHand)
            {
                axisRendererLeft = target.AddComponent <AxisRenderer>();
            }
            else
            {
                axisRendererRight = target.AddComponent <AxisRenderer>();
            }
        }
    }
示例#7
0
        void Awake()
        {
            sunMove    = new SunMove();
            pSim       = new PlanetSimulator(5, 10, SunFunction, sunAngle, angularVelocity);
            simDisplay = new SimulatorDisplay(pSim, DisplayMapType.PRESSURE_MAP);
            aRenderer  = new AxisRenderer();
            debug      = new DebugGUI(pSim);
            //cloudSystem = new CloudSystem(pSim);

            pSim.bufferFlip += simDisplay.OnBufferChange;


            if (mainCamera == null)
            {
                mainCamera = GameObject.Find("Main Camera");
                SetCamera();
            }
        }
示例#8
0
    private void UpdateUnityInput()
    {
        UpdateTrackedControllers();

        var left  = InputState.Current.GetController(XRNode.LeftHand);
        var right = InputState.Current.GetController(XRNode.RightHand);

        // Motion
        foreach (XRNode nodeType in uDevices.Keys)
        {
            MotionControllerState state;
            if (nodeType == XRNode.LeftHand)
            {
                state = left;
            }
            else if (nodeType == XRNode.RightHand)
            {
                state = right;
            }
            else
            {
                TraceHelper.Log("Ignoring nodetype" + nodeType);
                continue;
            }
            var position = InputTracking.GetLocalPosition(nodeType);
            var rotation = InputTracking.GetLocalRotation(nodeType);

            SetTransform(uDevices[nodeType], position, rotation);

            if (ShowDebugAxis)
            {
                AxisRenderer axis   = null;
                var          angles = rotation.eulerAngles;

                axis = (nodeType == XRNode.RightHand) ? axisRendererRight : axisRendererLeft;
                if (axis != null)
                {
                    axis.SetWorldValues(position, (rotation * Vector3.forward), rotation, AxisRenderer.ControllerElement.Grip);
                }

                if (axis != null)
                {
                    position.y += .05f;
                    axis.SetWorldValues(position, angles, rotation, AxisRenderer.ControllerElement.Pointer);
                }
            }

            state.GripPosition = position;
            state.GripRotation = rotation;
        }

        // Buttons
        if (Input.GetButtonDown(UnityInputAxis.MotionController_Select_Left))
        {
            left.SelectPressed = true;
        }
        if (Input.GetButtonDown(UnityInputAxis.MotionController_Select_Right))
        {
            right.SelectPressed = true;
        }
        if (Input.GetButtonDown(UnityInputAxis.MotionController_Menu_Left))
        {
            left.MenuPressed = true;
        }
        if (Input.GetButtonDown(UnityInputAxis.MotionController_Menu_Right))
        {
            right.MenuPressed = true;
        }
        if (Input.GetButtonDown(UnityInputAxis.MotionController_Grasp_Left))
        {
            left.GraspPressed = true;
        }
        if (Input.GetButtonDown(UnityInputAxis.MotionController_Grasp_Right))
        {
            right.GraspPressed = true;
        }
        if (Input.GetButtonDown(UnityInputAxis.MotionController_TouchpadTouched_Left))
        {
            left.TouchPadTouched = true;
        }
        if (Input.GetButtonDown(UnityInputAxis.MotionController_TouchpadTouched_Right))
        {
            right.TouchPadTouched = true;
        }
        if (Input.GetButtonDown(UnityInputAxis.MotionController_TouchpadPressed_Left))
        {
            left.TouchPadPressed = true;
        }
        if (Input.GetButtonDown(UnityInputAxis.MotionController_TouchpadPressed_Right))
        {
            right.TouchPadPressed = true;
        }
        if (Input.GetButtonDown(UnityInputAxis.MotionController_ThumbstickPressed_Left))
        {
            left.ThumbstickPressed = true;
        }
        if (Input.GetButtonDown(UnityInputAxis.MotionController_ThumbstickPressed_Right))
        {
            right.ThumbstickPressed = true;
        }

        // Axes

        left.SelectValue       = Input.GetAxis(UnityInputAxis.MotionController_SelectPressedValue_Left);
        right.SelectValue      = Input.GetAxis(UnityInputAxis.MotionController_SelectPressedValue_Right);
        left.TouchPadXValue    = Input.GetAxis(UnityInputAxis.MotionController_TouchpadX_Left);
        left.TouchPadYValue    = Input.GetAxis(UnityInputAxis.MotionController_TouchpadY_Left);
        right.TouchPadXValue   = Input.GetAxis(UnityInputAxis.MotionController_TouchpadX_Right);
        right.TouchPadYValue   = Input.GetAxis(UnityInputAxis.MotionController_TouchpadY_Right);
        left.ThumbstickXValue  = Input.GetAxis(UnityInputAxis.MotionController_ThumbstickX_Left);
        left.ThumbstickYValue  = Input.GetAxis(UnityInputAxis.MotionController_ThumbstickY_Left);
        right.ThumbstickXValue = Input.GetAxis(UnityInputAxis.MotionController_ThumbstickX_Right);
        right.ThumbstickYValue = Input.GetAxis(UnityInputAxis.MotionController_ThumbstickY_Right);

#if TRACING_VERBOSE
        right.TraceState(PoseSource.Any);
        left.TraceState(PoseSource.Any);
#endif
    }
    private void UpdateInteractionSourceState(InteractionSourceState sourceState)
    {
        uint            id    = sourceState.source.id;
        ControllerState state = InputState.Current.GetController(sourceState);

        if (imDevices.ContainsKey(id))
        {
            var        sourcePose      = sourceState.sourcePose;
            Vector3    position        = Vector3.zero;
            Quaternion rotation        = Quaternion.identity;
            Vector3    pointerPosition = Vector3.zero;
            Quaternion pointerRotation = Quaternion.identity;

#if UNITY_5
            bool hasRotation = sourcePose.TryGetRotation(out rotation);
            bool hasPosition = sourcePose.TryGetPosition(out position);
#else
            bool hasRotation = sourcePose.TryGetRotation(out rotation, InteractionSourceNode.Grip);
            bool hasPosition = sourcePose.TryGetPosition(out position, InteractionSourceNode.Grip);
#endif

#if UNITY_5
            bool hasPointerPosition = sourcePose.TryGetPointerPosition(out pointerPosition);
            bool hasPointerRotation = sourcePose.TryGetPointerRotation(out pointerRotation);
#else
            bool hasPointerPosition = sourcePose.TryGetPosition(out pointerPosition, InteractionSourceNode.Pointer);
            bool hasPointerRotation = sourcePose.TryGetRotation(out pointerRotation, InteractionSourceNode.Pointer);
#endif

            if (hasPosition || hasRotation || hasPointerPosition || hasPointerRotation)
            {
#if VALIDATE_INPUT
                if (pointerPosition.IsDebugValid() && position.IsDebugValid() &&
                    pointerRotation.IsDebugValid() && rotation.IsDebugValid()
                    )
#endif
                {
                    state.Position = position;
                    state.Rotation = rotation;

                    if ((hasPosition && hasRotation) && ((FilterInput & PoseSource.Grip) != PoseSource.None))
                    {
                        SetTransform(imDevices[id], position, rotation);
                    }

                    else if ((hasPointerPosition && hasPointerRotation) && ((FilterInput & PoseSource.Pointer) != PoseSource.None))
                    {
                        SetTransform(imDevices[id], pointerPosition, pointerRotation);
                    }


                    if (hasPointerPosition)
                    {
                        Vector3 forward;
#if UNITY_5
                        Ray ray;
                        if (sourcePose.TryGetPointerRay(out ray))
                        {
                            forward         = ray.direction;
                            pointerPosition = ray.origin;
#else
                        if (sourcePose.TryGetForward(out forward, InteractionSourceNode.Pointer))
                        {
#endif
#if VERBOSE_POSITION
                            TraceHelper.LogDiff(string.Format("Pos:{0}, Fwd:{1}",
                                                              pointerPosition, forward), Cache.ForwardPosition);
#endif
                            if (cursor != null)
                            {
                                cursor.transform.position = pointerPosition + forward;
                            }
                        }
                        else
                        {
                            TraceHelper.Log("Failed get forward");
                        }
                    }
                }
#if VALIDATE_INPUT
                else
                {
                    invalidCoordsCount++;
                    TraceHelper.LogModulus(string.Format("Invalid: Pointer: {0}, Grip: {1}, count: {2}",
                                                         pointerPosition, position, invalidCoordsCount), TraceVariables.InteractionManagerLoop);
                }
#endif
            }
            else
            {
                TraceHelper.LogModulus(string.Format("No readings:{0}-- Grip: Pos-{1}, Rot-{2}, PointerPos-{3}, Rot-{4}",
#if UNITY_5
                                                     sourceState.source.sourceKind.ToString(),
#else
                                                     sourceState.source.kind.ToString(),
#endif
                                                     hasPosition, hasRotation,
                                                     hasPointerPosition, hasPointerRotation
                                                     ), TraceVariables.InteractionManagerLoop);
            }
            var rootproperties = sourceState;
#if UNITY_5
            state.SelectValue       = (float)rootproperties.selectPressedValue;
            state.TouchPadXValue    = (float)rootproperties.controllerProperties.touchpadX;
            state.TouchPadYValue    = (float)rootproperties.controllerProperties.touchpadY;
            state.ThumbstickXValue  = (float)rootproperties.controllerProperties.thumbstickX;
            state.ThumbstickYValue  = (float)rootproperties.controllerProperties.thumbstickY;
            state.TouchPadPressed   = rootproperties.controllerProperties.touchpadPressed;
            state.TouchPadTouched   = rootproperties.controllerProperties.touchpadTouched;
            state.ThumbstickPressed = rootproperties.controllerProperties.thumbstickPressed;
#else
            state.SelectValue       = rootproperties.selectPressedAmount;
            state.TouchPadXValue    = rootproperties.touchpadPosition.x;
            state.TouchPadYValue    = rootproperties.touchpadPosition.y;
            state.ThumbstickXValue  = rootproperties.thumbstickPosition.x;
            state.ThumbstickYValue  = rootproperties.thumbstickPosition.y;
            state.TouchPadPressed   = rootproperties.touchpadPressed;
            state.TouchPadTouched   = rootproperties.touchpadTouched;
            state.ThumbstickPressed = rootproperties.thumbstickPressed;
#endif

            state.SelectPressed   = rootproperties.selectPressed;
            state.MenuPressed     = rootproperties.menuPressed;
            state.GraspPressed    = rootproperties.grasped;
            state.Position        = position;
            state.PointerPosition = pointerPosition;
            state.Rotation        = rotation;
            state.PointerRotation = pointerRotation;
            state.IsLeftHand      = sourceState.source.handedness == InteractionSourceHandedness.Left;
            state.IsRightHand     = sourceState.source.handedness == InteractionSourceHandedness.Right;

#if VERBOSE_STATE
            state.TraceState(FilterInput);
#endif

            Vector3 pointerForward = Vector3.zero, gripForward = Vector3.zero;
            bool    hasPointerForward = false, hasGripForward = false;
#if !UNITY_5
            if ((hasPointerForward = sourcePose.TryGetForward(out pointerForward, InteractionSourceNode.Pointer)) &&
                (hasGripForward = sourcePose.TryGetForward(out gripForward, InteractionSourceNode.Grip)))
            {
#else
            Ray rayAxis;
            if ((hasPointerForward = hasPointerPosition = sourcePose.TryGetPointerRay(out rayAxis)))
            {
                pointerForward  = rayAxis.direction;
                pointerPosition = rayAxis.origin;
                hasGripForward  = true; //it is a zero vector.
#endif
                if (ShowDebugAxis)
                {
                    AxisRenderer axis = (state.IsLeftHand ? axisRendererLeft : axisRendererRight);
                    if (axis != null)
                    {
                        if (hasPointerForward && hasPointerPosition)
                        {
                            axis.SetValues(state.PointerPosition, pointerForward * 2, state.PointerRotation, AxisRenderer.ControllerElement.Pointer);
                        }
                        if (hasGripForward && hasPosition)
                        {
                            axis.SetValues(state.Position, gripForward * 2, state.Rotation, AxisRenderer.ControllerElement.Grip);
                        }
                    }
                }
            }
#if VERBOSE_STATE
            else
            {
                TraceHelper.LogModulus(string.Format("No Forward vectors. Grip: {0}, pointer:{1}",
                                                     hasPointerForward, hasGripForward), TraceVariables.InteractionManagerLoop);
            }
#endif


            if (AnimateControllerModel)
            {
                MotionControllerInfo currentController;
                if (controllerInfoForAnimation.TryGetValue(sourceState.source.id, out currentController))
                {
#if !UNITY_5
                    currentController.AnimateSelect(sourceState.selectPressedAmount);
                    if (sourceState.source.supportsGrasp)
                    {
                        currentController.AnimateGrasp(sourceState.grasped);
                    }

                    if (sourceState.source.supportsMenu)
                    {
                        currentController.AnimateMenu(sourceState.menuPressed);
                    }
                    if (sourceState.source.supportsThumbstick)
                    {
                        currentController.AnimateThumbstick(sourceState.thumbstickPressed, sourceState.thumbstickPosition);
                    }

                    if (sourceState.source.supportsTouchpad)
                    {
                        currentController.AnimateTouchpad(sourceState.touchpadPressed, sourceState.touchpadTouched, sourceState.touchpadPosition);
                    }
#else
                    currentController.AnimateSelect((float)sourceState.selectPressedValue);
                    if (sourceState.source.supportsGrasp)
                    {
                        currentController.AnimateGrasp(sourceState.grasped);
                    }

                    if (sourceState.source.supportsMenu)
                    {
                        currentController.AnimateMenu(sourceState.menuPressed);
                    }

                    InteractionController controller;
                    if (sourceState.source.TryGetController(out controller))
                    {
                        if (controller.hasThumbstick)
                        {
                            currentController.AnimateThumbstick(sourceState.controllerProperties.thumbstickPressed,
                                                                new Vector2((float)sourceState.controllerProperties.thumbstickX,
                                                                            (float)sourceState.controllerProperties.thumbstickY));
                        }

                        if (controller.hasTouchpad)
                        {
                            currentController.AnimateTouchpad(sourceState.controllerProperties.touchpadPressed,
                                                              sourceState.controllerProperties.touchpadTouched,
                                                              new Vector2((float)sourceState.controllerProperties.touchpadX,
                                                                          (float)sourceState.controllerProperties.touchpadX));
                        }
                    }
#endif
                }
                else
                {
                    TraceHelper.Log("Could not animate " + sourceState.source.id);
                }
            }

            if (state.ThumbstickPressed &&
                (Time.unscaledTime > (debounceThumbstickTime + 3f))
                )
            {
                ShowDebugAxis = !ShowDebugAxis;
                UpdateDebugAxis(ShowDebugAxis);
                debounceThumbstickTime = Time.unscaledTime;
            }
        }
    }

    float debounceThumbstickTime = 0f;
示例#10
0
文件: GDI_Draw.cs 项目: lzz42/ZHello
        public void DrawForm()
        {
            var f = new ZForm()
            {
                Size = new Size(1080, 800),
                Text = "ZForm"
            };
            var btn = new Button()
            {
                Text     = "Draw",
                Location = new Point(10, 400),
            };
            var num = new NumericUpDown()
            {
                Minimum  = 1,
                Maximum  = 500,
                Value    = 1,
                Size     = new Size(60, 30),
                Location = new Point(10, 430),
            };

            num.ValueChanged += (s, e) =>
            {
                btn.PerformClick();
            };
            btn.MouseClick += (s, e) =>
            {
                ZHello.GDI.Draw.DDX = (int)num.Value;
                var dc = f.CreateGraphics();
                //dc.SetClip(new Rectangle(100, 100, 1000, 1000));
                //dc.Clear(Color.White);
                //dc.ResetClip();
                //f.DrawTestGrahpics();
                //dc.DrawStar(new Rectangle(200, 100, 200, 200), Color.Red);
                int radius = 80;
                dc.DrawPolygonX(new PointF(200, 200), radius, 3, Color.Red);
                dc.DrawPolygonX(new PointF(400, 200), radius, 4, Color.Blue);
                dc.DrawPolygonX(new PointF(600, 200), radius, 5, Color.Green);
                dc.DrawPolygonX(new PointF(800, 200), radius, 6, Color.Yellow);

                dc.DrawPolygonX(new PointF(200, 400), radius, 7, Color.Red);
                dc.DrawPolygonX(new PointF(400, 400), radius, 8, Color.Blue);
                dc.DrawPolygonX(new PointF(600, 400), radius, 9, Color.Green);
                dc.DrawPolygonX(new PointF(800, 400), radius, 10, Color.Yellow);

                dc.DrawPolygonX(new PointF(200, 600), radius, 11, Color.Red);
                dc.DrawPolygonX(new PointF(400, 600), radius, 12, Color.Blue);
                dc.DrawPolygonX(new PointF(600, 600), radius, 13, Color.Green);
                dc.DrawPolygonX(new PointF(800, 600), radius, 14, Color.Yellow);
            };
            var axis = new AxisRenderer()
            {
                AxisType      = AxisType.AxisXY,
                SubScaleCount = 2,
            };

            f.Paint += (s, e) =>
            {
                var dc = e.Graphics;
                dc.TranslateTransform(f.AutoScrollPosition.X, f.AutoScrollPosition.Y);
                axis.Bounds = new Rectangle(1, 1, 800, 600);
                axis.Render(dc);
                //e.Graphics.DrawStar(new Rectangle(100, 100, 100, 100), Color.Red);
            };
            f.Controls.Add(btn);
            f.Controls.Add(num);
            f.ShowDialog();
        }