void ShowBrowser() { if (_browserVisible) { return; } BrowserGrid.Visibility = Visibility.Visible; if (_browser == null) { var executionMode = WebViewExecutionMode.SameThread; if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.WebViewExecutionMode", "SeparateProcess")) { executionMode = WebViewExecutionMode.SeparateProcess; } _browser = new WebView(executionMode); _browser.NavigationStarting += OnNavigationStarting; _browser.NavigationCompleted += OnNavigationCompleted; _browser.ScriptNotify += OnScriptNotify; BrowserContainer.Content = _browser; _browser.Navigate(new Uri(LOGIN_URL)); } _browserVisible = true; ShowBrowserStoryboard.Begin(); }
public MainPage() { InitializeComponent(); _currentView = ApplicationView.GetForCurrentView(); ButtonsInMultilineEditMode_StackPanel.Visibility = Visibility.Collapsed; _viewModel = DataContext as MainViewModel; _viewModel.LyricItems.CollectionChanged += LyricItems_CollectionChanged; _viewModel.SelectedItems = Lyrics_ListView.SelectedItems; _viewModel.UndoOperations.CollectionChanged += UndoOperations_CollectionChanged; _settings.PropertyChanged += Settings_PropertyChanged; GlobalKeyNotifier.KeyDown += WindowKeyDown; GlobalKeyNotifier.KeyUp += WindowKeyUp; MusicFileNotifier.FileChangeRequested += MusicFileChangeRequested; ImageFileNotifier.FileChanged += ImageFileChanged; if (!ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationViewMode") || !ApiInformation.IsEnumNamedValuePresent(typeof(ApplicationViewMode).FullName, "CompactOverlay") || !_currentView.IsViewModeSupported(ApplicationViewMode.CompactOverlay)) { MiniMode_StackPanel.Visibility = Visibility.Collapsed; } }
private ShareView() { InitializeComponent(); DataContext = TLContainer.Current.Resolve <ShareViewModel>(); //Title = Strings.Resources.ShareSendTo; PrimaryButtonText = Strings.Resources.Send; SecondaryButtonText = Strings.Resources.Close; var observable = Observable.FromEventPattern <TextChangedEventArgs>(SearchField, "TextChanged"); var throttled = observable.Throttle(TimeSpan.FromMilliseconds(Constants.TypingTimeout)).ObserveOnDispatcher().Subscribe(async x => { var items = ViewModel.Search; if (items != null && string.Equals(SearchField.Text, items.Query)) { await items.LoadMoreItemsAsync(2); await items.LoadMoreItemsAsync(3); } }); if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "BottomEdgeAlignedRight")) { MenuFlyout.Placement = FlyoutPlacementMode.BottomEdgeAlignedRight; } }
private void DetectSupportedInputScope() { InputScope scope = new InputScope(); InputScopeName scopeName = new InputScopeName(); // Check that the ChatWithEmoji value is present. // (It's present starting with Windows 10, version 1607, // the Target version for the app. This check returns false on earlier versions.) if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Input.InputScopeNameValue", "ChatWithoutEmoji")) { // Set new ChatWithoutEmoji InputScope if present. scopeName.NameValue = InputScopeNameValue.ChatWithoutEmoji; } else { // Fall back to Chat InputScope. scopeName.NameValue = InputScopeNameValue.Chat; } // Set InputScope on messaging TextBox. scope.Names.Add(scopeName); chatBox.InputScope = scope; // For this example, set the TextBox text to show the selected InputScope. chatBox.Text = chatBox.InputScope.Names[0].NameValue.ToString(); }
public SettingsNightModePage() { InitializeComponent(); DataContext = TLContainer.Current.Resolve <SettingsNightModeViewModel>(); // We have to do this as english copy contains a randomic \n at the end of the string. AutoNightLocation.Content = Strings.Resources.AutoNightLocation.TrimEnd('\n'); FromPicker.ClockIdentifier = GlobalizationPreferences.Clocks.FirstOrDefault(); ToPicker.ClockIdentifier = GlobalizationPreferences.Clocks.FirstOrDefault(); if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "BottomEdgeAlignedLeft")) { FromPicker.Placement = FlyoutPlacementMode.BottomEdgeAlignedLeft; ToPicker.Placement = FlyoutPlacementMode.BottomEdgeAlignedLeft; } //var sensor = LightSensor.GetDefault(); //if (sensor != null) //{ // Automatic.Visibility = Visibility.Visible; // AutomaticSeparator.Visibility = Visibility.Visible; // sensor.ReportInterval = 50000; // sensor.ReadingChanged += LightSensor_ReadingChanged; //} //else //{ // Automatic.Visibility = Visibility.Collapsed; // AutomaticSeparator.Visibility = Visibility.Collapsed; //} }
public static async Task RegisterTaskAsync() { bool isSystemAllow = false; if (ApiInformation.IsEnumNamedValuePresent(typeof(BackgroundAccessStatus).ToString(), "AllowedSubjectToSystemPolicy")) { switch (await BackgroundExecutionManager.RequestAccessAsync()) { case BackgroundAccessStatus.AlwaysAllowed: case BackgroundAccessStatus.AllowedSubjectToSystemPolicy: isSystemAllow = true; break; case BackgroundAccessStatus.Unspecified: case BackgroundAccessStatus.DeniedBySystemPolicy: case BackgroundAccessStatus.DeniedByUser: isSystemAllow = false; break; } } else { switch (await BackgroundExecutionManager.RequestAccessAsync()) { case BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity: case BackgroundAccessStatus.AllowedMayUseActiveRealTimeConnectivity: isSystemAllow = true; break; case BackgroundAccessStatus.Unspecified: case BackgroundAccessStatus.Denied: isSystemAllow = false; break; } } if (isSystemAllow) { var builder = new BackgroundTaskBuilder(); builder.Name = TASK_NAME; builder.TaskEntryPoint = typeof(Tasks.LiveTileBackgroundTask).FullName; builder.SetTrigger(new TimeTrigger(15, false)); builder.AddCondition(new SystemCondition(SystemConditionType.InternetAvailable)); builder.Register(); } else { MessageDialog message = new MessageDialog("You didn't allow this app to run in background.", "Permission Denied"); message.Commands.Add(new UICommand("Go to Settings", async(command) => { await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-backgroundapps")); })); message.Commands.Add(new UICommand("Cancel")); await message.ShowAsync(); } }
public static async void LeaveCompactOverlay() { if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.ViewManagement.ApplicationViewMode", "CompactOverlay")) { if (ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.CompactOverlay) { await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default); } } }
public SettingsThemesPage() { InitializeComponent(); DataContext = TLContainer.Current.Resolve<SettingsThemesViewModel>(); if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "BottomEdgeAlignedRight")) { MenuFlyout.Placement = FlyoutPlacementMode.BottomEdgeAlignedRight; } }
public static bool AreInteractionTrackerPointerWheelRedirectionModesAvailable() { if (s_areInteractionTrackerPointerWheelRedirectionModesAvailable == null) { s_areInteractionTrackerPointerWheelRedirectionModesAvailable = IsSystemDll() || IsRS5OrHigher() || (IsRS4OrHigher() && ApiInformation.IsEnumNamedValuePresent("Windows.UI.Composition.Interactions.VisualInteractionSourceRedirectionMode", "PointerWheelOnly")); } return(s_areInteractionTrackerPointerWheelRedirectionModesAvailable.Value); }
protected override void OnLaunched(LaunchActivatedEventArgs activationArgs) { // Use Reveal Focus on 1803+ if (ApiInformation.IsEnumNamedValuePresent(nameof(Windows.UI.Xaml.FocusVisualKind), nameof(FocusVisualKind.Reveal))) { FocusVisualKind = FocusVisualKind.Reveal; } // Start AppCenter AppCenter.Start(Constants.AppCenterUwpKey, typeof(Analytics), typeof(Crashes)); base.OnLaunched(activationArgs); }
public SettingsPage() { InitializeComponent(); DataContext = TLContainer.Current.Resolve <SettingsViewModel, ISettingsDelegate>(this); NavigationCacheMode = NavigationCacheMode.Required; Diagnostics.Text = $"Unigram " + GetVersion(); if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "BottomEdgeAlignedRight")) { PhotoFlyout.Placement = FlyoutPlacementMode.BottomEdgeAlignedRight; } }
public ExtraCommandBarFlyoutPage() { this.InitializeComponent(); if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "BottomEdgeAlignedLeft")) { TextCommandBarContextFlyout.Placement = FlyoutPlacementMode.BottomEdgeAlignedLeft; } else { TextCommandBarContextFlyout.Placement = FlyoutPlacementMode.Top; } if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "TopEdgeAlignedLeft")) { TextCommandBarSelectionFlyout.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; } else { TextCommandBarSelectionFlyout.Placement = FlyoutPlacementMode.Top; } if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "ContextFlyout")) { TextBox1.ContextFlyout = TextCommandBarContextFlyout; RichTextBlock1.ContextFlyout = TextCommandBarContextFlyout; } try { if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.TextBox", "SelectionFlyout")) { TextBox1.SelectionFlyout = TextCommandBarSelectionFlyout; } } catch (InvalidCastException) { // RS5 interfaces can change before release, so we need to make sure we don't crash if they do. } if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.RichTextBlock", "SelectionFlyout")) { RichTextBlock1.SelectionFlyout = TextCommandBarSelectionFlyout; } }
private void Emoji_Click(object sender, RoutedEventArgs e) { EmojiList.ItemsSource = Icons.Filters; EmojiList.SelectedItem = ViewModel.Icon; var flyout = FlyoutBase.GetAttachedFlyout(EmojiButton); if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "TopEdgeAlignedRight")) { flyout.ShowAt(EmojiButton, new FlyoutShowOptions { Placement = FlyoutPlacementMode.BottomEdgeAlignedRight }); } else { flyout.ShowAt(EmojiButton); } }
public void RaiseExpandCollapseAutomationEvent(ExpandCollapseState newState) { // Uno Doc: AutomationEvents not currently implemented so added an API check if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Automation.Peers.AutomationEvents", nameof(AutomationEvents.PropertyChanged))) { if (AutomationPeer.ListenerExists(AutomationEvents.PropertyChanged)) { ExpandCollapseState oldState = (newState == ExpandCollapseState.Expanded) ? ExpandCollapseState.Collapsed : ExpandCollapseState.Expanded; // if box_value(oldState) doesn't work here, use ReferenceWithABIRuntimeClassName to make Narrator unbox it. RaisePropertyChangedEvent(ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty, oldState, newState); } } }
private void Canvas_Tapped(object sender, TappedRoutedEventArgs e) { var uri = Video.Url; var provider = Embed?.Provider?.Name.ToLowerInvariant(); if (provider == "giphy") { var builder = new UriBuilder(uri) { Host = "i.giphy.com" }; uri = builder.Uri; } if (provider == "youtube") { var embedBuilder = new UriBuilder(uri); var query = QueryString.Parse(System.Net.WebUtility.UrlDecode(embedBuilder.Query ?? "").Trim('?')); query.Add("autoplay", "1"); embedBuilder.Query = query.ToString(); uri = embedBuilder.Uri; } var executionMode = WebViewExecutionMode.SameThread; if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.WebViewExecutionMode", "SeparateProcess")) { executionMode = WebViewExecutionMode.SeparateProcess; } var browser = new WebView(executionMode) { Source = uri, VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch }; browser.ContainsFullScreenElementChanged += Browser_ContainsFullScreenElementChanged; content.Children.Add(browser); posterContainer.Visibility = Visibility.Collapsed; }
public SettingsAppearancePage() { InitializeComponent(); DataContext = TLContainer.Current.Resolve <SettingsAppearanceViewModel>(); var preview = ElementCompositionPreview.GetElementVisual(Preview); preview.Clip = preview.Compositor.CreateInsetClip(); Message1.Mockup(Strings.Resources.FontSizePreviewLine1, Strings.Resources.FontSizePreviewName, Strings.Resources.FontSizePreviewReply, false, DateTime.Now.AddSeconds(-25)); Message2.Mockup(Strings.Resources.FontSizePreviewLine2, true, DateTime.Now); BackgroundPresenter.Update(ViewModel.SessionId, ViewModel.ProtoService, ViewModel.Aggregator); if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "BottomEdgeAlignedRight")) { MenuFlyout.Placement = FlyoutPlacementMode.BottomEdgeAlignedRight; } }
private void Menu_ContextRequested(object sender, RoutedEventArgs e) { var viewModel = ViewModel; if (viewModel == null) { return; } var item = viewModel.SelectedItem as GalleryContent; if (item == null) { return; } var flyout = new MenuFlyout(); flyout.CreateFlyoutItem(x => item.CanView, viewModel.ViewCommand, item, Strings.Resources.ShowInChat, new FontIcon { Glyph = Icons.Message }); flyout.CreateFlyoutItem(x => item.CanCopy, viewModel.CopyCommand, item, Strings.Resources.Copy, new FontIcon { Glyph = Icons.Copy }, Windows.System.VirtualKey.C); flyout.CreateFlyoutItem(x => item.CanSave, viewModel.SaveCommand, item, Strings.Additional.SaveAs, new FontIcon { Glyph = Icons.SaveAs }, Windows.System.VirtualKey.S); flyout.CreateFlyoutItem(x => viewModel.CanOpenWith, viewModel.OpenWithCommand, item, Strings.Resources.OpenInExternalApp, new FontIcon { Glyph = Icons.OpenIn }); flyout.CreateFlyoutItem(x => viewModel.CanDelete, viewModel.DeleteCommand, item, Strings.Resources.Delete, new FontIcon { Glyph = Icons.Delete }); if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "BottomEdgeAlignedRight")) { flyout.Placement = FlyoutPlacementMode.BottomEdgeAlignedRight; } flyout.ShowAt(sender as FrameworkElement); }
/// <summary> /// Initializes a new instance of the MainPage class. /// </summary> public MainPage() { InitializeComponent(); _navigationHelper = new NavigationHelper(this); _navigationHelper.LoadState += _navigationHelper_LoadState; _navigationHelper.SaveState += _navigationHelper_SaveState; // ReSharper disable once UseNameofExpression if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Symbol", "Share")) { ShareButton.Icon = new SymbolIcon(Symbol.Share); } if (ReorderGridAnimation.IsSupported) { ReorderGridAnimation.SetDuration(StickerGridView, 300); } if (!DataTransferManager.IsSupported() || AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Xbox") { ShareButton.Visibility = Visibility.Collapsed; } }
public TextCommandBarFlyoutPage() { this.InitializeComponent(); RichEditBox1.Document.SetText(Windows.UI.Text.TextSetOptions.None, "Lorem ipsum ergo sum"); Clipboard.ContentChanged += OnClipboardContentChanged; if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "BottomEdgeAlignedLeft")) { TextControlContextFlyout.Placement = FlyoutPlacementMode.BottomEdgeAlignedLeft; } else { TextControlContextFlyout.Placement = FlyoutPlacementMode.Top; } if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "TopEdgeAlignedLeft")) { TextControlSelectionFlyout.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; } else { TextControlSelectionFlyout.Placement = FlyoutPlacementMode.Top; } if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "ContextFlyout")) { TextBox1.ContextFlyout = TextControlContextFlyout; TextBlock1.ContextFlyout = TextControlContextFlyout; RichEditBox1.ContextFlyout = TextControlContextFlyout; RichTextBlock1.ContextFlyout = TextControlContextFlyout; PasswordBox1.ContextFlyout = TextControlContextFlyout; } try { if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.TextBox", "SelectionFlyout")) { TextBox1.SelectionFlyout = TextControlSelectionFlyout; } if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.TextBlock", "SelectionFlyout")) { TextBlock1.SelectionFlyout = TextControlSelectionFlyout; } if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.RichEditBox", "SelectionFlyout")) { RichEditBox1.SelectionFlyout = TextControlSelectionFlyout; } if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.RichTextBlock", "SelectionFlyout")) { RichTextBlock1.SelectionFlyout = TextControlSelectionFlyout; } if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.PasswordBox", "SelectionFlyout")) { PasswordBox1.SelectionFlyout = TextControlSelectionFlyout; } } catch (InvalidCastException) { // RS5 interfaces can change before release, so we need to make sure we don't crash if they do. } }
public CommandBarFlyoutPage() { this.InitializeComponent(); dynamicLabelTimer.Tick += DynamicLabelTimer_Tick; dynamicVisibilityTimer.Tick += DynamicVisibilityTimer_Tick; dynamicWidthTimer.Tick += DynamicWidthTimer_Tick; dynamicCommandTimer.Tick += DynamicCommandTimer_Tick; clearSecondaryCommandsTimer.Interval = new TimeSpan(0, 0, 3 /*sec*/); clearSecondaryCommandsTimer.Tick += ClearSecondaryCommandsTimer_Tick; clearSecondaryCommandsTimer.Interval = new TimeSpan(0, 0, 3 /*sec*/); clearPrimaryCommandsTimer.Tick += ClearPrimaryCommandsTimer_Tick; if (ApiInformation.IsTypePresent("Windows.UI.Xaml.Input.KeyboardAccelerator")) { UndoButton1.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); UndoButton2.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); UndoButton3.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); UndoButton4.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); UndoButton5.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); UndoButton6.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); UndoButton7.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); RedoButton1.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); RedoButton2.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); RedoButton3.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); RedoButton4.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); RedoButton5.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); RedoButton6.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); RedoButton7.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); SelectAllButton1.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); SelectAllButton2.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); SelectAllButton3.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); SelectAllButton4.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); SelectAllButton5.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); SelectAllButton6.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); SelectAllButton7.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); } if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "ContextFlyout")) { FlyoutTarget1.ContextFlyout = Flyout1; FlyoutTarget2.ContextFlyout = Flyout2; FlyoutTarget3.ContextFlyout = Flyout3; FlyoutTarget4.ContextFlyout = Flyout4; FlyoutTarget5.ContextFlyout = Flyout5; FlyoutTarget6.ContextFlyout = Flyout6; FlyoutTarget7.ContextFlyout = Flyout7; } if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "TopEdgeAlignedLeft")) { Flyout1.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; Flyout2.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; Flyout3.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; Flyout4.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; Flyout5.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; Flyout6.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; Flyout7.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; } }
public App() { // Initialize XAML Resources InitializeComponent(); // Check that we are not using the default theme, // if not change the requested theme to the users // picked theme. if (!SettingsService.Instance.IsDefaultTheme) { RequestedTheme = SettingsService.Instance.ThemeType; } // We want to use the controller if on xbox if (DeviceHelper.IsXbox) { RequiresPointerMode = ApplicationRequiresPointerMode.WhenRequested; } try { // Handle application crashes CrashHelper.HandleAppCrashes(this); } catch { } // Register Event Handlers EnteredBackground += AppEnteredBackground; LeavingBackground += AppLeavingBackground; Suspending += AppSuspending; // Used Reveal Focus on 1803+ if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.FocusVisualKind", nameof(FocusVisualKind.Reveal))) { FocusVisualKind = FocusVisualKind.Reveal; } // During the transition from foreground to background the // memory limit allowed for the application changes. The application // has a short time to respond by bringing its memory usage // under the new limit. MemoryManager.AppMemoryUsageLimitChanging += MemoryManager_AppMemoryUsageLimitChanging; // After an application is backgrounded it is expected to stay // under a memory target to maintain priority to keep running. // Subscribe to the event that informs the app of this change. MemoryManager.AppMemoryUsageIncreased += MemoryManager_AppMemoryUsageIncreased; // Run this code when a service is connected to SoundByte SoundByteService.Current.OnServiceConnected += (type, token) => { var vault = new PasswordVault(); // Add the password to the vault so we can access it when restarting the app string vaultName; switch (type) { case ServiceTypes.SoundCloud: case ServiceTypes.SoundCloudV2: vaultName = "SoundByte.SoundCloud"; break; case ServiceTypes.YouTube: vaultName = "SoundByte.YouTube"; break; case ServiceTypes.SoundByte: vaultName = "SoundByte.SoundByteV2"; break; default: vaultName = string.Empty; break; } if (string.IsNullOrEmpty(vaultName)) { return; } vault.Add(new PasswordCredential(vaultName, "Token", token.AccessToken)); vault.Add(new PasswordCredential(vaultName, "RefreshToken", string.IsNullOrEmpty(token.RefreshToken) ? "n/a" : token.RefreshToken)); vault.Add(new PasswordCredential(vaultName, "ExpireTime", string.IsNullOrEmpty(token.ExpireTime) ? "n/a" : token.ExpireTime)); // Track the connect event SimpleIoc.Default.GetInstance <ITelemetryService>().TrackEvent("Service Connected", new Dictionary <string, string> { { "Service", type.ToString() } }); }; // Run this code when a service is disconnected from SoundByte SoundByteService.Current.OnServiceDisconnected += async(type, reason) => { // Delete the vault depending on the service type switch (type) { case ServiceTypes.SoundCloud: case ServiceTypes.SoundCloudV2: SettingsService.Instance.DeleteAllFromVault("SoundByte.SoundCloud"); break; case ServiceTypes.YouTube: SettingsService.Instance.DeleteAllFromVault("SoundByte.YouTube"); break; case ServiceTypes.SoundByte: SettingsService.Instance.DeleteAllFromVault("SoundByte.SoundByteV2"); break; } // Track the disconnect event SimpleIoc.Default.GetInstance <ITelemetryService>().TrackEvent("Service Disconnected", new Dictionary <string, string> { { "Service", type.ToString() }, { "Reason", reason } }); // Attempt to log the user back in if (!string.IsNullOrEmpty(reason)) { // Navigate to the login page NavigateTo(typeof(AccountView), new AccountView.AccountViewParams { Service = type, }); // Tell the user what happened await NavigationService.Current.CallMessageDialogAsync("One of your accounts has been logged out. SoundByte will now redirect you to the login page.", "Account disconnected"); } }; }
public CommandBarFlyoutPage() { this.InitializeComponent(); if (ApiInformation.IsTypePresent("Windows.UI.Xaml.Input.KeyboardAccelerator")) { UndoButton1.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); UndoButton2.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); UndoButton3.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); UndoButton4.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); UndoButton5.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); UndoButton6.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); UndoButton7.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); RedoButton1.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); RedoButton2.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); RedoButton3.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); RedoButton4.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); RedoButton5.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); RedoButton6.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); RedoButton7.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); SelectAllButton1.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); SelectAllButton2.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); SelectAllButton3.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); SelectAllButton4.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); SelectAllButton5.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); SelectAllButton6.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); SelectAllButton7.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); } if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "ContextFlyout")) { FlyoutTarget1.ContextFlyout = Flyout1; FlyoutTarget2.ContextFlyout = Flyout2; FlyoutTarget3.ContextFlyout = Flyout3; FlyoutTarget4.ContextFlyout = Flyout4; FlyoutTarget5.ContextFlyout = Flyout5; FlyoutTarget6.ContextFlyout = Flyout6; FlyoutTarget7.ContextFlyout = Flyout7; } if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "TopEdgeAlignedLeft")) { Flyout1.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; Flyout2.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; Flyout3.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; Flyout4.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; Flyout5.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; Flyout6.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; Flyout7.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft; } }
public static WindowDisplayMode GetForCurrentView() { ApplicationView applicationView = ApplicationView.GetForCurrentView(); switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily) { case "Windows.Desktop": { if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.ViewManagement.ApplicationViewMode", "CompactOverlay") && applicationView.ViewMode == ApplicationViewMode.CompactOverlay) { return(WindowDisplayMode.CompactOverlay); } if (LockApplicationHost.GetForCurrentView() != null) { // When an application is in kiosk mode, ApplicationView.ISFullScreenMode will return false // even if the application is in fact displayed full screen. We need to check manually if an application is // in kiosk mode and force the result to FullScreen. return(WindowDisplayMode.FullScreen); } if (IsMixedReality()) { return(WindowDisplayMode.Windowed); } else { if (applicationView.IsFullScreenMode) { return(WindowDisplayMode.FullScreen); } else { switch (UIViewSettings.GetForCurrentView().UserInteractionMode) { case UserInteractionMode.Mouse: #pragma warning disable CS0618 // Type or member is obsolete return(applicationView.IsFullScreen ? WindowDisplayMode.Maximized : WindowDisplayMode.Windowed); #pragma warning restore CS0618 // Type or member is obsolete case UserInteractionMode.Touch: { if (applicationView.AdjacentToLeftDisplayEdge) { if (applicationView.AdjacentToRightDisplayEdge) { return(WindowDisplayMode.FullScreenTabletMode); } else { return(WindowDisplayMode.SnappedLeft); } } else { return(WindowDisplayMode.SnappedRight); } } default: return(WindowDisplayMode.Unknown); } } } } case "Windows.Mobile": { if (UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Mouse) { // Continuum return(applicationView.IsFullScreenMode ? WindowDisplayMode.Maximized : WindowDisplayMode.Windowed); } else { return(WindowDisplayMode.FullScreen); } } case "Windows.Holographic": { return(WindowDisplayMode.Windowed); } case "Windows.Xbox": case "Windows.IoT": { return(WindowDisplayMode.FullScreen); } case "Windows.Team": { if (applicationView.AdjacentToLeftDisplayEdge) { if (applicationView.AdjacentToRightDisplayEdge) { return(WindowDisplayMode.FullScreenTabletMode); } else { return(WindowDisplayMode.SnappedLeft); } } else { return(WindowDisplayMode.SnappedRight); } } default: return(WindowDisplayMode.Unknown); } }
private void Menu_ContextRequested(object sender, RoutedEventArgs e) { var flyout = new MenuFlyout(); var chat = ViewModel.Chat; if (chat == null) { return; } if (chat.Type is ChatTypePrivate || chat.Type is ChatTypeSecret) { var userId = chat.Type is ChatTypePrivate privata ? privata.UserId : chat.Type is ChatTypeSecret secret ? secret.UserId : 0; if (userId != ViewModel.CacheService.Options.MyId) { var user = ViewModel.CacheService.GetUser(userId); if (user == null) { return; } var fullInfo = ViewModel.CacheService.GetUserFull(userId); if (fullInfo == null) { return; } //if (fullInfo.CanBeCalled) //{ // callItem = menu.addItem(call_item, R.drawable.ic_call_white_24dp); //} if (user.IsContact) { flyout.CreateFlyoutItem(ViewModel.ShareCommand, Strings.Resources.ShareContact, new FontIcon { Glyph = Icons.Share }); flyout.CreateFlyoutItem(fullInfo.IsBlocked ? ViewModel.UnblockCommand : ViewModel.BlockCommand, fullInfo.IsBlocked ? Strings.Resources.Unblock : Strings.Resources.BlockContact, new FontIcon { Glyph = fullInfo.IsBlocked ? Icons.Banned : Icons.Banned }); flyout.CreateFlyoutItem(ViewModel.EditCommand, Strings.Resources.EditContact, new FontIcon { Glyph = Icons.Edit }); flyout.CreateFlyoutItem(ViewModel.DeleteCommand, Strings.Resources.DeleteContact, new FontIcon { Glyph = Icons.Delete }); } else { if (user.Type is UserTypeBot bot) { if (bot.CanJoinGroups) { flyout.CreateFlyoutItem(ViewModel.InviteCommand, Strings.Resources.BotInvite, new FontIcon { Glyph = Icons.AddUser }); } flyout.CreateFlyoutItem(null, Strings.Resources.BotShare, new FontIcon { Glyph = Icons.Share }); } else { flyout.CreateFlyoutItem(ViewModel.AddCommand, Strings.Resources.AddContact, new FontIcon { Glyph = Icons.AddUser }); } if (user.PhoneNumber.Length > 0) { flyout.CreateFlyoutItem(ViewModel.ShareCommand, Strings.Resources.ShareContact, new FontIcon { Glyph = Icons.Share }); flyout.CreateFlyoutItem(fullInfo.IsBlocked ? ViewModel.UnblockCommand : ViewModel.BlockCommand, fullInfo.IsBlocked ? Strings.Resources.Unblock : Strings.Resources.BlockContact, new FontIcon { Glyph = fullInfo.IsBlocked ? Icons.Banned : Icons.Banned }); } else { if (user.Type is UserTypeBot) { flyout.CreateFlyoutItem(fullInfo.IsBlocked ? ViewModel.UnblockCommand : ViewModel.BlockCommand, fullInfo.IsBlocked ? Strings.Resources.BotRestart : Strings.Resources.BotStop, new FontIcon { Glyph = fullInfo.IsBlocked ? Icons.Banned : Icons.Banned }); } else { flyout.CreateFlyoutItem(fullInfo.IsBlocked ? ViewModel.UnblockCommand : ViewModel.BlockCommand, fullInfo.IsBlocked ? Strings.Resources.Unblock : Strings.Resources.BlockContact, new FontIcon { Glyph = fullInfo.IsBlocked ? Icons.Banned : Icons.Banned }); } } } } else { flyout.CreateFlyoutItem(ViewModel.ShareCommand, Strings.Resources.ShareContact, new FontIcon { Glyph = Icons.Share }); } } //if (writeButton != null) //{ // boolean isChannel = ChatObject.isChannel(currentChat); // if (isChannel && !ChatObject.canChangeChatInfo(currentChat) || !isChannel && !currentChat.admin && !currentChat.creator && currentChat.admins_enabled) // { // writeButton.setImageResource(R.drawable.floating_message); // writeButton.setPadding(0, AndroidUtilities.dp(3), 0, 0); // } // else // { // writeButton.setImageResource(R.drawable.floating_camera); // writeButton.setPadding(0, 0, 0, 0); // } //} if (chat.Type is ChatTypeSupergroup super) { var supergroup = ViewModel.ProtoService.GetSupergroup(super.SupergroupId); if (supergroup == null) { return; } if (supergroup.Status is ChatMemberStatusCreator || supergroup.Status is ChatMemberStatusAdministrator) { if (supergroup.IsChannel) { flyout.CreateFlyoutItem(ViewModel.EditCommand, Strings.Resources.ManageChannelMenu, new FontIcon { Glyph = Icons.Edit }); } else { flyout.CreateFlyoutItem(ViewModel.EditCommand, Strings.Resources.ManageGroupMenu, new FontIcon { Glyph = Icons.Edit }); } } var fullInfo = ViewModel.ProtoService.GetSupergroupFull(super.SupergroupId); if (super.IsChannel) { if (fullInfo != null && fullInfo.CanViewStatistics) { flyout.CreateFlyoutItem(ViewModel.StatisticsCommand, Strings.Resources.Statistics, new FontIcon { Glyph = Icons.Statistics }); } } else { flyout.CreateFlyoutItem(ViewModel.MembersCommand, Strings.Resources.SearchMembers, new FontIcon { Glyph = Icons.Search }); if (!(supergroup.Status is ChatMemberStatusCreator) && !(supergroup.Status is ChatMemberStatusLeft) && !(supergroup.Status is ChatMemberStatusBanned)) { flyout.CreateFlyoutItem(ViewModel.DeleteCommand, Strings.Resources.LeaveMegaMenu, new FontIcon { Glyph = Icons.Delete }); } } } else if (chat.Type is ChatTypeBasicGroup basic) { var basicGroup = ViewModel.ProtoService.GetBasicGroup(basic.BasicGroupId); if (basicGroup == null) { return; } if (chat.Permissions.CanChangeInfo || basicGroup.Status is ChatMemberStatusCreator || basicGroup.Status is ChatMemberStatusAdministrator) { flyout.CreateFlyoutItem(ViewModel.EditCommand, Strings.Resources.ChannelEdit, new FontIcon { Glyph = Icons.Edit }); } flyout.CreateFlyoutItem(ViewModel.MembersCommand, Strings.Resources.SearchMembers, new FontIcon { Glyph = Icons.Search }); flyout.CreateFlyoutItem(ViewModel.DeleteCommand, Strings.Resources.DeleteAndExit, new FontIcon { Glyph = Icons.Delete }); } flyout.CreateFlyoutItem(null, Strings.Resources.AddShortcut, new FontIcon { Glyph = Icons.Pin }); if (flyout.Items.Count > 0) { if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode", "BottomEdgeAlignedRight")) { flyout.Placement = FlyoutPlacementMode.BottomEdgeAlignedRight; } flyout.ShowAt((Button)sender); } }