public GalleryWindow() { View = new GalleryView(); //must set the view first InitializeComponent(); //IsAnimated = false; //workarround: Can't turn over Pivot viewer when using 3D-style rotation, thowing transformation class cast errors }
private async void Photo_Click(object sender, RoutedEventArgs e) { var chat = ViewModel.Chat; if (chat == null) { return; } if (chat.Type is ChatTypePrivate || chat.Type is ChatTypeSecret) { var user = ViewModel.ProtoService.GetUser(chat); if (user == null || user.ProfilePhoto == null) { return; } var viewModel = new UserPhotosViewModel(ViewModel.ProtoService, ViewModel.Aggregator, user); await GalleryView.GetForCurrentView().ShowAsync(viewModel, () => Photo); } //var user = ViewModel.Item as TLUser; //var userFull = ViewModel.Full as TLUserFull; //if (userFull != null && userFull.ProfilePhoto is TLPhoto && user != null) //{ // var viewModel = new UserPhotosViewModel(ViewModel.LegacyService, userFull, user); // await GalleryView.Current.ShowAsync(viewModel, () => Photo); //} }
private async void Photo_Click(object sender, RoutedEventArgs e) { var chat = ViewModel.Chat; if (chat == null) { return; } if (chat.Type is ChatTypePrivate or ChatTypeSecret) { var user = ViewModel.ProtoService.GetUser(chat); if (user == null || user.ProfilePhoto == null) { return; } var userFull = ViewModel.ProtoService.GetUserFull(user.Id); if (userFull?.Photo == null) { return; } var viewModel = new UserPhotosViewModel(ViewModel.ProtoService, ViewModel.Aggregator, user, userFull); await GalleryView.GetForCurrentView().ShowAsync(viewModel, () => Photo); }
public static ContentView AsView(this PageType type) { ContentView view = null; switch (type) { case PageType.Analysis: view = new AnalysisView(); break; case PageType.Favorites: view = new FavoritesView(); break; case PageType.Gallery: view = new GalleryView(); break; case PageType.Home: view = new UploadView(); break; case PageType.Search: view = new SearchResultsView(); break; case PageType.Timeline: view = new TimelineView(); break; } return(view); }
private async void Photo_Click(object sender, RoutedEventArgs e) { var element = sender as FrameworkElement; var message = element.Tag as MessageWithOwner; var viewModel = new ChatGalleryViewModel(ViewModel.ProtoService, ViewModel.StorageService, ViewModel.Aggregator, message.ChatId, 0, message.Get(), true); await GalleryView.GetForCurrentView().ShowAsync(viewModel, () => element); }
public static CustomImageTableCell Create(GalleryView BaseView2, GalleryDataModel GelenDTO) { var OlusanView = (CustomImageTableCell)Nib.Instantiate(null, null)[0]; OlusanView.BaseView = BaseView2; OlusanView.GelenDTO = GelenDTO; return(OlusanView); }
public async void OpenMedia(MessageViewModel message, FrameworkElement target) { //ViewModel.Gallery.SelectedItem = item; //ViewModel.Gallery.FirstItem = item; ViewModel.Gallery.SelectedItem = ViewModel.Gallery.Items.FirstOrDefault(); ViewModel.Gallery.FirstItem = ViewModel.Gallery.Items.FirstOrDefault(); await GalleryView.GetForCurrentView().ShowAsync(ViewModel.Gallery, () => target); }
public void DisplayGallery(List <GalleryImage> images) { int offsetLeft = 10, offsetTop = 5; int left = offsetLeft, top = (int)TakePicture.Frame.Height + 5, imgHeight = 50, imgWidth = 50, frameWidth = (int)View.Frame.Width; Task.Run(() => { foreach (var img in images) { var uiImg = UIImage.LoadFromData(NSData.FromUrl(new NSUrl(img.url))); if (left + imgWidth + offsetLeft > frameWidth) { left = offsetLeft; top += imgHeight + offsetTop; } InvokeOnMainThread(() => { UIButton btn = new UIButton(new CGRect(left, top, imgWidth, imgHeight)); btn.SetImage(uiImg, UIControlState.Normal); btn.TouchUpInside += ((object sender, EventArgs e) => { var imgToDisplay = ((UIButton)sender).ImageView.Image; var btnImg = UIButton.FromType(UIButtonType.Custom); btnImg.BackgroundColor = UIColor.Black; btnImg.Frame = new CGRect(0, 0, View.Frame.Width, View.Frame.Height); btnImg.SetImage(imgToDisplay, UIControlState.Normal); btnImg.TouchUpInside += ((object sender2, EventArgs e2) => { NavigationController.DismissModalViewController(true); }); UIViewController ctrl = new UIViewController(); ctrl.View.Add(btnImg); NavigationController.PresentModalViewController(ctrl, true); }); GalleryView.AddSubview(btn); }); left += imgWidth + offsetLeft; } InvokeOnMainThread(() => { _spinner.Hide(); }); }); }
private async void Image_Click(object sender, RoutedEventArgs e) { var image = sender as ImageView; var item = image.DataContext as GalleryItem; if (item != null) { ViewModel.Gallery.SelectedItem = item; ViewModel.Gallery.FirstItem = item; await GalleryView.GetForCurrentView().ShowAsync(ViewModel.Gallery, () => image); } }
public MainWindow() { InitializeComponent(); this.Top = 0; this.Left = 0; this.Title = "BuulletinApp"; this.Height = 768; this.Width = 1366; this.WindowStyle = System.Windows.WindowStyle.None; this.AllowsTransparency = true; this.Background = Brushes.Transparent; this.Topmost = true; this.Loaded += OnLoaded; double marqueetime; if (!double.TryParse(ConfigurationManager.AppSettings["MarqueeTimeInSeconds"], out marqueetime)) { marqueetime = 160; } this.marqueecontrol.MarqueeTimeInSeconds = marqueetime; BroadManager.Instance.Register(); _tmSysDateTimer = new DispatcherTimer(); _tmSysDateTimer.Tick += new EventHandler(tmSysDateTimer_Tick); _tmSysDateTimer.Interval = TimeSpan.FromSeconds(1); _tmSysDateTimer.Start(); standbytimer = new System.Timers.Timer(); standbytimer.Interval = Convert.ToDouble(ConfigurationManager.AppSettings["Interval"]); standbytimer.Elapsed += standbytimer_Elapsed; marqueetimer = new System.Timers.Timer(); marqueetimer.Interval = Convert.ToDouble(ConfigurationManager.AppSettings["Marquee"]); // marqueetimer.Interval = 60000; marqueetimer.Elapsed += marqueetimer_Elapsed; reloadtimer = new System.Timers.Timer(); reloadtimer.Interval = Convert.ToDouble(ConfigurationManager.AppSettings["Reload"]); reloadtimer.Elapsed += reloadtimer_Elapsed; ieWin = new WebView(); galleryWin = new GalleryView(); exeWin = new ExeView(); exeWin.OnOpenExeEvent += exeWin_OnOpenExeEvent; if (!string.IsNullOrEmpty(BroadManager.Instance.Items[0].PlayPath)) { standby.Source = new Uri(BroadManager.Instance.Items[0].PlayPath, UriKind.Relative); } }
public ActionResult Create(GalleryView galleryView, IEnumerable <HttpPostedFileBase> PhotoFile) { if (ModelState.IsValid) { //Upload gallery main photo to ~/Images/Galleries string filename = Path.GetFileNameWithoutExtension(galleryView.MainPhotoFile.FileName) + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(galleryView.MainPhotoFile.FileName); galleryView.MainPhotoPath = "~/Images/Galleries/" + filename; filename = Path.Combine(Server.MapPath("~/Images/Galleries/"), filename); galleryView.MainPhotoFile.SaveAs(filename); //Pass the gallery inf from ProductView model to Gallery model Gallery gallery = new Gallery(); gallery.Title = galleryView.Title; gallery.Description = galleryView.Description; gallery.MainPhotoPath = galleryView.MainPhotoPath; //Save the gallery inf into database table Gallery db.Galleries.Add(gallery); db.SaveChanges(); //Upload multiple gallery photos to ~/Images/Galleries foreach (var file in galleryView.PhotoFile) { if (file == null) { return(RedirectToAction("Index")); } string filename2 = Path.GetFileNameWithoutExtension(file.FileName) + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(file.FileName); galleryView.PhotoPath = "~/Images/Photos/" + filename2; filename2 = Path.Combine(Server.MapPath("~/Images/Photos/"), filename2); file.SaveAs(filename2); //Pass the photo inf from ProductView model to Gallery model Photo photo = new Photo(); photo.GalleryId = gallery.GalleryId; photo.PhotoPath = galleryView.PhotoPath; //Save the photo inf into database table Gallery db.Photos.Add(photo); db.SaveChanges(); } return(RedirectToAction("Index")); } return(View(galleryView)); }
protected override void OnAppearing() { base.OnAppearing(); var galleryView = new GalleryView { Padding = 10, BackgroundColor = Color.Gray, Children = { new Label { BackgroundColor = Color.Red, Text = "First", XAlign = TextAlignment.Center, YAlign = TextAlignment.Center } , new Label { BackgroundColor = Color.Green, Text = "Second", XAlign = TextAlignment.Center, YAlign = TextAlignment.Center }, new Label { BackgroundColor = Color.Aqua, Text = "Third", XAlign = TextAlignment.Center, YAlign = TextAlignment.Center }, new Label { BackgroundColor = Color.Blue, Text = "Last", XAlign = TextAlignment.Center, YAlign = TextAlignment.Center }, } }; galleryView.ActivatePage(galleryView.Children [1], false); Content = new StackLayout { Padding = 8, HeightRequest = 150, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { galleryView } }; }
protected override void OnAppearing () { base.OnAppearing (); var galleryView = new GalleryView { Padding = 10, BackgroundColor = Color.Gray, Children = { new Label { BackgroundColor = Color.Red, Text = "First", XAlign = TextAlignment.Center, YAlign = TextAlignment.Center } , new Label { BackgroundColor = Color.Green, Text = "Second", XAlign = TextAlignment.Center, YAlign = TextAlignment.Center }, new Label { BackgroundColor = Color.Aqua, Text = "Third", XAlign = TextAlignment.Center, YAlign = TextAlignment.Center }, new Label { BackgroundColor = Color.Blue, Text = "Last", XAlign = TextAlignment.Center, YAlign = TextAlignment.Center }, } }; galleryView.ActivatePage (galleryView.Children [1], false); Content = new StackLayout{ Padding = 8, HeightRequest = 150, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { galleryView } }; }
public MainForm() { welcomeView = new WelcomeView(this); preferencesView = new PreferencesView(this); galleryView = new GalleryView(this); Title = "badabing"; ClientSize = new Size(720, 480); Content = new StackLayout { Orientation = Orientation.Vertical, HorizontalContentAlignment = HorizontalAlignment.Center, Spacing = 5, Padding = new Padding(10), Items = { welcomeView, preferencesView, galleryView } }; preferencesView.Visible = false; galleryView.Visible = false; }
public async void PlayMessage(MessageViewModel message, FrameworkElement target) { var text = message.Content as MessageText; // If autoplay is enabled and the message contains a video note, then we want a different behavior if (ViewModel.Settings.IsAutoPlayAnimationsEnabled && (message.Content is MessageVideoNote || text?.WebPage != null && text.WebPage.Video != null)) { ViewModel.PlaybackService.Play(message, ViewModel.ThreadId); //if (_old.TryGetValue(message.Id, out MediaPlayerItem item)) //{ // if (item.Presenter == null || item.Presenter.MediaPlayer == null) // { // return; // } // // If the video player is muted, then let's play the video again with audio turned on // if (item.Presenter.MediaPlayer.IsMuted) // { // TypedEventHandler<MediaPlayer, object> handler = null; // handler = (player, args) => // { // player.MediaEnded -= handler; // player.IsMuted = true; // player.IsLoopingEnabled = true; // player.Play(); // }; // item.Presenter.MediaPlayer.MediaEnded += handler; // item.Presenter.MediaPlayer.IsMuted = false; // item.Presenter.MediaPlayer.IsLoopingEnabled = false; // item.Presenter.MediaPlayer.PlaybackSession.Position = TimeSpan.Zero; // // Mark it as viewed if needed // if (message.Content is MessageVideoNote videoNote && !message.IsOutgoing && !videoNote.IsViewed) // { // ViewModel.ProtoService.Send(new OpenMessageContent(message.ChatId, message.Id)); // } // } // // If the video player is paused, then resume playback // else if (item.Presenter.MediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Paused) // { // item.Presenter.MediaPlayer.Play(); // } // // And last, if the video player can be pause, then pause it // else if (item.Presenter.MediaPlayer.PlaybackSession.CanPause) // { // item.Presenter.MediaPlayer.Pause(); // } //} } else if (ViewModel.Settings.IsAutoPlayAnimationsEnabled && (message.Content is MessageAnimation || (text?.WebPage != null && text.WebPage.Animation != null) || (message.Content is MessageGame game && game.Game.Animation != null))) { if (_prev.TryGetValue(message.AnimationHash(), out WeakReference reference) && reference.Target is IPlayerView item) { GalleryViewModelBase viewModel; if (message.Content is MessageAnimation) { viewModel = new ChatGalleryViewModel(ViewModel.ProtoService, ViewModel.StorageService, ViewModel.Aggregator, message.ChatId, ViewModel.ThreadId, message.Get()); } else { viewModel = new SingleGalleryViewModel(ViewModel.ProtoService, ViewModel.StorageService, ViewModel.Aggregator, new GalleryMessage(ViewModel.ProtoService, message.Get())); } await GalleryView.GetForCurrentView().ShowAsync(viewModel, () => target); } else { ViewVisibleMessages(false); } }
public async void PlayMessage(MessageViewModel message, FrameworkElement target) { var text = message.Content as MessageText; // If autoplay is enabled and the message contains a video note, then we want a different behavior if (ViewModel.Settings.IsAutoPlayAnimationsEnabled && (message.Content is MessageVideoNote || text?.WebPage != null && text.WebPage.Video != null)) { if (SettingsService.Current.Diagnostics.SoftwareDecoderEnabled) //TODO: Make audio and video playable like in other clients: together & control on top... { ViewModel.PlaybackService.Enqueue(message.Get()); } //if (_old.TryGetValue(message.Id, out MediaPlayerItem item)) //{ // if (item.Presenter == null || item.Presenter.MediaPlayer == null) // { // return; // } // // If the video player is muted, then let's play the video again with audio turned on // if (item.Presenter.MediaPlayer.IsMuted) // { // TypedEventHandler<MediaPlayer, object> handler = null; // handler = (player, args) => // { // player.MediaEnded -= handler; // player.IsMuted = true; // player.IsLoopingEnabled = true; // player.Play(); // }; // item.Presenter.MediaPlayer.MediaEnded += handler; // item.Presenter.MediaPlayer.IsMuted = false; // item.Presenter.MediaPlayer.IsLoopingEnabled = false; // item.Presenter.MediaPlayer.PlaybackSession.Position = TimeSpan.Zero; // // Mark it as viewed if needed // if (message.Content is MessageVideoNote videoNote && !message.IsOutgoing && !videoNote.IsViewed) // { // ViewModel.ProtoService.Send(new OpenMessageContent(message.ChatId, message.Id)); // } // } // // If the video player is paused, then resume playback // else if (item.Presenter.MediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Paused) // { // item.Presenter.MediaPlayer.Play(); // } // // And last, if the video player can be pause, then pause it // else if (item.Presenter.MediaPlayer.PlaybackSession.CanPause) // { // item.Presenter.MediaPlayer.Pause(); // } //} if (_old.TryGetValue(message.Id, out MediaPlayerItem item)) { if (item.MediaPlayerPresenter?.MediaPlayer == null) { return; } // If the video player is muted, then let's play the video again with audio turned on if (item.MediaPlayerPresenter.MediaPlayer.IsMuted) { item.MediaPlayerPresenter.MediaPlayer.IsMuted = false; item.MediaPlayerPresenter.MediaPlayer.IsLoopingEnabled = false; item.MediaPlayerPresenter.MediaPlayer.PlaybackSession.Position = TimeSpan.Zero; PauseAllOtherVideoNotes(message.Id); // Mark it as viewed if needed if (message.Content is MessageVideoNote videoNote && !message.IsOutgoing && !videoNote.IsViewed) { ViewModel.ProtoService.Send(new OpenMessageContent(message.ChatId, message.Id)); } if (item.Container.FindName("Progress") is RadialProgressBar progress) { progress.Maximum = item.MediaPlayerPresenter.MediaPlayer.PlaybackSession.NaturalDuration.TotalSeconds; async void ProgressHandler(Windows.Media.Playback.MediaPlaybackSession session, object args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { progress.Value = session.Position.TotalSeconds; }); } item.MediaPlayerPresenter.MediaPlayer.PlaybackSession.PositionChanged -= ProgressHandler; item.MediaPlayerPresenter.MediaPlayer.PlaybackSession.PositionChanged += ProgressHandler; } // MediaEnded if (item.Container.FindName("MutedIcon") is StackPanel mutedIcon) { mutedIcon.Visibility = Visibility.Collapsed; async void MediaEndedHandler(Windows.Media.Playback.MediaPlayer player, object args) { player.IsMuted = true; if (player.PlaybackSession.CanPause) { player.Pause(); } await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { mutedIcon.Visibility = Visibility.Visible; }); //TODO: Play next media content and scroll to that one } item.MediaPlayerPresenter.MediaPlayer.MediaEnded -= MediaEndedHandler; item.MediaPlayerPresenter.MediaPlayer.MediaEnded += MediaEndedHandler; } if (item.MediaPlayerPresenter.MediaPlayer.PlaybackSession.PlaybackState == Windows.Media.Playback.MediaPlaybackState.Paused) { item.MediaPlayerPresenter.MediaPlayer.Play(); } } // If the video player is paused, then resume playback else if (item.MediaPlayerPresenter.MediaPlayer.PlaybackSession.PlaybackState == Windows.Media.Playback.MediaPlaybackState.Paused) { item.MediaPlayerPresenter.MediaPlayer.IsMuted = false; item.MediaPlayerPresenter.MediaPlayer.Play(); PauseAllOtherVideoNotes(message.Id); if (item.Container.FindName("MutedIcon") is StackPanel mutedIcon) { mutedIcon.Visibility = Visibility.Collapsed; } } // And last, if the video player can be pause, then pause it else if (item.MediaPlayerPresenter.MediaPlayer.PlaybackSession.CanPause) { item.MediaPlayerPresenter.MediaPlayer.Pause(); // Note: UWP has no event or public player state property, so it gets hardcoded: if (item.Container.FindName("MutedIcon") is StackPanel mutedIcon) { mutedIcon.Visibility = Visibility.Visible; } } } } else if (ViewModel.Settings.IsAutoPlayAnimationsEnabled && (message.Content is MessageAnimation || (text?.WebPage != null && text.WebPage.Animation != null) || (message.Content is MessageGame game && game.Game.Animation != null))) { if (_old.TryGetValue(message.AnimationHash(), out MediaPlayerItem item)) { GalleryViewModelBase viewModel; if (message.Content is MessageAnimation) { viewModel = new ChatGalleryViewModel(ViewModel.ProtoService, ViewModel.Aggregator, message.ChatId, ViewModel.ThreadId, message.Get()); } else { viewModel = new SingleGalleryViewModel(ViewModel.ProtoService, ViewModel.Aggregator, new GalleryMessage(ViewModel.ProtoService, message.Get())); } await GalleryView.GetForCurrentView().ShowAsync(viewModel, () => target); } else { ViewVisibleMessages(false); } }