static void Main(string[] args) { MED m = new MED("intention", "execution"); // m.Calculate(); //m.Show(); ReadKey(); }
private void Update() { DP.Children.Clear(); if (SelectedInput != string.Empty && SelectedGoal != string.Empty) { MED.MED med = MedList.First(x => x.Name == SelectedGoal); Viewbox vb = new Viewbox(); List <List <TextBlock> > tbl = new List <List <TextBlock> >(); TextBlock tb; StackPanel isp; StackPanel sp = new StackPanel() { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; for (int i = SelectedInput.Length - 1; i >= 0; i--) { string pasvalue = SelectedInput[i].ToString(); isp = new StackPanel() { Orientation = Orientation.Horizontal }; tb = new TextBlock { Width = 15, Text = pasvalue, Foreground = Brushes.Blue, Padding = new Thickness(3, 0, 3, 0) }; isp.Children.Add(tb); sp.Children.Add(isp); } isp = new StackPanel() { Orientation = Orientation.Horizontal }; tb = new TextBlock { Width = 15, Text = "#", Foreground = Brushes.Blue, Padding = new Thickness(3, 0, 3, 0) }; isp.Children.Add(tb); sp.Children.Add(isp); isp = new StackPanel() { Orientation = Orientation.Horizontal }; tb = new TextBlock { Width = 15, Text = " ", Foreground = Brushes.Blue, Padding = new Thickness(3, 0, 3, 0) }; isp.Children.Add(tb); sp.Children.Add(isp); isp = (sp.Children[sp.Children.Count - 1] as StackPanel); tb = new TextBlock { Width = 15, Text = "#", Foreground = Brushes.Blue, Padding = new Thickness(3, 0, 3, 0) }; isp.Children.Add(tb); foreach (var item in SelectedGoal) { string pasvalue = item.ToString(); isp = (sp.Children[sp.Children.Count - 1] as StackPanel); tb = new TextBlock { Width = 15, Text = pasvalue, Foreground = Brushes.Blue, Padding = new Thickness(3, 0, 3, 0) }; isp.Children.Add(tb); //sp.Children.Add(isp); } //vb.Child = sp; for (int i = 0; i < med.res.GetLength(0); i++) { List <TextBlock> tblis = new List <TextBlock>(); isp = (sp.Children[i] as StackPanel); for (int j = 0; j < med.res.GetLength(1); j++) { tb = new TextBlock { Width = 15, Text = med.res[i, j].ToString(), Foreground = Brushes.Black, Padding = new Thickness(3, 0, 3, 0) }; isp.Children.Add(tb); tblis.Add(tb); } tbl.Add(tblis); } int ith = med.res.GetLength(0) - 1; int ithtemp = med.res.GetLength(0) - 1; int jth = med.res.GetLength(1) - 1; tbl[ithtemp - ith][jth].Background = Brushes.LightGreen; foreach (var item in med.ResPtr) { if (item == trak.deletion) { ith = ith - 1; } else if (item == trak.insertion) { jth = jth - 1; } else { ith = ith - 1; jth = jth - 1; } tbl[ithtemp - ith][jth].Background = Brushes.LightGreen; } DP.Children.Add(sp); } alight(); }
private void alight() { string top = string.Empty, down = string.Empty; int iindex = 0, jindex = 0; if (SelectedInput != string.Empty && SelectedGoal != string.Empty) { MED.MED med = MedList.First(x => x.Name == SelectedGoal); for (int i = med.ResPtr.Count - 1; i >= 0; i--) { if (med.ResPtr[i] == trak.insertion) { top += "*"; down += SelectedGoal[jindex++]; } if (med.ResPtr[i] == trak.deletion) { top += SelectedInput[iindex++]; down += "*"; } if (med.ResPtr[i] == trak.substitution) { top += SelectedInput[iindex++]; down += SelectedGoal[jindex++]; } } } StackPanel sp = new StackPanel { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; StackPanel sp1 = new StackPanel { Height = 50, Orientation = Orientation.Horizontal }; StackPanel sp2 = new StackPanel { Height = 50, Orientation = Orientation.Horizontal }; StackPanel sp3 = new StackPanel { Height = 50, Orientation = Orientation.Horizontal }; sp.Children.Add(sp1); sp.Children.Add(sp2); sp.Children.Add(sp3); foreach (var item in top) { TextBlock tb = new TextBlock { Width = 50, Text = item.ToString(), TextAlignment = TextAlignment.Center, FontSize = 20 }; sp1.Children.Add(tb); } foreach (var item in top) { Path p = new Path { Data = Geometry.Parse("M7.2064977,0L14.334524,0C14.639518,0,14.843499,0.20404053,14.843499,0.5090332L14.843499,17.820007C14.843499,18.126038,15.04754,18.330017,15.352535,18.330017L20.138569,18.330017C21.36056,18.330017,21.767544,19.042053,20.953576,20.061035L11.788491,31.466003C11.279516,32.17804,10.159516,32.17804,9.6495032,31.466003L0.3834657,19.857056C-0.32955072,19.042053,-0.023579955,18.330017,1.0964209,18.330017L6.1874495,18.330017C6.4934817,18.330017,6.6964855,18.126038,6.6964855,17.820007L6.6964855,0.5090332C6.6964855,0.20404053,6.900466,0,7.2064977,0z"), Width = 50, Stretch = Stretch.Uniform, Fill = Brushes.DarkRed, Stroke = Brushes.Black, StrokeThickness = 0.1 }; sp2.Children.Add(p); } foreach (var item in down) { TextBlock tb = new TextBlock { Width = 50, Text = item.ToString(), TextAlignment = TextAlignment.Center, FontSize = 20 }; sp3.Children.Add(tb); } alignment.Children.Clear(); alignment.Children.Add(sp); //Console.WriteLine(top); //Console.WriteLine(down); }