async void miDeleteAtom_Click(object sender, RoutedEventArgs e) { MessageBoxResult res = MessageBox.Show(TDSClient.Properties.Resources.strAreyousureyouwanttodeleteit, "TDS", MessageBoxButton.YesNo); if (res == MessageBoxResult.Yes) { structTransportCommonProperty CommonProperty = (structTransportCommonProperty)((System.Windows.Controls.MenuItem)sender).Tag; await TDSClient.SAGInterface.SAGSignalR.DeleteAtomByAtomName(VMMainViewModel.Instance.SimulationHubProxy, CommonProperty.AtomName); } }
public frmActivities(structTransportCommonProperty CommonProperty) { InitializeComponent(); this.Background = new LinearGradientBrush(Colors.AliceBlue, Colors.LightGray, 90); AtomCommonProperty = CommonProperty; Title = AtomCommonProperty.AtomName + " " + Title; SetGrid(); LoadData(); }
private void ShowGroundSelectAtomMenu(object sender, structTransportCommonProperty minDistAtom) { System.Windows.Application.Current.MainWindow.ContextMenu = null; // System.Windows.Controls.ContextMenu contextmenu = new System.Windows.Controls.ContextMenu(); contextmenu = new System.Windows.Controls.ContextMenu(); System.Windows.Controls.MenuItem miName = new System.Windows.Controls.MenuItem(); miName.Header = Properties.Resources.strNameColon + " " + minDistAtom.AtomName;///+ " " + minDistAtom.TextValue.Replace("_", "__"); ; miName.Focusable = false; contextmenu.Items.Add(miName); System.Windows.Controls.Separator Sp2 = new System.Windows.Controls.Separator(); contextmenu.Items.Add(Sp2); System.Windows.Controls.MenuItem miGroundMission = new System.Windows.Controls.MenuItem(); miGroundMission.Header = "Activity";// "Force Mission"; miGroundMission.Name = "miGroundMission"; miGroundMission.Tag = minDistAtom; miGroundMission.Click += new System.Windows.RoutedEventHandler(mnuGroundMission_Click); contextmenu.Items.Add(miGroundMission); System.Windows.Controls.MenuItem miMove = new System.Windows.Controls.MenuItem(); miMove.Header = Properties.Resources.strMove; // "Move"; miMove.Tag = minDistAtom; miMove.Name = "mnuMove"; miMove.Click += miMove_Click; // new System.Windows.RoutedEventHandler(mnuMove_Click); contextmenu.Items.Add(miMove); if (VMMainViewModel.Instance.CurrentGameStatus != typGamestatus.EDIT_STATUS) { miMove.IsEnabled = false; } System.Windows.Controls.MenuItem miDeleteAtom = new System.Windows.Controls.MenuItem(); miDeleteAtom.Header = Properties.Resources.strUndeploy;// Properties.Resources.strDelete; miDeleteAtom.Name = "miDeleteAtom"; miDeleteAtom.Tag = minDistAtom; miDeleteAtom.Click += miDeleteAtom_Click; contextmenu.Items.Add(miDeleteAtom); // System.Windows.Application.Current.MainWindow.ContextMenu = new System.Windows.Controls.ContextMenu(); System.Windows.Application.Current.MainWindow.ContextMenu = contextmenu; contextmenu.Visibility = Visibility.Visible; System.Windows.Application.Current.MainWindow.ContextMenu.Visibility = Visibility.Visible; System.Windows.Application.Current.MainWindow.ContextMenu.IsOpen = true; // System.Windows.Application.Current.MainWindow.ContextMenu.Width = 1000; }
public frmActivityEdit(structTransportCommonProperty CommonProperty, GeneralActivityDTO ActivityDTO) { InitializeComponent(); this.Background = new LinearGradientBrush(Colors.AliceBlue, Colors.LightGray, 90); txPlatformName.IsReadOnly = true; AtomCommonProperty = CommonProperty; refActivityDTO = ActivityDTO; if (AtomCommonProperty != null) { txPlatformName.Text = AtomCommonProperty.AtomName; } }
public void mnuGroundMission_Click(object sender, RoutedEventArgs e) { structTransportCommonProperty CommonProperty = (structTransportCommonProperty)((System.Windows.Controls.MenuItem)sender).Tag; TDSClient.Forms.frmActivities frm = new Forms.frmActivities(CommonProperty); frm.Owner = Application.Current.MainWindow; frm.Show(); //IEnumerable<GeneralActivityDTO> Activites = await TDSClient.SAGInterface.SAGSignalR.GetActivitesByAtomName(VMMainViewModel.Instance.SimulationHubProxy, CommonProperty.AtomName); //if(Activites!=null && Activites.Count()>0) //{ // GeneralActivityDTO pActivityDTO = Activites.ToArray<GeneralActivityDTO>()[0]; // TDSClient.Forms.frmRouteActivityRouting frm = new Forms.frmRouteActivityRouting(pActivityDTO); // frm.Owner = Application.Current.MainWindow; // frm.Show(); //} }
private void Find() { bFound = false; // string guid= comboBoxAtom.SelectedValue as string; string name = comboBoxAtom.Text as string; // if (guid == null) return; structTransportCommonProperty Tr = null; VMMainViewModel.Instance.colGroundAtoms.TryGetValue(name, out Tr); if (Tr != null) { VMMainViewModel.Instance.ConvertCoordGroundToPixel(Tr.X, Tr.Y, ref PixelX, ref PixelY); bFound = true; fx = Tr.X; fy = Tr.Y; VMMainViewModel.Instance.InvalidateVisual(); } }
private void cmdActivities_Click(object sender, RoutedEventArgs e) { int i = dtGridActors.SelectedIndex; if (i < 0) { return; } AtomDTOData currAtomData = (AtomDTOData)dtGridActors.Items[i]; structTransportCommonProperty Tr = null; VMMainViewModel.Instance.colGroundAtoms.TryGetValue(currAtomData.atom.Identification, out Tr); if (Tr != null) { TDSClient.Forms.frmActivities frm = new Forms.frmActivities(Tr); frm.Owner = this; frm.Show(); } }
private void btnZoom_Click(object sender, RoutedEventArgs e) { string name = comboBoxAtom.Text as string; // if (guid == null) return; structTransportCommonProperty Tr = null; VMMainViewModel.Instance.colGroundAtoms.TryGetValue(name, out Tr); if (Tr != null) { VMMainViewModel.Instance.ConvertCoordGroundToPixel(Tr.X, Tr.Y, ref PixelX, ref PixelY); bFound = true; fx = Tr.X; fy = Tr.Y; VMMainViewModel.Instance.MyMainMap.CenterOnGroundPointZoom(fx, fy); // VMMainViewModel.Instance.InvalidateVisual(); } }
public static ImageSource ImageSourceAtom(structTransportCommonProperty refTarget) { string imageKey = ""; ImageSource imageSource = null; System.Windows.Size sz = new System.Windows.Size(24, 24); System.Windows.Size szFor = new System.Windows.Size(15, 15); System.Windows.Size szP = new System.Windows.Size(20, 20); System.Windows.Point pnt = new System.Windows.Point(0, 0); System.Windows.Point pntP = new System.Windows.Point(5, 5); System.Windows.Point pntFor = new System.Windows.Point(2, 2); System.Windows.Rect rectBack = new System.Windows.Rect(pnt, sz); System.Windows.Rect rectP = new System.Windows.Rect(pntP, szP); System.Windows.Rect rectFor = new System.Windows.Rect(pntFor, szFor); ImageSource ImageSourceDrawHand = new BitmapImage(new Uri("pack://application:,,,/Images/PanDrag.ico")); // if (refTarget.AtomClass == "GameService.clsGroundAtom" || refTarget.AtomClass == "GameService.clsTarget" || refTarget.AtomClass == "GameService.NavalTask.clsNavalAtom") { char ch = new char(); System.Windows.Media.SolidColorBrush curBrush = new System.Windows.Media.SolidColorBrush(); curBrush.Color = System.Windows.Media.Colors.Red; // ch = (char)refTarget.FontKey; ch = (char)150; //switch (refTarget.CountryColorSide) //{ // case COLOR_SIDE.BLUE: // curBrush.Color = System.Windows.Media.Colors.Blue; // break; // case COLOR_SIDE.RED: // curBrush.Color = System.Windows.Media.Colors.Red; // break; // case COLOR_SIDE.GREEN: // curBrush.Color = System.Windows.Media.Colors.Green; // break; // case COLOR_SIDE.WHITE: // curBrush.Color = System.Windows.Media.Colors.Gray; // break; //} //System.Windows.Media.FormattedText frm = new System.Windows.Media.FormattedText(new string(ch, 1), // System.Globalization.CultureInfo.GetCultureInfo("en-us"), // System.Windows.FlowDirection.LeftToRight, // new System.Windows.Media.Typeface("Simulation Font Environmental"), // 14, curBrush); System.Windows.Media.FormattedText frm = new System.Windows.Media.FormattedText(new string(ch, 1), System.Globalization.CultureInfo.GetCultureInfo("en-us"), System.Windows.FlowDirection.LeftToRight, new System.Windows.Media.Typeface("Wingdings 2"), 42, curBrush); frm.TextAlignment = System.Windows.TextAlignment.Center; // frm.SetFontWeight(System.Windows.FontWeights.Bold); RenderTargetBitmap bmp = new RenderTargetBitmap(36, 36, 120, 96, PixelFormats.Pbgra32); DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); drawingContext.DrawText(frm, new System.Windows.Point(15, 5)); drawingContext.DrawImage(ImageSourceDrawHand, rectP); drawingContext.Close(); bmp.Render(drawingVisual); imageSource = bmp; } return(imageSource); }
void MapOnRightClickWPF(object sender, MapMouseEventArgsWPF e) { double SearchRadius = 2000; double SearchNeiborRadiuse = 200; double minDistance = double.MaxValue; structTransportCommonProperty minDistAtom = null; List <structTransportCommonProperty> NeighborList = new List <structTransportCommonProperty>(); double resolution = 0; double zoom = VMMainViewModel.Instance.MyMainMap.Zoom; //* Math.Cos(TerrainService.MathEngine.DegreesToRadians(e.MapYLongLatWGS84)) resolution = (156543) / Math.Pow(2, zoom); SearchNeiborRadiuse = resolution * 10; System.Windows.Application.Current.MainWindow.ContextMenu = null; // System.Windows.Controls.ContextMenu contextmenu = new System.Windows.Controls.ContextMenu(); // if (VMMainViewModel.Instance.currSelectionType == enSelection.Ground) { minDistance = double.MaxValue; if (VMMainViewModel.Instance.colGroundAtoms != null) { foreach (structTransportCommonProperty Tr in VMMainViewModel.Instance.colGroundAtoms.Values) { double Distance = Utilites.GreatCircleDistance(Tr.X, Tr.Y, e.MapXLongLatWGS84, e.MapYLongLatWGS84); if (Distance < minDistance && Distance > 0) { minDistance = Distance; minDistAtom = Tr; } } } } SelectMenu = new System.Windows.Controls.ContextMenu(); SelectMenu.Style = null; DPoint coordinates = new DPoint(e.MapXLongLatWGS84, e.MapYLongLatWGS84); // add menu item for adding barriers System.Windows.Controls.MenuItem mBarrier = new System.Windows.Controls.MenuItem(); mBarrier.Header = "Add Barrier"; mBarrier.Tag = coordinates; mBarrier.Click += miAddBarier_Click; SelectMenu.Items.Add(mBarrier); System.Windows.Controls.MenuItem mCoordinates = new System.Windows.Controls.MenuItem(); mCoordinates.Header = e.MapXLongLatWGS84.ToString() + " " + e.MapYLongLatWGS84.ToString(); mCoordinates.Tag = coordinates; mCoordinates.Click += miCoordinates_Click; SelectMenu.Items.Add(mCoordinates); System.Windows.Application.Current.MainWindow.ContextMenu = SelectMenu; if (minDistAtom != null && minDistance < SearchRadius) { //Create PopUP menu if (minDistAtom.AtomClass == "TDSServer.GroundTask.clsGroundAtom") { foreach (structTransportCommonProperty Tr in VMMainViewModel.Instance.colGroundAtoms.Values) { double Distance = TerrainService.MathEngine.CalcDistanceForPerformance(Tr.X, Tr.Y, minDistAtom.X, minDistAtom.Y); if (Distance <= SearchNeiborRadiuse) { NeighborList.Add(Tr); } } if (NeighborList.Count == 1) { ShowGroundSelectAtomMenu(null, minDistAtom); } else { // System.Windows.Controls.ContextMenu SelectMenu = new System.Windows.Controls.ContextMenu(); SelectMenu = new System.Windows.Controls.ContextMenu(); SelectMenu.Style = null; for (int i = 0; i < NeighborList.Count; i++) { // System.Windows.Controls.MenuItem mSelectGroundAtom = new System.Windows.Controls.MenuItem(); // mSelectGroundAtom.Style = null; System.Windows.Controls.MenuItem mSelectGroundAtom = new System.Windows.Controls.MenuItem(); mSelectGroundAtom.Header = NeighborList[i].AtomName; mSelectGroundAtom.Tag = NeighborList[i]; mSelectGroundAtom.Focusable = false; mSelectGroundAtom.Click += miName_Click; SelectMenu.Items.Add(mSelectGroundAtom); } System.Windows.Application.Current.MainWindow.ContextMenu = SelectMenu; return; } } } }
void miName_Click(object sender, RoutedEventArgs e) { structTransportCommonProperty CommonProperty = (structTransportCommonProperty)((System.Windows.Controls.MenuItem)sender).Tag; ShowGroundSelectAtomMenu(sender, CommonProperty); }
internal void DrawGroundAtomWPF(structTransportCommonProperty refGroundAtom, System.Windows.Media.DrawingContext dc) { int PixelX = 0; int PixelY = 0; char ch = new char(); string ParentName = string.Empty; System.Windows.Media.SolidColorBrush BackgroundBrush = new SolidColorBrush(); System.Windows.Media.SolidColorBrush curBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Black); try { BackgroundBrush = Brushes.Red; curBrush.Color = System.Windows.Media.Colors.Red; if (refGroundAtom.isCollision) { curBrush.Color = System.Windows.Media.Colors.Blue; } MyMainMap.ConvertCoordGroundToPixel(refGroundAtom.X, refGroundAtom.Y, ref PixelX, ref PixelY); ch = (char)150; // 1000; //(char)refGroundAtom.FontKey; // Yinon Douchan: Added code for showing dead/injured int fontSize = 42; if (refGroundAtom.isDead) { //curBrush.Color = System.Windows.Media.Colors.Black; ch = (char)207; fontSize = 16; } else if (refGroundAtom.isIncapacitated || refGroundAtom.isInjured) { ch = (char)204; fontSize = 16; } // --------------------------------------------------- //42 //System.Windows.Media.FormattedText frm2 = new System.Windows.Media.FormattedText(new string(ch, 1), // System.Globalization.CultureInfo.GetCultureInfo("en-us"), // System.Windows.FlowDirection.LeftToRight, // new System.Windows.Media.Typeface("Simulation Font Environmental"), // 24, curBrush); // Yinon Douchan: Added code for showing dead/injured System.Windows.Media.FormattedText frm2 = new System.Windows.Media.FormattedText(new string(ch, 1), System.Globalization.CultureInfo.GetCultureInfo("en-us"), System.Windows.FlowDirection.LeftToRight, new System.Windows.Media.Typeface("Wingdings 2"), fontSize, curBrush); // --------------------------------------------------- frm2.TextAlignment = System.Windows.TextAlignment.Center; // double w= (frm2.Width / 8); double w = (frm2.Width / 2); w = 0; double h = frm2.Height / 2; // dc.DrawText(frm2, new System.Windows.Point(PixelX, PixelY - frm2.Height / 2)); dc.DrawText(frm2, new System.Windows.Point(PixelX + w, PixelY - h)); } catch (Exception ex) { } }