public GeoFenceWidget() { this.Resources.MergedDictionaries.Add(SharedDictionaryManager.SharedStyleDictionary); this.Resources.MergedDictionaries.Add(SharedDictionaryManager.SharedDataTemplateDictionary); InitializeComponent(); DataGridViewModel = new GeoFenceViewModel(null); DataContext = DataGridViewModel; Caption = "GeoFences"; Properties = new Dictionary <string, string>(); _bAddWidgetWindowOpen = false; // init the widget's data members from the VM TrackIdFieldName = DataGridViewModel.TrackIdFieldName; NameFieldName = DataGridViewModel.NameFieldName; CategoryFieldName = DataGridViewModel.CategoryFieldName; ActiveFieldName = DataGridViewModel.ActiveFieldName; DataGridViewModel.GetProperties(Properties); }
/// <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) { try { if (DataGridViewModel == null) { return(false); } DataGridViewModel.SkipUpdates = true; // Show the configuration dialog GeoFenceWidgetDialog dialog = new GeoFenceWidgetDialog (dataSources, Caption, DataSourceId, TrackIdFieldName, NameFieldName, CategoryFieldName, ActiveFieldName, GroupByFieldName, SortByFieldName1, SortByFieldName2, SortByFieldOrder1, SortByFieldOrder2, DataGridViewModel.Properties) { Owner = owner }; if (dialog.ShowDialog() != true) { DataGridViewModel.SkipUpdates = false; return(false); } // Retrieve the selected values for the properties from the configuration dialog. Caption = dialog.Caption; DataSourceId = dialog.DataSource.Id; TrackIdFieldName = dialog.TrackIdField.Name; NameFieldName = dialog.NameField.Name; CategoryFieldName = dialog.CategoryField.Name; ActiveFieldName = dialog.ActiveField.Name; GroupByFieldName = dialog.GroupByField.Name; SortByFieldName1 = dialog.SortByField1.Name; SortByFieldName2 = dialog.SortByField2.Name; SortByFieldOrder1 = dialog.SortByFieldOrder1; SortByFieldOrder2 = dialog.SortByFieldOrder2; SetMapWidget(dialog.DataSource); DataGridViewModel.TrackIdFieldName = TrackIdFieldName; DataGridViewModel.NameFieldName = NameFieldName; DataGridViewModel.CategoryFieldName = CategoryFieldName; DataGridViewModel.ActiveFieldName = ActiveFieldName; DataGridViewModel.GroupByFieldName = GroupByFieldName; DataGridViewModel.SortByFieldName1 = SortByFieldName1; DataGridViewModel.SortByFieldName2 = SortByFieldName2; DataGridViewModel.SortByFieldOrder1 = SortByFieldOrder1; DataGridViewModel.SortByFieldOrder2 = SortByFieldOrder2; DataGridViewModel.GetProperties(Properties); DataGridViewModel.ApplySettings(); } catch (Exception ex) { Log.TraceException("ResourceWidget::Configure", ex); } DataGridViewModel.SkipUpdates = false; return(true); }