コード例 #1
0
        /// <summary>
        ///  Provides functionality for the widget to be configured by the end user through a dialog.
        /// </summary>
        /// <param name="owner">The application window which should be the owner of the dialog.</param>
        /// <param name="dataSources">The complete list of DataSources in the configuration.</param>
        /// <returns>True if the user clicks ok, otherwise false.</returns>
        public bool Configure(Window owner, IList <OD.DataSource> dataSources)
        {
            StopViewModel vm = DataGridViewModel as StopViewModel;

            if (vm == null)
            {
                return(false);
            }

            try
            {
                vm.SkipUpdates = true;

                // Show the configuration dialog.
                StopWidgetDialog dialog = new StopWidgetDialog
                                              (dataSources, Caption, StopDataSourceId, TrackIdFieldName,
                                              GroupByFieldName, SortByFieldName1, SortByFieldName2,
                                              SortByFieldOrder1, SortByFieldOrder2, StopsRouteNameFieldName,
                                              RouteDataSourceId, RoutesRouteNameFieldName,
                                              vm.Properties)
                {
                    Owner = owner
                };

                if (dialog.ShowDialog() != true)
                {
                    vm.SkipUpdates = false;
                    return(false);
                }

                // Retrieve the selected values for the properties from the configuration dialog.
                Caption                  = dialog.Caption;
                StopDataSourceId         = dialog.StopDataSource.Id;
                TrackIdFieldName         = dialog.TrackIdField.Name;
                GroupByFieldName         = dialog.GroupByField.Name;
                SortByFieldName1         = dialog.SortByField1.Name;
                SortByFieldName2         = dialog.SortByField2.Name;
                SortByFieldOrder1        = dialog.SortByFieldOrder1;
                SortByFieldOrder2        = dialog.SortByFieldOrder2;
                StopsRouteNameFieldName  = dialog.StopsRouteNameField.Name;
                RouteDataSourceId        = dialog.RouteDataSource.Id;
                RoutesRouteNameFieldName = dialog.RoutesRouteNameField.Name;

                vm.TrackIdFieldName         = TrackIdFieldName;
                vm.GroupByFieldName         = GroupByFieldName;
                vm.SortByFieldName1         = SortByFieldName1;
                vm.SortByFieldName2         = SortByFieldName2;
                vm.SortByFieldOrder1        = SortByFieldOrder1;
                vm.SortByFieldOrder2        = SortByFieldOrder2;
                vm.StopsRouteNameFieldName  = StopsRouteNameFieldName;
                vm.RoutesRouteNameFieldName = RoutesRouteNameFieldName;

                vm.GetProperties(Properties);

                vm.ApplySettings();
            }
            catch (Exception ex)
            {
                Log.TraceException("ResourceWidget::Configure", ex);
            }

            vm.SkipUpdates = false;
            return(true);
        }