Exemplo n.º 1
0
        /// <summary>Initializes a new instance of the <see cref="SearchHamburgerItem"/> class.</summary>
        public SearchHamburgerItem()
        {
            AutoSuggestBox = new AutoSuggestBox();
            AutoSuggestBox.QueryIcon = new SymbolIcon { Symbol = Symbol.Find };
            AutoSuggestBox.AutoMaximizeSuggestionArea = false;
            AutoSuggestBox.Loaded += delegate { AutoSuggestBox.PlaceholderText = PlaceholderText; };
            AutoSuggestBox.QuerySubmitted += OnQuerySubmitted;
            AutoSuggestBox.GotFocus += OnGotFocus;

            Content = AutoSuggestBox;
            Icon = new SymbolIcon(Symbol.Find);

            CanBeSelected = false;
            ShowContentIcon = false;
            PlaceholderText = string.Empty;
            
            Click += (sender, args) =>
            {
                args.Hamburger.IsPaneOpen = true;
                args.Hamburger.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    AutoSuggestBox.Focus(FocusState.Programmatic);
                });
            };
        }
Exemplo n.º 2
0
        public static CommandBar ToAppCommandBar(this IContextMenu source, CommandBar menu, bool isSecondary)
        {
            var commandsVector = isSecondary ? menu.SecondaryCommands : menu.PrimaryCommands;
            commandsVector.Clear();

            foreach(var item in source.Items)
            {
                AppBarButton button = new AppBarButton();
                commandsVector.Add(button);
                button.Label = item.Header;
                button.Command = item.Command;
                button.CommandParameter = item.CommandParameter;

                if (!string.IsNullOrEmpty(item.Icon))
                {
                    var icon = new SymbolIcon();
                    icon.Symbol = (Symbol)System.Enum.Parse(typeof(Symbol), item.Icon);
                    button.Icon = icon;
                }
                else
                    button.Icon = new SymbolIcon(Symbol.Emoji);
            }

            return menu;
        }
Exemplo n.º 3
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            button = GetTemplateChild(PART_BUTTON_NAME) as Button;
            symbol = GetTemplateChild(PART_SYMBOL_ICON_NAME) as SymbolIcon;
            this.PlaceholderText = "Type or Speech";

            Initialization = InitializeAsync();

            InitEvents();
        }
 public object Convert(object value, Type targetType, object parameter, string language)
 {
     var isPlaying = (bool)value;
     var icon = new SymbolIcon();
     if (isPlaying)
     {
         icon.Symbol = Symbol.Pause;
     }
     else
     {
         icon.Symbol = Symbol.Play;
     }
     return icon;
 }
 public object Convert(object value, Type targetType, object parameter, string language)
 {
     var isLocal = (bool)value;
     var symbolIcon = new SymbolIcon();
     if (isLocal)
     {
         symbolIcon.Symbol = Symbol.Delete;
     }
     else
     {
         symbolIcon.Symbol = Symbol.Download;
     }
     return symbolIcon;
 }
Exemplo n.º 6
0
        public ViewModel()
        {
            PlayCmd = new ActionCommand(PlayOrPause);
            ImportAllCmd = new ActionCommand(ImportSdCard);
            RepeatAllCmd = new ActionCommand(Nope);
            ShuffleCmd = new ActionCommand(Nope);
            PreviousCmd = new ActionCommand(Nope);
            NextCmd = new ActionCommand(Nope);
            DeleteCmd = new ActionCommand(Nope);
            ItemClickCmd = new ActionCommand<ItemClickEventArgs>(x => ItemClicked(x));

            PlayIcon = new SymbolIcon(Symbol.Play);
            CurrentlyPlayingImage = DefaultCurrentlyPlaying;

            ProgressMaximumDisplay = "0:00";
            ProgressValueDisplay = "0:00";
        }
        /// <summary>Initializes a new instance of the <see cref="SearchHamburgerItem"/> class.</summary>
        public SearchHamburgerItem()
        {
            _searchBox = new SearchBox();
            _searchBox.Loaded += delegate { _searchBox.PlaceholderText = PlaceholderText; };
            _searchBox.QuerySubmitted += OnQuerySubmitted;
            _searchBox.GotFocus += OnGotFocus;

            Content = _searchBox;
            Icon = new SymbolIcon(Symbol.Find);

            CanBeSelected = false;
            ShowContentIcon = false;

            Click += (sender, args) =>
            {
                args.Hamburger.IsPaneOpen = true;
                args.Hamburger.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    _searchBox.Focus(FocusState.Programmatic);
                });
            };
        }
Exemplo n.º 8
0
        //停止按钮的操作
        private void stop_Click(object sender, RoutedEventArgs e)
        {
            if (!has_loaded)
            {
                return;
            }

            //停止媒体播放和动画
            mediaPlayer.Stop();
            if (ellipse.Visibility == Visibility.Visible)
            {
                storyboard.Stop();
            }

            SymbolIcon icon = (SymbolIcon)playControl.Icon;

            if (icon.Symbol == Symbol.Pause)
            {
                icon.Symbol       = Symbol.Play;
                playControl.Label = "播放";
            }

            has_begun = false;
        }
Exemplo n.º 9
0
        public ChannelEditViewModel(DiscordChannel channel)
        {
            Channel = channel;

            Name                 = channel.Name;
            Topic                = channel.Topic;
            NSFW                 = channel.IsNSFW;
            Userlimit            = channel.UserLimit;
            Bitrate              = channel.Bitrate / 1000;
            PermissionOverwrites = new ObservableCollection <NavigationViewItem>();

            foreach (var overwrite in channel.PermissionOverwrites.OrderBy(o => o.Type))
            {
                var content = "";
                var icon    = new SymbolIcon();

                if (overwrite.Type == OverwriteType.Member)
                {
                    icon.Symbol = Symbol.Contact;
                    content     = channel.Guild.GetCachedMember(overwrite.Id, out var member)
                        ? $"@{member.Username}#{member.Discriminator}"
                        : $"Unknown Member {overwrite.Id}";
                }
                else if (overwrite.Type == OverwriteType.Role)
                {
                    var role = channel.Guild.Roles[overwrite.Id];
                    icon.Symbol = (Symbol)57704;
                    content     = role.Name;
                }

                PermissionOverwrites.Add(new NavigationViewItem()
                {
                    Tag = overwrite, Content = content, Icon = icon
                });
            }
        }
Exemplo n.º 10
0
 public ItemHambuguer(Symbol simbolo, string descricao)
 {
     Icone     = new SymbolIcon(simbolo);
     Descricao = descricao;
     InitializeComponent();
 }
    public ChartLayerAppearance AddScatterSeries(string desc_, string[] xAxis_, double[] yAxis_, Color color_, NullHandling nullHandling_ = NullHandling.DontPlot, SymbolIcon icon = SymbolIcon.Circle)
    {
      var d = new DataTable();
      d.Columns.Add("Heading", typeof(string));
      d.Columns.Add(desc_, typeof(double));

      for (int i = 0; i < xAxis_.Length; ++i)
      {
        d.LoadDataRow(!double.IsNaN(yAxis_[i]) ? new object[] {xAxis_[i], yAxis_[i]} : new object[] {xAxis_[i]}, true);
      }

      var series = new NumericSeries
      {
        Key = desc_,
        Label = desc_,
        Data =
        {
          LabelColumn = "Heading",
          ValueColumn = desc_
        }
      };
      series.PEs.Add(new PaintElement(color_));
      ultraChart.CompositeChart.Series.Add(series);

      var chart = new ChartLayerAppearance
      {
        ChartComponent = ultraChart,
        ChartArea = ultraChart.CompositeChart.ChartAreas[0],
        ChartType = ChartType.LineChart,
        Key = string.Format("{0}_chart", desc_),
      };

      chart.Series.Add(series);
      series.Data.DataSource = d;
      series.DataBind();

      chart.AxisX = chart.ChartArea.Axes.FromKey("xAxis_Line");
      chart.AxisY = chart.ChartArea.Axes.FromKey("yAxis_Line");

      var lcApp = (LineChartAppearance)chart.ChartTypeAppearance;
      {
        lcApp.EndStyle = LineCapStyle.Round;
        lcApp.DrawStyle = LineDrawStyle.Dot;
        lcApp.Thickness = 7;
        lcApp.MidPointAnchors = true;
        //lcApp.ConnectWithLines = false;
        //lcApp.Icon = icon;
        //lcApp.IconSize = SymbolIconSize.Medium;
        lcApp.NullHandling = nullHandling_;
      }

      ultraChart.CompositeChart.ChartLayers.Add(chart);

      m_datatables.Add(desc_, d);
      ultraChart.InvalidateLayers();

      return chart;
    }
