Exemplo n.º 1
0
        public void EnteringSetsIsBusyToTrue()
        {
            var busyState = new BusyState();

            busyState.Enter();
            Assert.IsTrue(busyState.IsBusy);
        }
Exemplo n.º 2
0
 public override async void OnNavigatedTo(INavigationContext context)
 {
     if (!context.Attribute.IsRestore())
     {
         await Navigator.PostActionAsync(() => BusyState.Using(InitializeAsync));
     }
 }
        /// <summary>
        /// busy scope
        /// </summary>
        /// <returns>
        /// returns an i disposable busy state scope
        /// </returns>
        public IScopeBusyState BusyScope(BusyState returnState)
        {
            IsAlreadyRunning
            .AsGuard <OperationCanceledException, CommonLocalised>(CommonLocalised.OnlyOneRunningCopyAllowed);

            return(new BusyStateScope(Mediator, StateMessage, returnState));
        }
    /// <summary>
    /// Disables other actions until this processingAction has been completed
    /// </summary>
    /// <param name="duration"></param>
    /// <returns></returns>
    protected virtual IEnumerator processAction(BusyState busyState, float duration)
    {
        _currentBusyState = busyState;
        yield return(new WaitForSeconds(duration));

        _currentBusyState = BusyState.NONE;
    }
