public IconSource(PointStyleViewModel pointStyleViewModel)
        {
            viewModel = pointStyleViewModel;

            EnableEditSize       = true;
            ConstrainProportions = true;

            iconCategories   = IconHelper.GetIconCategories();
            currentIcons     = new ObservableCollection <IconEntity>();
            SelectedCategory = IconCategories.First();
            if (SelectedCategory != null)
            {
                if (viewModel.ActualImage != null)
                {
                    var bitmapImage = new System.Windows.Media.Imaging.BitmapImage();
                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = viewModel.ActualImage.GetImageStream();
                    bitmapImage.EndInit();

                    SelectedIcon = new IconEntity()
                    {
                        Icon = bitmapImage
                    };
                }

                if (selectedCategory.HasSubCategories)
                {
                    SelectedSubCategory = SelectedCategory.SubCategories[0];
                    if (string.IsNullOrEmpty(viewModel.ImagePath) && SelectedIcon.Icon == null)
                    {
                        SelectedIcon = SelectedSubCategory.Icons[0];
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(viewModel.ImagePath) && (SelectedIcon == null || SelectedIcon.Icon == null))
                    {
                        SelectedIcon = SelectedCategory.Icons[0];
                    }
                }
            }
        }
Beispiel #2
0
        public static Uri GetIcon(IconCategories category, string name)
        {
            string strcategory;

            switch (category)
            {
            case IconCategories.Small:
                strcategory = "SmallIcons";
                break;

            case IconCategories.Big:
                strcategory = "BigIcons";
                break;

            case IconCategories.Normal:
            default:
                strcategory = "Icons";
                break;
            }

            string final = $"pack://application:,,,/Thingy.Resources;component/{strcategory}/{name}";

            return(new Uri(final, UriKind.Absolute));
        }