/// <summary> /// Inits data grid layout /// </summary> protected void _InitDataGridLayout() { DataGridCollectionViewSource collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY); Debug.Assert(!string.IsNullOrEmpty(GridStructureName)); GridStructureInitializer gridStructureInitializer = new GridStructureInitializer(GridStructureName); gridStructureInitializer.BuildGridStructure(collectionSource, XceedGrid); // load grid layout Debug.Assert(!string.IsNullOrEmpty(SettingsRepositoryName)); GridLayoutLoader vehicleLayoutLoader = new GridLayoutLoader(SettingsRepositoryName, collectionSource.ItemProperties); vehicleLayoutLoader.LoadLayout(XceedGrid); _isDataGridLayoutLoaded = true; }
/// <summary> /// Prepare data grid control to work. /// </summary> private void _InitDataGridControl() { _collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY); // Initialize grid structure. GridStructureInitializer structureInitializer = new GridStructureInitializer(GridSettingsProvider.FleetGeocodableGridStructure); structureInitializer.BuildGridStructure(_collectionSource, DataGridControl); // Find index for first non-Name field to determine it as Address Field. int columnIndex = 0; for (int i = 0; i < DataGridControl.Columns.Count; i++) { if (DataGridControl.Columns[i].FieldName != NAME_COLUMN) { columnIndex = i; break; // Work done: first non-Name field found. } } // Set special content template to show "Add location" string. ColumnBase addressColumn = DataGridControl.Columns[columnIndex]; addressColumn.CellContentTemplate = (DataTemplate)App.Current.FindResource(ADDRESSLINE_CONTENT_TEMPLATE_NAME); CommonHelpers.HidePostalCode2Column(DataGridControl); // Load grid layout. GridLayoutLoader layoutLoader = new GridLayoutLoader(GridSettingsProvider.FleetLocationsSettingsRepositoryName, _collectionSource.ItemProperties); layoutLoader.LoadLayout(DataGridControl); }
/// <summary> /// Inits page GUI elements. /// </summary> protected void _InitPageContent() { App.Current.MainWindow.StatusBar.SetStatus(this, null); if (!_isLoaded) { _viewSourceReports = (DataGridCollectionViewSource)mainGrid.FindResource("reportsTable"); GridStructureInitializer structureInitializer = new GridStructureInitializer(GRID_STRUCTURE_REPORT_PREFERENCES); structureInitializer.BuildGridStructure(_viewSourceReports, xceedGridReports); ColumnBase columnName = xceedGridReports.Columns["Name"]; columnName.ReadOnly = false; columnName.CellValidationRules.Add(new ReportTemplateValidationRule()); xceedGridReports.OnItemSourceChanged += new EventHandler(_OnItemSourceChanged); _InitReportTable(); _isLoaded = true; } }
/// <summary> /// Method inits collection of projects. /// </summary> private void _InitProjectsCollection() { _collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource("projectSource"); GridStructureInitializer structureInitializer = new GridStructureInitializer(GridSettingsProvider.ProjectsGridStructure); structureInitializer.BuildGridStructure(_collectionSource, XceedGrid); XceedGrid.Columns[IS_CURRENT_COLUMN_CAPTION].CellEditor = (CellEditor)LayoutRoot.FindResource("ProjectsRadioButtonEditor"); XceedGrid.Columns[IS_CURRENT_COLUMN_CAPTION].CellContentTemplate = (DataTemplate)LayoutRoot.FindResource("RadioButtonTemplate"); XceedGrid.Columns[IS_CURRENT_COLUMN_CAPTION].CellEditorDisplayConditions = CellEditorDisplayConditions.Always; XceedGrid.Columns[NAME_COLUMN_CAPTION].CellValidationRules.Add(new ProjectNameValidationRule()); _BuildProjectsWrapperCollection(); _UpdateProjectsCheckboxes(); _collectionSource.Source = _projectsDataCollection; _isInited = true; }
/// <summary> /// Method inits all xceed data grid controls (sets collection source and columns structure foreach of them). /// </summary> private void _InitGridControl() { _isNewItemCreated = false; // init grid structure if (_collectionSource == null) _collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(ROUTES_COLLECTION_SOURCE_NAME); // Set collection source to null to refresh items collection. _collectionSource.Source = null; GridStructureInitializer initializer = new GridStructureInitializer(GridSettingsProvider.RoutesGridStructure); initializer.BuildGridStructure(_collectionSource, RoutesGrid); // init detail structure DetailConfiguration orders = (DetailConfiguration)LayoutRoot.FindResource(ROUTES_DETAIL_CONFIGURATION_NAME); GridStructureInitializer detailInitializer = new GridStructureInitializer(GridSettingsProvider.StopsGridStructure); detailInitializer.BuildDetailStructure(_collectionSource, RoutesGrid, orders); // load grid layout GridLayoutLoader layoutLoader = new GridLayoutLoader(GridSettingsProvider.RoutesSettingsRepositoryName, _collectionSource.ItemProperties, _collectionSource.DetailDescriptions[0].ItemProperties); layoutLoader.LoadLayout(RoutesGrid); }
/// <summary> /// Method inits all xceed data grid controls (sets collection source and columns structure foreach of them). /// </summary> private void _InitGridControl() { _isNewItemCreated = false; _collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(ORDERS_COLLECTION_SOURCE_NAME); GridStructureInitializer initializer = new GridStructureInitializer(GridSettingsProvider.OrdersGridStructure); initializer.BuildGridStructure(_collectionSource, OrdersGrid); // load grid layout GridLayoutLoader layoutLoader = new GridLayoutLoader(GridSettingsProvider.OrdersSettingsRepositoryName, _collectionSource.ItemProperties); layoutLoader.LoadLayout(OrdersGrid); }
protected void _InitDataGridLayout() { DataGridCollectionViewSource collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY); GridStructureInitializer structureInitializer = new GridStructureInitializer(GridSettingsProvider.DriversGridStructure); structureInitializer.BuildGridStructure(collectionSource, XceedGrid); // load grid layout GridLayoutLoader layoutLoader = new GridLayoutLoader(GridSettingsProvider.DriversSettingsRepositoryName, collectionSource.ItemProperties); layoutLoader.LoadLayout(XceedGrid); _isDataGridLayoutLoaded = true; }
/// <summary> /// Inits page state. /// </summary> private void _Init() { Debug.Assert(!_isInited); _viewSourceRoutes = mainGrid.FindResource(ROUTES_TABLE_CONFIGURATION_NAME) as DataGridCollectionViewSource; _InitGridStructure(_viewSourceRoutes, xceedGridRoutes, GridSettingsProvider.ReportRoutesGridStructure, CELL_EDITOR_RESOURCE_NAME); _viewSourceTemplates = mainGrid.FindResource(TEMPLATES_TABLE_CONFIGURATION_NAME) as DataGridCollectionViewSource; _InitGridStructure(_viewSourceTemplates, xceedGridTemplates, GridSettingsProvider.ReportTemplatesGridStructure, CELL_EDITOR_RESOURCE_NAME_EX); // init template detail structure var subReport = mainGrid.FindResource(REPORT_TEMPLATE_DETAIL_CONFIGURATION_NAME) as DetailConfiguration; var detailInitializer = new GridStructureInitializer(GridSettingsProvider.ReportTemplatesGridStructure); detailInitializer.BuildDetailStructure(_viewSourceTemplates, xceedGridTemplates, subReport); _InitCheckBox(subReport.Columns, CELL_EDITOR_RESOURCE_NAME_EX); // subscribe on value change event of ItemSource property var dpd = DependencyPropertyDescriptor.FromProperty(DataGridControl.ItemsSourceProperty, typeof(DataGridControl)); dpd.AddValueChanged(xceedGridTemplates, _xceedGridTemplates_OnItemSourceChanged); _viewSourceReports = mainGrid.FindResource(REPORTS_TABLE_CONFIGURATION_NAME) as DataGridCollectionViewSource; _InitGridStructure(_viewSourceReports, xceedGridReports, GridSettingsProvider.ReportReportsGridStructure, null); _viewSourceReports.Source = new List<ReportDataWrapper>(); xceedGridReports.OnItemSourceChanged += new EventHandler(_xceedGridReports_OnItemSourceChanged); _isInited = true; }
/// <summary> /// Inits grid structure. /// </summary> /// <param name="source">Grid view source.</param> /// <param name="xceedGrid">Grid object.</param> /// <param name="sourceXAML">Source greed XAML-file.</param> /// <param name="cellEditorName">CheckBox cell editor resource name (can be null).</param> private void _InitGridStructure(DataGridCollectionViewSource source, DataGridControl xceedGrid, string sourceXAML, string cellEditorName) { Debug.Assert(null != source); Debug.Assert(null != xceedGrid); Debug.Assert(!string.IsNullOrEmpty(sourceXAML)); var structureInitializer = new GridStructureInitializer(sourceXAML); structureInitializer.BuildGridStructure(source, xceedGrid); if (!string.IsNullOrEmpty(cellEditorName)) _InitCheckBox(xceedGrid.Columns, cellEditorName); }
/// <summary> /// Loads grid layout. /// </summary> private void _InitDataGridLayout() { if (_collectionSource == null) { _collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY); } var structureInitializer = new GridStructureInitializer(GridSettingsProvider.BarriersGridStructure); structureInitializer.BuildGridStructure(_collectionSource, XceedGrid); // load grid layout var layoutLoader = new GridLayoutLoader(GridSettingsProvider.BarriersSettingsRepositoryName, _collectionSource.ItemProperties); layoutLoader.LoadLayout(XceedGrid); // Find geometry field and... foreach (Column column in XceedGrid.Columns) { if (column.FieldName == GEOMETRY_FIELD_NAME) { // ...set field width to default one, // to let users know about this fields is exists. ColumnBase geometryColumn = XceedGrid.Columns[GEOMETRY_FIELD_NAME]; if (geometryColumn.Width == 0) geometryColumn.Width = DEFAULT_COLUMN_WIDTH; break; // Work done. } } _isLayoutLoaded = true; }
/// <summary> /// Method loads grid layout /// </summary> private void _InitQuantitiesDataGridLayout() { DataGridCollectionViewSource collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource("quantityCollection"); collectionSource.Source = SymbologyManager.OrderQuantities; GridStructureInitializer structureInitializer = new GridStructureInitializer("ESRI.ArcLogistics.App.GridHelpers.QuantitySymbologyGridStructure.xaml"); structureInitializer.BuildGridStructure(collectionSource, QuantityXceedGrid); // load grid layout GridLayoutLoader layoutLoader = new GridLayoutLoader("QuantitiesGridSettings", collectionSource.ItemProperties); layoutLoader.LoadLayout(QuantityXceedGrid); QuantityValidationRule valuesValidationRule = new QuantityValidationRule(); QuantityXceedGrid.Columns[MINVALUE_COLUMN_INDEX].CellValidationRules.Add(valuesValidationRule); QuantityXceedGrid.Columns[MAXVALUE_COLUMN_INDEX].CellValidationRules.Add(valuesValidationRule); }
/// <summary> /// Inits grid structure. /// </summary> /// <param name="source">Data view source.</param> /// <param name="gridName">Grid name.</param> private void _InitGridStructure(DataGridCollectionViewSource source, string gridName) { Debug.Assert(null != source); Debug.Assert(!string.IsNullOrEmpty(gridName)); var structureInitializer = new GridStructureInitializer(GridSettingsProvider.ExportFieldsGridStructure); var xceedGrid = (DataGridControl)ctrlFields.FindName(gridName); structureInitializer.BuildGridStructure(source, xceedGrid); ColumnBase columnCkecked = xceedGrid.Columns["IsChecked"]; columnCkecked.CellEditor = (CellEditor)layoutRoot.FindResource("CheckBoxCellEditor"); columnCkecked.Width = 25; }
/// <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> /// React on page loaded. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Ignored.</param> private void _FleetSetupWizardUngeocodedOrdersPageLoaded(object sender, RoutedEventArgs e) { // Init page if not inited yet. if (!_inited) { _isParentFleetWizard = DataKeeper != null; // Set row height. ContentGrid.RowDefinitions[DATA_GRID_ROW_DEFINITION_INDEX].Height = new System.Windows.GridLength(DEFAULT_ROW_HEIGHT * ROW_COUNT + DataGridControl.Margin.Top + DataGridControl.Margin.Bottom + ROW_COUNT); // Create subpages. string typeName = (string)App.Current.FindResource(ORDER_RESOURCE_NAME); typeName = typeName.ToLower(); _matchFoundSubPage = new MatchFoundSubPage(typeName); _candidatesNotFoundSubPage = new CandidatesNotFoundSubPage(typeName); _candidatesFoundSubPage = new CandidatesFoundSubPage(typeName); _SetSubPage(null); // Init orders collection. _collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY); _CreateOrdersLayer(); // Create and init geocodable page. _geocodablePage = new GeocodablePage(typeof(Order), mapCtrl, candidateSelect, controlsGrid, DataGridControl, splitter, _ordersLayer); _geocodablePage.MatchFound += new EventHandler(_MatchFound); _geocodablePage.CandidatesFound += new EventHandler(_CandidatesFound); _geocodablePage.CandidatesNotFound += new EventHandler(_CandidatesNotFound); // Datakeeper is not null in fleetwizard. _geocodablePage.ParentIsFleetWisard = _isParentFleetWizard; mapCtrl.AddTool(new EditingTool(), null); _collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY); GridStructureInitializer structureInitializer = new GridStructureInitializer(GridSettingsProvider.FleetGeocodableGridStructure); structureInitializer.BuildGridStructure(_collectionSource, DataGridControl); CommonHelpers.HidePostalCode2Column(DataGridControl); // Load grid layout. GridLayoutLoader layoutLoader = new GridLayoutLoader(GridSettingsProvider.FleetLocationsSettingsRepositoryName, _collectionSource.ItemProperties); layoutLoader.LoadLayout(DataGridControl); if (!_isParentFleetWizard) _RemoveRedundantElements(); _inited = true; } // Get orders collection from datakeeper if it is not null. Otherwise - from current project. if (_isParentFleetWizard) { // Fill ungeocoded orders list. _FillUngeocodedOrders(DataKeeper.AddedOrders); } else { // Do nothing. Ungeocoded order already set by constructor. } _collectionSource.Source = _ungeocodedOrders; _ordersLayer.Collection = _ungeocodedOrders; _selectionBinding.UnregisterAllCollections(); _selectionBinding.RegisterCollection(DataGridControl); _selectionBinding.RegisterCollection(mapCtrl.SelectedItems); ButtonFinish.IsEnabled = _IsFinishButtonEnabled(_ungeocodedOrders); }
/// <summary> /// Loads grid layout. /// </summary> private void _InitDataGridLayout() { if (_collectionSource == null) _collectionSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY); GridStructureInitializer structureInitializer = new GridStructureInitializer(GridSettingsProvider.ZonesGridStructure); structureInitializer.BuildGridStructure(_collectionSource, XceedGrid); // Load grid layout. GridLayoutLoader layoutLoader = new GridLayoutLoader(GridSettingsProvider.ZonesSettingsRepositoryName, _collectionSource.ItemProperties); layoutLoader.LoadLayout(XceedGrid); _isDataGridLayoutLoaded = true; }
private void _InitDataGridLayout() { DataGridCollectionViewSource fuelsCollection = (DataGridCollectionViewSource)LayoutRoot.FindResource(COLLECTION_SOURCE_KEY); GridStructureInitializer structureInitializer = new GridStructureInitializer(GridSettingsProvider.FuelTypesGridStructure); structureInitializer.BuildGridStructure(fuelsCollection, XceedGrid); // load grid layout GridLayoutLoader layoutLoader = new GridLayoutLoader(GridSettingsProvider.FuelTypesSettingsRepositoryName, fuelsCollection.ItemProperties); layoutLoader.LoadLayout(XceedGrid); _isDataGridLayoutLoaded = true; }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Method inits context of XceedGrid. /// </summary> private void _InitGUI() { if (!_isInited) { _collectionSource = (DataGridCollectionViewSource)layoutRoot.FindResource("messageTable"); GridStructureInitializer structureInitializer = new GridStructureInitializer(GridSettingsProvider.MessageWindowGridStructure); structureInitializer.BuildGridStructure(_collectionSource, xceedGrid); xceedGrid.DetailConfigurations.Clear(); xceedGrid.DetailConfigurations.Add((DetailConfiguration)layoutRoot.FindResource("messageDetailConfiguration")); // collaps all detail and reexpand it. List<DataGridContext> dataGridContexts = new List<DataGridContext>(xceedGrid.GetChildContexts()); foreach (DataGridContext dataGridContext in dataGridContexts) { dataGridContext.ParentDataGridContext.CollapseDetails(dataGridContext.ParentItem); dataGridContext.ParentDataGridContext.ExpandDetails(dataGridContext.ParentItem); } _collectionSource.Source = _data; _isInited = true; } }
/// <summary> /// Method loads layout of Custom order properties data grid. /// </summary> private void _InitDataGridLayout() { // Get Data grid collection view source. DataGridCollectionViewSource gridCollectionViewSource = (DataGridCollectionViewSource)LayoutRoot.FindResource(CUSTOM_ORDER_PROPERTIES_COLLECTION_SOURCE_KEY); // Bind collection of custom order properties to Xceed DataGrid. gridCollectionViewSource.Source = _customOrderProperties; //Grid structure file name. string gridStructureFileName = GridSettingsProvider.CustomOrderPropertiesGridStructure; // Grid structure initializer. GridStructureInitializer gridStructureInitializer = new GridStructureInitializer(gridStructureFileName); // Build structure of Xceed DataGrid. gridStructureInitializer.BuildGridStructure(gridCollectionViewSource, _customOrderPropertiesXceedGrid); // Grid settings repository name. string gridSettingsRepositoryName = GridSettingsProvider.CustomOrderPropertiesSettingsRepositoryName; // Grid layout loader. GridLayoutLoader gridLayoutLoader = new GridLayoutLoader(gridSettingsRepositoryName, gridCollectionViewSource.ItemProperties); // Load grid layout. gridLayoutLoader.LoadLayout(_customOrderPropertiesXceedGrid); }