Пример #1
0
 private void doppelClick(object sender, EventArgs e)
 {
     try
     {
         ListViewItem lvi = sender as ListViewItem;
         ResultEntry  rse = lvi.Content as ResultEntry;
         Output = System.Text.Encoding.GetEncoding(1252).GetBytes(rse.Text);
     }
     catch (Exception ex)
     {
     }
 }
Пример #2
0
        string entryToText(ResultEntry entry)
        {
            string keyword = getKeyword(entry.KeyArray);

            string key = String.IsNullOrEmpty(keyword)
                ? "Key: " + String.Join(" ", entry.KeyArray)
                : "Key (numeric): " + String.Join(" ", entry.KeyArray) + "\n" + "Key (alphabetic): " + keyword;

            return("Rank: " + entry.Ranking + "\n" +
                   "Value: " + entry.Value + "\n" +
                   key + "\n" +
                   "Text: " + entry.Text);
        }
Пример #3
0
        public void ContextMenuHandler(Object sender, EventArgs eventArgs)
        {
            MenuItem    menu  = (MenuItem)((RoutedEventArgs)eventArgs).Source;
            ResultEntry entry = (ResultEntry)menu.CommandParameter;

            if (entry == null)
            {
                return;
            }

            if ((string)(menu.Tag) == "copy_text")
            {
                Clipboard.SetText(entry.Text);
            }
            else if ((string)(menu.Tag) == "copy_value")
            {
                Clipboard.SetText(entry.Value);
            }
            else if ((string)(menu.Tag) == "copy_key")
            {
                Clipboard.SetText(entry.Key);
            }
            else if ((string)(menu.Tag) == "copy_line")
            {
                Clipboard.SetText(entryToText(entry));
            }
            else if ((string)(menu.Tag) == "copy_all")
            {
                List <string> lines = new List <string>();
                foreach (var e in entries)
                {
                    lines.Add(entryToText(e));
                }
                Clipboard.SetText(String.Join("\n\n", lines));
            }
        }
Пример #4
0
        private void showProgress(DateTime startTime, ulong totalKeys, ulong doneKeys)
        {
            if (!Presentation.IsVisible || stop)
            {
                return;
            }

            long ticksPerSecond = 10000000;

            TimeSpan elapsedtime  = DateTime.Now.Subtract(startTime);
            double   totalSeconds = elapsedtime.TotalSeconds;

            if (totalSeconds == 0)
            {
                totalSeconds = 0.001;
            }
            elapsedtime = new TimeSpan(elapsedtime.Ticks - (elapsedtime.Ticks % ticksPerSecond));   // truncate to seconds

            TimeSpan timeleft = new TimeSpan();
            DateTime endTime  = new DateTime();
            double   secstodo;

            double keysPerSec = doneKeys / totalSeconds;

            if (keysPerSec > 0)
            {
                if (totalKeys < doneKeys)
                {
                    totalKeys = doneKeys;
                }
                secstodo = (totalKeys - doneKeys) / keysPerSec;
                timeleft = new TimeSpan((long)secstodo * ticksPerSecond);
                endTime  = DateTime.Now.AddSeconds(secstodo);
                endTime  = new DateTime(endTime.Ticks - (endTime.Ticks % ticksPerSecond));  // truncate to seconds
            }

            ((TranspositionAnalyserQuickWatchPresentation)Presentation).Dispatcher.BeginInvoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
            {
                var culture = System.Threading.Thread.CurrentThread.CurrentUICulture;

                myPresentation.startTime.Content     = "" + startTime;
                myPresentation.keysPerSecond.Content = String.Format(culture, "{0:##,#}", (ulong)keysPerSec);

                if (keysPerSec > 0)
                {
                    myPresentation.timeLeft.Content    = "" + timeleft;
                    myPresentation.elapsedTime.Content = "" + elapsedtime;
                    myPresentation.endTime.Content     = "" + endTime;
                }
                else
                {
                    myPresentation.timeLeft.Content = "incalculable";
                    myPresentation.endTime.Content  = "in a galaxy far, far away...";
                }

                myPresentation.entries.Clear();

                for (int i = 0; i < TOPLIST.Count; i++)
                {
                    ValueKey v        = TOPLIST[i];
                    ResultEntry entry = new ResultEntry();

                    entry.Ranking  = (i + 1).ToString();
                    entry.Value    = String.Format("{0:0.00000}", v.score);
                    entry.KeyArray = v.key;
                    entry.Key      = "[" + String.Join(",", v.key) + "]";
                    entry.Text     = Encoding.GetEncoding(1252).GetString(v.plaintext);

                    myPresentation.entries.Add(entry);
                }
            }
                                                                                               , null);
        }