示例#1
0
        private BlockPickerItem CreateDefaultBlockButton(int index)
        {
            BlockPickerItem btn = CreateBaseBlockButton();
            int             img_width_height = (index == -1 ? 30 : 50);

            btn.MainButton.Tag  = index;
            btn.CrossButton.Tag = index;

            Image img = new Image();

            img.Width   = img_width_height;
            img.Height  = img_width_height;
            img.Stretch = Stretch.UniformToFill;

            RenderOptions.SetBitmapScalingMode(img, BitmapScalingMode.HighQuality);

            if (index == -1)
            {
                img.Source             = Application.Current.Resources["PlusIcon"] as DrawingImage;
                btn.MainButton.Content = img;
            }
            else
            {
                string packUri = BlockList.ElementAtOrDefault(index) ?? BlockList[0];
                var    bmp     = new BitmapImage(new Uri(packUri, UriKind.Relative));
                img.Source             = bmp;
                btn.MainButton.Content = img;
            }

            return(btn);
        }
示例#2
0
        private BlockPickerItem CreateCustomBlockButton(string path)
        {
            BlockPickerItem btn = CreateBaseBlockButton();
            int             img_width_height = 50;

            btn.MainButton.Tag  = path;
            btn.CrossButton.Tag = path;
            btn.IsCustomImage   = true;

            Image img = new Image();

            img.Width   = img_width_height;
            img.Height  = img_width_height;
            img.Stretch = Stretch.UniformToFill;

            RenderOptions.SetBitmapScalingMode(img, BitmapScalingMode.HighQuality);

            BitmapImage bmp = new BitmapImage();

            bmp.BeginInit();
            bmp.CacheOption = BitmapCacheOption.OnLoad;
            bmp.UriSource   = new Uri(System.IO.Path.Combine(LauncherModel.Default.FilepathManager.GetCacheFolderPath(), path), UriKind.Absolute);
            bmp.EndInit();

            img.Source             = bmp;
            btn.MainButton.Content = img;

            return(btn);
        }
示例#3
0
        private BlockPickerItem CreateBaseBlockButton()
        {
            BlockPickerItem btn = new BlockPickerItem();

            btn.MainButton.Click  += Btn_Click;
            btn.CrossButton.Click += CrossBtn_Click;
            return(btn);
        }