예제 #1
0
        private bool AreUsersReadyToJoinGroup(StatusNotifier inviteMessage)
        {
#warning sprawdz nie tylko liste zaproszen ale tez liste gotowych grup
            if (clientsGroupInvites != null)
            {
                lock (syncRootGroupsInvites)
                {
                    for (int i = 0; i < clientsGroupInvites.Count; i++)
                    {
                        var group = clientsGroupInvites[i];
                        var groupClientsUsernames = group.LoggedClients.Select(c => c.Username);
                        for (int j = 0; j < inviteMessage.Usernames.Count; ++j)
                        {
                            var  username = inviteMessage.Usernames[j];
                            bool groupContainsUsername = groupClientsUsernames.Contains(username);
                            if (groupContainsUsername)
                            {
                                return(false);
                            }
                        }
                    }
                }
            }
            return(true);
        }
예제 #2
0
 private void CreateGroupAndInviteClients(LoggedClient loggedClient, StatusNotifier inviteMessage)
 {
     lock (syncRootGroupsInvites)
     {
         var groupClientsList = new List <LoggedClient>()
         {
             loggedClient
         };
         var invitedUsernames = inviteMessage.Usernames;
         for (int i = 0; i < invitedUsernames.Count; ++i)
         {
             var client = loggedClients.Where(x => x.Username == invitedUsernames[i]).FirstOrDefault();
             if (client != null)
             {
                 groupClientsList.Add(client);
             }
         }
         if (groupClientsList.Count > 1)
         {
             var group = new ClientsGroupInvite(groupClientsList);
             group.GroupInviteTimeout += Group_GroupInviteTimeout;
             group.GroupCreated       += Group_GroupCreated;
             clientsGroupInvites.Add(group);
         }
     }
 }
예제 #3
0
 private void InviteUsersToGroup(LoggedClient loggedClient, BaseMessage baseMessage)
 {
     try
     {
         StatusNotifier inviteMessage = null;
         try
         {
             inviteMessage = StatusNotifier.Deserialize(baseMessage);
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine(ex.Message);
         }
         if (inviteMessage != null)
         {
             if (AreUsersReadyToJoinGroup(inviteMessage))
             {
                 CreateGroupAndInviteClients(loggedClient, inviteMessage);
             }
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
 }
예제 #4
0
        private void NotifyNewClientHasConnected(string newClientUsername)
        {
            var allLoggedClients = loggedClients;

            if (allLoggedClients != null)
            {
                for (int i = 0; i < allLoggedClients.Count; ++i)
                {
                    var me         = allLoggedClients[i];
                    var myUsername = me.Username;
                    if (myUsername != newClientUsername)
                    {
                        var myFriends                = allLoggedClients.Where(x => x.Username != myUsername).Select(u => u.Username).ToList();
                        var statusNotifier           = new StatusNotifier(false, myFriends);
                        var serializedStatusNotifier = MessagesSerializer.Serialize(statusNotifier);
                        var baseMessage              = new BaseMessage(MessageType.StatusNotifier, serializedStatusNotifier);
                        var serializedBaseMessage    = MessagesSerializer.Serialize(baseMessage);
                        try
                        {
                            me.SendMessage(serializedBaseMessage);
                        }
                        catch { }
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Asynchronously initializes startup flow
        /// </summary>
        public async void StartAsync(StartupManager sm)
        {
            var startupResults = await sm.ManageStartupAsync();

            StartupManagerExitCode = startupResults;

            switch (startupResults)
            {
            case StartupManagerExitCode.Success:
                StatusNotifier.Print("Starting...");
                break;

            case StartupManagerExitCode.UpdateFailedButNotRequired:
                StatusNotifier.Print("Update not currently possible, starting installed version...");
                break;

            case StartupManagerExitCode.UpdateRequiredButFailed:
                // Configuration requires to make sure app is always most recent
                StatusNotifier.Print("Update not possible. Application cannot be started.");
                StatusNotifier.IsTryAgainVisible = true;
                MessageBox.Show(
                    messageBoxText: "Application could not be started. Check your network and try again.",
                    caption: "Application not started",
                    button: MessageBoxButton.OK,
                    icon: MessageBoxImage.Error);
                break;

            case StartupManagerExitCode.InstallationFailed:
                StatusNotifier.Print("Installation failed. Application cannot be started.");
                StatusNotifier.IsTryAgainVisible = true;
                MessageBox.Show(
                    messageBoxText: "Application could not be installed. Check your network and try again.",
                    caption: "Application not started",
                    button: MessageBoxButton.OK,
                    icon: MessageBoxImage.Error);
                break;

            default:
                break;
            }
            if (ConfigurationProvider.IsLoggerOn)
            {
                Logger.DumpToFile();
            }
            // close
            if (startupResults == StartupManagerExitCode.Success ||
                startupResults == StartupManagerExitCode.UpdateFailedButNotRequired)
            {
                StartupManager.StartProcess(ConfigurationProvider);
                CloseWithDelayAsync(2000);
            }
        }
예제 #6
0
 public KinectHandler()
 {
     if (deviceConnectionTest())
     {
         sensor = KinectSensor.KinectSensors[0];
         sensor = KinectSensor.KinectSensors.FirstOrDefault(sensorItem => sensorItem.Status == KinectStatus.Connected);
         //Console.WriteLine(sensor.UniqueKinectId);
     }
     else
     {
         System.Windows.Forms.MessageBox.Show("No Kinect device connected", "Device Connection Error",
                                              MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     notifier = new StatusNotifier();
 }
예제 #7
0
 private void InviteUsers()
 {
     if (LoggedClients != null)
     {
         var usernames     = LoggedClients.Select(x => x.Username).ToList();
         var inviteMessage = new StatusNotifier(true, usernames);
         inviteMessage.GroupSize = usernames.Count;
         var serializedInviteMessage = MessagesSerializer.Serialize(inviteMessage);
         var baseMessage             = new BaseMessage(MessageType.StatusNotifier, serializedInviteMessage);
         var seriazlizedBaseMessage  = MessagesSerializer.Serialize(baseMessage);
         for (int i = 0; i < LoggedClients.Count; ++i)
         {
             var loggedClient = LoggedClients[i];
             try
             {
                 loggedClient.SendMessage(seriazlizedBaseMessage);
             }
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.WriteLine(ex.Message);
             }
         }
     }
 }
예제 #8
0
 public static void UpdateModel( UmlModel model, out ArrayList errors, StatusNotifier sn )
 {
     ModelBuilder mb = new ModelBuilder();
     mb.model = model;
     mb.notify = sn;
     mb.Update();
     errors = mb.errors.Count > 0 ? mb.errors : null;
 }