コード例 #1
0
        private void OpenInBrowser(object sender, RoutedEventArgs e)
        {
            A11yData selectedItem = (A11yData)IssueGrid.SelectedItem;

            System.Diagnostics.Process.Start(selectedItem.url);
        }
コード例 #2
0
        /// <summary>
        /// Save the file.
        /// Right now called with ctr-enter on editor, or clicking the save to file button.
        /// Also reloads the HTML and scrolls to element (but element no longer has red border).
        /// </summary>
        private void SaveFile()
        {
            if (curPage == null)
            {
                return;
            }
            var newNode = HtmlNode.CreateNode(editor.Text);

            curNode.ParentNode.ReplaceChild(newNode, curNode);
            curNode = newNode;
            A11yData selectedItem = (A11yData)IssueGrid.SelectedItem;
            var      index        = data.IndexOf(selectedItem);

            data[index].Completed = !data[index].Completed;
            if (isCanvas)
            {
                string location      = curCanvasItem.Keys.ElementAt(0);
                int    pageInfoIndex = course.PageInfoList.IndexOf(curCanvasItem);
                string question_id   = selectedItem.Location.CleanSplit("?").LastOrDefault().CleanSplit("&").FirstOrDefault().CleanSplit("=").LastOrDefault();
                if (!selectedItem.Location.Contains("question_num"))
                {
                    question_id = "";
                }
                string answer_id = selectedItem.Location.CleanSplit("?").LastOrDefault().CleanSplit("&").LastOrDefault().CleanSplit("=").LastOrDefault();
                if (!selectedItem.Location.Contains("answer_num"))
                {
                    answer_id = "";
                }
                bool comment = selectedItem.Location.Contains("answer_comment");
                course.PageInfoList[pageInfoIndex][location] = curCanvasItem[location]
                                                               .SaveContent(course.CourseIdOrPath,
                                                                            curPage.Doc.DocumentNode.OuterHtml,
                                                                            question_id,
                                                                            answer_id,
                                                                            comment,
                                                                            out bool saved
                                                                            );
                if (!saved)
                {
                    System.Windows.MessageBox.Show("Failed to save item to canvas");
                }
            }
            else
            {
                curPage.Doc.Save(curPage.Location);
            }
            if (data.Count <= IssueGrid.SelectedIndex + 1)
            {
            }
            else
            {
                if (MoveGridRowTimer.ElapsedMilliseconds > 300)
                {
                    MoveGridRowTimer.Restart();
                    IssueGrid.SelectedIndex = IssueGrid.SelectedIndex + 1;
                }
            }
            ViewSource.View.Refresh();
            SetCurrentNode();
            //ViewSource.View.Refresh();
            //browser.LoadHtmlAndWait(curPage.Doc.DocumentNode.OuterHtml);
            //browser.QueueScriptCall($"var el = document.getElementById('focus_this'); el.scrollIntoView({{behavior: 'smooth' , block: 'center', inline: 'center'}});");
        }