示例#1
0
 public ExceptionDialog(string Msg, XamlRoot xamlRoot)
 {
     this.InitializeComponent();
     this.PrimaryButtonText = "确定";
     this.msgTextBlock.Text = Msg;
     this.XamlRoot          = xamlRoot;
 }
 private SingleVideoDialog(SingleVideoDialogViewModel vm, XamlRoot xamlRoot)
 {
     this.vm          = vm;
     this.DataContext = vm;
     this.InitializeComponent();
     this.Closing += SingleVideoDialog_Closing;
     XamlRoot      = xamlRoot;
 }
 private MasteredVideoDialog(MasteredVideoDialogViewModel vm, XamlRoot xamlRoot)
 {
     this.vm          = vm;
     this.DataContext = vm;
     this.InitializeComboBoxData(vm);
     this.InitializeComponent();
     this.Closing += MasteredVideoDialog_Closing;
     XamlRoot      = xamlRoot;
 }
示例#4
0
        public static IReadOnlyList <Popup> GetOpenPopupsForXamlRoot(XamlRoot xamlRoot)
        {
            if (xamlRoot == XamlRoot.Current)
            {
                return(GetOpenPopups(Window.Current));
            }

            return(new Popup[0]);
        }
示例#5
0
        internal XamlRoot GetOrCreateXamlRoot()
        {
            if (XamlRoot is null)
            {
                XamlRoot = new XamlRoot(this);
            }

            return(XamlRoot);
        }
示例#6
0
 public void ShowPopup(XamlRoot xamlRoot)
 {
     UserNameInputBox.SetText("");
     PasswordInputBox.SetText("");
     CaptchaBlock.Visibility = Visibility.Collapsed;
     WebContainer.Visibility = Visibility.Collapsed;
     //BackupWebView.NavigateToString("");
     UIHelper.PopupShow(this, xamlRoot);
     PopupIn.Begin();
 }
示例#7
0
        /// <summary>
        /// Tracks information about the app's launch.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        /// <param name="xamlRoot">The XamlRoot object from your visual tree.</param>
        public void TrackAppUse(IActivatedEventArgs args, XamlRoot xamlRoot = null)
        {
            if (args.PreviousExecutionState == ApplicationExecutionState.ClosedByUser ||
                args.PreviousExecutionState == ApplicationExecutionState.NotRunning)
            {
                LaunchCount      = _localObjectStorageHelper.Read <long>(nameof(LaunchCount)) + 1;
                TotalLaunchCount = _localObjectStorageHelper.Read <long>(nameof(TotalLaunchCount)) + 1;

                // In case we upgraded the properties, make TotalLaunchCount is correct
                if (TotalLaunchCount < LaunchCount)
                {
                    TotalLaunchCount = LaunchCount;
                }

                _localObjectStorageHelper.Save(nameof(LaunchCount), LaunchCount);
                _localObjectStorageHelper.Save(nameof(TotalLaunchCount), TotalLaunchCount);

                LaunchTime = DateTime.UtcNow;

                var lastLaunch = _localObjectStorageHelper.Read <long>(nameof(LastLaunchTime));
                LastLaunchTime = lastLaunch != default(long)
                    ? DateTime.FromFileTimeUtc(lastLaunch)
                    : LaunchTime;

                _localObjectStorageHelper.Save(nameof(LastLaunchTime), LaunchTime.ToFileTimeUtc());
                _localObjectStorageHelper.Save(nameof(AppUptime), 0L);

                var lastResetTime = _localObjectStorageHelper.Read <long>(nameof(LastResetTime));
                LastResetTime = lastResetTime != default(long)
                    ? DateTime.FromFileTimeUtc(lastResetTime)
                    : DateTime.MinValue;
            }

            if (xamlRoot != null)
            {
                void XamlRoot_Changed(XamlRoot sender, XamlRootChangedEventArgs e)
                {
                    UpdateVisibility(sender.IsHostVisible);
                }

                xamlRoot.Changed -= XamlRoot_Changed;
                xamlRoot.Changed += XamlRoot_Changed;
            }
            else
            {
                void App_VisibilityChanged(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.VisibilityChangedEventArgs e)
                {
                    UpdateVisibility(e.Visible);
                }

                Windows.UI.Core.CoreWindow.GetForCurrentThread().VisibilityChanged -= App_VisibilityChanged;
                Windows.UI.Core.CoreWindow.GetForCurrentThread().VisibilityChanged += App_VisibilityChanged;
            }
        }
示例#8
0
        private void WindowsXamlHostBase_OnChildChanged(object sender, EventArgs e)
        {
            var host = (WindowsXamlHost)sender;

            if (host.Child is OilLakeUI.UI.TextTabView control)
            {
                Root = host.Child.XamlRoot;
                control.DataContext             = ((MainWindowViewModel)DataContext).TabViewModel;
                control.AllowFocusOnInteraction = true;
            }
        }
 private static float GetScale(XamlRoot xamlRoot)
 {
     if (xamlRoot != null)
     {
         return((float)xamlRoot.RasterizationScale);
     }
     else
     {
         return((float)DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel);
     }
 }
