Ejemplo n.º 1
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);
            if (Control is null || Element is null)
            {
                return;
            }

            if (e.PropertyName == VisualElement.HeightProperty.PropertyName ||
                e.PropertyName == VisualElement.WidthProperty.PropertyName ||
                e.PropertyName == IconAwesomeLabelBase.IconProperty.PropertyName ||
                e.PropertyName == IconAwesomeLabelBase.TextProperty.PropertyName ||
                e.PropertyName == IconAwesomeLabelBase.TypeIconProperty.PropertyName)
            {
                if (!string.IsNullOrEmpty(((IconAwesomeLabelBase)Element).Icon))
                {
                    Control.Font = UIFont.FromName(IconExtensions.FindNameForFont
                                                       (((IconAwesomeLabelBase)Element).TypeIcon), (nfloat)Element.FontSize);

                    IIcon icon = IconExtensions.FindIconForKey(((IconAwesomeLabelBase)Element).Icon);

                    Control.Text = $"{icon.Character}";
                }
            }
        }
Ejemplo n.º 2
0
        private void uiIcon_SelectedIndexChanged(object sender, EventArgs e)
        {
            var icon = (Z.IconLibrary.Fugue.Icon)Enum.Parse(typeof(Z.IconLibrary.Fugue.Icon), uiIcon.SelectedValue);

            //uiDynamicCssClass16.CssClass = IconExtensions.GetCssClass16(icon);
            //uiDynamicCssClass32.CssClass = IconExtensions.GetCssClass32(icon);

            //uiDynamicUrl16.ImageUrl = IconExtensions.GetUrl16(icon);
            //uiDynamicUrl32.ImageUrl = IconExtensions.GetUrl32(icon);

            //uiDynamicWebResourceUrl16.ImageUrl = IconExtensions.GetWebResourceUrl16(icon);
            //uiDynamicWebResourceUrl32.ImageUrl = IconExtensions.GetWebResourceUrl32(icon);

            //uiDynamicCssClass16.CssClass = icon.GetCssClass();
            //uiDynamicUrl16.ImageUrl = icon.GetUrl();
            //uiDynamicWebResourceUrl16.ImageUrl = icon.GetWebResourceUrl();

            uiDynamicCssClass16.CssClass       = IconExtensions.GetCssClass(icon);
            uiDynamicUrl16.ImageUrl            = IconExtensions.GetUrl(icon);
            uiDynamicWebResourceUrl16.ImageUrl = IconExtensions.GetWebResourceUrl(icon);

            //uiDynamicCssClass16.CssClass = icon.GetCssClass();

            //uiDynamicUrl16.ImageUrl = icon.GetUrl();

            //uiDynamicWebResourceUrl16.ImageUrl = icon.GetWebResourceUrl();
        }
