private string EventualeTagDaImpronta(FileInfo finfo)
        {
            string tag = null;

            // Devo cercare se nella lista delle persone sconosciute esiste un record
            // dello stesso range temporale della foto (compreso dei secondi di scarto configurati)
            for (int ii = 0; ii < personeSconosciute.Count; ii++)
            {
                Sconosciuto sconosciuto = personeSconosciute[ii];

                // Timestamp di quando è stata scansionata l'impronta
                DateTime tempoImpronta = sconosciuto.tempo;
                // Timestamp di quando è stata scattata la foto (e trasferita sul pc)
                DateTime tempoFoto = finfo.CreationTime;

                if (tempoFoto >= tempoImpronta.AddSeconds(userConfigOnRide.secDiscesaMin)
                    &&
                    tempoFoto <= tempoImpronta.AddSeconds(userConfigOnRide.secDiscesaMax)
                    )
                {
                    // Ok associo
                    tag = sconosciuto.nome;
                    personeSconosciute.RemoveAt(ii);
                    break;
                }
            }


            return(tag);
        }
Beispiel #2
0
            /// <summary>
            /// Resizes the map using the Null Insert method
            /// </summary>
            /// <param name="newWidth"></param>
            /// <param name="newHeight"></param>
            private void NullInsertResize(short newWidth, short newHeight)
            {
                using (ObservableCollectionEx <byte?> safeMapData = this.data.DisableNotifications())
                {
                    //TODO merge a bunch of stuff in here
                    if (newWidth > width)
                    {
                        for (int i = height - 1; i >= 0; i--)
                        {
                            for (int _i = width; _i < newWidth; _i++)
                            {
                                safeMapData.Insert(width + (i * width), null);
                            }
                        }
                    }
                    else if (newWidth < width)
                    {
                        for (int i = height - 1; i >= 0; i--)
                        {
                            for (int _i = width; _i > newWidth; _i--)
                            {
                                safeMapData.RemoveAt((i * width) + newWidth);
                            }
                        }
                    }
                    this.width = newWidth;

                    if (newHeight > height)
                    {
                        for (int i = 0; i < width * (newHeight - height); i++)
                        {
                            if ((height * width) + i < safeMapData.Count)
                            {
                                safeMapData[(height * width) + i] = null;
                            }
                            else
                            {
                                safeMapData.Insert((height * width) + i, null);
                            }
                        }
                    }
                    else if (newHeight < height)
                    {
                        while (safeMapData.Count > newHeight * newWidth)
                        {
                            safeMapData.RemoveAt(safeMapData.Count - 1);
                        }
                    }
                    this.height = newHeight;
                }
            }
        public void LoginModeTracksAvailableConnections()
        {
            var connectionManager    = Substitute.For <IConnectionManager>();
            var connections          = new ObservableCollectionEx <IConnection>();
            var gitHubLogin          = Substitute.For <ILoginToGitHubViewModel>();
            var enterpriseLogin      = Substitute.For <ILoginToGitHubForEnterpriseViewModel>();
            var gitHubConnection     = Substitute.For <IConnection>();
            var enterpriseConnection = Substitute.For <IConnection>();

            connectionManager.Connections.Returns(connections);
            gitHubConnection.HostAddress.Returns(HostAddress.GitHubDotComHostAddress);
            enterpriseConnection.HostAddress.Returns(HostAddress.Create("https://enterprise.url"));
            gitHubConnection.IsLoggedIn.Returns(true);
            enterpriseConnection.IsLoggedIn.Returns(true);

            var loginViewModel = new LoginCredentialsViewModel(connectionManager, gitHubLogin, enterpriseLogin);

            Assert.Equal(LoginMode.DotComOrEnterprise, loginViewModel.LoginMode);

            connections.Add(enterpriseConnection);
            Assert.Equal(LoginMode.DotComOnly, loginViewModel.LoginMode);

            connections.Add(gitHubConnection);
            Assert.Equal(LoginMode.None, loginViewModel.LoginMode);

            connections.RemoveAt(0);
            Assert.Equal(LoginMode.EnterpriseOnly, loginViewModel.LoginMode);
        }