Exemplo n.º 12
0
 public CancelButton()
 {
     Icon = new SymbolIcon(Symbol.Cancel);
 }
Exemplo n.º 13
0
 public SearchButton()
 {
     Icon = new SymbolIcon(Symbol.Zoom);
 }
Exemplo n.º 14
0
 public RefreshButton()
 {
     Icon = new SymbolIcon(Symbol.Refresh);
 }
Exemplo n.º 15
0
        /// <summary>
        /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call
        /// ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays
        /// in your app. Override this method to influence the default post-template logic of a class.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            if (_view != null)
            {
                _view.ScriptNotify        -= View_ScriptNotify;
                _view.NavigationCompleted -= View_NavigationCompleted;
            }

            if (_playPauseButton != null)
            {
                _playPauseButton.Click -= PlayPauseButton_Click;
            }

            if (_animationList != null)
            {
                _animationList.SelectionChanged -= AnimationList_SelectionChanged;
            }

            if (_animationSlider != null)
            {
                _animationSlider.LayoutUpdated -= AnimationSlider_LayoutUpdated;
                _animationSlider.ValueChanged  -= AnimationSlider_ValueChanged;
            }

            base.OnApplyTemplate();

            _view = GetTemplateChild(WebViewPart) as WebView;
            if (_view != null)
            {
                _view.ScriptNotify        += View_ScriptNotify;
                _view.NavigationCompleted += View_NavigationCompleted;
                _view.Navigate(new Uri("ms-appx-web:///CrossDeviceExpDemo.Shared/Controls/Model3D/BabylonView.html"));
            }

            _animationList = GetTemplateChild(AnimationListPart) as ComboBox;
            if (_animationList != null)
            {
                _animationList.SelectionChanged += AnimationList_SelectionChanged;
            }

            _commandGrid = GetTemplateChild(CommandGridPart) as Grid;

            _playSymbol  = GetTemplateChild(PlaySymbolPart) as SymbolIcon;
            _pauseSymbol = GetTemplateChild(PauseSymbolPart) as SymbolIcon;

            _animationSlider = GetTemplateChild(AnimationSliderPart) as Slider;

            if (_animationSlider != null)
            {
                _animationSlider.Minimum        = 0;
                _animationSlider.Maximum        = 100;
                _animationSlider.LayoutUpdated += AnimationSlider_LayoutUpdated;
                _animationSlider.ValueChanged  += AnimationSlider_ValueChanged;
            }

            _playPauseButton = GetTemplateChild(PlayPauseButtonPart) as Button;
            if (_playPauseButton != null)
            {
                _playPauseButton.Click += PlayPauseButton_Click;
            }
        }
Exemplo n.º 16
0
        public void PreviousSongs(MediaElement m, ListView lsv, ListView lsv1, SymbolIcon s, SymbolIcon s2)
        {
            SolidColorBrush Currentcolor1 = (SolidColorBrush)s.Foreground;
            SolidColorBrush Currentcolor2 = (SolidColorBrush)s2.Foreground;
            SolidColorBrush color         = new SolidColorBrush(Color.FromArgb(255, 51, 51, 51));



            if ((lsv.SelectedIndex < 0 || lsv.SelectedIndex <= lsv.Items.Count - 1) || (lsv1.SelectedIndex < 0 || lsv1.SelectedIndex <= lsv1.Items.Count - 1))
            {
                if (!Currentcolor1.Color.Equals(color.Color) && !Currentcolor2.Color.Equals(color.Color))
                {
                    if (lsv.Visibility == Windows.UI.Xaml.Visibility.Visible)
                    {
                        lsv.SelectedIndex--;
                    }
                    else
                    if (lsv1.Visibility == Windows.UI.Xaml.Visibility.Visible)
                    {
                        //lsv1.SelectedIndex = lsv.SelectedIndex;
                        lsv1.SelectedIndex--;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    if (Currentcolor1.Color.Equals(color.Color) && s.Name == "shuffleIcon")
                    {
                        Shuffler(lsv);
                    }

                    else if (Currentcolor2.Color.Equals(color.Color) && s2.Name == "repeatIcon")
                    {
                        RepeatSongs(m);
                    }
                }
            }
            else
            {
                return;
            }
        }
Exemplo n.º 17
0
        //Shows song suggestions in the searchbox based on what has been typed.
        private void SearchBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
        {
            if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
            {
                var textresults = new List <StackPanel>();

                //Get Artists
                var artistsresults = SongListStorage.SearchArtists(SearchBox.Text);
                foreach (Artist artist in artistsresults)
                {
                    StackPanel stackpanel = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    stackpanel.Tag = artist;

                    SymbolIcon symbol = new SymbolIcon()
                    {
                        Symbol = Symbol.Contact,
                        Margin = new Thickness()
                        {
                            Right = 5
                        }
                    };
                    stackpanel.Children.Add(symbol);

                    TextBlock textblock = new TextBlock()
                    {
                        Text = artist.name,
                    };


                    stackpanel.Children.Add(textblock);

                    textresults.Add(stackpanel);
                }

                //Get Albums
                var albumresults = SongListStorage.SearchAlbums(SearchBox.Text, SongListStorage.Albums);
                foreach (Album album in albumresults)
                {
                    StackPanel stackpanel = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    stackpanel.Tag = album;

                    SymbolIcon symbol = new SymbolIcon()
                    {
                        Symbol = Symbol.Rotate,
                        Margin = new Thickness()
                        {
                            Right = 5
                        }
                    };
                    stackpanel.Children.Add(symbol);

                    TextBlock textblock = new TextBlock()
                    {
                        Text = album.Name,
                    };
                    stackpanel.Children.Add(textblock);

                    /*Button playbutton = new Button()
                     * {
                     *  Content = new SymbolIcon()
                     *  {
                     *      Symbol = Symbol.Play,
                     *      Margin = new Thickness() { Right = 5 },
                     *      Tag = album
                     *  },
                     * };
                     * playbutton.Click += Playbutton_Click;
                     * stackpanel.Children.Add(playbutton);*/


                    textresults.Add(stackpanel);
                }

                //Get Songs
                var songresults = SongListStorage.SearchSongs(SearchBox.Text);
                foreach (Song song in songresults)
                {
                    StackPanel stackpanel = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    stackpanel.Tag = song;

                    SymbolIcon symbol = new SymbolIcon()
                    {
                        Symbol = Symbol.Audio,
                        Margin = new Thickness()
                        {
                            Right = 5
                        }
                    };
                    stackpanel.Children.Add(symbol);

                    TextBlock textblock = new TextBlock()
                    {
                        Text = song.Title,
                    };
                    stackpanel.Children.Add(textblock);

                    /*Button playbutton = new Button()
                     * {
                     *  Content = new SymbolIcon()
                     *  {
                     *      Symbol = Symbol.Play,
                     *      Margin = new Thickness() { Right = 5 },
                     *      Tag = song
                     *  },
                     * };
                     * playbutton.Click += Playbutton_Click;
                     * stackpanel.Children.Add(playbutton);*/



                    textresults.Add(stackpanel);
                }

                SearchBox.ItemsSource = textresults;
            }
        }
Exemplo n.º 18
0
        /// <inheritdoc/>
        public override void AddControls()
        {
            Grid content = new Grid()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
            };

            RowDefinition mainRow = new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            };

            RowDefinition buttonsRow = new RowDefinition()
            {
                Height = new GridLength(59, GridUnitType.Pixel)
            };

            content.RowDefinitions.Add(mainRow);
            content.RowDefinitions.Add(buttonsRow);

            ScrollViewer mainScrollView = new ScrollViewer()
            {
                VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
                VerticalScrollMode          = ScrollMode.Enabled
            };

            Grid.SetRow(mainScrollView, 0);

            mainContent            = new RelativePanel();
            mainScrollView.Content = mainContent;

            content.Children.Add(mainScrollView);

            Grid buttonsPart = new Grid();

            Grid.SetRow(buttonsPart, 1);

            RowDefinition buttonRow = new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            };

            buttonsPart.RowDefinitions.Add(buttonRow);

            Button Cancel = new Button()
            {
                Name                = nameof(Cancel),
                Margin              = new Thickness(1, 1, 0, 1),
                FontSize            = 15,
                IsEnabled           = true,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Command             = (DataContext as ViewModelBase).GetPropertyValue("Close") as ICommand
            };

            StackPanel cancelContent = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };

            SymbolIcon cancelIcon = new SymbolIcon(Symbol.Cancel)
            {
                Margin = new Thickness(0, 0, 10, 0)
            };

            TextBlock cancelText = new TextBlock()
            {
                Text = "Cancel"
            };

            cancelContent.Children.Add(cancelIcon);
            cancelContent.Children.Add(cancelText);
            Cancel.Content = cancelContent;
            ToolTipService.SetToolTip(Cancel, "Cancel (Esc)");

            KeyboardAccelerator cancelKeyboardAccelerator = new KeyboardAccelerator()
            {
                Key = VirtualKey.Escape
            };

            Cancel.KeyboardAccelerators.Add(cancelKeyboardAccelerator);

            buttonsPart.Children.Add(Cancel);
            content.Children.Add(buttonsPart);

            Content = content;
        }
