Beispiel #1
0
        private void UndoSaveBtn_Click(object sender, EventArgs e)
        {
            MyReceiver myReceiver = new MyReceiver();

            _editor.SetCommand(new SaveCommand(myReceiver, textBox1.Text));
            MessageBox.Show(_editor.Undo());
        }
 public void StartRecordByType()
 {
     if (Count < 1)
     {
         StartService(intent);
         // Registering a Broadcast Receiver
         Receiver = new MyReceiver();
         IntentFilter filter = new IntentFilter();
         filter.AddAction("HealthKitService");
         this.RegisterReceiver(Receiver, filter);
         Count++;
     }
     else
     {
         this.UnregisterReceiver(Receiver);
         Count--;
         StartService(intent);
         // Registering a Broadcast Receiver
         Receiver = new MyReceiver();
         IntentFilter filter = new IntentFilter();
         filter.AddAction("HealthKitService");
         this.RegisterReceiver(Receiver, filter);
         Count++;
     }
 }
Beispiel #3
0
        private void PrintBtn_Click(object sender, EventArgs e)
        {
            MyReceiver myReceiver = new MyReceiver();

            _editor.SetCommand(new PrintCommand(myReceiver));
            MessageBox.Show(_editor.Execute());
        }
Beispiel #4
0
        private void UndoOpenBtn_Click(object sender, EventArgs e)
        {
            MyReceiver myReceiver = new MyReceiver();

            _editor.SetCommand(new OpenCommand(myReceiver));
            MessageBox.Show(_editor.Undo());
        }
Beispiel #5
0
		public Form1()
		{
            InitializeComponent();
            this.FormClosed += FormClosed;
			_receiver = new MyReceiver();
			_receiver.OnMessage += MessageReceived;
			_receiver.Start();
		}
Beispiel #6
0
    public void Run()
    {
        Action onAction = () => {
            Console.WriteLine("Did something");
        };
        var receiver = new MyReceiver();
        var evt      = receiver.GetType().GetEvent("OnAction");

        evt.AddEventHandler(receiver, AnonymousAction.WrapDelegate(onAction, evt.EventHandlerType));
        receiver.Do();
    }
Beispiel #7
0
    public void HandleRecall(PlayerInputState input, bool recalling)
    {
        if (!recalling)
        {
            return;
        }

        Receiver foreignReceiver = null;

        if (CanRecall(TransmissionType.Jump, input.JumpDown))
        {
            foreignReceiver = foreignReceivers[TransmissionType.Jump];
        }
        if (CanRecall(TransmissionType.Move, input.TransmitMove))
        {
            foreignReceiver = foreignReceivers[TransmissionType.Move];
        }

        if (foreignReceiver)
        {
            if (foreignReceiver.ActionBank.Count() > 0)
            {
                //Pull the transmission from the foreign receiver
                TransmissionType type = foreignReceiver.ActionBank.GetFirst();
                if (MyReceiver.CanReceive(type) && MyReceiver.ReceiveTransmission(type))
                {
                    foreignReceiver.ActionBank.RemoveAction(type);
                    foreignReceivers.Remove(type);

                    Animator anim = foreignReceiver.GetComponentInParent <Animator>();
                    if (anim)
                    {
                        anim.speed /= 3f;
                    }

                    //Grant the appropriate action controller of the receive to the sender.
                    if (type == TransmissionType.Jump)
                    {
                        GameController.S.jumpText.color = Color.green;
                        InputManager.JumpingController  = InputManager.PlayerMovementController;
                    }

                    if (type == TransmissionType.Move)
                    {
                        GameController.S.moveText.color = Color.green;
                        InputManager.MovingController.StopMovement();
                        InputManager.MovingController = InputManager.PlayerMovementController;
                    }
                }
            }
        }
    }
Beispiel #8
0
        void Start()
        {
            m_Graph = PlayableGraph.Create("NotificationGraph");
            var output = ScriptPlayableOutput.Create(m_Graph, "NotificationOutput");

            //Create and register a receiver
            m_Receiver = new MyReceiver();
            output.AddNotificationReceiver(m_Receiver);

            //Push a notification on the output
            output.PushNotification(Playable.Null, new MyNotification());

            m_Graph.Play();
        }
