예제 #1
0
        void InitializeCommunicator(int rpHostProcessID)
        {
            r_Communicator = new MemoryMappedFileCommunicator($"Sakuno/HeavenlyWind({rpHostProcessID})", 4096);
            r_Communicator.ReadPosition  = 0;
            r_Communicator.WritePosition = 2048;

            r_Messages = r_Communicator.GetMessageObservable().ObserveOnDispatcher().Publish();
            r_Messages.Connect();

            r_Communicator.StartReader();

            r_Messages.Subscribe(CommunicatorMessages.ClearCache, _ => r_BrowserProvider?.ClearCache(false));
            r_Messages.Subscribe(CommunicatorMessages.ClearCacheAndCookie, _ => r_BrowserProvider?.ClearCache(true));

            r_Messages.Subscribe(CommunicatorMessages.GoBack, _ => r_Browser?.GoBack());
            r_Messages.Subscribe(CommunicatorMessages.GoForward, _ => r_Browser?.GoForward());
            r_Messages.Subscribe(CommunicatorMessages.Navigate, rpUrl => r_Browser?.Navigate(rpUrl));
            r_Messages.Subscribe(CommunicatorMessages.Refresh, _ => r_Browser?.Refresh());

            r_Messages.Subscribe(CommunicatorMessages.SetZoom, r =>
            {
                r_Zoom = double.Parse(r);
                r_Browser?.SetZoom(r_Zoom);
                r_Communicator.Write(CommunicatorMessages.InvalidateArrange);
            });

            r_Messages.Subscribe(CommunicatorMessages.ResizeBrowserToFitGame, _ =>
            {
                r_Container.Width  = GameConstants.GameWidth * r_Zoom / DpiUtil.ScaleX / DpiUtil.ScaleX;
                r_Container.Height = GameConstants.GameHeight * r_Zoom / DpiUtil.ScaleY / DpiUtil.ScaleY;
                r_Communicator.Write(CommunicatorMessages.InvalidateArrange);
            });

            InitializeScreenshotMessagesSubscription();
        }
        void InitializeCommunicator()
        {
            Communicator = new MemoryMappedFileCommunicator($"Sakuno/HeavenlyWind({HostProcessID})", 4096);
            Communicator.ReadPosition = 2048;
            Communicator.WritePosition = 0;

            Messages = Communicator.GetMessageObservable().Publish();
            Messages.Connect();

            Communicator.StartReader();
        }
        void InitializeCommunicator(int rpHostProcessID)
        {
            r_Communicator = new MemoryMappedFileCommunicator($"Sakuno/HeavenlyWind({rpHostProcessID})", 4096);
            r_Communicator.ReadPosition = 0;
            r_Communicator.WritePosition = 2048;

            r_Messages = r_Communicator.GetMessageObservable().ObserveOnDispatcher().Publish();
            r_Messages.Connect();

            r_Communicator.StartReader();

            r_Messages.Subscribe(CommunicatorMessages.ClearCache, _ => r_BrowserProvider?.ClearCache(false));
            r_Messages.Subscribe(CommunicatorMessages.ClearCacheAndCookie, _ => r_BrowserProvider?.ClearCache(true));

            r_Messages.Subscribe(CommunicatorMessages.GoBack, _ => r_Browser?.GoBack());
            r_Messages.Subscribe(CommunicatorMessages.GoForward, _ => r_Browser?.GoForward());
            r_Messages.Subscribe(CommunicatorMessages.Navigate, rpUrl => r_Browser?.Navigate(rpUrl));
            r_Messages.Subscribe(CommunicatorMessages.Refresh, _ => r_Browser?.Refresh());

            r_Messages.Subscribe(CommunicatorMessages.SetZoom, r =>
            {
                r_Zoom = double.Parse(r);
                r_Browser?.SetZoom(r_Zoom);
                r_Communicator.Write(CommunicatorMessages.InvalidateArrange);
            });

            r_Messages.Subscribe(CommunicatorMessages.ResizeBrowserToFitGame, _ =>
            {
                r_Container.Width = GameConstants.GameWidth * r_Zoom / DpiUtil.ScaleX / DpiUtil.ScaleX;
                r_Container.Height = GameConstants.GameHeight * r_Zoom / DpiUtil.ScaleY / DpiUtil.ScaleY;
                r_Communicator.Write(CommunicatorMessages.InvalidateArrange);
            });

            InitializeScreenshotMessagesSubscription();

        }
예제 #4
0
        public static IObservable <KeyValuePair <string, string> > GetMessageObservable(this MemoryMappedFileCommunicator rpCommunicator)
        {
            return(rpCommunicator.DataReceived.Select(r =>
            {
                var rMessage = Encoding.UTF8.GetString(r);

                var rCommand = rMessage;
                var rParamater = string.Empty;

                var rPosition = rMessage.IndexOf(':');
                if (rPosition != -1)
                {
                    rCommand = rMessage.Remove(rPosition);
                    rParamater = rMessage.Substring(rPosition + 1);
                }

                return new KeyValuePair <string, string>(rCommand, rParamater);
            }));
        }