Exemplo n.º 19
0
            public DecreaseFontSizeCommand(EntryNotesViewModel parent)
            {
                if (parent == null)
                    throw new ArgumentNullException("parent");

                _parent = parent;
                Label = "decrease";
                Icon = new SymbolIcon(Symbol.FontDecrease);

                UpdateState();
            }
        private void UpdatePlayPauseLabelAndIcon()
        {
            switch (playService.CurrentState)
            {
                case Windows.Media.Playback.MediaPlaybackState.Opening:
                    break;
                case Windows.Media.Playback.MediaPlaybackState.Buffering:
                    break;
                case Windows.Media.Playback.MediaPlaybackState.Playing:
                    PlayPauseIcon = new SymbolIcon(Symbol.Pause);
                    PlayPauseLabel = "Pause";
                    canPlayPause = true;
                    break;
                case Windows.Media.Playback.MediaPlaybackState.Paused:
                    PlayPauseIcon = new SymbolIcon(Symbol.Play);
                    PlayPauseLabel = "Resume";
                    canPlayPause = true;
                    break;
                default:
                    break;
            }

            (PlayPauseCommand as RelayCommand).RaiseCanExecuteChanged();
        }
Exemplo n.º 21
0
        /// <inheritdoc/>
        public override void AddControls()
        {
            Grid content = new Grid()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
            };

            RowDefinition mainRow = new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            };

            RowDefinition buttonsRow = new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            };

            // binding

            content.RowDefinitions.Add(mainRow);
            content.RowDefinitions.Add(buttonsRow);

            ScrollViewer mainScrollView = new ScrollViewer()
            {
                VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
                VerticalScrollMode          = ScrollMode.Enabled
            };

            Grid.SetRow(mainScrollView, 0);

            mainContent            = new RelativePanel();
            mainScrollView.Content = mainContent;

            content.Children.Add(mainScrollView);



            Grid buttonsPart = new Grid();

            Grid.SetRow(buttonsPart, 1);

            ColumnDefinition col1 = new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            };

            ColumnDefinition col2 = new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            };

            buttonsPart.ColumnDefinitions.Add(col1);
            buttonsPart.ColumnDefinitions.Add(col2);

            RowDefinition AddCloseRow = new RowDefinition();

            AddCloseRow.SetValue(NameProperty, nameof(AddCloseRow));

            RowDefinition row2 = new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            };

            buttonsPart.RowDefinitions.Add(AddCloseRow);
            buttonsPart.RowDefinitions.Add(row2);

            Button AddClose = new Button()
            {
                Name                = nameof(AddClose),
                Margin              = new Thickness(0, 0, 0, 1),
                FontSize            = 15,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Command             = (DataContext as ViewModelBase).GetPropertyValue("SaveItemCloseCommand") as ICommand,
                CommandParameter    = (DataContext as ViewModelBase).GetPropertyValue("AddEditItem")
            };

            Grid.SetRow(AddClose, 0);
            Grid.SetColumnSpan(AddClose, 2);

            Binding addCloseRowHeightBinding = new Binding()
            {
                Path                = new PropertyPath(nameof(Button.Visibility)),
                ElementName         = nameof(AddClose),
                Mode                = BindingMode.OneWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Converter           = new VisibilityToGridLength()
            };

            BindingOperations.SetBinding(AddCloseRow, RowDefinition.HeightProperty, addCloseRowHeightBinding);

            Binding gridRowHeightBinding = new Binding()
            {
                Path                = new PropertyPath(nameof(Button.Visibility)),
                ElementName         = nameof(AddClose),
                Mode                = BindingMode.OneWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Converter           = new AddCloseVisibilityConverter()
            };

            BindingOperations.SetBinding(buttonsRow, RowDefinition.HeightProperty, gridRowHeightBinding);

            Binding addCloseVisibilityBinding = new Binding()
            {
                Source = ((DataContext as ViewModelBase).GetPropertyValue("AddEditItem") as AtomicItem).Id,
                Mode   = BindingMode.OneWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Converter           = new IdConverter(),
                ConverterParameter  = "visibility"
            };

            BindingOperations.SetBinding(AddClose, Button.VisibilityProperty, addCloseVisibilityBinding);
            ApplicationBase.Current.PropertyChangedNotifier.RegisterProperty(AddClose, Button.VisibilityProperty, "AddEditItem", viewModelType, "Id", converter: new IdConverter(), converterParameter: "visibility");

            StackPanel addCloseContent = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };

            SymbolIcon addCloseIcon = new SymbolIcon(Symbol.SaveLocal)
            {
                Margin = new Thickness(0, 0, 10, 0)
            };

            TextBlock addCloseText = new TextBlock()
            {
                Text = "Add and Close"
            };

            addCloseContent.Children.Add(addCloseIcon);
            addCloseContent.Children.Add(addCloseText);
            AddClose.Content = addCloseContent;

            ToolTipService.SetToolTip(AddClose, "Add and Close (Ctrl + Shift + S)");

            KeyboardAccelerator addCloseKeyboardAccelerator = new KeyboardAccelerator()
            {
                Key       = VirtualKey.S,
                Modifiers = VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift
            };

            AddClose.KeyboardAccelerators.Add(addCloseKeyboardAccelerator);

            Button Add = new Button()
            {
                Name                = nameof(Add),
                Margin              = new Thickness(0, 1, 1, 1),
                FontSize            = 15,
                IsEnabled           = true,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Command             = (DataContext as ViewModelBase).GetPropertyValue("SaveItemCommand") as ICommand,
                CommandParameter    = (DataContext as ViewModelBase).GetPropertyValue("AddEditItem")
            };

            Grid.SetRow(Add, 1);
            Grid.SetColumn(Add, 0);

            StackPanel addContent = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };

            SymbolIcon addIcon = new SymbolIcon(Symbol.Save)
            {
                Margin = new Thickness(0, 0, 10, 0)
            };

            TextBlock AddText = new TextBlock()
            {
                Name = nameof(AddText)
            };

            Binding addTextBinding = new Binding()
            {
                Source = ((DataContext as ViewModelBase).GetPropertyValue("AddEditItem") as AtomicItem).Id,
                Mode   = BindingMode.OneWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Converter           = new IdConverter(),
                ConverterParameter  = "text"
            };

            BindingOperations.SetBinding(AddText, TextBlock.TextProperty, addTextBinding);
            ApplicationBase.Current.PropertyChangedNotifier.RegisterProperty(AddText, TextBlock.TextProperty, "AddEditItem", viewModelType, "Id", converter: new IdConverter(), converterParameter: "text");

            addContent.Children.Add(addIcon);
            addContent.Children.Add(AddText);
            Add.Content = addContent;
            ToolTipService.SetToolTip(Add, "Add (Ctrl + S)");

            KeyboardAccelerator addKeyboardAccelerator = new KeyboardAccelerator()
            {
                Key       = VirtualKey.S,
                Modifiers = VirtualKeyModifiers.Control
            };

            Add.KeyboardAccelerators.Add(addKeyboardAccelerator);

            Button Cancel = new Button()
            {
                Name                = nameof(Cancel),
                Margin              = new Thickness(1, 1, 0, 1),
                FontSize            = 15,
                IsEnabled           = true,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Command             = (DataContext as ViewModelBase).GetPropertyValue("Close") as ICommand
            };

            Grid.SetRow(Cancel, 1);
            Grid.SetColumn(Cancel, 1);

            StackPanel cancelContent = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };

            SymbolIcon cancelIcon = new SymbolIcon(Symbol.Cancel)
            {
                Margin = new Thickness(0, 0, 10, 0)
            };

            TextBlock cancelText = new TextBlock()
            {
                Text = "Cancel"
            };

            cancelContent.Children.Add(cancelIcon);
            cancelContent.Children.Add(cancelText);
            Cancel.Content = cancelContent;
            ToolTipService.SetToolTip(Cancel, "Cancel (Esc)");

            KeyboardAccelerator cancelKeyboardAccelerator = new KeyboardAccelerator()
            {
                Key = VirtualKey.Escape
            };

            Cancel.KeyboardAccelerators.Add(cancelKeyboardAccelerator);

            buttonsPart.Children.Add(AddClose);
            buttonsPart.Children.Add(Add);
            buttonsPart.Children.Add(Cancel);
            content.Children.Add(buttonsPart);

            Content = content;
        }
