Example #1
1
 private void Pause()
 {
     currentlyPlayingMusic = false;
     PlayIcon = new SymbolIcon(Symbol.Play);
     MediaElement.Pause();
 }
Example #2
0
 public ShellNavigationItem(string label, IconElement icon, Type viewModeType)
     : this()
 {
     Label         = label;
     _iconElement  = icon;
     ViewModelType = viewModeType;
 }
Example #3
0
        protected ICommandBarElement CreateAppBarToggleButton(IconElement icon, string label, RoutedEventHandler eventHandler)
        {
            var command = CreateAppBarToggleButton(label, eventHandler) as AppBarToggleButton;

            command.Icon = icon;
            return(command);
        }
Example #4
0
        public async void JoinCircle()
        {
            if (!AuthorizationHelper.IsLogin)
            {
                PopupMessage.DisplayMessageInRes("NeedLogin");
                return;
            }

            if (Misc.ZhiHuCircleId.ToString() == CircleId && JoinCircleButtonIcon == _checkIcon)
            {
                PopupMessage.DisplayMessageInRes("CannotQuitZhiHuCircle");
                return;
            }

            if (JoinCircleButtonIcon == _addIcon)
            {
                JoinCircleButtonIcon = _checkIcon;
                await DataRequester.JoinCircle(CircleId);

                PopupMessage.DisplayMessageInRes("JoinCircleSuccess");
            }
            else
            {
                JoinCircleButtonIcon = _addIcon;
                await DataRequester.QuitCircle(CircleId);

                PopupMessage.DisplayMessageInRes("QuitCircleSuccess");
            }
        }
 public PaneMenuItem(string label, IconElement icon, ICommand command, Func<object> getParameter = null)
 {
     _label = label;
     _icon = icon;
     _command = command;
     _getParameter = getParameter;
 }
Example #6
0
 private void Icon_OnMouseDown(object sender, MouseButtonEventArgs e)
 {
     _curIcon = ((FrameworkElement)sender).DataContext as IconElement;
     if (e.ClickCount < 2 || e.ChangedButton != MouseButton.Left)
     {
         return;
     }
     if (_curIcon != null)
     {
         _header.Header.Icons.NextIcon(_curIcon);
     }
 }
Example #7
0
        public ShellNavigationItem(string name, IconElement icon, string pageIdentifier)
        {
            this.Label          = name;
            this._iconElement   = icon;
            this.PageIdentifier = pageIdentifier;

            Services.ThemeSelectorService.OnThemeChanged += (s, e) => { if (!IsSelected)
                                                                        {
                                                                            SelectedForeground = GetStandardTextColorBrush();
                                                                        }
            };
        }
Example #8
0
        internal static AppBarButton BuildAppBarButton(string label, IconElement icon)
        {
            var appBarButton = new AppBarButton()
            {
                Label           = label,
                Icon            = icon,
                BorderThickness = new Thickness(0, 0, 0, 0)
            };

            ToolTipService.SetToolTip(appBarButton, label);
            return(appBarButton);
        }
Example #9
0
        public ShellNavigationItem(string label, IconElement icon, string viewModelName)
        {
            this.Label         = label;
            this._iconElement  = icon;
            this.ViewModelName = viewModelName;

            Services.ThemeSelectorService.OnThemeChanged += (s, e) => { if (!IsSelected)
                                                                        {
                                                                            SelectedForeground = GetStandardTextColorBrush();
                                                                        }
            };
        }
Example #10
0
        private ShellNavigationItem(string name, IconElement icon, Type pageType)
        {
            this.Label        = name;
            this._iconElement = icon;
            this.PageType     = pageType;

            Services.ThemeSelectorService.OnThemeChanged += (s, e) => { if (!IsSelected)
                                                                        {
                                                                            SelectedForeground = GetStandardTextColorBrush();
                                                                        }
            };
        }