示例#10
0
        private static object?GetFocusedElementWithRootImpl(XamlRoot xamlRoot)
        {
            if (xamlRoot is null)
            {
                throw new ArgumentNullException(nameof(xamlRoot));
            }

            var focusManager     = xamlRoot.VisualTree.ContentRoot.FocusManager;
            var dependencyObject = focusManager.FocusedElement;

            return(dependencyObject);
        }
示例#11
0
        public static async Task ShowSingleButtonContentDialogAsync(XamlRoot xamlRoot, string dialogMessage, string closeButtonText = "Close", string title = "Packet Messaging")
        {
            // See https://docs.microsoft.com/en-us/windows/uwp/design/layout/show-multiple-views
            ContentDialog contentDialog = new ContentDialog()
            {
                Title           = title,
                Content         = dialogMessage,
                CloseButtonText = closeButtonText,
            };

            contentDialog.XamlRoot = xamlRoot;
            await contentDialog.ShowAsync();
        }
        private async void XamlRoot_Changed(XamlRoot sender, XamlRootChangedEventArgs args)
        {
            if (_rootGrid.Width != sender.Size.Width || _rootGrid.Height != sender.Size.Height)
            {
                UpdateRootGridSize(sender.Size.Width, sender.Size.Height);
            }

            if (_currentDpi != sender.RasterizationScale)
            {
                _currentDpi = sender.RasterizationScale;
                await UpdateAppScreenshotAsync();
            }
        }
示例#13
0
 public SESSDATALoginDialog(XamlRoot xamlRoot)
 {
     this.InitializeComponent();
     this.IsPrimaryButtonEnabled = false;
     this.Closing += (s, e) =>
     {
         if (!needToClose)
         {
             e.Cancel = true;
         }
     };
     XamlRoot = xamlRoot;
 }
示例#14
0
 public static void PopupShow(IAppPopup popup, XamlRoot xamlRoot, Action changeAction = null)
 {
     //App.AppViewModel.WindowsSizeChangedNotify.Add(new Tuple<Guid, Action<Size>>(popup._popupId, (rect) =>
     //{
     //    popup.Width = rect.Width;
     //    popup.Height = rect.Height;
     //    changeAction?.Invoke();
     //}));
     //popup.Width = Window.Current.Bounds.Width;
     //popup.Height = Window.Current.Bounds.Height;
     //var view = popup as UIElement;
     popup._popup.XamlRoot = xamlRoot;
     popup._popup.IsOpen   = true;
 }
示例#15
0
        public static FrameworkElement GetOpenFlyoutPresenter(XamlRoot xamlRoot)
        {
#if NETFX_CORE
            var popups = VisualTreeHelper.GetOpenPopups(Window.Current);
#else
            var popups = VisualTreeHelper.GetOpenPopupsForXamlRoot(xamlRoot);
#endif
            if (popups.Count != 1)
            {
                throw new InvalidOperationException("Expected exactly one open Popup.");
            }

            return(popups[0] ?? throw new InvalidOperationException("Popup child should not be null."));
        }
 private BangumiDialog(BangumiDialogViewModel vm, XamlRoot xamlRoot)
 {
     this.vm          = vm;
     this.DataContext = vm;
     InitializeComboBoxData(vm);
     this.InitializeComponent();
     this.Closing += (s, e) =>
     {
         if (!needToClose)
         {
             e.Cancel = true;
         }
     };
     XamlRoot = xamlRoot;
 }
示例#17
0
        protected override UIElement CreateShell()
        {
            var shell = Container.Resolve <Shell>();

#if NET5_0 && WINDOWS
            _window = new Window();
            _window.Activate();
            _window.Content = shell;
#endif

#if HAS_UNO_WINUI || NETCOREAPP
            MainXamlRoot = shell.XamlRoot;
#endif

            return(shell);
        }
        public async Task GetMoreVideoAsync(XamlRoot xamlRoot)
        {
            var count = this.VideoList.Count - 1;

            if ((count < 20) || (count % 20 != 0))
            {
                var dialog = new ErrorDialog("已经没有更多了", xamlRoot)
                {
                    PrimaryButtonText = ""
                };
                await dialog.ShowAsync();

                return;
            }

            var fav = await BiliFavHelper.GetBiliFavAsync(this.Id, (count / 20) + 1, UserPage.SESSDATA);

            if (fav == null)
            {
                var dialog = new ErrorDialog("已经没有更多了", xamlRoot)
                {
                    PrimaryButtonText = ""
                };
                await dialog.ShowAsync();

                return;
            }

            var list = new List <FavVideoViewModel>();

            foreach (var video in fav.VideoList)
            {
                list.Add(await FavVideoViewModel.CreateAsync(video.Title, video.Bv, video.Picture));
            }

            this.VideoList.Remove(this.VideoList.TakeLast(1).Single());
            list.ForEach(v => this.VideoList.Add(v));

            this.VideoList.Add(new FavVideoViewModel()
            {
                Bv       = "加载更多",
                Title    = "加载更多",
                CoverImg = new BitmapImage(new Uri("ms-appx:///Assets/LoadMore.png"))
            });
        }