Exemplo n.º 5
0
        public void ExitingSetsIsBusyToFalseAgain()
        {
            var busyState = new BusyState();

            busyState.Enter();
            busyState.Exit();
            Assert.IsFalse(busyState.IsBusy);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BusyStateScope"/> class.
        /// </summary>
        /// <param name="mediator">The mediator.</param>
        /// <param name="stateMessage">The state message.</param>
        public BusyStateScope(IManageEventPublication mediator, ICreateApplicationStateMessages stateMessage, BusyState returnState = BusyState.IsIdle)
        {
            Mediator     = mediator;
            StateMessage = stateMessage;
            ReturnState  = returnState;

            Mediator.Publish(StateMessage.Create(BusyState.IsBusy));
        }
    /// <summary>
    /// Disables other actions until the skill has been completed
    /// </summary>
    /// <param name="skill"></param>
    /// <returns></returns>
    protected virtual IEnumerator processAction(Skill skill, BusyState busyState)
    {
        skill.OnSkillStart(this);
        _currentBusyState = busyState;
        yield return(new WaitForSeconds(skill.Duration));

        skill.OnSkillEnd(this);
        _currentBusyState = BusyState.NONE;
    }
        /// <summary>
        /// Constructor.
        /// </summary>
        protected AbstractClientSocket
        (
            [NotNull] IIrbisConnection connection
        )
        {
            Sure.NotNull(connection, nameof(connection));

            Connection = connection;
            Busy       = new BusyState(false);
        }
Exemplo n.º 9
0
        public void CanUseUsingBlock()
        {
            var busyState = new BusyState();

            using (busyState.Enter())
            {
                Assert.IsTrue(busyState.IsBusy);
            }
            Assert.IsFalse(busyState.IsBusy);
        }
Exemplo n.º 10
0
 protected IDisposable Busy()
 {
     return(BusyState.Begin(delegate
     {
         isBusy = true;
     },
                            delegate
     {
         isBusy = false;
     }));
 }
        public BusyContainerAdvancedViewModel()
        {
            ResetContentCommand = new RelayUICommand(() => Content = null, () => Content != null)
            {
                Title = "Reset"
            };

            ContentControlCommands = new[]
            {
                ResetContentCommand,
                new RelayUICommand(() => Content = new CustomState())
                {
                    Title = "Mutable title"
                },
                new RelayUICommand(() => Content = new StateWithMutableDescription())
                {
                    Title = "Mutable description"
                },
                new RelayUICommand(() => Content = new StateWithToStringOverride())
                {
                    Title = "ToString override"
                },
                new RelayUICommand(() => Content = new BusyState
                {
                    Title       = "Built in type",
                    Description = "Some description"
                })
                {
                    Title = "Built in"
                }
            };

            SetContentStateWithMutableTitleCommand = new RelayUICommand(() => Content = new CustomState())
            {
                Title = "Mutable title"
            };
            SetContentStateWithMutableDescriptionCommand = new RelayUICommand(() => Content = new StateWithMutableDescription())
            {
                Title = "Mutable description"
            };
            SetContentStateWithToStringOverrideCommand = new RelayUICommand(() => Content = new StateWithToStringOverride())
            {
                Title = "ToString override"
            };
            SetContentBuiltInBusyStateCommand = new RelayUICommand(() => Content = new BusyState
            {
                Title       = "Built in type",
                Description = "Some description"
            })
            {
                Title = "Built in"
            };
        }
Exemplo n.º 12
0
 public void NoteOff()
 {
     if (busy == BusyState.BUSY)
     {
         busy = BusyState.RELEASED;
     }
     for (byte i = 0; i < ops.Length; i++)
     {
         var op = ops[i] as Operator;
         op?.NoteOff();
     }
 }
Exemplo n.º 13
0
        public void DoesntGetItsKnickersInATwistWhenExitingTooManyTimes()
        {
            var busyState = new BusyState();

            busyState.Exit();
            busyState.Exit();
            busyState.Exit();
            Assert.IsFalse(busyState.IsBusy);

            busyState.Enter();
            Assert.IsTrue(busyState.IsBusy);
        }
 public override async void OnNavigatedTo(INavigationContext context)
 {
     if (!context.Attribute.IsRestore())
     {
         await Navigator.PostActionAsync(() => BusyState.Using(async() =>
         {
             if (await dialogs.Confirm("Cancel ?", acceptButton: "Yes", cancelButton: "No"))
             {
                 await Navigator.ForwardAsync(ViewId.Menu);
             }
         }));
     }
 }
Exemplo n.º 15
0
        public void MustCallExitSameNumberOfTimesAsEnter()
        {
            var busyState = new BusyState();

            busyState.Enter();
            busyState.Enter();
            busyState.Enter();
            busyState.Exit();
            Assert.IsTrue(busyState.IsBusy);
            busyState.Exit();
            Assert.IsTrue(busyState.IsBusy);
            busyState.Exit();
            Assert.IsFalse(busyState.IsBusy);
        }
Exemplo n.º 16
0
 IDisposable Busy()
 {
     return(BusyState.Begin(delegate
     {
         isBusy = true;
         pgBusy.Visibility = ViewStates.Visible;
         btnReset.Enabled = false;
     },
                            delegate
     {
         pgBusy.Visibility = ViewStates.Gone;
         UpdateResetButtonState();
         isBusy = false;
     }));
 }
Exemplo n.º 17
0
 IDisposable Busy()
 {
     return(BusyState.Begin(delegate
     {
         isBusy = true;
         pgbBusy.Visibility = ViewStates.Visible;
         tbConfirmCode.Enabled = false;
         btnConfirm.Enabled = false;
     }, delegate
     {
         isBusy = false;
         pgbBusy.Visibility = ViewStates.Gone;
         tbConfirmCode.Enabled = true;
         btnConfirm.Enabled = true;
     }));
 }
Exemplo n.º 18
0
        private void Busy_StateChanged
        (
            object sender,
            EventArgs e
        )
        {
            BusyState state = (BusyState)sender;

            this.InvokeIfRequired
            (
                () =>
            {
                _busyStripe.Visible = state;
                _busyStripe.Moving  = state;
            }
            );
        }
Exemplo n.º 19
0
        protected IDisposable Busy(bool indicator = true)
        {
            return(BusyState.Begin(delegate
            {
                isBusy = true;

                if (indicator)
                {
                    swipeRefreshLayout.Refreshing = true;
                }
            },
                                   delegate
            {
                isBusy = false;
                swipeRefreshLayout.Refreshing = false;
            }));
        }
Exemplo n.º 20
0
        public void RaisesPropertyChangedOnIsBusyChanged()
        {
            var changes = new Queue <string>();

            var busyState = new BusyState();

            busyState.PropertyChanged += (x, e) => changes.Enqueue(e.PropertyName);

            busyState.Enter();
            Assert.AreEqual("IsBusy", changes.Dequeue());
            busyState.Enter();
            Assert.AreEqual(0, changes.Count);

            busyState.Exit();
            Assert.AreEqual(0, changes.Count);
            busyState.Exit();
            Assert.AreEqual("IsBusy", changes.Dequeue());

            Assert.AreEqual(0, changes.Count);
        }
Exemplo n.º 21
0
        protected IDisposable Busy(bool indicator = true)
        {
            return(BusyState.Begin(() =>
            {
                isBusy = true;

                if (indicator && swipeRefreshLayout != null)
                {
                    swipeRefreshLayout.Refreshing = true;
                }
            },
                                   () =>
            {
                isBusy = false;

                if (indicator && swipeRefreshLayout != null)
                {
                    swipeRefreshLayout.Refreshing = false;
                }
            }));
        }
Exemplo n.º 22
0
        private void UpdateProgress()
        {
            if (_progress == null)
            {
                return;
            }

            BusyState busyState = BusyState;

            if (busyState != null && busyState != BusyState.Idle)
            {
                if (busyState.MaxProgressValue == 0)
                {
                    _progress.IsIndeterminate = true;
                }
                else
                {
                    _progress.Maximum         = busyState.MaxProgressValue;
                    _progress.Value           = busyState.ProgressValue;
                    _progress.IsIndeterminate = false;
                }

                if (string.IsNullOrWhiteSpace(busyState.Message))
                {
                    _message.Visibility = Visibility.Collapsed;
                }
                else
                {
                    _message.Text       = busyState.Message;
                    _message.Visibility = Visibility.Visible;
                }

                _popup.IsOpen = true;
            }
            else
            {
                _popup.IsOpen = false;
            }
        }
Exemplo n.º 23
0
        ////// RECALCULATES THE PRIORITY SCORE
        public short CalcPriorityScore()
        {
            int score = (int)256 - (Math.Abs(lastSample >> 6)); //0-127 -- simple volume value;
            // int score=0;

            //Check busy state for free.
            bool setFree = true;

            for (byte i = 0; i < ops.Length; i++)
            {
                //        Skip over Filter ops when adding egStatus entirely and instead if an operator is connected to a filter,
                //        Determine if the filter's connected to output, and only then process op as if directly connected to output.
                if (!voice.OpReachesOutput(i) || voice.egs[i].mute)
                {
                    continue;                                                   //Skip over connections not connected to output.
                }
                var op = ops[i];
                if (busy == BusyState.BUSY ||
                    (busy == BusyState.RELEASED && (op.egStatus != EGStatus.INACTIVE)))
                {
                    setFree = false;     //Found an active channel.  Don't set our busy state to FREE.
                }
                //Status of the envelope is such that the further along in the envelope it is, the higher the score.
                //Lsh ensures that the value is always positive -- Delay is considered same priority as Decay, Hold the same as Sustained
                score  += (int)op.egStatus << 4;
                score >>= 1;  //Compensate for multiple operators connected to output.
            }
            if (setFree)
            {
                busy = BusyState.FREE;
            }
            score += (int)busy;   //512 points if BusyState.Released;  1024 if free.

            lastPriorityScore = (short)score;
            return(lastPriorityScore);
        }
Exemplo n.º 24
0
        public AdminHomePage()
        {
            OnLoaded += (s, rootFrame) =>
            {
                lbTotalMoney        = rootFrame.FindViewById <TextView>(Resource.Id.lb_total_money);
                lbMoneyToday        = rootFrame.FindViewById <TextView>(Resource.Id.lb_money_today);
                lbMoneyYesterday    = rootFrame.FindViewById <TextView>(Resource.Id.lb_money_yesterday);
                lbMoneyWeek         = rootFrame.FindViewById <TextView>(Resource.Id.lb_money_week);
                lbReservationsToday = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_today);

                lbReservationsYesterday = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_yesterday);
                lbReservationsWeek      = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_week);
                lbReservationsTotal     = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_total);
                lbReservationsActive    = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_active);
                lbReservationsPending   = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_pending);
                lbReservationsUsed      = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_used);

                //
                lbRoutesTotal = rootFrame.FindViewById <TextView>(Resource.Id.lb_routes_total);

                //
                lbBusesTotal             = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_total);
                lbBusesActive            = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_active);
                lbBusesIdle              = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_idle);
                lbBusesCompleteToday     = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_complete_today);
                lbBusesCompleteYesterday = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_complete_yesterday);
                lbBusesCompleteWeek      = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_complete_week);

                //
                lbBusesActiveToday     = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_active_today);
                lbBusesActiveYesterday = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_active_yesterday);
                lbBusesActiveWeek      = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_active_week);
                lbBusesIdleToday       = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_idle_today);
                lbBusesIdleYesterday   = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_idle_yesterday);
                lbBusesIdleWeek        = rootFrame.FindViewById <TextView>(Resource.Id.lb_buses_idle_week);

                //
                lbUsersTotal               = rootFrame.FindViewById <TextView>(Resource.Id.lb_users_total);
                lbUsersRegisteredToday     = rootFrame.FindViewById <TextView>(Resource.Id.lb_users_registered_today);
                lbUsersRegisteredWeek      = rootFrame.FindViewById <TextView>(Resource.Id.lb_users_registered_week);
                lbUsersRegisteredMonth     = rootFrame.FindViewById <TextView>(Resource.Id.lb_users_registered_month);
                lbUsersRegisteredYesterday = rootFrame.FindViewById <TextView>(Resource.Id.lb_users_registered_yesterday);
                lbUsersPendingActivation   = rootFrame.FindViewById <TextView>(Resource.Id.lb_users_pending_activation);

                //
                swipeRefreshLayout = rootFrame.FindViewById <SwipeRefreshLayout>(Resource.Id.swipe_refresh_root);
                swipeRefreshLayout.SetColorSchemeColors(AvatarDisplay.DefaultColors.Take(4).Select(t => t.ToArgb()).ToArray());
                swipeRefreshLayout.Refresh += async delegate
                {
                    if (isBusy)
                    {
                        return;
                    }

                    using (BusyState.Begin(() => updateTimer.Stop(), () => updateTimer.Start()))
                        using (Busy())
                        {
                            await LoadDashboardValues();
                        }
                };

                updateTimer.Elapsed += delegate
                {
                    if (isBusy)
                    {
                        return;
                    }

                    if (!IsActivePage)
                    {
                        updateTimer.Stop();
                        return;
                    }

                    Activity.RunOnUiThread(async delegate
                    {
                        using (Busy(false))
                        {
                            await LoadDashboardValues(true);
                        }
                    });
                };

                //
                dashboard = new AdminDashboardModel()
                {
                    Buses        = new AdminDashboardModel.BusSpec(),
                    Money        = new AdminDashboardModel.MoneySpec <double>(),
                    Reservations = new AdminDashboardModel.ReservationSpec <long>(),
                    Routes       = new AdminDashboardModel.RoutesSpec(),
                    Users        = new AdminDashboardModel.UsersSpec()
                };

                BindDashboardValues();
            };
        }
