private void closeVideoAnimation_Completed(Canvas fullVideoCanvas, CVideo cVideo, DControlDto dto) { pageTemplate1.mqServer.SendMsg(new VideoControlMessage(dto.id, "fullScreenExit")); pageTemplate1.mqServer.SendMsg(new VideoControlMessage(dto.id, "pause")); cVideo = null; pageTemplate1.container.Children.Remove(fullVideoCanvas); }
private static void _CloseProgram() { // Unloading in reverse order try { CController.Close(); CVocaluxeServer.Close(); CGraphics.Close(); CThemes.Close(); CCover.Close(); CFonts.Close(); CBackgroundMusic.Close(); CWebcam.Close(); CDataBase.Close(); CVideo.Close(); CRecord.Close(); CSound.Close(); CDraw.Close(); } catch (Exception e) { CLog.LogError("Error during shutdown!", false, false, e); } GC.Collect(); // Do a GC run here before we close logs to have finalizers run try { CLog.Close(); // Do this last, so we get all log entries! } catch (Exception) {} Environment.Exit(Environment.ExitCode); }
/* * 3.4插入视频 Video */ public void insertVideoToPage(DControl ctl) { //获取视频所在的集合 StorageVideo storageVideo = storageVideoBll.get(ctl.storageId); if (storageVideo == null) { storageVideo = new StorageVideo(); storageVideo.url = "/myfile/sysimg/notExists/video.mp4"; storageVideo.origFilename = "演示视频.mp4"; } StorageVideoDto dto = StorageVideoUtil.convert(storageVideo); StorageImage storageImage = storageImageBll.get(dto.storageImageId); dto.storageImageUrl = storageImage?.url; //foreach (Window win in App.appWindowList) //{ // string type = win.GetType().Name; // Console.WriteLine("窗口类型:" + type); //} Cfg pageCfg = PageWidthUtil.getPageCfg(dPage, App.localStorage.cfg); CVideo cVideo = NewControlUtil.newCVideo(ctl, dto, pageCfg, pageTemplate1.mqServer, false); loadAllAnimation(cVideo, ctl); mainContainer.Children.Add(cVideo); }
protected void SelectSong(int nr) { if (CSongs.Category >= 0 && (CSongs.NumVisibleSongs > 0) && (nr >= 0) && ((_actsong != nr) || (_streams.Count == 0))) { foreach (int stream in _streams) { CSound.FadeAndStop(stream, 0f, 1f); } _streams.Clear(); CVideo.VdClose(_video); _video = -1; CDraw.RemoveTexture(ref _vidtex); _actsong = nr; if (_actsong >= CSongs.NumVisibleSongs) { _actsong = 0; } int _stream = CSound.Load(Path.Combine(CSongs.VisibleSongs[_actsong].Folder, CSongs.VisibleSongs[_actsong].MP3FileName), true); CSound.SetStreamVolumeMax(_stream, _MaxVolume); CSound.SetStreamVolume(_stream, 0f); float startposition = CSongs.VisibleSongs[_actsong].PreviewStart; if (startposition == 0f) { startposition = CSound.GetLength(_stream) / 4f; } CSound.SetPosition(_stream, startposition); CSound.Play(_stream); CSound.Fade(_stream, 100f, 3f); _streams.Add(_stream); _actsongstream = _stream; if (CSongs.VisibleSongs[_actsong].VideoFileName != String.Empty && CConfig.VideoPreview == EOffOn.TR_CONFIG_ON) { _video = CVideo.VdLoad(Path.Combine(CSongs.VisibleSongs[_actsong].Folder, CSongs.VisibleSongs[_actsong].VideoFileName)); if (_video == -1) { return; } CVideo.VdSkip(_video, startposition, CSongs.VisibleSongs[_actsong].VideoGap); _VideoFadeTimer.Stop(); _VideoFadeTimer.Reset(); _VideoFadeTimer.Start(); } } }
static void CloseProgram() { // Unloading try { CSound.RecordCloseAll(); CSound.CloseAllStreams(); CVideo.VdCloseAll(); CDraw.Unload(); CLog.CloseAll(); CDataBase.CloseConnections(); } catch (Exception) { } }
private void CloseSong() { CSound.FadeAndStop(_CurrentStream, 0f, 0.5f); CSound.RecordStop(); if (_CurrentVideo != -1) { CVideo.VdClose(_CurrentVideo); _CurrentVideo = -1; CDraw.RemoveTexture(ref _CurrentVideoTexture); } CDraw.RemoveTexture(ref _Background); Lyrics[htLyrics(LyricMain)].Clear(); Lyrics[htLyrics(LyricSub)].Clear(); Lyrics[htLyrics(LyricMainDuet)].Clear(); Lyrics[htLyrics(LyricSubDuet)].Clear(); Lyrics[htLyrics(LyricMainTop)].Clear(); Lyrics[htLyrics(LyricSubTop)].Clear(); Texts[htTexts(TextSongName)].Text = String.Empty; }
/* * 关闭视频 * * 动画,回到原位,移除大图 */ private void closeVideoAnimation(Canvas fullVideoCanvas, DControlDto dControlDto, CVideo cVideo) { //1.淡出 DoubleAnimation da = new DoubleAnimation(fullVideoCanvas.Opacity, 0, new Duration(TimeSpan.FromMilliseconds(100))); da.BeginTime = TimeSpan.FromMilliseconds(200); fullVideoCanvas.BeginAnimation(UIElement.OpacityProperty, da); //触摸缩放后 double backToScaleX = dControlDto.width / fullVideoCanvas.Width; double backToScaleY = dControlDto.height / fullVideoCanvas.Height; Transform transform = fullVideoCanvas.RenderTransform; TransformGroup group = (TransformGroup)fullVideoCanvas.RenderTransform; //2.缩放 ScaleTransform scaleTransform = TransformGroupUtil.GetScaleTransform(group); DoubleAnimation da1 = new DoubleAnimation(scaleTransform.ScaleX, backToScaleX, new Duration(TimeSpan.FromMilliseconds(300))); scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, da1); DoubleAnimation da2 = new DoubleAnimation(scaleTransform.ScaleY, backToScaleY, new Duration(TimeSpan.FromMilliseconds(300))); scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, da2); // 3.平移 TranslateTransform translateTransform = TransformGroupUtil.GetTranslateTransform(group); DoubleAnimation da3 = new DoubleAnimation(translateTransform.X, 0, new Duration(TimeSpan.FromMilliseconds(300))); translateTransform.BeginAnimation(TranslateTransform.XProperty, da3); DoubleAnimation da4 = new DoubleAnimation(translateTransform.Y, 0, new Duration(TimeSpan.FromMilliseconds(300))); da4.Completed += (sender, e) => closeVideoAnimation_Completed(fullVideoCanvas, cVideo, dControlDto); translateTransform.BeginAnimation(TranslateTransform.YProperty, da4); }
/* * 1.4 链接到全屏视频 */ public void insertFullVideoToPage(DControlDto dControlDto) { StorageVideo storageVideo = storageVideoBll.get(dControlDto.linkToVideoId); int frameWidth = App.localStorage.cfg.screenWidth; int frameHeight = App.localStorage.cfg.screenHeight; if (dPage.width > 0) { frameWidth = dPage.width; } if (dPage.height > 0) { frameHeight = dPage.height; } Cfg cfg = new Cfg(); cfg.screenWidth = frameWidth; cfg.screenHeight = frameHeight; if (storageVideo == null) { storageVideo = new StorageVideo(); storageVideo.url = "/myfile/sysimg/notExists/video.mp4"; storageVideo.origFilename = "演示视频.mp4"; } StorageVideoDto dto = StorageVideoUtil.convert(storageVideo); StorageImage storageImage = storageImageBll.get(dto.storageImageId); dto.storageImageUrl = storageImage?.url; DControl ctl = new DControl(); ctl.id = 10003; ctl.pageId = 0; ctl.name = "cVideo"; ctl.width = cfg.screenWidth; ctl.height = cfg.screenHeight; ctl.left = 0; ctl.top = 0; ctl.type = "Video"; ctl.content = FileUtil.getFilenameTitle(storageVideo?.origFilename); ctl.idx = 0; ///// ctl.linkToPageId = 0; ctl.isClickShow = false; ctl.linkToVideoId = 0; ctl.autoplay = true; ctl.loop = false; ctl.turnPictureSpeed = 0; ctl.storageId = storageVideo.id; Canvas fullVideoCanvas = new Canvas(); fullVideoCanvas.Name = "fullVideoCanvas"; fullVideoCanvas.Width = ctl.width; fullVideoCanvas.Height = ctl.height; fullVideoCanvas.HorizontalAlignment = HorizontalAlignment.Left; fullVideoCanvas.VerticalAlignment = VerticalAlignment.Top; TransformGroup group = new TransformGroup(); double scaleX = dControlDto.width / Convert.ToDouble(ctl.width); double scaleY = dControlDto.height / Convert.ToDouble(ctl.height); ScaleTransform scaleTransform = new ScaleTransform(); scaleTransform.ScaleX = scaleX; scaleTransform.ScaleY = scaleY; group.Children.Add(scaleTransform); fullVideoCanvas.RenderTransform = group; double left = dControlDto.left; double top = dControlDto.top; fullVideoCanvas.Margin = new Thickness(left, top, 0, 0); Panel.SetZIndex(fullVideoCanvas, 10003); CVideo cVideo = new CVideo(ctl, true, cfg, dto, pageTemplate1.mqServer, true); cVideo.Name = "cVideo"; cVideo.HorizontalAlignment = HorizontalAlignment.Left; cVideo.VerticalAlignment = VerticalAlignment.Top; cVideo.Width = ctl.width; cVideo.Height = ctl.height; cVideo.Background = null; cVideo.Tag = ctl; //动画,平移到指定位置 double toTranslateTransformX = 0 - dControlDto.left; double toTranslateTransformY = 0 - dControlDto.top; fullVideoCanvas.Children.Add(cVideo); AnimationUtil.loadFullVideo(fullVideoCanvas, toTranslateTransformX, toTranslateTransformY); pageTemplate1.container.Children.Add(fullVideoCanvas); //是否显示关闭按钮 Button closebtn = cVideo.GetClosebtn(); closebtn.Visibility = Visibility.Visible; closebtn.Tag = true; closebtn.Click += (object sender, RoutedEventArgs e) => closeVideoAnimation(fullVideoCanvas, dControlDto, cVideo); }
static void Main(string[] args) { AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolver); // Close program if there is another instance running if (!EnsureSingleInstance()) { //TODO: put it into language file MessageBox.Show("Another Instance of Vocaluxe is already runnning!"); return; } Application.DoEvents(); try { // Init Log CLog.Init(); CSettings.CreateFolders(); Application.DoEvents(); // Init Language CLog.StartBenchmark(0, "Init Language"); CLanguage.Init(); CLog.StopBenchmark(0, "Init Language"); Application.DoEvents(); // load config CLog.StartBenchmark(0, "Init Config"); CConfig.LoadCommandLineParams(args); CConfig.UseCommandLineParamsBefore(); CConfig.Init(); CConfig.UseCommandLineParamsAfter(); CLog.StopBenchmark(0, "Init Config"); Application.DoEvents(); _SplashScreen = new SplashScreen(); Application.DoEvents(); // Init Draw CLog.StartBenchmark(0, "Init Draw"); CDraw.InitDraw(); CLog.StopBenchmark(0, "Init Draw"); Application.DoEvents(); // Init Database CLog.StartBenchmark(0, "Init Database"); CDataBase.Init(); CLog.StopBenchmark(0, "Init Database"); Application.DoEvents(); // Init Playback CLog.StartBenchmark(0, "Init Playback"); CSound.PlaybackInit(); CLog.StopBenchmark(0, "Init Playback"); Application.DoEvents(); // Init Record CLog.StartBenchmark(0, "Init Record"); CSound.RecordInit(); CLog.StopBenchmark(0, "Init Record"); Application.DoEvents(); //Init Webcam CLog.StartBenchmark(0, "Init Webcam"); CWebcam.Init(); CLog.StopBenchmark(0, "Init Webcam"); Application.DoEvents(); // Init Background Music CLog.StartBenchmark(0, "Init Background Music"); CBackgroundMusic.Init(); CLog.StopBenchmark(0, "Init Background Music"); Application.DoEvents(); // Init Profiles CLog.StartBenchmark(0, "Init Profiles"); CProfiles.Init(); CLog.StopBenchmark(0, "Init Profiles"); Application.DoEvents(); // Init Font CLog.StartBenchmark(0, "Init Font"); CFonts.Init(); CLog.StopBenchmark(0, "Init Font"); Application.DoEvents(); // Init VideoDecoder CLog.StartBenchmark(0, "Init Videodecoder"); CVideo.Init(); CLog.StopBenchmark(0, "Init Videodecoder"); Application.DoEvents(); // Load Cover CLog.StartBenchmark(0, "Init Cover"); CCover.Init(); CLog.StopBenchmark(0, "Init Cover"); Application.DoEvents(); // Theme System CLog.StartBenchmark(0, "Init Theme"); CTheme.InitTheme(); CLog.StopBenchmark(0, "Init Theme"); Application.DoEvents(); // Init Screens CLog.StartBenchmark(0, "Init Screens"); CGraphics.InitGraphics(); CLog.StopBenchmark(0, "Init Screens"); Application.DoEvents(); // Init Input CLog.StartBenchmark(0, "Init Input"); CInput.Init(); CLog.StopBenchmark(0, "Init Input"); // Init Game; CLog.StartBenchmark(0, "Init Game"); CGame.Init(); CLog.StopBenchmark(0, "Init Game"); } catch (Exception e) { MessageBox.Show("Error on start up: " + e.Message + e.StackTrace); CLog.LogError("Error on start up: " + e.Message + e.StackTrace); CloseProgram(); Environment.Exit(Environment.ExitCode); } Application.DoEvents(); // Start Main Loop _SplashScreen.Close(); try { CDraw.MainLoop(); } catch (Exception e) { MessageBox.Show("Unhandled error: " + e.Message + e.StackTrace); CLog.LogError("Unhandled error: " + e.Message + e.StackTrace); } CloseProgram(); }
public void PageTemplate_UnLoaded(object sender, RoutedEventArgs e) { Unloaded -= PageTemplate_UnLoaded; foreach (FrameworkElement element in container.Children) { if (element is Button) { Button btn = element as Button; if (btn.Name == "Image") { btn.Click -= insertToPage.imageButtonClick; } else if (btn.Name == "BackButton") { btn.Click -= insertToPage.backButtonClick; } else if (btn.Name == "HomeButton") { btn.Click -= insertToPage.homeButtonClick; } btn.Background = null; btn = null; } else if (element is DocumentViewer) { DocumentViewer documentViewer = element as DocumentViewer; documentViewer.Document = null; documentViewer = null; } else if (element is TurnPicture) { TurnPicture turnPicture = element as TurnPicture; turnPicture = null; } else if (element is Marque) { Marque marque = element as Marque; marque = null; } else if (element is MarqueLayer) { MarqueLayer marqueLayer = element as MarqueLayer; marqueLayer = null; } else if (element is CVideo) { CVideo cVideo = element as CVideo; cVideo = null; } else if (element is CFrame) { CFrame cFrame = element as CFrame; cFrame.Content = null; cFrame = null; } else if (element is TextBlock) { TextBlock textBlock = element as TextBlock; textBlock.PreviewMouseUp -= insertToPage.textBlock_PreviewMouseUp; textBlock.PreviewTouchUp -= insertToPage.textBlock_PreviewTouchUp; textBlock = null; } else if (element is Gif) { Gif gif = element as Gif; gif.PreviewMouseUp -= insertToPage.gif_PreviewMouseUp; gif.PreviewTouchUp -= insertToPage.gif_PreviewTouchUp; gif = null; } else if (element is CAudio) { CAudio cAudio = element as CAudio; cAudio.PreviewMouseUp += insertToPage.cAudio_PreviewMouseUp; cAudio.PreviewTouchUp += insertToPage.cAudio_PreviewTouchUp; cAudio = null; } else if (element is CCalendar) { CCalendar cCalendar = element as CCalendar; cCalendar = null; } else if (element is Canvas && element.Name == "frameDialogCanvas") { releaseFrameDialogCanvas(element); } else { FrameworkElement fe = element as FrameworkElement; fe = null; } } //释放视频背景 foreach (FrameworkElement ele in backgroundVideo.Children) { if (ele.Name == "CVideoBackground") { CVideoBackground cVideoBackground = (CVideoBackground)ele; cVideoBackground = null; } } backgroundVideo.Children.Clear(); Background = null; insertToPage = null; Content = null; container.Children.Clear(); GC.Collect(); }
private void LoadNextSong() { CGame.NextRound(); if (CGame.IsFinished()) { CGraphics.FadeTo(EScreens.ScreenScore); _FadeOut = true; return; } CSong song = CGame.GetSong(); if (song == null) { CLog.LogError("Critical Error! ScreenSing.LoadNextSong() song is null!"); return; } CloseSong(); if (!song.CoverSmallLoaded) { song.ReadNotes(); } string songname = song.Artist + " - " + song.Title; int rounds = CGame.GetNumSongs(); if (rounds > 1) { songname += " (" + CGame.RoundNr + "/" + rounds.ToString() + ")"; } Texts[htTexts(TextSongName)].Text = songname; _CurrentStream = CSound.Load(song.GetMP3(), true); CSound.SetStreamVolume(_CurrentStream, _Volume); CSound.SetPosition(_CurrentStream, song.Start); _CurrentTime = song.Start; _FinishTime = song.Finish; _TimeToFirstNote = 0f; _TimeToFirstNoteDuet = 0f; CGame.ResetPlayer(); CDraw.RemoveTexture(ref _CurrentVideoTexture); if (song.VideoFileName != String.Empty) { _CurrentVideo = CVideo.VdLoad(Path.Combine(song.Folder, song.VideoFileName)); CVideo.VdSkip(_CurrentVideo, song.Start, song.VideoGap); _VideoAspect = song.VideoAspect; } CDraw.RemoveTexture(ref _Background); if (song.BackgroundFileName != String.Empty) { _Background = CDraw.AddTexture(Path.Combine(song.Folder, song.BackgroundFileName)); } SingNotes[htSingNotes(SingBars)].Reset(); bool LyricsOnTop = CGame.NumPlayer == 2 && CConfig.LyricsOnTop == EOffOn.TR_CONFIG_ON; if (song.IsDuet) { CGame.Player[1].LineNr = 1; Statics[htStatics(StaticLyricsDuet)].Visible = true; Lyrics[htLyrics(LyricMainDuet)].Visible = true; Lyrics[htLyrics(LyricSubDuet)].Visible = true; Lyrics[htLyrics(LyricMainTop)].Visible = false; Lyrics[htLyrics(LyricSubTop)].Visible = false; Statics[htStatics(StaticLyricsTop)].Visible = false; } else { Statics[htStatics(StaticLyricsDuet)].Visible = false; Lyrics[htLyrics(LyricMainDuet)].Visible = false; Lyrics[htLyrics(LyricSubDuet)].Visible = false; Lyrics[htLyrics(LyricMainTop)].Visible = LyricsOnTop; Lyrics[htLyrics(LyricSubTop)].Visible = LyricsOnTop; Statics[htStatics(StaticLyricsTop)].Visible = LyricsOnTop; } for (int p = 0; p < CGame.NumPlayer; p++) { NoteLines[p] = SingNotes[htSingNotes(SingBars)].AddPlayer( SingNotes[htSingNotes(SingBars)].BarPos[p, CGame.NumPlayer - 1], CTheme.GetPlayerColor(p + 1), p); } /* * case 4: * NoteLines[0] = SingNotes[htSingNotes(SingBars)].AddPlayer(new SRectF(35f, 100f, 590f, 200f, -0.5f), CTheme.ThemeColors.Player[0]); * NoteLines[1] = SingNotes[htSingNotes(SingBars)].AddPlayer(new SRectF(35f, 350f, 590f, 200f, -0.5f), CTheme.ThemeColors.Player[1]); * NoteLines[2] = SingNotes[htSingNotes(SingBars)].AddPlayer(new SRectF(640f, 100f, 590f, 200f, -0.5f), CTheme.ThemeColors.Player[2]); * NoteLines[3] = SingNotes[htSingNotes(SingBars)].AddPlayer(new SRectF(640f, 350f, 590f, 200f, -0.5f), CTheme.ThemeColors.Player[3]); * break; */ _TimerSongText.Stop(); _TimerSongText.Reset(); if (song.Notes.Lines.Length != 2) { _TimerSongText.Start(); } StartSong(); }
public override bool UpdateGame() { bool Finish = false; if (CSound.IsPlaying(_CurrentStream) || CSound.IsPaused(_CurrentStream)) { _CurrentTime = CSound.GetPosition(_CurrentStream); if (_FinishTime != 0 && _CurrentTime >= _FinishTime) { Finish = true; } } else { Finish = true; } if (Finish) { LoadNextSong(); } UpdateSongText(); if (_FadeOut) { return(true); } UpdateTimeLine(); CGame.UpdatePoints(_CurrentTime); UpdateLyrics(); float[] Alpha = CalcFadingAlpha(); if (Alpha != null) { Lyrics[htLyrics(LyricMain)].Alpha = Alpha[0]; Lyrics[htLyrics(LyricSub)].Alpha = Alpha[1]; Lyrics[htLyrics(LyricMainTop)].Alpha = Alpha[0]; Lyrics[htLyrics(LyricSubTop)].Alpha = Alpha[1]; Statics[htStatics(StaticLyrics)].Alpha = Alpha[0]; Statics[htStatics(StaticLyricsTop)].Alpha = Alpha[0]; Statics[htStatics(StaticLyricHelper)].Alpha = Alpha[0]; Statics[htStatics(StaticLyricHelperTop)].Alpha = Alpha[0]; for (int p = 0; p < CGame.NumPlayer; p++) { SingNotes[htSingNotes(SingBars)].SetAlpha(NoteLines[p], Alpha[CGame.Player[p].LineNr * 2]); } if (Alpha.Length > 2) { Lyrics[htLyrics(LyricMainDuet)].Alpha = Alpha[0]; Lyrics[htLyrics(LyricSubDuet)].Alpha = Alpha[1]; Statics[htStatics(StaticLyricsDuet)].Alpha = Alpha[0]; Statics[htStatics(StaticLyricHelperDuet)].Alpha = Alpha[0]; Lyrics[htLyrics(LyricMain)].Alpha = Alpha[2]; Lyrics[htLyrics(LyricSub)].Alpha = Alpha[3]; Statics[htStatics(StaticLyrics)].Alpha = Alpha[2]; Statics[htStatics(StaticLyricHelper)].Alpha = Alpha[2]; } } for (int p = 0; p < CGame.NumPlayer; p++) { Texts[htTexts(TextScores[p, CGame.NumPlayer - 1])].Text = CGame.Player[p].Points.ToString("00000"); } if (_CurrentVideo != -1 && !_FadeOut && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON) { float vtime = 0f; CVideo.VdGetFrame(_CurrentVideo, ref _CurrentVideoTexture, _CurrentTime, ref vtime); } return(true); }