コード例 #1
0
ファイル: ReactiveTests.cs プロジェクト: WolfspiritM/Colore
        public void ShouldConstructWithCorrectParameters()
        {
            const Led Led = Led.Logo;
            const Duration Duration = Duration.Medium;
            var color = Color.Red;

            var effect = new Reactive(Led, Duration, color);

            Assert.AreEqual(Led, effect.Led);
            Assert.AreEqual(Duration, effect.Duration);
            Assert.AreEqual(color, effect.Color);
        }
コード例 #2
0
ファイル: Proactives.cs プロジェクト: Dextarius/Dexterity
        private static WeakReference <Proactive <int> > GenerateChainOfFactors(HashSet <WeakReference <Reactive <int> > > references)
        {
            Proactive <int> proactiveValue = new Proactive <int>(5);
            WeakReference <Proactive <int> > referenceToProactive = new WeakReference <Proactive <int> >(proactiveValue);
            Reactive <int> createdReactive  = CreateReactiveThatGetsValueOf(proactiveValue);
            int            triggerAReaction = createdReactive.Value;

            for (int i = 0; i < 3; i++)
            {
                createdReactive = CreateReactiveThatDependsOn(createdReactive);
                references.Add(new WeakReference <Reactive <int> >(createdReactive));
            }

            foreach (var reference in references)
            {
                reference.TryGetTarget(out var reactive);
                Assert.That(reactive, Is.Not.Null);
            }

            Assert.That(proactiveValue.IsConsequential);

            return(referenceToProactive);
        }
コード例 #3
0
        public void TestKey()
        {
            var reactiveList = new Dictionary <int, string> {
                { 1, "first" }, { 2, "second" }, { 3, "third" }, { 4, "fourth" }
            }.ToReactive();
            var countExpression = Reactive.Expression(() => reactiveList[2]);
            var counter         = 0;

            countExpression.Subscribe(getValue => ReactiveManagerTest.Const(getValue, () => counter++));
            var expectation = 1;

            reactiveList[2] = "fifth";
            Assert.AreEqual(++expectation, counter);
            reactiveList[1] = "sixth";
            Assert.AreEqual(expectation, counter);
            reactiveList[3] = "seventh";
            Assert.AreEqual(expectation, counter);
            reactiveList.Add(8, "eight");
            Assert.AreEqual(expectation, counter);
            reactiveList.Remove(8);
            Assert.AreEqual(expectation, counter);
            reactiveList.Remove(1);
            Assert.AreEqual(expectation, counter);
        }
コード例 #4
0
        public static void Process(States value, Controller controller)
        {
            if (controller.SharedState != null)
            {
                // If either state of the Autopilot switch is released
                if (Reactive.MultiSwitchStateOff(value, apahButton))
                {
                    controller.SharedState.ChangeMode(EliteSharedState.Mode.Travel);
                }

                if (Reactive.ButtonPressed(value, Button27))
                {
                    controller.SharedState.ChangeMode(EliteSharedState.Mode.Fighting);
                }

                if (Reactive.ButtonPressed(value, Button28))
                {
                    controller.SharedState.ChangeMode(EliteSharedState.Mode.Mining);
                }

                if (Reactive.ButtonPressed(value, Button01))
                {
                    controller.SharedState.ThrottleShift1 = true;
                }

                if (Reactive.ButtonReleased(value, Button01))
                {
                    controller.SharedState.ThrottleShift1 = false;
                }

                if (Reactive.ButtonReleased(value, Button15))
                {
                    controller.SharedState.ThrottleShift2 = true;
                }
            }
        }
コード例 #5
0
 public static Reactive <T> CreateReactiveThatGetsValueOf <T>(Reactive <T> reactiveSourceValue) => new Reactive <T>(() => reactiveSourceValue.Value);
コード例 #6
0
 public void Set(Reactive effect)
 {
     SetReactive(effect);
 }
