示例#1
0
        private void AddDeclaredGoal_Click(object sender, RoutedEventArgs e)
        {
            GoalDeclaration declaration = null;

            if (sender is Button)
            {
                if (listBoxDeclaredGoals.SelectedItem != null)
                {
                    declaration = (GoalDeclaration)listBoxDeclaredGoals.SelectedItem;
                }
                else
                {
                    declaration = new GoalDeclaration(0, Engine.Settings.Date, "0000/0000", 0);
                }
            }
            else if (sender is MenuItem)
            {
                var point = new AXPoint(DateTime.Now, MapViewer.MousePointerPosition.X, MapViewer.MousePointerPosition.Y, 0);
                declaration = new GoalDeclaration(0, Engine.Settings.Date, point.ToString(AXPointInfo.CompetitionCoords10).Trim(), double.NaN);
            }

            if (declaration != null)
            {
                var dlg = new InputWindow(s => GoalDeclaration.Parse(s) != null)
                {
                    Title = "Enter goal declaration",
                    Text  = declaration.ToString(AXPointInfo.Name | AXPointInfo.Date | AXPointInfo.Time | AXPointInfo.Declaration | AXPointInfo.Altitude)
                };
                dlg.ShowDialog();
                if (dlg.Response == System.Windows.Forms.DialogResult.OK)
                {
                    Report.AddDeclaredGoal(GoalDeclaration.Parse(dlg.Text));
                    Engine.Display();
                }
            }
        }