public static DialogResult ShowFlyoutMessage(WindowsUIView view, Flyout flyoutMessage, String caption, String description, params FlyoutCommand[] commands) { FlyoutAction messageAction = new FlyoutAction() { Caption = caption, Description = description }; flyoutMessage.Properties.AllowHtmlDraw = DefaultBoolean.True; flyoutMessage.Properties.AppearanceDescription.TextOptions.WordWrap = WordWrap.Wrap; flyoutMessage.Properties.AppearanceDescription.TextOptions.Trimming = Trimming.EllipsisWord; messageAction.Commands.Clear(); if (commands.Length == 0) { messageAction.Commands.Add(FlyoutCommand.OK); } else { foreach (FlyoutCommand command in commands) { messageAction.Commands.Add(command); } } flyoutMessage.Action = messageAction; return view.ShowFlyoutDialog(flyoutMessage); }
public async Task<Tuple<bool, bool>> GetUserConfirmationBeforeExportingBinderAsync(CancellationToken cancToken) { var result = new Tuple<bool, bool>(false, false); Flyout dialog = null; ConfirmationBeforeExportingBinder dialogContent = null; await RunInUiThreadAsync(delegate { dialog = new Flyout(); dialogContent = new ConfirmationBeforeExportingBinder(); dialog.Closed += OnDialog_Closed; dialog.Content = dialogContent; dialogContent.UserAnswered += OnYesNoDialogContent_UserAnswered; _isHasUserAnswered = false; dialog.ShowAt(Window.Current.Content as FrameworkElement); }).ConfigureAwait(false); while (!_isHasUserAnswered && !cancToken.IsCancellationRequested) { await Task.Delay(DELAY, cancToken).ConfigureAwait(false); } await RunInUiThreadAsync(delegate { dialog.Closed -= OnDialog_Closed; dialogContent.UserAnswered -= OnYesNoDialogContent_UserAnswered; dialog.Hide(); result = new Tuple<bool, bool>(dialogContent.YesNo, dialogContent.IsHasUserInteracted); }).ConfigureAwait(false); return result; }
public static Flyout DisplayFullSizeImage() { var flyout = new Flyout(); var image = new Image(); image.Source = new BitmapImage(new Uri("ms-appx:///Assets/120px-Human_Thumbnail.jpg")); flyout.Content = image; flyout.Placement = FlyoutPlacementMode.Full; return flyout; }
private void MicrophoneIsNotAvailableHandler(object sender, string errorMessage) { if (_microphoneIsNotAvailableFylout == null) { var contentGrid = GetMicrophoneIsNotAvailableFlyoutContent(errorMessage); _microphoneIsNotAvailableFylout = new Flyout {Content = contentGrid}; } _microphoneIsNotAvailableFylout.ShowAt(MuteButton); }
public void ShowInviteSentConfirmationFlyout() { Flyout flyout = new Flyout(); flyout.Content = new ContentPresenter { ContentTemplate = (DataTemplate)App.Current.Resources["InviteConfirmationTemplate"] }; flyout.Placement = FlyoutPlacementMode.Bottom; flyout.ShowAt(PlacementSource); }
private void CriaFlyOut (object sender, RoutedEventArgs e) { var flyout = new Flyout(); var grid = new Grid(); grid.Children.Add(new TextBlock() { Text = "Criado Programaticamente", Foreground = new SolidColorBrush (Colors.White), FontSize = 20 }); flyout.Content = grid; flyout.ShowAt(sender as FrameworkElement); }
private void loginBtn_Click(object sender, RoutedEventArgs e) { var user = userTxt.Text.ToString(); var password = passwordBox.Password.ToString(); if (user == "*****@*****.**" && password == "admin123") { this.Frame.Navigate(typeof(AdminView), e); } else if (user == "*****@*****.**" && password == "seller1123") { this.Frame.Navigate(typeof(SellerView), e); } else if (user == "*****@*****.**" && password == "seller2123") { this.Frame.Navigate(typeof(SellerView), e); } else { var flyout = new Flyout(); var grid = new Grid(); grid.Children.Add(new TextBlock { Text = "The e-mail and/or password entered \n is invalid. Please try again.", FontSize = 18}); grid.Width = 300; grid.Height = 60; flyout.Content = grid; flyout.ShowAt(sender as FrameworkElement); userTxt.BorderBrush = new SolidColorBrush(Colors.Red); passwordBox.BorderBrush = new SolidColorBrush(Colors.Red); userTxtBlock.Foreground = new SolidColorBrush(Colors.Red); passwordTxtBlock.Foreground = new SolidColorBrush(Colors.Red); } }
protected override void OnApplyTemplate() { base.OnApplyTemplate(); if (emotionData != null) { flyout = new Flyout(); //TextBlock text = new TextBlock(); //text.Text = $"anger: {emotionData.Scores.Anger}" + // $"\ncontempt: {emotionData.Scores.Contempt}" + // $"\ndisgust: {emotionData.Scores.Disgust}" + // $"\nfear: {emotionData.Scores.Fear}" + // $"\nhappiness: {emotionData.Scores.Happiness}" + // $"\nneutral: {emotionData.Scores.Neutral}" + // $"\nsadness: {emotionData.Scores.Sadness}" + // $"\nsurprise: {emotionData.Scores.Surprise}"; //text.TextWrapping = Windows.UI.Xaml.TextWrapping.Wrap; //flyout.Content = text; flyout.Content = GetScoresStackPanel(); Canvas.SetLeft(this, emotionData.FaceRectangle.Left); Canvas.SetTop(this, emotionData.FaceRectangle.Top); } }
public async Task<Tuple<BriefcaseVM.ImportBinderOperations, string>> GetUserChoiceBeforeImportingBinderAsync(string targetBinderName, CancellationToken cancToken) { var result = new Tuple<BriefcaseVM.ImportBinderOperations, string>(BriefcaseVM.ImportBinderOperations.Cancel, string.Empty); Flyout dialog = null; ChoiceBeforeImportingBinder dialogContent = null; await RunInUiThreadAsync(delegate { dialog = new Flyout(); dialogContent = new ChoiceBeforeImportingBinder(targetBinderName); dialog.Closed += OnDialog_Closed; dialog.Content = dialogContent; dialogContent.UserAnswered += OnThreeBtnDialogContent_UserAnswered; _isHasUserAnswered = false; dialog.ShowAt(Window.Current.Content as FrameworkElement); }).ConfigureAwait(false); while (!_isHasUserAnswered && !cancToken.IsCancellationRequested) { await Task.Delay(DELAY, cancToken).ConfigureAwait(false); } await RunInUiThreadAsync(delegate { dialog.Closed -= OnDialog_Closed; dialogContent.UserAnswered -= OnThreeBtnDialogContent_UserAnswered; dialog.Hide(); result = new Tuple<BriefcaseVM.ImportBinderOperations, string>(dialogContent.Operation, dialogContent.DBName); }).ConfigureAwait(false); return result; }
public async Task When_Too_Large_For_Any_Fallback() { var target = new TextBlock { Text = "Anchor", VerticalAlignment = VerticalAlignment.Bottom }; var stretchedTargetWrapper = new Border { MinHeight = 600, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Child = target }; var windowHeight = ApplicationView.GetForCurrentView().VisibleBounds.Height; var flyoutContent = new Ellipse { Width = 90, Height = windowHeight * 1.5, Fill = new SolidColorBrush(Colors.Tomato) }; var presenterStyle = new Style { TargetType = typeof(FlyoutPresenter), Setters = { new Setter(FrameworkElement.MaxHeightProperty, windowHeight * 1.7) } }; var flyout = new Flyout { FlyoutPresenterStyle = presenterStyle, Content = flyoutContent, Placement = FlyoutPlacementMode.Top }; TestServices.WindowHelper.WindowContent = stretchedTargetWrapper; await TestServices.WindowHelper.WaitForLoaded(target); try { FlyoutBase.SetAttachedFlyout(target, flyout); FlyoutBase.ShowAttachedFlyout(target); await TestServices.WindowHelper.WaitForLoaded(flyoutContent); var contentScreenBounds = flyoutContent.GetOnScreenBounds(); var contentCenter = contentScreenBounds.GetCenter(); var targetScreenBounds = target.GetOnScreenBounds(); var targetCenter = targetScreenBounds.GetCenter(); var presenter = await TestServices.WindowHelper.WaitForNonNull(() => flyoutContent.FindFirstParent <FlyoutPresenter>()); VerifyRelativeContentPosition(HorizontalPosition.Center, VerticalPosition.BeyondTop, presenter, // The content itself is in a ScrollViewer and its bounds will exceed the visible area 0, target ); } finally { flyout.Hide(); } }
/// <summary> /// Opens the specified attachment. /// </summary> private async void OpenButton_Click(object sender, RoutedEventArgs e) { var info = (AttachmentInfoItem)((FrameworkElement)sender).DataContext; string message = null; try { using (var data = await info.GetDataAsync()) { if (data != Stream.Null) { var source = new BitmapImage(); await source.SetSourceAsync(data.AsRandomAccessStream()); var flyout = new Flyout(); flyout.Content = new Image() { Source = source }; flyout.ShowAt(AttachmentsButton); } } } catch (Exception ex) { message = ex.Message; } }
public void ShowDotoFlyout(FrameworkElement frameworkElement, FlyoutPlacementMode flyoutPlacement, string contentTemplate = "", UserControl flyoutControl = null) { Flyout flyout = new Flyout(); if (flyoutControl != null) { flyout.Content = flyoutControl; } else { flyout.Content = new ContentPresenter { Content = viewModel, ContentTemplate = (DataTemplate)App.Current.Resources[contentTemplate] }; } flyout.Placement = flyoutPlacement; if (frameworkElement is Button) { ((Button)frameworkElement).Flyout = flyout; } flyout.ShowAt(frameworkElement); }
public Form1() { InitializeComponent(); if(Components == null) Components = new System.ComponentModel.Container(); this.SuspendLayout(); try { fDocumentManager = new DocumentManager(Components); ((System.ComponentModel.ISupportInitialize)(DocumentManager)).BeginInit(); try { DocumentManager.ContainerControl = this; fMainView = new WindowsUIView(Components); ((System.ComponentModel.ISupportInitialize)(MainView)).BeginInit(); try { MainView.SplashScreenProperties.ShowCaption = true; MainView.SplashScreenProperties.ShowLoadingDescription = true; MainView.SplashScreenProperties.ShowImage = true; MainView.TileContainerProperties.HeaderOffset = -10; MainView.TileContainerProperties.Margin = new Padding(25); MainView.TileContainerProperties.ItemSize = 160; MainView.TileContainerProperties.ItemPadding = new Padding(8); MainView.PageProperties.HeaderOffset = -10; MainView.PageProperties.Margin = new System.Windows.Forms.Padding(0, -15, 0, 0); MainView.AddTileWhenCreatingDocument = DevExpress.Utils.DefaultBoolean.False; MainView.AllowCaptionDragMove = DevExpress.Utils.DefaultBoolean.True; DocumentManager.ViewCollection.Add(MainView); DocumentManager.View = MainView; fMainMenu = new TileContainer(Components); ((System.ComponentModel.ISupportInitialize)(MainMenu)).BeginInit(); try { MainMenu.Properties.AllowDrag = DevExpress.Utils.DefaultBoolean.True; MainMenu.Properties.AllowDragTilesBetweenGroups = DevExpress.Utils.DefaultBoolean.True; MainMenu.Properties.AllowHtmlDraw = DevExpress.Utils.DefaultBoolean.True; MainMenu.Properties.AllowGroupHighlighting = DevExpress.Utils.DefaultBoolean.False; MainMenu.Properties.AllowItemHover = DevExpress.Utils.DefaultBoolean.False; MainMenu.Properties.AllowSelectedItem = DevExpress.Utils.DefaultBoolean.False; MainMenu.Properties.ShowGroupText = DevExpress.Utils.DefaultBoolean.True; MainMenu.Properties.HorizontalContentAlignment = DevExpress.Utils.HorzAlignment.Near; MainMenu.Properties.VerticalContentAlignment = DevExpress.Utils.VertAlignment.Top; MainMenu.EndItemDragging += MainMenu_EndItemDragging; MainView.ContentContainers.Add(MainMenu); { Tile Tile = new Tile(); Tile.Tag = null; Tile.Padding = new Padding(5, 5, 5, 5); Tile.Properties.ItemSize = TileItemSize.Small; Tile.Properties.AllowCheck = DevExpress.Utils.DefaultBoolean.False; { TileItemElement Element = new TileItemElement(); Element.Text = @"Test"; Element.TextAlignment = TileItemContentAlignment.BottomCenter; Tile.Elements.Add(Element); } MainView.Tiles.Add(Tile); MainMenu.Items.Add(Tile); } } finally { ((System.ComponentModel.ISupportInitialize)(MainMenu)).EndInit(); } { Flyout Flyout = new Flyout(); FlyoutAction FlyoutAction = new FlyoutAction(); FlyoutAction.Caption = @"Enter New Group Name"; FlyoutAction.Commands.Add(FlyoutCommand.OK); FlyoutAction.Commands.Add(FlyoutCommand.Cancel); Flyout.Action = FlyoutAction; fQueryGroupNameFlyout = Flyout; MainView.ContentContainers.Add(Flyout); } MainView.ActivateContainer(MainMenu); } finally { ((System.ComponentModel.ISupportInitialize)(MainView)).EndInit(); } } finally { ((System.ComponentModel.ISupportInitialize)(DocumentManager)).EndInit(); } QueryGroupNameFlyout.Document = MainView.AddDocument(new TextEdit()) as Document; } finally { this.ResumeLayout(false); this.PerformLayout(); } }
private void Grid_RightTapped(object sender, RightTappedRoutedEventArgs e) { Flyout.ShowAttachedFlyout((Border)sender); }
private void FilterHiddenPostsListViewItem_Tapped(object sender, TappedRoutedEventArgs e) { Flyout.SetAttachedFlyout(FilterButton, this.Resources["FilterHiddenFlyout"] as Flyout); Flyout.ShowAttachedFlyout(FilterButton); }
public void OnLoad() { // create overlay and insert into HDT overlay AutoUpdate(); CreateDateFileEnviroment(); _overlay = new BgMatchOverlay(); _view = new View(); _tribes = new TribesOverlay(); _inGameDisconectorOverlay = new InGameDisconectorOverlay(); _console = new ConsoleOverlay(); _simpleOverlay = new SimpleOverlay(); BgMatchData._overlay = _overlay; BgMatchData._view = _view; BgMatchData._tribes = _tribes; BgMatchData._cheatButtonForNoobs = _inGameDisconectorOverlay; //BgMatchData._console = _console; BgMatchData._simpleOverlay = _simpleOverlay; // Triggered upon startup and when the user ticks the plugin on GameEvents.OnGameStart.Add(BgMatchData.GameStart); GameEvents.OnInMenu.Add(BgMatchData.InMenu); GameEvents.OnTurnStart.Add(BgMatchData.TurnStart); GameEvents.OnGameEnd.Add(BgMatchData.GameEnd); BgMatchData.OnLoad(_config); if (_config.showStatsOverlay) { MountOverlay(); } _overlayManager = new OverlayManager(_overlay, _config); _tribeOverlayManager = new TriverOverlayManager(_tribes, _config); BgMatchData._input = _overlayManager; BgMatchData._tribeInput = _tribeOverlayManager; Canvas.SetTop(_overlay, _config.posTop); Canvas.SetLeft(_overlay, _config.posLeft); Canvas.SetTop(_inGameDisconectorOverlay, 50); Canvas.SetLeft(_inGameDisconectorOverlay, 300); Canvas.SetTop(_tribes, _config.tribePosTop); Canvas.SetLeft(_tribes, _config.tribePosLeft); _settingsFlyout = new Flyout(); _settingsFlyout.Name = "BgSettingsFlyout"; _settingsFlyout.Position = Position.Left; Panel.SetZIndex(_settingsFlyout, 100); _settingsFlyout.Header = "BoonwinsBattlegroundTracker Settings"; _settingsControl = new SettingsControl(_config, MountOverlay, UnmountOverlay); _settingsFlyout.Content = _settingsControl; //_settingsFlyout.ClosingFinished += (sender, args) => //{ // config.save(); //}; Core.MainWindow.Flyouts.Items.Add(_settingsFlyout); }
private void FilterButton_Click(object sender, RoutedEventArgs e) { Flyout.SetAttachedFlyout(FilterButton, this.Resources["FilterMainFlyout"] as Flyout); Flyout.ShowAttachedFlyout(FilterButton); }
private void MenuFlyoutSubItem_Tapped(object sender, TappedRoutedEventArgs e) { Flyout.SetAttachedFlyout(FilterButton, this.Resources["FilterRatingFlyout"] as Flyout); Flyout.ShowAttachedFlyout(FilterButton); }
private void FilterReturnItem_Tapped(object sender, TappedRoutedEventArgs e) { Flyout.SetAttachedFlyout(FilterButton, this.Resources["FilterMainFlyout"] as Flyout); Flyout.ShowAttachedFlyout(FilterButton); }
private void NotificationClicked(object sender, TappedRoutedEventArgs e, Notification _notification, Canvas _canvas) { TextBlock clickedTextBlock = sender as TextBlock; Flyout editNotification = new Flyout(); Grid grid = new Grid(); editNotification.Content = grid; grid.Height = Double.NaN; grid.Width = 300; grid.RowDefinitions.Add(new RowDefinition()); grid.RowDefinitions.Add(new RowDefinition()); grid.RowDefinitions.Add(new RowDefinition()); grid.RowDefinitions.Add(new RowDefinition()); TextBox titleText = new TextBox(); TextBox dateText = new TextBox(); TextBox timeText = new TextBox(); TextBox textText = new TextBox(); titleText.Header = "Title"; dateText.Header = "Date"; timeText.Header = "Time"; textText.Header = "Text"; titleText.Text = _notification.title; textText.Text = _notification.text; dateText.Text = _notification.date; timeText.Text = _notification.time; Button applyBtn = new Button(); applyBtn.Content = "Apply"; applyBtn.SetValue(VerticalAlignmentProperty, VerticalAlignment.Bottom); applyBtn.SetValue(HorizontalContentAlignmentProperty, HorizontalAlignment.Right); applyBtn.Click += (sendeer, ee) => SendNotificationEditToServer(sender, e, _canvas, _notification); titleText.SetValue(Grid.RowProperty, 0); dateText.SetValue(Grid.RowProperty, 1); timeText.SetValue(Grid.RowProperty, 1); textText.SetValue(Grid.RowProperty, 2); applyBtn.SetValue(Grid.RowProperty, 3); timeText.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Right); dateText.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Left); timeText.Width = grid.Width / 2; dateText.Width = grid.Width / 2; grid.Children.Add(titleText); grid.Children.Add(dateText); grid.Children.Add(timeText); grid.Children.Add(textText); grid.Children.Add(applyBtn); CalendarNode node = selectedNodes[0]; dateText.Text = node._dateTime.Date.ToString("d"); node._node.Background = new SolidColorBrush(Colors.Red); editNotification.ShowAt(node._node); }
/// <summary> /// transforms a JToken (json) object to a Notification object and links said object to the corresponding date on the calendar /// </summary> /// <param name="notificationJSON"></param> private void CalendarClicked(object sender, TappedRoutedEventArgs e) { Canvas canvas = (Canvas)sender; CalendarNode node = GetCalendarNode(canvas); Debug.WriteLine(node._row); // If a calendar node is not selected // Either create a new notification or show details of existing ones if (selectedNodes.Count == 0) { // If there are no notifications on selected day // Show create notification flyout if (node._notifications.Count == 0) { Flyout notificationFlyout = new Flyout(); Grid notificationGrid = new Grid(); notificationFlyout.Content = notificationGrid; notificationFlyout.Closed += notificationFlyoutClosed; notificationGrid.Height = Double.NaN; notificationGrid.Width = 300; notificationGrid.RowDefinitions.Add(new RowDefinition()); notificationGrid.RowDefinitions.Add(new RowDefinition()); notificationGrid.RowDefinitions.Add(new RowDefinition()); notificationGrid.RowDefinitions.Add(new RowDefinition()); TextBox titleText = new TextBox(); TextBox dateText = new TextBox(); TextBox timeText = new TextBox(); TextBox textText = new TextBox(); titleText.Header = "Title"; dateText.Header = "Date"; timeText.Header = "Time"; textText.Header = "Text"; Button applyBtn = new Button(); applyBtn.Content = "Apply"; applyBtn.SetValue(VerticalAlignmentProperty, VerticalAlignment.Bottom); applyBtn.SetValue(HorizontalContentAlignmentProperty, HorizontalAlignment.Right); applyBtn.Click += SendNotificationToServer; titleText.SetValue(Grid.RowProperty, 0); dateText.SetValue(Grid.RowProperty, 1); timeText.SetValue(Grid.RowProperty, 1); textText.SetValue(Grid.RowProperty, 2); applyBtn.SetValue(Grid.RowProperty, 3); timeText.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Right); dateText.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Left); timeText.Width = notificationGrid.Width / 2; dateText.Width = notificationGrid.Width / 2; notificationGrid.Children.Add(titleText); notificationGrid.Children.Add(dateText); notificationGrid.Children.Add(timeText); notificationGrid.Children.Add(textText); notificationGrid.Children.Add(applyBtn); selectedNodes.Add(node); dateText.Text = node._dateTime.Date.ToString("d"); node._node.Background = new SolidColorBrush(Colors.Red); notificationFlyout.ShowAt(canvas); } // If There are notifications on the selected day // Show Details of said notifications else { Flyout notificationFlyout = new Flyout(); Grid notificationGrid = new Grid(); notificationFlyout.Content = notificationGrid; notificationFlyout.Closed += notificationFlyoutClosed; notificationGrid.Height = Double.NaN; notificationGrid.Width = 300; notificationGrid.RowDefinitions.Add(new RowDefinition()); Button addNotification = new Button(); addNotification.SetValue(Grid.RowProperty, 0); addNotification.Content = "+ Add new notification"; notificationGrid.Children.Add(addNotification); notificationGrid.RowDefinitions.Add(new RowDefinition()); TextBlock date = new TextBlock(); date.Text = node._dateTime.Date.ToString("d"); date.Width = 300; date.SetValue(Grid.RowProperty, 1); date.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Right); notificationGrid.Children.Add(date); for (int i = 0; i < node._notifications.Count; i++) { notificationGrid.RowDefinitions.Add(new RowDefinition()); Notification notification = node._notifications[i]; TextBlock title = new TextBlock(); TextBlock text = new TextBlock(); title.Text = notification.title; text.Text = notification.text; title.Width = 300; text.Width = 300; title.SetValue(Grid.RowProperty, i + 2); text.SetValue(Grid.RowProperty, i + 2); title.SetValue(MarginProperty, new Thickness(0, 0, 0, 0)); text.SetValue(MarginProperty, new Thickness(0, 20, 0, 0)); notificationGrid.Children.Add(title); notificationGrid.Children.Add(text); title.Tapped += new TappedEventHandler((sendeer, ee) => NotificationClicked(sender, e, notification, canvas)); } selectedNodes.Add(node); node._node.Background = new SolidColorBrush(Colors.Red); notificationFlyout.ShowAt(canvas); } } // If calendar node is selected // Clear the selected nodes else { ClearSelectedNodes(); } }
private async void toastsound_Tapped(object sender, TappedRoutedEventArgs e) { Grid mainGrid = new Grid { MinWidth = 320, }; Flyout mainFlyout = new Flyout { Content = mainGrid, Placement = Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode.Top }; mainGrid.RowDefinitions.Add(new RowDefinition()); mainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); // Setup Content var panel = new StackPanel { Padding = new Thickness(12), }; panel.SetValue(Grid.RowProperty, 0); mainGrid.Children.Add(panel); TextBlock title = new TextBlock { Text = "Zvuk notifikacije", FontSize = 22, FontWeight = FontWeights.Bold, }; panel.Children.Add(title); ListView lv = new ListView { HorizontalContentAlignment = HorizontalAlignment.Stretch, VerticalContentAlignment = VerticalAlignment.Stretch, SelectionMode = ListViewSelectionMode.None, }; panel.Children.Add(lv); var toastSounds = await Alarm_Sounds(); List <RadioButton> rbtns = new List <RadioButton>(); foreach (var it in toastSounds) { RadioButton rbtn = new RadioButton { Content = it.DisplayName, Tag = "ms-appx:///" + Fixed.App_Assets_Folder + "/" + Fixed.App_Sound_Folder + "/" + it.Name, Padding = new Thickness(6), FontSize = 18, IsChecked = false }; lv.Items.Add(rbtn); if (Memory.Toast_Sound.Contains(it.Name)) { rbtn.IsChecked = true; } rbtns.Add(rbtn); rbtn.Checked += (s, args) => { foreach (var rb in rbtns) { if (rb != rbtn) { rb.IsChecked = false; } } audio_prev.Source = new Uri(rbtn.Tag.ToString()); audio_prev.AutoPlay = true; audio_prev.Stop(); }; } #region Buttons Grid keyGrid = new Grid { }; keyGrid.ColumnDefinitions.Add(new ColumnDefinition()); keyGrid.ColumnDefinitions.Add(new ColumnDefinition()); keyGrid.SetValue(Grid.RowProperty, 1); mainGrid.Children.Add(keyGrid); Button lBtn = new Button { Padding = new Thickness(6), Margin = new Thickness(3), BorderBrush = new SolidColorBrush(Colors.White), BorderThickness = new Thickness(1), HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, Content = "sačuvaj", HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; lBtn.Click += (s, arg) => { foreach (var rb in rbtns) { if (rb.IsChecked == true) { Memory.Toast_Sound = rb.Tag.ToString(); } } audio_prev.AutoPlay = false; audio_prev.Stop(); Notification.Set(Data.Obavijest.All); mainFlyout.Hide(); }; lBtn.SetValue(Grid.ColumnProperty, 0); keyGrid.Children.Add(lBtn); Button rBtn = new Button { Padding = new Thickness(6), Margin = new Thickness(3), BorderBrush = new SolidColorBrush(Colors.White), BorderThickness = new Thickness(1), HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, Content = "poništi", HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; rBtn.Click += (s, arg) => { audio_prev.AutoPlay = false; audio_prev.Stop(); mainFlyout.Hide(); }; mainFlyout.Closed += (s, arg) => { audio_prev.AutoPlay = false; audio_prev.Stop(); }; rBtn.SetValue(Grid.ColumnProperty, 1); keyGrid.Children.Add(rBtn); #endregion mainFlyout.ShowAt(this); }
private void TextBlock_Tapped(object sender, TappedRoutedEventArgs e) { Flyout.ShowAt(dtUsername); }
private void editComment(object sender, RoutedEventArgs e) { var element = commentThread.ItemContainerGenerator.ContainerFromItem(commentThread.SelectedItem) as UIElement; flyout = new Flyout(); flyout.Background = new SolidColorBrush(Colors.Black); StackPanel sp = new StackPanel(); editBox = new TextBox() { Width = 300, Height = 100, Padding = new Thickness(5, 0, 0, 0), Text = (commentThread.SelectedItem as Comment).content, TextWrapping = TextWrapping.Wrap }; sp.Children.Add(editBox); Button b = new Button(); b.Content = "Edit Comment"; b.Click += postEdit; sp.Children.Add(b); flyout.Content = sp; flyout.PlacementTarget = element; flyout.IsOpen = true; }
public static Flyout ToPopup(this IContextMenu source) { var flyout = new Flyout(); ItemsControl items = new ItemsControl(); foreach(var item in source.Items) { Button button = new Button(); button.Content = item.Header; button.Command = new RelayCommand<object>( (param) => { flyout.Hide(); item.Command.Execute(param); }, (param) => item.Command.CanExecute(param)); button.CommandParameter = item.CommandParameter; button.HorizontalAlignment = HorizontalAlignment.Stretch; items.Items.Add(button); } Border border = new Border(); border.Padding = new Thickness(12); border.MinWidth = 480; border.HorizontalAlignment = HorizontalAlignment.Stretch; border.VerticalAlignment = VerticalAlignment.Bottom; border.Child = items; flyout.Content = border; return flyout; }
private void Border_Tapped(object sender, TappedRoutedEventArgs e) { Flyout.ShowAttachedFlyout(sender as FrameworkElement); }
private void imageTitle_Tapped(object sender, TappedRoutedEventArgs e) { Flyout.ShowAttachedFlyout(sender as TextBlock); }
private void TryShowFlyout(Flyout flyout, FrameworkElement location) { try { flyout.ShowAt(location); } catch (ArgumentException ex) { PlatformAdapter.SendToCustomLogger(ex, LoggingLevel.Error); } }
private void SendCommand_Tapped(object sender, TappedRoutedEventArgs e) { Flyout flyOut = new Flyout(); flyOut.Placement = FlyoutPlacementMode.Top; flyOut.FlyoutPresenterStyle = new Style(typeof(FlyoutPresenter)); flyOut.FlyoutPresenterStyle.Setters.Add(new Setter(FlyoutPresenter.RequestedThemeProperty, ElementTheme.Dark)); flyOut.FlyoutPresenterStyle.Setters.Add(new Setter(FlyoutPresenter.PaddingProperty, 10)); StackPanel panel = new StackPanel(); panel.Width = 300; panel.Margin = new Thickness(10); panel.Orientation = Orientation.Vertical; panel.Children.Add(new TextBlock() { Text = "Command name", FontSize = 14.8 }); TextBox commandName = new TextBox(); panel.Children.Add(commandName); panel.Children.Add(new TextBlock() { Text = "Params", FontSize = 14.8, Margin = new Thickness(0, 10, 0, 0) }); TextBox commandParams = new TextBox(); panel.Children.Add(commandParams); panel.Children.Add(new TextBlock() { Text = "JSON or empty string" }); Button sendButton = new Button() { Content = "Send", Margin = new Thickness(0, 10, 0, 0) }; panel.Children.Add(sendButton); if (CommandSelected != null) { commandName.Text = CommandSelected.Name; commandParams.Text = (string)new ObjectToJsonStringConverter().Convert(CommandSelected.Parameters, null, null, null); } sendButton.Command = new DelegateCommand(async() => { if (commandName.Text.Trim() == "") { new MessageDialog("Empty command name", "Send command").ShowAsync(); return; } panel.ControlsEnable(false); LoadingItems++; try { var command = new Command(commandName.Text, commandParams.Text != "" ? JObject.Parse(commandParams.Text) : null); Debug.WriteLine("CMD SEND START"); await ClientService.Current.SendCommandAsync(deviceId, command, CommandResultCallback); Debug.WriteLine("CMD SEND END"); flyOut.Hide(); } catch (Exception ex) { new MessageDialog(ex.Message, "Send command").ShowAsync(); } panel.ControlsEnable(true); LoadingItems--; }); flyOut.Content = panel; flyOut.ShowAt((FrameworkElement)sender); }
void DoHolding(object sender) { if (((sender as StackPanel).DataContext as MyRenderItem).Word != -1) { Flyout ContextFlyout = new Flyout(); StackPanel Panel = new StackPanel(); //Panel.SetValue(NameProperty, "TopLevel"); //Panel.Name = "TopLevel"; Panel.DataContext = this; ContextFlyout.Content = Panel; Panel.Children.Add(new ItemsControl() { ItemsPanel = Resources["VirtualPanelTemplate"] as ItemsPanelTemplate, ItemTemplate = Resources["WrapTemplate"] as DataTemplate, ItemsSource = VirtualizingWrapPanelAdapter.GroupRenderModels(System.Linq.Enumerable.Select(AppSettings.ChData.GetMorphologicalDataForWord(((sender as StackPanel).DataContext as MyRenderItem).Chapter, ((sender as StackPanel).DataContext as MyRenderItem).Verse, ((sender as StackPanel).DataContext as MyRenderItem).Word).Items, (Arr) => new MyRenderItem((XMLRender.RenderArray.RenderItem)Arr)).ToList(), UIChanger.MaxWidth) }); VirtualizingStackPanel.SetVirtualizationMode((Panel.Children.Last() as ItemsControl), VirtualizationMode.Recycling); Panel.Children.Add(new Button() { Content = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("CopyToClipboard/Text") }); (Panel.Children.Last() as Button).Click += (object _sender, RoutedEventArgs _e) => { #if WINDOWS_APP || WINDOWS_UWP Windows.ApplicationModel.DataTransfer.DataPackage package = new Windows.ApplicationModel.DataTransfer.DataPackage(); package.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText); Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(package); #else global::Windows.System.LauncherOptions options = new global::Windows.System.LauncherOptions(); options.PreferredApplicationDisplayName = "Clipboarder"; options.PreferredApplicationPackageFamilyName = "InTheHandLtd.Clipboarder"; options.DisplayApplicationPicker = false; global::Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format("clipboard:Set?Text={0}", Uri.EscapeDataString(string.Empty))), options); #endif }; Panel.Children.Add(new Button() { Content = new TextBlock() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Share/Text") } }); (Panel.Children.Last() as Button).Click += (object _sender, RoutedEventArgs _e) => { //#if WINDOWS_APP Windows.ApplicationModel.DataTransfer.DataPackage package = new Windows.ApplicationModel.DataTransfer.DataPackage(); package.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText); Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested += (Windows.ApplicationModel.DataTransfer.DataTransferManager __sender, Windows.ApplicationModel.DataTransfer.DataRequestedEventArgs __e) => { __e.Request.Data.Properties.Title = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("DisplayName"); __e.Request.Data.Properties.Description = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Description"); __e.Request.Data.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText); Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested -= null; }; Windows.ApplicationModel.DataTransfer.DataTransferManager.ShowShareUI(); //#else // Microsoft.Phone.Tasks.ShareStatusTask shareStatusTask = new Microsoft.Phone.Tasks.ShareStatusTask(); // shareStatusTask.Status = string.Empty; // shareStatusTask.Show(); //#endif }; FlyoutBase.SetAttachedFlyout(sender as StackPanel, ContextFlyout); FlyoutBase.ShowAttachedFlyout(sender as StackPanel); } else if (((sender as StackPanel).DataContext as MyRenderItem).Chapter != -1) { MenuFlyout ContextFlyout = new MenuFlyout(); int idxMark = Array.FindIndex(AppSettings.Bookmarks, (Item) => Item[0] == Division && Item[1] == Selection && Item[2] == ((sender as StackPanel).DataContext as MyRenderItem).Chapter && Item[3] == ((sender as StackPanel).DataContext as MyRenderItem).Verse); ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString((idxMark == -1 ? "AddBookmark" : "RemoveBookmark") + "/Text") }); (ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) => { List<int[]> marks = AppSettings.Bookmarks.ToList(); if (idxMark != -1) { marks.RemoveAt(idxMark); } else { marks.Add(new int[] { Division, Selection, ((sender as StackPanel).DataContext as MyRenderItem).Chapter, ((sender as StackPanel).DataContext as MyRenderItem).Verse }); } AppSettings.Bookmarks = marks.ToArray(); }; ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("CopyToClipboard/Text") }); (ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) => { #if WINDOWS_APP || WINDOWS_UWP Windows.ApplicationModel.DataTransfer.DataPackage package = new Windows.ApplicationModel.DataTransfer.DataPackage(); package.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText); Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(package); #else global::Windows.System.LauncherOptions options = new global::Windows.System.LauncherOptions(); options.PreferredApplicationDisplayName = "Clipboarder"; options.PreferredApplicationPackageFamilyName = "InTheHandLtd.Clipboarder"; options.DisplayApplicationPicker = false; global::Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format("clipboard:Set?Text={0}", Uri.EscapeDataString(string.Empty))), options); #endif }; ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Share/Text") }); (ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) => { //#if WINDOWS_APP Windows.ApplicationModel.DataTransfer.DataPackage package = new Windows.ApplicationModel.DataTransfer.DataPackage(); package.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText); Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested += (Windows.ApplicationModel.DataTransfer.DataTransferManager __sender, Windows.ApplicationModel.DataTransfer.DataRequestedEventArgs __e) => { __e.Request.Data.Properties.Title = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("DisplayName"); __e.Request.Data.Properties.Description = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("Description"); __e.Request.Data.SetText(((sender as StackPanel).DataContext as MyRenderItem).GetText); Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested -= null; }; Windows.ApplicationModel.DataTransfer.DataTransferManager.ShowShareUI(); //#else // Microsoft.Phone.Tasks.ShareStatusTask shareStatusTask = new Microsoft.Phone.Tasks.ShareStatusTask(); // shareStatusTask.Status = string.Empty; // shareStatusTask.Show(); //#endif }; ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("SetPlaybackVerse/Text") }); (ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) => { ViewModel.CurrentVerse = (sender as StackPanel).DataContext as MyRenderItem; for (int count = 0; count <= ViewModel.VerseReferences.Count() - 1; count++) { if (ViewModel.VerseReferences[count] == ViewModel.CurrentVerse) { CurrentPlayingItem = count; break; } VersePlayer.Source = null; } }; //ContextFlyout.Items.Add(new MenuFlyoutItem() { Text = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("ShowExegesis/Text") }); //(ContextFlyout.Items.Last() as MenuFlyoutItem).Click += (object _sender, RoutedEventArgs _e) => { }; FlyoutBase.SetAttachedFlyout(sender as StackPanel, ContextFlyout); FlyoutBase.ShowAttachedFlyout(sender as StackPanel); } }
private void SendCommand_Tapped(object sender, TappedRoutedEventArgs e) { Flyout flyOut = new Flyout(); flyOut.Placement = FlyoutPlacementMode.Top; flyOut.FlyoutPresenterStyle = new Style(typeof(FlyoutPresenter)); flyOut.FlyoutPresenterStyle.Setters.Add(new Setter(FlyoutPresenter.RequestedThemeProperty, ElementTheme.Dark)); flyOut.FlyoutPresenterStyle.Setters.Add(new Setter(FlyoutPresenter.PaddingProperty, 10)); StackPanel panel = new StackPanel(); panel.Width = 300; panel.Margin = new Thickness(10); panel.Orientation = Orientation.Vertical; panel.Children.Add(new TextBlock() { Text = "Command name", FontSize = 14.8 }); TextBox commandName = new TextBox(); panel.Children.Add(commandName); panel.Children.Add(new TextBlock() { Text = "Params", FontSize = 14.8, Margin = new Thickness(0, 10, 0, 0) }); TextBox commandParams = new TextBox(); panel.Children.Add(commandParams); panel.Children.Add(new TextBlock() { Text = "JSON or empty string" }); Button sendButton = new Button() { Content = "Send", Margin = new Thickness(0, 10, 0, 0) }; panel.Children.Add(sendButton); if (CommandSelected != null) { commandName.Text = CommandSelected.Name; commandParams.Text = (string)new ObjectToJsonStringConverter().Convert(CommandSelected.Parameters, null, null, null); } sendButton.Command = new DelegateCommand(async () => { if (commandName.Text.Trim() == "") { new MessageDialog("Empty command name", "Send command").ShowAsync(); return; } panel.ControlsEnable(false); LoadingItems++; try { var command = new Command(commandName.Text, commandParams.Text != "" ? JObject.Parse(commandParams.Text) : null); Debug.WriteLine("CMD SEND START"); await ClientService.Current.SendCommandAsync(deviceId, command, CommandResultCallback); Debug.WriteLine("CMD SEND END"); flyOut.Hide(); } catch (Exception ex) { new MessageDialog(ex.Message, "Send command").ShowAsync(); } panel.ControlsEnable(true); LoadingItems--; }); flyOut.Content = panel; flyOut.ShowAt((FrameworkElement)sender); }
protected override void OnApplyTemplate() { base.OnApplyTemplate(); _dropDownButton = GetTemplateChild("DropDownButton") as Button; if (_dropDownButton != null) { _dropDownButton.Tapped += OnDropDownButton_Tapped; } _deleteButton = GetTemplateChild("DeleteButton") as Button; if (_deleteButton != null) { _deleteButton.Tapped += OnDeleteButton_Tapped; } _popupBorder = GetTemplateChild("PopupBorder") as Border; _flyout = GetTemplateChild("Flyout") as Flyout; _listView = GetTemplateChild("PopupListView") as ListView; if (_listView != null) { _listView.ItemClick += OnListView_ItemClick; } //_contentElement = GetTemplateChild("ContentElement") as ScrollViewer; //_headerContentPresenter = GetTemplateChild("HeaderContentPresenter") as ContentPresenter; UpdateEDV(); UpdateDropDownButtonVisibility(); UpdateDeleteButtonVisibility(); //UpdateStates(false); }
private async void Accept_Click(object sender, RoutedEventArgs e) { Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; await storageFolder.CreateFileAsync("username.txt", Windows.Storage.CreationCollisionOption.OpenIfExists); await checkUser(); // hier moet je uit dat textveld waar die acceptbutton in staat even die waarden eruit halen en die variabele in de methode hieronder zetten i.p.v 8000 en 127.0.0.1 try { string[] strings = loginBox.Text.Trim().Split(':'); await EH.ConnectToBridge("lol", strings[1], strings[0]); EH.SAR.ip = strings[0]; EH.SAR.port = strings[1]; await EH.getAlldata(); //collectionlamp = EH.lamps; foreach(Lamp l in EH.lamps){ collectionlamp.Add(l); } Flyout f = Resources["Login"] as Flyout; f.Hide(); LoginButton.IsEnabled = false; } catch (Exception) { Flyout flyout = new Flyout(); TextBlock b = new TextBlock(); b.Text = "Please make sure you entered the adress correctly"; flyout.Content = b; flyout.ShowAt(Elipse); } }
/*private async void IniList(bool IsRefresh) { refreshIndicator.IsActive = true; if (!IsRefresh) { try { //Get data from storage StorageFolder fzuhelperDataFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("FzuhelperData"); StorageFile timetable = await fzuhelperDataFolder.GetFileAsync("timetable.dat"); jsonData = await FileIO.ReadTextAsync(timetable); } catch { if (firstTimeLoad) { IniList(true); firstTimeLoad = false; return; } MainPage.SendToast("获取数据出错,请刷新"); refreshIndicator.IsActive = false; return; } } else { try { jsonData = await HttpRequest.GetTimetable(); if(jsonData == "error") { MainPage.SendToast("获取数据出错"); refreshIndicator.IsActive = false; return; } } catch { MainPage.SendToast("获取数据出错"); refreshIndicator.IsActive = false; return; } } try { ttrv = JsonConvert.DeserializeObject<TimetableReturnValue>(jsonData); //A list of every week courses ,and the first item is current week courses tableInfo = JsonConvert.DeserializeObject<List<TableInfoArr>>(ttrv.data["tableInfo"].ToString()); currentWeek = tableInfo[0].week; ShowOneWeekCourse(0); IniWeekOption(); } catch { MainPage.SendToast("获取数据出错,请刷新"); } refreshIndicator.IsActive = false; }*/ /*private void ShowOneWeekCourse(int week) { //System.Diagnostics.Debug.WriteLine(timeTableMain.Children.Count); //Clear timetable while (timeTableMain.Children.Count != 18) { timeTableMain.Children.Remove(timeTableMain.Children.Last()); } //Clear single day course arr list singleDayCourseList.Clear(); List<DayCourseArr> dayCourseList = new List<DayCourseArr>(); DayCourseArr dayCourse = new DayCourseArr(); for (int i = 1; i <= 7; i++) { for (int jie = 1; jie <= 11; jie++) { dayCourse = JsonConvert.DeserializeObject<DayCourseArr>(tableInfo[week].courseArr[i.ToString()][jie.ToString()].ToString()); dayCourseList.Add(dayCourse); } } //Preparation for course color courseColorCount = 0; courseColorDict.Clear(); for (int i = 1; i <= 7; i++) { //Initialize single day course arr list singleDayCourseList.Add(new List<SingleDayCourseArr>()); //System.Diagnostics.Debug.WriteLine(tableInfo[week].courseArr[i.ToString()]["1"]); //i represents the column index that course should be placed and jie represents the row index for (int jie = 1; jie <= 11; jie++) { DayCourseArr currentCourse = dayCourseList[(i - 1) * 11 + jie - 1]; //If the course is empty if (currentCourse.courseName == "") { continue; } //Check rowspan int rowspans = 0; while (true) { //System.Diagnostics.Debug.WriteLine(rowspans); if (currentCourse.courseName == dayCourseList[(i - 1) * 11 + jie + rowspans].courseName && currentCourse.place == dayCourseList[(i - 1) * 11 + jie + rowspans].place && currentCourse.teacherName == dayCourseList[(i - 1) * 11 + jie + rowspans].teacherName && currentCourse.betweenWeek == dayCourseList[(i - 1) * 11 + jie + rowspans].betweenWeek) { if ((((i - 1) * 11) < ((i - 1) * 11 + jie + rowspans) && ((i - 1) * 11 + jie + rowspans) <= ((i - 1) * 11 + 10))) { rowspans++; } } else { break; } } //jieDuration = jie ~ jie+rowspans string jieDur = jie.ToString() + "-" + (jie + rowspans).ToString(); singleDayCourseList[i - 1].Add(new SingleDayCourseArr(currentCourse.courseName, currentCourse.place, currentCourse.teacherName, currentCourse.betweenWeek + "周", jieDur)); //Create stackpanel and visible textblocks StackPanel stackPanel = new StackPanel() { Orientation = Orientation.Vertical }; TextBlock textBlock1 = new TextBlock() { Text = currentCourse.courseName, MaxLines = 2, Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)), FontSize = 12, HorizontalAlignment = HorizontalAlignment.Stretch, TextWrapping = TextWrapping.WrapWholeWords }; TextBlock textBlock2 = new TextBlock() { Text = currentCourse.place, Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)), FontSize = 12, HorizontalAlignment = HorizontalAlignment.Stretch, TextWrapping = TextWrapping.WrapWholeWords }; //Invisible textblocks TextBlock textBlock3 = new TextBlock() { Text = currentCourse.teacherName, Visibility = Visibility.Collapsed }; TextBlock textBlock4 = new TextBlock() { Text = currentCourse.betweenWeek, Visibility = Visibility.Collapsed }; TextBlock textBlock5 = new TextBlock() { Text = jieDur, Visibility = Visibility.Collapsed }; //Add elements to stackpanel stackPanel.Children.Add(textBlock1); stackPanel.Children.Add(textBlock2); stackPanel.Children.Add(textBlock3); stackPanel.Children.Add(textBlock4); stackPanel.Children.Add(textBlock5); //Create button Button singleCourse = new Button() { Margin = new Thickness(2), Padding = new Thickness(2), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; singleCourse.Content = stackPanel; singleCourse.Flyout = AddCourseFlyout(stackPanel); singleCourse.Click += SingleCourse_Click; //Set course background color if (courseColorDict.ContainsKey(currentCourse.courseName)) { singleCourse.Background = courseColorDict[currentCourse.courseName]; } else { singleCourse.Background = courseColor[courseColorCount]; courseColorDict.Add(currentCourse.courseName, courseColor[courseColorCount]); courseColorCount++; if (courseColorCount == courseColorAmount) { courseColorCount = 0; } } Grid.SetColumn(singleCourse, i); Grid.SetRow(singleCourse, jie); if (rowspans != 0) { Grid.SetRowSpan(singleCourse, rowspans + 1); } timeTableMain.Children.Add(singleCourse); jie += rowspans; } } //Set selected week selectedWeek.Text = tableInfo[week].week; if (tableInfo[week].week.Equals(tableInfo[0].week)) { selectedWeekBtn.Label = "(本周)"; } else { selectedWeekBtn.Label = "(非本周)"; } //Set single day course data binding MonCourse.ItemsSource = singleDayCourseList[0]; TueCourse.ItemsSource = singleDayCourseList[1]; WedCourse.ItemsSource = singleDayCourseList[2]; ThuCourse.ItemsSource = singleDayCourseList[3]; FriCourse.ItemsSource = singleDayCourseList[4]; SatCourse.ItemsSource = singleDayCourseList[5]; SunCourse.ItemsSource = singleDayCourseList[6]; //Display current day int currentDayIndex = weekToInt.w2i[DateTime.Now.DayOfWeek.ToString()]; singleDayCourseView.SelectedItem = singleDayCourseView.Items.ElementAt(currentDayIndex); //Check empty foreach (List<SingleDayCourseArr> item in singleDayCourseList) { if (item.Count == 0) { TextBlock tb = new TextBlock() { Text = "没课啦", FontSize = 24, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; ListViewItem lvi = new ListViewItem(); lvi.Content = tb; switch (singleDayCourseList.IndexOf(item)) { case 0: MonCourse.ItemsSource = null; MonCourse.Items.Clear(); MonCourse.Items.Add(lvi); break; case 1: TueCourse.ItemsSource = null; TueCourse.Items.Clear(); TueCourse.Items.Add(lvi); break; case 2: WedCourse.ItemsSource = null; WedCourse.Items.Clear(); WedCourse.Items.Add(lvi); break; case 3: ThuCourse.ItemsSource = null; ThuCourse.Items.Clear(); ThuCourse.Items.Add(lvi); break; case 4: FriCourse.ItemsSource = null; FriCourse.Items.Clear(); FriCourse.Items.Add(lvi); break; case 5: SatCourse.ItemsSource = null; SatCourse.Items.Clear(); SatCourse.Items.Add(lvi); break; case 6: SunCourse.ItemsSource = null; SunCourse.Items.Clear(); SunCourse.Items.Add(lvi); break; default: break; } } } }*/ private Flyout AddCourseFlyout(StackPanel sp) { TextBlock t1 = (TextBlock)sp.Children.ElementAt(0);//courseName TextBlock t2 = (TextBlock)sp.Children.ElementAt(1);//place TextBlock t3 = (TextBlock)sp.Children.ElementAt(2);//teacherName TextBlock t4 = (TextBlock)sp.Children.ElementAt(3);//betweenWeek TextBlock t5 = (TextBlock)sp.Children.ElementAt(4);//jie //Create main stackpanel StackPanel spMain = new StackPanel() { Padding = new Thickness(5), Margin = new Thickness(10), HorizontalAlignment = HorizontalAlignment.Stretch, Orientation = Orientation.Horizontal }; //Create left and right stackpanel StackPanel spLeft = new StackPanel() { Margin = new Thickness(0,0,20,0), HorizontalAlignment = HorizontalAlignment.Stretch, Orientation = Orientation.Vertical }; StackPanel spRight = new StackPanel() { HorizontalAlignment = HorizontalAlignment.Stretch, Orientation = Orientation.Vertical }; //Create new textblocks //indicators TextBlock tbi1 = new TextBlock() { Text = "课程", Margin = new Thickness(0, 5, 0, 5) }; TextBlock tbi2 = new TextBlock() { Text = "教室", Margin = new Thickness(0, 5, 0, 5) }; TextBlock tbi3 = new TextBlock() { Text = "老师", Margin = new Thickness(0, 5, 0, 5) }; TextBlock tbi4 = new TextBlock() { Text = "周数", Margin = new Thickness(0, 5, 0, 5) }; TextBlock tbi5 = new TextBlock() { Text = "节数", Margin = new Thickness(0, 5, 0, 5) }; //values TextBlock tb1 = new TextBlock() { Text = t1.Text, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 5, 0, 5) }; TextBlock tb2 = new TextBlock() { Text = t2.Text, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 5, 0, 5) }; TextBlock tb3 = new TextBlock() { Text = t3.Text, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 5, 0, 5) }; TextBlock tb4 = new TextBlock() { Text = t4.Text, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 5, 0, 5) }; TextBlock tb5 = new TextBlock() { Text = t5.Text, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 5, 0, 5) }; //Add textblocks to stackpanels spLeft.Children.Add(tbi1); spLeft.Children.Add(tbi2); spLeft.Children.Add(tbi3); spLeft.Children.Add(tbi4); spLeft.Children.Add(tbi5); spRight.Children.Add(tb1); spRight.Children.Add(tb2); spRight.Children.Add(tb3); spRight.Children.Add(tb4); spRight.Children.Add(tb5); spMain.Children.Add(spLeft); spMain.Children.Add(spRight); Flyout flyout = new Flyout(); flyout.Content = spMain; //FlyoutBase.SetAttachedFlyout(sp, flyout); return flyout; }
public void AddFlyout(string name, Type viewType, Position position, UnloadBehavior unloadBehavior = UnloadBehavior.SaveAndCloseViewModel, FlyoutTheme flyoutTheme = FlyoutTheme.Adapt) { Argument.IsNotNullOrWhitespace(() => name); Argument.IsNotNull(() => viewType); Log.Info("Adding flyout '{0}' with view type '{1}'", name, viewType.FullName); var content = (UIElement)_typeFactory.CreateInstance(viewType); var flyout = new Flyout(); flyout.Theme = flyoutTheme; flyout.Position = position; var flyoutInfo = new FlyoutInfo(flyout, content); flyout.SetBinding(Flyout.HeaderProperty, new Binding("ViewModel.Title") { Source = content }); ((ICompositeCommand)_commandManager.GetCommand("Close")).RegisterAction(() => { flyout.IsOpen = false; }); #pragma warning disable AvoidAsyncVoid flyout.IsOpenChanged += async(sender, e) => #pragma warning restore AvoidAsyncVoid { if (!flyout.IsOpen) { var vmContainer = flyout.Content as IViewModelContainer; if (vmContainer != null) { var vm = vmContainer.ViewModel; if (vm != null) { switch (unloadBehavior) { case UnloadBehavior.CloseViewModel: await vm.CloseViewModelAsync(null); break; case UnloadBehavior.SaveAndCloseViewModel: await vm.SaveAndCloseViewModelAsync(); break; case UnloadBehavior.CancelAndCloseViewModel: await vm.CancelAndCloseViewModelAsync(); break; default: throw new ArgumentOutOfRangeException(nameof(unloadBehavior)); } } } flyout.Content = null; flyout.DataContext = null; } }; _flyouts[name] = flyoutInfo; }
public async Task ShowTextAsync(string text, CancellationToken cancToken) { Flyout dialog = null; TextViewer tv = null; await RunInUiThreadAsync(delegate { dialog = new Flyout(); tv = new TextViewer(text); dialog.Closed += OnDialog_Closed; dialog.Content = tv; tv.UserAnswered += OnTextViewer_UserAnswered; ; _isHasUserAnswered = false; dialog.ShowAt(Window.Current.Content as FrameworkElement); }).ConfigureAwait(false); while (!_isHasUserAnswered && !cancToken.IsCancellationRequested) { await Task.Delay(DELAY, cancToken).ConfigureAwait(false); } await RunInUiThreadAsync(delegate { dialog.Closed -= OnDialog_Closed; tv.UserAnswered -= OnTextViewer_UserAnswered; dialog.Hide(); }).ConfigureAwait(false); }
void ShowFilterFlyout(object sender, DateTime?start, DateTime?end, Action <DateTime?, DateTime?> filterAction) { Flyout flyOut = new Flyout(); flyOut.Placement = FlyoutPlacementMode.Top; flyOut.FlyoutPresenterStyle = new Style(typeof(FlyoutPresenter)); flyOut.FlyoutPresenterStyle.Setters.Add(new Setter(FlyoutPresenter.RequestedThemeProperty, ElementTheme.Dark)); flyOut.FlyoutPresenterStyle.Setters.Add(new Setter(FlyoutPresenter.PaddingProperty, 10)); StackPanel filterPanel = new StackPanel(); filterPanel.Margin = new Thickness(10); filterPanel.Orientation = Orientation.Vertical; filterPanel.Children.Add(new TextBlock() { Text = "Start time", FontSize = 14.8 }); TextBox filterStart = new TextBox(); filterPanel.Children.Add(filterStart); filterPanel.Children.Add(new TextBlock() { Text = "End time", FontSize = 14.8, Margin = new Thickness(0, 10, 0, 0) }); TextBox filterEnd = new TextBox(); filterPanel.Children.Add(filterEnd); filterPanel.Children.Add(new TextBlock() { Text = "Leave field empty to subscribe to new data from server" }); Button filterDoButton = new Button() { Content = "Filter", Margin = new Thickness(0, 10, 0, 0) }; filterPanel.Children.Add(filterDoButton); filterStart.Text = start != null?start.ToString() : ""; filterEnd.Text = end != null?end.ToString() : ""; filterDoButton.Command = new DelegateCommand(() => { start = null; end = null; DateTime newStart, newEnd; if (filterStart.Text != "") { if (DateTime.TryParse(filterStart.Text, out newStart)) { start = newStart; } else { new MessageDialog("Wrong start date", "Filter").ShowAsync(); return; } } if (filterEnd.Text != "") { if (DateTime.TryParse(filterEnd.Text, out newEnd)) { end = newEnd; } else { new MessageDialog("Wrong end date", "Filter").ShowAsync(); return; } } filterAction(start, end); }); flyOut.Content = filterPanel; flyOut.ShowAt((FrameworkElement)sender); }
public void ShowAt(FrameworkElement target) { Flyout.ShowAt(target); }
private void toastsound_Tapped(object sender, TappedRoutedEventArgs e) { if (ucitavam) { return; } Grid mainGrid = new Grid { MinWidth = 320, }; Flyout mainFlyout = new Flyout { Content = mainGrid, Placement = Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode.Top }; mainGrid.RowDefinitions.Add(new RowDefinition()); mainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); // Setup Content var panel = new StackPanel { Margin = new Thickness(12), }; panel.SetValue(Grid.RowProperty, 0); mainGrid.Children.Add(panel); TextBlock title = new TextBlock { Text = "Zvuk notifikacije", FontSize = 22, FontWeight = FontWeights.Bold, }; panel.Children.Add(title); ListView lv = new ListView { HorizontalContentAlignment = HorizontalAlignment.Stretch, VerticalContentAlignment = VerticalAlignment.Stretch, SelectionMode = ListViewSelectionMode.None, }; panel.Children.Add(lv); List <string> svi = Paths_To_All_Toast_Sounds(); List <RadioButton> rbtns = new List <RadioButton>(); foreach (var it in svi) { RadioButton rbtn = new RadioButton { Content = Daj_Ime_Zvuka_Notifikacije(it), Tag = it, Padding = new Thickness(6), FontSize = 18, }; lv.Items.Add(rbtn); if (it == Memory.Toast_Sound) { rbtn.IsChecked = true; } else { rbtn.IsChecked = false; } rbtns.Add(rbtn); rbtn.Checked += (s, args) => { foreach (var rb in rbtns) { if (rb != rbtn) { rb.IsChecked = false; } } audio_prev.Source = new Uri(rbtn.Tag.ToString()); audio_prev.AutoPlay = true; audio_prev.Stop(); }; } #region Buttons Grid keyGrid = new Grid { }; keyGrid.ColumnDefinitions.Add(new ColumnDefinition()); keyGrid.ColumnDefinitions.Add(new ColumnDefinition()); keyGrid.SetValue(Grid.RowProperty, 1); mainGrid.Children.Add(keyGrid); Button lBtn = new Button { Padding = new Thickness(6), Margin = new Thickness(3), BorderBrush = new SolidColorBrush(Colors.White), BorderThickness = new Thickness(1), HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, Content = "sačuvaj", HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; lBtn.Click += (s, arg) => { foreach (var rb in rbtns) { if (rb.IsChecked == true) { Memory.Toast_Sound = rb.Tag.ToString(); } } audio_prev.AutoPlay = false; audio_prev.Stop(); Postavi_Stranicu(); Set.Group_Notifications(2, 0, false, 6, 2, true); mainFlyout.Hide(); }; lBtn.SetValue(Grid.ColumnProperty, 0); keyGrid.Children.Add(lBtn); Button rBtn = new Button { Padding = new Thickness(6), Margin = new Thickness(3), BorderBrush = new SolidColorBrush(Colors.White), BorderThickness = new Thickness(1), HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, Content = "poništi", HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; rBtn.Click += (s, arg) => { audio_prev.AutoPlay = false; audio_prev.Stop(); mainFlyout.Hide(); }; mainFlyout.Closed += (s, arg) => { audio_prev.AutoPlay = false; audio_prev.Stop(); }; rBtn.SetValue(Grid.ColumnProperty, 1); keyGrid.Children.Add(rBtn); #endregion mainFlyout.ShowAt(this); }
void ShowFilterFlyout(object sender, DateTime? start, DateTime? end, Action<DateTime?, DateTime?> filterAction) { Flyout flyOut = new Flyout(); flyOut.Placement = FlyoutPlacementMode.Top; flyOut.FlyoutPresenterStyle = new Style(typeof(FlyoutPresenter)); flyOut.FlyoutPresenterStyle.Setters.Add(new Setter(FlyoutPresenter.RequestedThemeProperty, ElementTheme.Dark)); flyOut.FlyoutPresenterStyle.Setters.Add(new Setter(FlyoutPresenter.PaddingProperty, 10)); StackPanel filterPanel = new StackPanel(); filterPanel.Margin = new Thickness(10); filterPanel.Orientation = Orientation.Vertical; filterPanel.Children.Add(new TextBlock() { Text = "Start time", FontSize = 14.8 }); TextBox filterStart = new TextBox(); filterPanel.Children.Add(filterStart); filterPanel.Children.Add(new TextBlock() { Text = "End time", FontSize = 14.8, Margin = new Thickness(0, 10, 0, 0) }); TextBox filterEnd = new TextBox(); filterPanel.Children.Add(filterEnd); filterPanel.Children.Add(new TextBlock() { Text = "Leave field empty to subscribe to new data from server" }); Button filterDoButton = new Button() { Content = "Filter", Margin = new Thickness(0, 10, 0, 0) }; filterPanel.Children.Add(filterDoButton); filterStart.Text = start != null ? start.ToString() : ""; filterEnd.Text = end != null ? end.ToString() : ""; filterDoButton.Command = new DelegateCommand(() => { start = null; end = null; DateTime newStart, newEnd; if (filterStart.Text != "") { if (DateTime.TryParse(filterStart.Text, out newStart)) { start = newStart; } else { new MessageDialog("Wrong start date", "Filter").ShowAsync(); return; } } if (filterEnd.Text != "") { if (DateTime.TryParse(filterEnd.Text, out newEnd)) { end = newEnd; } else { new MessageDialog("Wrong end date", "Filter").ShowAsync(); return; } } filterAction(start, end); }); flyOut.Content = filterPanel; flyOut.ShowAt((FrameworkElement)sender); }
private void FlyoutButtonPressed(object sender, RoutedEventArgs e) { Flyout.Hide(); }
private void TryShowFlyout(Flyout flyout, FrameworkElement location) { try { flyout.ShowAt(location); } catch (ArgumentException ex) { Debug.WriteLine("Error displaying flyout"); LoggingService.Log(ex, LoggingLevel.Critical); } }
private void RootAlbumItem_Holding(object sender, HoldingRoutedEventArgs e) { Flyout.ShowAttachedFlyout((Grid)sender); }
private void ButtonVolume_Click(object sender, RoutedEventArgs e) { var flyout = new Flyout(); flyout.Content = new VolumeControl(); flyout.Placement = FlyoutPlacementMode.Top; flyout.ShowAt(sender as FrameworkElement); }
public void Attach(Flyout flyout) { this.flyout = flyout; }