Beispiel #4
0
        private void UpdatePeerStatus(UpdateStatusMessage message)
        {
            if (message.header.Receiver == this.name)
            {
                TempBuilding b;

                lock (_lLock)
                {
                    for (int i = 0; i < _buildings.Count; i++)
                    {
                        if (_buildings[i].Name == message.header.Sender)
                        {
                            //Workaround for observable issue...
                            b = _buildings[i];

                            b.EnBought = message.energyBought;
                            b.EnSold   = message.energySold;

                            _buildings.RemoveAt(i);
                            _buildings.Add(b);

                            break;
                        }
                    }
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Deletes the current account.
        /// </summary>
        private void DeleteAccount()
        {
            if ((_index < 0) || (_index >= _accounts.Count))
            {
                _delete.RaiseCanExecuteChanged();
                return;
            }

            var index = _index;

            try
            {
                _accounts.RemoveAt(index);

                while (index >= _accounts.Count)
                {
                    index--;
                }

                SelectedIndex = index;
            }
            finally
            {
                SaveState();
            }
        }
        public void LoginModeIgnoresAvailableConnections()
        {
            // We always want to option to log-in to GitHub or GitHub Enterprise

            var connectionManager    = Substitute.For <IConnectionManager>();
            var connections          = new ObservableCollectionEx <IConnection>();
            var gitHubLogin          = Substitute.For <ILoginToGitHubViewModel>();
            var enterpriseLogin      = Substitute.For <ILoginToGitHubForEnterpriseViewModel>();
            var gitHubConnection     = Substitute.For <IConnection>();
            var enterpriseConnection = Substitute.For <IConnection>();

            connectionManager.Connections.Returns(connections);
            gitHubConnection.HostAddress.Returns(HostAddress.GitHubDotComHostAddress);
            enterpriseConnection.HostAddress.Returns(HostAddress.Create("https://enterprise.url"));
            gitHubConnection.IsLoggedIn.Returns(true);
            enterpriseConnection.IsLoggedIn.Returns(true);

            var loginViewModel = new LoginCredentialsViewModel(connectionManager, gitHubLogin, enterpriseLogin);

            Assert.That(LoginMode.DotComOrEnterprise, Is.EqualTo(loginViewModel.LoginMode));

            connections.Add(enterpriseConnection);
            Assert.That(LoginMode.DotComOrEnterprise, Is.EqualTo(loginViewModel.LoginMode));

            connections.Add(gitHubConnection);
            Assert.That(LoginMode.DotComOrEnterprise, Is.EqualTo(loginViewModel.LoginMode));

            connections.RemoveAt(0);
            Assert.That(LoginMode.DotComOrEnterprise, Is.EqualTo(loginViewModel.LoginMode));
        }
Beispiel #7
0
        public void AddBufferToHistory()
        {
            if (!_SaveHistory)
            {
                return;
            }

            if (_Undo.Count >= 100)
            {
                _Undo.RemoveAt(0);
            }

            _Undo.Add(buffer.ToArray());
            buffer.Clear();

            ClearRedoHistory();
        }
Beispiel #8
0
        /// <summary>
        /// Sort Playlist by Rally-Number
        /// </summary>
        public void Sort()
        {
            List <Guid> sorted = rallyIDs.OrderBy(x => match.Rallies.Where <Rally>(r => r.ID == x).FirstOrDefault <Rally>().Number).ToList();
            int         ptr    = 0;

            while (ptr < sorted.Count)
            {
                if (!rallyIDs[ptr].Equals(sorted[ptr]))
                {
                    Guid t = rallyIDs[ptr];
                    rallyIDs.RemoveAt(ptr);
                    rallyIDs.Insert(sorted.IndexOf(t), t);
                }
                else
                {
                    ptr++;
                }
            }
        }