Beispiel #1
0
    private void CheckInvalidAddress()
    {
        if (!isInvalidAddress)
        {
            return;
        }

        var loweredText    = addressField.Text.ToLower();
        var possibleTokens = tokenListManager.TokenList.Where(token => token.Name.ToLower().Contains(loweredText) || token.Symbol.ToLower().StartsWith(loweredText)).ToList();

        ActivelySelectedButton?.Toggle();

        if (string.IsNullOrEmpty(loweredText) || possibleTokens.Count == 0)
        {
            OnStatusChanged?.Invoke(Status.NoTokenFound);
            okButton.interactable = false;
        }
        else if (possibleTokens.Count > MAX_TOKEN_COUNT)
        {
            OnStatusChanged?.Invoke(Status.TooManyTokensFound);
            okButton.interactable = false;
        }
        else
        {
            DisplayAddableTokens(possibleTokens);
        }
    }
Beispiel #2
0
    private void DisplayAddableTokens(List <TokenInfo> newTokenList)
    {
        newTokenList.Sort((t1, t2) => t1.Symbol.CompareTo(t2.Symbol));

        for (int i = newTokenList.Count; i < addableTokens.Count; i++)
        {
            addableTokens[i].transform.parent.gameObject.SetActive(false);
        }

        for (int i = 0; i < newTokenList.Count; i++)
        {
            if (i < addableTokens.Count)
            {
                addableTokens[i].transform.parent.gameObject.SetActive(true);
                addableTokens[i].SetButtonInfo(newTokenList[i]);
            }
            else
            {
                var newTokenButton = addableTokenButtonFactory.Create();
                newTokenButton.SetButtonInfo(newTokenList[i]);
                newTokenButton.transform.parent.parent     = addableTokenSpawnTransform;
                newTokenButton.transform.parent.localScale = Vector3.one;
                addableTokens.Add(newTokenButton);
            }
        }

        OnStatusChanged?.Invoke(Status.MultipleTokensFound);
    }
Beispiel #3
0
        private void DeInitScanner()
        {
            if (m_EmdkManager != null)
            {
                if (m_Scanner != null)
                {
                    try
                    {
                        m_Scanner.Data   -= DataReceived;
                        m_Scanner.Status -= StatusChanged;
                        m_Scanner.Disable();
                    }
                    catch (ScannerException e)
                    {
                        OnStatusChanged?.Invoke(this, new EMDKStatusChangedArgs($"Error: {e.Message}"));
                    }
                }

                if (m_BarcodeManager != null)
                {
                    m_EmdkManager.Release(EMDKManager.FEATURE_TYPE.Barcode);
                }

                m_BarcodeManager = null;
                m_Scanner        = null;
            }
        }
Beispiel #4
0
        void InitScanner()
        {
            if (m_EmdkManager != null)
            {
                if (m_BarcodeManager == null)
                {
                    try
                    {
                        m_BarcodeManager = (BarcodeManager)m_EmdkManager.GetInstance(EMDKManager.FEATURE_TYPE.Barcode);
                        m_Scanner        = m_BarcodeManager.GetDevice(BarcodeManager.DeviceIdentifier.Default);

                        if (m_Scanner != null)
                        {
                            m_Scanner.Data   -= DataReceived;
                            m_Scanner.Data   += DataReceived;
                            m_Scanner.Status -= StatusChanged;
                            m_Scanner.Status += StatusChanged;
                        }
                        else
                        {
                            OnStatusChanged?.Invoke(this, new EMDKStatusChangedArgs("Failed to enable scanner."));
                        }
                    }
                    catch (ScannerException e)
                    {
                        OnStatusChanged?.Invoke(this, new EMDKStatusChangedArgs($"Error: {e.Message}"));
                    }
                    catch (Exception ex)
                    {
                        OnStatusChanged?.Invoke(this, new EMDKStatusChangedArgs($"Error: {ex.Message}"));
                    }
                }
            }
        }
Beispiel #5
0
        void EMDKManager.IEMDKListener.OnOpened(EMDKManager p0)
        {
            OnStatusChanged?.Invoke(this, new EMDKStatusChangedArgs("EMDK Opened successfully."));
            m_EmdkManager = p0;

            InitScanner();
        }
