async protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif await HelperUP.LoadTokensAsync(); ChangeStatusBar(); Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { rootFrame.Navigate(typeof(FolderPage), e.Arguments); } Window.Current.Activate(); }
private void MediaElement_CurrentStateChanged(object sender, RoutedEventArgs e) { if (PlayerPage.Current != null && PlayerPage.Current.MediaElement != null) { HelperUP.Output("MediaElement_CurrentStateChanged pumped+" + PlayerPage.Current.MediaElement.CurrentState); switch (PlayerPage.Current.MediaElement.CurrentState) { case MediaElementState.Playing: PlayPauseButtonCTM.Icon = new BitmapIcon { UriSource = new Uri("ms-appx:///Assets/pauseIcon.png") }; break; case MediaElementState.Closed: case MediaElementState.Opening: case MediaElementState.Paused: case MediaElementState.Stopped: PlayPauseButtonCTM.Icon = new BitmapIcon { UriSource = new Uri("ms-appx:///Assets/playIcon.png") }; break; default: PlayPauseButtonCTM.Icon = new BitmapIcon { UriSource = new Uri("ms-appx:///Assets/playIcon.png") }; break; } } }
public async Task SetInfoByFileAsync(bool setThumnail = false) { if (File == null) { return; } Name = File.Name; Path = File.Path; if (setThumnail) { SetThumbnail(); } try { var info = await File.Properties.GetVideoPropertiesAsync(); Duration = string.Format("{0}:{1}:{2}", info.Duration.Hours.ToString("00"), info.Duration.Minutes.ToString("00"), info.Duration.Seconds.ToString("00")); } catch (Exception ex) { Debug.WriteLine("SetInfoByFile.GetVideoPropertiesAsync ex: " + ex.Message); } try { BasicProperties basicProperties = await File.GetBasicPropertiesAsync(); Size = HelperUP.CalculateBytes(basicProperties.Size); DateModified = basicProperties.DateModified.ToString(); } catch (Exception ex) { Debug.WriteLine("SetInfoByFile.GetBasicPropertiesAsync ex: " + ex.Message); } Type = File.FileType; FolderCount = string.Empty; }
public void SetShowBox(bool show) { if (show) { ShadowBorder.Background = new SolidColorBrush(HelperUP.GetColorFromHex("#7F000000")); } else { ShadowBorder.Background = new SolidColorBrush(Colors.Transparent); } }
private void FolderPage_Loaded(object sender, RoutedEventArgs e) { lv.Items.Clear(); if (HelperUP.TokenList != null && HelperUP.TokenList.Any()) { foreach (var item in HelperUP.TokenList) { HelperUP.Output(Directory.GetDirectoryRoot(item.Path)); lv.Items.Add(item); } } }
private void Dt_Tick(object sender, object e) { try { if (SubtitleList != null && SubtitleList.Any() && showSubtitle) { var v = (from item in SubtitleList where item != null && item.StartTime + seekDouble <= mediaElement.Position.TotalMilliseconds && item.EndTime + seekDouble >= mediaElement.Position.TotalMilliseconds orderby item descending select item).FirstOrDefault(); CurrentSubtitleItem = v; if (v != null) { customMTC.SubtitleText.Blocks.Clear(); Paragraph myParagraph = new Paragraph(); int nextParagraph = 1; foreach (string item in v.Lines) { if (GetRun(item) != null) { myParagraph.Inlines.Add(GetRun(item.Replace("ي", "ی"))); try { if (v.Lines.Count < nextParagraph && v.Lines[nextParagraph] != null) { myParagraph.Inlines.Add(new LineBreak()); } } catch (Exception ex) { HelperUP.Output("nextParagraph ex: " + ex.Message); } } nextParagraph++; } customMTC.SubtitleText.Blocks.Add(myParagraph); customMTC.ShadowBorder.Visibility = customMTC.SubtitleText.Visibility = Windows.UI.Xaml.Visibility.Visible; } else { customMTC.ShadowBorder.Visibility = customMTC.SubtitleText.Visibility = Windows.UI.Xaml.Visibility.Collapsed; customMTC.SubtitleText.Blocks.Clear(); } } else { customMTC.SubtitleText.Blocks.Clear(); } } catch (Exception ex) { HelperUP.Output("mediaPlayer_PositionChanged ex: " + ex.Message); } }
async public void ImportSubtitle(StorageFile file) { try { if (file == null) { return; } Stream stream = await file.OpenStreamForReadAsync(); var parser = new SubParser(); var fileName = Path.GetFileName(file.Path); SubtitleEncoding Subencoding = HelperUP.GetSubtitleEncoding(stream); Encoding encoding = new UTF8Encoding(); if (Subencoding == SubtitleEncoding.ASCII) { encoding = new ASCIIEncoding(); } else if (Subencoding == SubtitleEncoding.Unicode) { encoding = new UnicodeEncoding(); } else if (Subencoding == SubtitleEncoding.UTF8) { encoding = new UTF8Encoding(); } else if (Subencoding == SubtitleEncoding.Windows1256) { encoding = new CustomCP1256Encoding(); } else if (Subencoding == SubtitleEncoding.UTF7) { encoding = new UTF7Encoding(); } else if (Subencoding == SubtitleEncoding.UTF32) { encoding = Encoding.UTF32; } else if (Subencoding == SubtitleEncoding.BigEndianUnicode) { encoding = Encoding.BigEndianUnicode; } var mostLikelyFormat = parser.GetMostLikelyFormat(fileName, stream, encoding); HelperUP.Output("mostLikelyFormat: " + mostLikelyFormat.Name); SubtitleList = parser.ParseStream(await file.OpenStreamForReadAsync(), encoding, mostLikelyFormat); dt.Start(); } catch (Exception ex) { HelperUP.Output("ImportSubtitle ex: " + ex.Message); } }
private void Mfi_Click(object sender, RoutedEventArgs e) { if (sender != null) { try { MenuFlyoutItem mfi = sender as MenuFlyoutItem; ItemSub itemSub = mfi.Tag as ItemSub; if (itemSub != null && itemSub.File != null) { ImportSubtitle(itemSub.File); } } catch (Exception ex) { HelperUP.Output("mediaElement_DoubleTapped ex: " + ex.Message); } } }
private void backRequested(object sender, BackRequestedEventArgs e) { if (lockBackButton) { e.Handled = true; return; } Debug.WriteLine(((Frame)Window.Current.Content).GetType()); if (Window.Current.Content != null && ((Frame)Window.Current.Content).Content.GetType() == typeof(PlayerPage)) { if (((Frame)Window.Current.Content).CanGoBack) { e.Handled = true; HelperUP.Output("reqa"); ((Frame)Window.Current.Content).GoBack(); return; } } if (FolderPage.Current != null && FolderPage.Current.MyFrame != null) { if (FolderPage.Current.MyFrame.CanGoBack) { e.Handled = true; FolderPage.Current.MyFrame.GoBack(); if (!FolderPage.Current.MyFrame.CanGoBack) { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } } HelperUP.Output("req"); if (!FolderPage.Current.MyFrame.CanGoBack) { if (FolderPage.Current.MyFrame.Visibility == Visibility.Visible) { e.Handled = true; FolderPage.Current.MyFrame.Visibility = Visibility.Collapsed; FolderPage.Current.LV.Visibility = Visibility.Visible; FolderPage.Current.Text = ""; } } } }
private void ZoomedOutGridView_ItemClick(object sender, ItemClickEventArgs e) { if (e != null && e.ClickedItem != null && e.ClickedItem.GetType() == typeof(Item)) { var item = e.ClickedItem as Item; if (item.Folder != null) { FolderPage.Current.MyFrame.Navigate(typeof(FileManagerPage1), item.Folder); } else if (item.File != null) { HelperUP.Output("sublistCount:" + subList.Count); ((Frame)Window.Current.Content).Navigate(typeof(PlayerPage), new ItemWithItemSub { ItemSubList = subList, Item = item }); } } }
private void FullWindowBTN_Click(object sender, RoutedEventArgs e) { if (PlayerPage.Current != null && PlayerPage.Current.MediaElement != null) { if (PlayerPage.Current.MediaElement.IsFullWindow) { PlayerPage.Current.MediaElement.IsFullWindow = false; FullWindowBTN.Icon = new SymbolIcon(Symbol.BackToWindow); ShowSomething("Default screen"); } else { PlayerPage.Current.MediaElement.IsFullWindow = true; FullWindowBTN.Icon = new SymbolIcon(Symbol.FullScreen); ShowSomething("Full screen"); } HelperUP.Output("IsFullWindow " + PlayerPage.Current.MediaElement.IsFullWindow) ; } }
private async void btnAddFolder_Click(object sender, RoutedEventArgs e) { var folderPicker = new FolderPicker(); folderPicker.FileTypeFilter.Add("*"); var folder = await folderPicker.PickSingleFolderAsync(); if (folder == null) { return; } var randomName = HelperUP.CreateTokenName(); MToken token = new MToken(); token.Name = folder.Name; token.Path = folder.Path; token.Token = randomName; if (HelperUP.AddToken(token)) { StorageApplicationPermissions.FutureAccessList.AddOrReplace(token.Token, folder); LV.Items.Add(token); } }
protected override void OnApplyTemplate() { HelperUP.Output("OnApplyTemplate"); transformTopTimelineBorder = GetTemplateChild("transformTopTimelineBorder") as CompositeTransform; darknessBorder = GetTemplateChild("darknessBorder") as Border; SubtitleText = GetTemplateChild("txtSubtitle") as RichTextBlock; ShadowBorder = GetTemplateChild("shadowBorder") as Border; PlayPauseButtonCTM = GetTemplateChild("PlayPauseButtonCTM") as AppBarButton; PlayPauseButtonCTM.Click += PlayPauseButtonCTM_Click; ZoomButtonCTM = GetTemplateChild("ZoomButtonCTM") as AppBarButton; ZoomButtonCTM.Click += ZoomButtonCTM_Click; FullWindowBTN = GetTemplateChild("FullWindowBTN") as AppBarButton; FullWindowBTN.Click += FullWindowBTN_Click; stackPlayPauseButton = GetTemplateChild("stackPlayPauseButton") as StackPanel; stackPlayPauseButton.PointerEntered += StackPlayPauseButton_PointerEntered; stackPlayPauseButton.PointerExited += StackPlayPauseButton_PointerExited; darknessBorder.Tapped += DarknessBorder_Tapped; subsFlyout = GetTemplateChild("subsFlyout") as Flyout; timelineBorder = GetTemplateChild("timelineBorder") as Border; timelineBorder.PointerEntered += StackPlayPauseButton_PointerEntered; timelineBorder.PointerExited += StackPlayPauseButton_PointerExited; txtShowSomething = GetTemplateChild("txtShowSomething") as TextBlock; txtDarkness = GetTemplateChild("txtDarkness") as TextBlock; txtVolume = GetTemplateChild("txtVolume") as TextBlock; lockGrid = GetTemplateChild("lockGrid") as Grid; lockGrid.Tapped += LockGrid_Tapped; lockButton = GetTemplateChild("lockButton") as Button; unlockButton = GetTemplateChild("unlockButton") as Button; lockUnLockOrientationButton = GetTemplateChild("lockUnLockOrientationButton") as AppBarButton; lockButton.Click += LockButton_Click; unlockButton.Click += UnlockButton_Click; lockUnLockOrientationButton.Click += LockUnLockOrientationButton_Click; if (PlayerPage.Current != null && PlayerPage.Current.MediaElement != null) { PlayerPage.Current.MediaElement.CurrentStateChanged += MediaElement_CurrentStateChanged; } menuShowHideSub = GetTemplateChild("menuShowHideSub") as MenuFlyoutItem; menuOpenSub = GetTemplateChild("menuOpenSub") as MenuFlyoutItem; menuSubSettings = GetTemplateChild("menuSubSettings") as MenuFlyoutItem; menuFlyoutRelativeSubs = GetTemplateChild("menuFlyoutRelativeSubs") as MenuFlyoutSubItem; menuShowHideSub.Click += MenuShowHideSub_Click; menuOpenSub.Click += MenuOpenSub_Click; menuSubSettings.Click += MenuSubSettings_Click; darknessBorder.ManipulationMode = ManipulationModes.TranslateY | ManipulationModes.TranslateX; darknessBorder.ManipulationStarted += manipulationStarted; darknessBorder.ManipulationCompleted += manipulationCompleted; darknessBorder.ManipulationDelta += manipulationDelta; ShadowBorder.ManipulationMode = ManipulationModes.TranslateX; ShadowBorder.ManipulationStarted += manipulationStarted; ShadowBorder.ManipulationCompleted += manipulationCompleted; ShadowBorder.ManipulationDelta += manipulationDelta; SubtitleText.ManipulationMode = ManipulationModes.TranslateX; SubtitleText.ManipulationStarted += manipulationStarted2; SubtitleText.ManipulationCompleted += manipulationCompleted2; base.OnApplyTemplate(); }
Run GetRun(string text) { if (!string.IsNullOrEmpty(text)) { text = HelperUP.FixInvalidItalicTags(text); text = HelperUP.FixInvalidFontTags(text); text = HelperUP.FixInvalidUnderlineTags(text); text = HelperUP.FixInvalidBoldTags(text); Run run = new Run(); string pattern = @"<b>(?<bold>.*)</b>"; MatchCollection reg = Regex.Matches(text, pattern); if (reg.Count > 0) { run.FontWeight = new Windows.UI.Text.FontWeight { Weight = 700 } } ; pattern = @"<i>(?<italic>.*)</i>"; reg = Regex.Matches(text, pattern); if (reg.Count > 0) { run.FontStyle = Windows.UI.Text.FontStyle.Italic; } pattern = @"color=""(?<color>.*)"""; reg = Regex.Matches(text, pattern); if (reg.Count > 0) { foreach (Match item in reg) { try { if (item.Groups["color"].ToString().StartsWith("#")) { if (item.Groups["color"].ToString().Length == 7) { run.Foreground = new SolidColorBrush(HelperUP.GetColorFromHex("#ff" + item.Groups["color"].ToString().Substring(1))); } else { run.Foreground = new SolidColorBrush(HelperUP.GetColorFromHex(item.Groups["color"].ToString())); } } else if (item.Groups["color"].ToString().ToLower().Equals("white")) { run.Foreground = new SolidColorBrush(Colors.White); } else if (item.Groups["color"].ToString().ToLower().Equals("red")) { run.Foreground = new SolidColorBrush(Colors.Red); } else if (item.Groups["color"].ToString().ToLower().Equals("cyan")) { run.Foreground = new SolidColorBrush(Colors.Cyan); } else if (item.Groups["color"].ToString().ToLower().Equals("yellow")) { run.Foreground = new SolidColorBrush(Colors.Yellow); } else if (item.Groups["color"].ToString().ToLower().Equals("orange")) { run.Foreground = new SolidColorBrush(Colors.Orange); } else if (item.Groups["color"].ToString().ToLower().Equals("blue")) { run.Foreground = new SolidColorBrush(Colors.Blue); } else if (item.Groups["color"].ToString().ToLower().Equals("black")) { run.Foreground = new SolidColorBrush(Colors.Black); } else if (item.Groups["color"].ToString().ToLower().Equals("brown")) { run.Foreground = new SolidColorBrush(Colors.Brown); } else if (item.Groups["color"].ToString().ToLower().Equals("green")) { run.Foreground = new SolidColorBrush(Colors.Green); } else if (item.Groups["color"].ToString().ToLower().Equals("pink")) { run.Foreground = new SolidColorBrush(Colors.Pink); } else { HelperUP.Output(string.Format("Color '{0}' not supported", item.Groups["color"].ToString())); } // white,red,cyan,yellow,orange,blue,black,brown,green } catch (Exception Exception) { HelperUP.Output("GetRun ex: " + Exception.Message); } } } text = HelperUP.RemoveHtmlTags(text).Replace("</font>", "").Replace("</i>", "").Replace("</b>", ""); run.Text = text; return(run); } return(null); } }