Ejemplo n.º 3
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Label> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement == null)
            {
                //Only enable hardware accelleration on lollipop
                if ((int)Android.OS.Build.VERSION.SdkInt < 21)
                {
                    SetLayerType(LayerType.Software, null);
                }
            }

            if (!string.IsNullOrEmpty(((IconAwesomeLabelBase)Element).Icon))
            {
                Control.Typeface = Typeface.CreateFromAsset(context.Assets,
                                                            IconExtensions.FindNameFileForFont(((IconAwesomeLabelBase)Element).TypeIcon));

                IIcon icon = IconExtensions.FindIconForKey(((IconAwesomeLabelBase)Element).Icon);

                Element.Text = $"{icon.Character}";
            }
            else
            {
                Control.Typeface = Typeface.Create(Element.FontFamily, TypefaceStyle.Normal);
                Element.Text     = ((IconAwesomeLabelBase)Element).Text;
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Page.AddIconStyleSheet();
            PageExtensions.AddIconStyleSheet(this);

            if (!Page.IsPostBack)
            {
                //uiCssClass16.CssClass = Icon.AcceptButton.GetCssClass16(); // required web.config setup
                //uiCssClass32.CssClass = Icon.AcceptButton.GetCssClass32(); // required web.config setup

                //uiUrl16.ImageUrl = Icon.AcceptButton.GetUrl16(); // required web.config setup
                //uiUrl32.ImageUrl = Icon.AcceptButton.GetUrl32(); // required web.config setup

                //uiWebResourceUrl16.ImageUrl = Icon.AcceptButton.GetWebResourceUrl16(); // no requirement
                //uiWebResourceUrl32.ImageUrl = Icon.AcceptButton.GetWebResourceUrl32(); // no requirement

                //IEnumerable<Icon> values = Enum.GetValues(typeof(Icon)).Cast<Icon>().ToList().Take(100);

                //uiCssClass16.CssClass = IconExtensions.GetCssClass16(Icon.AcceptButton); // required web.config setup
                //uiCssClass32.CssClass = IconExtensions.GetCssClass32(Icon.AcceptButton); // required web.config setup

                //uiUrl16.ImageUrl = IconExtensions.GetUrl16(Icon.AcceptButton); // required web.config setup
                //uiUrl32.ImageUrl = IconExtensions.GetUrl32(Icon.AcceptButton); // required web.config setup

                //uiWebResourceUrl16.ImageUrl = IconExtensions.GetWebResourceUrl16(Icon.AcceptButton); // no requirement
                //uiWebResourceUrl32.ImageUrl = IconExtensions.GetWebResourceUrl32(Icon.AcceptButton); // no requirement

                //uiCssClass16.CssClass = Icon.Accept.GetCssClass(); // required web.config setup
                //uiUrl16.ImageUrl = Icon.Accept.GetUrl(); // required web.config setup
                //uiWebResourceUrl16.ImageUrl = Icon.Accept.GetWebResourceUrl(); // no requirement

                uiCssClass16.CssClass       = IconExtensions.GetCssClass(Z.IconLibrary.Fugue.Icon.Acorn);       // required web.config setup
                uiUrl16.ImageUrl            = IconExtensions.GetUrl(Z.IconLibrary.Fugue.Icon.Acorn);            // required web.config setup
                uiWebResourceUrl16.ImageUrl = IconExtensions.GetWebResourceUrl(Z.IconLibrary.Fugue.Icon.Acorn); // no requirement

                //uiCssClass16.CssClass = IconExtensions.GetCssClass16(Icon.AcceptButton); // required web.config setup
                //uiUrl16.ImageUrl = IconExtensions.GetUrl16(Icon.AcceptButton); // required web.config setup
                //uiWebResourceUrl16.ImageUrl = IconExtensions.GetWebResourceUrl16(Icon.AcceptButton); // no requirement



                IEnumerable <Z.IconLibrary.Fugue.Icon> values = Enum.GetValues(typeof(Z.IconLibrary.Fugue.Icon)).Cast <Z.IconLibrary.Fugue.Icon>().ToList().Take(100);

                //uiCssClass16.CssClass = Icon.AcceptButton.GetCssClass(); // required web.config setup
                //uiUrl16.ImageUrl = Icon.AcceptButton.GetUrl(); // required web.config setup
                //uiWebResourceUrl16.ImageUrl = Icon.AcceptButton.GetWebResourceUrl(); // no requirement

                //uiCssClass16.CssClass = Icon.Accept.GetCssClass(); // required web.config setup
                //uiUrl16.ImageUrl = Icon.Accept.GetUrl(); // required web.config setup
                //uiWebResourceUrl16.ImageUrl = Icon.Accept.GetWebResourceUrl(); // no requirement


                uiIcon.DataSource = values;
                uiIcon.DataBind();
            }

            uiIcon.SelectedIndexChanged += uiIcon_SelectedIndexChanged;
        }
Ejemplo n.º 5
0
        public AppItemViewModel(IAudioMixerViewModelCallback callback, EarTrumpetAudioSessionModelGroup sessions)
        {
            _sessions = sessions;
            // select a session at random as sndvol does.
            var session = _sessions.Sessions.First();

            IconHeight = IconWidth = 32;
            SessionId  = session.SessionId;
            ProcessId  = session.ProcessId;
            ExeName    = GetExeName(session.DisplayName);
            IsDesktop  = session.IsDesktop;

            _volume = Convert.ToInt32(Math.Round((session.Volume * 100),
                                                 MidpointRounding.AwayFromZero));
            _isMuted  = session.IsMuted;
            _callback = callback;

            if (session.IsDesktop)
            {
                try
                {
                    if (Path.GetExtension(session.IconPath) == ".dll")
                    {
                        Icon = IconExtensions.ExtractIconFromDll(session.IconPath);
                    }
                    else
                    {
                        // override for SpeechRuntime.exe (Repo -> HEY CORTANA)
                        if (session.IconPath.ToLowerInvariant().Contains("speechruntime.exe"))
                        {
                            var sysType = Environment.Is64BitOperatingSystem ? "SysNative" : "System32";
                            Icon = IconExtensions.ExtractIconFromDll(Path.Combine("%windir%", sysType, "Speech\\SpeechUX\\SpeechUXWiz.exe"), 0);
                        }
                        else
                        {
                            Icon = System.Drawing.Icon.ExtractAssociatedIcon(session.IconPath).ToImageSource();
                        }
                    }
                }
                catch
                {
                    // ignored
                }
                Background = new SolidColorBrush(Colors.Transparent);
            }
            else
            {
                if (File.Exists(session.IconPath)) //hack until we invoke the resource manager correctly.
                {
                    Icon = new BitmapImage(new Uri(session.IconPath));
                }
                Background = new SolidColorBrush(AccentColorService.FromABGR(session.BackgroundColor));
            }
        }
