private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (sender is TabControl t) { if (t.SelectedIndex == 1) { var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build(); var result = Properties.Resources.MarkdownStyleHead + "\n" + Markdown.ToHtml(Description.Text, pipeline) + "\n" + Properties.Resources.MarkdownStyleTail; var curDir = AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/"); if (curDir.EndsWith("/")) { curDir = curDir.Substring(0, curDir.Length - 1); } result = result.Replace("${ExtensionsDir}", "file://" + curDir + "/Extensions"); curDir = Environment.GetEnvironmentVariable("temp"); if (curDir.EndsWith("\\")) { curDir = curDir.Substring(0, curDir.Length - 1); } if (!string.IsNullOrEmpty(_curAddress)) { try { File.Delete(_curAddress); } catch { //ignored } } _curAddress = curDir + "\\" + Guid.NewGuid().ToString() + ".html"; File.WriteAllText(_curAddress, result, Encoding.Unicode); DescriptionViewer.Navigate(new Uri(_curAddress)); } } }
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!(ListView.SelectedItem is Problem problem)) { return; } ProblemName.Text = problem.ProblemName; SpecialJudge.Text = problem.SpecialJudge; ExtraFiles.Text = StringArrCastToString(problem.ExtraFiles); InputFileName.Text = problem.InputFileName; OutputFileName.Text = problem.OutputFileName; CompileCommand.Text = problem.CompileCommand; AddDate.Content = problem.AddDate; DataSetsNumber.Text = problem.DataSets?.Length.ToString() ?? "0"; Level.Value = Convert.ToInt32(problem.Level); LevelShow.Content = Level.Value; Public.IsChecked = (problem.Option & 1) != 0; Description.Text = string.IsNullOrEmpty(problem.Description) ? Connection.GetProblemDescription(problem.ProblemId) : problem.Description; var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build(); var result = Properties.Resources.MarkdownStyleHead + "\n" + Markdown.ToHtml(Description.Text, pipeline) + "\n" + Properties.Resources.MarkdownStyleTail; var curDir = AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/"); if (curDir.EndsWith("/")) { curDir = curDir.Substring(0, curDir.Length - 1); } result = result.Replace("${ExtensionsDir}", "file://" + curDir + "/Extensions"); curDir = Environment.GetEnvironmentVariable("temp"); if (curDir.EndsWith("\\")) { curDir = curDir.Substring(0, curDir.Length - 1); } if (!string.IsNullOrEmpty(_curAddress)) { try { File.Delete(_curAddress); } catch { //ignored } } _curAddress = curDir + "\\" + Guid.NewGuid().ToString() + ".html"; File.WriteAllText(_curAddress, result, Encoding.Unicode); DescriptionViewer.Navigate(new Uri(_curAddress)); var a = problem.DataSets?.Length ?? 0; DataSetsNumber.Text = a.ToString(); while (ListBox.Items.Count > a) { foreach (var t in ListBox.Items) { if ((t as Grid)?.Name == $"Data{ListBox.Items.Count}") { (t as Grid).Children.Clear(); } } ListBox.Items.RemoveAt(ListBox.Items.Count - 1); } while (ListBox.Items.Count < a) { var strreader = new StringReader( Properties.Resources.DataSetControl.Replace("${index}", (ListBox.Items.Count + 1).ToString())); var xmlreader = new XmlTextReader(strreader); var obj = XamlReader.Load(xmlreader); ListBox.Items.Add((UIElement)obj); } for (var i = 0; i < ListBox.Items.Count; i++) { foreach (var t in ListBox.Items) { if ((t as Grid)?.Name != $"Data{i + 1}") { continue; } var b = (t as Grid).FindName($"Input{i + 1}") as TextBox; if (b != null) { b.Text = problem.DataSets?[i]?.InputFile ?? string.Empty; } b = (t as Grid).FindName($"Output{i + 1}") as TextBox; if (b != null) { b.Text = problem.DataSets?[i]?.OutputFile ?? string.Empty; } b = (t as Grid).FindName($"Time{i + 1}") as TextBox; if (b != null) { b.Text = problem.DataSets?[i]?.TimeLimit.ToString() ?? string.Empty; } b = (t as Grid).FindName($"Memory{i + 1}") as TextBox; if (b != null) { b.Text = problem.DataSets?[i]?.MemoryLimit.ToString() ?? string.Empty; } b = (t as Grid).FindName($"Score{i + 1}") as TextBox; if (b != null) { b.Text = problem.DataSets?[i]?.Score.ToString(CultureInfo.CurrentCulture) ?? string.Empty; } } } }