コード例 #1
0
        public static void PredefinedSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            GeoStyleViewModel     geoStyleEntity = (GeoStyleViewModel)e.NewValue;
            PredefinedStylePicker control        = (PredefinedStylePicker)sender;

            if (e.OldValue != null && geoStyleEntity != null && ((GeoStyleViewModel)e.OldValue).Name != geoStyleEntity.Name)
            {
                control.SelectedItem = control.StylesSource.FirstOrDefault(i => { return(i.Name == geoStyleEntity.Name); });
            }
        }
コード例 #2
0
        public static void PredefinedStyleTypeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            PredefinedStylePicker control = (PredefinedStylePicker)sender;

            control.stylesSource.Clear();
            switch ((PredefinedStyleType)e.NewValue)
            {
            case PredefinedStyleType.Line:
                PropertyInfo[] lineStyleInfos = typeof(LineStyles).GetProperties();
                foreach (var lineStyleInfo in lineStyleInfos)
                {
                    LineStyle         geoLineStyle   = (LineStyle)lineStyleInfo.GetValue(null, null);
                    GeoStyleViewModel geoStyleEntity = new GeoStyleViewModel(lineStyleInfo.Name, geoLineStyle);
                    control.stylesSource.Add(geoStyleEntity);
                }
                break;

            case PredefinedStyleType.Point:
                PropertyInfo[] pointStyleInfos = typeof(PointStyles).GetProperties();
                foreach (var pointStyleInfo in pointStyleInfos)
                {
                    PointStyle        geoPointStyle  = (PointStyle)pointStyleInfo.GetValue(null, null);
                    GeoStyleViewModel geoStyleEntity = new GeoStyleViewModel(pointStyleInfo.Name, geoPointStyle);
                    control.stylesSource.Add(geoStyleEntity);
                }
                break;

            case PredefinedStyleType.Area:
                PropertyInfo[] areaStyleInfos = typeof(AreaStyles).GetProperties();
                foreach (var areaStyleInfo in areaStyleInfos)
                {
                    AreaStyle         geoAreaStyle   = (AreaStyle)areaStyleInfo.GetValue(null, null);
                    GeoStyleViewModel geoStyleEntity = new GeoStyleViewModel(areaStyleInfo.Name, geoAreaStyle);
                    control.stylesSource.Add(geoStyleEntity);
                }
                break;
            }
        }