Ejemplo n.º 6
0
        public AppItemViewModel(IAudioMixerViewModelCallback callback, EarTrumpetAudioSessionModelGroup sessions,
                                ProcessTitleProvider titleProvider)
        {
            _sessions = sessions;
            // select a session at random as sndvol does.
            var session = _sessions.Sessions.First();

            IconHeight  = IconWidth = 32;
            SessionId   = session.SessionId;
            DisplayName = session.DisplayName.Equals("System Sounds") ? EarTrumpet.Properties.Resources.SystemSoundsDisplayName : session.DisplayName;
            IsDesktop   = session.IsDesktop;

            _volume = Convert.ToInt32(Math.Round((session.Volume * 100),
                                                 MidpointRounding.AwayFromZero));
            _callback = callback;

            if (session.IsDesktop)
            {
                try
                {
                    Icon = Path.GetExtension(session.IconPath) == ".dll" ? IconExtensions.ExtractIconFromDll(session.IconPath) : System.Drawing.Icon.ExtractAssociatedIcon(session.IconPath).ToImageSource();
                }
                catch
                {
                    // ignored
                }

                Background = new SolidColorBrush(Colors.Transparent);

                try
                {
                    string gotTitle;
                    if (titleProvider.TryGetTitleForProcess(session.ProcessId, out gotTitle))
                    {
                        DisplayName = gotTitle;
                    }
                }
                catch { } // we fallback to exe name if DisplayName is not set in the try above.
            }
            else
            {
                if (File.Exists(session.IconPath)) //hack until we invoke the resource manager correctly.
                {
                    Icon = new BitmapImage(new Uri(session.IconPath));
                }
                Background = new SolidColorBrush(AccentColorService.FromABGR(session.BackgroundColor));
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Button> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement == null)
            {
                //Only enable hardware accelleration on lollipop
                if ((int)Android.OS.Build.VERSION.SdkInt < 21)
                {
                    SetLayerType(LayerType.Software, null);
                }
            }

            if (!string.IsNullOrEmpty(((IconAwesomeButtonBase)Element).Icon))
            {
                Control.Typeface = Typeface.CreateFromAsset(context.Assets,
                                                            IconExtensions.FindNameFileForFont(((IconAwesomeButtonBase)Element).TypeIcon));

                IIcon icon = IconExtensions.FindIconForKey(((IconAwesomeButtonBase)Element).Icon);

                Element.Text = $"{icon.Character}";
            }
            else
            {
                Control.Typeface = Typeface.Create(Element.FontFamily, TypefaceStyle.Normal);
                Element.Text     = ((IconAwesomeButtonBase)Element).Text;
            }

            if (((IconAwesomeButtonBase)Element).ImageSource != null)
            {
                Android.Widget.Button thisButton = Control as Android.Widget.Button;
                thisButton.Touch += (object sender, Android.Views.View.TouchEventArgs e2) =>
                {
                    if (e2.Event.Action == MotionEventActions.Down)
                    {
                        Control.SetBackgroundColor(Element.BackgroundColor.ToAndroid());
                    }
                    else if (e2.Event.Action == MotionEventActions.Up)
                    {
                        Control.SetBackgroundColor(Element.BackgroundColor.ToAndroid());
                        Control.SetShadowLayer(0, 0, 0, Android.Graphics.Color.Transparent);
                        Control.CallOnClick();
                    }
                };
            }
        }
