protected override void drawValue() { var range = Range + mDRange; if (range < 100) { range = 100; } var pOfs = DispUnit * 2 - 1; var pRise = pOfs - (int)(Rise * DispUnit * 2 / range); var pTop = pOfs - (int)(Top * DispUnit * 2 / range); var pSustain = pOfs; var pFall = pOfs - (int)(Fall * DispUnit * 2 / range); var psRise = pRise; var psTop = pTop; var psFall = pFall; if (mPicValue.Height < psRise + 20) { psRise = mPicValue.Height - 20; } if (mPicValue.Height < psTop + 20) { psTop = mPicValue.Height - 20; } if (mPicValue.Height < psFall + 20) { psFall = mPicValue.Height - 20; } // mGValue.SmoothingMode = SmoothingMode.AntiAlias; mGValue.DrawLine(Colors.PLineA, 0, pRise, ColumnWidth, pTop); mGValue.DrawLine(Colors.PLineA, ColumnWidth, pTop, ColumnWidth * 2, pSustain); mGValue.DrawLine(Colors.PLineA, ColumnWidth * 2, pSustain, ColumnWidth * 3, pFall); mGValue.SmoothingMode = SmoothingMode.None; // mGValue.FillPie(Colors.BPoint, -4, pRise - 4, 8, 8, 0, 360); mGValue.FillPie(Colors.BPoint, ColumnWidth - 4, pTop - 4, 8, 8, 0, 360); mGValue.FillPie(Colors.BPoint, ColumnWidth * 3 - 4, pFall - 4, 8, 8, 0, 360); mGValue.DrawArc(Colors.PTableBorderLight, -4, pRise - 4, 8, 8, 0, 360); mGValue.DrawArc(Colors.PTableBorderLight, ColumnWidth - 4, pTop - 4, 8, 8, 0, 360); mGValue.DrawArc(Colors.PTableBorderLight, ColumnWidth * 3 - 4, pFall - 4, 8, 8, 0, 360); // mGValue.DrawString(Rise.ToString("0cent"), Fonts.Small, Colors.BTableFont, 3, psRise); mGValue.DrawString(Top.ToString("0cent"), Fonts.Small, Colors.BTableFont, ColumnWidth + 3, psTop); mGValue.DrawString(Fall.ToString("0cent"), Fonts.Small, Colors.BTableFont, ColumnWidth * 3 - 3, psFall, Fonts.AlignTR); }
private void ActualUpdateButton_Click(object sender, RoutedEventArgs e) { if (fallSelector.SelectedItem.ToString() == "---") { showSelectFall(); return; } if (latText.Text == "?") { showSelectGeotaggedPic(); return; } fallSelector.IsEnabled = false; picSelectButton.IsEnabled = false; try { // Finding the fall we want to update Fall leFall = new Fall(); foreach (Fall f in MainWindow.GetCurrentVM().Falls) { if (f.ToString() == fallSelector.SelectedItem.ToString()) { leFall = f; } } // Setting up the variables for the new coordinates float NewX = 0.0f, NewY = 0.0f; float.TryParse(latText.Text, out NewX); float.TryParse(lonText.Text, out NewY); string confirm = "Lat1: " + leFall.x.ToString() + " -> Lat2: " + latText.Text + "\nLon1: " + leFall.y.ToString() + " -> Lon2: " + lonText.Text; string[] messageTitle = showConfirm(confirm, leFall.ToString()); MessageBoxResult result1 = System.Windows.MessageBox.Show(messageTitle[0], messageTitle[1], MessageBoxButton.OKCancel, MessageBoxImage.Question); if (result1 != MessageBoxResult.OK) { fallSelector.IsEnabled = true; picSelectButton.IsEnabled = true; return; } // Calling the model to deal with the actual data MainWindow.GetCurrentVM().CurrentModel.UpdateFall(leFall.id, NewX, NewY); // Re-setting the source of the selector... List <string> currentFalls = new List <string>(); currentFalls.Add("---"); foreach (Fall fall in MainWindow.GetCurrentVM().Falls) { if (fall.isGeotagged == null || !fall.isGeotagged) { currentFalls.Add(fall.ToString()); } } fallSelector.ItemsSource = currentFalls; fallSelector.SelectedItem = fallSelector.Items.GetItemAt(0); selectedFallMap.Children.Clear(); // ... and re-setting the demo photo and the lat and lon texts latText.Text = "?"; lonText.Text = "?"; geoPic.Source = new BitmapImage(new Uri(@"Resources/demoPic.png", UriKind.Relative)); showSuccess(); } catch (Exception) { showSomethingWrong(); } fallSelector.IsEnabled = true; picSelectButton.IsEnabled = true; }