/// <summary> /// React on left button down. Check click on buttons or start drag otherwise. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Event args.</param> private void _PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { // Check close button pressed. if (_IsElementPressed(CloseButton, e)) { // Hide hint. Visibility = Visibility.Collapsed; } // Check tool button pressed. else if (_IsElementPressed(PushpinToolButton, e)) { // Change tool state. _AddressByPointToolPressed(); } // Check link click. else if (_IsElementPressed(ZoomedAddress, e)) { // Zoom to candidates. MapExtentHelpers.ZoomToCandidates(_mapControl, _candidatesToZoom); } else { // Start drag if mouse was clicked on canvas. GeocodingHint geocodingHint = XceedVisualTreeHelper.FindParent <GeocodingHint>((DependencyObject)e.Source); if (geocodingHint != null || e.Source == this) { _isDown = true; _startPoint = e.GetPosition(_canvas); _canvas.CaptureMouse(); e.Handled = true; } } }
/// <summary> /// Do convertion. Set background to textbox if empty value. /// </summary> /// <param name="value"></param> /// <param name="targetType">Ignored.</param> /// <param name="parameter">Ignored.</param> /// <param name="culture">Ignored.</param> /// <returns>Null, if background was set. Cell value otherwise.</returns> public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture) { TextBlock textBlock = value[1] as TextBlock; if (textBlock == null) { return(null); } // Get datagridcontrol cell. DataCell cell = XceedVisualTreeHelper.FindParent <DataCell>(textBlock); if (cell == null) { return(null); } // Get location. Location location = cell.DataContext as Location; // Get background brush. Brush backgroundBrush = _GetBackgroundBrushForCell(cell); // Brush need to be set only if address fields is empty. if (GeocodeHelpers.IsActiveAddressFieldsEmpty(location)) { // Workaround for .NET 4.0: Do not not change value if not needed. if (textBlock.Background != backgroundBrush) { textBlock.Background = backgroundBrush; } } else if (textBlock.Background != null) { textBlock.Background = null; } else { // Do nothing. } return(value[0]); }
/// <summary> /// If it is polyline barrier then hide combobox and show textblock. /// </summary> private void _InitVisibility() { // Get Barrier.Geometry type. Cell cell = XceedVisualTreeHelper.GetCellByEditor(this); Row row = XceedVisualTreeHelper.FindParent <Row>(cell); Barrier barrier = row.DataContext as Barrier; // If barrier is polyline or have no geometry hide edit control. if (barrier.Geometry == null || barrier.Geometry is ESRI.ArcLogistics.Geometry.Polyline) { _border.Visibility = System.Windows.Visibility.Hidden; _popupPanel.Child = null; _textBlock.Visibility = System.Windows.Visibility.Visible; if (barrier.Geometry is ESRI.ArcLogistics.Geometry.Polyline) { _textBlock.Text = (string)App.Current.FindResource("BlockTravelString"); } } }
/// <summary> /// React on dependency property changing. /// </summary> private void _OnValueChanged() { if (_barrier != null) { _barrier.PropertyChanged -= new PropertyChangedEventHandler(_BarrierPropertyChanged); } Cell cell = XceedVisualTreeHelper.GetCellByEditor(this); Row row = XceedVisualTreeHelper.FindParent <Row>(cell); _barrier = row.DataContext as Barrier; if (_barrierEditor != null) { _barrierEditor.Barrier = _barrier; } if (_barrier != null) { _barrier.PropertyChanged += new PropertyChangedEventHandler(_BarrierPropertyChanged); } }
/// <summary> /// Gets current background brush for cell. /// </summary> /// <param name="cell">Cell.</param> /// <returns>Current background brush.</returns> private Brush _GetBackgroundBrushForCell(DataCell cell) { Debug.Assert(cell != null); // Get layoutroot to get access to background brushes. Grid layoutRootGrid = _GetLayoutRootGrid(cell); // Get datagridcontrol to check is location first in collection. DataGridControl dataGridControl = XceedVisualTreeHelper.FindParent <DataGridControl>(cell); int indexOfItem = -1; try { // Workaround: Sometimes grid throws exception. indexOfItem = dataGridControl.Items.IndexOf(cell.DataContext); } catch { } Brush backgroundBrush; if (indexOfItem == 0) { // Use "Add location" string for first item. backgroundBrush = (Brush)layoutRootGrid.Resources[AddLocationBrushResourceName]; } else { // Use "Add another location" string for other items. backgroundBrush = (Brush)layoutRootGrid.Resources[AddAnotherLocationBrushResourceName]; } return(backgroundBrush); }