Ejemplo n.º 8
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);
            if (Control is null || Element is null)
            {
                return;
            }

            if (e.PropertyName == VisualElement.HeightProperty.PropertyName ||
                e.PropertyName == VisualElement.WidthProperty.PropertyName ||
                e.PropertyName == IconAwesomeButtonBase.BorderColorProperty.PropertyName ||
                e.PropertyName == IconAwesomeButtonBase.BorderThicknessProperty.PropertyName ||
                e.PropertyName == IconAwesomeButtonBase.IconProperty.PropertyName ||
                e.PropertyName == IconAwesomeButtonBase.TextProperty.PropertyName ||
                e.PropertyName == IconAwesomeButtonBase.TypeIconProperty.PropertyName)
            {
                CreateCircle();

                if (!String.IsNullOrEmpty(((IconAwesomeButtonBase)Element).Icon))
                {
                    Control.Font = UIFont.FromName(IconExtensions.FindNameForFont
                                                       (((IconAwesomeButtonBase)Element).TypeIcon), (nfloat)Element.FontSize);

                    IIcon icon = IconExtensions.FindIconForKey(((IconAwesomeButtonBase)Element).Icon);

                    Control.SetTitle($"{icon.Character}", UIControlState.Normal);
                }
                else
                {
                    Control.Font = Font.OfSize(Element.FontFamily, Element.FontSize).WithAttributes(Element.FontAttributes).ToUIFont();
                    Control.TitleLabel.LineBreakMode = UILineBreakMode.WordWrap;
                    Control.TitleLabel.TextAlignment = UITextAlignment.Center;
                    Control.SetTitle(((IconAwesomeButtonBase)Element).Text, UIControlState.Normal);
                }
            }
        }
Ejemplo n.º 9
0
        protected override ImageSource Convert(FileSystemItemViewModel viewModel, Type targetType)
        {
            if (viewModel == null)
            {
                return(null);
            }
            var rm    = viewModel.ResourceManager;
            var bytes = viewModel.IsUpDirectory ? null : viewModel.Thumbnail;

            if (bytes == null)
            {
                string icon;
                switch (viewModel.Type)
                {
                case ItemType.Directory:
                    if (viewModel.IsUpDirectory)
                    {
                        icon = "up";
                    }
                    else if (viewModel.Name == "0000000000000000")
                    {
                        icon = "games_folder";
                    }
                    else if (viewModel.Model.RecognitionState == RecognitionState.PartiallyRecognized)
                    {
                        icon = "xbox_logo";
                    }
                    else if (viewModel.IsRefreshing)
                    {
                        icon = "refresh_folder";
                    }
                    else
                    {
                        icon = "folder";
                    }
                    break;

                case ItemType.Link:
                    icon = "reparse_point";
                    break;

                case ItemType.File:
                    if (viewModel.IsCompressedFile)
                    {
                        icon = "package";
                    }
                    else if (viewModel.IsIso)
                    {
                        icon = "iso";
                    }
                    else if (viewModel.IsXex)
                    {
                        icon = "xex";
                    }
                    else
                    {
                        ImageSource image     = null;
                        var         extension = Path.GetExtension(viewModel.Name);
                        if (!string.IsNullOrEmpty(extension))
                        {
                            var key = ThumbnailSize + extension;
                            if (SystemIconCache.ContainsKey(key))
                            {
                                image = SystemIconCache[key];
                            }
                            else
                            {
                                try
                                {
                                    var shinfo = new ShellFileInfo();
                                    var path   = viewModel.Path;
                                    if (!File.Exists(path))
                                    {
                                        path = key;     //creating a temporary dummy file, i.e. 16.png
                                        using (File.Create(path)) {}
                                    }
                                    var size = ThumbnailSize == 16 ? (uint)1 : 0;
                                    IconExtensions.SHGetFileInfo(path, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), 0x100 | size);
                                    if (path != viewModel.Path)
                                    {
                                        File.Delete(path);
                                    }
                                    if (IntPtr.Zero != shinfo.hIcon)
                                    {
                                        image = Imaging.CreateBitmapSourceFromHIcon(shinfo.hIcon, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                                    }
                                }
                                catch
                                {
                                }
                                SystemIconCache.Add(key, image);
                            }
                            if (image != null)
                            {
                                return(image);
                            }
                        }
                        icon = "file";
                    }
                    break;

                case ItemType.Drive:
                    switch (viewModel.Model.DriveType)
                    {
                    case DriveType.CDRom:
                        icon = "drive_cd";
                        break;

                    case DriveType.Network:
                        icon = "drive_network";
                        break;

                    case DriveType.Removable:
                        icon = "drive_flash";
                        break;

                    default:
                        icon = "drive";
                        break;
                    }
                    break;

                default:
                    throw new NotSupportedException("Invalid item type: " + viewModel.Type);
                }
                bytes = rm.GetContentByteArray(string.Format("/Resources/Items/{0}x{0}/{1}.png", ThumbnailSize, icon));
            }
            return(bytes[0] == 0 ? null : StfsPackageExtensions.GetBitmapFromByteArray(bytes));
        }