//設定初始化載入功能頁面 private void WindowLoaded() { imageBar_Page = new ImageBar_Page(this); if (string.IsNullOrEmpty(imgPath)) { App.mainWindow.Frame_bar.Content = imageBar_Page; } else { //點擊媒體開始 ImgOrMedia = InitialLoadFile(); } ArgsInput = false; }
//進行載入檔案並進行初始化設定 private int InitialLoadFile() { int ImgOrMedia = 0; //0 is Img, 1 is Media, 2 is txt //取得副檔名 fileName_Extension = Path.GetExtension(imgPath).Remove(0, 1); //先判斷選取物件種類, enum寫法 //Image if (Enum.IsDefined(typeof(img_all_type), fileName_Extension)) { //image_Page = new Image_Page(this); imageBar_Page = new ImageBar_Page(this); //Navigate to Image Page if (true) { //App.mainWindow.Frame_main.Content = image_Page; App.mainWindow.Frame_bar.Content = imageBar_Page; } UpdateTitleBarText(); try { picSource = BitmapFromUri(new Uri(imgPath)); } catch (Exception ex) { pic_error_code = 1; MessageBox.Show(ex.StackTrace.ToString()); } //image is not exist mediaSource = null; zIndex_group = new int[] { 0, 0, 0 }; //設定視窗至螢幕中央 Rect workArea = System.Windows.SystemParameters.WorkArea; var height_dif = workArea.Height - App.mainWindow.Height; var width_dif = workArea.Width - App.mainWindow.Width; if (height_dif >= 0 && width_dif >= 0) { App.mainWindow.Left = (workArea.Width - App.mainWindow.Width) / 2 + workArea.Left; App.mainWindow.Top = (workArea.Height - App.mainWindow.Height) / 2 + workArea.Top; } imgManager = new ImageManager(); ImgOrMedia = 0; } //Media else if (Enum.IsDefined(typeof(media_all_type), fileName_Extension)) { if (media_Page == null) { media_Page = new Media_Page(this); mediaBar_Page = new MediaBar_Page(this); mediaControl = new MediaControl(this); //Navigate to Media Page App.mainWindow.Frame_main.Content = media_Page; App.mainWindow.Frame_bar.Content = mediaBar_Page; } else { fileName = Path.GetFileName(imgPath); } mediaSource = imgPath; titleBar_ico_source = "../Resources/下_1.png"; //set title bar icon image mediaBtn_play_pause = "../Resources/pause.png"; picSource = null; zIndex_group = new int[] { 0, 0, 2 }; //sliderVisible = Visibility.Visible; titleBar = fileName + " - ImageTraveler"; ImgOrMedia = 1; } else if (string.Compare(fileName_Extension, "txt") == 0) { App.mainWindow.Frame_main_for_txt.Content = null; textViewer_Page = new TextViewer_Page(this); textViewerBar_Page = new TextViewerBar_Page(this); App.mainWindow.Btn_Next.Visibility = Visibility.Collapsed; App.mainWindow.Btn_Previous.Visibility = Visibility.Collapsed; App.mainWindow.Frame_main.Content = null; App.mainWindow.Frame_main_for_txt.Content = textViewer_Page; App.mainWindow.Frame_bar.Content = textViewerBar_Page; titleBar = fileName + " - ImageTraveler"; ImgOrMedia = 2; //txt=2 } GroupOpacity = new double[] { 0, 0, 0 }; initial_picSource = null; return(ImgOrMedia); }