Example #11
0
        public Task <IconElement> LoadIconElementAsync(ImageSource imagesource, CancellationToken cancellationToken = default(CancellationToken))
        {
            IconElement image = null;

            if (imagesource is FileImageSource filesource)
            {
                string file = filesource.File;
                image = new BitmapIcon {
                    UriSource = new Uri("ms-appx:///" + file)
                };
            }

            return(Task.FromResult(image));
        }
        public Task <IconElement> LoadIconElementAsync(ImageSource imagesource, CancellationToken cancellationToken = default(CancellationToken))
        {
            IconElement image = null;

            if (imagesource is FontImageSource fontImageSource)
            {
                image = new FontIcon
                {
                    Glyph      = fontImageSource.Glyph,
                    FontFamily = new FontFamily(fontImageSource.FontFamily),
                    FontSize   = fontImageSource.Size,
                    Foreground = fontImageSource.Color.ToBrush()
                };
            }

            return(Task.FromResult(image));
        }
        public override void SetValue(object value)
        {
            FeatureInfo feature = value as FeatureInfo;

            if (feature.IsNew)
            {
                var           size   = ScaleToDeviceDPI(new Size(16, 16));
                var           icon1  = new C1PolygonIcon();
                List <PointF> points = new List <PointF>();
                points.Add(new PointF(12.115f, 8.084f));
                points.Add(new PointF(14.158f, 6.093f));
                points.Add(new PointF(10.929f, 5.623f));
                points.Add(new PointF(11.322f, 2.681f));
                points.Add(new PointF(9.202f, 3.897f));
                points.Add(new PointF(8.121f, 1.706f));
                points.Add(new PointF(6.807f, 4.367f));
                points.Add(new PointF(3.863f, 2.956f));
                points.Add(new PointF(4.449f, 5.749f));
                points.Add(new PointF(2.083f, 6.093f));
                points.Add(new PointF(3.943f, 7.907f));
                points.Add(new PointF(1.821f, 10.135f));
                points.Add(new PointF(4.857f, 10.462f));
                points.Add(new PointF(4.389f, 13.19f));
                points.Add(new PointF(6.748f, 11.95f));
                points.Add(new PointF(8.016f, 14.296f));
                points.Add(new PointF(9.15f, 11.77f));
                points.Add(new PointF(11.852f, 13.19f));
                points.Add(new PointF(11.332f, 10.157f));
                points.Add(new PointF(13.889f, 9.688f));
                icon1.Points   = points.ToArray();
                icon1.IsClosed = true;
                icon1.Color    = Color.FromArgb(220, 154, 49);
                icon1.Size     = size;
                var icon2 = new C1PathIcon();
                icon2.Data  = "M8.121,1.706l1.081,2.191l2.12-1.217l-0.394,2.942l3.229,0.47l-2.043,1.991l1.773,1.604l-2.557,0.469l0.52,3.033L9.15,11.77l-1.135,2.526L6.748,11.95l-2.359,1.24l0.469-2.729l-3.037-0.327l2.123-2.228L2.083,6.093l2.367-0.344L3.863,2.956l2.943,1.411L8.121,1.706 M8.121,0L7.443,1.372L6.461,3.364L4.19,2.275L2.812,1.614L3.125,3.11l0.42,2.008L1.974,5.346l-1.513,0.22l1.095,1.067l1.327,1.294L1.274,9.614L0.22,10.722l1.521,0.163l2.237,0.241l-0.333,1.938L3.387,14.57l1.354-0.712l1.699-0.893l0.912,1.688L8.078,16l0.627-1.396l0.805-1.793l1.991,1.047l1.354,0.712l-0.259-1.507l-0.394-2.298l1.823-0.335l1.504-0.274L14.395,9.13l-1.178-1.066l1.469-1.43l1.095-1.068l-1.513-0.22l-2.492-0.362l0.295-2.202l0.203-1.517l-1.326,0.762L9.523,2.843L8.797,1.372L8.121,0L8.121,0z";
                icon2.Color = Color.White;
                icon2.Size  = size;
                var icon = new C1CompositeIcon();
                icon.Size = size;
                icon.Icons.Add(icon2);
                icon.Icons.Add(icon1);
                _newIcon = IconElement.CreateElement(icon);
            }
            _text.Text = value?.ToString();
        }
		public Task<IconElement> LoadIconElementAsync(ImageSource imagesource, CancellationToken cancellationToken = default(CancellationToken))
		{
			IconElement image = null;

			if (imagesource is FontImageSource fontImageSource)
			{
				image = new FontIcon
				{
					Glyph = fontImageSource.Glyph,
					FontSize = fontImageSource.Size,
					Foreground = fontImageSource.Color.ToBrush()
				};

				var uwpFontFamily = fontImageSource.FontFamily.ToFontFamily();

				if (!string.IsNullOrEmpty(uwpFontFamily.Source))
					((FontIcon)image).FontFamily = uwpFontFamily;
			}

			return Task.FromResult(image);
		}
        // C1Icon is UI-less object which can be used to specify icon properties, layout and other options.
        // To show C1Icon, application should create IconElements and put them inside some layout panel.
        // BuildUI method creates elements for every icon and puts them into uniform grid cells.
        private void BuildUI()
        {
            if (_icons == null || _icons.Count < 1)
            {
                return;
            }

            // create uniform grid with the same number of rows and columns
            int count = (int)Math.Floor(Math.Sqrt(_icons.Count));

            _element = new UniformGrid(count, count);
            Element  = _element;
            Element.Parent.Bounds    = this.Bounds;
            _element.Style           = new Style();
            _element.Style.Margins   = new Thickness(4);
            _element.Style.ForeColor = ForeColor;

            // Create IconElements for each icon and place them into uniform grid
            int r = 0;
            int c = 0;

            foreach (C1Icon icon in _icons)
            {
                // Use factory method IconElement.CreateElement(icon) to create elements.
                // This method returns IconElement instances specific to icon type.
                // For example, for C1PathIcon it returns PathIconElement.
                var iconElement = IconElement.CreateElement(icon);

                // place IconElement into grid cell
                _element[r, c].Element = iconElement;
                c++;
                if (c > count - 1)
                {
                    c = 0;
                    r++;
                }
            }
        }