Beispiel #9
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            EMDKResults result = EMDKManager.GetEMDKManager(Application.Context, this);

            if (result.StatusCode != EMDKResults.STATUS_CODE.Success)
            {
                Toast.MakeText(this, "Error opening the EMDK Manager", ToastLength.Long).Show();
            }
            else
            {
                Toast.MakeText(this, "EMDK Manager is available", ToastLength.Long).Show();
            }

            // Get our button from the layout resource,
            // and attach an event to toggle scanning option
            Button scanButton = FindViewById <Button>(Resource.Id.btn_scan);

            scanButton.Click += delegate
            {
                var intent = new Intent();
                intent.SetAction(ACTION_SOFTSCANTRIGGER);
                intent.PutExtra(EXTRA_PARAM, DWAPI_TOGGLE_SCANNING);
                SendBroadcast(intent);
            };

            MyReceiver _broadcastReceiver = new MyReceiver();

            EditText editText = FindViewById <EditText>(Resource.Id.editbox);

            _broadcastReceiver.scanDataReceived += (s, scanData) =>
            {
                editText.Text = scanData;
            };

            // Register the broadcast receiver
            IntentFilter filter = new IntentFilter("barcodescanner.RECVR");

            filter.AddCategory("android.intent.category.DEFAULT");
            Application.Context.RegisterReceiver(_broadcastReceiver, filter);
        }
Beispiel #10
0
        public override IReceiver <T, L> Execute(System.Security.Principal.IPrincipal user)
        {
            if (!AllowExecute(user))
            {
                MyReceiver.Status = new ReceiverStatus
                {
                    CommandResponseCode = ResponseCodes.RESPONSE_UNAUTH
                };
                return(MyReceiver);
            }
            using (var session = Settings.OpenHbmSession)
            {
                try
                {
                    if (!MyReceiver.IsIdAssigned)
                    {
                        var crit = session.CreateCriteria(typeof(T));
                        crit.Add(MyReceiver.CustomSearch());
                        MyReceiver.Data = (T)crit.UniqueResult();
                    }
                    else
                    {
                        MyReceiver.Data = session.Get <T>(MyReceiver.DataId);
                    }

                    MyReceiver.Status = new ReceiverStatus
                    {
                        CommandResponseCode = ResponseCodes.RESPONSE_OK
                    };
                }
                catch (Exception ex)
                {
                    MyReceiver.Status = new ReceiverStatus
                    {
                        CommandResponseCode = ResponseCodes.RESPONSE_ERROR,
                        Error = ex
                    };
                }
            }
            return(MyReceiver);
        }
Beispiel #11
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            recever = new MyReceiver();
            var filter = new IntentFilter();

            filter.AddAction(MainApplication.UPDATE_STATUS_ACTION);
            RegisterReceiver(recever, filter);

            PushAgent pushAgent = PushAgent.GetInstance(this);

            pushAgent.OnAppStart();
            var id = pushAgent.RegistrationId;

            if (bundle == null)
            {
                InAppMessageManager.GetInstance(this).ShowCardMessage(this, "main", new MyUmengAppMsgCloseCallback());
            }
        }
Beispiel #12
0
        void Start()
        {
            playableGraph = PlayableGraph.Create("NotificationGraph");
            var output = ScriptPlayableOutput.Create(playableGraph, "NotificationOutput");

            //Create and register a receiver
            myReceiver = new MyReceiver();
            output.AddNotificationReceiver(myReceiver);

            //Create a TimeNotificationBehaviour
            var timeNotificationPlayable = ScriptPlayable <TimeNotificationBehaviour> .Create(playableGraph);

            output.SetSourcePlayable(timeNotificationPlayable);

            //Add a notification on the time notification behaviour
            var notificationBehaviour = timeNotificationPlayable.GetBehaviour();

            //notificationBehaviour.AddNotification(19.1, new NotificationMarker());
            notificationBehaviour.AddNotification(5.0, new MyNotification());

            playableGraph.Play();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            myReceiver = new MyReceiver {
                Context = this
            };
            ServiceConnection = new CustomServiceConnection {
                Activity = this
            };

            SetContentView(Resource.Layout.activity_main);

            // Check that the user hasn't revoked permissions by going to Settings.
            if (Utils.RequestingLocationUpdates(this))
            {
                if (!CheckPermissions())
                {
                    RequestPermissions();
                }
            }
        }
