protected override void UpdateUICore(UserControl styleItemUI)
        {
            base.UpdateUICore(styleItemUI);

            var viewModel = styleItemUI.DataContext as ValueStyleViewModel;

            if (viewModel != null && viewModel.ValueItems.Count != Children.Count)
            {
                List <ValueItemEntity> temps = viewModel.ValueItems.ToList();
                viewModel.ValueItems.Clear();
                foreach (var subItem in Children.OfType <StyleLayerListItem>())
                {
                    var valueItem = subItem.ConcreteObject as ValueItem;
                    var item      = new ValueItemEntity();
                    item.PropertyChanged += Item_PropertyChanged;
                    item.ValueItem        = valueItem;
                    item.MatchedValue     = valueItem.Value;
                    item.Image            = StyleHelper.GetImageFromStyle(valueItem.CustomStyles);
                    ValueItemEntity temp = temps.FirstOrDefault(v => v.ValueItem == valueItem);
                    if (temp != null)
                    {
                        item.Count = temp.Count;
                    }
                    viewModel.ValueItems.Add(item);
                }
            }
        }
        private void InitializeValueItems()
        {
            valueItems = new ObservableCollection <ValueItemEntity>(actualValueStyle.ValueItems.Select(tmpItem =>
            {
                var image = StyleHelper.GetImageFromStyle(tmpItem.CustomStyles.LastOrDefault());
                return(GetValueItemEntity(image, tmpItem.Value, tmpItem));
            }).ToList());

            valueItems.CollectionChanged += (s, e) => { SyncActualValueItems(); };
        }
示例#3
0
        protected override void UpdateUICore(UserControl styleItemUI)
        {
            var viewModel = styleItemUI.DataContext as ClassBreakStyleViewModel;

            if (viewModel != null)
            {
                var currentClassBreakItem = viewModel.ClassBreakItems.FirstOrDefault(c => c.ClassBreak == ConcreteObject);
                viewModel.SelectedClassBreakItem = currentClassBreakItem;

                currentClassBreakItem.Image = StyleHelper.GetImageFromStyle(currentClassBreakItem.ClassBreak.CustomStyles);
            }
        }
        private void Add()
        {
            if (string.IsNullOrEmpty(ColumnName))
            {
                System.Windows.Forms.MessageBox.Show(GisEditor.LanguageManager.GetStringResource("ValueStyleViewModelColumnCanntEmptyMessage"), "Column is Empty");
            }
            else
            {
                var stylePlugin = GisEditor.StyleManager.GetDefaultStylePlugin(requiredValues.AvailableStyleCategories);
                if (stylePlugin != null)
                {
                    var newValueItem = new ValueItem();
                    newValueItem.Value = "Undefined";
                    newValueItem.CustomStyles.Add(stylePlugin.GetDefaultStyle());

                    var image           = StyleHelper.GetImageFromStyle(newValueItem.CustomStyles[0]);
                    var valueItemEntity = GetValueItemEntity(image, newValueItem.Value, newValueItem);

                    //if (RequiredValues.FeatureLayer is ShapeFileFeatureLayer)
                    //{
                    //    valueItemEntity.Count = StyleHelper.CalculateSpeceficValuesCount(ColumnName
                    //        , newValueItem.Value, (ShapeFileFeatureLayer)RequiredValues.FeatureLayer);
                    //}
                    //else if (RequiredValues.FeatureLayer != null)
                    //{
                    //    if (distinctColumnValues == null)
                    //    {
                    //        RequiredValues.FeatureLayer.SafeProcess(() =>
                    //        {
                    //            distinctColumnValues = RequiredValues.FeatureLayer.FeatureSource.GetDistinctColumnValues(ColumnName);
                    //        });
                    //    }

                    //    if (distinctColumnValues != null && distinctColumnValues.Count > 0)
                    //    {
                    //        var distinctColumnValue = distinctColumnValues.FirstOrDefault(tmpFeature
                    //            => tmpFeature.ColumnValue
                    //            .Equals(newValueItem.Value, StringComparison.Ordinal));
                    //        if (distinctColumnValue != null)
                    //        {
                    //            valueItemEntity.Count = distinctColumnValue.ColumnValueCount;
                    //        }
                    //    }
                    //}
                    ValueItems.Add(valueItemEntity);
                    RaisePropertyChanged("ValueItems");
                }
            }
        }
        protected override void UpdateUICore(UserControl styleItemUI)
        {
            var viewModel = styleItemUI.DataContext as ValueStyleViewModel;

            if (viewModel != null)
            {
                var currentValueItem = viewModel.ValueItems.FirstOrDefault(c => c.ValueItem == ConcreteObject);
                if (currentValueItem != null)
                {
                    currentValueItem.Image = StyleHelper.GetImageFromStyle(currentValueItem.ValueItem.CustomStyles);
                }

                viewModel.SelectedValueItem = viewModel.ValueItems.Where(v => v.ValueItem == (ValueItem)ConcreteObject).FirstOrDefault();
            }
        }
