/// <summary> /// This event will be raised on click of discussion hyperlink /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void hlDiscussionSubject_Click(object sender, RoutedEventArgs e) { HyperlinkButton hlSubject = sender as HyperlinkButton; string subject = hlSubject.Content.ToString(); string disId = hlSubject.Tag.ToString(); //Retrieve discussionId and subject int discussionId = Convert.ToInt32(disId); Discussions objDiscussion = new Discussions(); objDiscussion.DiscussionId = discussionId; objDiscussion.Subject = subject; var discussion = App.Current as App; discussion.Discussion = objDiscussion; NavigationService.Navigate(new Uri("/Discussion.xaml", UriKind.Relative)); }
public override void PerformAction() { //get list of searchable websites from database List <SearchableWebsite> allSearchableWebsites = StoredProcedures.QueryAllSearchableWebsites(); //need to check if user provided a website to search bool isUserProvidedWebsiteSearch = false; //go through list of searchable websites. return true if user included the searchable website in search //this will also set the website if there is a match isUserProvidedWebsiteSearch = GetActionFromCommand(allSearchableWebsites); string searchParameters; string searchQuery; if (isUserProvidedWebsiteSearch) { //find what is wanted to be searched and concatenate with + for end of url searchParameters = GetSearchParameters(isUserProvidedWebsiteSearch); searchQuery = BuildSearchQuery(desiredSearchableWebsite, searchParameters); //launch browser. this will be done with the default browser LaunchSearch(searchQuery); } else { //sets desiredSearchEngine, which is the default selected in settings GetDefaultSearchEngine(); searchParameters = GetSearchParameters(isUserProvidedWebsiteSearch); searchQuery = BuildSearchQuery(desiredSearchEngine, searchParameters); //launch browser. this will be done with the default browser LaunchSearch(searchQuery); } // show a link to the search this.ClearArea(); var linkElement = new HyperlinkButton(); linkElement.Content = $"{searchParameters} on {(desiredSearchableWebsite != null ? desiredSearchableWebsite.Name : desiredSearchEngine?.Name)}"; linkElement.NavigateUri = new Uri(searchQuery); linkElement.FontSize = 24; RelativePanel.SetAlignHorizontalCenterWithPanel(linkElement, true); RelativePanel.SetAlignVerticalCenterWithPanel(linkElement, true); this.DynamicArea.Children.Add(linkElement); // announce to the user that we're searching for something TextToSpeechEngine.SpeakText(this.MediaElement, $"Sure, searching for {linkElement.Content}"); }
public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange rng) { var tableLink = grid[rng.Row, rng.Column] as TableLink; if (tableLink != null) { var btn = new HyperlinkButton(); btn.Tag = tableLink; btn.Content = tableLink.Href; btn.VerticalAlignment = VerticalAlignment.Center; btn.HorizontalAlignment = HorizontalAlignment.Left; btn.Click += btn_Click; bdr.Child = btn; } else { base.CreateCellContent(grid, bdr, rng); } }
private void btDelFavorite_Click(object sender, RoutedEventArgs e) { HyperlinkButton tmpButton = (HyperlinkButton)sender; FavoriteList FavoriteItem = (FavoriteList)tmpButton.DataContext; if (FavoriteItem != null) { DelFavorite(FavoriteItem.FriendTwitterID); ObservableCollection <FavoriteList> tmpList = (ObservableCollection <FavoriteList>)LayoutRoot.DataContext; foreach (FavoriteList item in tmpList) { if (item.FriendTwitterID == FavoriteItem.FriendTwitterID) { tmpList.Remove(FavoriteItem); break; } } } }
public void FirstStartPopup() { var link = new HyperlinkButton { Content = AppResources.VisitWebsite, NavigateUri = new Uri(AppResources.Website, UriKind.Absolute), }; CustomMessageBox messageBox = new CustomMessageBox() { Caption = AppResources.FirstStartCaption, Message = AppResources.FirstStartMessage, Content = link, IsRightButtonEnabled = false, LeftButtonContent = "ok", }; messageBox.Show(); }
private void ButtonEdit_Click(object sender, RoutedEventArgs e) { dynamic data = this.DataGrid.SelectedItem as dynamic; HyperlinkButton btn = sender as HyperlinkButton; if (data != null) { string op = btn.Name.Equals("hybtnEdit") ? "edt" : "mge"; //op = (data.PromotionType.Equals("限时抢购") ? "cd" : "sd") + op; op = (data.PromotionType.Equals(ResCountdownQuery.Msg_Countdown) ? "cd" : "sd") + op; string url = string.Format(ConstValue.MKT_CountdownMaintainUrlFormat, "?op=" + op + "&sysNo=" + data.SysNo); Window.Navigate(url, null, true); } else { //Window.Alert("请选择团购后操作。", MessageType.Error); Window.Alert(ResCountdownQuery.Msg_AfterSelcGroupBuy, MessageType.Error); } }
private async void ProvideDirectionsSuccessMessage(string destination) { // show a link to the search this.ClearArea(); var linkElement = new HyperlinkButton(); linkElement.Content = $"Directions to {destination.ToLower()}"; string directionsLink = await this.GetDirectionsLink(destination); if (directionsLink != null) { linkElement.NavigateUri = new Uri(directionsLink); linkElement.FontSize = 24; RelativePanel.SetAlignHorizontalCenterWithPanel(linkElement, true); RelativePanel.SetAlignVerticalCenterWithPanel(linkElement, true); this.DynamicArea.Children.Add(linkElement); TextToSpeechEngine.SpeakText(this.MediaElement, $"Alright, getting {linkElement.Content.ToString().ToLower()}"); } }
private void AddBookmark(Bookmark bookmark) { Grid gridBookmark = new Grid() { Margin = new Thickness(0, 0, 0, 0), HorizontalAlignment = HorizontalAlignment.Stretch }; gridBookmark.ColumnDefinitions.Add(new ColumnDefinition()); gridBookmark.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20) }); gridBookmark.Background = (countBookmark % 2 == 0) ? gridBackColor1 : null; SimpleLinkButton bookmarkNameLink = new SimpleLinkButton() { Text = bookmark.Name, Tag = bookmark.Extent, Margin = new Thickness(4, 4, 4, 4) }; bookmarkNameLink.MouseOverBackColor = new SolidColorBrush(Colors.Transparent); bookmarkNameLink.MouseOverTextColor = new SolidColorBrush(Colors.Brown); bookmarkNameLink.Click += new RoutedEventHandler(BookmarkNameLink_Click); gridBookmark.Children.Add(bookmarkNameLink); Grid.SetColumn(bookmarkNameLink, 0); HyperlinkButton deleteLinkButton = new HyperlinkButton() { Tag = bookmark, Height = 16, Width = 16, Margin = new Thickness(4, 4, 4, 4), HorizontalAlignment = HorizontalAlignment.Right }; deleteLinkButton.Background = new ImageBrush() { ImageSource = deleteButtonSource }; deleteLinkButton.Visibility = (bookmark.UserAdded) ? Visibility.Visible : Visibility.Collapsed; deleteLinkButton.Click += new RoutedEventHandler(DeleteLinkButton_Click); gridBookmark.Children.Add(deleteLinkButton); Grid.SetColumn(deleteLinkButton, 1); StackBookmarkList.Children.Add(gridBookmark); countBookmark++; }
private static Inline GenerateHyperLink(HtmlNode node) { Span s = new Span(); InlineUIContainer iui = new InlineUIContainer(); HyperlinkButton hb = new HyperlinkButton() { NavigateUri = new Uri(node.Attributes["href"].Value, UriKind.Absolute), Content = CleanText(node.InnerText) }; //if (node.ParentNode != null && (node.ParentNode.Name == "li" || node.ParentNode.Name == "LI")) // hb.Style = (Style)Application.Current.Resources["RTLinkLI"]; //else if ((node.NextSibling == null || string.IsNullOrWhiteSpace(node.NextSibling.InnerText)) && (node.PreviousSibling == null || string.IsNullOrWhiteSpace(node.PreviousSibling.InnerText))) // hb.Style = (Style)Application.Current.Resources["RTLinkOnly"]; //else // hb.Style = (Style)Application.Current.Resources["RTLink"]; iui.Child = hb; s.Inlines.Add(iui); return(s); }
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void hyperlinkBrandID_Click(object sender, RoutedEventArgs e) { CPApplication.Current.CurrentPage.Context.Window.Confirm("是否删除?", (obj, arg) => { if (arg.DialogResult == Newegg.Oversea.Silverlight.Controls.Components.DialogResultType.OK) { HyperlinkButton link = (HyperlinkButton)sender; int sysNo = (int)link.Tag; facade.DeleteImageSize(sysNo, (objs, args) => { if (args.FaultsHandle()) { return; } CPApplication.Current.CurrentPage.Context.Window.Alert("删除成功!"); this.ImageSizeResult.Bind(); }); } }); }
HyperlinkButton addButton(Type entryObjectType, EntryObjectDTO existingObject) { HyperlinkButton link = new HyperlinkButton(); link.Style = (Style)Application.Current.Resources["EmptyButtonStyle"]; HubTile content = new HubTile(); content.Tag = link.Tag = existingObject; link.Content = content; if (prepareButton(link, entryObjectType)) { TranslateTransform transform = new TranslateTransform(); content.RenderTransform = transform; pnlMain.Children.Add(link); content.Tap += content_Tap; return(link); } return(null); }
/// <summary> /// Навигация в соответствии с нажатой кнопкой обратного пути /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PathElement_Click(object sender, RoutedEventArgs e) { HyperlinkButton button = sender as HyperlinkButton; if ((int)button.CommandParameter == 2) { this._month = (int)button.Tag; } else if ((int)button.CommandParameter == 1) { this._year = (int)button.Tag; this._month = 0; } else { this._year = 0; this._month = 0; } this.UpdateChoiceFramePage(); }
void UpdateLinkStates() { var activeWorkspaceName = _shell.ActiveItem.Name; foreach (UIElement child in LinksStackPanel.Children) { HyperlinkButton hb = child as HyperlinkButton; if (hb != null) { if (hb.Tag as string == activeWorkspaceName) { VisualStateManager.GoToState(hb, "ActiveLink", true); } else { VisualStateManager.GoToState(hb, "InactiveLink", true); } } } }
private void btUnFavorite_Click(object sender, RoutedEventArgs e) { HyperlinkButton tmpButton = (HyperlinkButton)sender; FriendTimelineList FriendTimelineItem = (FriendTimelineList)tmpButton.DataContext; if (FriendTimelineItem != null) { FriendTimelineItem.IsFavorited = false; foreach (FavoriteList item in Globals.FavoriteCollection) { if (item.FriendTwitterID == FriendTimelineItem.FriendTwitterID) { Globals.FavoriteCollection.Remove(item); DelFavorite(FriendTimelineItem.FriendTwitterID); break; } } } }
private void UpdateSelectedLinks(Uri uri) { for (int i = 0; i < CategoriesItemsControl.Items.Count; i++) { var child = VisualTreeHelper.GetChild(this.CategoriesItemsControl.ItemContainerGenerator.ContainerFromIndex(i), 0); HyperlinkButton hb = child as HyperlinkButton; if (hb != null && hb.NavigateUri != null) { var compareTo = uri.ToString(); if (hb.NavigateUri.ToString().Equals(compareTo)) { VisualStateManager.GoToState(hb, "ActiveLink", true); } else { VisualStateManager.GoToState(hb, "InactiveLink", true); } } } }
protected override void OnApplyTemplate() { Window.Current.SizeChanged += Current_SizeChanged; _alternateCloseButton = GetTemplateChild <Button>("AlternateCloseButton"); _actionButton = GetTemplateChild <Button>("ActionButton"); _title = GetTemplateChild <TextBlock>("Title"); _message = GetTemplateChild <TextBlock>("Message"); _hyperlinkButton = GetTemplateChild <HyperlinkButton>("HyperlinkButton"); _standardIcon = GetTemplateChild <IconSourceElement>("StandardIcon"); _userIcon = GetTemplateChild <IconSourceElement>("UserIcon"); _contentRootGrid = GetTemplateChild <Grid>("ContentRootGrid"); UpdateButtonsState(); UpdateSeverityState(); OnIsOpenChanged(); UpdateMargins(); _alternateCloseButton.Click += new RoutedEventHandler(OnCloseButtonClick); _actionButton.Click += (s, e) => ActionButtonClick?.Invoke(s, e); }
private void PlanManagerContentFrame_Navigated(object sender, NavigationEventArgs e) { foreach (UIElement child in PlanManagerMenu.Children) { HyperlinkButton hb = child as HyperlinkButton; if (hb != null && hb.NavigateUri != null) { if (PlanManagerContentFrame.UriMapper.MapUri(e.Uri).ToString().Equals(PlanManagerContentFrame.UriMapper.MapUri(hb.NavigateUri).ToString())) { VisualStateManager.GoToState(hb, "ActiveLink", true); PlanManagerViewModel planManagerViewModel = this.DataContext as PlanManagerViewModel; planManagerViewModel.CurrentPageName = hb.Content.ToString(); } else { VisualStateManager.GoToState(hb, "InactiveLink", true); } } } }
/// <summary> /// Handles the project Hyperlink click event. /// </summary> /// <param name="sender">The <see cref="HyperlinkButton"/>.</param> /// <param name="e">The <see cref="RoutedEventArgs"/>.</param> private void ProjectLink_Click(object sender, RoutedEventArgs e) { HyperlinkButton linkButton = sender as HyperlinkButton; if (linkButton != null && linkButton.Content != null) { Uri source = Application.Current.Host.Source; StringBuilder uriBuilder = new StringBuilder(); string hostname = source.AbsoluteUri.Substring(0, source.AbsoluteUri.IndexOf("ClientBin", StringComparison.OrdinalIgnoreCase)); uriBuilder.Append(hostname); uriBuilder.AppendFormat(CultureInfo.InvariantCulture, "Default.aspx?projectId={0}", linkButton.Content); Uri navigateUri = new Uri(uriBuilder.ToString()); HtmlPage.Window.Navigate(navigateUri); } }
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void hlAdvertisingDelete_Click(object sender, RoutedEventArgs e) { CPApplication.Current.CurrentPage.Context.Window.Confirm("是否删除?", (obj, arg) => { if (arg.DialogResult == Newegg.Oversea.Silverlight.Controls.Components.DialogResultType.OK) { HyperlinkButton link = (HyperlinkButton)sender; int sysNo = (int)(link.Tag ?? 0); new AdvertisingFacade(this).Delete(sysNo, (objs, args) => { if (args.FaultsHandle()) { return; } Window.MessageBox.Show("删除成功!", Newegg.Oversea.Silverlight.Controls.Components.MessageBoxType.Success); this.dgAdvertisingQueryResult.Bind(); }); } }); }
private void ButtonVoid_Click(object sender, RoutedEventArgs e) { this.Window.Confirm(ResBanner.Confirm_Void, (cs, cargs) => { if (cargs.DialogResult == DialogResultType.OK) { HyperlinkButton btnEdit = sender as HyperlinkButton; var row = btnEdit.DataContext as dynamic; BannerFacade facade = new BannerFacade(this); facade.Deactive((int)row.SysNo, (s, args) => { if (args.FaultsHandle()) { return; } this.Window.Alert(ResBanner.Info_VoidSuccessfully); }); } }); }
internal override FrameworkElement GenerateElement(object childData) { HyperlinkButton hyperlink = new HyperlinkButton(); hyperlink.DataContext = childData; Binding contentBinding = ContentBinding as Binding; Binding b = Binding as Binding; if (b != null) { if (b.Mode == BindingMode.OneWay) { if (!b.INTERNAL_WasModeSetByUserRatherThanDefaultValue()) { b.Mode = BindingMode.TwoWay; } } hyperlink.SetBinding(HyperlinkButton.NavigateUriProperty, b); } if (contentBinding != null) { if (contentBinding.Mode == BindingMode.OneWay) { if (!contentBinding.INTERNAL_WasModeSetByUserRatherThanDefaultValue()) { contentBinding.Mode = BindingMode.TwoWay; } } hyperlink.SetBinding(HyperlinkButton.ContentProperty, contentBinding); } else if (b != null) { hyperlink.SetBinding(HyperlinkButton.ContentProperty, b); } else if (childData is string) { hyperlink.NavigateUri = new Uri((string)childData); hyperlink.Content = (string)childData; } return(hyperlink); }
internal override FrameworkElement GenerateElement(object childData) { HyperlinkButton hyperlink = new HyperlinkButton(); hyperlink.DataContext = childData; Binding contentBinding = this.INTERNAL_GetBinding(DataGridHyperlinkColumn.ContentBindingProperty); //we get the Binding in the ContentBinding property set by the user. Binding b = this.INTERNAL_GetBinding(DataGridBoundColumn.BindingProperty); //we get the Binding in the Binding property set by the user. if (b != null) { if (b.Mode == BindingMode.OneWay) { if (!b.INTERNAL_WasModeSetByUserRatherThanDefaultValue()) { b.Mode = BindingMode.TwoWay; } } hyperlink.SetBinding(HyperlinkButton.NavigateUriProperty, b); } if (contentBinding != null) { if (contentBinding.Mode == BindingMode.OneWay) { if (!contentBinding.INTERNAL_WasModeSetByUserRatherThanDefaultValue()) { contentBinding.Mode = BindingMode.TwoWay; } } hyperlink.SetBinding(HyperlinkButton.ContentProperty, contentBinding); } else if (b != null) { hyperlink.SetBinding(HyperlinkButton.ContentProperty, b); } else if (childData is string) { hyperlink.NavigateUri = new Uri((string)childData); hyperlink.Content = (string)childData; } return(hyperlink); }
/// <summary> /// Обновить хлебные крошки и заголовок при совершении навигации страницы выбора /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ChoiceFrame_Navigated(object sender, NavigationEventArgs e) { //Параметр команды хранит глубину кнопки, тэг - числовое предстаавление this.PathPanel.Children.Clear(); HyperlinkButton link = new HyperlinkButton() { Content = "Дневник", CommandParameter = 0 }; link.Click += PathElement_Click; this.PathPanel.Children.Add(link); if (this._year == 0) { this.pageTitle.Text = "Дневник"; } else { this.PathPanel.Children.Add(new TextBlock()); link = new HyperlinkButton() { Content = this._year, Tag = this._year, CommandParameter = 1 }; link.Click += PathElement_Click; this.PathPanel.Children.Add(link); if (this._month == 0) { this.pageTitle.Text = this._year.ToString(); } else { this.PathPanel.Children.Add(new TextBlock()); link = new HyperlinkButton() { Content = DateHelper.GetMonthName(this._month, true, false), Tag = this._month, CommandParameter = 2 }; link.Click += PathElement_Click; this.PathPanel.Children.Add(link); this.pageTitle.Text = DateHelper.GetMonthName(this._month, true, false) + " " + this._year; } } }
private void btnEdit_Click(object sender, RoutedEventArgs e) { HyperlinkButton btn = sender as HyperlinkButton; dynamic d = btn.DataContext as dynamic; ProductLineVM vm = DynamicConverter <ProductLineVM> .ConvertToVM(d); vm.BrandEnabled = false; vm.CategoryEnabled = false; UCProductLineDetail uc = new UCProductLineDetail(vm); IDialog dialog = CPApplication.Current.CurrentPage.Context.Window.ShowDialog("修改产品线信息", uc, (obj, args) => { if (args.DialogResult == DialogResultType.OK) { this.BindData(this.dataProductLineList.QueryCriteria); } }); uc.Dialog = dialog; }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); Globals.DisplayTasks(ListPanel); foreach (var c in ListPanel.Children) { if (c.GetType() == typeof(HyperlinkButton)) { HyperlinkButton link = c as HyperlinkButton; link.Click += Link_Click; } if (c.GetType() == typeof(CheckBox)) { CheckBox check = c as CheckBox; check.Unchecked += Check_Unchecked; check.Checked += Check_Checked; } } }
/// <summary> /// 删除ISO /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void Destroy_Click(object sender, RoutedEventArgs e) { HyperlinkButton btnOper = (HyperlinkButton)sender; string isoid = btnOper.Tag.ToString(); int nRet = await MessageAdapter.ShowYesNoAsync("该操作将删除该ISO镜像\r\n是否进行操作?"); if (nRet == 1) { HttpAdapter adapter = new HttpAdapter(); bool ret = await adapter.IsoDestroy(isoid); if (ret) { await MessageAdapter.ShowMsgDlgAsync("删除成功"); } else { await MessageAdapter.ShowMsgDlgAsync("删除失败"); } } }
private void HyperlinkButtonAction_Click(object sender, RoutedEventArgs e) { HyperlinkButton btn = sender as HyperlinkButton; CommandParameter = btn.CommandParameter.ToString(); isOpenClose = btn.Tag.ToString(); if (isOpenClose == "open") { Menu_CloseIndex.IsEnabled = true; Menu_OpenIndex.IsEnabled = false; Menu_BrowseData.IsEnabled = true; } else { Menu_CloseIndex.IsEnabled = false; Menu_OpenIndex.IsEnabled = true; Menu_BrowseData.IsEnabled = false; } ActionMenuFlyout.ShowAt(sender as HyperlinkButton); return; }
private void ButtonBrandDelete_Click(object sender, RoutedEventArgs e) { HyperlinkButton btnEdit = sender as HyperlinkButton; var tempVM = btnEdit.DataContext as FloorSectionBrandVM; CurrentWindow.Confirm(ResFloorMaintain.Info_ConfirmDelete, (diaObj, diaArgs) => { if (diaArgs.DialogResult == DialogResultType.OK) { ServiceFacade.DeleteFloorSectionItem(tempVM.SysNo.Value, (s, objArgs) => { if (objArgs.FaultsHandle()) { return; } BrandListVM.Remove(tempVM); BrandResult.ItemsSource = BrandListVM; }); } }); }
private void RecentFiles_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { lstRecentFiles.Children.Clear(); stkRecentFiles.Visibility = Visibility.Collapsed; if (viewModel.RecentFiles.Any()) { stkRecentFiles.Visibility = Visibility.Visible; } foreach (var file in viewModel.RecentFiles) { var link = new HyperlinkButton() { Content = file.Name, Command = viewModel.OpenRecentFileCmd, CommandParameter = file.Path }; lstRecentFiles.Children.Add(link); } }
private async void HyperlinkButton_Click(object sender, RoutedEventArgs e) { HyperlinkButton btn = sender as HyperlinkButton; string tag = btn.Tag as string; switch (tag) { case "b": await Launcher.LaunchUriAsync(new Uri("ms-settings-bluetooth:")); break; case "w": await Launcher.LaunchUriAsync(new Uri("ms-settings-wifi:")); break; case "p": await Launcher.LaunchUriAsync(new Uri("ms-settings-power:")); break; case "a": await Launcher.LaunchUriAsync(new Uri("ms-settings-airplanemode:")); break; case "l": await Launcher.LaunchUriAsync(new Uri("ms-settings-lock:")); break; case "m": StorageFolder music = KnownFolders.MusicLibrary; await Launcher.LaunchFolderAsync(music); break; } }
// ** ctor public ExcelCalcEngine(C1FlexGridBook grid) { // save reference to parent grid _flex = grid; // parse multi-cell range references ($A2:B$4) IdentifierChars = "$:"; // register Hyperlink function (returns a HyperlinkButton) CacheExpressions = false; RegisterFunction("hyperlink", 2, (parms) => { var h = new HyperlinkButton(); //h.NavigateUri = new Uri((string)parms[0]); h.Content = (string)parms[1]; h.BorderThickness = new Thickness(0); h.BorderBrush = null; h.VerticalAlignment = VerticalAlignment.Center; h.HorizontalAlignment = HorizontalAlignment.Left; h.Foreground = _brLinkForeground; //h.TargetName = "_blank"; return h; }); }
/// <inheritdoc /> protected virtual async void ShowIcon(Microsoft.Media.Advertising.Icon icon, StaticResource staticResource, CancellationTokenSource cts) { if (icon.Offset.HasValue) { try { #if SILVERLIGHT && !WINDOWS_PHONE || WINDOWS_PHONE7 await TaskEx.Delay((int)icon.Offset.Value.TotalMilliseconds, cts.Token); #else await Task.Delay((int)icon.Offset.Value.TotalMilliseconds, cts.Token); #endif } catch (OperationCanceledException) { /* swallow */ } } if (!cts.IsCancellationRequested) { var iconHost = new HyperlinkButton(); iconHost.NavigateUri = icon.ClickThrough; double topMargin = 0; double leftMargin = 0; if (icon.Width.HasValue) { iconHost.Width = icon.Width.Value; } if (icon.Height.HasValue) { iconHost.Height = icon.Height.Value; } switch (icon.XPosition) { case "left": iconHost.HorizontalAlignment = HorizontalAlignment.Left; break; case "right": iconHost.HorizontalAlignment = HorizontalAlignment.Right; break; default: iconHost.HorizontalAlignment = HorizontalAlignment.Left; int xPositionValue; if (int.TryParse(icon.XPosition, out xPositionValue)) { leftMargin = xPositionValue; } break; } switch (icon.YPosition) { case "top": iconHost.VerticalAlignment = VerticalAlignment.Top; break; case "bottom": iconHost.VerticalAlignment = VerticalAlignment.Bottom; break; default: iconHost.VerticalAlignment = VerticalAlignment.Top; int yPositionValue; if (int.TryParse(icon.YPosition, out yPositionValue)) { topMargin = yPositionValue; } break; } iconHost.Margin = new Thickness(leftMargin, topMargin, 0, 0); var iconElement = new Image(); iconElement.Stretch = Stretch.Fill; iconElement.Source = new BitmapImage(staticResource.Value); iconHost.Content = iconElement; //TODO: avoid visually overlaping icons iconHost.Tag = icon; iconElement.Tag = icon; iconHost.Click += iconHost_Click; iconElement.ImageOpened += iconElement_ImageOpened; AdContainer.Children.Add(iconHost); try { if (icon.Duration.HasValue) { #if SILVERLIGHT && !WINDOWS_PHONE || WINDOWS_PHONE7 await TaskEx.Delay((int)icon.Duration.Value.TotalMilliseconds, cts.Token); #else await Task.Delay((int)icon.Duration.Value.TotalMilliseconds, cts.Token); #endif } else { await cts.Token.AsTask(); } } catch (OperationCanceledException) { /* swallow */ } finally { AdContainer.Children.Remove(iconHost); iconHost.Click -= iconHost_Click; iconElement.ImageOpened -= iconElement_ImageOpened; } } }
public HyperlinkCommand(HyperlinkButton button, ICommand inner) { _Inner = inner; _Button = button; _Inner.CanExecuteChanged += _Inner_CanExecuteChanged; }