private void showQuestionMark(Point point) { leftSide.Opacity = 0; rightSide.Opacity = 0; upSide.Opacity = 0; downSide.Opacity = 0; double height = Application.Current.RootVisual.RenderSize.Height; double width = Application.Current.RootVisual.RenderSize.Width; bool found = false; PanoramaItem panoramaItem; FrameworkElement item = (FrameworkElement)this.FindName(itemID); var parent = item.Parent; while (parent.GetType() != typeof(PanoramaItem) && parent != null) { parent = ((FrameworkElement)parent).Parent; } if (parent.GetType() == typeof(PanoramaItem)) { panoramaItem = (PanoramaItem)parent; Debug.WriteLine("look up"); if (pagePanorama.Items.IndexOf(panoramaItem) != pagePanorama.SelectedIndex) { int count = 0; foreach (PanoramaItem pi in pagePanorama.Items) { if (pi.Visibility == Visibility.Visible) { count++; } } int leftSteps = 0; int rightSteps = 0; int index = pagePanorama.SelectedIndex; while (index != pagePanorama.Items.IndexOf(panoramaItem)) { index++; rightSteps++; if (index == count) { index = 0; } } index = pagePanorama.SelectedIndex; while (index != pagePanorama.Items.IndexOf(panoramaItem)) { index--; leftSteps++; if (index == -1) { index = count - 1; } } //Debug.WriteLine("da is er: " + pagePanorama.SelectedIndex + " da will ich hin:" + pagePanorama.Items.IndexOf(panoramaItem) + "(left:" + leftSteps + ", right:" + rightSteps); if (leftSteps < rightSteps) { point.X = 10; leftSide.Opacity = 1; Debug.WriteLine("left out"); } else { point.X = width - 50; rightSide.Opacity = 1; Debug.WriteLine("right out"); } } else { if (point.Y < 280) { point.Y = 280; upSide.Opacity = 1; } if (point.Y > height - 110) { point.Y = height - 110; downSide.Opacity = 1; } } } OpenPoint.SetValue(Canvas.LeftProperty, point.X); OpenPoint.SetValue(Canvas.TopProperty, point.Y); OpenPointQuestionMark.SetValue(Canvas.LeftProperty, point.X); OpenPointQuestionMark.SetValue(Canvas.TopProperty, point.Y); upSide.SetValue(Canvas.LeftProperty, point.X); upSide.SetValue(Canvas.TopProperty, point.Y - 12); downSide.SetValue(Canvas.LeftProperty, point.X); downSide.SetValue(Canvas.TopProperty, point.Y + 12); leftSide.SetValue(Canvas.LeftProperty, point.X - 12); leftSide.SetValue(Canvas.TopProperty, point.Y); rightSide.SetValue(Canvas.LeftProperty, point.X + 12); rightSide.SetValue(Canvas.TopProperty, point.Y); showOpenPoint.Begin(); }
private void updateOpenPoint(object sender, EventArgs e) { try { if (itemID != "") { var transform = ((FrameworkElement)(this.FindName(itemID))).TransformToVisual(Application.Current.RootVisual); Point point = transform.Transform(new Point(0, 0)); leftSide.Opacity = 0; rightSide.Opacity = 0; upSide.Opacity = 0; downSide.Opacity = 0; double height = Application.Current.RootVisual.RenderSize.Height; double width = Application.Current.RootVisual.RenderSize.Width; bool found = false; PanoramaItem panoramaItem; FrameworkElement item = (FrameworkElement)this.FindName(itemID); var parent = item.Parent; while (parent.GetType() != typeof(PanoramaItem) && parent != null) { parent = ((FrameworkElement)parent).Parent; } if (parent.GetType() == typeof(PanoramaItem)) { panoramaItem = (PanoramaItem)parent; zahl++; if (pagePanorama.Items.IndexOf(panoramaItem) != pagePanorama.SelectedIndex) { int count = 0; foreach (PanoramaItem pi in pagePanorama.Items) { if (pi.Visibility == Visibility.Visible) { count++; } } int leftSteps = 0; int rightSteps = 0; int index = pagePanorama.SelectedIndex; while (index != pagePanorama.Items.IndexOf(panoramaItem)) { index++; rightSteps++; if (index == count) { index = 0; } } index = pagePanorama.SelectedIndex; while (index != pagePanorama.Items.IndexOf(panoramaItem)) { index--; leftSteps++; if (index == -1) { index = count - 1; } } //Debug.WriteLine("da is er: " + pagePanorama.SelectedIndex + " da will ich hin:" + pagePanorama.Items.IndexOf(panoramaItem) + "(left:" + leftSteps + ", right:" + rightSteps); if (leftSteps < rightSteps) { point.X = 10; leftSide.Opacity = 1; } else { point.X = width - 50; rightSide.Opacity = 1; } } else { if (point.Y < 280) { point.Y = 280; upSide.Opacity = 1; } if (point.Y > height - 110) { point.Y = height - 110; downSide.Opacity = 1; } } OpenPoint.SetValue(Canvas.LeftProperty, point.X); OpenPoint.SetValue(Canvas.TopProperty, point.Y); OpenPointQuestionMark.SetValue(Canvas.LeftProperty, point.X); OpenPointQuestionMark.SetValue(Canvas.TopProperty, point.Y); upSide.SetValue(Canvas.LeftProperty, point.X); upSide.SetValue(Canvas.TopProperty, point.Y - 12); downSide.SetValue(Canvas.LeftProperty, point.X); downSide.SetValue(Canvas.TopProperty, point.Y + 12); leftSide.SetValue(Canvas.LeftProperty, point.X - 12); leftSide.SetValue(Canvas.TopProperty, point.Y); rightSide.SetValue(Canvas.LeftProperty, point.X + 12); rightSide.SetValue(Canvas.TopProperty, point.Y); } } else { timer.Stop(); } } catch { timer.Stop(); } }