Exemplo n.º 22
0
 public ResetGameEvent(int startingLifeValue)
 {
     PrimaryText   = "The game has been reset.";
     SecondaryText = $"Starting life is {startingLifeValue}.";
     Glyph         = new SymbolIcon(Symbol.Rotate);
 }
Exemplo n.º 23
0
        protected async override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _folder = await ApplicationData.Current.TemporaryFolder.CreateFolderAsync("hipda", CreationCollisionOption.OpenIfExists);

            if (_isCommon)
            {
                _folder = await _folder.CreateFolderAsync("common", CreationCollisionOption.OpenIfExists); // 为公共图片创建一个文件夹
            }
            else
            {
                _folder = await _folder.CreateFolderAsync(FolderName, CreationCollisionOption.OpenIfExists); // 为当前主题创建一个文件夹
            }

            ContentControl content1              = GetTemplateChild("content1") as ContentControl;
            var            myDependencyObject    = (LocalSettingsDependencyObject)App.Current.Resources["MyLocalSettings"];
            Binding        pictureOpacityBinding = new Binding {
                Source = myDependencyObject, Path = new PropertyPath("PictureOpacity")
            };

            Image img = new Image();

            img.SetBinding(Image.OpacityProperty, pictureOpacityBinding);
            img.Stretch      = Stretch.None;
            img.ImageFailed += (s, e) =>
            {
                return;
            };

            string[] urlAry       = Url.Split('/');
            string   fileFullName = urlAry.Last();

            try
            {
                IStorageItem existsFile = await _folder.TryGetItemAsync(fileFullName);

                if (existsFile != null)
                {
                    _file = existsFile as StorageFile;
                }
                else
                {
                    // 不存在则请求
                    using (var client = new HttpClient())
                    {
                        var response = await client.GetAsync(new Uri(Url));

                        var buf = await response.Content.ReadAsBufferAsync();

                        _file = await _folder.CreateFileAsync(fileFullName, CreationCollisionOption.ReplaceExisting);

                        await FileIO.WriteBufferAsync(_file, buf);
                    }
                }
            }
            catch
            {
            }

            try
            {
                if (_folder != null && _file != null)
                {
                    if (_isCommon)
                    {
                        img.Stretch = Stretch.None;
                        var bm = new BitmapImage();
                        bm.UriSource = new Uri(Url, UriKind.Absolute);
                        img.Source   = bm;
                    }
                    else
                    {
                        using (IRandomAccessStream fileStream = await _file.OpenAsync(FileAccessMode.Read))
                        {
                            if (fileStream != null)
                            {
                                BitmapImage bitmapImg = new BitmapImage();
                                await bitmapImg.SetSourceAsync(fileStream);

                                int imgWidth  = bitmapImg.PixelWidth;
                                int imgHeight = bitmapImg.PixelHeight;

                                if (_isGif)
                                {
                                    if (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily.Equals("Windows.Mobile"))
                                    {
                                        // 移动端用Button显示Gif
                                        img.Stretch  = Stretch.Uniform;
                                        img.MaxWidth = imgWidth;
                                        img.Source   = bitmapImg;

                                        SymbolIcon gifSymbolIcon = new SymbolIcon();
                                        gifSymbolIcon.Symbol = Symbol.Play;
                                        gifSymbolIcon.HorizontalAlignment = HorizontalAlignment.Center;
                                        gifSymbolIcon.VerticalAlignment   = VerticalAlignment.Center;

                                        Grid gifGrid = new Grid();
                                        gifGrid.Children.Add(img);
                                        gifGrid.Children.Add(gifSymbolIcon);

                                        Button gifButton = new Button();
                                        gifButton.Padding = new Thickness(0);
                                        gifButton.Content = gifGrid;

                                        content1.Content = gifButton;
                                    }
                                    else if (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily.Equals("Windows.Desktop"))
                                    {
                                        // PC端用WebView显示Gif图片
                                        WebView webView = new WebView();
                                        webView.SetBinding(WebView.OpacityProperty, pictureOpacityBinding);
                                        webView.DefaultBackgroundColor = Colors.Transparent;
                                        webView.Width         = imgWidth;
                                        webView.Height        = imgHeight;
                                        webView.ScriptNotify += async(s, e) =>
                                        {
                                            await OpenPhoto();
                                        };

                                        string imgHtml = @"<html><head><meta name=""viewport"" content=""width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0""></head><body style=""margin:0;padding:0;"" onclick=""window.external.notify('go');""><img src=""{0}"" alt=""Gif Image"" /></body></html>";
                                        imgHtml = string.Format(imgHtml, Url);
                                        webView.NavigateToString(imgHtml);

                                        content1.Content = webView;
                                    }
                                }
                                else // 其它图片,使用Image控件显示
                                {
                                    img.MaxWidth = imgWidth;
                                    img.Stretch  = Stretch.UniformToFill;
                                    img.Source   = bitmapImg;
                                }
                            }
                        }
                    }
                }

                if (_isCommon || !_isGif) // 公共或非gif图片,使用Image控件显示
                {
                    content1.Content = img;
                }
            }
            catch
            {
            }
        }
Exemplo n.º 24
0
 public NumberPlayersChangedEvent(int numberOfPlayers)
 {
     PrimaryText = $"There are now {numberOfPlayers} players.";
     PrimaryText = (numberOfPlayers > 1) ? $"There are now {numberOfPlayers} players." : $"There is now {numberOfPlayers} player.";
     Glyph       = new SymbolIcon(Symbol.People);
 }
Exemplo n.º 25
0
 public NavigationItemModel(Symbol symbol, string label, string key) : this(label, key)
 {
     Icon = new SymbolIcon(symbol);
 }
