void AssociatedObject_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            ListBoxItem connectionItem = ControlTreeHelper.FindAncestorOfType <ListBoxItem>(AssociatedObject);

            if (connectionItem == null)
            {
                return;
            }

            Connection connectionToDelete = connectionItem.DataContext as Connection;

            if (connectionToDelete == null)
            {
                return;
            }

            ConnectionsDropDownPopupControl connectivityControl = ControlTreeHelper.FindAncestorOfType <ConnectionsDropDownPopupControl>(AssociatedObject);

            if (connectivityControl == null)
            {
                return;
            }

            connectivityControl.DeleteConnection(connectionToDelete);

            e.Handled = true;
        }
Пример #2
0
        private void refreshButtonCommands()
        {
            if (TabControl == null)
            {
                return;
            }
            List <ButtonBase> customButtons = ControlTreeHelper.FindChildrenOfType <ButtonBase>(TabControl as DependencyObject, 12);

            if (customButtons != null)
            {
                foreach (ButtonBase btn in customButtons)
                {
                    ICommand cmd = btn.Command;
                    if (cmd != null)
                    {
                        cmd.CanExecuteChanged -= cmd_CanExecuteChanged;
                        cmd.CanExecuteChanged += cmd_CanExecuteChanged;
                        btn.Command            = null;
                        btn.Command            = cmd;
                        ToggleButton toggleButton = btn as ToggleButton;
                        if (toggleButton != null)
                        {
                            IToggleCommand toggleButtonCmd = cmd as IToggleCommand;
                            if (toggleButtonCmd != null)
                            {
                                toggleButton.IsChecked = toggleButtonCmd.IsChecked();
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
        void AssociatedObject_ColorPicked(object sender, ColorChosenEventArgs e)
        {
            ControlTreeHelper helper = new ControlTreeHelper();
            Popup             popup  = helper.FindParentControl <Popup>(AssociatedObject);

            if (popup == null)
            {
                return;
            }

            DropDownButton dropDownButton = popup.Tag as DropDownButton;

            if (dropDownButton == null)
            {
                return;
            }

            MapTipsConfig mapTipsConfig = helper.FindAncestorOfType <MapTipsConfig>(dropDownButton);

            if (mapTipsConfig != null)
            {
                mapTipsConfig.MapTipBorder = new SolidColorBrush(e.Color);
            }

            dropDownButton.ClosePopup();
        }
        public override void OnApplyTemplate()
        {
            if (SymbolCategories != null)
            {
                SymbolCategories.SelectionChanged -= SymbolCategories_SelectionChanged;
            }

            if (Symbols != null)
            {
                Symbols.SelectionChanged -= Symbols_SelectionChanged;
            }

            base.OnApplyTemplate();

            SymbolCategories = GetTemplateChild(PART_SYMBOLCATEGORIES) as ComboBox;

            if (SymbolCategories != null)
            {
                SymbolCategories.SelectionChanged += SymbolCategories_SelectionChanged;
            }

            Symbols = GetTemplateChild(PART_SYMBOLS) as ListBox;

            if (Symbols != null)
            {
                Symbols.SelectionChanged += Symbols_SelectionChanged;
            }

            SymbolsScrollViewer = GetTemplateChild(PART_SYMBOLSSCROLLVIEWER) as ScrollViewer;

            LayoutRoot = GetTemplateChild(PART_LAYOUTROOT) as FrameworkElement;

            getSymbolCategories();

            if (Symbols != null)
            {
                // Size width of symbols wrap panel to fit within parent ListBox
                Dispatcher.BeginInvoke((Action) delegate()
                {
                    SymbolsWrapPanel = ControlTreeHelper.FindChildOfType <WrapPanel>(Symbols, 5);
                    if (SymbolsWrapPanel != null && double.IsNaN(SymbolsWrapPanel.Width) && !double.IsNaN(Symbols.ActualWidth) && Symbols.ActualWidth > 0)
                    {
                        SymbolsWrapPanel.Width = SymbolsScrollViewer.ViewportWidth - 2;
                        Symbols.SizeChanged   -= Symbols_SizeChanged;
                        Symbols.SizeChanged   += Symbols_SizeChanged;
                    }
                });
            }
            isInitialized = true;

            if (InitCompleted != null)
            {
                InitCompleted(this, EventArgs.Empty);
            }
        }
        public void ToggleVisibility(bool visible)
        {
            Visibility visibility = visible ? Visibility.Visible : System.Windows.Visibility.Collapsed;

            if (Container == null)
            {
                InitialVisibility = visibility;
                return;
            }

            if (visibility == Container.Visibility)
            {
                return;
            }

            #region showHideRibbonTabs
            if (TabControl != null)
            {
                if (visible)
                {
                    previouslyVisibleTabIndices.Clear();
                    TabControl.SelectedIndex = 0;
                }
                else if (TabControl.SelectedIndex == 0)
                {
                    TabControl.SelectedIndex = 1;
                }

                Grid mainGrid = ControlTreeHelper.FindChildOfType <Grid>(TabControl);
                if (mainGrid != null && mainGrid.Children.Count > 0)
                {
                    Grid templateTop = mainGrid.Children[0] as Grid;
                    if (templateTop != null && templateTop.Children.Count > 1)
                    {
                        Border border = templateTop.Children[1] as Border;
                        if (border != null)
                        {
                            border.Visibility = visible ? Visibility.Collapsed : Visibility.Visible;
                        }
                    }
                }
            }
            #endregion

            ShowBackStage(visible);

            //TODO:- EVAL
            //if (visible)
            //    View.HideSearchUI();
        }
        void AssociatedObject_Clicked(object sender, RoutedEventArgs e)
        {
            MapTipsLayerConfig mapTipsConfig = ControlTreeHelper.FindAncestorOfType <MapTipsLayerConfig>(AssociatedObject);

            if (mapTipsConfig != null)
            {
                if (AssociatedObject.IsChecked.Value)
                {
                    mapTipsConfig.FieldInfo_MapTipVisiblityChecked(this.AssociatedObject.DataContext as FieldInfo);
                }
                else
                {
                    mapTipsConfig.FieldInfo_MapTipVisibilityUnChecked(this.AssociatedObject.DataContext as FieldInfo);
                }
            }
        }
Пример #7
0
        void AssociatedObject_Clicked(object sender, RoutedEventArgs e)
        {
            AttributeDisplayConfig mapTipsConfig = ControlTreeHelper.FindAncestorOfType <AttributeDisplayConfig>(AssociatedObject);

            if (mapTipsConfig != null)
            {
                if (AssociatedObject.IsChecked.Value)
                {
                    mapTipsConfig.FieldInfo_AttributeDisplayChecked(this.AssociatedObject.DataContext as FieldInfo);
                }
                else
                {
                    mapTipsConfig.FieldInfo_AttributeDisplayUnChecked(this.AssociatedObject.DataContext as FieldInfo);
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Fires when the associated Popup is opened
        /// </summary>
        private void Popup_Opened(object sender, EventArgs e)
        {
            if (Application.Current != null && Application.Current.RootVisual != null)
            {
                // Find the Grid that is closest to the root of the application's visual tree
                if (rootGrid == null)
                {
                    rootGrid = ControlTreeHelper.FindChildOfType <Grid>(Application.Current.RootVisual);
                }

                if (rootGrid != null)
                {
                    // Create the overlay grid
                    if (overlay == null)
                    {
                        // Make the overlay grid almost transparent, but not completely so.  Elements that are
                        // completely transparent cannot intercept clicks.
                        overlay = new Grid()
                        {
                            Background          = new SolidColorBrush(Color.FromArgb(1, 255, 255, 255)),
                            HorizontalAlignment = HorizontalAlignment.Stretch,
                            VerticalAlignment   = VerticalAlignment.Stretch
                        };

                        // Set the column and row span of the overlay so that it covers the entire grid

                        if (rootGrid.ColumnDefinitions.Count > 0)
                        {
                            Grid.SetColumnSpan(overlay, rootGrid.ColumnDefinitions.Count);
                        }

                        if (rootGrid.RowDefinitions.Count > 0)
                        {
                            Grid.SetRowSpan(overlay, rootGrid.RowDefinitions.Count);
                        }

                        // Listen to click events on the overlay
                        overlay.MouseLeftButtonDown  += Overlay_Click;
                        overlay.MouseRightButtonDown += Overlay_Click;
                    }

                    // Insert the overlay into the grid
                    rootGrid.Children.Add(overlay);
                }
            }
        }
Пример #9
0
        void AssociatedObject_Click(object sender, RoutedEventArgs e)
        {
            DataGridColumnHeader header = ControlTreeHelper.FindAncestorOfType <DataGridColumnHeader>(AssociatedObject);

            if (header == null)
            {
                return;
            }

            FieldInfo fieldInfo = header.Content as FieldInfo;

            if (fieldInfo == null)
            {
                return;
            }

            AttributeDisplay attrDisplay = ControlTreeHelper.FindAncestorOfType <AttributeDisplay>(AssociatedObject);

            if (attrDisplay != null)
            {
                attrDisplay.RaiseSortedEvent(fieldInfo);
            }
        }
Пример #10
0
        public override void Execute(object parameter)
        {
            if (!CanExecute(parameter))
            {
                return;
            }

            var popupInfo = PopupInfo as OnClickPopupInfo;

            if (popupInfo == null)
            {
                return;
            }

            InfoWindow win = popupInfo.Container as InfoWindow;

            if (win != null)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    try
                    {
                        FeatureLayer featureLayer = popupInfo.PopupItem.Layer as FeatureLayer;
                        if (featureLayer == null)
                        {
                            return;
                        }

                        FeatureDataForm form = new FeatureDataForm
                        {
                            Width  = win.ActualWidth,
                            Height = win.ActualHeight,
                            Style  = PopupFeatureDataFormStyleHelper.Instance.GetStyle("PopupFeatureDataFormStyle"),
                            CommitButtonContent = Resources.Strings.Apply,
                            GraphicSource       = popupInfo.PopupItem.Graphic,
                            FeatureLayer        = featureLayer,
                            DataContext         = popupInfo,
                        };

                        form.Loaded += (s, e) =>
                        {
                            // enable switching back to the original popup content when the 'Back' button is clicked
                            List <Button> buttons = ControlTreeHelper.FindChildrenOfType <Button>(form, int.MaxValue);
                            if (buttons != null && buttons.Count > 0)
                            {
                                Button backButton = buttons.Where(b => b.Name == "BackButton").FirstOrDefault();
                                if (backButton != null)
                                {
                                    backButton.Content = Resources.Strings.EditValuesCommandEditorBackButtonContent;
                                    backButton.Click  += (ss, ee) => BackToOriginalContent(popupInfo);
                                }
                                Button closeButton = buttons.Where(b => b.Name == "CloseButton").FirstOrDefault();
                                if (closeButton != null)
                                {
                                    closeButton.Click += (ss, ee) => BackToOriginalContent(popupInfo);
                                }
                            }
                            PopupHelper.SetDisplayMode(PopupHelper.DisplayMode.EditValues);
                        };
                        win.Content = null;
                        win.Content = form;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                });
            }
        }