private void Window_Drop(object sender, System.Windows.DragEventArgs e)
        {
            // Show analysis result when saved files are dropped
            string[] paths = e.Data.GetData(System.Windows.DataFormats.FileDrop) as string[];

            if (paths.Length == 1)
            {
                // visualize single answer sheet
                string filepath = paths[0];
                if (System.IO.Path.GetExtension(filepath) == ".json")
                {
                    // Visualize answer sheet when 1 json file is dropped
                    PreviewWindow previewWindow = new PreviewWindow();
                    previewWindow.Show();
                    this.visualizer.VisualizeAnswerSheet(filepath, previewWindow.PreviewCanvas, previewWindow.StepGraphCanvas, true, false, true);
                }
                else if (Directory.Exists(filepath))
                {
                    // Group answer sheets when directory is dropped.
                    this.analyzer.GroupAnswerSheet(filepath);
                    AnswerGroupWindow groupWindow = new AnswerGroupWindow(this.analyzer, this.visualizer);
                    groupWindow.Show();
                }
            }
            else if (paths.Length == 2)
            {
                string filepath1 = paths[0];
                string filepath2 = paths[1];
                if (System.IO.Path.GetExtension(filepath1) == ".json"
                    && System.IO.Path.GetExtension(filepath2) == ".json")
                {
                    // visualize answer sheets comparison when 2 json files are dropped
                    ComparisonWindow comparisonWindow = new ComparisonWindow();
                    comparisonWindow.Show();
                    this.visualizer.VisualizeAnswerSheetComparison(filepath1, filepath2, comparisonWindow.PreviewCanvas1, comparisonWindow.PreviewCanvas2, comparisonWindow.GraphCanvas);
                }
            }
        }
 private void BtnGroupAnswerSheets_Click(object sender, RoutedEventArgs e)
 {
     FolderBrowserDialog fbd = new FolderBrowserDialog();
     fbd.Description = "Select directory which have answer sheet data (*.json)";
     fbd.RootFolder = Environment.SpecialFolder.Desktop;
     if (fbd.ShowDialog(this) == true)
     {
         this.analyzer.GroupAnswerSheet(fbd.SelectedPath);
         AnswerGroupWindow w = new AnswerGroupWindow(this.analyzer, this.visualizer);
         w.Show();
     }
 }
        /// <summary>
        /// Initialization with answer information
        /// </summary>
        /// <param name="ans"></param>
        /// <param name="controller"></param>
        /// <param name="w"></param>
        public AnswerSheetItemData(AnswerSheet ans, AnswerSheetVisualizer v, AnswerGroupWindow w)
        {
            this.parentWindow = w;
            this.answerData = ans;
            this.visualizer = v;
            this.strokes = new StrokeCollection();
            foreach (AnalysisPenStroke s in ans.Strokes)
            {
                this.strokes.Add(s.GetStrokeObject(Config.OutputThumbnailCanvasWidth, Config.OutputThumbnailCanvasHeight));
            }
            this.NameLabel = ans.Name;
            this.timeLabel = "Time: " + ((double)ans.AnswerTime / 1000.0).ToString("f3") + "(sec)";

            double writingRatio = ans.WritingRatio;
            this.writingTime = new GridLength(MaxWritingTime * writingRatio * 2.5);
            this.writingTimeLabel = (writingRatio * 100.0).ToString("F2") + "%";

            double speedAvg = ans.WritingSpeedAvg;
            this.writingSpeedAvg = new GridLength(MaxWritingTime * (speedAvg - 0.5));
            this.writingSpeedAvgLabel = speedAvg.ToString("F4");

            double speedVar = ans.WritingSpeedVar;
            this.writingSpeedVar = new GridLength(MaxWritingTime * speedVar);
            this.writingSpeedVarLabel = speedVar.ToString("F4");
        }
        /// <summary>
        /// Initialization with group information
        /// </summary>
        /// <param name="group"></param>
        /// <param name="controller"></param>
        /// <param name="w"></param>
        public AnswerGroupItemData(AnswerSheetGroup group, AnswerSheetVisualizer visualizer, AnswerGroupWindow w)
        {
            this.answerGroupData = group;
            this.groupNameLabel = group.Name;
            this.timeLabel = "Average Time: " + (group.GetAverageAnswerTime() / 1000.0).ToString("f3") + "(sec)";

            this.AnswerSheetData = new ObservableCollection<AnswerSheetItemData>();
            foreach (AnswerSheet ans in group.AnswerSheetList)
            {
                this.AnswerSheetData.Add(new AnswerSheetItemData(ans, visualizer, w));
            }

            // sort item by answer time
            this.AnswerSheetData = new ObservableCollection<AnswerSheetItemData>(this.AnswerSheetData.OrderBy(n => n.AnswerData.AnswerTime));
        }