Example #16
0
        private async Task RefreshCircleInfo()
        {
            if (string.IsNullOrEmpty(CircleId))
            {
                return;
            }

            Circle = await DataRequester.RequestCircleInfo(CircleId);

            if (Circle == null)
            {
                return;
            }

            Title = Circle.Name;
            if (string.IsNullOrEmpty(Circle.Image))
            {
                Circle.Image = Circle.Thumbnail;
            }
            Circle.Adjust();

            JoinCircleButtonIcon = Circle.Status == 1 ? _checkIcon : _addIcon;
            Notify("Circle");
        }
Example #17
0
        public object GenerateView(object view, string title)
        {
            string    _title    = App.Current.Resources["title"]?.ToString() ?? title;
            DockPanel _baseDock = new DockPanel();

            if (StackCount() != 0)
            {
                //初始化标题栏
                StackPanel _navBar = new StackPanel()
                {
                    Orientation = Orientation.Horizontal,
                    Margin      = new Thickness(0, 0, 0, 10)
                };
                Button    backBtn = new Button();
                TextBlock titleTB = new TextBlock()
                {
                    FontSize = 23, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(20, 0, 0, 0), Text = _title
                };
                IconElement.SetGeometry(backBtn, (Geometry)App.Current.Resources["LeftGeometry"]);
                backBtn.Click += (s, e) => Back();
                _navBar.Children.Add(backBtn);
                _navBar.Children.Add(titleTB);
                _baseDock.Children.Add(_navBar);
                DockPanel.SetDock(_navBar, Dock.Top);
            }
            //初始化内容容器
            ContentControl contentControl = new ContentControl()
            {
                Content = view
            };

            _baseDock.Children.Add(contentControl);
            DockPanel.SetDock(contentControl, Dock.Bottom);

            return(_baseDock);
        }
Example #18
0
        private void CreateFlyoutItem(IList <MenuFlyoutItemBase> flyout, bool create, Action command, string text, IconElement icon = null, VirtualKey?key = null, VirtualKeyModifiers modifiers = VirtualKeyModifiers.Control)
        {
            var flyoutItem = new MenuFlyoutItem();

            flyoutItem.IsEnabled = create;
            flyoutItem.Command   = new RelayCommand(command);
            flyoutItem.Text      = text;

            if (icon != null)
            {
                flyoutItem.Icon = icon;
            }

            if (key.HasValue && ApiInfo.CanUseAccelerators)
            {
                flyoutItem.KeyboardAccelerators.Add(new KeyboardAccelerator {
                    Modifiers = modifiers, Key = key.Value, IsEnabled = false
                });
            }

            flyout.Add(flyoutItem);
        }
