private void ChangeTextHandler(object sender, RoutedEventArgs e) { //Graphic g = sender as Graphic; _currentPoint = SelectedSymbol.Geometry as MapPoint; TextSymbol ts = SelectedSymbol.Symbol as TextSymbol; TextSymbolPropsWindow win = new TextSymbolPropsWindow(); win.TextFont = ts.FontFamily.Source; win.TextFontSize = ts.FontSize; win.Annotation = ts.Text; win.EditMode = true; win.Closed += new EventHandler(win_Closed); win.Show(); //MessageBox.Show("show change dialog here"); //RemoveSymbol(SelectedSymbol); }
private void DrawCompleteHandler(object sender, DrawEventArgs args) { _currentPoint = args.Geometry as MapPoint; TextSymbolPropsWindow win = new TextSymbolPropsWindow(); win.EditMode = false; win.Closed += new EventHandler(win_Closed); win.Show(); //GraphicsLayer graphicsLayer = _map.Map.Layers["defaultTextGraphicsLayer"] as GraphicsLayer; //string input = System.Windows.Browser.HtmlPage.Window.Prompt("Enter text to display"); //if (!String.IsNullOrEmpty(input)) //{ // MapPoint pt = args.Geometry as MapPoint; // TextSymbol sym = new TextSymbol(); // sym.FontFamily = new FontFamily("Arial"); // sym.FontSize = 20; // sym.Text = input; // sym.Foreground = new SolidColorBrush { Color = Colors.Black }; // Main.Helpers.Font f = new Font(); // f.Family = sym.FontFamily; // f.Size = sym.FontSize; // f.Style = FontStyles.Normal; // f.Weight = FontWeights.Normal; // String s = new String(input.ToCharArray()); // Size size = s.Measure(f); // sym.OffsetX = size.Width / 2; // sym.OffsetY = size.Height / 2; // //MessageBox.Show("h:" + size.Height.ToString() + " w:" + size.Width.ToString()); // //TODO: Apply offest to center label // ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic() // { // Geometry = args.Geometry, // Symbol = sym, // }; // graphic.MouseLeftButtonUp += new MouseButtonEventHandler(graphic_MouseLeftButtonUp); // graphic.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(graphic_MouseRightButtonDown); // graphicsLayer.Graphics.Add(graphic); //_map.PreviousExtents.Push(_map.Map.Extent); //} //_map.NextExtents.Clear(); //_map.Map.ZoomTo(args.Geometry as ESRI.ArcGIS.Client.Geometry.Envelope); }
void win_Closed(object sender, EventArgs e) { TextSymbolPropsWindow win = sender as TextSymbolPropsWindow; GraphicsLayer graphicsLayer = _map.Map.Layers["defaultTextGraphicsLayer"] as GraphicsLayer; string input = win.Annotation; // System.Windows.Browser.HtmlPage.Window.Prompt("Enter text to display"); if (!String.IsNullOrEmpty(input)) { MapPoint pt = _currentPoint; TextSymbol sym = new TextSymbol(); sym.FontFamily = new FontFamily(win.TextFont); // new FontFamily("Arial"); sym.FontSize = win.TextFontSize; // 20; sym.Text = win.Annotation; // input; sym.Foreground = new SolidColorBrush { Color = Colors.Black }; Main.Helpers.Font f = new Font(); f.Family = sym.FontFamily; f.Size = sym.FontSize; f.Style = FontStyles.Normal; f.Weight = FontWeights.Normal; String s = new String(input.ToCharArray()); Size size = s.Measure(f); sym.OffsetX = size.Width / 2; sym.OffsetY = size.Height / 2; //MessageBox.Show("h:" + size.Height.ToString() + " w:" + size.Width.ToString()); //TODO: Apply offest to center label ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic() { Geometry = pt, Symbol = sym, }; graphic.MouseLeftButtonUp += new MouseButtonEventHandler(graphic_MouseLeftButtonUp); graphic.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(graphic_MouseRightButtonDown); if (win.EditMode) { graphicsLayer.Graphics.Remove(SelectedSymbol); }//_map.PreviousExtents.Push(_map.Map.Extent); graphicsLayer.Graphics.Add(graphic); } }