コード例 #7
0
ファイル: ReactiveSpecs.cs プロジェクト: shishkin/Stimpack
        public void Can_unsubscribe_from_source()
        {
            var reactive = new Reactive<int>();
            reactive.Subscribe(observer);

            using (reactive.SubscribeTo(source))
            {
                source.OnNext(5);
            }

            source.OnNext(10);

            observedValues.ShouldBe(new[] { 5 });
        }
コード例 #8
0
 private void ReactToChanges(Reactive <float> reactive)
 {
     TriggerComponentUpdated(this);
 }
コード例 #9
0
ファイル: NativeWrapper.cs プロジェクト: DeadlyEmbrace/Colore
 /// <summary>
 /// Creates a reactive effect for the keyboard.
 /// </summary>
 /// <param name="effect">Effect options.</param>
 /// <returns>A <see cref="Guid" /> for the created effect.</returns>
 internal static Guid CreateKeyboardEffect(Reactive effect)
 {
     return(CreateKeyboardEffect(Razer.Keyboard.Effects.Effect.Reactive, effect));
 }
コード例 #10
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         CustomList <HRM_Emp> lstEmp      = (CustomList <HRM_Emp>)_EmpList;
         CustomList <HRM_Emp> CheckedList = lstEmp.FindAll(f => f.IsChecked);
         if (ddlApprovalList.SelectedValue == "1")
         {
             foreach (HRM_Emp emp in CheckedList)
             {
                 emp.EmpStatus = "Active";
                 emp.SetModified();
             }
             CheckedList.UpdateSpName = "spNewEmpApproval";
             if (CheckedList.IsNotNull())
             {
                 if (!CheckUserAuthentication(CheckedList))
                 {
                     return;
                 }
                 manager.SaveEmpApproval(ref CheckedList);
                 this.SuccessMessage = (StaticInfo.SavedSuccessfullyMsg);
             }
         }
         else if (ddlApprovalList.SelectedValue == "3")
         {
             CustomList <SeparationGrid> SeparationApprovedList = new CustomList <SeparationGrid>();
             foreach (HRM_Emp emp in CheckedList)
             {
                 SeparationGrid newSeparation = new SeparationGrid();
                 newSeparation.EmployeeKey  = emp.EmpKey;
                 newSeparation.ApprovedBy   = CurrentUserSession.EmpKey.ToString();
                 newSeparation.ApprovedDate = DateTime.Now;
                 newSeparation.SetModified();
                 SeparationApprovedList.Add(newSeparation);
             }
             SeparationApprovedList.UpdateSpName = "spEmpSeparationApproval";
             if (!CheckUserAuthentication(SeparationApprovedList))
             {
                 return;
             }
             manager.SaveEmpSeparationApproval(ref SeparationApprovedList);
             this.SuccessMessage = (StaticInfo.SavedSuccessfullyMsg);
         }
         else if (ddlApprovalList.SelectedValue == "2")
         {
             CustomList <Reactive> ReactiveList = new CustomList <Reactive>();
             foreach (HRM_Emp emp in CheckedList)
             {
                 Reactive newReactive = new Reactive();
                 newReactive.EmpKey = emp.EmpKey;
                 newReactive.DOJ    = emp.DOJ;
                 emp.DOJ            = emp.RejoiningDate;
                 emp.SetModified();
                 ReactiveList.Add(newReactive);
             }
             CheckedList.UpdateSpName  = "spSeparatedEmpRejoining";
             ReactiveList.InsertSpName = "spInsertReactive";
             if (CheckedList.IsNotNull())
             {
                 if (!CheckUserAuthentication(CheckedList, ReactiveList))
                 {
                     return;
                 }
                 manager.SaveEmpReActive(ref CheckedList, ref ReactiveList);
                 this.SuccessMessage = (StaticInfo.SavedSuccessfullyMsg);
             }
         }
     }
     catch (SqlException ex)
     {
         this.ErrorMessage = (ExceptionHelper.getSqlExceptionMessage(ex));
     }
     catch (Exception ex)
     {
         this.ErrorMessage = (ExceptionHelper.getExceptionMessage(ex));
     }
 }