Exemplo n.º 25
0
        public void WhenInitializedIsNotBusy()
        {
            var busyState = new BusyState();

            Assert.IsFalse(busyState.IsBusy);
        }
 /// <summary>
 /// Creates the specified change state message.
 /// </summary>
 /// <param name="newState">The new state.</param>
 /// <returns>a new state message</returns>
 public ICarryChangeStateMessage Create(BusyState newState)
 {
     return(new ChangeStateMessage {
         Payload = newState
     });
 }
Exemplo n.º 27
0
        /// <summary>
        /// Opens a project from a <see cref="Filename">file</see>.
        /// </summary>
        /// <param name="parameter">ignored</param>
        /// <exception cref="Exception">When exception occurs, new project is created and exception is rethrown.</exception>
        public override void Execute(object parameter)
        {
            OpenFileDialog dlg = new OpenFileDialog
            {
                DefaultExt = ".XCase",
                Filter     = "XCase files (*.XCase)|*.XCase|XML files (*.xml)|*.xml|All files (*.*)|*.*||"
            };

            bool?result = null;

            if (!NoDialogs && !NoOpenFileDialog)
            {
                result = dlg.ShowDialog();
            }
            else
            {
                dlg.FileName = Filename;
            }

            if (NoDialogs || NoOpenFileDialog || result == true)
            {
                String msg = string.Empty;

                XmlDeserializatorBase deserializator;
                if (XmlDeserializatorVersions.UsesVersions(dlg.FileName))
                {
                    deserializator = new XmlDeserializatorVersions();
                }
                else
                {
                    deserializator = new XmlDeserializator();
                }

                // First, validates if the file is a valid XCase XML file
                // TODO: it would be better to have two separate schemas rather than one choice schema
                if (!deserializator.ValidateXML(dlg.FileName, ref msg))
                {
                    Dialogs.ErrMsgBox.Show("File cannot be opened", "Not a valid XCase XML file");
                    return;
                }

                // version check
                string v1;
                string v2;
                if (!XmlDeserializatorBase.VersionsEqual(dlg.FileName, out v1, out v2))
                {
                    fProjectConverter projectConverter = new fProjectConverter();

                    if (projectConverter.CanConvert(v1, v2))
                    {
                        MessageBoxResult yn = XCaseYesNoBox.Show("Project is obsolete. ", "Project is obsolete and must be converted to a new version before opening. \r\nDo you want to convert it now? ");
                        if (yn == MessageBoxResult.Yes)
                        {
                            projectConverter.SetFile(dlg.FileName);
                            projectConverter.DialogMode = true;
                            projectConverter.ShowDialog();
                        }
                    }
                    else
                    {
                        Dialogs.ErrMsgBox.Show(string.Format("Can not open file {0}. Project version is {1}, needed version is {2}.", dlg.FileName, v1, v2), "");
                    }
                    if (!XmlDeserializatorBase.VersionsEqual(dlg.FileName, out v1, out v2))
                    {
                        Dialogs.ErrMsgBox.Show(string.Format("Can not open file {0}. Project version is {1}, needed version is {2}. \r\nUse project converter to convert the file to new version.", dlg.FileName, v1, v2), "");
                        return;
                    }
                }

                // Closes existing project
                if (CurrentProject != null)
                {
                    // Save existing project if there are some unsaved changes
                    if (MainWindow.HasUnsavedChanges && !NoDialogs)
                    {
                        MessageBoxResult r =
                            XCaseYesNoBox.Show("Current project is not saved", "Do you want to save it?");

                        if (r == MessageBoxResult.Yes)
                        {
                            new cmdSaveProject(MainWindow, null).Execute();
                        }
                        else
                        if (r == MessageBoxResult.Cancel)
                        {
                            return;
                        }
                    }

                    //new cmdCloseProject(MainWindow, null).Execute();
                    MainWindow.CloseProject();
                }
                //try
                {
                    BusyState.SetBusy();

                    if (deserializator is XmlDeserializator)
                    {
                        Project p = deserializator.RestoreProject(dlg.FileName);
                        p.FilePath = dlg.FileName;
                        p.CreateModelController();
                        // HACK (SEVERE) - this should be somewhere else ...
                        p.GetModelController().getUndoStack().ItemsChanged += MainWindow.UndoStack_ItemsChanged;
                        MainWindow.CurrentProject    = p;
                        MainWindow.Title             = "XCase editor - " + p.FilePath;
                        MainWindow.HasUnsavedChanges = false;


                        //It is this way so that when the CurrentProject is set, ModelController is present
                        MainWindow.projectsWindow.BindToProject(CurrentProject);
                        MainWindow.navigatorWindow.BindToProject(CurrentProject);
                        MainWindow.propertiesWindow.BindDiagram(ref MainWindow.dockManager);
                        MainWindow.InitializeMainMenu();
                        MainWindow.HasUnsavedChanges = false;
                        MainWindow.OpenProjectDiagrams();
                    }
                    else
                    {
                        VersionManager versionManager = ((XmlDeserializatorVersions)deserializator).RestoreVersionedProject(dlg.FileName);
                        versionManager.FilePath = dlg.FileName;
                        foreach (Project project in versionManager.VersionedProjects.Values)
                        {
                            project.FilePath = dlg.FileName;
                            project.CreateModelController();
                        }
                        MainWindow.projectsWindow.BindToVersionManager(versionManager);
                        Project latestProjectVersion = versionManager.LatestVersion;
                        MainWindow.projectsWindow.SwitchToVersion(latestProjectVersion.Version);
                        MainWindow.navigatorWindow.BindToProject(latestProjectVersion);
                        MainWindow.InitializeMainMenu();
                        MainWindow.OpenProjectDiagrams();
                        MainWindow.HasUnsavedChanges = false;
                        MainWindow.Title             = "XCase editor - " + versionManager.FilePath;

                        #if DEBUG
                        foreach (KeyValuePair <Version, Project> kvp in versionManager.VersionedProjects)
                        {
                            Tests.ModelIntegrity.ModelConsistency.CheckEverything(kvp.Value);
                        }
                        Tests.ModelIntegrity.VersionsConsistency.CheckVersionsConsistency(versionManager);
                        #endif
                    }
                }
                //catch
                //{
                //    new cmdNewProject(MainWindow, null).Execute();
                //    throw;
                //}
                //finally
                //{
                //    BusyState.SetNormalState();
                //}
            }
        }
