예제 #1
0
        void PlatformInit()
        {
            DefinedSymbols.Define("android");

            float px = TypedValue.ApplyDimension(ComplexUnitType.Mm, 1, Activity.Resources.DisplayMetrics);

            UiUnit.PixelsPerMm = px;
        }
예제 #2
0
        void PlatformInit()
        {
            DefinedSymbols.Define("ios");

            var view = Services.GetService <UIViewController>().View;

            view.Window.AddGestureRecognizer(new TouchPad_iOSGestureRecognizer(view));

            UiUnit.PixelsPerMm = UIScreen.MainScreen.Scale * 160.0 / 25.4;
        }
예제 #3
0
        void PlatformInit()
        {
            Initialization?.Invoke();

            DefinedSymbols.Define("uwp");
            DefinedSymbols.Define("win");

            double dpi = Math.Max(DisplayInformation.GetForCurrentView().RawDpiX, DisplayInformation.GetForCurrentView().RawDpiY);

            double px = dpi / 25.4;

            UiUnit.PixelsPerMm = px;

            AppDeactivated += Platform.AppDeactivated;
            AppActivated   += Platform.AppActivated;
        }
예제 #4
0
        void PlatformInit()
        {
            DefinedSymbols.Define("winDx");
            DefinedSymbols.Define("win");

            Form form = (Form)Control.FromHandle(Window.Handle);

            using (var graphics = form.CreateGraphics())
            {
                float  dpi       = Math.Max(graphics.DpiX, graphics.DpiY);
                double mmToPixel = dpi / 25.4;
                UiUnit.PixelsPerMm = mmToPixel;
            }

            form.BackColor = System.Drawing.Color.Black;

            form.FormClosing += (o, e) =>
            {
                if (CanClose != null)
                {
                    e.Cancel = !CanClose(this);
                }
            };

            form.SizeChanged += (o, e) =>
            {
                _updateSizeTimer = 0.1f;
            };

            _keyboardHandler = new KeyboardHandler(form.Handle);

            _keyboardHandler.OnCharacter += (c) =>
            {
                if (_currentFocus != null)
                {
                    if (c == '\r')
                    {
                        c = '\n';
                    }

                    _currentFocus.OnCharacter(c);
                }
                else
                {
                    Accelerators.Instance.Process(c);
                }

                OnCharacter?.Invoke(c);
            };

            _keyboardHandler.OnKeyDown += (k) =>
            {
                if (_currentFocus != null)
                {
                    _currentFocus.OnKey(k);
                }
                else
                {
                    Accelerators.Instance.Process(k);
                }

                OnKeyDown?.Invoke(k);
            };

            _keyboardHandler.OnKeyUp += (k) =>
            {
                if (OnKeyUp != null)
                {
                    OnKeyUp(k);
                }
            };

            _keyboardHandler.OnKeyDown += GamePads.Instance[0].ProcessKey;
            _keyboardHandler.OnKeyUp   += GamePads.Instance[0].ProcessKey;
        }