Beispiel #1
0
        public void StartUp()
        {
            Console.WriteLine("StartUp()");
            if (!_setupRun)
            {
                Console.WriteLine("Setting up");


                string rootPath = TestConfig.GetConfig().GetRipleyServerPath();
                BBC.Dna.AppContext.OnDnaStartup(rootPath);

                //Create the mocked inputcontext
                Mockery mock = new Mockery();
                _context = DnaMockery.CreateDatabaseInputContext();

                // Create a mocked site for the context
                ISite mockedSite = DnaMockery.CreateMockedSite(_context, 1, "h2g2", "h2g2", true, "comment");
                Stub.On(_context).GetProperty("CurrentSite").Will(Return.Value(mockedSite));
                Stub.On(mockedSite).GetProperty("ModClassID").Will(Return.Value(1));

                Stub.On(_context).Method("FileCacheGetItem").Will(Return.Value(false));
                Stub.On(_context).Method("FileCachePutItem").Will(Return.Value(false));

                // Initialise the profanities object
                var p = new ProfanityFilter(DnaMockery.CreateDatabaseReaderCreator(), DnaDiagnostics.Default, CacheFactory.GetCacheManager(), null, null);
                BBC.Dna.User user = new BBC.Dna.User(_context);
                Stub.On(_context).GetProperty("ViewingUser").Will(Return.Value(user));
                
                _setupRun = true;
            }
            Console.WriteLine("Finished StartUp()");
        }
Beispiel #2
0
        public MouseClickEventArgs(IPoint2D position,
                                   MouseButtons button,
                                   Int32 clickCount,
                                   IInputContext inputContext)
        {
            Position     = position;
            InputContext = inputContext;
            Button       = button;
            ClickCount   = clickCount;

            switch (button)
            {
            case MouseButtons.Left:
                Action = InputAction.LeftClick;
                break;

            case MouseButtons.Right:
                Action = InputAction.RightClick;
                break;

            case MouseButtons.Middle:
                Action = InputAction.MiddleClick;
                break;

            default:
                throw new NotSupportedException();
            }
        }
        /// <summary>
        /// Constructs a new ImGuiController.
        /// </summary>
        public ImGuiController(GL gl, IView view, IInputContext input)
        {
            _gl           = gl;
            _glVersion    = new Version(gl.GetInteger(GLEnum.MajorVersion), gl.GetInteger(GLEnum.MinorVersion));
            _view         = view;
            _input        = input;
            _windowWidth  = view.Size.X;
            _windowHeight = view.Size.Y;

            IntPtr context = ImGuiNET.ImGui.CreateContext();

            ImGuiNET.ImGui.SetCurrentContext(context);
            var io = ImGuiNET.ImGui.GetIO();

            io.Fonts.AddFontDefault();

            io.BackendFlags |= ImGuiBackendFlags.RendererHasVtxOffset;

            CreateDeviceResources();
            SetKeyMappings();

            SetPerFrameImGuiData(1f / 60f);

            ImGuiNET.ImGui.NewFrame();
            _frameBegun        = true;
            _keyboard          = _input.Keyboards[0];
            _view.Resize      += WindowResized;
            _keyboard.KeyChar += OnKeyChar;
        }
Beispiel #4
0
        /// <summary>
        /// 
        /// </summary>
        ///<param name="inputContext"></param>
        /// <param name="outputContext"></param>
        /// <returns></returns>
        public bool Initialise(IInputContext inputContext, IOutputContext outputContext)
        {
            _skinSet = inputContext.CurrentSite.SkinSet;
 
            List<string> skinNames = GetOrderedSkinNames(inputContext);
            foreach (string skinName in skinNames)
            {

                _skinName = skinName.ToLower();
                if (_skinName.EndsWith("-xml", true, null))
                {
                    // Legacy support  -xml indicates xml skin. 
                    _skinName = "xml";
                }

                if (VerifySkin(_skinName, inputContext.CurrentSite))
                {
                    return true;
                }
            }

            //Fallback to specified Skin in Vanilla SkinSet.
            if ( _skinName != null && _skinName != string.Empty )
            {
                if ( outputContext.VerifySkinFileExists( _skinName, "vanilla") )
                {
                    _skinSet = "vanilla";
                    return true;
                }
            }

            //Fallback to users preferred skin
            if ( inputContext.ViewingUser != null && inputContext.ViewingUser.UserLoggedIn)
            {
                if (inputContext.ViewingUser.PreferredSkin.Length != 0 && VerifySkin(inputContext.ViewingUser.PreferredSkin, inputContext.CurrentSite))
                {
                    _skinName = inputContext.ViewingUser.PreferredSkin.ToLower();
                    return true;
                }
            }

            // Fallback to default skin for site.
            if (VerifySkin(inputContext.CurrentSite.DefaultSkin, inputContext.CurrentSite))
            {
                _skinName = inputContext.CurrentSite.DefaultSkin.ToLower();
                return true;
            }

            // Try to return vanilla default skin.
            if (outputContext.VerifySkinFileExists("html", "vanilla"))
            {
                _skinName = "html";
                _skinSet = "vanilla";
                return true;
            }

            //Error - no skin.
            return false;
            
        }
Beispiel #5
0
        private void InitControls()
        {
            inputContext = Window.CreateInput();
            context      = new ListenContext()
            {
                Active = true
            };

            Keyboard        = new Keyboard(inputContext);
            Mouse           = new Mouse(Screen, inputContext);
            PhoneBackButton = new BackButton();
            TouchPanel      = new TouchPanel();

            controllers     = new List <IController>();
            GameControllers = new List <GamePad>(4);

            GameControllers.Add(new GamePad(inputContext, 0));
            GameControllers.Add(new GamePad(inputContext, 1));
            GameControllers.Add(new GamePad(inputContext, 2));
            GameControllers.Add(new GamePad(inputContext, 3));
            controllers.AddRange(GameControllers);

            controllers.Add(Mouse);

            controllers.Add(Keyboard);

            controllers.Add(Accelerometer);
            controllers.Add(TouchPanel);

            controllers.Add(PhoneBackButton);
        }