Beispiel #14
0
        public void NoCacheLookup()
        {
            MyReceiver myReceiver = new MyReceiver();

            using (MockHttpAndServiceBundle harness = CreateTestHarness(telemetryCallback: myReceiver.HandleTelemetryEvents))
            {
                TokenCache cache = new TokenCache(harness.ServiceBundle, false);

                MsalAccessTokenCacheItem atItem = new MsalAccessTokenCacheItem(
                    TestConstants.ProductionPrefNetworkEnvironment,
                    TestConstants.ClientId,
                    TestConstants.s_scope.AsSingleString(),
                    TestConstants.Utid,
                    null,
                    new DateTimeOffset(DateTime.UtcNow + TimeSpan.FromSeconds(3599)),
                    new DateTimeOffset(DateTime.UtcNow + TimeSpan.FromSeconds(7200)),
                    MockHelpers.CreateClientInfo());

                string atKey = atItem.GetKey().ToString();
                atItem.Secret = atKey;
                ((ITokenCacheInternal)cache).Accessor.SaveAccessToken(atItem);

                MockWebUI ui = new MockWebUI()
                {
                    MockResult = AuthorizationResult.FromUri(TestConstants.AuthorityHomeTenant + "?code=some-code")
                };

                MockInstanceDiscoveryAndOpenIdRequest(harness.HttpManager);

                harness.HttpManager.AddSuccessTokenResponseMockHandlerForPost(TestConstants.AuthorityHomeTenant);

                AuthenticationRequestParameters parameters = harness.CreateAuthenticationRequestParameters(
                    TestConstants.AuthorityHomeTenant,
                    TestConstants.s_scope,
                    cache,
                    extraQueryParameters: new Dictionary <string, string>
                {
                    { "extra", "qp" }
                });
                parameters.RedirectUri = new Uri("some://uri");
                parameters.LoginHint   = TestConstants.DisplayableId;
                AcquireTokenInteractiveParameters interactiveParameters = new AcquireTokenInteractiveParameters
                {
                    Prompt = Prompt.SelectAccount,
                    ExtraScopesToConsent = TestConstants.s_scopeForAnotherResource.ToArray(),
                };

                InteractiveRequest request = new InteractiveRequest(
                    harness.ServiceBundle,
                    parameters,
                    interactiveParameters,
                    ui);

                Task <AuthenticationResult> task = request.RunAsync(CancellationToken.None);
                task.Wait();
                AuthenticationResult result = task.Result;
                Assert.IsNotNull(result);
                Assert.AreEqual(1, ((ITokenCacheInternal)cache).Accessor.GetAllRefreshTokens().Count());
                Assert.AreEqual(2, ((ITokenCacheInternal)cache).Accessor.GetAllAccessTokens().Count());
                Assert.AreEqual(result.AccessToken, "some-access-token");

                Assert.IsNotNull(
                    myReceiver.EventsReceived.Find(
                        anEvent => // Expect finding such an event
                        anEvent[EventBase.EventNameKey].EndsWith("ui_event") &&
                        anEvent[UiEvent.UserCancelledKey] == "false"));
                Assert.IsNotNull(
                    myReceiver.EventsReceived.Find(
                        anEvent => // Expect finding such an event
                        anEvent[EventBase.EventNameKey].EndsWith("api_event") &&
                        anEvent[ApiEvent.PromptKey] == "select_account"));
                Assert.IsNotNull(
                    myReceiver.EventsReceived.Find(
                        anEvent => // Expect finding such an event
                        anEvent[EventBase.EventNameKey].EndsWith("ui_event") &&
                        anEvent[UiEvent.AccessDeniedKey] == "false"));
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            EMDKResults result = EMDKManager.GetEMDKManager(Application.Context, this);

            if (result.StatusCode != EMDKResults.STATUS_CODE.Success)
            {
                Toast.MakeText(this, "Error opening the EMDK Manager", ToastLength.Long).Show();
            }
            else
            {
                Toast.MakeText(this, "EMDK Manager is available", ToastLength.Long).Show();
            }

            // Get our button from the layout resource,
            // and attach an event to toggle scanning option
            Button scanButton = FindViewById<Button>(Resource.Id.btn_scan);

            scanButton.Click += delegate
            {
                var intent = new Intent();
                intent.SetAction(ACTION_SOFTSCANTRIGGER);
                intent.PutExtra(EXTRA_PARAM, DWAPI_TOGGLE_SCANNING);
                SendBroadcast(intent);
            };

            MyReceiver _broadcastReceiver = new MyReceiver();

            EditText editText = FindViewById<EditText>(Resource.Id.editbox);

            _broadcastReceiver.scanDataReceived += (s, scanData) =>
            {
                editText.Text = scanData;
            };

            // Register the broadcast receiver
            IntentFilter filter = new IntentFilter("barcodescanner.RECVR");
            filter.AddCategory("android.intent.category.DEFAULT");
            Application.Context.RegisterReceiver(_broadcastReceiver, filter);
        }
Beispiel #16
0
 public OpenCommand(MyReceiver receiver)
 {
     _receiver = receiver;
 }
Beispiel #17
0
 public SaveCommand(MyReceiver receiver, string text)
 {
     _receiver = receiver;
     Text      = text;
 }
Beispiel #18
0
        public void NewReceiverGetAChancewithCurrentItems2()
        {
            Port<int> p = new Port <int> ();
            var receiver = new MyReceiver ( Arbiter.FromHandler (() =>{}));
            receiver.State = ReceiverTaskState.Persistent;

            p.Post (10);
            p.Post (20);
            p.Post (30);

            IPortReceive pr = p;
            pr.RegisterReceiver (receiver);

            Assert.AreEqual (3, receiver.eval, "#1");
            Assert.AreEqual (0, p.ItemCount, "#2");
        }
Beispiel #19
0
        public void NewReceiverGetAChancewithCurrentItems4()
        {
            Port<int> p = new Port <int> ();
            var r0 = new MyReceiver (false, Arbiter.FromHandler (() =>{}));
            r0.State = ReceiverTaskState.Persistent;
            IPortReceive pr = p;
            pr.RegisterReceiver (r0);

            p.Post (10);
            p.Post (20);
            p.Post (30);

            Assert.AreEqual (3, p.ItemCount, "#1");

            var r1 = new MyReceiver (false, Arbiter.FromHandler (() =>{}));
            r1.State = ReceiverTaskState.Persistent;
            pr.RegisterReceiver (r1);

            Assert.AreEqual (3, r0.eval, "#2");
            Assert.AreEqual (3, r1.eval, "#3");
            Assert.AreEqual (3, p.ItemCount, "#4");
        }
Beispiel #20
0
        public void OptimizedSingleReissueReceiver()
        {
            Port<int> p = new Port <int> ();
            p.Mode = PortMode.OptimizedSingleReissueReceiver;
            var rec = new MyReceiver (Arbiter.FromHandler (() =>{}));
            rec.State = ReceiverTaskState.Persistent;

            ((IPortReceive)p).RegisterReceiver (rec);
            p.Post (10);
            Assert.AreEqual (0, rec.eval, "#1");
            Assert.AreEqual (1, rec.consume, "#2");
            Assert.AreEqual (0, p.ItemCount, "#3");
        }
Beispiel #21
0
 public PrintCommand(MyReceiver receiver)
 {
     _receiver = receiver;
 }
 public void CheckSomething()
 {
     MyReceiver.DoSomething();
 }