Ejemplo n.º 1
0
 private void ViewDataClick(object sender, RoutedEventArgs e)
 {
     if (GisEditor.ActiveMap.ActiveLayer is FeatureLayer)
     {
         DataViewerUserControl content = new DataViewerUserControl();
         content.ShowDialog();
     }
 }
 private void InitializeCommands()
 {
     viewDataCommand = new RelayCommand(() =>
     {
         DataViewerUserControl content = new DataViewerUserControl();
         content.ShowDialog();
     });
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SplitWizardShareObject dataSource = (SplitWizardShareObject)DataContext;

            DataViewerUserControl content = new DataViewerUserControl(dataSource.SelectedLayerToSplit);

            content.IsHighlightFeatureOnly = dataSource.UseSelectedFeaturesOnly;
            content.ShowDialog();
        }
        private void InitializeCommands()
        {
            addConditionCommand = new RelayCommand(() =>
            {
                FilterConditionWindow newFilterConditionWindow = new FilterConditionWindow();
                FilterConditionViewModel itemViewModel         = new FilterConditionViewModel(RequiredValues);
                itemViewModel.PropertyChanged       += ItemViewModel_PropertyChanged;
                newFilterConditionWindow.DataContext = itemViewModel;
                foreach (var item in columnNameTypes)
                {
                    newFilterConditionWindow.ViewModel.ColumnNameTypes[item.Key] = item.Value;
                }

                newFilterConditionWindow.ViewModel.SelectedColumnName = newFilterConditionWindow.ViewModel.ColumnNames.FirstOrDefault();
                if (newFilterConditionWindow.ShowDialog().GetValueOrDefault())
                {
                    var stylePlugin = GisEditor.StyleManager.GetDefaultStylePlugin(requiredValues.AvailableStyleCategories);

                    filterConditions.Add(newFilterConditionWindow.ViewModel);
                    SyncConditions();
                    RaisePropertyChanged("FilterConditions");
                }
            });

            editConditionCommand = new RelayCommand <FilterConditionViewModel>(v =>
            {
                var clonedViewModel = v.CloneDeep();
                clonedViewModel.ColumnNameTypes.Clear();

                foreach (var item in columnNameTypes)
                {
                    clonedViewModel.ColumnNameTypes[item.Key] = item.Value;
                }

                FilterConditionWindow newFilterConditionWindow = new FilterConditionWindow(clonedViewModel);

                FeatureLayerPlugin resultLayerPlugin = GisEditor.LayerManager.GetLayerPlugins(RequiredValues.FeatureLayer.GetType()).LastOrDefault() as FeatureLayerPlugin;

                if (resultLayerPlugin != null)
                {
                    Collection <IntermediateColumn> columns = resultLayerPlugin.GetIntermediateColumns(requiredValues.FeatureLayer.FeatureSource);
                    foreach (var item in columns)
                    {
                        newFilterConditionWindow.ViewModel.ColumnNameTypes[item.ColumnName] = item.IntermediateColumnType;
                    }
                }

                if (newFilterConditionWindow.ShowDialog().Value)
                {
                    var index = FilterConditions.IndexOf(v);
                    if (index != -1)
                    {
                        v = clonedViewModel;
                        FilterConditions.RemoveAt(index);
                        FilterConditions.Insert(index, v);
                    }
                }

                SyncConditions();
            });

            removeConditionCommand = new RelayCommand <FilterConditionViewModel>(v =>
            {
                if (FilterConditions.Contains(v))
                {
                    var messageBoxResult = System.Windows.Forms.MessageBox.Show(GisEditor.LanguageManager.GetStringResource("FilterStyleViewModelConditionRemovedMessage")
                                                                                , "Alert"
                                                                                , System.Windows.Forms.MessageBoxButtons.YesNo);

                    if (messageBoxResult == System.Windows.Forms.DialogResult.Yes)
                    {
                        FilterConditions.Remove(v);
                        SyncConditions();
                        RaisePropertyChanged("FilterConditions");
                    }
                }
            });

            testScriptCommand = new RelayCommand(() =>
            {
                try
                {
                    var result = actualFilterStyle.GetRequiredColumnNames().All(c => requiredValues.ColumnNames.Contains(c));
                    if (!result)
                    {
                        MessageBox.Show(GisEditor.LanguageManager.GetStringResource("FilterStyleUserControlColumnMessage"));
                    }
                    else
                    {
                        Collection <Feature> features   = new Collection <Feature>();
                        ScriptFilterCondition condition = actualFilterStyle.Conditions.OfType <ScriptFilterCondition>().FirstOrDefault();
                        if (condition != null)
                        {
                            condition.GetMatchingFeatures(features);
                        }
                        MessageBox.Show(GisEditor.LanguageManager.GetStringResource("TestPassMessage"));
                    }
                }
                catch (Exception ex)
                {
                    GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
                    MessageBox.Show(ex.Message);
                }
            });

            viewDataCommand = new RelayCommand(() =>
            {
                DataViewerUserControl content = new DataViewerUserControl();
                content.ShowDialog();
            });

            showResultsCommand = new ObservedCommand(() =>
            {
                ShowFilteredData(requiredValues.FeatureLayer, FilterConditions.Select(f => f.FilterCondition), "");
            }, () => filterConditions.Count > 0);
        }
        private void ViewDataClick(object sender, RoutedEventArgs e)
        {
            DataViewerUserControl content = new DataViewerUserControl(StyleBuilderArguments.FeatureLayer);

            content.ShowDialog();
        }