Exemple #1
0
        public ProgramsMenu()
        {
            EntranceAnimation = null;
            ExitAnimation = null;
            VerticalScroll = true;

            _bgImage = TinyIoCContainer.Current.Resolve<ScaledBackground>();

            Size = new Size(100, 100);
            SizeChanged += (sender, args) => OnSizeChanged();

            _refa = new FileRoutines.structa();

            _bgColor = MetroTheme.PhoneAccentBrush;
            _bgBrush = new SolidBrush(_bgColor);
            _rect = new Rectangle(0, 0, IconSize + BorderSize * 2, IconSize + BorderSize * 2);

            DataTemplateSelector = item => BuildItem;
            SourceItems = GetProgramList();
        }
Exemple #2
0
        protected virtual void PaintIcon(Graphics g, Rectangle rect)
        {
            // get icon from file
            if (String.IsNullOrEmpty(_iconPath))
                return;

            int captionHeight = (Caption == "") ? 0 :
                (CaptionHeight + ((GridSize.Height == 1) ? 1 : 0));

            // draw icon from external image file
            if (_iconImage != null)
            {
                _iconImage.PaintIcon(g, new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height - captionHeight/2));
                return;
            }

            // draw main icon from executable file
            if (IsExecutableIcon())
            {
                var refa = new FileRoutines.structa();
                FileRoutines.SHGetFileInfo(ref _iconPath, 0, ref refa, Marshal.SizeOf(refa), 0x100);
                var icon = Icon.FromHandle(refa.a);

                g.DrawIcon(icon, (rect.Left + rect.Right - icon.Width) / 2,
                    rect.Top + (rect.Height - icon.Height - captionHeight) / 2);

                icon.Dispose();
            }
        }
        private void SetTileImage(String value)
        {
            if (_tileImage == value) return;

            _tileImage = value;

            try
            {
                if (_pictureBox.Image != null)
                {
                    _pictureBox.Image.Dispose();
                    _pictureBox.Image = null;
                }

                if (String.IsNullOrEmpty(_tileImage))
                    return;

                if (IsExecutableIcon())
                {
                    // get icon from file
                    if (String.IsNullOrEmpty(_tileImage))
                        return;

                    var refa = new FileRoutines.structa();
                    FileRoutines.SHGetFileInfo(ref _tileImage, 0, ref refa, Marshal.SizeOf(refa), 0x100);
                    var icon = Icon.FromHandle(refa.a);
                    _pictureBox.Image = GetBitmap(icon);
                }

                else
                {
                    var factory = (IImagingFactory)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("327ABDA8-072B-11D3-9D7B-0000F81EF32E")));
                    IImage img;

                    factory.CreateImageFromFile(_tileImage, out img);

                    ImageInfo imageInfo;
                    img.GetImageInfo(out imageInfo);

                    IBitmapImage bmp;
                    factory.CreateBitmapFromImage(img, imageInfo.Width, imageInfo.Height,
                                                   PixelFormatID.PixelFormat16bppRGB565,
                                                   InterpolationHint.InterpolationHintDefault, out bmp);

                    _pictureBox.Image = ImageHelpers.IBitmapImageToBitmap(bmp);
                }

            }
            catch (Exception)
            {
                _pictureBox.Image = null;
            }

            _pictureBox.Update();

            NotifyPropertyChanged("Value");
        }