Exemplo n.º 26
0
        /// <summary>
        /// Click listener. Calculates all the possible attacks and moves. Everything else is handled in MainPage.xaml.cs
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (!ThisPlayersTurn) return;
            System.Diagnostics.Debug.WriteLine("First controller event");
            if (ArrowsShown)
            {
               ArrowsShown = false;
            }
            else
            {
                Attacks.Clear();
                Moves.Clear();
                ArrowsShown = true;
                foreach (var a in Game.Instance.Countries[CountryName].Attacks())
                {
                    var to = Game.Instance.Countries[a.ToName];
                    var tup = GetArrowPosAndRotation(X, Y, to.X, to.Y);
                    //custom arrow position for Kamchatka/Alaska
                    if (to.Name == "Alaska" && CountryName == "Kamchatka")
                        tup = Tuple.Create(new Thickness(1230, 130, 0, 0), 90.0);
                    if(to.Name == "Kamchatka" && CountryName == "Alaska")
                        tup = Tuple.Create(new Thickness(40, 120, 0, 0), 270.0);

                    var s = new SymbolIcon
                    {
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment = VerticalAlignment.Top,
                        Foreground = Constants.AttackColor,
                        Symbol = Symbol.Up,
                        Margin = tup.Item1
                    };

                    var r = new RotateTransform()
                    {
                        Angle = tup.Item2
                    };
                    s.RenderTransform = r;
                    Attacks.Add(s, a);
                }

                foreach (var a in Game.Instance.Countries[CountryName].Moves())
                {
                    var to = Game.Instance.Countries[a.ToName];
                    var tup = GetArrowPosAndRotation(X, Y, to.X, to.Y);
                    //custom arrow position for Kamchatka/Alaska
                    if (to.Name == "Alaska" && CountryName == "Kamchatka")
                        tup = Tuple.Create(new Thickness(1230, 130, 0, 0), 90.0);
                    if (to.Name == "Kamchatka" && CountryName == "Alaska")
                        tup = Tuple.Create(new Thickness(40, 120, 0, 0), 270.0);

                    var s = new SymbolIcon
                    {
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment = VerticalAlignment.Top,
                        Foreground = Constants.MoveColor,
                        Symbol = Symbol.Up,
                        Margin = tup.Item1
                    };

                    var r = new RotateTransform()
                    {
                        Angle = tup.Item2
                    };
                    s.RenderTransform = r;
                    Moves.Add(s, a);
                }
            }
            System.Diagnostics.Debug.WriteLine("First controller event done");

        }
Exemplo n.º 27
0
        static void CreateBar(Canvas p)
        {
            if (PSB.canA != null)
            {
                return;
            }
            Canvas can = new Canvas();

            PSB.canA = can;
            p.Children.Add(can);
            can = new Canvas();
            p.Children.Add(can);
            PSB.canB       = can;
            can.Background = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255));
            can.Width      = screenW;
            can.Height     = 70;
            can.Margin     = new Thickness(0, screenH - 70, 0, 0);

            ProgressBar pb = new ProgressBar();

            pb.PointerReleased += ProgressChange;
            pb.Background       = new SolidColorBrush(Color.FromArgb(64, 255, 0, 0));
            pb.Foreground       = new SolidColorBrush(Color.FromArgb(128, 0, 250, 18));
            pb.Width            = screenW;
            pb.Height           = 5;
            pb.Margin           = new Thickness(0, 20, 0, 0);
            can.Children.Add(pb);
            PSB.progress = pb;

            SymbolIcon flag = new SymbolIcon();

            flag.Symbol     = Symbol.Flag;
            flag.Foreground = new SolidColorBrush(Colors.OrangeRed);
            can.Children.Add(flag);
            PSB.flag = flag;

            SymbolIcon si = new SymbolIcon();

            si.Symbol          = Symbol.Pause;
            si.PointerPressed += Pause;
            PSB.play           = si;
            can.Children.Add(si);
            Thickness tk = new Thickness();

            tk.Top    = 30;
            tk.Left   = 10;
            tk.Top    = 40;
            si.Margin = tk;

            si                  = new SymbolIcon();
            si.Symbol           = Symbol.Volume;
            si.PointerReleased += volume_released;
            PSB.volume          = si;
            can.Children.Add(si);
            tk.Left  += 30;
            si.Margin = tk;

            Slider s = new Slider();

            s.Visibility    = Visibility.Collapsed;
            s.ValueChanged += slider_change;
            s.Width         = 100;
            PSB.slider      = s;
            can.Children.Add(s);
            s.Margin = tk;

            ComboBox cb = new ComboBox();

            cb.SelectionChanged += (o, e) => { ChangeSharp((o as ComboBox).SelectedIndex); };
            PSB.sharp            = cb;
            can.Children.Add(cb);
            tk.Left  += 140;
            cb.Margin = tk;

            cb = new ComboBox();
            cb.SelectionChanged += (o, e) => { ChangSite((o as ComboBox).SelectedIndex); };
            PSB.site             = cb;
            can.Children.Add(cb);
            tk.Left  += 80;
            cb.Margin = tk;

            TextBlock tb = new TextBlock();

            tb.Foreground = title_brush;
            tk.Left      += 80;
            tb.Margin     = tk;
            can.Children.Add(tb);
            PSB.title = tb;

            can = new Canvas();
            p.Children.Add(can);
            can.Background      = trans_brush;
            PSB.bor             = can;
            can.Width           = screenW;
            can.Height          = screenH;
            can.PointerPressed += (o, e) => {
                time = DateTime.Now.Ticks;
                PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId);
                sx = pp.Position;
                ss = PSB.flag.Margin.Left;
            };
            can.PointerMoved += (o, e) => {
                PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId);
                if (pp.IsInContact)
                {
                    double    ox = pp.Position.X - sx.X;
                    Thickness t  = PSB.flag.Margin;
                    double    x  = ss + ox;
                    if (x < 0)
                    {
                        x = 0;
                    }
                    if (x > screenX)
                    {
                        x = screenX;
                    }
                    t.Left          = x;
                    PSB.flag.Margin = t;
                    x /= screenX;
                    x *= vic.alltime;
                    int h   = (int)x / 3600;
                    int se  = (int)x % 3600;
                    int min = se / 60;
                    se %= 60;
                    string st = h.ToString() + ":" + min.ToString() + ":" + se.ToString();
                    Main.Notify(st, font_brush, trans_brush, 1000);
                }
            };
            can.PointerReleased += (o, e) => {
                if (DateTime.Now.Ticks - time < presstime)
                {
                    if (PSB.canB.Visibility == Visibility.Visible)
                    {
                        PSB.canB.Visibility = Visibility.Collapsed;
                        PSB.bor.Width       = screenW;
                        PSB.bor.Height      = screenH;
                    }
                    else
                    {
                        PSB.canB.Visibility = Visibility.Visible;
                        PSB.bor.Width       = screenW;
                        PSB.bor.Height      = screenH - 70;
                    }
                }
                else
                {
                    PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId);
                    double       ox = pp.Position.X - sx.X;
                    X = ss + ox;
                    if (X < 0)
                    {
                        X = 0;
                    }
                    if (X > screenX)
                    {
                        X = screenX;
                    }
                    Jump();
                }
            };
        }
Exemplo n.º 28
0
 public MultiSelectButton()
 {
     Icon = new SymbolIcon(Symbol.Bullets);
 }