Beispiel #6
0
    private void CheckTokenContract(bool existsInTokenList)
    {
        if (existsInTokenList)
        {
            return;
        }

        addressField.InputFieldBase.interactable = false;

        OnStatusChanged?.Invoke(Status.Loading);

        string addressText = addressField.Text;

        ERC20 erc20 = new ERC20(addressText);

        erc20.OnInitializationSuccessful(() =>
        {
            tradableAssetImageManager.LoadImage(erc20.Symbol, img =>
            {
                tokenIcon.sprite = img;

                CheckStatus(erc20.Symbol, erc20.Name, erc20.Decimals, 0);
            });
        });

        erc20.OnInitializationUnsuccessful(() =>
        {
            SimpleContractQueries.QueryUInt256Output <BalanceOf>(addressText, userWalletManager.GetWalletAddress(), userWalletManager.GetWalletAddress())
            .OnSuccess(balance => CheckStatus(null, null, null, balance.Value))
            .OnError(_ => CheckStatus(null, null, null, null));
        });
    }
Beispiel #7
0
        public virtual void ChangeStatus(Status status)
        {
            switch (status)
            {
            case Status.Running:
                Enable();
                break;

            case Status.Stopped:
                Disable();
                break;

            case Status.Completed:
                Complete();
                break;

            case Status.Ready:
                Reset();
                break;

            case Status.Error:
                Error();
                break;
            }
            OnStatusChanged?.Invoke(this);
        }
Beispiel #8
0
        private void CheckConnectionStatus()
        {
            const string PingCommand           = "ping raspberrypi.local -n 2";
            const int    SentPackagesIndex     = 1;
            const int    ReceivedPackagesIndex = 2;
            var          getPingStatsRegex     = new Regex(@"Sent = (\d), Received = (\d)");

            while (true)
            {
                var result    = _commandExecutor.Execute(PingCommand);
                var pingStats = getPingStatsRegex.Match(result);

                bool isConnected = false;

                if (pingStats.Success)
                {
                    int sent     = int.Parse(pingStats.Groups[SentPackagesIndex].Value);
                    int received = int.Parse(pingStats.Groups[ReceivedPackagesIndex].Value);
                    isConnected = sent == received;
                }

                if (_isConnected != isConnected)
                {
                    _isConnected = isConnected;
                    OnStatusChanged?.Invoke(this, EventArgs.Empty);
                }

                Thread.Sleep(ConnectionCheckInterval);
            }
        }
 public void UpdateStatus(object sender, EventArgs e)
 {
     remoteHostStatus = Reachability.RemoteHostStatus();
     internetStatus   = Reachability.InternetConnectionStatus();
     localWifiStatus  = Reachability.LocalWifiConnectionStatus();
     OnStatusChanged?.Invoke(this, e);
 }
        public async Task StartAsync()
        {
            try
            {
                await hubConnection.StartAsync(cancellationTokenSource.Token);

                if (hubConnection.State == HubConnectionState.Connected)
                {
                    OnStatusChanged?.Invoke(Statuses.Connected);
                }
                if (hubConnection.State == HubConnectionState.Connecting)
                {
                    OnStatusChanged?.Invoke(Statuses.Connecting);
                }
                if (hubConnection.State == HubConnectionState.Reconnecting)
                {
                    OnStatusChanged?.Invoke(Statuses.Reconnecting);
                }
                if (hubConnection.State == HubConnectionState.Disconnected)
                {
                    OnStatusChanged?.Invoke(Statuses.Disconnected);
                }
            }
            catch (Exception ex)
            {
                OnStatusChanged?.Invoke(Statuses.Disconnected);
                logger.Error(ex, "An unhandled exception has occurred while trying to start the connection to server.");
            }
        }
