Inheritance: System.Windows.Controls.Control
        public override void OnApplyTemplate()
        {
            if (SymbolOverlay != null)
                SymbolOverlay.MouseLeftButtonUp -= SymbolOverlay_MouseLeftButtonUp;

            if (SymbolSelector != null)
                SymbolSelector.SymbolSelected -= SymbolSelector_SymbolSelected;

            base.OnApplyTemplate();

            SymbolSelector = GetTemplateChild("SymbolSelector") as SymbolSelector;
            if (SymbolSelector != null)
                SymbolSelector.SymbolSelected += SymbolSelector_SymbolSelected;

            UniqueValueTextBlock = GetTemplateChild("UniqueValueTextBlock") as TextBlock;

            ToggleButton = GetTemplateChild("ToggleButton") as ToggleButton;

            SymbolDisplay = GetTemplateChild("SymbolDisplay") as SymbolDisplay;

            SymbolOverlay = GetTemplateChild("SymbolOverlay") as Rectangle;
            if (SymbolOverlay != null)
                SymbolOverlay.MouseLeftButtonUp += SymbolOverlay_MouseLeftButtonUp;

            if (InitCompleted != null)
                InitCompleted(this, EventArgs.Empty);
        }
        public override void OnApplyTemplate()
        {            
            if (SymbolSelector != null)
                SymbolSelector.SymbolSelected -= SymbolSelector_SymbolSelected;

            if (SymbolDropDownButton != null)
                SymbolDropDownButton.IsContentPopupOpen = false;

            base.OnApplyTemplate();

            SymbolSelector = GetTemplateChild("SymbolSelector") as SymbolSelector;
            if (SymbolSelector != null)
                SymbolSelector.SymbolSelected += SymbolSelector_SymbolSelected;

            SymbolDisplay = GetTemplateChild("SymbolDisplay") as SymbolDisplay;

            SymbolDropDownButton = GetTemplateChild("SymbolDropDownButton") as DropDownButton;

            if (InitCompleted != null)
                InitCompleted(this, EventArgs.Empty);
        }
        private List<ExportFile> GetImages()
        {
            List<ExportFile> images = new List<ExportFile>();

              foreach(Symbol symbol in mUsedSymbols)
              {
            SymbolDisplay symDisplay = new SymbolDisplay();

            symDisplay.Symbol = symbol;
            symDisplay.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            symDisplay.VerticalAlignment = System.Windows.VerticalAlignment.Center;

            //Need to put panel in popup and open popup, so panel ends up in control visual tree.
            //Otherwise when bitmap is rendered, panel will not include any child controls.
            Popup popUp = new System.Windows.Controls.Primitives.Popup();
            popUp.Child = symDisplay;
            popUp.IsOpen = true;
            popUp.UpdateLayout();

            WriteableBitmap bmp = new WriteableBitmap(symDisplay, null);
            ImageTools.Image img = ImageTools.ImageExtensions.ToImage(bmp);

            MemoryStream stream = new MemoryStream();

            ImageTools.ImageExtensions.WriteToStream(img, stream);

            images.Add(new ExportFile()
            {
              Title = symbol.GetHashCode().ToString(),
              Path = string.Format("files/{0}.png", symbol.GetHashCode().ToString()),
              Data = stream.ToArray()
            });

            stream.Dispose();

            popUp.IsOpen = false;
              }

              return images;
        }
        void SymbolConfigProvider_GetSymbolForResourceDictionary(object sender, GetSymbolsForResourceDictionaryCompletedEventArgs e)
        {
            if (e.Symbols == null)
                return;            

            if (Symbols != null)
            {
                try
                {
                    Symbols.Items.Clear();
                    foreach (SymbolDescription symbolDescription in e.Symbols)
                    {
                        if (symbolDescription == null || symbolDescription.Symbol == null)
                            continue;
                        Symbol symbol = symbolDescription.Symbol;
                        double size = 50;
                        ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol markerSymbol = symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol;
                        if (markerSymbol != null)
                        {
                            if (!double.IsNaN(markerSymbol.Size))
                                size = markerSymbol.Size;
                        }
                        else if (symbol is FillSymbol || symbol is LineSymbol)
                            size = 25;
                        else if (symbol is ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol )
                        {
                            ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol simpleMarkerSymbol =
                                symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol;
                            if (simpleMarkerSymbol != null && !double.IsNaN(simpleMarkerSymbol.Size))
                                size = simpleMarkerSymbol.Size;
                        }
                        else if (symbol is ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol)
                        {
                            ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol sms =
                                symbol as ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol;
                            if (sms != null && !double.IsNaN(sms.Size))
                                size = sms.Size;
                        }

                        SymbolDisplay disp = new SymbolDisplay()
                        {
                            Symbol = symbolDescription.Symbol,                            
                            Width = size,
                            Height = size,
                            IsHitTestVisible = false // Set to false to prevent mouseover and selection effects
                        };

                        // Wrap symbol display in a grid to allow cursor and tooltip
                        Grid symbolGrid = new Grid() 
                            { 
                                Cursor = Cursors.Hand,
                                // Apply nearly transparent background so grid is hit-test visible
                                Background = new SolidColorBrush(Color.FromArgb(1, 255, 255, 255))
                            };
                        symbolGrid.Children.Add(disp);
                       
                        Symbols.Items.Add(symbolGrid);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogError(ex);
					MessageBoxDialog.Show(ESRI.ArcGIS.Mapping.Controls.Resources.Strings.ErrorRetrievingSymbols + Environment.NewLine + ex.Message);
                }
            }
        }
        public override void OnApplyTemplate()
        {
            if (SymbolSelector != null)
                SymbolSelector.SymbolSelected -= SymbolSelector_SymbolChanged;

            if (MinValueTextBlock != null)
                MinValueTextBlock.MouseLeftButtonUp -= MinValueTextBlock_MouseLeftButtonUp;

            if (MaxValueTextBlock != null)
                MaxValueTextBlock.MouseLeftButtonUp -= MaxValueTextBlock_MouseLeftButtonUp;

            if (MinValueTextBox != null)
            {
                MinValueTextBox.KeyDown -= MinValueTextBox_KeyDown;
                MinValueTextBox.LostFocus -= MinValueTextBox_LostFocus;
            }

            if (MaxValueTextBox != null)
            {
                MaxValueTextBox.KeyDown += MaxValueTextBox_KeyDown;
                MaxValueTextBox.LostFocus -= MaxValueTextBox_LostFocus;
            }

            if (SymbolOverlay != null)
                SymbolOverlay.MouseLeftButtonUp -= SymbolOverlay_MouseLeftButtonUp;

            base.OnApplyTemplate();

            SymbolSelector = GetTemplateChild("SymbolSelector") as SymbolSelector;
            if(SymbolSelector != null)
                SymbolSelector.SymbolSelected += SymbolSelector_SymbolChanged;

            MinValueTextBlock = GetTemplateChild("MinValueTextBlock") as TextBlock;
            if (MinValueTextBlock != null)
                MinValueTextBlock.MouseLeftButtonUp += MinValueTextBlock_MouseLeftButtonUp;

            MaxValueTextBlock = GetTemplateChild("MaxValueTextBlock") as TextBlock;
            if (MaxValueTextBlock != null)
                MaxValueTextBlock.MouseLeftButtonUp += MaxValueTextBlock_MouseLeftButtonUp;

            MinValueTextBox = GetTemplateChild("MinValueTextBox") as TextBox;
            if (MinValueTextBox != null)
            {
                MinValueTextBox.KeyDown += MinValueTextBox_KeyDown;
                MinValueTextBox.LostFocus += MinValueTextBox_LostFocus;
            }

            MaxValueTextBox = GetTemplateChild("MaxValueTextBox") as TextBox;
            if (MaxValueTextBox != null)
            {
                MaxValueTextBox.KeyDown += MaxValueTextBox_KeyDown;
                MaxValueTextBox.LostFocus += MaxValueTextBox_LostFocus;
            }

            ToggleButton = GetTemplateChild("ToggleButton") as ToggleButton;           

            SymbolDisplay = GetTemplateChild("SymbolDisplay") as SymbolDisplay;

            SymbolOverlay = GetTemplateChild("SymbolOverlay") as Rectangle;
            if (SymbolOverlay != null)
                SymbolOverlay.MouseLeftButtonUp += SymbolOverlay_MouseLeftButtonUp;
            
            if (InitCompleted != null)
                InitCompleted(this, EventArgs.Empty);
        }
Exemplo n.º 6
0
        private static void OnAttributesPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SymbolDisplay obj = (SymbolDisplay)d;

            obj.data.Attributes = (IDictionary <string, object>)e.NewValue;
        }
Exemplo n.º 7
0
        private static void OnSymbolPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SymbolDisplay obj = (SymbolDisplay)d;

            obj.SymbolContent.Symbol = obj.data.Symbol = e.NewValue as Symbol;
        }