private void ClearResult() { for (int i = 0; i < CA_Main.Children.Count; i++) { Button b = CA_Main.Children[i] as Button; if (b != null) { ButtonProperty bp = b.Tag as ButtonProperty; if (bp.Type == 4 || bp.Type == 5) { bp.Type = 0; bp.Distance = -1; bp.EvaDistance = -1; bp.Parent = -1; b.Style = this.FindResource("CommonButtonStyle") as Style; } if (b.Content != null) { ArrowControl ar = b.Content as ArrowControl; ar.SetDistance(0); ar.SetEvaDistance(0); ar.SetSumDistance(0); if (ar != null) { ar.Visibility = Visibility.Hidden; } } } } }
private void ShowResult(ResultCollection ret) { if (ret.parentMap != null) { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { Button b = buttonMap[i, j]; ArrowControl arrow = b.Content as ArrowControl; ButtonProperty bp = buttonMap[i, j].Tag as ButtonProperty; if (ret.parentMap[i, j] != -1) { arrow.Visibility = Visibility.Visible; bp.Parent = ret.parentMap[i, j]; arrow.SetDirection(ret.parentMap[i, j]); } } } } if (ret.resultMap != null) { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { Button b = buttonMap[i, j]; ButtonProperty bp = buttonMap[i, j].Tag as ButtonProperty; int type = ret.resultMap[i, j]; if (type == 4) { b.Style = FindResource("PathButtonStyle") as Style; bp.Type = type; b.Tag = bp; } if (type == 5) { b.Style = FindResource("TraveledButtonStyle") as Style; bp.Type = type; b.Tag = bp; } } } } if (ret.distanceMap != null) { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { Button b = buttonMap[i, j]; ArrowControl arrow = b.Content as ArrowControl; ButtonProperty bp = buttonMap[i, j].Tag as ButtonProperty; if (ret.distanceMap[i, j] != int.MaxValue) { arrow.Visibility = Visibility.Visible; bp.Parent = ret.parentMap[i, j]; bp.Distance = ret.distanceMap[i, j]; if (ret.evaDistanceMap != null) { bp.EvaDistance = ret.evaDistanceMap[i, j]; } arrow.SetDistance(ret.distanceMap[i, j]); if (ret.evaDistanceMap != null) { arrow.SetEvaDistance(ret.evaDistanceMap[i, j]); } else { arrow.SetEvaDistance(0); } if (ret.evaDistanceMap != null) { arrow.SetSumDistance(ret.distanceMap[i, j] + ret.evaDistanceMap[i, j]); } else { arrow.SetEvaDistance(0); } } } } } }