コード例 #11
0
 /// <summary>
 /// Sets a reactive effect on the mouse.
 /// </summary>
 /// <param name="effect">Effect options struct.</param>
 public void SetReactive(Reactive effect)
 {
     SetGuid(NativeWrapper.CreateMouseEffect(effect));
 }
コード例 #12
0
ファイル: Reactives.cs プロジェクト: Dextarius/Dexterity
        public void AfterConstruction_IsNotUpdating()
        {
            Reactive <int> reactiveToTest = new Reactive <int>(Return42);

            Assert.That(reactiveToTest.IsUpdating, Is.False, $"The property {nameof(reactiveToTest.IsUpdating)} was marked as true during construction.");
        }
コード例 #13
0
ファイル: Reactives.cs プロジェクト: Dextarius/Dexterity
        public void Constructor_WhenGivenNullName_UsesADefault()
        {
            Reactive <int> testReactive = new Reactive <int>(Return42, null);

            Assert.NotNull(testReactive.Name);
        }
コード例 #14
0
        public static void NormalProcess(States value, Controller controller)
        {
            // Volume 1 Base Up
            if (Reactive.ButtonPressed(value, (uint)BBI32Button.Button23))
            {
                EliteDangerousGain += (float)1.0;
                VoiceMeeter.Remote.SetParameter(EliteDangerous, EliteDangerousGain);
            }

            // Volume 1 Base Down
            if (Reactive.ButtonPressed(value, (uint)BBI32Button.Button24))
            {
                EliteDangerousGain -= (float)1.0;
                VoiceMeeter.Remote.SetParameter(EliteDangerous, EliteDangerousGain);
            }

            // Volume 1 Tip Up
            if (Reactive.ButtonPressed(value, (uint)BBI32Button.Button26))
            {
                VoiceAttackGain += (float)1.0;
                VoiceMeeter.Remote.SetParameter(VoiceAttack, VoiceAttackGain);
            }

            // Volume 1 Tip Down
            if (Reactive.ButtonPressed(value, (uint)BBI32Button.Button25))
            {
                VoiceAttackGain -= (float)1.0;
                VoiceMeeter.Remote.SetParameter(VoiceAttack, VoiceAttackGain);
            }

            // Volume 2 Base Up
            if (Reactive.ButtonPressed(value, (uint)BBI32Button.Button20))
            {
                SpotifyGain += (float)1.0;
                VoiceMeeter.Remote.SetParameter(Spotify, SpotifyGain);
            }

            // Volume 2 Base Down
            if (Reactive.ButtonPressed(value, (uint)BBI32Button.Button19))
            {
                SpotifyGain -= (float)1.0;
                VoiceMeeter.Remote.SetParameter(Spotify, SpotifyGain);
            }

            // Volume 2 Tip Up
            if (Reactive.ButtonPressed(value, (uint)BBI32Button.Button17))
            {
                DiscordGain += (float)1.0;
                VoiceMeeter.Remote.SetParameter(Discord, DiscordGain);
            }

            // Volume 2 Tip Down
            if (Reactive.ButtonPressed(value, (uint)BBI32Button.Button18))
            {
                DiscordGain -= (float)1.0;
                VoiceMeeter.Remote.SetParameter(Discord, DiscordGain);
            }

            // Volume 2 Button  Spotify Play/Pause
            if (Reactive.ButtonPressed(value, (uint)BBI32Button.Button21))
            {
                // Launch if not running
                if (Utils.ProcessRunning("Spotify"))
                {
                    Utils.SendVKeyToProcess("Spotify", MediaPlayPause);
                }
                else
                {
                    Utils.Launch("spotify:");
                }
            }

            // Volume 1 Button  Restart Audio Engine
            if (Reactive.ButtonPressed(value, (uint)BBI32Button.Button22))
            {
                VoiceMeeter.Remote.Restart();
            }
        }
コード例 #15
0
 public PreviewVenueView(Reactive <Core.Editor.Venue.Json.Venue> reactiveCurrentVenue)
 {
     this.reactiveCurrentVenue = reactiveCurrentVenue;
 }
