/// <summary> /// Guzik, który umożliwia przełączenie widoku mapy. /// </summary> private void trybMapy(object sender, RoutedEventArgs e) { AppBarButton ab = new AppBarButton(); ab = (AppBarButton)sender; //ab = sender as AppBarButton; FontIcon fIcon = new FontIcon(); FontFamily = FontFamily.XamlAutoFontFamily; if (mojaMapa.Style == MapStyle.AerialWithRoads) { mojaMapa.Style = MapStyle.Road; ab.Label = "satelita"; fIcon.FontFamily = new FontFamily("Auto"); fIcon.Glyph = "S"; ab.Icon = fIcon; } else { mojaMapa.Style = MapStyle.AerialWithRoads; ab.Label = "drogi"; fIcon.FontFamily = new FontFamily("Auto"); fIcon.Glyph = "D"; ab.Icon = fIcon; } }
public CameraForm() { InitializeComponent(); this.ShowIcon = false; barcodeService = new BarcodeService(); pictureBox1.Image = FontIcon.CreateGlyphIcon(FontIcon.Glyphs.Camera, iconWidth: 50, iconHeight: 50, emSize: 28, fontColor: Color.Red).ToBitmap(); }
private void NavView_Loaded(object sender, RoutedEventArgs e) { _title = UWPUtilities.FindControlWithName <TextBlock>("tbTitle", MyNavView); _ellName = UWPUtilities.FindControlWithName <Ellipse>("ellName", MyNavView); _ccNameGrid = UWPUtilities.FindControlWithName <Grid>("ccNameGrid", MyNavView); _ccName = UWPUtilities.FindControlWithName <ContentControl>("ccName", MyNavView); _txtName = UWPUtilities.FindControlWithName <TextBlock>("txtName", MyNavView); _txtNameChevron = UWPUtilities.FindControlWithName <FontIcon>("txtNameChevron", MyNavView); _txtAsset = UWPUtilities.FindControlWithName <TextBlock>("txtAsset", MyNavView); _txtAmount = UWPUtilities.FindControlWithName <TextBlock>("txtAmount", MyNavView); _paneContentGrid = UWPUtilities.FindControlWithName <Grid>("PaneContentGrid", MyNavView); _selectionIndicators = UWPUtilities.FindControlsWithName <Rectangle>("SelectionIndicator", MyNavView); _paneContentGrid.Background = _acrylicBrush; _txtNameChevronOriginalMargin = _txtNameChevron.Margin; _txtNameChevronOriginalVisibility = _txtNameChevron.Visibility; _ccNameGridOriginalHorizontalAlignment = _ccNameGrid.HorizontalAlignment; _ccNameOriginalHorizontalAlignment = _ccName.HorizontalAlignment; _ccNameOriginalMargin = _ccName.Margin; _ellNameOriginalWidth = _ellName.Width; _ellNameOriginalHeight = _ellName.Height; _txtNameOriginalFontSize = _txtName.FontSize; _txtAssetOriginalVisibility = _txtAsset.Visibility; _txtAmountOriginalVisibility = _txtAmount.Visibility; NavView.PaneClosing += NavView_PaneClosing; NavView.PaneOpening += NavView_PaneOpening; SetColors(); TogglePane(!NavView.IsPaneOpen); }
/* *************** * EVENTS HANDLERS * *************** */ private async void Favorite_Tapped(object sender, TappedRoutedEventArgs e) { FontIcon icon = (FontIcon)sender; Quote quote = (Quote)icon.DataContext; bool result = await FavoritesController.RemoveFavorite(quote, FavoritesController.CollectionType.favorites); }
private void Share_Tapped(object sender, TappedRoutedEventArgs e) { FontIcon icon = (FontIcon)sender; Quote q = (Quote)icon.DataContext; Controller.share(q); }
private SetsViewItem CreateTextEditorSetsViewItem(ITextEditor textEditor) { var modifierIcon = new FontIcon() { Glyph = "\uF127", FontSize = 1.5, Width = 3, Height = 3, Foreground = new SolidColorBrush(ThemeSettingsService.AppAccentColor), }; var textEditorSetsViewItem = new SetsViewItem { Header = textEditor.EditingFileName ?? textEditor.FileNamePlaceholder, Content = textEditor, SelectionIndicatorForeground = new SolidColorBrush(ThemeSettingsService.AppAccentColor), Icon = modifierIcon }; if (textEditorSetsViewItem.Content == null || textEditorSetsViewItem.Content is Page) { throw new Exception("Content should not be null and type should not be Page (SetsView does not work well with Page controls)"); } textEditorSetsViewItem.Icon.Visibility = textEditor.IsModified ? Visibility.Visible : Visibility.Collapsed; textEditorSetsViewItem.ContextFlyout = new TabContextFlyout(this, textEditor); return(textEditorSetsViewItem); }
private async void GetQuanziInfo() { wc = new WebClientClass(); string url = string.Format("http://www.im9.com/api/query.detail.community.do?community_id={0}&access_key={1}&actionKey=appkey&appkey={2}&build=418000&mobi_app=android&platform=android&ts={3}", par.id, ApiHelper.access_key, ApiHelper._appKey_Android, ApiHelper.GetTimeSpen); url += "&sign=" + ApiHelper.GetSign_Android(url); string results = await wc.GetResults(new Uri(url)); QuanziInfoModel model = JsonConvert.DeserializeObject <QuanziInfoModel>(results); QuanziInfoModel info = JsonConvert.DeserializeObject <QuanziInfoModel>(model.data.ToString()); grid_Info.DataContext = info; if (info.join_state == 1) { btn_Atten.Label = "关注"; FontIcon font = new FontIcon(); font.FontFamily = new FontFamily("Segoe MDL2 Assets"); font.Glyph = "\uE006"; btn_Atten.Icon = font; } else { btn_Atten.Label = "取消关注"; FontIcon font = new FontIcon(); font.FontFamily = new FontFamily("Segoe MDL2 Assets"); font.Glyph = "\uE00B"; btn_Atten.Icon = font; } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { //if (Frame.BackStack.Count != 0 && Frame.BackStack.First().SourcePageType == typeof(LoginPage)) // Frame.BackStack.Remove(Frame.BackStack.First()); // TODO: Create an appropriate data model for your problem domain to replace the sample data //var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); //this.DefaultViewModel["Groups"] = sampleDataGroups; //var posts = await Posts.GetActivities(null, null, null); //FontIcon icon = new FontIcon(); //icon.Glyph = (await Notifications.GetNotificationCount()).ToString(); //notificationAppBarButton.Icon = icon; //itemGridView.ItemsSource = posts.posts; var squares = await Squares.GetSquares(); //communitiesGridView.Source = squares; communitiesHub.DataContext = squares; var circles = await Circles.GetCircles(); circlesHub.DataContext = circles; FontIcon icon = new FontIcon(); icon.Glyph = (await Notifications.GetNotificationCount()).ToString(); notificationAppBarButton.Icon = icon; favouritesHub.DataContext = commands; }
public void Load(string glyph, SolidColorBrush brush) { icon = new FontIcon(); icon.FontSize = 45; icon.Foreground = brush; icon.Glyph = glyph; }
public void AddTileToList(string name, string tag) { ListViewItem item = new ListViewItem(); // Replace Special characters and create name for item Regex reg = new Regex("[*'\",_&#^@]"); item.Name = reg.Replace("item_" + name, "_"); item.Tag = tag; Grid grid = new Grid(); TextBlock text = new TextBlock { Text = name, Margin = new Thickness(0, 10, 10, 10) }; FontIcon icon = new FontIcon { FontFamily = new Windows.UI.Xaml.Media.FontFamily("Segoe MDL2 Assets"), Glyph = "\uE107" }; AppBarButton rm_button = new AppBarButton { Icon = icon, Height = 40, Width = 40, HorizontalAlignment = HorizontalAlignment.Right }; Grid.SetColumn(rm_button, 1); grid.Children.Add(rm_button); grid.Children.Add(text); grid.Width = tileList.Width; grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(40, GridUnitType.Pixel) }); item.HorizontalContentAlignment = HorizontalAlignment.Stretch; item.Content = grid; tileList.Items.Add(item); }
private async void Favorite_Tapped(object sender, TappedRoutedEventArgs e) { FontIcon icon = (FontIcon)sender; Quote quote = (Quote)icon.DataContext; if (FavoritesController.IsFavorite(quote.Link)) { // Remove from favorites bool result = await FavoritesController.RemoveFavorite(quote); if (result) { quote.IsFavorite = false; } } else { // Add to favorites bool result = await FavoritesController.AddFavorite(quote); if (result) { quote.IsFavorite = true; } } }
private void refreshMenu() { NavView.MenuItems.Clear(); foreach (var item in MenuItem.GetMainItems()) { IconElement icon; if (item.Icon.ToLowerInvariant().EndsWith(".png")) { icon = new BitmapIcon() { UriSource = new Uri(item.Icon, UriKind.RelativeOrAbsolute) }; } else { icon = new FontIcon() { FontFamily = new FontFamily("Segoe MDL2 Assets"), Glyph = item.Icon }; } NavView.MenuItems.Add(new NavigationViewItem() { Icon = icon, Content = item.Name, DataContext = item }); } }
private void NavigationMenuPageRenderer_ElementChanged(object sender, VisualElementChangedEventArgs e) { ContainerElement.Loaded += (s, ie) => { var innerGrid = VisualTreeHelper.GetChild(ContainerElement, 0); var grid = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(innerGrid))); var cmdBar = grid.FindChild <FormsCommandBar>("CommandBar"); foreach (AppBarButton cmd in cmdBar.PrimaryCommands) { var toolBarItem = ((FrameworkElement)cmd).DataContext as IconToolbarItem; if (!string.IsNullOrEmpty(toolBarItem.IconGlyph)) { var myBinding = new Windows.UI.Xaml.Data.Binding() { Source = toolBarItem, Path = new PropertyPath(nameof(IconToolbarItem.IconGlyph)), Mode = Windows.UI.Xaml.Data.BindingMode.OneWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; var icon = new FontIcon() { FontFamily = new FontFamily("Segoe MDL2 Assets"), Glyph = toolBarItem.IconGlyph }; icon.SetBinding(FontIcon.GlyphProperty, myBinding); cmd.Icon = icon; } } }; }
/// <inheritdoc /> protected override void OnApplyTemplate() { _canvasTextBoxTools = (StackPanel)GetTemplateChild("CanvasTextBoxTools"); _canvasTextBoxColorPicker = (ColorPicker)GetTemplateChild("CanvasTextBoxColorPicker"); _canvasTextBoxFontSizeTextBox = (TextBox)GetTemplateChild("CanvasTextBoxFontSizeTextBox"); _canvasTextBoxItlaicButton = (ToggleButton)GetTemplateChild("CanvasTextBoxItlaicButton"); _canvasTextBoxBoldButton = (ToggleButton)GetTemplateChild("CanvasTextBoxBoldButton"); _drawingSurfaceRenderer = (InfiniteCanvasVirtualDrawingSurface)GetTemplateChild("DrawingSurfaceRenderer"); _mainContainer = (Canvas)GetTemplateChild("MainContainer"); _infiniteCanvasScrollViewer = (ScrollViewer)GetTemplateChild("InfiniteCanvasScrollViewer"); _eraseAllButton = (Button)GetTemplateChild("EraseAllButton"); _canvasTextBox = (InfiniteCanvasTextBox)GetTemplateChild("CanvasTextBox"); _enableTextButton = (InkToolbarCustomToolButton)GetTemplateChild("EnableTextButton"); _enableTouchInkingButton = (InkToolbarCustomToggleButton)GetTemplateChild("EnableTouchInkingButton"); _inkCanvasToolBar = (InkToolbar)GetTemplateChild("InkCanvasToolBar"); _canvasToolbarContainer = (StackPanel)GetTemplateChild("CanvasToolbarContainer"); _inkCanvas = (InkCanvas)GetTemplateChild("DrawingInkCanvas"); _undoButton = (Button)GetTemplateChild("UndoButton"); _redoButton = (Button)GetTemplateChild("RedoButton"); _fontColorIcon = (FontIcon)GetTemplateChild("FontColorIcon"); UnRegisterEvents(); RegisterEvents(); ConfigureControls(); base.OnApplyTemplate(); }
protected override void OnGameStarted() { // Maximum priority so we never miss it. var priority = NotificationPriority.Critical; // Make the notification look fancy by setting the color // to the current company color. var color = Company.Current.Color; var title = "Hello World!"; var message = "Oh gosh, this is my first ever C# mod " + "for VT, and it's actually working for some reason!"; // Action is executed when player clicks on notification. var action = new HelloVoxelWorldNotificationAction(); // If you don't need any action, just pass default value (null). // var action = default(INotificationAction); // Use custom FontAwesome (https://fontawesome.com/icons) icon var icon = FontIcon.FaSolid("\uf7e4"); // And finally, call the API NotificationManager.Current.Push(priority, color, title, message, action, icon); }
/// <summary> /// Creates the buttons of the given Bridges. /// </summary> /// <param name="bridges">An array of the available Bridges. </param> private void ShowAvailableBridges(Q42.HueApi.Models.Bridge.LocatedBridge[] bridges) { int currentRow = 0; foreach (Q42.HueApi.Models.Bridge.LocatedBridge bridge in bridges) { Grid buttonGrid = new Grid() { HorizontalAlignment = HorizontalAlignment.Left }; buttonGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(GridLength.Auto.Value, GridLength.Auto.GridUnitType) }); buttonGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(GridLength.Auto.Value, GridLength.Auto.GridUnitType) }); buttonGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); FontIcon fontIcon = new FontIcon() { FontFamily = new FontFamily("Segoe MDL2 Assets"), Glyph = "\xF158" }; Grid.SetColumn(fontIcon, 0); buttonGrid.Children.Add(fontIcon); TextBlock ipTextBlock = new TextBlock() { Margin = new Thickness(5, 0, -5, 0), Text = bridge.IpAddress, Style = (Style)Application.Current.Resources["BigInformation"] }; Grid.SetColumn(ipTextBlock, 1); buttonGrid.Children.Add(ipTextBlock); Button newButton = new Button() { Name = bridge.IpAddress + "BridgeButton", Tag = bridge.IpAddress, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, HorizontalContentAlignment = HorizontalAlignment.Left, Background = new SolidColorBrush(Color.FromArgb(0, 255, 255, 255)) }; AvailableBridgeButtonsGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(60, GridUnitType.Auto) }); Grid.SetRow(newButton, currentRow); AvailableBridgeButtonsGrid.Children.Add(newButton); newButton.Content = buttonGrid; newButton.Click += BridgeButton_Click; currentRow++; } }
protected override void OnApplyTemplate() { base.OnApplyTemplate(); Icon = GetTemplateChild("Icon") as FontIcon; Root = GetTemplateChild("RootGrid") as Grid; Icon.Glyph = string.IsNullOrWhiteSpace(IconSymbol) ? "\uE00B" : IconSymbol.First().ToString(); Bloom = GetTemplateChild("Bloom") as Ellipse; }
private void SetupToolStripMenuItem() { toolStripMenuItem1.Image = FontIcon.CreateGlyphIcon(FontIcon.Glyphs.Play).ToBitmap(); toolStripMenuItem1.Text = string.Format("{0} barcode scanning", "Start"); toolStripMenuItem2.Image = FontIcon.CreateGlyphIcon(FontIcon.Glyphs.Setting).ToBitmap(); toolStripMenuItem3.Image = FontIcon.CreateGlyphIcon(FontIcon.Glyphs.Info).ToBitmap(); toolStripMenuItem4.Image = FontIcon.CreateGlyphIcon(FontIcon.Glyphs.SignOut).ToBitmap(); }
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; } 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; 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 (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; } return(pathIcon); } return(null); }
public static string ToChar(this FontIcon icon) { var bytes = BitConverter.GetBytes((int)icon); bytes[2] = 0; var intCode = BitConverter.ToInt32(bytes, 0); return(char.ConvertFromUtf32(intCode)); }
public object Convert(object value, Type targetType, object parameter, string language) { var fontIcon = new FontIcon { Glyph = value?.ToString() ?? parameter?.ToString() ?? "" }; return(fontIcon); }
public ItemHambuguer(string glyph, string descricao) { Icone = new FontIcon() { Glyph = glyph }; Descricao = descricao; InitializeComponent(); }
protected override void OnApplyTemplate() { base.OnApplyTemplate(); _icon = base.GetTemplateChild("icon") as FontIcon; _text = base.GetTemplateChild("text") as TextBlock; UpdateControl(); }
void UpdateBottomBar() { _BottomBar.Children.Clear(); _BottomBar.ColumnDefinitions.Clear(); var items = ShellItemController?.GetItems(); if (items?.Count > 1) { for (int i = 0; i < items.Count; i++) { var section = items[i]; var btn = new AppBarButton() { Label = section.Title, Width = double.NaN, MinWidth = 68, MaxWidth = 200 }; switch (section.Icon) { case FileImageSource fileImageSource: btn.Icon = new BitmapIcon() { UriSource = new Uri("ms-appx:///" + fileImageSource.File) }; break; case FontImageSource fontImageSource: var icon = new FontIcon() { Glyph = fontImageSource.Glyph, FontFamily = new FontFamily(fontImageSource.FontFamily), FontSize = fontImageSource.Size, }; if (!fontImageSource.Color.IsDefault) { icon.Foreground = fontImageSource.Color.ToBrush(); } btn.Icon = icon; break; } btn.Click += (s, e) => OnShellSectionClicked(section); _BottomBar.ColumnDefinitions.Add(new UwpColumnDefinition() { Width = new UwpGridLength(1, UwpGridUnitType.Star) }); SetColumn(btn, i); _BottomBar.Children.Add(btn); } } }
private FontIcon Get(string glyph) { var icon = new FontIcon { FontFamily = _fontFamily, Glyph = glyph, }; return(icon); }
internal static AppBarButton BuildAppBarButton(string label, string codeString) { int code = int.Parse(codeString, NumberStyles.HexNumber); var icon = new FontIcon() { FontFamily = new FontFamily("Segoe MDL2 Assets"), Glyph = char.ConvertFromUtf32(code) }; return(BuildAppBarButton(label, icon)); }
private async void FontIcon_PointerPressed(object sender, PointerRoutedEventArgs e) { FontIcon FI = sender as FontIcon; SingleMusicControl.SelectedItem = ((FontIcon)sender).DataContext; SearchSingleMusic SSM = SingleMusicList[SingleMusicControl.SelectedIndex]; if (((SolidColorBrush)FI.Foreground).Color == Colors.White) { string MusicURL = (await NetEaseMusic.GetSongsUrlAsync(SingleMusicList[SingleMusicControl.SelectedIndex].SongID)).Data[0].Url; if (MusicURL == null) { ContentDialog dialog = new ContentDialog { Title = "抱歉", Content = "当前歌曲暂时无法播放", CloseButtonText = "确定", Background = Application.Current.Resources["DialogAcrylicBrush"] as Brush }; await dialog.ShowAsync(); return; } FI.Glyph = "\uEB52"; FI.Foreground = new SolidColorBrush(Colors.Red); MusicList.ThisPage.FavouriteMusicCollection.Add(new PlayList(SSM.MusicName, SSM.Artist, SSM.Album, SSM.Duration, SSM.ImageUrl, SSM.SongID[0], SSM.MVid)); MediaPlaybackItem Item = new MediaPlaybackItem(MediaSource.CreateFromUri(new Uri(MusicURL))); MediaItemDisplayProperties Props = Item.GetDisplayProperties(); Props.Type = Windows.Media.MediaPlaybackType.Music; Props.MusicProperties.Title = SSM.MusicName; Props.MusicProperties.Artist = SSM.Artist; Item.ApplyDisplayProperties(Props); MediaPlayList.FavouriteSongList.Items.Add(Item); await SQLite.GetInstance().SetMusicDataAsync(SSM.MusicName, SSM.Artist, SSM.Album, SSM.Duration, SSM.ImageUrl, SSM.SongID[0], SSM.MVid); } else { FI.Glyph = "\uEB51"; FI.Foreground = new SolidColorBrush(Colors.White); for (int i = 0; i < MusicList.ThisPage.FavouriteMusicCollection.Count; i++) { if (MusicList.ThisPage.FavouriteMusicCollection[i].SongID == SSM.SongID[0]) { await SQLite.GetInstance().DeleteMusicAsync(MusicList.ThisPage.FavouriteMusicCollection[i]); MusicList.ThisPage.FavouriteMusicCollection.RemoveAt(i); MediaPlayList.FavouriteSongList.Items.RemoveAt(i); break; } } } }
public NativePageInfo(string name, string uri, Type type, string fontIconGlyph) { Name = name; Uri = uri; Type = type; Icon = new FontIcon { FontFamily = new FontFamily("Segoe MDL2 Assets"), Glyph = fontIconGlyph }; }
/// <inheritdoc /> protected override void OnApplyTemplate() { _canvasTextBoxTools = (StackPanel)GetTemplateChild(CanvasTextBoxToolsName); this._canvasTextBoxColorPicker = (Windows.UI.Xaml.Controls.ColorPicker)GetTemplateChild(CanvasTextBoxColorPickerName); _canvasTextBoxFontSizeTextBox = (TextBox)GetTemplateChild(CanvasTextBoxFontSizeTextBoxName); _canvasTextBoxItalicButton = (ToggleButton)GetTemplateChild(CanvasTextBoxItalicButtonName); _canvasTextBoxBoldButton = (ToggleButton)GetTemplateChild(CanvasTextBoxBoldButtonName); _drawingSurfaceRenderer = (InfiniteCanvasVirtualDrawingSurface)GetTemplateChild(DrawingSurfaceRendererName); _mainContainer = (Canvas)GetTemplateChild(MainContainerName); _infiniteCanvasScrollViewer = (ScrollViewer)GetTemplateChild(InfiniteCanvasScrollViewerName); _eraseAllButton = (Button)GetTemplateChild(EraseAllButtonName); _canvasTextBox = (InfiniteCanvasTextBox)GetTemplateChild(CanvasTextBoxName); _enableTextButton = (InkToolbarCustomToolButton)GetTemplateChild(EnableTextButtonName); _enableTouchInkingButton = (InkToolbarCustomToggleButton)GetTemplateChild(EnableTouchInkingButtonName); _inkCanvasToolBar = (InkToolbar)GetTemplateChild(InkCanvasToolBarName); _canvasToolbarContainer = (StackPanel)GetTemplateChild(CanvasToolbarContainerName); _inkCanvas = (InkCanvas)GetTemplateChild(DrawingInkCanvasName); _undoButton = (Button)GetTemplateChild(UndoButtonName); _redoButton = (Button)GetTemplateChild(RedoButtonName); _fontColorIcon = (FontIcon)GetTemplateChild(FontColorIconName); UnRegisterEvents(); RegisterEvents(); ConfigureControls(); if (double.IsNaN(_infiniteCanvasScrollViewer.Width)) { if (ControlHelpers.IsXamlRootAvailable && _infiniteCanvasScrollViewer.XamlRoot != null) { _infiniteCanvasScrollViewer.Width = _infiniteCanvasScrollViewer.XamlRoot.Size.Width; } else { _infiniteCanvasScrollViewer.Width = Window.Current.Bounds.Width; } } if (double.IsNaN(_infiniteCanvasScrollViewer.Height)) { if (ControlHelpers.IsXamlRootAvailable && _infiniteCanvasScrollViewer.XamlRoot != null) { _infiniteCanvasScrollViewer.Height = _infiniteCanvasScrollViewer.XamlRoot.Size.Height; } else { _infiniteCanvasScrollViewer.Height = Window.Current.Bounds.Height; } } base.OnApplyTemplate(); }
public void FontIconSourceTest() { FontIconSource iconSource = null; RunOnUIThread.Execute(() => { iconSource = new FontIconSource(); // IconSource.Foreground should be null to allow foreground inheritance from // the parent to work. Verify.AreEqual(iconSource.Foreground, null); Log.Comment("Validate the defaults match FontIcon."); var icon = new FontIcon(); Verify.AreEqual(icon.Glyph, iconSource.Glyph); Verify.AreEqual(icon.FontSize, iconSource.FontSize); Verify.AreEqual(icon.FontStyle, iconSource.FontStyle); Verify.AreEqual(icon.FontWeight.Weight, iconSource.FontWeight.Weight); Verify.AreEqual(icon.FontFamily.Source, iconSource.FontFamily.Source); Verify.AreEqual(icon.IsTextScaleFactorEnabled, iconSource.IsTextScaleFactorEnabled); Verify.AreEqual(icon.MirroredWhenRightToLeft, iconSource.MirroredWhenRightToLeft); Log.Comment("Validate that you can change the properties."); iconSource.Foreground = new SolidColorBrush(Windows.UI.Colors.Red); iconSource.Glyph = ""; iconSource.FontSize = 25; iconSource.FontStyle = FontStyle.Oblique; iconSource.FontWeight = new FontWeight() { Weight = 250 }; iconSource.FontFamily = new FontFamily("Segoe UI Symbol"); iconSource.IsTextScaleFactorEnabled = true; iconSource.MirroredWhenRightToLeft = true; }); IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { Verify.IsTrue(iconSource.Foreground is SolidColorBrush); Verify.AreEqual(Windows.UI.Colors.Red, (iconSource.Foreground as SolidColorBrush).Color); Verify.AreEqual("", iconSource.Glyph); Verify.AreEqual(25, iconSource.FontSize); Verify.AreEqual(FontStyle.Oblique, iconSource.FontStyle); Verify.AreEqual(250, iconSource.FontWeight.Weight); Verify.AreEqual("Segoe UI Symbol", iconSource.FontFamily.Source); Verify.AreEqual(true, iconSource.IsTextScaleFactorEnabled); Verify.AreEqual(true, iconSource.MirroredWhenRightToLeft); }); }
private async Task UpdateTileAsync() { // create UI var grid = new Grid { VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch, HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch, Background=new SolidColorBrush(Colors.Red), }; var star = new FontIcon { Glyph = "", FontSize = 50 }; grid.Children.Add(star); var number = new TextBlock { Text = 12.ToString(), FontSize = 25, Foreground = new SolidColorBrush(Colors.White) }; grid.Children.Add(number); // create bitmap var bitmap = new RenderTargetBitmap(); await bitmap.RenderAsync(grid, 150, 150); // create destination file var folder = ApplicationData.Current.LocalFolder; var file = await folder.CreateFileAsync("tile.png", CreationCollisionOption.ReplaceExisting); // write bitmap to file using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite)) { var pixels = await bitmap.GetPixelsAsync(); // using System.Runtime.InteropServices.WindowsRuntime; var bytes = pixels.ToArray(); var encoder = await BitmapEncoder .CreateAsync(BitmapEncoder.PngEncoderId, stream); var format = BitmapPixelFormat.Bgra8; var alpha = BitmapAlphaMode.Ignore; var width = (uint)bitmap.PixelWidth; var height = (uint)bitmap.PixelHeight; var dpi = DisplayInformation.GetForCurrentView().LogicalDpi; encoder.SetPixelData(format, alpha, width, height, dpi, dpi, bytes); await encoder.FlushAsync(); stream.Seek(0); } await FileIO.WriteBytesAsync(file, null); // replace existing tile var type = TileTemplateType.TileSquare150x150Image; var xml = TileUpdateManager.GetTemplateContent(type); // no text on tile var elements = xml.GetElementsByTagName("binding"); (elements[0] as XmlElement).SetAttribute("branding", "none"); // image on tile elements = xml.GetElementsByTagName("image"); (elements[0] as XmlElement).SetAttribute("src", file.Path); // update tile var notification = new TileNotification(xml); var updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Clear(); updater.Update(notification); // prepare notification toast var toastTemplate = ToastTemplateType.ToastText01; xml = ToastNotificationManager.GetTemplateContent(toastTemplate); var text = xml.CreateTextNode(string.Format("Tile image updated to {0}", number)); elements = xml.GetElementsByTagName("text"); elements[0].AppendChild(text); // send toast var toast = new ToastNotification(xml); var notifier = ToastNotificationManager.CreateToastNotifier(); notifier.Show(toast); Debug.WriteLine("Background task toast shown: " + number.ToString()); }
private void Parent_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { if (SelectedTool == InkingToolMode.Annotate) { Point position = e.GetPosition(null); // Find if we're intersecting with the toolbar, because we don't want annotation screens there. IEnumerable<UIElement> intersectedElements = VisualTreeHelper.FindElementsInHostCoordinates(position, _inkToolbar); // Check what elements of the sender we're on top of. If there's a button, we'll intersect with our toggle button collection // to confirm whether we'd like to simply 'hittest' that button. IEnumerable<UIElement> allIntersectedElements = VisualTreeHelper.FindElementsInHostCoordinates(position, (UIElement)sender); // Not intersected with the toolbar and no togglebuttons (of ours) in the way indicating there's another annotation, go ahead // and create the XAML. if (intersectedElements.Count() == 0 && (AnnotationTogglers.Intersect(allIntersectedElements.OfType<ButtonBase>())).Count() == 0) { var panel = new Grid { Width = 300, Height = 200 }; StackPanel collapsingPanel = new StackPanel { Orientation = Orientation.Horizontal }; var toggleButtonText = new TextBlock { DataContext = this, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; var toggleButtonId = "tb" + Guid.NewGuid().ToString(); var toggleButtonContent = new Grid(); toggleButtonContent.Children.Add(toggleButtonText); toggleButtonContent.Children.Add(new FontIcon { FontFamily = new FontFamily("Segoe MDL2 Assets"), Glyph = "\uE70B" }); var toggleButton = new ToggleButton { Content = new Viewbox { Child = toggleButtonContent }, Name = toggleButtonId, RenderTransform = new TranslateTransform { X = -10 }, Width = 32, Height = 32, Template = null, VerticalAlignment = VerticalAlignment.Top }; toggleButton.AddHandler(ToggleButton.PointerPressedEvent, new PointerEventHandler(ToggleButton_PointerPressed), true); toggleButton.AddHandler(ToggleButton.PointerReleasedEvent, new PointerEventHandler(ToggleButton_PointerReleased), true); toggleButton.AddHandler(ToggleButton.PointerMovedEvent, new PointerEventHandler(ToggleButton_PointerMoved), true); toggleButton.PointerReleased += ToggleButton_PointerReleased; AnnotationTogglers.Add(toggleButton); toggleButtonText.SetBinding(TextBlock.TextProperty, new Binding { Path = new PropertyPath("AnnotationTogglers"), Converter = listIndexerConverter, ConverterParameter = toggleButtonId, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); collapsingPanel.Children.Add(toggleButton); var innerGrid = new Grid(); CommandBar richTextEditBar = new CommandBar(); var boldButton = new AppBarButton { Label = "Bold", Icon = new SymbolIcon(Symbol.Bold) }; // TODO: remove when destroyed boldButton.Click += BoldButton_Click; richTextEditBar.PrimaryCommands.Add(boldButton); var italicButton = new AppBarButton { Label = "Italic", Icon = new SymbolIcon(Symbol.Italic) }; // TODO: remove when destroyed italicButton.Click += ItalicButton_Click; richTextEditBar.PrimaryCommands.Add(italicButton); innerGrid.Children.Add(new RichEditBox { Header = richTextEditBar, Width = 200 }); var deleteIcon = new FontIcon { Name = "deleteIcon", FontFamily = new FontFamily("Segoe MDL2 Assets"), Glyph = "\uE74D", Margin = new Thickness(0, 0, 5, 5), HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom }; deleteIcon.Tapped += new Windows.UI.Xaml.Input.TappedEventHandler((o, a) => { DeleteAnnotation(panel); }); innerGrid.Children.Add(deleteIcon); innerGrid.SetBinding(Grid.VisibilityProperty, new Binding { ElementName = toggleButton.Name, Path = new PropertyPath("IsChecked"), Converter = booleanToVisibilityConverter }); collapsingPanel.Children.Add(innerGrid); panel.Children.Add(collapsingPanel); Canvas.SetLeft(panel, position.X); Canvas.SetTop(panel, position.Y); _annotationCanvas.Children.Add(panel); } } }
private void CreateSelectedElements() { _selectedBorderVisual = new Border(); _selectedPathVisual = new Polygon(); _selectedFontIconVisual = new FontIcon(); var focusRectMargin = new Thickness(FocusRectPadding); _selectedBorderVisual.IsHitTestVisible = false; _selectedBorderVisual.Opacity = 0; _selectedBorderVisual.BorderBrush = SelectedBrush; _selectedBorderVisual.BorderThickness = new Thickness(SelectedRectThickness); _selectedBorderVisual.Margin = focusRectMargin; _selectedPathVisual.IsHitTestVisible = false; _selectedPathVisual.Opacity = 0; _selectedPathVisual.HorizontalAlignment = HorizontalAlignment.Right; _selectedPathVisual.Fill = SelectedBrush; _selectedPathVisual.Points.Add(new Point(0, 0)); _selectedPathVisual.Points.Add(new Point(35, 0)); _selectedPathVisual.Points.Add(new Point(35, 35)); _selectedPathVisual.Margin = focusRectMargin; _selectedFontIconVisual.IsHitTestVisible = false; _selectedFontIconVisual.Opacity = 0; _selectedFontIconVisual.Margin = new Thickness(FocusRectPadding, FocusRectPadding + SelectedRectThickness, FocusRectPadding + SelectedRectThickness, FocusRectPadding); _selectedFontIconVisual.HorizontalAlignment = HorizontalAlignment.Right; _selectedFontIconVisual.VerticalAlignment = VerticalAlignment.Top; _selectedFontIconVisual.FontFamily = new FontFamily("Segoe MDL2 Assets"); _selectedFontIconVisual.FontSize = 16; _selectedFontIconVisual.Foreground = new SolidColorBrush(Colors.White); _selectedFontIconVisual.Glyph = "\uE73E"; _contentGrid.Children.Insert(0, _selectedFontIconVisual); _contentGrid.Children.Insert(0, _selectedBorderVisual); _contentGrid.Children.Insert(0, _selectedPathVisual); }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { // Find the stack panels that host our AppBarButtons within the AppBar leftPanel = rootPage.FindName("LeftPanel") as StackPanel; rightPanel = rootPage.FindName("RightPanel") as StackPanel; CopyButtons(leftPanel, leftItems); CopyButtons(rightPanel, rightItems); // Remove existing AppBarButtons leftPanel.Children.Clear(); rightPanel.Children.Clear(); // Create the AppBarToggle button for the 'Shuffle' command AppBarToggleButton shuffle = new AppBarToggleButton(); shuffle.Label = "Shuffle"; shuffle.Icon = new SymbolIcon(Symbol.Shuffle); rightPanel.Children.Add(shuffle); // Create the AppBarButton for the 'Sun' command AppBarButton sun = new AppBarButton(); sun.Label = "Sun"; // This button will use the FontIcon class for its icon which allows us to choose // any glyph from any FontFamily FontIcon sunIcon = new FontIcon(); sunIcon.FontFamily = new Windows.UI.Xaml.Media.FontFamily("Wingdings"); sunIcon.FontSize = 30.0; sunIcon.Glyph = "\u0052"; sun.Icon = sunIcon; rightPanel.Children.Add(sun); // Create the AppBarButton for the 'Triangle' command AppBarButton triangle = new AppBarButton(); triangle.Label = "Triangle"; // This button will use the PathIcon class for its icon which allows us to // use vector data to represent the icon PathIcon trianglePathIcon = new PathIcon(); PathGeometry g = new PathGeometry(); g.FillRule = FillRule.Nonzero; // Just create a simple triange shape PathFigure f = new PathFigure(); f.IsFilled = true; f.IsClosed = true; f.StartPoint = new Windows.Foundation.Point(20.0, 5.0); LineSegment s1 = new LineSegment(); s1.Point = new Windows.Foundation.Point(30.0, 30.0); LineSegment s2 = new LineSegment(); s2.Point = new Windows.Foundation.Point(10.0, 30.0); LineSegment s3 = new LineSegment(); s3.Point = new Windows.Foundation.Point(20.0, 5.0); f.Segments.Add(s1); f.Segments.Add(s2); f.Segments.Add(s3); g.Figures.Add(f); trianglePathIcon.Data = g; triangle.Icon = trianglePathIcon; rightPanel.Children.Add(triangle); // Create the AppBarButton for the 'Smiley' command AppBarButton smiley = new AppBarButton(); smiley.Label = "Smiley"; smiley.Icon = new BitmapIcon { UriSource = new Uri("ms-appx:/Assets/smiley.png") }; rightPanel.Children.Add(smiley); }