public static bool isAPIContractExist(ushort number) { return(ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", number)); }
private static bool InitMessageWebSocketReceiveModeSupported() { return(ApiInformation.IsPropertyPresent( "Windows.Networking.Sockets.MessageWebSocketControl", "ReceiveMode")); }
private async void MainPage_Loaded(object sender, RoutedEventArgs e) { Windows.Devices.Radios.RadioAccessStatus s = await Windows.Devices.Radios.Radio.RequestAccessAsync(); //await Windows.Devices.WiFi.WiFiAdapter.RequestAccessAsync(); /*string rsel = Windows.Devices.Radios.Radio.GetDeviceSelector(); * foreach(DeviceInformation di in await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(rsel)) * { * Debug.WriteLine(di.Name); * await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => * { * Radio r = await Windows.Devices.Radios.Radio.FromIdAsync(di.Id); * Debug.WriteLine(r.Name); * Debug.WriteLine(r.Kind); * Debug.WriteLine(r.State); * }); * }*/ var radios = await Windows.Devices.Radios.Radio.GetRadiosAsync(); foreach (Windows.Devices.Radios.Radio r in radios) { System.Diagnostics.Debug.WriteLine(r.Name); Debug.WriteLine(r.Kind); Debug.WriteLine(r.State); } p = await InTheHand.Devices.Sensors.Pedometer.GetDefaultAsync(); if (p != null) { var r = p.GetCurrentReadings(); foreach (KeyValuePair <InTheHand.Devices.Sensors.PedometerStepKind, InTheHand.Devices.Sensors.PedometerReading> readingentry in r) { System.Diagnostics.Debug.WriteLine(readingentry.Value.Timestamp.ToString() + " " + readingentry.Value.CumulativeSteps.ToString() + " " + readingentry.Value.StepKind); } } var sel = InTheHand.Devices.Bluetooth.BluetoothLEDevice.GetDeviceSelector(); //var sel = Windows.Devices.Bluetooth.GenericAttributeProfile.GattDeviceService.GetDeviceSelectorFromUuid(InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattServiceUuids.DeviceInformation); var devs = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(sel); foreach (DeviceInformation di in devs) { //var s = await Windows.Devices.Bluetooth.GenericAttributeProfile.GattDeviceService.FromIdAsync(di.Id); //var d = await InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattDeviceService.FromIdAsync(di.Id); var d = await InTheHand.Devices.Bluetooth.BluetoothLEDevice.FromIdAsync(di.Id); foreach (InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattDeviceService serv in d.GattServices) { System.Diagnostics.Debug.WriteLine(serv.Uuid.ToString()); if (serv.Uuid == GattServiceUuids.DeviceInformation) { foreach (InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattCharacteristic ch in serv.GetCharacteristics(GattCharacteristicUuids.ManufacturerNameString)) { if (ch.CharacteristicProperties.HasFlag(GattCharacteristicProperties.Notify)) { ch.ValueChanged += MainPage_ValueChanged; } InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattReadResult rr = await ch.ReadValueAsync(); var vl = rr.Value; System.Diagnostics.Debug.WriteLine(System.Text.Encoding.UTF8.GetString(vl)); } } foreach (InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattCharacteristic c in serv.GetAllCharacteristics()) { System.Diagnostics.Debug.WriteLine(c.Uuid.ToString()); /*foreach(InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattDescriptor ds in c.GetAllDescriptors()) * { * InTheHand.Devices.Bluetooth.GenericAttributeProfile.GattReadResult r = await ds.ReadValueAsync(); * object raw = r.Value; * }*/ } } System.Diagnostics.Debug.WriteLine(di.Name); } if (ApiInformation.IsTypePresent("Windows.UI.ViewManagment.StatusBar")) { StatusBar.GetForCurrentView()?.ProgressIndicator.HideAsync(); } }
public PullToRefreshPage() { this.InitializeComponent(); if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 6)) { rc2 = new RefreshContainer(); rc2.RefreshRequested += new TypedEventHandler <RefreshContainer, RefreshRequestedEventArgs>(rc2_RefreshRequested); rv2 = new RefreshVisualizer(); rv2.RefreshStateChanged += new TypedEventHandler <RefreshVisualizer, RefreshStateChangedEventArgs>(rv2_RefreshStateChanged); Image ptrImage = new Image(); AccessibilitySettings accessibilitySettings = new AccessibilitySettings(); // Checking light theme if ((ThemeHelper.RootTheme == ElementTheme.Light || Application.Current.RequestedTheme == ApplicationTheme.Light) && !accessibilitySettings.HighContrast) { ptrImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/SunBlack.png")); } // Checking high contrast theme else if (accessibilitySettings.HighContrast && accessibilitySettings.HighContrastScheme.Equals("High Contrast Black")) { ptrImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/SunBlack.png")); } else { ptrImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/SunWhite.png")); } ptrImage.Width = 35; ptrImage.Height = 35; rv2.Content = ptrImage; rc2.Visualizer = rv2; ListView lv2 = new ListView(); lv2.Width = 200; lv2.Height = 200; lv2.BorderThickness = new Thickness(1); lv2.HorizontalAlignment = HorizontalAlignment.Center; lv2.BorderBrush = (Brush)Application.Current.Resources["TextControlBorderBrush"]; rc2.Content = lv2; Ex2Grid.Children.Add(rc2); Grid.SetRow(rc2, 1); Grid.SetRow(lv2, 1); timer1.Interval = new TimeSpan(0, 0, 0, 0, 500); timer1.Tick += Timer1_Tick; timer2.Interval = new TimeSpan(0, 0, 0, 0, 800); timer2.Tick += Timer2_Tick; foreach (var c in @"AcrylicBrush ColorPicker NavigationView ParallaxView PersonPicture PullToRefreshPage RatingsControl RevealBrush TreeView".Split(' ')) { items1.Add(c); } lv.ItemsSource = items1; foreach (var c in @"Mike Ben Barbra Claire Justin Shawn Drew Lili".Split(' ')) { items2.Add(c); } lv2.ItemsSource = items2; this.Loaded += PullToRefreshPage_Loaded; } }
private void Search_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.InRecycleQueue) { //var photo = content.Children[0] as ProfilePicture; //photo.Source = null; return; } var result = args.Item as SearchResult; var chat = result.Chat; var user = result.User ?? ViewModel.ProtoService.GetUser(chat); if (user == null) { return; } var content = args.ItemContainer.ContentTemplateRoot as Grid; if (content == null) { return; } if (args.Phase == 0) { var title = content.Children[1] as TextBlock; title.Text = user.GetFullName(); } else if (args.Phase == 1) { var subtitle = content.Children[2] as TextBlock; if (result.IsPublic) { subtitle.Text = $"@{user.Username}"; } else { subtitle.Text = LastSeenConverter.GetLabel(user, true); } if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.TextBlock", "TextHighlighters")) { if (subtitle.Text.StartsWith($"@{result.Query}", StringComparison.OrdinalIgnoreCase)) { var highligher = new TextHighlighter(); highligher.Foreground = new SolidColorBrush(Colors.Red); highligher.Background = new SolidColorBrush(Colors.Transparent); highligher.Ranges.Add(new TextRange { StartIndex = 1, Length = result.Query.Length }); subtitle.TextHighlighters.Add(highligher); } else { subtitle.TextHighlighters.Clear(); } } } else if (args.Phase == 2) { var photo = content.Children[0] as ProfilePicture; photo.Source = PlaceholderHelper.GetUser(ViewModel.ProtoService, user, 36, 36); } if (args.Phase < 2) { args.RegisterUpdateCallback(Search_ContainerContentChanging); } args.Handled = true; }
private void SetupCommandBarFlyoutTest(out CommandBarFlyout flyout, out Button flyoutTarget) { CommandBarFlyout commandBarFlyout = null; Button commandBarFlyoutTarget = null; RunOnUIThread.Execute(() => { commandBarFlyout = new CommandBarFlyout() { Placement = FlyoutPlacementMode.Right }; commandBarFlyout.PrimaryCommands.Add(new AppBarButton() { Icon = new SymbolIcon(Symbol.Cut) }); commandBarFlyout.PrimaryCommands.Add(new AppBarButton() { Icon = new SymbolIcon(Symbol.Copy) }); commandBarFlyout.PrimaryCommands.Add(new AppBarButton() { Icon = new SymbolIcon(Symbol.Paste) }); commandBarFlyout.PrimaryCommands.Add(new AppBarButton() { Icon = new SymbolIcon(Symbol.Bold) }); commandBarFlyout.PrimaryCommands.Add(new AppBarButton() { Icon = new SymbolIcon(Symbol.Italic) }); commandBarFlyout.PrimaryCommands.Add(new AppBarButton() { Icon = new SymbolIcon(Symbol.Underline) }); AppBarButton undoButton = new AppBarButton() { Label = "Undo", Icon = new SymbolIcon(Symbol.Undo) }; commandBarFlyout.SecondaryCommands.Add(undoButton); AppBarButton redoButton = new AppBarButton() { Label = "Redo", Icon = new SymbolIcon(Symbol.Redo) }; commandBarFlyout.SecondaryCommands.Add(redoButton); AppBarButton selectAllButton = new AppBarButton() { Label = "Select all" }; commandBarFlyout.SecondaryCommands.Add(selectAllButton); if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "KeyboardAccelerators")) { undoButton.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Z, Modifiers = VirtualKeyModifiers.Control }); redoButton.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.Y, Modifiers = VirtualKeyModifiers.Control }); selectAllButton.KeyboardAccelerators.Add(new KeyboardAccelerator() { Key = VirtualKey.A, Modifiers = VirtualKeyModifiers.Control }); } commandBarFlyoutTarget = new Button() { Content = "Click for flyout" }; }); TestUtilities.SetAsVisualTreeRoot(commandBarFlyoutTarget); flyout = commandBarFlyout; flyoutTarget = commandBarFlyoutTarget; }
public IEnumerable <ShellProfile> GetPreinstalledShellProfiles() { return(new[] { new ShellProfile { Id = GetDefaultShellProfileId(), Name = "Powershell", MigrationVersion = ShellProfile.CurrentMigrationVersion, Arguments = string.Empty, Location = @"C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe", PreInstalled = true, WorkingDirectory = string.Empty, UseConPty = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8), // Windows 10 1903+ UseBuffer = false, EnvironmentVariables = new Dictionary <string, string> { ["TERM"] = "xterm-256color" }, KeyBindings = new [] { new KeyBinding { Command = GetDefaultShellProfileId().ToString(), Ctrl = true, Alt = true, Shift = false, Meta = false, Key = (int)ExtendedVirtualKey.Number1 } } }, new ShellProfile { Id = Guid.Parse("ab942a61-7673-4755-9bd8-765aff91d9a3"), Name = "CMD", MigrationVersion = ShellProfile.CurrentMigrationVersion, Arguments = string.Empty, Location = @"C:\Windows\System32\cmd.exe", PreInstalled = true, WorkingDirectory = string.Empty, UseConPty = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 7), // Windows 10 1809+ UseBuffer = true, EnvironmentVariables = new Dictionary <string, string> { ["TERM"] = "xterm-256color" }, KeyBindings = new [] { new KeyBinding { Command = "ab942a61-7673-4755-9bd8-765aff91d9a3", Ctrl = true, Alt = true, Shift = false, Meta = false, Key = (int)ExtendedVirtualKey.Number2 } } }, new ShellProfile { Id = Guid.Parse("e5785ad6-584f-40cb-bdcd-d5b3b3953e7f"), Name = "WSL", MigrationVersion = ShellProfile.CurrentMigrationVersion, Arguments = string.Empty, Location = @"C:\windows\system32\wsl.exe", PreInstalled = true, WorkingDirectory = string.Empty, UseConPty = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 7), // Windows 10 1809+ UseBuffer = true, //TODO: Set to false if the buffer causes issues with WSL. EnvironmentVariables = new Dictionary <string, string> { ["TERM"] = "xterm-256color" }, KeyBindings = new [] { new KeyBinding { Command = "e5785ad6-584f-40cb-bdcd-d5b3b3953e7f", Ctrl = true, Alt = true, Shift = false, Meta = false, Key = (int)ExtendedVirtualKey.Number3 } } } }); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected async override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG // enable if desired... //if (Debugger.IsAttached) //{ // DebugSettings.EnableFrameRateCounter = true; //} #endif Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // hide windows phone status bar if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0)) { var statusBar = StatusBar.GetForCurrentView(); await statusBar.HideAsync(); } // change color of uwp title bar if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView")) { var titleBar = ApplicationView.GetForCurrentView().TitleBar; if (titleBar != null) { var desiredColor = Color.FromArgb(255, 00, 96, 180); // deep blue titleBar.BackgroundColor = desiredColor; titleBar.ButtonBackgroundColor = desiredColor; titleBar.ForegroundColor = Colors.White; titleBar.ButtonForegroundColor = Colors.White; } } Initialize(); // initiliaze Caliburn.Micro Xamarin.Forms.Forms.Init(e, RendererAssemblies()); // TODO: Initialize other xamarin.form 3rd party components if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); }
private async Task UpdateNotiFile() { // Check Permissions if (!ApiInformation.IsTypePresent("Windows.UI.Notifications.Management.UserNotificationListener")) { Debug.WriteLine("IsTypePresent: NG"); return; } Debug.WriteLine("IsTypePresent: OK"); UserNotificationListener listener = UserNotificationListener.Current; Debug.Write("listener: "); Debug.WriteLine(listener); while (true) { // Read Notifications try { UserNotificationListenerAccessStatus accessStatus = await listener.RequestAccessAsync(); Debug.Write("accessStatus: "); Debug.WriteLine(accessStatus); if (accessStatus != UserNotificationListenerAccessStatus.Allowed) { Debug.WriteLine("アクセス拒否"); return; } Debug.WriteLine("アクセス許可"); IReadOnlyList <UserNotification> notifs = await listener.GetNotificationsAsync(NotificationKinds.Toast); // Write to Download/App3 Windows.Storage.StorageFile file = await DownloadsFolder.CreateFileAsync("notifications.txt"); // await Windows.Storage.FileIO.WriteTextAsync(file, "Example of writing a string\r\n"); // Append a list of strings, one per line, to the file var listOfStrings = new List <string> { }; foreach (var n in notifs) { NotificationBinding toastBinding = n.Notification.Visual.GetBinding(KnownNotificationBindings.ToastGeneric); if (toastBinding != null) { IReadOnlyList <AdaptiveNotificationText> textElements = toastBinding.GetTextElements(); string titleText = textElements.FirstOrDefault()?.Text; string bodyText = string.Join("\n", textElements.Skip(1).Select(t => t.Text)); Debug.Write("Title:"); Debug.WriteLine(titleText); Debug.Write("Body:"); Debug.WriteLine(bodyText); int MsgType = GetNotiType(n.AppInfo.DisplayInfo.DisplayName); if (MsgType != -1) { listOfStrings.Add(String.Format("{0}", MsgType)); } // await Windows.Storage.FileIO.WriteTextAsync(file, String.Format("{0}, {1}\n", n.AppInfo.DisplayInfo.DisplayName, titleText)); } } await Windows.Storage.FileIO.AppendLinesAsync(file, listOfStrings); // each entry in the list is written to the file on its own line. await Task.Delay(TimeSpan.FromSeconds(1)); } catch (Exception ex) { } } }
/// <summary> /// Open a connection with the Servo Pi /// </summary> /// <returns></returns> /// <example>servopi.Connect();</example> public async Task Connect() { if (IsConnected) { return; // Already connected } if (!ApiInformation.IsTypePresent("Windows.Devices.I2c.I2cDevice")) { return; // This system does not support this feature: can't connect } /* Initialize the I2C bus */ try { var aqs = I2cDevice.GetDeviceSelector(ABE_Helpers.I2C_CONTROLLER_NAME); // Find the selector string for the I2C bus controller var dis = await DeviceInformation.FindAllAsync(aqs); // Find the I2C bus controller device with our selector string if (dis.Count == 0) { return; // Controller not found } var settings = new I2cConnectionSettings(Address) { BusSpeed = I2cBusSpeed.FastMode }; i2cbus = await I2cDevice.FromIdAsync(dis[0].Id, settings); /* Create an I2cDevice with our selected bus controller and I2C settings */ if (i2cbus != null) { // Connection is established so set IsConnected to true IsConnected = true; helper.WriteI2CByte(i2cbus, MODE1, 0x00); // Check to see if the output pin has been set and if so try to connect to the GPIO pin on the Raspberry Pi if (OutputEnablePin != 0) { gpio = GpioController.GetDefault(); if (gpio != null) { GpioOpenStatus status; gpio.TryOpenPin(OutputEnablePin, GpioSharingMode.Exclusive, out pin, out status); if (status == GpioOpenStatus.PinOpened) { // Latch HIGH value first. This ensures a default value when the pin is set as output pin.Write(GpioPinValue.High); // Set the IO direction as output pin.SetDriveMode(GpioPinDriveMode.Output); } } } // Fire the Connected event handler Connected?.Invoke(this, EventArgs.Empty); } else { IsConnected = false; } } catch (Exception ex) { IsConnected = false; throw new Exception("I2C Initialization Failed", ex); } }
private void ProcessRichText(TLRichTextBase text, Span span) { switch (text) { case TLTextPlain plainText: if (GetIsStrikethrough(span)) { span.Inlines.Add(new Run { Text = StrikethroughFallback(plainText.Text) }); } else { span.Inlines.Add(new Run { Text = plainText.Text }); } break; case TLTextConcat concatText: foreach (var concat in concatText.Texts) { var concatRun = new Span(); span.Inlines.Add(concatRun); ProcessRichText(concat, concatRun); } break; case TLTextBold boldText: span.FontWeight = FontWeights.SemiBold; ProcessRichText(boldText.Text, span); break; case TLTextEmail emailText: ProcessRichText(emailText.Text, span); break; case TLTextFixed fixedText: span.FontFamily = new FontFamily("Consolas"); ProcessRichText(fixedText.Text, span); break; case TLTextItalic italicText: span.FontStyle |= FontStyle.Italic; ProcessRichText(italicText.Text, span); break; case TLTextStrike strikeText: if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Documents.TextElement", "TextDecorations")) { span.TextDecorations |= TextDecorations.Strikethrough; ProcessRichText(strikeText.Text, span); } else { SetIsStrikethrough(span, true); ProcessRichText(strikeText.Text, span); } break; case TLTextUnderline underlineText: if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Documents.TextElement", "TextDecorations")) { span.TextDecorations |= TextDecorations.Underline; ProcessRichText(underlineText.Text, span); } else { var underline = new Underline(); span.Inlines.Add(underline); ProcessRichText(underlineText.Text, underline); } break; case TLTextUrl urlText: var hyperlink = new Hyperlink { UnderlineStyle = UnderlineStyle.None }; //span.Inlines.Add(new Run { Text = " " }); span.Inlines.Add(hyperlink); //span.Inlines.Add(new Run { Text = " " }); hyperlink.Click += (s, args) => Hyperlink_Click(urlText); ProcessRichText(urlText.Text, hyperlink); break; case TLTextEmpty emptyText: break; } }
public static bool IsNewerOrEqual(Version Version) { return(ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", (ushort)Version)); }
public async void TakeScreenshotWithDelay() { // 3 second countdown for (int i = 3; i > 0; i--) { ScreenshotStatusTextBlock.Text = i.ToString(); await Task.Delay(1000); } ScreenshotStatusTextBlock.Text = "Image captured"; // AppRecordingManager is desktop-only, and its use here is quite hacky, // but it is able to capture popups (though not theme shadows). bool isAppRecordingPresent = ApiInformation.IsTypePresent("Windows.Media.AppRecording.AppRecordingManager"); if (!isAppRecordingPresent) { // Better than doing nothing TakeScreenshot(); } else { var manager = AppRecordingManager.GetDefault(); if (manager.GetStatus().CanRecord) { var result = await manager.SaveScreenshotToFilesAsync( ApplicationData.Current.LocalFolder, "appScreenshot", AppRecordingSaveScreenshotOption.HdrContentVisible, manager.SupportedScreenshotMediaEncodingSubtypes); if (result.Succeeded) { // Open the screenshot back up var screenshotFile = await ApplicationData.Current.LocalFolder.GetFileAsync("appScreenshot.png"); using (var stream = await screenshotFile.OpenAsync(FileAccessMode.Read)) { var decoder = await BitmapDecoder.CreateAsync(stream); // Find the control in the picture GeneralTransform t = ControlPresenter.TransformToVisual(Window.Current.Content); Point pos = t.TransformPoint(new Point(0, 0)); ; if (!CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar) { // Add the height of the title bar, which I really wish was programmatically available anywhere. pos.Y += 32.0; } // Crop the screenshot to the control area var transform = new BitmapTransform() { Bounds = new BitmapBounds() { X = (uint)(Math.Ceiling(pos.X)) + 1, // Avoid the 1px window border Y = (uint)(Math.Ceiling(pos.Y)) + 1, Width = (uint)ControlPresenter.ActualWidth - 1, // Rounding issues -- this avoids capturing the control border Height = (uint)ControlPresenter.ActualHeight - 1 } }; var softwareBitmap = await decoder.GetSoftwareBitmapAsync( decoder.BitmapPixelFormat, BitmapAlphaMode.Ignore, transform, ExifOrientationMode.IgnoreExifOrientation, ColorManagementMode.DoNotColorManage); // Save the cropped picture var file = await ApplicationData.Current.LocalFolder.CreateFileAsync(GetBestScreenshotName(), CreationCollisionOption.ReplaceExisting); using (var outStream = await file.OpenAsync(FileAccessMode.ReadWrite)) { BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, outStream); encoder.SetSoftwareBitmap(softwareBitmap); await encoder.FlushAsync(); } } // Delete intermediate file await screenshotFile.DeleteAsync(); } } } await Task.Delay(1000); ScreenshotStatusTextBlock.Text = ""; }
public void Configure() { InitializeLayer(); container.Reset(); // .SingleIstance() is required to register a singleton service. container.ContainerBuilder.RegisterType <MTProtoService>().As <IMTProtoService>().SingleInstance(); container.ContainerBuilder.RegisterType <TelegramEventAggregator>().As <ITelegramEventAggregator>().SingleInstance(); container.ContainerBuilder.RegisterType <InMemoryCacheService>().As <ICacheService>().SingleInstance(); container.ContainerBuilder.RegisterType <DeviceInfoService>().As <IDeviceInfoService>().SingleInstance(); container.ContainerBuilder.RegisterType <UpdatesService>().As <IUpdatesService>().SingleInstance(); container.ContainerBuilder.RegisterType <TransportService>().As <ITransportService>().SingleInstance(); container.ContainerBuilder.RegisterType <ConnectionService>().As <IConnectionService>().SingleInstance(); // Files container.ContainerBuilder.RegisterType <DownloadFileManager>().As <IDownloadFileManager>().SingleInstance(); container.ContainerBuilder.Register((ctx) => new DownloadDocumentFileManager(ctx.Resolve <ITelegramEventAggregator>(), ctx.Resolve <IMTProtoService>(), ctx.Resolve <IStatsService>(), DataType.Audios)).As <IDownloadAudioFileManager>().SingleInstance(); container.ContainerBuilder.Register((ctx) => new DownloadDocumentFileManager(ctx.Resolve <ITelegramEventAggregator>(), ctx.Resolve <IMTProtoService>(), ctx.Resolve <IStatsService>(), DataType.Videos)).As <IDownloadVideoFileManager>().SingleInstance(); container.ContainerBuilder.Register((ctx) => new DownloadDocumentFileManager(ctx.Resolve <ITelegramEventAggregator>(), ctx.Resolve <IMTProtoService>(), ctx.Resolve <IStatsService>(), DataType.Files)).As <IDownloadDocumentFileManager>().SingleInstance(); container.ContainerBuilder.RegisterType <DownloadWebFileManager>().As <IDownloadWebFileManager>().SingleInstance(); container.ContainerBuilder.Register((ctx) => new UploadManager(ctx.Resolve <ITelegramEventAggregator>(), ctx.Resolve <IMTProtoService>(), ctx.Resolve <IStatsService>(), DataType.Photos)).As <IUploadFileManager>().SingleInstance(); container.ContainerBuilder.Register((ctx) => new UploadManager(ctx.Resolve <ITelegramEventAggregator>(), ctx.Resolve <IMTProtoService>(), ctx.Resolve <IStatsService>(), DataType.Audios)).As <IUploadAudioManager>().SingleInstance(); container.ContainerBuilder.Register((ctx) => new UploadManager(ctx.Resolve <ITelegramEventAggregator>(), ctx.Resolve <IMTProtoService>(), ctx.Resolve <IStatsService>(), DataType.Videos)).As <IUploadVideoManager>().SingleInstance(); container.ContainerBuilder.Register((ctx) => new UploadManager(ctx.Resolve <ITelegramEventAggregator>(), ctx.Resolve <IMTProtoService>(), ctx.Resolve <IStatsService>(), DataType.Files)).As <IUploadDocumentManager>().SingleInstance(); container.ContainerBuilder.RegisterType <ContactsService>().As <IContactsService>().SingleInstance(); container.ContainerBuilder.RegisterType <LocationService>().As <ILocationService>().SingleInstance(); container.ContainerBuilder.RegisterType <PushService>().As <IPushService>().SingleInstance(); container.ContainerBuilder.RegisterType <JumpListService>().As <IJumpListService>().SingleInstance(); container.ContainerBuilder.RegisterType <HardwareService>().As <IHardwareService>().SingleInstance(); //container.ContainerBuilder.RegisterType<GifsService>().As<IGifsService>().SingleInstance(); container.ContainerBuilder.RegisterType <StickersService>().As <IStickersService>().SingleInstance(); container.ContainerBuilder.RegisterType <StatsService>().As <IStatsService>().SingleInstance(); container.ContainerBuilder.RegisterType <AppUpdateService>().As <IAppUpdateService>().SingleInstance(); // Disabled due to crashes on Mobile: // The RPC server is unavailable. //if (ApiInformation.IsTypePresent("Windows.Devices.Haptics.VibrationDevice") || ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 4)) //{ // // Introduced in Creators Update // container.ContainerBuilder.RegisterType<VibrationService>().As<IVibrationService>().SingleInstance(); //} //else if (ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice")) { // To keep vibration compatibility with Anniversary Update container.ContainerBuilder.RegisterType <WindowsPhoneVibrationService>().As <IVibrationService>().SingleInstance(); } else { container.ContainerBuilder.RegisterType <FakeVibrationService>().As <IVibrationService>().SingleInstance(); } // ViewModels container.ContainerBuilder.RegisterType <IntroViewModel>(); container.ContainerBuilder.RegisterType <SignInViewModel>(); container.ContainerBuilder.RegisterType <SignUpViewModel>(); container.ContainerBuilder.RegisterType <SignInSentCodeViewModel>(); container.ContainerBuilder.RegisterType <SignInPasswordViewModel>(); container.ContainerBuilder.RegisterType <MainViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <ShareViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <ForwardViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <DialogSendLocationViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <DialogsViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <DialogViewModel>(); container.ContainerBuilder.RegisterType <DialogStickersViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <UserDetailsViewModel>(); container.ContainerBuilder.RegisterType <ChannelManageViewModel>(); container.ContainerBuilder.RegisterType <ChannelAdminLogViewModel>(); container.ContainerBuilder.RegisterType <ChannelAdminLogFilterViewModel>(); container.ContainerBuilder.RegisterType <ChannelAdminRightsViewModel>(); container.ContainerBuilder.RegisterType <ChannelBannedRightsViewModel>(); container.ContainerBuilder.RegisterType <UserCommonChatsViewModel>(); container.ContainerBuilder.RegisterType <ChatDetailsViewModel>(); // .SingleInstance(); container.ContainerBuilder.RegisterType <ChatInviteViewModel>(); // .SingleInstance(); container.ContainerBuilder.RegisterType <ChatInviteLinkViewModel>(); // .SingleInstance(); container.ContainerBuilder.RegisterType <ChannelDetailsViewModel>(); // .SingleInstance(); container.ContainerBuilder.RegisterType <ChannelEditViewModel>(); // .SingleInstance(); container.ContainerBuilder.RegisterType <ChannelEditTypeViewModel>(); // .SingleInstance(); container.ContainerBuilder.RegisterType <ChannelEditStickerSetViewModel>(); // .SingleInstance(); container.ContainerBuilder.RegisterType <ChannelAdminsViewModel>(); // .SingleInstance(); container.ContainerBuilder.RegisterType <ChannelBannedViewModel>(); // .SingleInstance(); container.ContainerBuilder.RegisterType <ChannelKickedViewModel>(); // .SingleInstance(); container.ContainerBuilder.RegisterType <ChannelParticipantsViewModel>(); // .SingleInstance(); container.ContainerBuilder.RegisterType <DialogSharedMediaViewModel>(); // .SingleInstance(); container.ContainerBuilder.RegisterType <UsersSelectionViewModel>(); //.SingleInstance(); container.ContainerBuilder.RegisterType <CreateChannelStep1ViewModel>(); //.SingleInstance(); container.ContainerBuilder.RegisterType <CreateChannelStep2ViewModel>(); //.SingleInstance(); container.ContainerBuilder.RegisterType <CreateChatStep1ViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <CreateChatStep2ViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <InstantViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsGeneralViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsPhoneViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsPhoneSentCodeViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsStorageViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsStatsViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <FeaturedStickersViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsUsernameViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsEditNameViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsSessionsViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsBlockedUsersViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsBlockUserViewModel>(); container.ContainerBuilder.RegisterType <SettingsNotificationsViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsDataAndStorageViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsPrivacyAndSecurityViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsPrivacyStatusTimestampViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsPrivacyPhoneCallViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsPrivacyChatInviteViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsSecurityChangePasswordViewModel>(); //.SingleInstance(); container.ContainerBuilder.RegisterType <SettingsAccountsViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsStickersViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsStickersFeaturedViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsStickersArchivedViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsMasksViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsMasksArchivedViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <SettingsWallPaperViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <AttachedStickersViewModel>(); container.ContainerBuilder.RegisterType <StickerSetViewModel>(); container.ContainerBuilder.RegisterType <AboutViewModel>().SingleInstance(); container.ContainerBuilder.RegisterType <PaymentFormStep1ViewModel>(); container.ContainerBuilder.RegisterType <PaymentFormStep2ViewModel>(); container.ContainerBuilder.RegisterType <PaymentFormStep3ViewModel>(); container.ContainerBuilder.RegisterType <PaymentFormStep4ViewModel>(); container.ContainerBuilder.RegisterType <PaymentFormStep5ViewModel>(); container.ContainerBuilder.RegisterType <PaymentReceiptViewModel>(); container.Build(); Task.Run(() => LoadStateAndUpdate()); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (Debugger.IsAttached) { // disabled, obscures the hamburger button, enable if you need it //this.DebugSettings.EnableFrameRateCounter = true; } #endif var shell = Window.Current.Content as Shell; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (shell == null) { // Create a Shell which navigates to the first page shell = new Shell(); // hook-up shell root frame navigation events shell.RootFrame.NavigationFailed += OnNavigationFailed; shell.RootFrame.Navigated += OnNavigated; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // set the Shell as content Window.Current.Content = shell; // listen for back button clicks (both soft- and hardware) SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) { HardwareButtons.BackPressed += OnBackPressed; } UpdateBackButtonVisibility(); } if (!e.PrelaunchActivated) { // Ensure the current window is active Window.Current.Activate(); //Mobile customization if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0)) { var statusBar = StatusBar.GetForCurrentView(); statusBar.HideAsync(); } Color?systemAccentColorOverride = (Color)App.Current.Resources["SystemAccentColor"]; if (systemAccentColorOverride != null) { //PC customization if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView")) { var titleBar = ApplicationView.GetForCurrentView().TitleBar; if (titleBar != null) { titleBar.ForegroundColor = Colors.White; titleBar.ButtonForegroundColor = Colors.White; titleBar.InactiveForegroundColor = Colors.LightGray; titleBar.BackgroundColor = systemAccentColorOverride; titleBar.ButtonBackgroundColor = systemAccentColorOverride; titleBar.ButtonHoverBackgroundColor = systemAccentColorOverride; titleBar.ButtonInactiveBackgroundColor = systemAccentColorOverride; titleBar.InactiveBackgroundColor = systemAccentColorOverride; } } if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { var statusBar = StatusBar.GetForCurrentView(); if (statusBar != null) { statusBar.BackgroundOpacity = 1; statusBar.BackgroundColor = systemAccentColorOverride; statusBar.ForegroundColor = Colors.White; } } } } }
public static bool SupportsAcrylicBrushes() { return(ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.AcrylicBrush")); }
private async void Import_ks_Click(object sender, RoutedEventArgs e) { loadsave loadsave = new loadsave(); parse_bytes parse_bytes = new parse_bytes(); // 打开文件 files files = await loadsave.load_ksasync(); if (files.filename != "empty" && files.srcode.Count() != 0) { string encoding = parse_bytes.DetectUnicode(files.srcode); string src2; //ANSI 处理 if (encoding == "ansi") { ansitake ansitake_dlg = new ansitake(); ansitake_dlg.src = files.srcode; await ansitake_dlg.ShowAsync(); encoding = ansitake_dlg.cp; } //还原二进制为文本 src2 = parse_bytes.byte2str(files.srcode, encoding); //判断 .ks 文件类型 if (files.filename.Contains(".ks")) { parse_ks_perline parse_ks_perline = new parse_ks_perline(); ks_perline = parse_ks_perline.parsestr(src2); //按行拆分文本 for (int i = 0; i < ks_perline.Count; i++) { //根据每行内容,进行上色 if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5)) { ks_perline[i].textcolor = new SolidColorBrush(this.ActualTheme == ElementTheme.Dark ? ks_perline[i].text_cd : ks_perline[i].text_cl); } else { //由于 this.RequestedTheme 会返回 ElementTheme.Default,故原方法不可用 ks_perline[i].textcolor = new SolidColorBrush(Application.Current.RequestedTheme == ApplicationTheme.Dark ? ks_perline[i].text_cd : ks_perline[i].text_cl); } } file_info.Text = files.filename; if (textonly == true) { //过滤代码等内容,只留下文本 filter_ks_perline = parse_ks_perline.filter_perline(ks_perline); text_list.ItemsSource = filter_ks_perline; text_list2.ItemsSource = filter_ks_perline; } else { //原样输出 text_list.ItemsSource = ks_perline; text_list2.ItemsSource = ks_perline; } bot_p_n.IsEnabled = true; bot_p_n2.IsEnabled = true; text_src.IsEnabled = true; text_src2.IsEnabled = true; text_dst.IsEnabled = true; text_dst2.IsEnabled = true; } else if (files.filename.Contains(".out.txt")) { parse_bgi_perline parse_bgi_perline = new parse_bgi_perline(); bgi_perline = parse_bgi_perline.parsestr(src2); file_info.Text = files.filename; text_list.ItemsSource = bgi_perline; text_list2.ItemsSource = bgi_perline; for (int i = 0; i < bgi_perline.Count; i++) { //根据每行内容,进行上色 if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5)) { bgi_perline[i].textcolor = new SolidColorBrush(this.ActualTheme == ElementTheme.Dark ? bgi_perline[i].text_cd : bgi_perline[i].text_cl); } else { //由于 this.RequestedTheme 会返回 ElementTheme.Default,故原方法不可用 bgi_perline[i].textcolor = new SolidColorBrush(Application.Current.RequestedTheme == ApplicationTheme.Dark ? bgi_perline[i].text_cd : bgi_perline[i].text_cl); } } bot_p_n.IsEnabled = true; bot_p_n2.IsEnabled = true; text_src.IsEnabled = true; text_src2.IsEnabled = true; text_dst.IsEnabled = true; text_dst2.IsEnabled = true; } else { //如果打开文件的过程被中断(比如:按下了“取消”键),会返回“empty”。 //由于发现打开空白文件的时候会发生错误,所以这里追加判断打开文件的情况。 string err_msg = files.filename == "empty" ? "没有打开文件。" : string.Format("打开了空白的文件:{0}。", files.filename); ContentDialog err_dlg = new ContentDialog() { Title = "发生错误", Content = err_msg, PrimaryButtonText = "关闭" }; await err_dlg.ShowAsync(); } } }
private void OnTypeChanged(string newType) { this.IsActive = !string.IsNullOrWhiteSpace(newType) && ApiInformation.IsTypePresent(newType); }
private LanguageManager() { List <string> imageLanguagesList = GetImageSupportedLanguages(); // Only Image Enable Map _displayNameToImageLanguageMap = new SortedDictionary <string, string>( imageLanguagesList.Select(tag => { var lang = new Language(tag); return(new KeyValuePair <string, string>(lang.NativeName, GetLocaleFromLanguageTag(lang.LanguageTag))); }).ToDictionary(keyitem => keyitem.Key, valueItem => valueItem.Value) ); ImageLanguageDisplayNames = _displayNameToImageLanguageMap.Keys.ToList(); _displayNameToLanguageMap = new Dictionary <string, string>( ApplicationLanguages.ManifestLanguages.Union(imageLanguagesList).Select(tag => { var lang = new Language(tag); return(new KeyValuePair <string, string>(lang.NativeName, GetLocaleFromLanguageTag(lang.LanguageTag))); }).Distinct().OrderBy(a => a.Key).ToDictionary(keyitem => keyitem.Key, valueItem => valueItem.Value) ); LanguageDisplayNames = _displayNameToLanguageMap.Keys.ToList(); _displayNameToInputLanguageMap = new SortedDictionary <string, string>( _inputLanguages.Select(tag => { var lang = new Language(tag); return(new KeyValuePair <string, string>(lang.NativeName, GetLocaleFromLanguageTag(lang.LanguageTag))); }).ToDictionary(keyitem => keyitem.Key, valueItem => valueItem.Value) ); InputLanguageDisplayNames = _displayNameToInputLanguageMap.Keys.ToList(); // Exception when running in Local Machine try { // Add Image Enabled Languages as Global Preferences List if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5)) { // Find language currently set as UI language. This should be // the first language in the list passed to TrySetLanguages var uiLanguageTag = GlobalizationPreferences.Languages[0]; var index = imageLanguagesList.IndexOf(uiLanguageTag); if (index != 0) { if (index != -1) { imageLanguagesList.Remove(uiLanguageTag); } imageLanguagesList.Insert(0, uiLanguageTag); } GlobalizationPreferences.TrySetLanguages(imageLanguagesList); } } catch (UnauthorizedAccessException ex) { // This is indicative of EmbeddedMode not being enabled (i.e. // running on Desktop or Mobile without enabling EmbeddedMode) // https://developer.microsoft.com/en-us/windows/iot/docs/embeddedmode App.LogService.Write(ex.ToString()); } }
public IEnumerable <ShellProfile> GetPreinstalledShellProfiles() { return(new[] { new ShellProfile { Id = GetDefaultShellProfileId(), Name = "Powershell", Arguments = string.Empty, Location = @"C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe", PreInstalled = true, WorkingDirectory = string.Empty, LineEndingTranslation = LineEndingStyle.DoNotModify, UseConPty = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8), // Windows 10 1903+ KeyBindings = new [] { new KeyBinding { Command = GetDefaultShellProfileId().ToString(), Ctrl = true, Alt = true, Shift = false, Meta = false, Key = (int)ExtendedVirtualKey.Number1 } } }, new ShellProfile { Id = Guid.Parse("ab942a61-7673-4755-9bd8-765aff91d9a3"), Name = "CMD", Arguments = string.Empty, Location = @"C:\Windows\System32\cmd.exe", PreInstalled = true, WorkingDirectory = string.Empty, LineEndingTranslation = LineEndingStyle.DoNotModify, UseConPty = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 7), // Windows 10 1809+ KeyBindings = new [] { new KeyBinding { Command = "ab942a61-7673-4755-9bd8-765aff91d9a3", Ctrl = true, Alt = true, Shift = false, Meta = false, Key = (int)ExtendedVirtualKey.Number2 } } }, new ShellProfile { Id = Guid.Parse("e5785ad6-584f-40cb-bdcd-d5b3b3953e7f"), Name = "WSL", Arguments = string.Empty, Location = @"C:\windows\system32\wsl.exe", PreInstalled = true, WorkingDirectory = string.Empty, LineEndingTranslation = LineEndingStyle.ToLF, UseConPty = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 7), // Windows 10 1809+ KeyBindings = new [] { new KeyBinding { Command = "e5785ad6-584f-40cb-bdcd-d5b3b3953e7f", Ctrl = true, Alt = true, Shift = false, Meta = false, Key = (int)ExtendedVirtualKey.Number3 } } } }); }
/// <summary> /// Inits the root frame and the navigation. /// </summary> private void InitRootFrameAndNavigation() { // setup frame if (RootFrame == null) { RootFrame = new Frame { Language = ApplicationLanguages.Languages[0] }; RootFrame.Navigated += (s, args) => { UpdateShellBackButton(); }; // register back button SystemNavigationManager.GetForCurrentView().BackRequested += (s, args) => { var handledByAppShell = false; if (UseAppShell) { var appshell = Window.Current.Content as AppShell; if (appshell != null) { appshell.BackRequested(ref handledByAppShell); } } if (!handledByAppShell) { var handled = false; if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0)) { if (NavigationService.CanGoBack) { handled = true; } else if (BackButtonBehaviour == AppBackButtonBehaviour.Terminate) { args.Handled = true; Current.Exit(); } } else { handled = !NavigationService.CanGoBack; } args.Handled = handled; RaiseBackRequested(ref handled); } else { args.Handled = true; } }; // hook up keyboard and mouse Back handler _keyboardService = Injector.Get <IKeyboardService>(); _keyboardService.AfterBackGesture = () => { //the result is no matter var handled = false; RaiseBackRequested(ref handled); }; // Hook up keyboard and house Forward handler _keyboardService.AfterForwardGesture = RaiseForwardRequested; } // setup default view var view = WindowWrapper.ActiveWrappers.First(); var navigationService = new NavigationService(RootFrame); view.NavigationServices.Add(navigationService); // requrest minimum size, to be like the MSN apps var applicationView = ApplicationView.GetForCurrentView(); applicationView.SetPreferredMinSize(new Size(500, 500)); }
public MainPage() { this.InitializeComponent(); ApplicationDataContainer AppSettings = ApplicationData.Current.LocalSettings; if (AppSettings.Values.ContainsKey("tsLett")) { tsLett.IsOn = (bool)AppSettings.Values["tsLett"]; } if (AppSettings.Values.ContainsKey("tsNumb")) { tsNumb.IsOn = (bool)AppSettings.Values["tsNumb"]; } if (AppSettings.Values.ContainsKey("tsSymb")) { tsSymb.IsOn = (bool)AppSettings.Values["tsSymb"]; } if (AppSettings.Values.ContainsKey("tsSimi")) { tsSimi.IsOn = (bool)AppSettings.Values["tsSimi"]; } if (AppSettings.Values.ContainsKey("sLeng")) { sLeng.Value = (double)AppSettings.Values["sLeng"]; } string deviceFamilyVersion = AnalyticsInfo.VersionInfo.DeviceFamilyVersion; ulong osVersion = ulong.Parse(deviceFamilyVersion); int build = Convert.ToInt32((osVersion & 0x00000000FFFF0000L) >> 16); if (build >= 16299) { bgMain.Background = Resources["SystemControlAccentAcrylicWindowAccentMediumHighBrush"] as Brush; } var colorBar = Application.Current.Resources["SystemControlForegroundAccentBrush"] as SolidColorBrush; if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { var statusBar = StatusBar.GetForCurrentView(); if (statusBar != null) { statusBar.BackgroundColor = colorBar.Color; statusBar.BackgroundOpacity = 1; } } if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView")) { ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar; if (titleBar != null && ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.XamlCompositionBrushBase") && build >= 16299) { CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; titleBar.ButtonBackgroundColor = Colors.Transparent; titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; } else if (titleBar != null && ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.XamlCompositionBrushBase")) { titleBar.ButtonBackgroundColor = colorBar.Color; titleBar.BackgroundColor = colorBar.Color; } } Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().IsScreenCaptureEnabled = false; }
protected override void OnLaunched(LaunchActivatedEventArgs e) { Bootstrapper_UWP.Initialize(); Xamarin.Forms.Forms.SetFlags( "FastRenderers_Experimental", "CollectionView_Experimental", "CarouselView_Experimental", "IndicatorView_Experimental", "SwipeView_Experimental", "Expander_Experimental", "Brush_Experimental", "Shapes_Experimental"); FFImageLoading.Forms.Platform.CachedImageRenderer.Init(); Rg.Plugins.Popup.Popup.Init(); Xamarin.Forms.Forms.Init(e, Rg.Plugins.Popup.Popup.GetExtraAssemblies()); if (!(Window.Current.Content is Frame rootFrame)) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } try { if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView")) { var titleBar = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar; if (titleBar != null) { titleBar.ButtonBackgroundColor = Xamarin.Forms.Application.Current.DarkPrimaryColor().ToWindowsColor(); titleBar.BackgroundColor = Xamarin.Forms.Application.Current.DarkPrimaryColor().ToWindowsColor(); titleBar.InactiveBackgroundColor = Xamarin.Forms.Application.Current.AccentColor().ToWindowsColor(); titleBar.ButtonInactiveBackgroundColor = Xamarin.Forms.Application.Current.AccentColor().ToWindowsColor(); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
/// <summary> /// Uses Composition API to get the UIElement and sets an ExpressionAnimation /// The ExpressionAnimation uses the height of the UIElement to calculate an opacity value /// for the Header as it is scrolling off-screen. The opacity reaches 0 when the Header /// is entirely scrolled off. /// </summary> /// <returns><c>true</c> if the assignment was successfull; otherwise, <c>false</c>.</returns> private bool AssignAnimation() { StopAnimation(); // Confirm that Windows.UI.Xaml.Hosting.ElementCompositionPreview is available (Windows 10 10586 or later). if (!ApiInformation.IsMethodPresent("Windows.UI.Xaml.Hosting.ElementCompositionPreview", nameof(ElementCompositionPreview.GetScrollViewerManipulationPropertySet))) { // Just return true since it's not supported return(true); } if (AssociatedObject == null) { return(false); } if (_scrollViewer == null) { _scrollViewer = AssociatedObject as ScrollViewer ?? AssociatedObject.FindDescendant <ScrollViewer>(); } if (_scrollViewer == null) { return(false); } if (_scrollProperties == null) { _scrollProperties = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(_scrollViewer); } if (_scrollProperties == null) { return(false); } // Implicit operation: Find the Header object of the control if it uses ListViewBase if (HeaderElement == null) { var listElement = AssociatedObject as Windows.UI.Xaml.Controls.ListViewBase ?? AssociatedObject.FindDescendant <Windows.UI.Xaml.Controls.ListViewBase>(); if (listElement != null) { HeaderElement = listElement.Header as UIElement; } } var headerElement = HeaderElement as FrameworkElement; if (headerElement == null || headerElement.RenderSize.Height == 0) { return(false); } if (_headerVisual == null) { _headerVisual = ElementCompositionPreview.GetElementVisual(headerElement); } if (_headerVisual == null) { return(false); } headerElement.SizeChanged -= ScrollHeader_SizeChanged; headerElement.SizeChanged += ScrollHeader_SizeChanged; var compositor = _scrollProperties.Compositor; if (_animationProperties == null) { _animationProperties = compositor.CreatePropertySet(); _animationProperties.InsertScalar("OffsetY", 0.0f); } _previousVerticalScrollOffset = _scrollViewer.VerticalOffset; var expressionAnimation = compositor.CreateExpressionAnimation($"max(animationProperties.OffsetY - ScrollingProperties.Translation.Y, 0)"); expressionAnimation.SetReferenceParameter("ScrollingProperties", _scrollProperties); expressionAnimation.SetReferenceParameter("animationProperties", _animationProperties); _headerVisual.StartAnimation("Offset.Y", expressionAnimation); return(true); }
public static bool IsNotificationListenerSupported() { return(ApiInformation.IsTypePresent("Windows.UI.Notifications.Management.UserNotificationListener")); }
public StickersView() { InitializeComponent(); var shadow1 = DropShadowEx.Attach(HeaderSeparator, 20, 0.25f); var shadow2 = DropShadowEx.Attach(Separator, 20, 0.25f); HeaderSeparator.SizeChanged += (s, args) => { shadow1.Size = args.NewSize.ToVector2(); }; Separator.SizeChanged += (s, args) => { shadow2.Size = args.NewSize.ToVector2(); }; var observable = Observable.FromEventPattern <TextChangedEventArgs>(FieldStickers, "TextChanged"); var throttled = observable.Throttle(TimeSpan.FromMilliseconds(Constants.TypingTimeout)).ObserveOnDispatcher().Subscribe(async x => { var items = ViewModel.Stickers.SearchStickers; if (items != null && string.Equals(FieldStickers.Text, items.Query)) { await items.LoadMoreItemsAsync(1); await items.LoadMoreItemsAsync(2); } }); var observable2 = Observable.FromEventPattern <TextChangedEventArgs>(FieldAnimations, "TextChanged"); var throttled2 = observable2.Throttle(TimeSpan.FromMilliseconds(Constants.TypingTimeout)).ObserveOnDispatcher().Subscribe(x => { ViewModel.Stickers.FindAnimations(FieldAnimations.Text); //var items = ViewModel.Stickers.SearchStickers; //if (items != null && string.Equals(FieldStickers.Text, items.Query)) //{ // await items.LoadMoreItemsAsync(1); // await items.LoadMoreItemsAsync(2); //} }); switch (SettingsService.Current.Stickers.SelectedTab) { case Services.Settings.StickersTab.Emoji: Pivot.SelectedIndex = 0; break; case Services.Settings.StickersTab.Animations: Pivot.SelectedIndex = 1; break; case Services.Settings.StickersTab.Stickers: Pivot.SelectedIndex = 2; break; } if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "Shadow")) { var themeShadow = new ThemeShadow(); BackgroundElement.Shadow = themeShadow; BackgroundElement.Translation += new Vector3(0, 0, 32); themeShadow.Receivers.Add(ShadowElement); } }
public static bool IsMobileSystem() { return(ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")); }
private static bool InitMessageWebSocketClientCertificateSupported() { return(ApiInformation.IsPropertyPresent( "Windows.Networking.Sockets.MessageWebSocketControl", "ClientCertificate")); }
public static bool IsSystemTrayAvailable() { return(ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")); }
public UsageData(string docId, IApiCatalogLookup catalog, IApiRecommendations recommendations) { Api = new ApiInformation(docId, catalog, recommendations); }
public bool SetExchangeApi(ApiInformation apiInfo) { _apiInfo = apiInfo; return(true); }