Beispiel #11
0
        public ApiPSU()
        {
            Bl = new BL();
            Global.OnReceiptCalculationComplete += (wareses, pIdReceipt) =>
            {
                FileLogger.WriteLogMessage($"OnReceiptCalculationComplete =>Start", eTypeLog.Expanded);
                foreach (var el in wareses)
                {
                    FileLogger.WriteLogMessage($"OnReceiptCalculationComplete Promotion=>{el.GetStrWaresReceiptPromotion.Trim()} \n{el.NameWares} - {el.Price} Quantity=> {el.Quantity} SumDiscount=>{el.SumDiscount}", eTypeLog.Expanded);
                }

                OnProductsChanged?.Invoke(wareses.Select(s => GetProductViewModel(s)), Global.GetTerminalIdByIdWorkplace(pIdReceipt.IdWorkplace));
                FileLogger.WriteLogMessage($"OnReceiptCalculationComplete =>End", eTypeLog.Expanded);
            };

            Global.OnSyncInfoCollected += (SyncInfo) =>
            {
                OnSyncInfoCollected?.Invoke(SyncInfo);
                FileLogger.WriteLogMessage($"OnSyncInfoCollected Status=>{SyncInfo.Status} StatusDescription=>{SyncInfo.StatusDescription}", eTypeLog.Expanded);
            };

            Global.OnStatusChanged += (Status) => OnStatusChanged?.Invoke(Status);

            Global.OnChangedStatusScale += (Status) => OnChangedStatusScale?.Invoke(Status);

            Global.OnClientChanged += (client, guid) =>
            {
                OnCustomerChanged?.Invoke(GetCustomerViewModelByClient(client), Global.GetTerminalIdByIdWorkplace(guid));
                FileLogger.WriteLogMessage($"Client.Wallet=> {client.Wallet} SumBonus=>{client.SumBonus} ", eTypeLog.Expanded);
            };

            Global.OnClientWindows += (pTerminalId, pTypeWindows, pMessage) =>
            {
                TerminalCustomWindowModel TCV = null;
                if (pTypeWindows == eTypeWindows.LimitSales)
                {
                    TCV = new TerminalCustomWindowModel()
                    {
                        TerminalId   = Global.GetTerminalIdByIdWorkplace(pTerminalId),
                        CustomWindow = new CustomWindowModel()
                        {
                            Caption        = "",
                            Text           = pMessage,
                            AnswerRequired = false,
                            Type           = CustomWindowInputType.Buttons,
                            Buttons        = new List <CustomWindowButton>()
                            {
                                new CustomWindowButton()
                                {
                                    ActionData = "Ok", DisplayName = "Ok"
                                }
                            }
                        }
                    };
                }
                OnShowCustomWindow?.Invoke(TCV);
                string sTCV = JsonConvert.SerializeObject(TCV);
                FileLogger.WriteLogMessage($"OnClientWindows => {pTypeWindows} TerminalId=>{pTerminalId}{Environment.NewLine} Message=> {pMessage} {Environment.NewLine} TCV=>{sTCV}", eTypeLog.Expanded);
            };
        }
        public ProSuiteQAResponse StartQASync(ProSuiteQARequest parameters)
        {
            var args = PrepareGPToolParameters(parameters, ProSuiteQAToolType.Xml);

            if (args == null)
            {
                return(new ProSuiteQAResponse()
                {
                    Error = ProSuiteQAError.ServiceFailed
                });
            }

            Geoprocessing.OpenToolDialog(_toolpath, args, null, false,
                                         (event_name, o) =>
            {
                if (event_name == "OnEndExecute")
                {
                    var result = o as IGPResult;
                    OnStatusChanged?.Invoke(this, new ProSuiteQAServiceEventArgs(ProSuiteQAServiceState.Finished, result?.Values?.First()));
                }
                else                         // TODO other events than "OnStartExecute" ?
                {
                }
            });
            return(null);
        }
Beispiel #13
0
 private void UpdateStatus(StatusCheckData status)
 {
     status.DidWorkOnce          = true;
     status.IsWorking            = true;
     status.LastWorkingTimestamp = DateTime.Now;
     OnStatusChanged?.Invoke();
 }
Beispiel #14
0
        /// <summary>
        /// Updates the state of the player.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <param name="position"></param>
        public void UpdatePlaybackState(int state, int position = 0)
        {
            if (CurrentSession == null && (_binder?.IsBinderAlive).GetValueOrDefault(false) && !string.IsNullOrWhiteSpace(_packageName))
            {
                InitMediaSession(_packageName, _binder);
            }

            PlaybackStateCompat.Builder stateBuilder = new PlaybackStateCompat.Builder()
                                                       .SetActions(PlaybackStateCompat.ActionPlay
                                                                   | PlaybackStateCompat.ActionPlayPause
                                                                   | PlaybackStateCompat.ActionPause
                                                                   | PlaybackStateCompat.ActionSkipToNext
                                                                   | PlaybackStateCompat.ActionSkipToPrevious
                                                                   | PlaybackStateCompat.ActionStop);

            stateBuilder.SetState(state, position, 0, SystemClock.ElapsedRealtime());
            CurrentSession?.SetPlaybackState(stateBuilder.Build());
            OnStatusChanged?.Invoke(CurrentSession, state);

            //Used for backwards compatibility
            if ((Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) &&
                (CurrentSession?.RemoteControlClient == null ||
                 (bool)!CurrentSession?.RemoteControlClient.Equals(typeof(RemoteControlClient))))
            {
                return;
            }

            RemoteControlClient remoteControlClient = (RemoteControlClient)CurrentSession?.RemoteControlClient;

            RemoteControlFlags flags = RemoteControlFlags.Play
                                       | RemoteControlFlags.Pause
                                       | RemoteControlFlags.PlayPause;

            remoteControlClient?.SetTransportControlFlags(flags);
        }
