Пример #1
0
        /// <summary>
        /// Adds an entry to the BestList
        /// </summary>
        /// <param name="score"></param>
        /// <param name="IoC1"></param>
        /// <param name="IoC2"></param>
        /// <param name="transkey"></param>
        /// <param name="transpositionResult"></param>
        public void AddNewBestListEntry(double score, double IoC1, double IoC2, String transkey, String transpositionResult)
        {
            try
            {
                var entry = new ResultEntry
                {
                    Score               = score,
                    Ic1                 = IoC1,
                    Ic2                 = IoC2,
                    TransKey            = transkey,
                    TranspositionResult = transpositionResult
                };

                if (((ADFGVXAnalyzerPresentation)Presentation).BestList.Count == 0)
                {
                }
                else if (entry.Score > ((ADFGVXAnalyzerPresentation)Presentation).BestList.First().Score)
                {
                }

                Presentation.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
                {
                    try
                    {
                        if (((ADFGVXAnalyzerPresentation)Presentation).BestList.Count > 0 && entry.Score <= ((ADFGVXAnalyzerPresentation)Presentation).BestList.Last().Score)
                        {
                            return;
                        }

                        //Insert new entry at correct place to sustain order of list:
                        var insertIndex = myPresentation.BestList.TakeWhile(e => e.Score > entry.Score).Count();
                        myPresentation.BestList.Insert(insertIndex, entry);

                        if (((ADFGVXAnalyzerPresentation)Presentation).BestList.Count > MaxBestListEntries)
                        {
                            ((ADFGVXAnalyzerPresentation)Presentation).BestList.RemoveAt(MaxBestListEntries);
                        }
                        var ranking = 1;
                        foreach (var e in ((ADFGVXAnalyzerPresentation)Presentation).BestList)
                        {
                            e.Ranking = ranking;
                            ranking++;
                        }
                    }
                    // ReSharper disable once EmptyGeneralCatchClause
                    catch (Exception)
                    {
                        //do nothing
                    }
                }, null);
            }
            catch (Exception ex)
            {
                GuiLogMessage("AddNewBestListEntry: " + ex.Message, NotificationLevel.Error);
            }
        }
Пример #2
0
 //Method to send a transactionhash by doubleclick
 private void getTranspositionResult(ResultEntry resultEntry)
 {
     try
     {
         TranspositionResult = resultEntry.TranspositionResult;
     }
     catch (Exception ex)
     {
         GuiLogMessage(ex.Message, NotificationLevel.Error);
     }
 }