コード例 #16
0
 /// <summary>
 /// Sets a reactive effect on the keyboard.
 /// </summary>
 /// <param name="effect">Effect options.</param>
 public void SetReactive(Reactive effect)
 {
     SetGuid(NativeWrapper.CreateKeyboardEffect(Effect.Reactive, effect));
 }
コード例 #17
0
 public ReactiveManipulator(T valueToUse)
 {
     linkedProactive = new Proactive <T>(valueToUse);
     Reactive        = new Reactive <T>(WaitAndReturnSourceValue);
 }
コード例 #18
0
ファイル: Keyboard.cs プロジェクト: danm-de/DrunkenOctoNinja
 /// <summary>
 ///     Sets a reactive effect on the keyboard.
 /// </summary>
 /// <param name="effect">Effect options.</param>
 public void Set(Reactive effect)
 {
     Set(NativeWrapper.CreateKeyboardEffect(effect));
 }
コード例 #19
0
ファイル: GenericDevice.cs プロジェクト: d8ahazard/Colore
 /// <summary>
 /// Sets a reactive effect on this device.
 /// </summary>
 /// <param name="effect">Effect options.</param>
 public void SetReactive(Reactive effect)
 {
     SetGuid(NativeWrapper.CreateDeviceEffect(DeviceId, Effect.Reactive, effect));
 }
コード例 #20
0
        private void OnEnable()
        {
            fsmShapeSelection = new FSM <ShapeSelectionState>(FSM.TransitionModeEnum.Immediate);
            fig = new GLFigure();
            guiSelectedShape    = new TextInt(gui.selectedShape);
            guiSelectedVertices = new TextInt(gui.selectedVertices);
            rctVisTarget        = new Reactive <VisTargetEnum>();

            SetMapper(new Mapper());

            fig.DefaultLineMat.ZTestMode = GLMaterial.ZTestEnum.ALWAYS;
            guiSelectedShape.Changed    += r => {
                validator.Invalidate();
                gui.selectedShape = r.Value;
            };
            guiSelectedVertices.Changed += r => {
                validator.Invalidate();
                gui.selectedVertices = r.Value;
            };
            rctVisTarget.Changed += r => {
                mapper.CurrFlags = r.Value == VisTargetEnum.Input ?
                                   (mapper.CurrFlags | Mapper.OutputFlags.InputVertex) :
                                   (mapper.CurrFlags & ~Mapper.OutputFlags.InputVertex);
            };

            validator.Reset();
            validator.Validation += () => {
                if (mapper == null)
                {
                    validator.Invalidate();
                    return;
                }
                mapper.Clear();
                foreach (var q in data.shapes.quads)
                {
                    mapper.Add(q);
                }
            };

            fsmShapeSelection.StateFor(ShapeSelectionState.None).Update(f => {
                if (0 <= gui.selectedShape && gui.selectedShape < data.shapes.Count)
                {
                    f.Goto(ShapeSelectionState.Selected);
                    return;
                }
            });
            fsmShapeSelection.StateFor(ShapeSelectionState.Selected).Update(f => {
                if (gui.selectedShape < 0 || data.shapes.Count <= gui.selectedShape)
                {
                    f.Goto(ShapeSelectionState.None);
                    return;
                }
            });
            fsmShapeSelection.Init(ShapeSelectionState.None);

            mouse.OnSelection += (m, arg) => {
                if ((arg & MouseTracker.ButtonFlag.Left) == 0)
                {
                    return;
                }

                var s2n = CoordConverter.ScreenToNDC;
                var dx  = (Vector2)s2n.MultiplyVector(m.PositionDiff);

                var shape = GetSelectedShape();
                if (shape != null)
                {
                    var vertices = GetVertices(shape);
                    for (var i = 0; i < vertices.Count; i++)
                    {
                        if ((gui.selectedVertices & (1 << i)) == 0)
                        {
                            continue;
                        }
                        var v = vertices[i];
                        v.x        += dx.x;
                        v.y        += dx.y;
                        vertices[i] = v;
                    }
                    shape.Invalidate();
                }
            };

            Load();
        }