示例#6
0
        private ClassBreakItem GetClassBreakItem(ClassBreak classBreak)
        {
            var classBreakItem = new ClassBreakItem
            {
                Image         = StyleHelper.GetImageFromStyle(classBreak.CustomStyles.LastOrDefault()),
                StartingValue = classBreak.Value.ToString(),
                ClassBreak    = classBreak
            };

            classBreakItem.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName.Equals("StartingValue"))
                {
                    RaisePropertyChanged(e.PropertyName);
                }
            };

            return(classBreakItem);
        }
        protected override void UpdateUICore(UserControl styleItemUI)
        {
            base.UpdateUICore(styleItemUI);

            var viewModel = styleItemUI.DataContext as ClassBreakStyleViewModel;

            if (viewModel != null)
            {
                viewModel.ClassBreakItems.Clear();
                foreach (var classBreak in Children.Select(i => i.ConcreteObject).OfType <ClassBreak>())
                {
                    ClassBreakItem classBreakItem = new ClassBreakItem();
                    classBreakItem.PropertyChanged += (s, e) => { if (e.PropertyName.Equals("StartingValue"))
                                                                  {
                                                                      UpdateStyleItem();
                                                                  }
                    };
                    classBreakItem.ClassBreak    = classBreak;
                    classBreakItem.StartingValue = classBreak.Value.ToString(CultureInfo.InvariantCulture);
                    classBreakItem.Image         = StyleHelper.GetImageFromStyle(classBreak.CustomStyles);
                    viewModel.ClassBreakItems.Add(classBreakItem);
                }
            }
        }
示例#8
0
 public void Update(ValueItem newValueItem)
 {
     Image        = StyleHelper.GetImageFromStyle(newValueItem.CustomStyles.LastOrDefault());
     MatchedValue = newValueItem.Value;
     ValueItem    = newValueItem;
 }
        private void InitValueItem <T>(StyleCategories styleProviderType, DistinctColumnValue columnValueGroup, string columnName) where T : Style
        {
            Collection <Style> styles = new Collection <Style>();

            if (styleProviderType == StyleCategories.Composite)
            {
                Collection <StylePlugin> plugins = new Collection <StylePlugin>();
                var areaPlugin = GisEditor.StyleManager.GetDefaultStylePlugin(StyleCategories.Area);
                if (areaPlugin != null)
                {
                    plugins.Add(areaPlugin);
                }
                var linePlugin = GisEditor.StyleManager.GetDefaultStylePlugin(StyleCategories.Line);
                if (linePlugin != null)
                {
                    plugins.Add(linePlugin);
                }
                var pointPlugin = GisEditor.StyleManager.GetDefaultStylePlugin(StyleCategories.Point);
                if (pointPlugin != null)
                {
                    plugins.Add(pointPlugin);
                }
                foreach (var item in plugins)
                {
                    Style style = GetStyleByPlugin(item);
                    if (style != null)
                    {
                        styles.Add(style);
                    }
                }
            }
            else
            {
                var styleProvider = GisEditor.StyleManager.GetDefaultStylePlugin(styleProviderType);
                if (styleProvider != null)
                {
                    Style style = GetStyleByPlugin(styleProvider);
                    if (style != null)
                    {
                        styles.Add(style);
                    }
                }
            }

            if (styles.Count > 0)
            {
                ValueItem valueItem = new ValueItem();
                valueItem.Value = columnValueGroup.ColumnValue;
                styles.ForEach(s => valueItem.CustomStyles.Add(s));

                ValueItemEntity valueItemEntity = ValueItems.FirstOrDefault(tmpItem
                                                                            => tmpItem.MatchedValue.Equals(columnValueGroup.ColumnValue, StringComparison.Ordinal));

                if (valueItemEntity == null)
                {
                    valueItem       = new ValueItem();
                    valueItem.Value = columnValueGroup.ColumnValue;
                    styles.ForEach(s => valueItem.CustomStyles.Add(s));

                    var image = StyleHelper.GetImageFromStyle(styles);
                    var newValueItemEntity = GetValueItemEntity(image, columnValueGroup.ColumnValue, valueItem);
                    newValueItemEntity.Count = columnValueGroup.ColumnValueCount;
                    ValueItems.Add(newValueItemEntity);
                }
                else
                {
                    //valueItemEntity.Update(valueItem);
                    valueItemEntity.Count = columnValueGroup.ColumnValueCount;
                }
            }
        }