Beispiel #15
0
    public EffectResult SetStatus(ConditionID conditionId)
    {
        //Check current status
        if (Status != null)
        {
            return(EffectResult.AlreadyOne);
        }

        //Check invulnerability
        //Poison
        if (conditionId == ConditionID.psn && (Base.Type1 == PokemonType.Poison || Base.Type2 == PokemonType.Poison))
        {
            return(EffectResult.Inmune);
        }

        //Burn
        if (conditionId == ConditionID.brn && (Base.Type1 == PokemonType.Fire || Base.Type2 == PokemonType.Fire))
        {
            return(EffectResult.Inmune);
        }

        //TODO: En el futuro quiza habria que add la resistencia de los tipo planta a ciertos ataques(drenadoras, somnifero, etc)

        Status = ConditionsDB.Conditions[conditionId];
        Status?.OnStart?.Invoke(this);
        StatusChanges.Enqueue($"{Base.Name} {Status.StartMessage}");
        OnStatusChanged?.Invoke();

        return(EffectResult.Succes);
    }
Beispiel #16
0
        public virtual void SetPoisoning(int hurt, uint timeout, uint interval)
        {
            ClearTimeout(_poisonTimerTimeout);

            if (!IsGodMode)
            {
                if (!_poisoning)
                {
                    _poisoning           = true;
                    _poisonTimerInterval = SetInterval(() =>
                    {
                        this.Damage(hurt, true);
                    }, interval);
                }

                _poisonTimerTimeout = SetTimeout(() =>
                {
                    _poisoning = false;
                    ClearInterval(_poisonTimerInterval);
                    OnStatusChanged?.Invoke();
                }, timeout);
            }

            OnStatusChanged?.Invoke();
        }
Beispiel #17
0
 /// <summary>
 ///     Close the serial port connection
 /// </summary>
 public void Close()
 {
     StopReading();
     _serial.Close();
     OnStatusChanged?.Invoke(this, "Connection closed.");
     OnSerialPortOpened?.Invoke(this, false);
 }
Beispiel #18
0
        private void DoListen()
        {
            while (isAlive || l.Any())
            {
                if (Application.Current == null)
                {
                    isAlive = false;
                    break;
                }

                if (l.Count > 0)
                {
                    Lock.Wait();
                    List.SynchronizeTo(l[0], MainList);
                    FileWorkerManager.DoAsync(Document, FilePath, Lock);
                    l.RemoveAt(0);
                    if (l.Any() || OnStatusChanged == null)
                    {
                        continue;
                    }
                    OnStatusChanged.Invoke(SaveManagerStatus.Stoped, 0);
                }
            }
            Thread.CurrentThread.Abort();
        }
        protected void InvokStatusChanged(EIOState EIOState, Exception Exception = null)
        {
            _Status = EIOState;

            IOStateChange IOSC = new IOStateChange(EIOState, Exception);

            OnStatusChanged?.Invoke(this, IOSC);
        }
Beispiel #20
0
 public void Suspend()
 {
     if (_downloader != null)
     {
         _downloader.Suspend();
         OnStatusChanged?.Invoke(this, _downloader.Address + " suspended");
     }
 }
Beispiel #21
0
 public void Resume()
 {
     if (_downloader != null)
     {
         _downloader.Resume();
         OnStatusChanged?.Invoke(this, _downloader.Address + " in progress");
     }
 }
 public NefitEasyClient(NefitEasyCredentials credentials)
 {
     _gateway = new NefitEasyGateway(credentials);
     _gateway.OnClientStatusChanged += (sender, status) =>
     {
         Status = status;
         OnStatusChanged?.Invoke(this, status);
     };
 }
Beispiel #23
0
 private void OnCheckProcessProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     if (e.ProgressPercentage != -1)
     {
         return;
     }
     OnStatusChanged?.Invoke(this, new ProcessStatusEventArgs(_newStatus));
     _lastStatus = _newStatus;
 }
Beispiel #24
0
 public void Disable()
 {
     if (!IsEnabled)
     {
         throw new HardwareCannotBeDisabledException("The CPU is already disabled");
     }
     IsEnabled = false;
     OnStatusChanged?.Invoke(this, new CPUEventArgs("The CPU has been disabled", Title, IsEnabled));
 }
 public void AnimationCloseEventHandler()
 {
     IsOpened = false;
     Animator.SetBool("Down", false);
     if (OnStatusChanged != null)
     {
         OnStatusChanged.Invoke(IsOpened);
     }
 }
