/// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="dataGridControl">Grid from parent page.</param>
        /// <param name="layoutRoot">Parent page layout root.</param>
        /// <param name="mapContainer">Container element for map.</param>
        public GridAutoFitHelper(DataGridControlEx dataGridControl, Grid layoutRoot, FrameworkElement mapContainer)
        {
            _dataGridControl = dataGridControl;
            _dataGridControl.OnItemSourceChanged += new EventHandler(_DataGridControlItemSourceChanged);

            _layoutRoot = layoutRoot;

            _mapContainer = mapContainer;
            _mapContainer.SizeChanged += new SizeChangedEventHandler(_MapContainerSizeChanged);

            _ProcessNewItemsSource();
        }
        /// <summary>
        /// Create GeocodablePage.
        /// </summary>
        /// <param name="geocodableType">Geocodable type.</param>
        /// <param name="mapCtrl">Map from parent page.</param>
        /// <param name="candidateSelect">Control for selecting candidates.</param>
        /// <param name="controlsGrid">Grid, that contains map and candidateselect control.</param>
        /// <param name="geocodableGrid">Grid with geocodable items from parent page.</param>
        /// <param name="splitter">Splitter between map and candidateSelectControl.</param>
        /// <param name="parentLayer">Layer, that contains regions.</param>
        public GeocodablePage(Type geocodableType, MapControl mapCtrl, CandidateSelectControl candidateSelect,
            Grid controlsGrid, DataGridControlEx geocodableGrid, GridSplitter splitter, ObjectLayer parentLayer)
        {
            Debug.Assert(mapCtrl != null);
            Debug.Assert(candidateSelect != null);
            Debug.Assert(controlsGrid != null);
            Debug.Assert(geocodableGrid != null);
            Debug.Assert(splitter != null);
            Debug.Assert(parentLayer != null);

            _mapCtrl = mapCtrl;

            _candidateSelect = candidateSelect;
            _candidateSelect.Initialize(geocodableType);
            _controlsGrid = controlsGrid;
            _geocodableGrid = geocodableGrid;
            _splitter = splitter;
            _parentLayer = parentLayer;

            _geocodableType = geocodableType;

            _collapsed = new GridLength(0, GridUnitType.Star);
            _expanded = controlsGrid.ColumnDefinitions[SELECTORGRIDINDEX].Width;
            _collapsedMinWidth = 0;
            _expandedMinWidth = controlsGrid.ColumnDefinitions[SELECTORGRIDINDEX].MinWidth;
            _CollapseCandidateSelect();

            // Subscribe to grid loaded event.
            _geocodableGrid.Loaded += new RoutedEventHandler(_GeocodableGridLoaded);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="dataGrid">DataGridControlEx.</param>
        /// 
        public ValidationCalloutController(DataGridControlEx dataGrid)
        {
            // Check input parameter.
            Debug.Assert(dataGrid != null);

            // Init fields.
            _dataGrid = dataGrid;
            var context = DataGridControl.GetDataGridContext(_dataGrid);
            _collection = context.Items;

            // When page loaded - do validation and subscribe to events.
            dataGrid.Loaded += (sender, args) =>
            {
                // Do initial validation.
                _Validate();

                // Subscribe to events.
                _InitEventHandlers();
            };

            // When page unloaded - close callout and unsubscribe from events.
            dataGrid.Unloaded += (sender, args) =>
            {
                // Close popup.
                _ClosePopup(false);

                // Unsubscribe from events.
                _UnsubscribeFromEvents();
            };

            // Init timer, which will hide callout.
            _InitTimer();
        }
        /// <summary>
        /// Make this grid visible and hide all other.
        /// </summary>
        /// <param name="grid">DataGridControlEx.</param>
        private void _InitGridVisibility(DataGridControlEx grid)
        {
            DriveTimeGrid.Visibility = System.Windows.Visibility.Collapsed;
            WorkTimeGrid.Visibility = System.Windows.Visibility.Collapsed;
            TimeWindowGrid.Visibility = System.Windows.Visibility.Collapsed;

            grid.Visibility = System.Windows.Visibility.Visible;
        }
        /// <summary>
        /// Init grid for the currently selected breaks type.
        /// </summary>
        private void _InitProperGrid()
        {
            // Init grid, corresponding to currently selected breaks type.
            if (App.Current.Project.BreaksSettings.BreaksType == BreakType.TimeWindow)
            {
                // Get repository with grid setting.
                _gridSettingsRepository = Properties.Settings.Default.TimeWindowBreaksGridSettings;

                // If there is no - create it.
                if (_gridSettingsRepository == null)
                {
                    Properties.Settings.Default.TimeWindowBreaksGridSettings = new SettingsRepository();
                    _gridSettingsRepository = Properties.Settings.Default.TimeWindowBreaksGridSettings;
                }

                // Get grid's collection source.
                _currentCollectionSource =
                    (DataGridCollectionViewSource)LayoutRoot.FindResource(TIMEWINDOW_COLLECTION_SOURCE_KEY);

                // Make this grid visible and hide all other grids.
                _InitGridVisibility(TimeWindowGrid);

                _currentGrid = TimeWindowGrid;
            }
            else if (App.Current.Project.BreaksSettings.BreaksType == BreakType.DriveTime)
            {
                // Get repository with grid setting.
                _gridSettingsRepository = Properties.Settings.Default.DriveTimeBreaksGridSettings;

                // If there is no - create it.
                if (_gridSettingsRepository == null)
                {
                    Properties.Settings.Default.DriveTimeBreaksGridSettings = new SettingsRepository();
                    _gridSettingsRepository = Properties.Settings.Default.DriveTimeBreaksGridSettings;
                }

                // Get grid's collection source.
                _currentCollectionSource =
                    (DataGridCollectionViewSource)LayoutRoot.FindResource(DRIVETIME_COLLECTION_SOURCE_KEY);

                // Make this grid visible and hide all other grids.
                _InitGridVisibility(DriveTimeGrid);
                _currentGrid = DriveTimeGrid;
            }
            else if (App.Current.Project.BreaksSettings.BreaksType == BreakType.WorkTime)
            {
                // Get repository with grid setting.
                _gridSettingsRepository = Properties.Settings.Default.WorkTimeBreaksGridSettings;

                // If there is no - create it.
                if (_gridSettingsRepository == null)
                {
                    Properties.Settings.Default.WorkTimeBreaksGridSettings = new SettingsRepository();
                    _gridSettingsRepository = Properties.Settings.Default.WorkTimeBreaksGridSettings;
                }

                // Get grid's collection source.
                _currentCollectionSource =
                    (DataGridCollectionViewSource)LayoutRoot.FindResource(WORKTIME_COLLECTION_SOURCE_KEY);

                // Make this grid visible and hide all other grids.
                _InitGridVisibility(WorkTimeGrid);
                _currentGrid = WorkTimeGrid;
            }
            else
                // This breaks type isn't supported.
                Debug.Assert(false);

            // Subscribe to event.
            _currentGrid.SelectionChanged += new DataGridSelectionChangedEventHandler
                (_XceedGridSelectionChanged);
        }
 /// <summary>
 /// Init grid structure for Grid.
 /// </summary>
 /// <param name="gridStructure">Structure of the grid.</param>
 /// <param name="gridSettingsRepositoryName">Repository with grid settings.</param>
 /// <param name="grid">Grid.</param>
 /// <param name="collectionSource">Grid's collection source.</param>
 private void _InitGridStructure(string gridStructure, string gridSettingsRepositoryName,
     DataGridControlEx grid, DataGridCollectionViewSource collectionSource)
 {
     // Initializing gridstructure and gridlayout.
     GridStructureInitializer structureInitializer = new GridStructureInitializer
         (gridStructure);
     structureInitializer.BuildGridStructure(collectionSource, grid);
     GridLayoutLoader layoutLoader = new GridLayoutLoader(gridSettingsRepositoryName,
         collectionSource.ItemProperties);
     layoutLoader.LoadLayout(grid);
 }
        /// <summary>
        /// Register grid collection.
        /// </summary>
        /// <param name="grid">Grid to register.</param>
        public void RegisterCollection(DataGridControlEx grid)
        {
            Debug.Assert(grid != null);

            _RegisterCollection(grid);
        }
        /// <summary>
        /// Register grid collection.
        /// </summary>
        /// <param name="grid">Grid to register.</param>
        protected void _RegisterCollection(DataGridControlEx grid)
        {
            Debug.Assert(grid != null);
            Debug.Assert(_grids != null);

            grid.SelectionChanged += new DataGridSelectionChangedEventHandler(_GridSelectionChanged);
            _grids.Add(grid);
            _AddCollection(grid.SelectedItems);
        }
 /// <summary>
 /// Register grid collection.
 /// </summary>
 /// <param name="grid">Grid to register.</param>
 /// <param name="multiCollectionFilter">Collection filter.</param>
 public void RegisterCollection(DataGridControlEx grid, MultiCollectionFilter multiCollectionFilter)
 {
     _multiCollectionFilters.Add(multiCollectionFilter);
     _RegisterCollection(grid);
 }
示例#10
0
        /// <summary>
        /// Create RegionsPage.
        /// </summary>
        /// <param name="mapCtrl">Map from parent page.</param>
        /// <param name="dataGridControl">Grid from parent page.</param>
        /// <param name="parentLayer">Layer, that contains regions.</param>
        /// <param name="type">Semantic type of regions. Barrier or Zone.</param>
        /// <param name="layoutRoot">Parent page layout root.</param>
        /// <param name="mapBorder">Container element for map.</param>
        public RegionsPage(MapControl mapCtrl, DataGridControlEx dataGridControl, ObjectLayer parentLayer,
            Type type, Grid layoutRoot, Border mapBorder)
        {
            _mapCtrl = mapCtrl;
            _mapCtrl.CanSelectCallback = _CanSelect;
            _mapCtrl.StartEditRegionCallback = _EditStarted;
            _mapCtrl.EndEditRegionCallback = _EditEnded;

            _dataGridControl = dataGridControl;

            _parentLayer = parentLayer;

            _type = type;

            if (_type == typeof(Zone))
            {
                _polygonTool = new ZonePolygonTool();
                _polygonTool.OnComplete += new EventHandler(_PolygonToolOnComplete);
                _mapCtrl.AddTool(_polygonTool, _CanActivateZonePolygonTool);
            }
            else if (_type == typeof(Barrier))
            {
                _CreateBarrierTools();
            }
            else
                Debug.Assert(false);

            _gridAutoFitHelper = new GridAutoFitHelper(dataGridControl, layoutRoot, mapBorder);
        }