Ejemplo n.º 1
0
 protected async void OnMessageReceived(object sender, IrcMessageEventArgs e)
 {
     if ((e == null) || (e.Message == null))
     {
         if (Connecting && !Connected)
         {
             StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.FailedConnection));
         }
         else
         {
             StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.Disconnected));
         }
         Connecting = false;
         Connected  = false;
         return;
     }
     if (!Connected && e.Message.Equals($":tmi.twitch.tv 001 {userName} :Welcome, GLHF!"))
     {
         Connected = true;
         StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.Connected));
     }
     else if (Connected && e.Message.Equals("PING :tmi.twitch.tv"))
     {
         await SendIrcMessageAsync("PONG :tmi.twitch.tv");
     }
     else if (Connected && e.Message.Equals($":{userName}.tmi.twitch.tv 353 {userName} = #{LastChannelName} :{userName}"))
     {
         StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.ChannelJoined, LastChannelName));
     }
 }
Ejemplo n.º 2
0
 void OnStateChange()
 {
     if (StateChange != null)
     {
         StateChange.Invoke(this, EventArgs.Empty);
     }
 }
Ejemplo n.º 3
0
        public async void OnValidTransfert()
        {
            try
            {
                await SqlContext.TransfertRackTo(TransfertRackValidation.IdRackPartant, TransfertRackValidation.IdRackArrivant);

                // Recharger les racks.
                Racks = await SqlContext.GetRackEmpty();

                RacksFull = await SqlContext.GetRackFull();

                AllHangar.RemoveAll(x => x.IdRack == TransfertRackValidation.IdRackPartant);
                HangarView hangar = await SqlContext.GetHangar(ClientTransfert.IdCommande, TransfertRackValidation.IdRackArrivant);

                AllHangar.Add(hangar);
                await HangarGrid.Reload();

                Notification.Notify(NotificationSeverity.Success, "Transfert OK", "Transfert effectué");

                // Remise à zéro
                TransfertRackValidation = new TransfertRackValidation();
                ClientTransfert         = new CommandeView();

                StateChange.Invoke();
            }
            catch (Exception ex)
            {
                Log.Error(ex, "HangarViewModel - OnValidTransfert");
                Notification.Notify(NotificationSeverity.Success, "Error", "Erreur sur le transfert");
            }
        }
        private void StateChangedEventHandler(object sender, StateChangedEventArgs args)
        {
            var newState = ConvertStateChangeEventArgs(args);

            ReadyState = newState.NewState;
            StateChange?.Invoke(this, newState);
        }
Ejemplo n.º 5
0
        private async void OnValidIntervertir()
        {
            try
            {
                await SqlContext.IntervertirRackTo(IntervertirValidation.IdRackPartant,
                                                   IntervertirValidation.IdRackArrivant,
                                                   IntervertirValidation.IdCommandePartant);

                await SqlContext.IntervertirRackTo(IntervertirValidation.IdRackArrivant,
                                                   IntervertirValidation.IdRackPartant,
                                                   IntervertirValidation.IdCommandeArrivant);

                // Recharger
                RacksFull = await SqlContext.GetRackFull();

                AllHangar = await SqlContext.GetHangar();

                await HangarGrid.Reload();

                Notification.Notify(NotificationSeverity.Success, "Inversion OK", "Inversion effectuée");

                // Remise à zéro
                IntervertirValidation = new InversionPaletteValidation();

                StateChange.Invoke();
            }
            catch (Exception ex)
            {
                Log.Error(ex, "HangarViewModel - OnValidIntervertir");
                Notification.Notify(NotificationSeverity.Success, "Error", "Erreur sur l'inversion");
            }
        }
