/// <summary> /// Handles the Click event of the DeleteDayOfTrip control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> public async void DeleteTrip_Click(object sender, RoutedEventArgs e) { var id = TripId; using (var client = new System.Net.Http.HttpClient()) { client.BaseAddress = new Uri(@"http://localhost:10051/api/"); await client.DeleteAsync("trips/" + id); var nav = WindowWrapper.Current().NavigationServices.FirstOrDefault(); nav.Navigate(typeof(Views.GetTripPage)); } }
/// <summary> /// Opening completed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void OpenBlurAnim_Completed(object sender, AnimationSetCompletedEventArgs e) { WindowWrapper.Current().Dispatcher.Dispatch(() => { var modal = Window.Current.Content as ModalDialog; if (!(modal.ModalContent is ModalWindow view)) { modal.ModalContent = view = new ModalWindow(ModalContent); } view.GotIt.IsEnabled = true; }); }
/// <summary> /// Closing completed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected static void CloseBlurAnim_Completed(object sender, AnimationSetCompletedEventArgs e) { WindowWrapper.Current().Dispatcher.Dispatch(() => { var modal = Window.Current.Content as ModalDialog; if (!(modal.ModalContent is ModalWindow view)) { modal.ModalContent = view = new ModalWindow(null); } modal.IsModal = view.IsShowed = false; }); }
private async void buttonStartMovie_Click(object sender, RoutedEventArgs e) { loadRemote(); if (_remote != null) { var response = await ConnectionHelper.ExecuteRequest(_remote.Host, _remote.Port, _remote.User, _remote.Pass, JsonHelper.JsonCommandPlayerOpen("movieid", Convert.ToInt32(_movie.Movieid))); if (response != "statusError" && response != "connectionError") { WindowWrapper.Current().NavigationServices.FirstOrDefault().Navigate(typeof(MainPage)); } } }
// hide and show busy dialog public static void SetBusy(bool busy, string text = null) { WindowWrapper.Current().Dispatcher.Dispatch(() => { var modal = Window.Current.Content as ModalDialog; var view = modal.ModalContent as Busy; if (view == null) { modal.ModalContent = view = new Busy(); } modal.IsModal = view.IsBusy = busy; view.BusyText = text; }); }
private IContainer _BuildContainer() { var builder = new ContainerBuilder(); builder.RegisterModule <ServicesModule>(); builder.RegisterModule <ViewModelsModule>(); builder.Register(_GetNavigationService).As <INavigationService>().InstancePerDependency(); return(builder.Build()); object _GetNavigationService(IComponentContext arg) { return(WindowWrapper.Current().NavigationServices.FirstOrDefault()); } }
/// <summary> /// Will close the modal dialog. /// </summary> public void CloseControl() { //Get the current window and cast it to a UserInfoPart ModalDialog and shut it down. WindowWrapper.Current().Dispatcher.Dispatch(() => { var modal = Window.Current.Content as ModalDialog; var view = modal.ModalContent as FieldBookDialog; modal.ModalContent = view; modal.IsModal = false; }); //Set header visibility init Services.DatabaseServices.DataLocalSettings localSetting = new DataLocalSettings(); localSetting.InitializeHeaderVisibility(); }
public static MonitorUtils Current(IWindowWrapper windowWrapper = null) { windowWrapper = windowWrapper ?? WindowWrapper.Current(); if (!Cache.ContainsKey(windowWrapper)) { var item = new MonitorUtils(windowWrapper); Cache.Add(windowWrapper, item); windowWrapper.ApplicationView().Consolidated += new WeakReference <MonitorUtils, ApplicationView, object>(item) { EventAction = (i, s, e) => Cache.Remove(windowWrapper), DetachAction = (i, w) => windowWrapper.ApplicationView().Consolidated -= w.Handler }.Handler; } return(Cache[windowWrapper]); }
private void EditPlaylist(PlaylistToDisplay obj) { if (obj != null) { WindowWrapper.Current().Dispatcher.Dispatch(() => { var modal = Window.Current.Content as ModalDialog; var editPlaylistDialog = new EditPlaylistDialog(obj); editPlaylistDialog.Closing += DialogClosed; modal.ModalContent = editPlaylistDialog; modal.IsModal = true; modal.ModalBackground = new SolidColorBrush(Colors.Transparent); }); } }
async Task NavigateToAsync(NavigationMode mode, object parameter, object frameContent = null) { DebugWrite($"Mode: {mode}, Parameter: {parameter} FrameContent: {frameContent}"); frameContent = frameContent ?? FrameFacadeInternal.Frame.Content; LastNavigationParameter = parameter; LastNavigationType = frameContent.GetType().FullName; var page = frameContent as Page; if (page != null) { if (mode == NavigationMode.New) { var pageState = FrameFacadeInternal.PageStateSettingsService(page.GetType()).Values; pageState?.Clear(); } if (!(page.DataContext is INavigable) | page.DataContext == null) { // to support dependency injection, but keeping it optional. var viewmodel = BootStrapper.Current.ResolveForPage(page.GetType(), this); if (viewmodel != null) { page.DataContext = viewmodel; } } // call viewmodel var dataContext = page.DataContext as INavigable; if (dataContext != null) { // prepare for state load dataContext.NavigationService = this; dataContext.Dispatcher = WindowWrapper.Current(this)?.Dispatcher; dataContext.SessionState = BootStrapper.Current.SessionState; var pageState = FrameFacadeInternal.PageStateSettingsService(page.GetType()).Values; await dataContext.OnNavigatedToAsync(parameter, mode, pageState); { // update bindings after NavTo initializes data XamlUtils.InitializeBindings(page); XamlUtils.UpdateBindings(page); } } } }
/// <summary> /// This runs everytime the app is launched, even after suspension, so we use this to initialize stuff /// </summary> /// <param name="args"></param> /// <returns></returns> public override async Task OnInitializeAsync(IActivatedEventArgs args) { #if DEBUG // Init logger Logger.SetLogger(new ConsoleLogger(LogLevel.Info)); #endif // If we have a phone contract, hide the status bar if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { var statusBar = StatusBar.GetForCurrentView(); await statusBar.HideAsync(); } // Enter into full screen mode ApplicationView.GetForCurrentView().TryEnterFullScreenMode(); ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); ApplicationView.GetForCurrentView().FullScreenSystemOverlayMode = FullScreenSystemOverlayMode.Standard; // Forces the display to stay on while we play //_displayRequest.RequestActive(); WindowWrapper.Current().Window.VisibilityChanged += WindowOnVisibilityChanged; // Turn the display off when the proximity stuff detects the display is covered (battery saver) if (SettingsService.Instance.IsBatterySaverEnabled) { _proximityHelper.EnableDisplayAutoOff(true); } // Init vibration device if (ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice")) { _vibrationDevice = VibrationDevice.GetDefault(); } if (SettingsService.Instance.LiveTileMode == LiveTileModes.Peek) { LiveTileUpdater.EnableNotificationQueue(true); } // Check for network status NetworkInformation.NetworkStatusChanged += NetworkInformationOnNetworkStatusChanged; // Respond to changes in inventory and Pokemon in the immediate viscinity. GameClient.PokemonsInventory.CollectionChanged += PokemonsInventory_CollectionChanged; GameClient.CatchablePokemons.CollectionChanged += CatchablePokemons_CollectionChanged; await Task.CompletedTask; }
private async void listViewSong_ItemClick(object sender, ItemClickEventArgs e) { var clickedItem = (Song)e.ClickedItem; loadRemote(); if (_remote != null) { var response = await ConnectionHelper.ExecuteRequest(_remote.Host, _remote.Port, _remote.User, _remote.Pass, JsonHelper.JsonCommandPlayerOpen("songid", Convert.ToInt32(clickedItem.SongId))); if (response != "statusError" && response != "connectionError") { WindowWrapper.Current().NavigationServices.FirstOrDefault().Navigate(typeof(MainPage)); } } }
private void Hide() { WindowWrapper.Current().Dispatcher.Dispatch(() => { var modal = Window.Current.Content as ModalDialog; if (modal == null) { return; } // animate Storyboard sb = this.Resources["HideSortingMenuStoryboard"] as Storyboard; sb.Begin(); sb.Completed += Cleanup; }); }
public void RaisePropertyChanged([CallerMemberName] string propertyName = null) { if (global::Windows.ApplicationModel.DesignMode.DesignModeEnabled) { return; } try { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } catch { WindowWrapper.Current().Dispatcher.Run(() => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName))); } }
public void Initialize(string key, Frame parent) { var service = WindowWrapper.Current().NavigationServices.GetByFrameId(key) as NavigationService; if (service == null) { service = BootStrapper.Current.NavigationServiceFactory(BootStrapper.BackButton.Ignore, BootStrapper.ExistingContent.Exclude) as NavigationService; service.SerializationService = TLSerializationService.Current; service.FrameFacade.FrameId = key; service.FrameFacade.BackRequested += (s, args) => { if (DetailFrame.Content is IMasterDetailPage detailPage) { detailPage.OnBackRequested(args); if (args.Handled) { return; } } // TODO: maybe checking for the actual width is not the perfect way, // but if it is 0 it means that the control is not loaded, and the event shouldn't be handled if (CanGoBack && ActualWidth > 0) { DetailFrame.GoBack(); args.Handled = true; } else if (ParentFrame.Content is IMasterDetailPage masterPage) { masterPage.OnBackRequested(args); if (args.Handled) { return; } } else if (ParentFrame.CanGoBack && ActualWidth > 0) { ParentFrame.GoBack(); args.Handled = true; } }; } NavigationService = service; DetailFrame = NavigationService.Frame; ParentFrame = parent; }
private async void WebView_OnNewWindowRequested(WebView sender, WebViewNewWindowRequestedEventArgs args) { args.Handled = true; if (args.Uri.AbsoluteUri.Contains("https://www.flashback.org/t") || args.Uri.AbsoluteUri.Contains("https://www.flashback.org/sp")) // intern FB-trådlänk eller fb-singlepost { string id = args.Uri.AbsoluteUri.Replace("https://www.flashback.org/", ""); var nav = WindowWrapper.Current().NavigationServices.FirstOrDefault(); nav?.Navigate(typeof(Views.ThreadPage), id); } else if (args.Uri.AbsoluteUri.Contains("https://www.flashback.org/f")) // intern FB-forumlänk { string id = args.Uri.AbsoluteUri.Replace("https://www.flashback.org/", ""); var nav = WindowWrapper.Current().NavigationServices.FirstOrDefault(); nav?.Navigate(typeof(Views.ForumMainList), id); } else { var dialog = new Windows.UI.Popups.MessageDialog("Vill du verkligen öppna en länk till extern sida? Tänk på att länkar som öppnas från privata meddelanden kan utnytjas för att spåra dig!" + Environment.NewLine + Environment.NewLine + "Länken som kommer öppnas är: " + args.Uri.LocalPath, "Bekräfta"); dialog.Commands.Add(new Windows.UI.Popups.UICommand("Öppna") { Id = 0 }); dialog.Commands.Add(new Windows.UI.Popups.UICommand("Avbryt") { Id = 1 }); dialog.DefaultCommandIndex = 0; dialog.CancelCommandIndex = 1; var resultDialog = await dialog.ShowAsync(); if (resultDialog.Label == "Öppna") { var openUrl = Windows.System.Launcher.LaunchUriAsync(new Uri(System.Net.WebUtility.HtmlDecode(args.Uri.LocalPath))); } } }
private void GameManagerViewModelOnAskForPokemonSelection(object sender, SelectionTarget selectionTarget) { WindowWrapper.Current().Dispatcher.Dispatch(() => { switch (selectionTarget) { case SelectionTarget.SelectForDeploy: PokemonInventorySelector.SelectionMode = ListViewSelectionMode.Single; break; case SelectionTarget.SelectForTeamChange: PokemonInventorySelector.SelectionMode = ListViewSelectionMode.Single; break; } SelectPokemonGrid.Visibility = Visibility.Visible; }); }
private void NavigateTo(NavigationMode mode, object parameter) { parameter = DeserializePageParam(parameter as string); LastNavigationParameter = parameter; LastNavigationType = FrameFacade.Content.GetType().FullName; if (mode == NavigationMode.New) { FrameFacade.ClearFrameState(); } var page = FrameFacade.Content as Page; if (page == null) { return; } var insightsService = App.Current.Kernel.Resolve <IInsightsService>(); insightsService.TrackPageView(page.GetType().Name); if (page.DataContext == null) { // to support dependency injection, but keeping it optional. var viewmodel = BootStrapper.Current.ResolveForPage(page.GetType(), this); if (viewmodel != null) { page.DataContext = viewmodel; } } // call viewmodel var dataContext = page.DataContext as INavigable; if (dataContext != null) { // prepare for state load dataContext.NavigationService = this; dataContext.Dispatcher = WindowWrapper.Current(this)?.Dispatcher; dataContext.SessionState = BootStrapper.Current.SessionState; var pageState = FrameFacade.PageStateContainer(page.GetType()); dataContext.OnNavigatedTo(parameter, mode, pageState); } }
// hide and show busy dialog public static void ShowAuth(bool show, TaskCompletionSource <string> taskCompletionSource = null) { WindowWrapper.Current().Dispatcher.Dispatch(() => { var modal = Window.Current.Content as ModalDialog; modal.ModalBackground = new SolidColorBrush(Colors.Black) { Opacity = .5 }; if (!(modal.ModalContent is AuthModal view)) { modal.ModalContent = view = new AuthModal(); } modal.IsModal = show; view._authCompletionSource = taskCompletionSource; }); }
public void Handle(UpdateNewMessage update) { if (update.DisableNotification) { return; } // Adding some delay to be 110% the message hasn't been read already ThreadPoolTimer.CreateTimer(timer => { var chat = _protoService.GetChat(update.Message.ChatId); if (chat == null || chat.LastReadInboxMessageId >= update.Message.Id) { return; } var caption = _protoService.GetTitle(chat); var content = UpdateFromLabel(chat, update.Message) + GetBriefLabel(update.Message); var sound = ""; var launch = "GetLaunch(commonMessage)"; var tag = update.Message.Id.ToString(); var group = GetGroup(update.Message, chat); var picture = string.Empty; var date = BindConvert.Current.DateTime(update.Message.Date).ToString("o"); var loc_key = "CHANNEL"; //var loc_key = commonMessage.Parent is TLChannel channel && channel.IsBroadcast ? "CHANNEL" : string.Empty; Execute.BeginOnUIThread(() => { var service = WindowWrapper.Current().NavigationServices.GetByFrameId("Main"); if (service == null) { return; } if (WindowContext.GetForCurrentView().ActivationState != Windows.UI.Core.CoreWindowActivationState.Deactivated && service.CurrentPageType == typeof(DialogPage) && (long)service.CurrentPageParam == chat.Id) { return; } NotificationTask.UpdateToast(caption, content, sound, launch, tag, group, picture, date, loc_key); NotificationTask.UpdatePrimaryTile(caption, content, picture); }); }, TimeSpan.FromSeconds(2)); }
private void List_ItemClick(object sender, ItemClickEventArgs e) { var lang = e.ClickedItem as TLLangPackLanguage; if (lang == null) { return; } ApplicationLanguages.PrimaryLanguageOverride = lang.LangCode; ResourceContext.GetForCurrentView().Reset(); ResourceContext.GetForViewIndependentUse().Reset(); WindowWrapper.Current().NavigationServices.Remove(ViewModel.NavigationService); BootStrapper.Current.NavigationService.Reset(); //new LocaleService(ViewModel.ProtoService).applyRemoteLanguage(e.ClickedItem as TLLangPackLanguage, true); }
public async void RaisePropertyChanged([CallerMemberName] string propertyName = null) { if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { return; } // ensure there is a windows, which is NULL in case of a background task var window = WindowWrapper.Current(); if (window != null) { await window.Dispatcher.DispatchAsync(() => { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }); } }
private async void DelCourseBtn_Clicked(object sender, RoutedEventArgs e) { var dialog = new DialogBox() { Title = "提示", PrimaryButtonText = "取消", SecondaryButtonText = "确定" }; dialog.mainTextBlock.Text = "确定要删除该课程?"; if (await dialog.ShowAsync() == ContentDialogResult.Secondary) { await CourseManager.Remove(course); var nav = WindowWrapper.Current().NavigationServices.FirstOrDefault(); nav.Navigate(typeof(MainPage), null); } }
protected virtual void ViewExecute() { NavigationService.GoBack(); var message = _selectedItem as GalleryMessageItem; if (message == null) { return; } var service = WindowWrapper.Current().NavigationServices.GetByFrameId("Main"); if (service != null) { service.NavigateToChat(message.ChatId, message: message.Id); } }
protected internal NavigationService(Frame frame) { SerializationService = Services.SerializationService.SerializationService.Json; FrameFacadeInternal = new FrameFacade(this, frame); FrameFacadeInternal.Navigating += async(s, e) => { if (e.Suspending) { return; } // allow the viewmodel to cancel navigation e.Cancel = !(await NavigatingFromAsync(false, e.NavigationMode)); if (!e.Cancel) { await NavigateFromAsync(false); } }; FrameFacadeInternal.Navigated += async(s, e) => { var parameter = SerializationService.Deserialize(e.Parameter?.ToString()); var currentContent = FrameFacadeInternal.Frame.Content; if (Equals(e.Parameter?.ToString(), SerializationService.Serialize(LastNavigationParameter))) { parameter = LastNavigationParameter; } await WindowWrapper.Current().Dispatcher.DispatchAsync(async() => { try { if (currentContent == FrameFacadeInternal.Frame.Content) { await NavigateToAsync(e.NavigationMode, parameter, FrameFacadeInternal.Frame.Content); } } catch (Exception ex) { DebugWrite($"DispatchAsync/NavigateToAsync {ex.Message}"); throw; } }, 1); }; }
private void UpdateAvailableDevices() { switch (SelectedTransportType) { case TransportType.Serial: WindowWrapper.Current().Dispatcher.Dispatch(() => { BusySrv.ShowBusy(Res.GetString("HC_Searching")); AvailableDevices = new ObservableCollection <NanoDeviceBase>(SerialDebugService.SerialDebugClient.NanoFrameworkDevices); SerialDebugService.SerialDebugClient.NanoFrameworkDevices.CollectionChanged += NanoFrameworkDevices_CollectionChanged; // if there's just one, select it SelectedDevice = (AvailableDevices.Count == 1) ? AvailableDevices.First() : null; BusySrv.HideBusy(); }); break; case TransportType.Usb: WindowWrapper.Current().Dispatcher.Dispatch(() => { BusySrv.ShowBusy(Res.GetString("HC_Searching")); AvailableDevices = new ObservableCollection <NanoDeviceBase>(UsbDebugService.UsbDebugClient.NanoFrameworkDevices); UsbDebugService.UsbDebugClient.NanoFrameworkDevices.CollectionChanged += NanoFrameworkDevices_CollectionChanged; // if there's just one, select it SelectedDevice = (AvailableDevices.Count == 1) ? AvailableDevices.First() : null; BusySrv.HideBusy(); }); break; case TransportType.TcpIp: // TODO //BusySrv.ShowBusy("Not implemented yet! Why not give it a try??"); //await Task.Delay(2500); //await WindowWrapper.Current().Dispatcher.DispatchAsync(() => //{ // AvailableDevices = new ObservableCollection<NanoDeviceBase>(); // SelectedDevice = null; //}); //BusySrv.HideBusy(); break; } }
private async void NetworkInformationOnNetworkStatusChanged(object sender) { var connectionProfile = NetworkInformation.GetInternetConnectionProfile(); var tmpNetworkStatus = connectionProfile != null && connectionProfile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess; await WindowWrapper.Current().Dispatcher.DispatchAsync(() => { if (tmpNetworkStatus) { Logger.Write("Network is online"); Busy.SetBusy(false); } else { Logger.Write("Network is offline"); Busy.SetBusy(true, Utils.Resources.CodeResources.GetString("WaitingForNetworkText")); } }); }
// hide and show busy dialog public static void SetBusy(bool busy, string text = null) { WindowWrapper.Current().Dispatcher.Dispatch(() => { var modal = Window.Current.Content as ModalDialog; modal.ModalBackground = new SolidColorBrush(Color.FromArgb(255, 248, 248, 248)) { Opacity = .5 }; var view = modal.ModalContent as Busy; if (view == null) { modal.ModalContent = view = new Busy(); } modal.IsModal = view.IsBusy = busy; view.BusyText = text; }); }
private void SendExecute() { var switchInline = SwitchInline; var switchInlineBot = SwitchInlineBot; var sendMessage = SendMessage; var sendMessageUrl = SendMessageUrl; NavigationService.GoBack(); var service = WindowWrapper.Current().NavigationServices.GetByFrameId("Main"); if (service != null) { App.InMemoryState.SwitchInline = switchInline; App.InMemoryState.SwitchInlineBot = switchInlineBot; App.InMemoryState.SendMessage = sendMessage; App.InMemoryState.SendMessageUrl = sendMessageUrl; service.NavigateToDialog(_selectedItem); } }
private void GameManagerViewModelOnShowBattleOutcome(object sender, BattleOutcomeResultEventArgs battleResult) { WindowWrapper.Current().Dispatcher.Dispatch(() => { BattleOutcome.Text = battleResult.BattleOutcome; if (battleResult.TotalGymPrestigeDelta > 0) { TotalGymPrestigeDelta.Text = "+" + battleResult.TotalGymPrestigeDelta.ToString(); } else { TotalGymPrestigeDelta.Text = battleResult.TotalGymPrestigeDelta.ToString(); } TotalPlayerXpEarned.Text = battleResult.TotalPlayerXpEarned.ToString(); PokemonDefeated.Text = battleResult.PokemonDefeated.ToString(); BattleOutcomeGrid.Visibility = Visibility.Visible; ShowBattleOutcomeStoryboard.Begin(); }); }