Exemplo n.º 29
0
        static void CreateBar(Canvas p)
        {
            if (PSB.canA != null)
            {
                return;
            }
            Canvas can = new Canvas();

            PSB.canA = can;
            p.Children.Add(can);
            can = new Canvas();
            p.Children.Add(can);
            PSB.canB       = can;
            can.Background = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255));
            can.Width      = screenW;
            can.Height     = 70;
            can.Margin     = new Thickness(0, screenH - 70, 0, 0);

            ProgressBar pb = new ProgressBar();

            pb.PointerReleased += ProgressChange;
            pb.Background       = new SolidColorBrush(Color.FromArgb(64, 255, 0, 0));
            pb.Foreground       = new SolidColorBrush(Color.FromArgb(128, 0, 250, 18));
            pb.Width            = screenW;
            pb.Height           = 5;
            pb.Margin           = new Thickness(0, 20, 0, 0);
            can.Children.Add(pb);
            PSB.progress = pb;

            SymbolIcon flag = new SymbolIcon();

            flag.Symbol     = Symbol.Flag;
            flag.Foreground = new SolidColorBrush(Colors.OrangeRed);
            can.Children.Add(flag);
            PSB.flag = flag;

            SymbolIcon si = new SymbolIcon();

            si.Symbol          = Symbol.Pause;
            si.PointerPressed += Pause;
            PSB.play           = si;
            can.Children.Add(si);
            Thickness tk = new Thickness();

            tk.Top    = 30;
            tk.Left   = 10;
            tk.Top    = 40;
            si.Margin = tk;

            si                  = new SymbolIcon();
            si.Symbol           = Symbol.Volume;
            si.PointerReleased += volume_released;
            PSB.volume          = si;
            can.Children.Add(si);
            tk.Left  += 30;
            si.Margin = tk;

            Slider s = new Slider();

            s.Visibility    = Visibility.Collapsed;
            s.ValueChanged += slider_change;
            s.Width         = 100;
            PSB.slider      = s;
            can.Children.Add(s);
            s.Margin = tk;

            TextBlock tb = new TextBlock();

            tb.Foreground = Component.title_brush;
            tk.Left      += 80;
            tb.Margin     = tk;
            can.Children.Add(tb);
            PSB.title = tb;

            can = new Canvas();
            p.Children.Add(can);
            can.Background      = Component.trans_brush;
            PSB.bor             = can;
            can.Width           = screenW;
            can.Height          = screenH;
            can.PointerPressed += (o, e) => {
                time = DateTime.Now.Ticks;
                PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId);
                sx  = pp.Position;
                sst = PSB.flag.Margin.Left;
            };
            can.PointerMoved += (o, e) => {
                PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId);
                if (pp.IsInContact)
                {
                    double    ox = pp.Position.X - sx.X;
                    Thickness t  = PSB.flag.Margin;
                    t.Left = sst + ox;
                    if (t.Left < 0)
                    {
                        t.Left = 0;
                    }
                    if (t.Left > screenX)
                    {
                        t.Left = screenX;
                    }
                    PSB.flag.Margin = t;
                }
            };
            can.PointerReleased += (o, e) => {
                if (DateTime.Now.Ticks - time < presstime)
                {
                    if (PSB.canB.Visibility == Visibility.Visible)
                    {
                        PSB.canB.Visibility = Visibility.Collapsed;
                        PSB.bor.Width       = screenW;
                        PSB.bor.Height      = screenH;
                    }
                    else
                    {
                        PSB.canB.Visibility = Visibility.Visible;
                        PSB.bor.Width       = screenW;
                        PSB.bor.Height      = screenH - 70;
                    }
                }
                else
                {
                    PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId);
                    double       ox = pp.Position.X - sx.X;
                    X = sst + ox;
                    if (X < 0)
                    {
                        X = 0;
                    }
                    if (X > screenX)
                    {
                        X = screenX;
                    }
                    Jump();
                }
            };
        }
Exemplo n.º 30
0
 public RemoveButton()
 {
     Icon = new SymbolIcon(Symbol.Delete);
 }
Exemplo n.º 31
0
        private ChartLayerAppearance AddScatterSeries(DateTime[] dates_, double[] values_, string desc_, Color color_,
            int yAxisExtent_, string yLabelFormat_, object nanREplaceValue_ = null,
            NullHandling nullHandling_ = NullHandling.Zero, string[] pointLabels_ = null,
            SymbolIcon icon = SymbolIcon.Circle)
        {
            if (lineChartDataDisplay1.DataTableKeys.Contains(desc_))
                desc_ = desc_ + "(2)";

            if(ViewModel.HasTechnicals)
                return lineChartDataDisplay1.AddScatterSeries(dates_.Select(d => d.ToString("dd MMM yy")).ToArray(), values_, desc_, color_, yAxisExtent_, yLabelFormat_, nanREplaceValue_, nullHandling_, icon: icon);
            else
                return lineChartDataDisplay1.AddScatterSeries(dates_, values_, desc_, color_, yAxisExtent_, yLabelFormat_, nanREplaceValue_, nullHandling_, icon: icon);

        }
Exemplo n.º 32
0
 public AddButton()
 {
     Icon = new SymbolIcon(Symbol.Add);
 }
Exemplo n.º 33
0
 public SortAppBarButton()
 {
     Icon  = new SymbolIcon(Symbol.Sort);
     Label = "Sort";
 }
Exemplo n.º 34
0
        public Comment(double x, double y)
        {
            rectangle         = new Rectangle();
            rectangle.Width   = 25;
            rectangle.Height  = 25;
            rectangle.Opacity = 0.8;
            var rotation = new RotateTransform();

            rotation.Angle            = -30;
            rectangle.RenderTransform = rotation;
            Flyout flyout = new Flyout();

            FlyoutPresenter fp = new FlyoutPresenter();

            //Style fps = new Style();
            //fps.TargetType = typeof(FlyoutPresenter);
            //fps.Setters.Add(new Setter(BackgroundProperty, colorDecision));
            //fp.Style = fps;
            //flyout.FlyoutPresenterStyle = fps;

            Button deleteButton = new Button();

            SymbolIcon deleteSymbol = new SymbolIcon();

            deleteSymbol.Symbol  = Symbol.Delete;
            deleteButton.Content = deleteSymbol;
            deleteButton.Click  += async delegate(object e, RoutedEventArgs evt)
            {
                //canvas.Children.Remove(rectangle);
                //postits.Remove(rectangle);
            };

            InkCanvas ic = new InkCanvas();

            ic.Width  = 250;
            ic.Height = 250;

            InkToolbar it = new InkToolbar();

            it.TargetInkCanvas = ic;



            ic.InkPresenter.InputDeviceTypes =
                Windows.UI.Core.CoreInputDeviceTypes.Mouse |
                Windows.UI.Core.CoreInputDeviceTypes.Touch |
                Windows.UI.Core.CoreInputDeviceTypes.Pen;

            StackPanel sp = new StackPanel();

            sp.VerticalAlignment   = VerticalAlignment.Center;
            sp.HorizontalAlignment = HorizontalAlignment.Center;

            StackPanel rightAlign = new StackPanel();

            rightAlign.HorizontalAlignment = HorizontalAlignment.Right;
            rightAlign.Children.Add(deleteButton);
            sp.Children.Add(rightAlign);
            sp.Children.Add(ic);
            sp.Children.Add(it);

            flyout.Content = sp;
            flyout.LightDismissOverlayMode = LightDismissOverlayMode.On;
            rectangle.ContextFlyout        = flyout;
        }