Beispiel #6
0
        private void HandleUnsubscribeEventMessage(UnsubscribeEventMessage unsubscribeEventMessage,
                                                   IInputContext context)
        {
            if (!_objectsRepository.TryGetObject(unsubscribeEventMessage.ObjectId, out var objectAdapter) || objectAdapter == null)
            {
                WriteObjectNotFoundError(context, unsubscribeEventMessage.ObjectId);
                return;
            }

            if (!objectAdapter.Events.TryGetValue(unsubscribeEventMessage.EventName, out var ev))
            {
                WriteEventNotFoundError(context, unsubscribeEventMessage.ObjectId, unsubscribeEventMessage.EventName);
                return;
            }

            ISubscription subscription;

            lock (_subscriptions)
            {
                if (!_subscriptions.TryGetValue(ev, out subscription))
                {
                    //No exception or error is needed (same as for standard c# events when unsubscribed from a delegate that was not subscribed before).
                    return;
                }

                _subscriptions.Remove(ev);
            }

            subscription.Dispose();

            var ackMessage = new AckMessage(unsubscribeEventMessage.ClientHostAddress);

            context.Write(ackMessage.ToFrame());
        }
Beispiel #7
0
        public async Task Should_keep_track_of_only_the_last_value()
        {
            ILatestFilter <IInputContext <A> > latestFilter = null;

            IPipe <IInputContext <A> > pipe = Pipe.New <IInputContext <A> >(x =>
            {
                x.UseLatest(l => l.Created = filter => latestFilter = filter);
                x.UseExecute(payload =>
                {
                });
            });

            Assert.That(latestFilter, Is.Not.Null);

            var inputContext = new InputContext(new object());

            var limit = 100;

            for (var i = 0; i <= limit; i++)
            {
                var context = new InputContext <A>(inputContext, new A {
                    Index = i
                });
                await pipe.Send(context);
            }

            IInputContext <A> latest = await latestFilter.Latest;

            Assert.That(latest.Value.Index, Is.EqualTo(limit));
        }
Beispiel #8
0
        private void InputEvents_ButtonPressed(object sender, EventArgsInput e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            // TODO: remove ControllerA check once IsActionButton works for gamepads. https://github.com/Pathoschild/SMAPI/issues/416
            if (e.IsActionButton || e.Button == SButton.ControllerA)
            {
                const int controllerOffset = 2000;
                bool      isGamepad        = (int)e.Button > controllerOffset;
                this.CurrentInputContext = isGamepad ? (IInputContext)GamepadInputContext.DefaultContext : MouseInputContext.DefaultContext;
                this.CurrentInputContext.CursorPosition = e.Cursor;

                if (this.ActionManager.CanCheckForAction())
                {
                    this.ActionManager.CheckForAction(this.CurrentInputContext);
                }
            }
            else if (e.Button.Equals(SButton.F7))
            {
                Game1.warpFarmer(BathhouseLocationName, 27, 30, false);
            }
        }
Beispiel #9
0
        public void SetUp()
        {
            _mock = new Mockery();
            _site = _mock.NewMock<ISite>();
            Stub.On(_site).GetProperty("DefaultSkin").Will(Return.Value(SITE_DEFAULT_SKIN));
            Stub.On(_site).Method("DoesSkinExist").With(SITE_DEFAULT_SKIN).Will(Return.Value(true));
            Stub.On(_site).Method("DoesSkinExist").With(INVALID_SKIN).Will(Return.Value(false));
            Stub.On(_site).Method("DoesSkinExist").With(USER_PREFERRED_SKIN).Will(Return.Value(true));
            Stub.On(_site).Method("DoesSkinExist").With(Is.Null).Will(Return.Value(false));
            Stub.On(_site).Method("DoesSkinExist").With(REQUESTED_SKIN).Will(Return.Value(true));
            Stub.On(_site).Method("DoesSkinExist").With(FILTER_DERIVED_SKIN).Will(Return.Value(true));
            Stub.On(_site).Method("DoesSkinExist").With("xml").Will(Return.Value(true));
            Stub.On(_site).GetProperty("SkinSet").Will(Return.Value("vanilla"));
            
            _user = _mock.NewMock<IUser>();

            _inputContext = _mock.NewMock<IInputContext>();
            Stub.On(_inputContext).GetProperty("CurrentSite").Will(Return.Value(_site));

            _outputContext = _mock.NewMock<IOutputContext>();
            Stub.On(_outputContext).Method("VerifySkinFileExists").Will(Return.Value(true));
    
            _skinSelector = new SkinSelector();
           
            _request = _mock.NewMock<IRequest>();
        }
Beispiel #10
0
        private static void OnLoad()
        {
            IInputContext input = window.CreateInput();

            for (int i = 0; i < input.Keyboards.Count; i++)
            {
                input.Keyboards[i].KeyDown += KeyDown;
            }

            Gl = GL.GetApi(window);

            //Instantiating our new abstractions
            Ebo = new BufferObject <uint>(Gl, Indices, BufferTargetARB.ElementArrayBuffer);
            Vbo = new BufferObject <float>(Gl, Vertices, BufferTargetARB.ArrayBuffer);
            Vao = new VertexArrayObject <float, uint>(Gl, Vbo, Ebo);

            //Telling the VAO object how to lay out the attribute pointers
            Vao.VertexAttributePointer(0, 3, VertexAttribPointerType.Float, 5, 0);
            Vao.VertexAttributePointer(1, 2, VertexAttribPointerType.Float, 5, 3);

            Shader = new Shader(Gl, "gl/shaders/shader.vert", "gl/shaders/shader.frag");

            //Loading a texture.
            Texture = new Texture(Gl, "tex/silk.png");
        }