示例#19
0
        public static void DeCompressAndNotification(string filename, Button button, XamlRoot xamlRoot)
        {
            string _filename = null;

            if (Settings.IsAutoDeCompressEnabled)
            {
                var result = IsDeCompressed(filename);
                if (result.IsSuccess)
                {
                    File.Delete(filename);
                    _filename = result.FileName;
                    button.Tag = result.FileName ?? filename;
                }
            }
            if (Settings.IsShowNotificationEnabled)
            {
                OpenContentDialog(_filename ?? filename, filename, xamlRoot);
            }
        }
        public static async Task <BangumiDialog> CreateAsync(BiliBangumi bangumi, XamlRoot xamlRoot)
        {
            var model = new BangumiDialogViewModel();

            model.VideoTitle = bangumi.Title;

            //var stream = await NetHelper.HttpGetStreamAsync(bangumi.Cover, null, null);
            //var file = await ApplicationData.Current.LocalCacheFolder.CreateFileAsync("videocovercache", CreationCollisionOption.GenerateUniqueName);
            //var fileStream = await file.OpenStreamForWriteAsync();
            //await stream.CopyToAsync(fileStream);
            //stream.Close();
            //fileStream.Close();
            //var img = new BitmapImage();
            //await img.SetSourceAsync((await file.OpenStreamForReadAsync()).AsRandomAccessStream());
            var img = new BitmapImage(new Uri(bangumi.Cover));

            model.VideoCover = img;

            var list = bangumi.EpisodeList.Select(v => new VideoInfo()
            {
                Info = new BiliVideoInfo()
                {
                    Bv       = v.Bv,
                    Cid      = v.Cid,
                    Name     = v.Name,
                    CoverUrl = v.Cover
                },
                ToDownload           = false,
                BackGroundColorBrush = bangumi.EpisodeList.IndexOf(v) % 2 == 0
                ? new SolidColorBrush(Colors.WhiteSmoke) : new SolidColorBrush(Colors.White)
            }).ToList();
            var i = 1;

            foreach (var video in list)//添加序号
            {
                video.Info.Name = i + "." + video.Info.Name;
                i++;
            }
            model.VideoList = new ObservableCollection <VideoInfo>(list);

            return(new BangumiDialog(model, xamlRoot));
        }
示例#21
0
        internal static XamlRoot GetXamlRoot(DependencyObject obj)
        {
            XamlRoot xamlRoot = default;

            if (obj is UIElement e)
            {
                xamlRoot = e.XamlRoot;
            }
            else if (obj is TextElement te)
            {
                xamlRoot = te.XamlRoot;
            }
            else if (obj is Windows.UI.Xaml.Controls.Primitives.FlyoutBase fb)
            {
                xamlRoot = fb.XamlRoot;
            }
            else
            {
                throw new InvalidOperationException("TreeHelper::GetXamlRoot: Can't find XamlRoot for element");
            }
            return(xamlRoot);
        }
 public ShiftsManager(VMLocator vmLocator, XamlRoot xamlRoot)
 {
     _vmLocator = vmLocator;
     _messenger = vmLocator.GetMessenger();
     _xamlRoot  = xamlRoot;
 }
示例#23
0
 public ErrorDialog(string message, XamlRoot xamlRoot)
 {
     this.InitializeComponent();
     this.messageTextBlock.Text = message;
     XamlRoot = xamlRoot;
 }
示例#24
0
 public static object?GetFocusedElement(XamlRoot xamlRoot) => GetFocusedElementWithRootImpl(xamlRoot);
 public void ShowPopup(XamlRoot xamlRoot)
 {
     throw new NotImplementedException();
 }
        public async static Task <UserDetailModel> ShowLoginDialog(IMessenger messenger, DbUser dbUser, XamlRoot xamlRoot, bool showPassword = true)
        {
            var vm = new LoginViewModel(messenger, dbUser, showPassword);

            var dialog = new Controls.ContentDialog()
            {
                XamlRoot = xamlRoot,
                Content  = new Components.Login()
                {
                    DataContext = vm
                },
                PrimaryButtonText = "asd",
                CloseButtonText   = Localization.GetLocalizedString(LocalizationStrings.CancelButton),
                DefaultButton     = ContentDialogButton.Primary
            };

            return(await dialog.ShowAsync() is ContentDialogResult.Primary ? vm.InsertedUser : null);
        }
示例#27
0
 public EditCollectionDetailsDialog(Collection collection, XamlRoot root)
 {
     InitializeComponent();
     Collection = collection;
     XamlRoot   = root;
 }
 public QRcodeLoginDialog(XamlRoot xamlRoot)
 {
     this.InitializeComponent();
     token    = new CancellationTokenSource();
     XamlRoot = xamlRoot;
 }
 public static void SetUIContext(CurrentActiveWindowUIContextService service, UIContext uIContext, XamlRoot xamlRoot)
 {
     service.UIContext = uIContext;
     service.XamlRoot  = xamlRoot;
 }
 private async void XamlRoot_Changed(XamlRoot sender, XamlRootChangedEventArgs args)
 {
     await UpdateEyedropperWorkAreaAsync();
 }