Exemplo n.º 35
0
        public static IconElement MakeIconElementFrom(Microsoft.UI.Xaml.Controls.IconSource iconSource)
        {
            if (iconSource is Microsoft.UI.Xaml.Controls.FontIconSource fontIconSource)
            {
                FontIcon fontIcon = new FontIcon();

                fontIcon.Glyph    = fontIconSource.Glyph;
                fontIcon.FontSize = fontIconSource.FontSize;

                if (fontIconSource.FontFamily != null)
                {
                    fontIcon.FontFamily = fontIconSource.FontFamily;
                }

                if (fontIconSource.Foreground != null)
                {
                    fontIcon.Foreground = fontIconSource.Foreground;
                }

                fontIcon.FontWeight = fontIconSource.FontWeight;
                fontIcon.FontStyle  = fontIconSource.FontStyle;
                fontIcon.IsTextScaleFactorEnabled = fontIconSource.IsTextScaleFactorEnabled;
                fontIcon.MirroredWhenRightToLeft  = fontIconSource.MirroredWhenRightToLeft;

                return(fontIcon);
            }
            else if (iconSource is Microsoft.UI.Xaml.Controls.SymbolIconSource symbolIconSource)
            {
                SymbolIcon symbolIcon = new SymbolIcon();
                symbolIcon.Symbol = symbolIconSource.Symbol;

                if (symbolIconSource.Foreground != null)
                {
                    symbolIcon.Foreground = symbolIconSource.Foreground;
                }

                return(symbolIcon);
            }
            else if (iconSource is Microsoft.UI.Xaml.Controls.BitmapIconSource bitmapIconSource)
            {
                BitmapIcon bitmapIcon = new BitmapIcon();

                if (bitmapIconSource.UriSource != null)
                {
                    bitmapIcon.UriSource = bitmapIconSource.UriSource;
                }

                if (bitmapIconSource.Foreground != null)
                {
                    bitmapIcon.Foreground = bitmapIconSource.Foreground;
                }

                if (IsSystemDll() || ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.BitmapIcon", "ShowAsMonochrome"))
                {
                    bitmapIcon.ShowAsMonochrome = bitmapIconSource.ShowAsMonochrome;
                }

                return(bitmapIcon);
            }
            else if (iconSource is Microsoft.UI.Xaml.Controls.PathIconSource pathIconSource)
            {
                PathIcon pathIcon = new PathIcon();

                if (pathIconSource.Data != null)
                {
                    pathIcon.Data = pathIconSource.Data;
                }

                if (pathIconSource.Foreground != null)
                {
                    pathIcon.Foreground = pathIconSource.Foreground;
                }

                return(pathIcon);
            }

            return(null);
        }
Exemplo n.º 36
0
        private SymbolIcon CreateSymbolIcon(Symbol symbol, bool isRoot = false)
        {
            var icon = new SymbolIcon
            {
                Symbol = symbol,
                Width = 20,
                Height = 20,
            };

            if(isRoot)
            {
                icon.RenderTransformOrigin = new Windows.Foundation.Point(0.5, 0.5);
                icon.RenderTransform = new CompositeTransform { ScaleX = 2, ScaleY =2 };
            }

            return icon;
        }
 public MenuItem(string header, string subHeader, Symbol icon)
 {
     Header = header;
     SubHeader = subHeader;
     Icon = new SymbolIcon(icon);
 }
        private Grid CreateNodeTitle(Node node)
        {
            Grid grid = new Grid
            {
                VerticalAlignment = VerticalAlignment.Stretch,
                HorizontalAlignment = HorizontalAlignment.Stretch
            };

            SymbolIcon activityIcon = new SymbolIcon
            {
                Symbol = Symbol.Remove,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Center,
                Margin = new Thickness(5),
                Foreground = new SolidColorBrush(Color.FromArgb(255, 220, 220, 220)),
                Tag = node.nodeId
            };
            activityIcons.Add(activityIcon);
            grid.Children.Add(activityIcon);

     /*       Button button = new Button
            {
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment = VerticalAlignment.Center,
                Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)),
                Content = new SymbolIcon { Symbol = Symbol.More },
                Height = 30
                // Margin = new Thickness(5)
            };

            button.Tag = node.nodeId;
            button.Click += buttonNodeMenu_Click;
*/



            /*
             MenuFlyout menu = new MenuFlyout();
             MenuFlyoutItem item1 = new MenuFlyoutItem {Text = "Reboot Node"};
             item1.Click += buttonNodeMenu_Click;
             menu.Items.Add(item1);
             menu.Items[0].Tag = node.nodeId;

             menu.Items.Add(new MenuFlyoutItem { Text = "Delete Node" });
             MenuFlyoutItem n=new MenuFlyoutItem();
             button.Flyout = menu;
             */



            grid.Children.Add(new TextBlock
            {
                Text = "Node " + node.nodeId,
                Margin = new Thickness(5, 5, 5, 5),
                FontWeight = FontWeights.SemiBold,
                HorizontalAlignment = HorizontalAlignment.Center,

            });


          //  grid.Children.Add(button);


            return grid;
        }
Exemplo n.º 39
0
 public NavigationMenuItem(string displayName, Type pageType, Symbol icon)
 {
     DisplayName = displayName;
     Icon        = new SymbolIcon(icon);
     PageType    = pageType;
 }
Exemplo n.º 40
0
 private void PlayerServiceOnMediaStateChanged(object sender, MediaPlayerState mediaPlayerState)
 {
     var icon = Symbol.Play;
     switch (mediaPlayerState)
     {
         case MediaPlayerState.Playing:
             icon = Symbol.Pause;
             _timer.Start();
             break;
         default:
             _timer.Stop();
             break;
     }
     PlayPauseIcon = new SymbolIcon(icon);
 }
Exemplo n.º 41
0
 public CoinEvent()
 {
     PrimaryText = "Coin";
     Glyph       = new SymbolIcon(Symbol.ReShare);
 }
Exemplo n.º 42
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.Loaded      += GridViewEx_Loaded;
            this.SizeChanged += (s, ee) =>
            {
                _itemsWrapGrid = this.GetFirstDescendantOfType <ItemsWrapGrid>();
                if (_itemsWrapGrid == null)
                {
                    return;
                }
                int colum = (int)Math.Floor(ee.NewSize.Width / this.ItemWidthSuggest);
                _itemsWrapGrid.ItemWidth = ee.NewSize.Width / colum;
                if (colum > 1)
                {
                    this.ItemContainerStyle = (this.GetTemplateChild("RootLayout") as Grid).Resources["GridViewItemStyle2"] as Style;
                }
                else
                {
                    this.ItemContainerStyle = (this.GetTemplateChild("RootLayout") as Grid).Resources["GridViewItemStyle1"] as Style;
                }
            };

            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                return;
            }
            _scrollViewer = this.GetFirstDescendantOfType <ScrollViewer>();
            var binding = new Windows.UI.Xaml.Data.Binding {
                Source = _scrollViewer, Path = new PropertyPath("VerticalOffset")
            };

            BindingOperations.SetBinding(this, VerticalOffsetProperty, binding);

            _refreshIcon = this.GetTemplateChild("RefreshIcon") as SymbolIcon;
            _scrollViewer.DirectManipulationStarted   += OnDirectManipulationStarted;
            _scrollViewer.DirectManipulationCompleted += OnDirectManipulationCompleted;
            _scrollerViewerManipulation = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(_scrollViewer);
            var compositor = _scrollerViewerManipulation.Compositor;

            // At the moment there are three things happening when pulling down the list -
            // 1. The Refresh Icon fades in.
            // 2. The Refresh Icon rotates (400°).
            // 3. The Refresh Icon gets pulled down a bit (REFRESH_ICON_MAX_OFFSET_Y)
            // QUESTION 5
            // Can we also have Geometric Path animation so we can also draw the Refresh Icon along the way?
            //

            // Create a rotation expression animation based on the overpan distance of the ScrollViewer.
            _rotationAnimation = compositor.CreateExpressionAnimation("min(max(0, ScrollManipulation.Translation.Y) * Multiplier, MaxDegree)");
            _rotationAnimation.SetScalarParameter("Multiplier", 10.0f);
            _rotationAnimation.SetScalarParameter("MaxDegree", 400.0f);
            _rotationAnimation.SetReferenceParameter("ScrollManipulation", _scrollerViewerManipulation);

            // Create an opacity expression animation based on the overpan distance of the ScrollViewer.
            _opacityAnimation = compositor.CreateExpressionAnimation("min(max(0, ScrollManipulation.Translation.Y) / Divider, 1)");
            _opacityAnimation.SetScalarParameter("Divider", 30.0f);
            _opacityAnimation.SetReferenceParameter("ScrollManipulation", _scrollerViewerManipulation);

            // Create an offset expression animation based on the overpan distance of the ScrollViewer.
            _offsetAnimation = compositor.CreateExpressionAnimation("(min(max(0, ScrollManipulation.Translation.Y) / Divider, 1)) * MaxOffsetY");
            _offsetAnimation.SetScalarParameter("Divider", 30.0f);
            _offsetAnimation.SetScalarParameter("MaxOffsetY", REFRESH_ICON_MAX_OFFSET_Y);
            _offsetAnimation.SetReferenceParameter("ScrollManipulation", _scrollerViewerManipulation);

            // Get the RefreshIcon's Visual.
            _refreshIconVisual = ElementCompositionPreview.GetElementVisual(_refreshIcon);
            // Set the center point for the rotation animation
            //if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            //{
            //    _refreshIconVisual.CenterPoint = new Vector3(Convert.ToSingle(_refreshIcon.Width / 2), Convert.ToSingle(_refreshIcon.Height / 2), 0);
            //}
            // Kick off the animations.
            _refreshIconVisual.StartAnimation("RotationAngleInDegrees", _rotationAnimation);
            _refreshIconVisual.StartAnimation("Opacity", _opacityAnimation);
            _refreshIconVisual.StartAnimation("Offset.Y", _offsetAnimation);
            this.Unloaded += (s, e) =>
            {
                _scrollViewer.DirectManipulationStarted   -= OnDirectManipulationStarted;
                _scrollViewer.DirectManipulationCompleted -= OnDirectManipulationCompleted;
            };
            //加速度计,摇一摇
            //_accelerometer = Accelerometer.GetDefault();
            //if (_accelerometer != null)
            //{
            //    // Establish the report interval
            //    uint minReportInterval = _accelerometer.MinimumReportInterval;
            //    uint reportInterval = minReportInterval > 16 ? minReportInterval : 16;
            //    _accelerometer.ReportInterval = reportInterval;

            //    // Assign an event handler for the reading-changed event
            //    _accelerometer.ReadingChanged += new TypedEventHandler<Accelerometer, AccelerometerReadingChangedEventArgs>(ReadingChanged);
            //}
        }