Beispiel #11
0
        public Window(WindowConfig config)
        {
            _config = config;

            var opts = WindowOptions.DefaultVulkan;

            opts.WindowBorder = WindowBorder.Resizable;
            opts.Size         = new Silk.NET.Maths.Vector2D <int>((int)config.Width, (int)config.Height);
            opts.Title        = config.Title;
            opts.WindowState  = config.Fullscreen ? WindowState.Fullscreen : WindowState.Normal;

            _window         = Silk.NET.Windowing.Window.Create(opts);
            _window.Render += (time) => DrawFrame?.Invoke(time);

            _window.Initialize();

            _input = _window.CreateInput();
            var primaryKeyboard = _input.Keyboards.FirstOrDefault();

            if (primaryKeyboard != null)
            {
                primaryKeyboard.KeyDown += (keyboard, key, code) => OnKeyDown?.Invoke(key);
                primaryKeyboard.KeyUp   += (keyboard, key, code) => OnKeyUp?.Invoke(key);
            }
            for (int i = 0; i < _input.Mice.Count; i++)
            {
                _input.Mice[i].Cursor.CursorMode = config.CursorDisabled ? CursorMode.Disabled : CursorMode.Normal;
                _input.Mice[i].MouseMove        += (mouse, pos) => OnCursorPosition?.Invoke(pos.X, pos.Y);
                _input.Mice[i].Scroll           += (mouse, wheel) => OnScroll?.Invoke(wheel.X, wheel.Y);
                _input.Mice[i].MouseDown        += (mouse, button) => OnMouseDown?.Invoke(button);
                _input.Mice[i].MouseUp          += (mouse, button) => OnMouseUp?.Invoke(button);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Sends a key Event to the ibus current input context. This method will be called by
        /// the IbusKeyboardAdapter on some KeyDown and all KeyPress events.
        /// </summary>
        /// <param name="keySym">The X11 key symbol (for special keys) or the key code</param>
        /// <param name="scanCode">The X11 scan code</param>
        /// <param name="state">The modifier state, i.e. shift key etc.</param>
        /// <returns><c>true</c> if the key event is handled by ibus.</returns>
        /// <seealso cref="IBusKeyboardAdaptor.HandleKeyPress"/>
        public bool ProcessKeyEvent(int keySym, int scanCode, Keys state)
        {
            if (m_inputContext == null)
            {
                return(false);
            }

            try
            {
                // m_inputContext.IsEnabled() throws an exception for IBus 1.5.
                if (!KeyboardController.CombinedKeyboardHandling && !m_inputContext.IsEnabled())
                {
                    return(false);
                }

                var modifiers = ConvertToIbusModifiers(state, (char)keySym);

                return(m_inputContext.ProcessKeyEvent(keySym, scanCode, modifiers));
            }
            catch (NDesk.DBus.DBusConectionErrorException e)
            {
                Console.WriteLine("IbusCommunicator.ProcessKeyEvent({0},{1},{2}): caught DBusConectionErrorException: {3}", keySym, scanCode, state, e);
                m_ibus         = null;
                m_inputContext = null;
                NotifyUserOfIBusConnectionDropped();
            }
            catch (System.NullReferenceException e)
            {
                Console.WriteLine("IbusCommunicator.ProcessKeyEvent({0},{1},{2}): caught NullReferenceException: {3}", keySym, scanCode, state, e);
            }
            return(false);
        }
Beispiel #13
0
        private static void Load()
        {
            IInputContext input = window.CreateInput();

            foreach (IKeyboard keyboard in input.Keyboards)
            {
                keyboard.KeyDown += KeyDown;
            }
            foreach (IMouse mouse in input.Mice)
            {
                mouse.MouseMove += MouseMove;
            }

            gl = window.CreateOpenGL();

            OpenGLRenderer nvgRenderer = new(CreateFlags.Antialias | CreateFlags.StencilStrokes | CreateFlags.Debug, gl);

            nvg = Nvg.Create(nvgRenderer);

            demo = new Demo(nvg);

            timer = Stopwatch.StartNew();

            timer.Restart();

            prevTime = timer.Elapsed.TotalMilliseconds;
        }
Beispiel #14
0
        public InputEventManager(IInputContext inputContext)
        {
            _inputContext = inputContext;

            InitMouseEvents();
            InitKeyEvents();
        }
Beispiel #15
0
 public void SwitchContext(IInputContext newContext)
 {
     // TODO: Keep track of previous context so SwitchContextToPrevious();
     activeContext.OnExit();
     newContext.OnEnter();
     contextToSwitchTo = newContext;
 }
Beispiel #16
0
 void Start()
 {
     // Handle switch to default input context
     contextToSwitchTo = activeContext;
     activeContext.OnEnter();
     activeContext.OnFirstUpdate();
 }
Beispiel #17
0
        private static void OnLoad()
        {
            IInputContext input = window.CreateInput();

            primaryKeyboard = input.Keyboards.FirstOrDefault();
            if (primaryKeyboard != null)
            {
                primaryKeyboard.KeyDown += KeyDown;
            }
            for (int i = 0; i < input.Mice.Count; i++)
            {
                input.Mice[i].Cursor.CursorMode = CursorMode.Raw;
                input.Mice[i].MouseMove        += OnMouseMove;
                input.Mice[i].Scroll           += OnMouseWheel;
            }

            Gl = GL.GetApi(window);

            Ebo     = new BufferObject <uint>(Gl, Indices, BufferTargetARB.ElementArrayBuffer);
            Vbo     = new BufferObject <float>(Gl, Vertices, BufferTargetARB.ArrayBuffer);
            VaoCube = new VertexArrayObject <float, uint>(Gl, Vbo, Ebo);

            VaoCube.VertexAttributePointer(0, 3, VertexAttribPointerType.Float, 6, 0);
            VaoCube.VertexAttributePointer(1, 3, VertexAttribPointerType.Float, 6, 3);

            //The lighting shader will give our main cube its colour multiplied by the lights intensity
            LightingShader = new Shader(Gl, "shader.vert", "lighting.frag");
            //The Lamp shader uses a fragment shader that just colours it solid white so that we know it is the light source
            LampShader = new Shader(Gl, "shader.vert", "shader.frag");

            //Start a camera at position 3 on the Z axis, looking at position -1 on the Z axis
            Camera = new Camera(Vector3.UnitZ * 6, Vector3.UnitZ * -1, Vector3.UnitY, Width / Height);
        }
Beispiel #18
0
        public MouseUpEventArgs(IPoint2D position,
                                IPoint2D?positionWentDown,
                                MouseButtons button,
                                IInputContext inputContext,
                                Boolean isValidForClick)
        {
            Position         = position;
            PositionWentDown = positionWentDown;
            Button           = button;
            InputContext     = inputContext;
            IsValidForClick  = isValidForClick;

            switch (button)
            {
            case MouseButtons.Left:
                Action = InputAction.LeftMouseButtonUp;
                break;

            case MouseButtons.Right:
                Action = InputAction.RightMouseButtonUp;
                break;

            default:
                throw new NotSupportedException();
            }
        }
        /// <summary>
        /// Determines whether the specified mouse button was up and is now pressed.
        /// </summary>
        /// <param name="action"></param>
        /// <param name="button">The button.</param>
        /// <returns>
        ///   <c>true</c> if the specified mouse button is down; otherwise, <c>false</c>.
        /// </returns>
        public static bool IsPressed(this IInputContext action, MouseButtons button)
        {
            switch (button)
            {
            case MouseButtons.Middle:
            {
                return(action.Previous.MouseState.MiddleButton == ButtonState.Released && action.Current.MouseState.MiddleButton == ButtonState.Pressed);
            }

            case MouseButtons.Right:
            {
                return(action.Previous.MouseState.RightButton == ButtonState.Released && action.Current.MouseState.RightButton == ButtonState.Pressed);
            }

            case MouseButtons.X1:
            {
                return(action.Previous.MouseState.XButton1 == ButtonState.Released && action.Current.MouseState.XButton1 == ButtonState.Pressed);
            }

            case MouseButtons.X2:
            {
                return(action.Previous.MouseState.XButton2 == ButtonState.Released && action.Current.MouseState.XButton2 == ButtonState.Pressed);
            }

            case MouseButtons.Left:
            default:
            {
                return(action.Previous.MouseState.LeftButton == ButtonState.Released && action.Current.MouseState.LeftButton == ButtonState.Pressed);
            }
            }
        }
Beispiel #20
0
        /// <summary>
        /// Constructor for the User Tests to set up the context for the tests
        /// </summary>
        public UserListTests()
        {
            string rootPath = TestConfig.GetConfig().GetRipleyServerPath();
            BBC.Dna.AppContext.OnDnaStartup(rootPath);


            Console.WriteLine("Before RecentSearch - AddRecentSearchTests");

            //Create the mocked _InputContext
            Mockery mock = new Mockery();
            _InputContext = DnaMockery.CreateDatabaseInputContext();

            // Create a mocked site for the context
            ISite mockedSite = DnaMockery.CreateMockedSite(_InputContext, 1, "h2g2", "h2g2", true, "comment");
            Stub.On(_InputContext).GetProperty("CurrentSite").Will(Return.Value(mockedSite));
            Stub.On(mockedSite).GetProperty("ModClassID").Will(Return.Value(1));


            BBC.Dna.User user = new BBC.Dna.User(_InputContext);
            Stub.On(_InputContext).GetProperty("ViewingUser").Will(Return.Value(user));
            Stub.On(_InputContext).GetProperty("CurrentSite").Will(Return.Value(mockedSite));

            //Create sub editor group and users
            //create test sub editors
            DnaTestURLRequest dnaRequest = new DnaTestURLRequest("h2g2");
            dnaRequest.SetCurrentUserEditor();
            TestDataCreator testData = new TestDataCreator(_InputContext);
            int[] userIDs = new int[10];
            Assert.IsTrue(testData.CreateNewUsers(mockedSite.SiteID, ref userIDs), "Test users not created");
            Assert.IsTrue(testData.CreateNewUserGroup(dnaRequest.CurrentUserID, "subs"), "CreateNewUserGroup not created");
            Assert.IsTrue(testData.AddUsersToGroup(userIDs, mockedSite.SiteID, "subs"), "Unable to add users to group not created");


        }
Beispiel #21
0
        /// <summary>
        /// Sends a key Event to the ibus current input context. This method will be called by
        /// the IbusKeyboardAdapter on some KeyDown and all KeyPress events.
        /// </summary>
        /// <param name="keySym">The X11 key symbol (for special keys) or the key code</param>
        /// <param name="scanCode">The X11 scan code</param>
        /// <param name="state">The modifier state, i.e. shift key etc.</param>
        /// <returns><c>true</c> if the key event is handled by ibus.</returns>
        /// <seealso cref="IbusKeyboardSwitchingAdaptor.HandleKeyPress"/>
        public bool ProcessKeyEvent(int keySym, int scanCode, Keys state)
        {
            if (m_inputContext == null)
            {
                return(false);
            }

            try
            {
                // m_inputContext.IsEnabled() is no longer contained in IBus 1.5. However,
                // ibusdotnet >= 1.9.1 deals with that and always returns true so that we still
                // can use this method.
                if (!m_inputContext.IsEnabled())
                {
                    return(false);
                }

                var modifiers = ConvertToIbusModifiers(state, (char)keySym);

                return(m_inputContext.ProcessKeyEvent(keySym, scanCode, modifiers));
            }
            catch (NDesk.DBus.DBusConectionErrorException e)
            {
                Console.WriteLine("IbusCommunicator.ProcessKeyEvent({0},{1},{2}): caught DBusConectionErrorException: {3}", keySym, scanCode, state, e);
                m_ibus         = null;
                m_inputContext = null;
                NotifyUserOfIBusConnectionDropped();
            }
            catch (System.NullReferenceException e)
            {
                Console.WriteLine("IbusCommunicator.ProcessKeyEvent({0},{1},{2}): caught NullReferenceException: {3}", keySym, scanCode, state, e);
            }
            return(false);
        }
Beispiel #22
0
        /// <summary>
        /// Request the IP Address of a post.
        /// </summary>
        /// <param name="entryId"></param>
        /// <param name="reason"></param>
        /// <param name="context"></param>
        /// <param name="modId"></param>
        /// <returns></returns>
        public string RequestIPAddress(int entryId, string reason, int modId, IInputContext context)
        {
            using (IDnaDataReader reader = context.CreateDnaDataReader("getipaddressforthreadentry"))
            {
                reader.AddParameter("entryid", entryId);
                reader.AddParameter("userid", context.ViewingUser.UserID);
                reader.AddParameter("reason", reason);
                reader.AddParameter("modid", modId);
                reader.Execute();

                if (reader.HasRows)
                {
                    reader.Read();
					if (reader.DoesFieldExist("DatePosted") && !reader.IsDBNull("DatePosted"))
					{
						return string.Format("{0}\r\nPosted: {1}", reader[0].ToString(), reader["DatePosted"]);
					}
					else
					{
						return reader[0].ToString();
					}
                }
            }
            return "";
        }
Beispiel #23
0
        private static void OnLoad()
        {
            IInputContext input = window.CreateInput();

            primaryKeyboard = input.Keyboards.FirstOrDefault();
            if (primaryKeyboard != null)
            {
                primaryKeyboard.KeyDown += KeyDown;
            }
            for (int i = 0; i < input.Mice.Count; i++)
            {
                input.Mice[i].Cursor.CursorMode = CursorMode.Raw;
                input.Mice[i].MouseMove        += OnMouseMove;
                input.Mice[i].Scroll           += OnMouseWheel;
            }

            Gl = GL.GetApi(window);

            Ebo = new BufferObject <uint>(Gl, Indices, BufferTargetARB.ElementArrayBuffer);
            Vbo = new BufferObject <float>(Gl, Vertices, BufferTargetARB.ArrayBuffer);
            Vao = new VertexArrayObject <float, uint>(Gl, Vbo, Ebo);

            Vao.VertexAttributePointer(0, 3, VertexAttribPointerType.Float, 5, 0);
            Vao.VertexAttributePointer(1, 2, VertexAttribPointerType.Float, 5, 3);

            Shader = new Shader(Gl, "shader.vert", "shader.frag");

            Texture = new Texture(Gl, "silk.png");
        }
        private unsafe PinMameController(IInputContext input)
        {
            _pinMame = PinMame.PinMame.Instance();

            _pinMame.OnGameStarted        += OnGameStarted;
            _pinMame.OnDisplayAvailable   += OnDisplayAvailable;
            _pinMame.OnDisplayUpdated     += OnDisplayUpdated;
            _pinMame.OnAudioAvailable     += OnAudioAvailable;
            _pinMame.OnAudioUpdated       += OnAudioUpdated;
            _pinMame.OnConsoleDataUpdated += OnConsoleDataUpdated;
            _pinMame.OnGameEnded          += OnGameEnded;
            _pinMame.IsKeyPressed         += IsKeyPressed;

            _pinMame.SetHandleKeyboard(true);

            _dmdController = DmdController.Instance();

            _input = input;

            foreach (var keyboard in _input.Keyboards)
            {
                keyboard.KeyDown += (arg1, arg2, arg3) =>
                {
                    if (_keycodeMap.TryGetValue(arg2, out var keycode))
                    {
                        Logger.Trace($"KeyDown() {keycode} ({(int)keycode})");

                        _keypress[(int)keycode] = 1;
                    }
                };

                keyboard.KeyUp += (arg1, arg2, arg3) =>
                {
                    if (_keycodeMap.TryGetValue(arg2, out var keycode))
                    {
                        Logger.Trace($"KeyUp() {keycode} ({(int)keycode})");

                        _keypress[(int)keycode] = 0;
                    }
                };
            }

            _al = AL.GetApi(true);

            ALContext alContext = ALContext.GetApi(true);
            var       device    = alContext.OpenDevice("");

            if (device != null)
            {
                alContext.MakeContextCurrent(
                    alContext.CreateContext(device, null));

                _audioSource  = _al.GenSource();
                _audioBuffers = _al.GenBuffers(_maxAudioBuffers);
            }
            else
            {
                Logger.Error("PinMameController(): Could not create device");
            }
        }
Beispiel #25
0
        /// <summary>
        /// Create an input context and setup callback handlers.
        /// </summary>
        public void CreateInputContext()
        {
            System.Diagnostics.Debug.Assert(!m_contextCreated);
            if (m_ibus == null)
            {
                // This seems to be needed for tests on TeamCity.
                // It also seems that it shouldn't be necessary to run IBus to use Linux keyboarding!
                return;
            }

            // A previous version of this code that seems to have worked on Saucy had the following
            // comment: "For IBus 1.5, we must use the current InputContext because there is no
            // way to enable one we create ourselves.  (InputContext.Enable() has turned
            // into a no-op.)  For IBus 1.4, we must create one ourselves because
            // m_ibus.CurrentInputContext() throws an exception."
            // However as of 2015-08-11 this no longer seems to be true: when we use the existing
            // input context then typing with an IPA KMFL keyboard doesn't work in the
            // SIL.Windows.Forms.TestApp on Trusty with unity desktop although the keyboard
            // indicator correctly shows the IPA keyboard. I don't know what changed or why it is
            // suddenly behaving differently.
            //
            //			if (KeyboardController.CombinedKeyboardHandling)
            //			{
            //				var path = m_ibus.CurrentInputContext();
            //				m_inputContext = new InputContext(m_connection, path);
            //			}
            //			else

            m_inputContext = m_ibus.CreateInputContext("IbusCommunicator");

            AttachContextMethods(m_inputContext);
            m_contextCreated = true;
        }
Beispiel #26
0
        internal InputSnapshot(IInputContext ctx, MemoryPool <byte> pool)
        {
            var gamepads  = ctx.Gamepads;
            var joysticks = ctx.Joysticks;
            var keyboards = ctx.Keyboards;
            var mice      = ctx.Mice;

            Gamepads  = new GamepadState[gamepads.Count];
            Joysticks = new JoystickState[joysticks.Count];
            Keyboards = new KeyboardState[keyboards.Count];
            Mice      = new MouseState[mice.Count];
            for (var i = 0; i < gamepads.Count; i++)
            {
                Gamepads[i] = new(gamepads[i], pool);
            }

            for (var i = 0; i < joysticks.Count; i++)
            {
                Joysticks[i] = new(joysticks[i], pool);
            }

            for (var i = 0; i < keyboards.Count; i++)
            {
                Keyboards[i] = new(keyboards[i], pool);
            }

            for (var i = 0; i < mice.Count; i++)
            {
                Mice[i] = new(mice[i], pool);
            }
        }
Beispiel #27
0
        public static void Initialize(IInputContext inputContext, GraphicDeviceDesc graphicDeviceDesc)
        {
            if (_initialized)
            {
                return;
            }

            var graphicFactory = Service.Require <GraphicDeviceFactory>();

            _graphics = graphicFactory.CreateDevice(graphicDeviceDesc);

            var input = Service.Get <InputManager>();

            if (input != null)
            {
                _keyboard = input.CreateKeyboard(inputContext);
                if (_keyboard != null)
                {
                    _keyboardController = new KeyBoardController(_keyboard);
                }

                _mouse = input.CreateMouse(inputContext);
                if (_mouse != null)
                {
                    _mouseController = new MouseController(_mouse);
                }
                _joysticks = input.CreateJoysticks(inputContext);
            }

            RenderManager.PushTechnique <DefaultTechnique>();
            _initialized = true;
        }
Beispiel #28
0
        public InputHandler(IInputContext inputContext = null)
        {
            activeContext = inputContext;

            Device.RegisterDevice(UsagePage.Generic, UsageId.GenericKeyboard, DeviceFlags.None);

            Device.KeyboardInput += onKeyboardInput;
        }
Beispiel #29
0
 public MouseWheelEventArgs(IPoint2D position,
                            Int32 delta,
                            IInputContext inputContext)
 {
     Position     = position;
     Delta        = delta;
     InputContext = inputContext;
 }
 public MouseOverEventArgs(IPoint2D position,
                           Boolean isMouseOver,
                           IInputContext inputContext)
 {
     Position     = position;
     InputContext = inputContext;
     IsMouseOver  = isMouseOver;
 }
Beispiel #31
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public User(IInputContext context)
            : base(context)
        {
            _userData.Clear();
            _userGroupsData.Clear();

            //_viewingUserElementNode = CreateElementNode("VIEWING-USER");
            //RootElement.AppendChild(_viewingUserElementNode);
        }
 /// <summary>
 /// Default Constructor for the UserSubscriptionsList object
 /// </summary>
 public ArticleSubscriptionsList(IInputContext context)
     : base(context)
 {
     string delimiter = NamespacePhrases.GetSiteDelimiterToken(context);
     if (delimiter.Length > 0)
     {
         _token = delimiter.Substring(0, 1);
     }
 }
Beispiel #33
0
        /// <summary>
        /// Redirects handling of the request message to target object.
        /// </summary>
        /// <param name="requestMessage"></param>
        /// <param name="context"></param>
        private void HandleRequestMessage(RequestMessage requestMessage, IInputContext context)
        {
            if (!_objectsRepository.TryGetObject(requestMessage.ObjectId, out var objectAdapter))
            {
                WriteObjectNotFoundError(context, requestMessage.ObjectId);
                return;
            }

            objectAdapter?.HandleCall(context, requestMessage);
        }
Beispiel #34
0
        private static void OnLoad()
        {
            //Set-up input context.
            IInputContext input = window.CreateInput();

            for (int i = 0; i < input.Keyboards.Count; i++)
            {
                input.Keyboards[i].KeyDown += KeyDown;
            }
        }
Beispiel #35
0
 public DevRenderKit(ViewWindow window, IVisualElement visualElement,
                     IStyleContext styleContext, IInputHandler inputHandler, IInputContext inputContext)
     : base(window, visualElement, styleContext,
            new BasePerspective(),
            inputHandler, inputContext)
 {
     _window     = window;
     _sbSelected = new StringBuilder();
     _font       = new Das.Views.Font(10, "Segoe UI", FontStyle.Regular);
 }
Beispiel #36
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="context"></param>
 public WelcomePageBuilder(IInputContext context)
     : base(context)
 {
     IsNativeRenderRequest = true;
     UserLoggedIn = false;
     UserLoginName = "";
     DNAUserDisplayName = "";
     DNAUserID = 0;
     EditorOfSitesList = null;
 }
        /// <summary>
        /// Default constructor
        /// </summary>
        public NewPollContentRatingTests()
        {
            // Create the snap shot roll back if we need it!
			SnapshotInitialisation.ForceRestore();

            if (_databaseContext == null)
            {
                _databaseContext = DnaMockery.CreateDatabaseInputContext(); 
            }
        }
Beispiel #38
0
    void HandleContextSwitch()
    {
        if (contextToSwitchTo == activeContext)
        {
            return;
        }

        activeContext.OnLastUpdate();
        activeContext = contextToSwitchTo;
        activeContext.OnFirstUpdate();
    }
        public WindowDrawingContext(GraphicsContext graphics, IInputContext input)
            : base(graphics.DeviceManager)
        {
            Graphics = graphics;

            _window = new AppWindow(input);
            _window.SizeChanged += win => Initialize();

            _depthBuffer = new DepthBuffer(DeviceManager, _window.ClientWidth, _window.ClientHeight);
            _windowTextureBuffer = new WindowTextureBuffer(DeviceManager, _window.Form.Handle, _window.ClientWidth, _window.ClientHeight);
        }
Beispiel #40
0
 internal Mouse(ScreenView screen, IInputContext input)
 {
     this.screen        = screen;
     this.CurrentState  = default;
     this.internalState = default;
     this.mouse         = input.Mice[0]; // TODO: Mitä tapahtuu jos koneessa on useampi hiiri kiinni?
     mouse.Scroll      += MouseScroll;
     mouse.MouseDown   += MouseDown;
     mouse.MouseUp     += MouseUp;
     mouse.MouseMove   += MouseMove;
 }
Beispiel #41
0
        /// <summary>
        /// The default constructor
        /// </summary>
        /// <param name="context">An object that supports the IInputContext interface. basePage</param>
        public PostToForumBuilder(IInputContext context)
            : base(context)
        {
            _creator = new DnaDataReaderCreator(AppContext.TheAppContext.Config.ConnectionString,
                                                AppContext.TheAppContext.Diagnostics);

            _cache = CacheFactory.GetCacheManager();
            //this is a clutch until we unify user objects
            _viewingUser = InputContext.ViewingUser.ConvertUser();

            _forumHelper = new ForumHelper(_creator, _viewingUser, InputContext.TheSiteList);
        }
Beispiel #42
0
        private void HandleConnect(ConnectMessage connectMessage, IInputContext context)
        {
            if (!_objectsRepository.TryGetObject(connectMessage.ObjectId, out _))
            {
                WriteObjectNotFoundError(context, connectMessage.ObjectId);
                return;
            }

            var ackMessage = new AckMessage(connectMessage.ClientHostAddress);

            context.Write(ackMessage.ToFrame());
        }
Beispiel #43
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="inputContext"></param>
 /// <returns></returns>
 public bool IsXmlSkin(IInputContext inputContext)
 {
     List<string> skinNames = GetOrderedSkinNames(inputContext);
     foreach (string skinName in skinNames)
     {
         string skin = skinName;
         if ( skin.Equals("xml") || skin.EndsWith("-xml", true, null))
         {
             return true;
         }
     }
     return false;
 }
Beispiel #44
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public bool IsPureXml(IInputContext inputContext)
 {
     List<string> skinNames = GetOrderedSkinNames(inputContext);
     foreach (string skinName in skinNames)
     {
         string skin = skinName;
         if (skin.Equals("purexml") )
         {
             return true;
         }
     }
     return false;
 }
Beispiel #45
0
        public AppWindow(IInputContext input)
        {
            _input = input;
            _form = new RenderForm();
            _renderLoop = new RenderLoop(Form);

            _form.Resize += OnFormResize;
            _form.Closed += OnFormClosed;
            _form.LostFocus += OnLostFocus;
            _form.MouseMove += OnMouseMove;
            _form.MouseDown += OnMouseDown;
            _form.MouseUp += OnMouseUp;
            _form.MouseWheel += OnMouseWheel;
        }
Beispiel #46
0
        /// <summary>
        /// Get the xml representation of the groups a user is in for a specific site.
        /// </summary>
        /// <param name="userID">users id</param>
        /// <param name="siteID">site id</param>
        /// <param name="context">input context</param>
        /// <returns></returns>
        public static string GetUserGroupsAsXml(int userID, int siteID, IInputContext context)
        {
            string result = String.Empty;
            var usersGroups = UserGroups.GetObject().GetUsersGroupsForSite(userID, siteID);
			result = "<GROUPS>";
            foreach (var group in usersGroups)
			{
				result += "<GROUP><NAME>";
                result += group.Name.ToUpper();
				result += "</NAME></GROUP>";
			}
			result += "</GROUPS>";
            return result;
        }
Beispiel #47
0
 /// <summary>
 /// Helper method for creating a mocked default diagnostics object
 /// </summary>
 /// <param name="mockedInput">The context that you want to add the diagnostics mocked object to</param>
 /// <returns>The new mocked Diagnostics object</returns>
 public static IDnaDiagnostics SetDefaultDiagnostics(IInputContext mockedInput)
 {
     IDnaTracer mockedTracer = _mockery.NewMock<IDnaTracer>();
     Stub.On(mockedTracer).Method("Write").Will(Return.Value(null));
     Stub.On(mockedTracer).Method("Dispose").Will(Return.Value(null));
     IDnaDiagnostics mockedDiag = _mockery.NewMock<IDnaDiagnostics>();
     Stub.On(mockedDiag).Method("CreateTracer").Will(Return.Value(mockedTracer));
     Stub.On(mockedDiag).Method("WriteTimedSignInEventToLog").Will(Return.Value(null));
     Stub.On(mockedDiag).Method("WriteTimedEventToLog").Will(Return.Value(null));
     Stub.On(mockedDiag).Method("WriteWarningToLog").Will(Return.Value(null));
     Stub.On(mockedDiag).Method("WriteToLog").Will(Return.Value(null));
     Stub.On(mockedInput).GetProperty("Diagnostics").Will(Return.Value(mockedDiag));
     return mockedDiag;
 }
        public GraphicsContext(Lazy<IFileStore> files, IInputContext input)
        {
            var deviceManager = new DeviceManager();
            DeviceManager = deviceManager;

            TextureResourceManager = new TextureResourceManager(deviceManager, files);
            TextureSamplerManager = new TextureSamplerManager(deviceManager);
            MaterialManager = new MaterialManager(this);
            BlendStateManager = new BlendStateManager(deviceManager);
            RasterizerStateManager = new RasterizerStateManager(deviceManager);

            RenderTargetFactory = new RenderTargetFactory(this, input);
            VertexBufferManagerFactory = new VertexBufferManagerFactory(deviceManager);
            IndexBufferManagerFactory = new IndexBufferManagerFactory(deviceManager);
            ConstantBufferManagerFactory = new ConstantBufferManagerFactory(deviceManager);
        }
Beispiel #49
0
        /// <summary>
        /// Helper method for creating the mocked AllowedURLs object
        /// </summary>
        /// <param name="mockedInput">The context that you want to add the AllowedURLs mocked object to</param>
        /// <returns>The new mocked AllowedURLs object</returns>
        public static IAllowedURLs SetDefaultAllowedURLs(IInputContext mockedInput)
        {
            //IAllowedURLs mockedAllowedURLs = _mockery.NewMock<IAllowedURLs>();
            //Stub.On(mockedAllowedURLs).Method("DoesAllowedURLListContain").Will(Return.Value(true));

            //Stub.On(mockedAllowedURLs).Method("WriteWarningToLog").Will(Return.Value(null));
            //Stub.On(mockedAllowedURLs).Method("WriteToLog").Will(Return.Value(null));
            //Stub.On(mockedInput).GetProperty("AllowedURLs").Will(Return.Value(mockedAllowedURLs));
            //return mockedAllowedURLs;


            AllowedURLs urls = new AllowedURLs();
            urls.LoadAllowedURLLists(mockedInput);

            Stub.On(mockedInput).GetProperty("AllowedURLs").Will(Return.Value(urls));
            return urls;
        }
Beispiel #50
0
        public void WillLowerCaseTheDefaultSkin()
        {
            ISite siteWithMixedCaseDefaultSkin = _mock.NewMock<ISite>();
            Stub.On(siteWithMixedCaseDefaultSkin).GetProperty("DefaultSkin").Will(Return.Value("deFAulT-SKIN"));
            Stub.On(siteWithMixedCaseDefaultSkin).Method("DoesSkinExist").With("deFAulT-SKIN").Will(Return.Value(true));
            Stub.On(_inputContext).GetProperty("CurrentSite").Will(Return.Value(siteWithMixedCaseDefaultSkin));
            Stub.On(siteWithMixedCaseDefaultSkin).GetProperty("SkinSet").Will(Return.Value("vanilla"));

            _inputContext = _mock.NewMock<IInputContext>();
            Stub.On(_inputContext).GetProperty("CurrentSite").Will(Return.Value(siteWithMixedCaseDefaultSkin));

            setupRequestToHaveNoSkinSpecifiedOnUrl();
            setupUserAsNotLoggedIn();
           

            _skinSelector.Initialise(_inputContext, _outputContext);
            Assert.AreEqual("default-skin", _skinSelector.SkinName);
        }
Beispiel #51
0
        /// <summary>
        /// Get the xml element of the groups a user is in for a specific site.
        /// </summary>
        /// <param name="userID">users id</param>
        /// <param name="siteID">site id</param>
        /// <param name="context">input context</param>
        /// <returns></returns>
        public static XmlElement GetUserGroupsElement(int userID, int siteID, IInputContext context)
        {
            string result = String.Empty;

            XmlDocument groupsdoc = new XmlDocument();
			XmlElement groups = groupsdoc.CreateElement("GROUPS");

			var usersGroups = UserGroups.GetObject().GetUsersGroupsForSite(userID, siteID);
            foreach (var groupObj in usersGroups)
			{
				XmlElement group = groupsdoc.CreateElement("GROUP");
				XmlElement name = groupsdoc.CreateElement("NAME");
                name.AppendChild(groupsdoc.CreateTextNode(groupObj.Name));
				group.AppendChild(name);
				groups.AppendChild(group);
			}

			return groups;
        }
Beispiel #52
0
        void SetupArticles(IInputContext context)
        {
            int entryID = 0;
            int h2g2ID = 0;
            //create a dummy article

            using (IDnaDataReader reader = context.CreateDnaDataReader("createguideentry"))
            {
                reader.AddParameter("subject", "TEST ARTICLE");
                reader.AddParameter("bodytext", "TEST ARTICLE");
                reader.AddParameter("extrainfo", "<EXTRAINFO>TEST ARTICLE</EXTRAINFO>");
                reader.AddParameter("editor", 6);
                reader.AddParameter("typeid", 3001);
                reader.AddParameter("status", 3);

                reader.Execute();
                Assert.IsTrue(reader.Read(), "Article not created");
                entryID = reader.GetInt32NullAsZero("entryid");
                h2g2ID = reader.GetInt32NullAsZero("h2g2id");

                Assert.IsTrue(entryID != 0, "Article not created");
            }

            int recommendationID = 0;
            //recommnend article...
            using (IDnaDataReader reader = context.CreateDnaDataReader("storescoutrecommendation"))
            {
                reader.AddParameter("entryid", entryID);
                reader.AddParameter("@comments", "scout comment");
                reader.AddParameter("scoutid", 6);
                reader.Execute();
                Assert.IsTrue(reader.Read(), "Recommendation not created");
                recommendationID = reader.GetInt32NullAsZero("RecommendationID");
                Assert.IsTrue(recommendationID != 0, "Recommendation not created");
            }
        }
 /// <summary>
 /// Default constructor for the Forum component
 /// </summary>
 /// <param name="context">The Context of the DnaPage the component is created in.</param>
 public TestInputContextComponent(IInputContext context)
     : base(context)
 {
 }
Beispiel #54
0
 /// <summary>
 /// Default Constructor for the LinksList object
 /// </summary>
 public LinksList(IInputContext context)
     : base(context)
 {
 }
 /// <summary>
 /// Default construtor
 /// </summary>
 /// <param name="context">The inputcontext to create the object from</param>
 public BannedEmailsPageBuilder(IInputContext context)
     : base(context)
 {
 }
Beispiel #56
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="context"></param>
 public ModerationClasses(IInputContext context)
     : base(context)
 { }
Beispiel #57
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="context">The context that the object will be created for</param>
 public MoveThread(IInputContext context)
     : base(context)
 {
 }
Beispiel #58
0
 /// <summary>
 /// Constructor for the Template object
 /// </summary>
 /// <param name="context"></param>
 public UITemplate(IInputContext context)
     : base(context)
 {
 }
Beispiel #59
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="context">The current context</param>
 public SiteXmlBuilder(IInputContext context)
     : base(context)
 {
 }
Beispiel #60
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="context"></param>
 public ModerationReasons(IInputContext context)
     : base(context)
 { 
 }