Example #19
0
 private ShellNavigationItem(string name, IconElement icon, Type pageType)
 {
     this.Label        = name;
     this._iconElement = icon;
     this.PageType     = pageType;
 }
Example #20
0
        public void CreateCommandButton(ShellCommand command)
        {
            IconElement getIcon()
            {
                IconElement icon = null;

                if (command.Icon is SymbolIcon symbolicon)
                {
                    icon = new SymbolIcon {
                        Symbol = symbolicon.Symbol
                    }
                }
                ;
                else if (command.Icon is FontIcon fonticon)
                {
                    icon = new FontIcon {
                        FontFamily = fonticon.FontFamily, Glyph = fonticon.Glyph
                    }
                }
                ;

                command.Icons.Add(icon);

                return(icon);
            }

            if (command is ToggleShellCommand togglecommand)
            {
                var button = new AppBarToggleButton()
                {
                    DataContext = command,
                    Label       = command.Label,
                    Icon        = getIcon()
                };
                button.Click += delegate { togglecommand.Toggled = button.IsChecked.Value; command.Action.Invoke(); };
                PrimaryCommands.Add(button);

                command.IconReplacementRequested += delegate
                {
                    command.Icons.Remove(button.Icon);
                    button.Icon = getIcon();
                };
                command.LabelReplacementRequested += delegate
                {
                    button.Label = command.Label;
                };
            }
            else
            {
                var button = new AppBarButton()
                {
                    DataContext = command,
                    Label       = command.Label,
                    Icon        = getIcon()
                };
                button.Click += delegate { command.Action?.Invoke(); };
                PrimaryCommands.Add(button);

                command.IconReplacementRequested += delegate
                {
                    command.Icons.Remove(button.Icon);
                    button.Icon = getIcon();
                };
                command.LabelReplacementRequested += delegate
                {
                    button.Label = command.Label;
                };
            }

            HasItems = true;
            TryShowItems();
        }
Example #21
0
        /// <summary>
        /// Creates instance of <see cref="PlayerViewModel"/>
        /// </summary>
        /// <param name="logger">Instance of <see cref="ILogger"/></param>
        /// <param name="playlist">Instance of <see cref="IPlayList"/></param>
        /// <param name="applicationSettingsHelper">Instance of <see cref="IApplicationSettingsHelper"/></param>
        /// <param name="navigationService">Instance of <see cref="INavigationService"/></param>
        public PlayerViewModel(
            ILogger logger,
            IApplicationSettingsHelper applicationSettingsHelper,
            INavigationService navigationService,
            IPlaybackManager playbackManager)
        {
            this.logger = logger;
            this.navigationService = navigationService;
            this.applicationSettingsHelper = applicationSettingsHelper;
            this.playbackManager = playbackManager;
            pauseIcon = new SymbolIcon(Symbol.Pause);
            playIcon = new SymbolIcon(Symbol.Play);
            PlayButtonIcon = playIcon;
            progressUpdateTimer = new DispatcherTimer();

            // Using explicit casts here because of http://stackoverflow.com/questions/2057146/compiler-ambiguous-invocation-error-anonymous-method-and-method-group-with-fun
            PreviousTrackCommand = new RelayCommand((Action)onPreviousTrackAction);
            NextTrackCommand = new RelayCommand((Action)onNextTrackAction);
            PlayPauseCommand = new RelayCommand((Action)onPlayPauseAction);

            Application.Current.Suspending += onAppSuspending;
            Application.Current.Resuming += onAppResuming;

            Initialization = initializeAsync();
            logger.LogMessage("Foreground audio player initialized.", LoggingLevel.Information);
        }
        // Probably used only for members context menu
        public static void CreateFlyoutItem <T1, T2, T3>(this MenuFlyout flyout, Func <T1, T2, T3, bool> visibility, ICommand command, T1 chatType, T2 status, T3 parameter, string text, IconElement icon = null, VirtualKey?key = null, VirtualKeyModifiers modifiers = VirtualKeyModifiers.Control) where T3 : class
        {
            var value = visibility(chatType, status, parameter as T3);

            if (value)
            {
                var flyoutItem = new MenuFlyoutItem();
                flyoutItem.CommandParameter = parameter;
                flyoutItem.Command          = command;
                flyoutItem.Text             = text;

                if (icon != null)
                {
                    flyoutItem.Icon = icon;
                }

                if (key.HasValue && ApiInfo.CanUseAccelerators)
                {
                    flyoutItem.KeyboardAccelerators.Add(new KeyboardAccelerator {
                        Modifiers = modifiers, Key = key.Value, IsEnabled = false
                    });
                }

                flyout.Items.Add(flyoutItem);
            }
        }