Ejemplo n.º 6
0
        public void ChangeState(CellState pNewState)
        {
            State = pNewState;

            StateChanged?.Invoke(this);

            switch (State)
            {
            case CellState.DEFAULT:
                IsTraversable = true;
                IsFood        = false;
                break;

            case CellState.WALL:
                IsTraversable = false;
                IsFood        = false;
                break;

            case CellState.FOOD:
                IsTraversable = true;
                IsFood        = true;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 7
0
        private void CloseIntervertir()
        {
            DisplayRenderFragment = null;
            StateChange.Invoke();

            IntervertirValidation = new InversionPaletteValidation();
        }
Ejemplo n.º 8
0
        public async void OnSelectedRackPartant(string rackPartant)
        {
            if (!string.IsNullOrEmpty(rackPartant))
            {
                Rack rackSelected = RacksFull.FirstOrDefault(x => x.GisementPos == rackPartant);

                if (rackSelected != null)
                {
                    TransfertRackValidation.IdRackPartant = rackSelected.IdRack;

                    var temp = await SqlContext.GetCommandeByIdRack(rackSelected.IdRack);

                    ClientTransfert.NomClient      = temp.NomClient;
                    ClientTransfert.DescriptionCmd = temp.DescriptionCmd;
                    ClientTransfert.IdClient       = temp.IdClient;
                    ClientTransfert.IdCommande     = temp.IdCommande;

                    TransfertRackValidation.GisementRackPartant = rackSelected.GisementPos;
                    StateChange.Invoke();
                }
                else
                {
                    TransfertRackValidation.IdRackPartant       = 0;
                    TransfertRackValidation.GisementRackPartant = string.Empty;

                    ClientTransfert = new CommandeView();
                }
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// This method only changes the state of the object
 /// </summary>
 public void Activate()
 {
     StateChange?.Invoke(gameObject, GameActions.StateChange, new GenericMessage()
     {
         values = new string[] { id.ToString(), (!active).ToString() }
     });
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Enter IRC room asynchronously.
        /// </summary>
        /// <param name="channelName">Room name to enter</param>
        /// <param name="partPreviousChannels">if set to true leave all previous entered channels</param>
        /// <returns>If room was entered successfully.</returns>
        public async Task <bool> JoinRoomAsync(string channelName, bool partPreviousChannels = false)
        {
            channelName = channelName.ToLower();
            if (ChannelNames.Contains(channelName))
            {
                return(false);
            }
            if (partPreviousChannels)
            {
                foreach (string name in ChannelNames)
                {
                    await LeaveRoomAsync(name);
                }
                ChannelNames.Clear();
            }
            try
            {
                await outputStream.WriteLineAsync($"JOIN #{channelName}");

                await outputStream.FlushAsync();

                StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.ChannelJoining, channelName));
                LastChannelName = channelName;
                ChannelNames.Add(channelName);
                return(true);
            }
            catch
            {
                Connected  = false;
                Connecting = false;
                StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.Disconnected));
                return(false);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Leave IRC room asynchronously.
        /// </summary>
        /// <param name="channelName">Room name to leave</param>
        /// <returns>If room was left successfully.</returns>
        public async Task <bool> LeaveRoomAsync(string channelName)
        {
            channelName = channelName.ToLower();
            if (!ChannelNames.Contains(channelName))
            {
                return(false);
            }
            try
            {
                await outputStream.WriteLineAsync($"PART #{channelName}");

                await outputStream.FlushAsync();

                StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.ChannelLeaving, channelName));
                ChannelNames.Remove(channelName);
                return(true);
            }
            catch
            {
                Connected  = false;
                Connecting = false;
                StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.Disconnected));
                return(false);
            }
        }
Ejemplo n.º 12
0
        public void CloseEntre()
        {
            DisplayRenderFragment = null;
            StateChange.Invoke();

            EntreHangarValidation = new EntreHangarValidation();
        }
Ejemplo n.º 13
0
        private async Task LoginAsync()
        {
            try
            {
                await outputStream.WriteLineAsync($"PASS {password}");

                await outputStream.WriteLineAsync($"NICK {userName}");

                if (LastChannelName != "")
                {
                    await outputStream.WriteLineAsync($"JOIN #{LastChannelName}");

                    StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.ChannelJoining, LastChannelName));
                }
                await outputStream.FlushAsync();

                Connecting         = true;
                ReceiveMessage    += OnMessageReceived;
                ReadMessagesThread = new Thread(ReadMessagesAsync)
                {
                    IsBackground = true
                };
                ReadMessagesThread.Start();
            }
            catch
            {
                StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.Disconnected));
            }
        }