Exemplo n.º 43
0
            public OpenUrlExternalCommand(EntryDetailsViewModel parent)
            {
                if (parent == null)
                    throw new ArgumentNullException("parent");

                _parent = parent;

                Label = "url";
                Icon = new SymbolIcon(Symbol.Link);
            }
Exemplo n.º 44
0
        public MainPageViewModel(INavigationService navigationService, IServicesPhoto servicephoto)
        {
            _navigationService = navigationService;
            _servicesPhoto = servicephoto;

            Selectionphoto = new DelegateCommand<ItemClickEventArgs>(OnSelectionPhoto);


            SearchCommand = new DelegateCommand(() =>
            {
                switch (SearchVisible)
                {
                    case Visibility.Collapsed:
                        SearchVisible = Visibility.Visible;
                        LabelBar = "cancel";
                        IconBar = new SymbolIcon(Symbol.Cancel);
                        break;

                    case Visibility.Visible:
                        SearchVisible = Visibility.Collapsed;
                        LabelBar = "search";
                        IconBar = new SymbolIcon(Symbol.Find);
                        SearchPhoto = "";
                        break;

                    default:
                        break;
                }

            });
        }
Exemplo n.º 45
0
            public OpenUrlIntervalCommand(INavigationService navigation,
                EntryDetailsViewModel parent)
            {
                if (navigation == null) throw new ArgumentNullException("navigation");
                if (parent == null) throw new ArgumentNullException("parent");

                _parent = parent;
                _navigation = navigation;

                Label = "browse";
                Icon = new SymbolIcon(Symbol.World);
            }
Exemplo n.º 46
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();
        }
Exemplo n.º 47
0
        private void createButton()
        {
            foreach (ReminderData element in App.ListOfData)
            {
                Button     button       = new Button();
                SymbolIcon deleteButton = new SymbolIcon();

                button.Content = element.Name;
                button.HorizontalContentAlignment = HorizontalAlignment.Center;
                button.VerticalContentAlignment   = VerticalAlignment.Center;
                button.Width  = 175;
                button.Height = 50;
                Thickness margin = button.Margin;
                margin.Top              = 20;
                button.Margin           = margin;
                button.Background       = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 246, 162, 0));
                button.FontSize         = 20;
                button.IsHoldingEnabled = false;
                button.Name             = App.ListOfData.IndexOf(element).ToString();


                button.Click += (s, e) =>
                {
                    var notifier  = ToastNotificationManager.CreateToastNotifier();
                    var scheduled = notifier.GetScheduledToastNotifications();


                    for (int i = 0, len = scheduled.Count; i < len; i++)

                    {
                        if (scheduled[i].Tag == App.ListOfData[int.Parse(button.Name)].Name && scheduled[i].DeliveryTime.Hour == App.ListOfData[int.Parse(button.Name)].Time.Hours && scheduled[i].DeliveryTime.Minute == App.ListOfData[int.Parse(button.Name)].Time.Minutes)
                        {
                            notifier.RemoveFromSchedule(scheduled[i]);
                        }
                    }
                    this.Frame.Navigate(typeof(EditPage), button.Name);
                };


                deleteButton.Symbol           = Symbol.Delete;
                deleteButton.Width            = 50;
                deleteButton.Height           = 50;
                deleteButton.Margin           = margin;
                deleteButton.IsHoldingEnabled = false;
                deleteButton.Name             = App.ListOfData.IndexOf(element).ToString();

                deleteButton.Tapped += async(s, e) =>
                {
                    var notifier  = ToastNotificationManager.CreateToastNotifier();
                    var scheduled = notifier.GetScheduledToastNotifications();


                    for (int i = 0, len = scheduled.Count; i < len; i++)

                    {
                        if (scheduled[i].Tag == App.ListOfData[int.Parse(button.Name)].Name && scheduled[i].DeliveryTime.Hour == App.ListOfData[int.Parse(button.Name)].Time.Hours && scheduled[i].DeliveryTime.Minute == App.ListOfData[int.Parse(button.Name)].Time.Minutes)
                        {
                            notifier.RemoveFromSchedule(scheduled[i]);
                        }
                    }
                    App.ListOfData.RemoveAt(int.Parse(deleteButton.Name));
                    await SetupPage.SaveMyData(App.ListOfData);

                    this.Frame.Navigate(typeof(Reminders));
                };


                listBox.Items.Add(button);
                listBox1.Items.Add(deleteButton);
            }
        }
Exemplo n.º 48
0
 public void _Pause(SymbolIcon s, SymbolIcon s1, MediaElement m)
 {
     s.Symbol  = Symbol.Play;
     s1.Symbol = Symbol.Play;
     m.Pause();
 }
Exemplo n.º 49
0
        /// <summary>
        /// 常用键位操作(PC)
        /// </summary>
        private void Video_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            args.Handled = true;
            switch (args.VirtualKey)
            {
            case VirtualKey.Space:
            {
                if (media.CurrentState == MediaElementState.Playing)
                {
                    media.Pause();
                    danmaku.IsPauseDanmaku(true);
                    icon_play = new SymbolIcon(Symbol.Play);
                }
                else if (media.CurrentState == MediaElementState.Paused)
                {
                    media.Play();
                    danmaku.ClearStaticDanmu();
                    danmaku.IsPauseDanmaku(false);
                    icon_play = new SymbolIcon(Symbol.Pause);
                }
            }
            break;

            case VirtualKey.Left:
            {
                sli_main.Value -= 5;
                messagepop.Show(media.Position.Hours.ToString("00") + ":" + media.Position.Minutes.ToString("00") + ":" + media.Position.Seconds.ToString("00"));
            }
            break;

            case VirtualKey.Right:
            {
                sli_main.Value += 5;
                messagepop.Show(media.Position.Hours.ToString("00") + ":" + media.Position.Minutes.ToString("00") + ":" + media.Position.Seconds.ToString("00"));
            }
            break;

            case VirtualKey.Up:
            {
                sli_vol.Value++;
                messagepop.Show("音量:" + ((int)sli_vol.Value * 10).ToString() + "%");
            }
            break;

            case VirtualKey.Down:
            {
                sli_vol.Value--;
                messagepop.Show("音量:" + ((int)sli_vol.Value * 10).ToString() + "%");
            }
            break;

            case VirtualKey.Escape:
            {
                ApplicationView.GetForCurrentView().ExitFullScreenMode();
            }
            break;

            case VirtualKey.Enter:
            {
                if (ApplicationView.GetForCurrentView().IsFullScreenMode)
                {
                    ApplicationView.GetForCurrentView().ExitFullScreenMode();
                }
                else
                {
                    ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
                }
            }
            break;
            }
        }