Example #23
0
 /// <summary>
 /// Ajoute un bouton avec un flyout associé à la CommandBar
 /// </summary>
 /// <param name="emplacement">Type d'emplacment du bouton sur la CommandBar, PrimaryCommands ou SecondaryCommands</param>
 /// <param name="icon">Icon du bouton</param>
 /// <param name="label">Label du bouton</param>
 /// <param name="flyout">Flyout associé au bouton</param>
 public static CommandBarElement AddFlyoutButton(CommandBarEmplacement emplacement, IconElement icon, string label, FlyoutBase flyout)
 {
     return AddObjectToCommandBar(CommandBarButtonType.FlyoutButton, emplacement, icon, label, null, null, flyout);
 }
        public static NavigationItem NodeFromSubitems(string id, string caption, IEnumerable <NavigationItem> subitems, IconElement icon = null, Image image = null)
        {
            var node = new NavigationItem(id, caption);

            node.SubItems = subitems;
            node.Icon     = icon;
            node.Image    = image;
            return(node);
        }
        public static void CreateFlyoutItem(this IList <MenuFlyoutItemBase> items, ICommand command, object parameter, string text, IconElement icon = null, VirtualKey?key = null, VirtualKeyModifiers modifiers = VirtualKeyModifiers.Control)
        {
            var flyoutItem = new MenuFlyoutItem();

            flyoutItem.IsEnabled        = command != null;
            flyoutItem.CommandParameter = parameter;
            flyoutItem.Command          = command;
            flyoutItem.Text             = text;

            if (icon != null)
            {
                flyoutItem.Icon = icon;
            }

            if (key.HasValue && ApiInfo.CanUseAccelerators)
            {
                flyoutItem.KeyboardAccelerators.Add(new KeyboardAccelerator {
                    Modifiers = modifiers, Key = key.Value, IsEnabled = false
                });
            }

            items.Add(flyoutItem);
        }
Example #26
0
 public ShellNavigationItem(string label, IconElement icon, string viewModelName)
     : this(label, viewModelName)
 {
     _iconElement = icon;
 }
        public static NavigationItem NodeFromAction(string id, string caption, Action <NavigationItem> onClick, IconElement icon = null, Image image = null)
        {
            var node = new NavigationItem(id, caption);

            node.OnClick = onClick;
            node.Icon    = icon;
            node.Image   = image;
            return(node);
        }
Example #28
0
        private void Play()
        {
            currentlyPlayingMusic = true;
            PlayIcon = new SymbolIcon(Symbol.Pause);
            MediaElement.Play();

            ProgressMaximumDisplay = ConvertToMinuteFormat(MediaElement.NaturalDuration.TimeSpan.TotalSeconds);
            ProgressMaximum = MediaElement.NaturalDuration.TimeSpan.TotalSeconds;

            IProgress<object> progress = new Progress<object>(_ => UpdateTicker());
            Task.Run(async () =>
            {
                while (true)
                {
                    await Task.Delay(200);
                    progress.Report(null);
                }
            });
        }
Example #29
0
 protected static ICommandBarElement CreateAppBarToggleButton(IconElement icon, string label, RoutedEventHandler eventHandler)
 {
     var command = CreateAppBarToggleButton(label, eventHandler) as AppBarToggleButton;
     command.Icon = icon;
     return command;
 }