Ejemplo n.º 14
0
        public void CloseSortie()
        {
            DisplayRenderFragment = null;
            StateChange.Invoke();

            SortieHangarValidation = new SortieHangarValidation();
        }
Ejemplo n.º 15
0
        private void SignUpDbConnection()
        {
            var dbConn = GetNewDbConnection();

            SingletonConnection              = dbConn;
            SingletonConnection.StateChange += (sender, e) => StateChange?.Invoke(sender, e);
        }
Ejemplo n.º 16
0
        private void CloseTransfert()
        {
            DisplayRenderFragment = null;
            StateChange.Invoke();

            TransfertRackValidation = new TransfertRackValidation();
            ClientTransfert         = new CommandeView();
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Invoke event for connection state changes.
 /// </summary>
 /// <param name="newState">The new WebSocketState.</param>
 protected virtual void OnStateChange(WebSocketState newState)
 {
     if (_Status != newState)
     {
         _Status = newState;
         StateChange?.Invoke(this, newState);
     }
 }
Ejemplo n.º 18
0
        private void ChangeState(RdpState state, int?reason = null)
        {
            State = state;
            btnConnect.Enabled    = state == RdpState.Disconnected;
            btnDisconnect.Enabled = state == RdpState.Connected;

            StateChange?.Invoke(this, new StateChangeEventArgs(CurrentServer, state, ListIndex, reason));
        }
Ejemplo n.º 19
0
        protected virtual void OnStateChange(StateChangeEventArgs stateChange)
        {
            if (_supressStateChangeForReconnection)
            {
                return;
            }

            StateChange?.Invoke(this, stateChange);
        }
Ejemplo n.º 20
0
        public void Click(int x, int y)
        {
            var affectedCells = CalculateAffectedCells(x, y);

            affectedCells
            .Where(cell => cell.X > -1 && cell.X <_size && cell.Y> -1 && cell.Y < _size).ToList()
            .ForEach(row => _grid[row.Y][row.X] = !_grid[row.Y][row.X]);

            StateChange?.Invoke(this, new EventArgs());
        }
Ejemplo n.º 21
0
        protected void OnStateChange(object source, WorkerState state)
        {
            StateChangeHandlerEventArgs args = new StateChangeHandlerEventArgs();

            args.State = state;

            if (StateChange != null)
            {
                StateChange.Invoke(source, args);
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Permette di esportare tutte le immagini della collezione in una cartella
        /// </summary>
        /// <param name="PathOut"></param>
        /// <param name="OriginalName"></param>
        /// <param name="FormatoOutput"></param>
        public void Export(String PathOut, String OriginalName, FormatoOut FormatoOutput = FormatoOut.jpg)
        {
            StateChange?.Invoke(this, State.InWorking);


            if (!Directory.Exists(PathOut))
            {
                Directory.CreateDirectory(PathOut);
            }

            if (ic.IsEmpty)
            {
                StateChange?.Invoke(this, State.Finish);
                return;
            }


            ImageFormat format;

            if (FormatoOutput == FormatoOut.jpg)
            {
                format = ImageFormat.Jpeg;
            }
            else if (FormatoOutput == FormatoOut.png)
            {
                format = ImageFormat.Png;
            }
            else if (FormatoOutput == FormatoOut.bmp)
            {
                format = ImageFormat.Bmp;
            }
            else
            {
                format = ImageFormat.Jpeg;
            }


            String Ext = FormatoOutput.ToString();


            int current = 0;
            int tot     = ic.Collection.Count;

            foreach (Image i in ic.Collection)
            {
                ProgressChange?.Invoke(this, current++, tot);
                ExportSingle(i, format, Path.Combine(PathOut, OriginalName + "_" + current + "." + Ext));
            }



            StateChange?.Invoke(this, State.Finish);
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Start the connection to the IRC in asynchronous context.
 /// </summary>
 public async Task BeginConnectionAsync()
 {
     try
     {
         SetupStreams();
         StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.Connecting));
         await LoginAsync();
     }
     catch
     {
         StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.Disconnected));
     }
 }
        private void CheckNifudaConnection()
        {
            var lastStateNifuda = ConnectionState.Fetching;
            var lastStateIsup   = ConnectionState.Fetching;

            while (true)
            {
                try
                {
                    EmptyNifudaQueryExecute();

                    if (NifudaDataTableAdapter.Connection.State == ConnectionState.Open)
                    {
                        if (lastStateNifuda != NifudaDataTableAdapter.Connection.State)
                        {
                            StateChange?.Invoke(this,
                                                new StateChangeEventArgs(lastStateIsup, NifudaDataTableAdapter.Connection.State));
                            lastStateNifuda = NifudaDataTableAdapter.Connection.State;
                            continue;
                        }
                    }
                    else if (NifudaDataTableAdapter.Connection.State == ConnectionState.Closed)
                    {
                        if (lastStateNifuda != NifudaDataTableAdapter.Connection.State)
                        {
                            StateChange?.Invoke(this,
                                                new StateChangeEventArgs(lastStateIsup, NifudaDataTableAdapter.Connection.State));
                            lastStateNifuda = NifudaDataTableAdapter.Connection.State;
                            continue;
                        }

                        try
                        {
                            NifudaDataTableAdapter.Connection.Open();
                        }
                        catch { }
                    }

                    Thread.Sleep((int)SettingsContext.GlobalSettings.UpdateTimeout);
                }
                catch (ThreadAbortException)
                {
                    break;
                }
                catch (SqlException)
                {
                }
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Start the connection to the IRC.
 /// </summary>
 public async Task BeginConnectionAsync()
 {
     try
     {
         tcpClient    = new TcpClient(serverIp, serverPort);
         inputStream  = new StreamReader(tcpClient.GetStream());
         outputStream = new StreamWriter(tcpClient.GetStream());
         StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.Connecting));
         await LoginAsync();
     }
     catch
     {
         StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.Disconnected));
     }
 }