Exemplo n.º 28
0
        public UserHomePage()
        {
            OnLoaded += (s, rootFrame) =>
            {
                //  Reservations section
                lbReservationsToday     = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_today);
                lbReservationsYesterday = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_yesterday);
                lbReservationsWeek      = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_week);
                lbReservationsUsed      = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_used);
                lbReservationsActive    = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_active);
                lbReservationsPending   = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_pending);
                lbReservationsTotal     = rootFrame.FindViewById <TextView>(Resource.Id.lb_reservations_total);

                //  Money section
                lbMoneyTotal     = rootFrame.FindViewById <TextView>(Resource.Id.lb_money_total_value);
                lbMoneyToday     = rootFrame.FindViewById <TextView>(Resource.Id.lb_money_today);
                lbMoneyYesterday = rootFrame.FindViewById <TextView>(Resource.Id.lb_money_yesterday);
                lbMoneyRefunded  = rootFrame.FindViewById <TextView>(Resource.Id.lb_money_refunded);

                //
                swipeRefreshLayout = rootFrame.FindViewById <SwipeRefreshLayout>(Resource.Id.swipe_refresh_root);
                swipeRefreshLayout.SetColorSchemeColors(Views.AvatarDisplay.DefaultColors.Take(4).Select(x => x.ToArgb()).ToArray());

                swipeRefreshLayout.Refresh += async delegate
                {
                    if (isBusy)
                    {
                        return;
                    }

                    using (BusyState.Begin(() => updateTimer.Stop(), () => updateTimer.Start()))
                        using (Busy())
                        {
                            await LoadStatistics();
                        }
                };

                rootFrame.FindViewById <Button>(Resource.Id.btn_book_reservation).Click += delegate
                {
                    StartActivityForResult(new Intent(Activity, typeof(CreateReservationActivity)), CreateReservationLayout);
                };


                updateTimer.Elapsed += delegate
                {
                    if (isBusy)
                    {
                        return;
                    }

                    if (!IsActivePage)
                    {
                        updateTimer.Stop();
                        return;
                    }

                    Activity.RunOnUiThread(async delegate
                    {
                        using (Busy(false))
                            await LoadStatistics(true);
                    });
                };

                dashboardModel = new UserDashboardModel()
                {
                    Money        = new UserDashboardModel.MoneySpec <double>(),
                    Reservations = new UserDashboardModel.ReservationSpec <long>()
                };

                BindDashboardValues();
            };
        }