Beispiel #26
0
        private void SetStatus(IntPtr instance, IntPtr status, IntPtr error)
        {
            // decode message from bytes
            var instanceStr = Marshal.PtrToStringAnsi(instance);
            var statusStr   = Marshal.PtrToStringAnsi(status);
            var errorStr    = Marshal.PtrToStringAnsi(error);

            switch (statusStr)
            {
            case StatusConnecting:
                OnStatusChanged?.Invoke(this, new StatusEventArgs()
                {
                    Instance = instanceStr,
                    Status   = Status.Connecting
                });
                break;

            case StatusConnected:
                OnStatusChanged?.Invoke(this, new StatusEventArgs()
                {
                    Instance = instanceStr,
                    Status   = Status.Connected
                });
                OnConnected?.Invoke(this, instanceStr);
                if (tcss.ContainsKey(instanceStr))
                {
                    tcss[instanceStr]?.TrySetResult("");
                }
                break;

            case StatusError:
                OnStatusChanged?.Invoke(this, new StatusEventArgs()
                {
                    Instance = instanceStr,
                    Status   = Status.Error
                });
                OnError?.Invoke(this, new ErrorEventArgs()
                {
                    Instance     = instanceStr,
                    ErrorMessage = errorStr
                });
                if (tcss.ContainsKey(instanceStr))
                {
                    tcss[instanceStr]?.TrySetResult(errorStr);
                }
                break;

            default:
                OnStatusChanged?.Invoke(this, new StatusEventArgs()
                {
                    Instance = instanceStr,
                    Status   = Status.Disconnected
                });
                OnDisconnected?.Invoke(this, instanceStr);
                break;
            }
        }
 public void AnimationOpenEventHandler()
 {
     Animator.SetBool("Up", false);
     IsOpened = true;
     if (OnStatusChanged != null)
     {
         OnStatusChanged.Invoke(IsOpened);
     }
 }
Beispiel #28
0
    private void ValidTokenFound()
    {
        tokenName.text = name.LimitEnd(40, "...") + (!string.IsNullOrEmpty(symbol) ? $" ({symbol})" : "");
        tokenListManager.AddToken(addressField.Text, name, symbol, decimals.Value);

        OnStatusChanged?.Invoke(Status.ValidToken);

        okButton.interactable = true;
    }
 public void Stop()
 {
     if (!IsEnabled)
     {
         throw new SoftwareCannotBeDisabledException("The program is already disabled");
     }
     IsEnabled = false;
     OnStatusChanged?.Invoke(this, new SoftwareEventArgs("The program has been disabled", Title, IsEnabled));
 }
Beispiel #30
0
        private void UninstallWorkerThread()
        {
            var targetList    = AllUninstallersList;
            var configuration = Configuration;

            if (targetList == null || configuration == null)
            {
                throw new ArgumentException("BulkUninstallTask is incomplete, this should not have happened.");
            }

            while (AllUninstallersList.Any(x => x.CurrentStatus == UninstallStatus.Waiting || x.IsRunning))
            {
                do
                {
                    if (Aborted)
                    {
                        AllUninstallersList.ForEach(x => x.SkipWaiting(false));
                        break;
                    }
                    Thread.Sleep(500);
                } while (AllUninstallersList.Count(x => x.IsRunning) >= ConcurrentUninstallerCount);

                var running      = AllUninstallersList.Where(x => x.CurrentStatus == UninstallStatus.Uninstalling).ToList();
                var runningTypes = running.Select(y => y.UninstallerEntry.UninstallerKind).ToList();
                var loudBlocked  = OneLoudLimit && running.Any(y => !y.IsSilent);

                var result = AllUninstallersList.FirstOrDefault(x =>
                {
                    if (x.CurrentStatus != UninstallStatus.Waiting || (loudBlocked && !x.IsSilent))
                    {
                        return(false);
                    }

                    if (CheckForTypeCollisions(x.UninstallerEntry.UninstallerKind, runningTypes))
                    {
                        return(false);
                    }

                    if (CheckForAdvancedCollisions(x.UninstallerEntry, running.Select(y => y.UninstallerEntry)))
                    {
                        return(false);
                    }

                    return(true);
                });

                if (result != null)
                {
                    result.RunUninstaller(new BulkUninstallEntry.RunUninstallerOptions(configuration.AutoKillStuckQuiet,
                                                                                       configuration.RetryFailedQuiet, configuration.PreferQuiet, configuration.Simulate));
                    // Fire the event now so the interface can be updated
                    OnStatusChanged?.Invoke(this, EventArgs.Empty);
                }
            }

            Finished = true;
        }