Ejemplo n.º 26
0
 public void ChangeState(PlayerState state)
 {
     if (currentState == PlayerState.noClip)
     {
         if (state == PlayerState.empty)
         {
             currentState = state;
         }
         return;
     }
     if (currentState != state)
     {
         currentState = state;
         stateChange?.Invoke(state);
     }
 }
Ejemplo n.º 27
0
 public SqlServerConnect()
 {
     connection = new SqlConnection();
     command    = new SqlCommand
     {
         Connection = connection
     };
     SqlOptions              = new SqlOptions('[', ']', new Base.SqlServerBase());
     connection.StateChange += (sender, e) =>
     {
         if (StateChange != null)
         {
             StateChange.Invoke(sender, e);
         }
     };
 }
Ejemplo n.º 28
0
 public MySqlConnect()
 {
     connection = new MySqlConnection();
     command    = new MySqlCommand
     {
         Connection = connection
     };
     SqlOptions              = new SqlOptions('`', '`', new Base.MySqlBase());
     connection.StateChange += (sender, e) =>
     {
         if (StateChange != null)
         {
             StateChange.Invoke(sender, e);
         }
     };
 }
Ejemplo n.º 29
0
 private void ReadMessagesAsync()
 {
     while (Connecting || Connected)
     {
         try
         {
             string message = inputStream.ReadLine();
             ReceiveMessage?.Invoke(this, new IrcMessageEventArgs(message));
         }
         catch
         {
             StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.Disconnected));
             Connected  = false;
             Connecting = false;
         }
     }
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Sends an IRC message to the server.
        /// </summary>
        /// <param name="message">Message to send</param>
        /// <returns>If message was successfully sent.</returns>
        public async Task <bool> SendIrcMessageAsync(string message)
        {
            try
            {
                await outputStream.WriteLineAsync(message);

                await outputStream.FlushAsync();

                return(true);
            }
            catch
            {
                Connected  = false;
                Connecting = false;
                StateChange?.Invoke(this, new IrcChangedEventArgs(IrcStates.Disconnected));
                return(false);
            }
        }