-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
110 lines (90 loc) · 3.54 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Maps.MapControl.WPF;
namespace SharkViz
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = new SharkViewModel();
map.Focus();
}
private void Canvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
/*
Ellipse ellipse = new Ellipse();
ellipse.MaxHeight = ellipseDiameter;
ellipse.MaxWidth = ellipseDiam///eter;
ellipse.Height = ellipseDiameter;
ellipse.Width = ellipseDiameter;
var gradientStops = new GradientStopCollection();
Color red = Brushes.Red.Color;
red.A = 128;
Color yellow = Brushes.Yellow.Color;
yellow.A = 64;
Color blue = Brushes.Blue.Color;
blue.A = 0;
gradientStops.Add(new GradientStop(red, 0.0));
gradientStops.Add(new GradientStop(yellow, 0.50));
//gradientStops.Add(new GradientStop(Brushes.Green.Color, 0.75));
gradientStops.Add(new GradientStop(blue, 1.0));
//gradientStops.Add(new GradientStop(Brushes.Red.Color, 0.0));
//gradientStops.Add(new GradientStop(Brushes.Green.Color, 0.5));
//gradientStops.Add(new GradientStop(Brushes.Blue.Color, 1.0));
var brush = new RadialGradientBrush(gradientStops);
//brush.ColorInterpolationMode = ColorInterpolationMode.ScRgbLinearInterpolation;
ellipse.Fill = brush;
//ellipse.Fill = new RadialGradientBrush(Color.FromArgb(128, 0, 0, 0), Color.FromArgb(0, 0, 0, 0));
ellipse.SetValue(Canvas.LeftProperty, e.GetPosition(canvas).X - ellipseDiameter/2.0);
ellipse.SetValue(Canvas.TopProperty, e.GetPosition(canvas).Y - ellipseDiameter/2.0);
canvas.Children.Add(ellipse);
*/
}
private void Ellipse_MouseEnter(object sender, MouseEventArgs e)
{
FrameworkElement pin = sender as FrameworkElement;
var station = (ListeningStation)pin.Tag;
MapLayer.SetPosition(ContentPopup, station.Location);
MapLayer.SetPositionOffset(ContentPopup, new Point(20, -10));
ContentPopupText.Text = station.ID;
ContentPopupDescription.Text = station.Name;
ContentPopup.Visibility = Visibility.Visible;
}
private void Ellipse_MouseLeave(object sender, MouseEventArgs e)
{
ContentPopup.Visibility = Visibility.Collapsed;
}
private void MapPolyline_MouseEnter(object sender, MouseEventArgs e)
{
FrameworkElement pin = sender as FrameworkElement;
var edge = (Edge)pin.Tag;
Point mousePosition = e.GetPosition(this);
Location mouseLocation = map.ViewportPointToLocation(mousePosition);
MapLayer.SetPosition(ContentPopup, mouseLocation);
MapLayer.SetPositionOffset(ContentPopup, new Point(20, -10));
ContentPopupText.Text = edge.ID;
ContentPopupDescription.Text = edge.Name;
ContentPopup.Visibility = Visibility.Visible;
}
private void MapPolyline_MouseLeave(object sender, MouseEventArgs e)
{
ContentPopup.Visibility = Visibility.Collapsed;
}
}
}