Exemplo n.º 29
0
        //Generates a Note on this channel by setting new properties from a Voice.
        public void NoteOn(byte midi_note = Global.NO_NOTE_SPECIFIED, byte velocity = 127)
        {
            eventID = Global.NewEventID();
            if (midi_note >= 0x80)
            {
                return;                      //Invalid note
            }
            this.midi_note    = midi_note;
            this.lastVelocity = velocity;

            var opsToProcess = (byte)Math.Min(voice.alg.opCount, ops.Length); //Prevents out of bounds if the voice changed while notes are still on.

            for (byte i = 0; i < opsToProcess; i++)
            {
                var intent = ops[i].intent;


                //NOTE:  This might be faster as a type-matching switch pattern, but this isn't supported in c# 7.2.  Consider changing it in the future if more efficient
                switch (intent)
                {
                case OpBase.Intents.FM_OP:
                case OpBase.Intents.BITWISE:
                case OpBase.Intents.WAVEFOLDER:
                    var op = ops[i] as Operator;
                    op.eg.Configure(voice.egs[i]);

                    //TODO:  Consider pooling envelope resources to reduce memory thrash
                    //No EG Source?  Generate a new envelope.
                    // if (EGSource==null)
                    // {
                    //     op.eg = new Envelope(voice.egs[i]);  //Make copies of the old EG values so they can be altered on a per-note basis.
                    // } else {
                    //     //Return the previous envelope we were using to the pool and get a fresh one.
                    //     EGSource.Return(op.eg);
                    //     op.eg = EGSource.Get(voice.egs[i]);
                    // }

                    // Adjust the EG based on values from the RTables.
                    if (midi_note < 0x80)
                    {
                        op.eg.ksl.Apply(midi_note, ref op.eg.levels[4]);  //Apply KSL to total level

                        for (int j = 0; j < op.eg.rates.Length - 1; j++)
                        {
                            //Rate scaling is applied double to everything except the release rate. (r = 2r + ksr)
                            var rate = (byte)(op.eg.rates[j] * 2);
                            op.eg.ksr.Apply(midi_note, ref rate);
                            op.eg.rates[j] = (byte)rate;
                        }
                        op.eg.ksr.Apply(midi_note, ref op.eg.rates[op.eg.rates.Length - 1]); //Release rate
                    }
                    op.eg.velocity.Apply(velocity, ref op.eg.levels[4]);                     //Apply velocity to total level



                    op.pg = voice.pgs[i];                         //Set Increments to the last Voice increments value (ByVal copy)
                    op.SetOscillatorType((byte)voice.oscType[i]); //Set the wave function to what the voice says it should be

                    //Prepare the note's increment based on calculated pitch
                    if (!op.pg.fixedFreq)
                    {
                        op.pg.NoteSelect(this.midi_note);
                        op.pg.ApplyDetuneRandomness();  //Select a detune amount based on specified level of randomness
                    }

                    op.pg.Recalc();
                    op.NoteOn();
                    break;

                case OpBase.Intents.FILTER:
                    //TODO:  Consider adding a case for FILTER intent to SetOscillatorType here so that it's not relied on user to change the intent of each channel manually.
                    break;
                }
            }
            busy = BusyState.BUSY;
        }
Exemplo n.º 30
0
 public Task SetState(BusyState state, string description, double?progress)
 => _setState(new StateInfo {
     state = (int)state, description = description, progress = progress
 });