Example #30
0
        /// <summary>
        /// Ajoute un bouton à la barre
        /// </summary>
        /// <param name="objectType">type d'objet à créer</param>
        /// <param name="emplacement">Type d'emplacment du bouton sur la CommandBar, PrimaryCommands ou SecondaryCommands</param>
        /// <param name="icon">Icon du bouton</param>
        /// <param name="label">Label du bouton</param>
        /// <param name="command">ICommand du bouton</param>
        /// <param name="commandParameter">CommandParameter de la ICommand du bouton</param>
        private static CommandBarElement AddObjectToCommandBar(CommandBarButtonType objectType, CommandBarEmplacement emplacement, IconElement icon, string label, ICommand command, object commandParameter, FlyoutBase flyout)
        {
            ICommandBarElement element = null;

            switch (objectType)
            {
                case CommandBarButtonType.Button:
                    element = new AppBarButton
                    {
                        Icon = icon,
                        Label = label,
                        Command = command,
                        CommandParameter = commandParameter
                    };
                    break;
                case CommandBarButtonType.ToggleButton:
                    element = new AppBarToggleButton()
                    {
                        Icon = icon,
                        Label = label,
                        Command = command,
                        CommandParameter = commandParameter
                    };
                    break;
                case CommandBarButtonType.FlyoutButton:
                    element = new AppBarButton()
                    {
                        Icon = icon,
                        Label = label,
                        Flyout = flyout
                    };
                    break;
                case CommandBarButtonType.Separator:
                    element = new AppBarSeparator();
                    break;
            }

            if (element != null)
            {
                if (emplacement == CommandBarEmplacement.Primary)
                {
                    _commandBar.PrimaryCommands.Add(element);
                }
                else
                {
                    _commandBar.SecondaryCommands.Add(element);
                }

                if (_commandBar.Visibility == Visibility.Collapsed)
                {
                    _commandBar.Visibility = Visibility.Visible;
                }
            }
            return new CommandBarElement() { Element = element, Emplacement = emplacement };
        }
Example #31
0
 public static ShellNavigationItem FromType <T>(string name, IconElement icon) where T : Page
 {
     return(new ShellNavigationItem(name, icon, typeof(T)));
 }
        public static NavigationItem NodeFromControl(string id, string caption, Control control, IconElement icon = null, Image image = null)
        {
            var node = new NavigationItem(id, caption);

            node.Icon    = icon;
            node.Control = control;
            return(node);
        }
 public static void CreateFlyoutItem(this MenuFlyoutSubItem flyout, ICommand command, object parameter, string text, IconElement icon = null, VirtualKey?key = null, VirtualKeyModifiers modifiers = VirtualKeyModifiers.Control)
 {
     flyout.Items.CreateFlyoutItem(command, parameter, text, icon, key, modifiers);
 }
Example #34
0
 public static void SetIcon(UIElement element, IconElement value)
 {
     element.SetValue(DesignTime.IconProperty, value);
     SetInDesigner(nameof(IconProperty), element, value);
 }
 public static void CreateFlyoutItem <T>(this MenuFlyoutSubItem flyout, Func <T, bool> visibility, ICommand command, T parameter, string text, IconElement icon = null, VirtualKey?key = null, VirtualKeyModifiers modifiers = VirtualKeyModifiers.Control) where T : class
 {
     flyout.Items.CreateFlyoutItem(visibility, command, parameter, text, icon, key, modifiers);
 }
Example #36
0
 private ShellNavigationItem(string label, IconElement icon, Type pageType)
     : this(label, pageType)
 {
     _iconElement = icon;
 }
 public ShellNavigationItem(string name, IconElement icon, string pageIdentifier)
 {
     Label          = name;
     _iconElement   = icon;
     PageIdentifier = pageIdentifier;
 }
Example #38
0
 /// <summary>
 /// Ajoute un Toggle bouton à la CommandBar
 /// </summary>
 /// <param name="emplacement">Type d'emplacment du bouton sur la CommandBar, PrimaryCommands ou SecondaryCommands</param>
 /// <param name="icon">Icon du bouton</param>
 /// <param name="label">Label du bouton</param>
 /// <param name="command">ICommand du bouton</param>
 /// <param name="commandParameter">CommandParameter de la ICommand du bouton</param>
 public static CommandBarElement AddToggleButton(CommandBarEmplacement emplacement, IconElement icon, string label,
     ICommand command, object commandParameter = null)
 {
     return AddObjectToCommandBar(CommandBarButtonType.ToggleButton, emplacement, icon, label, command, commandParameter, null);
 }