public void SetPosition(double position)// ЧТО ЭТО ЗА ЖЕСТЬ?!!!!!! { if (dxPlay == null) { return; } timer.Stop(); if (IsPlaying) { pause(); timer.Stop(); Position = position; CurTime = TimeSpan.FromSeconds(Position / 1000 * Duration.TotalSeconds); dxPlay.Position = Position / 1000; ToolsTimer.Delay(() => { play(); }, TimeSpan.FromMilliseconds(300)); } else { timer.Stop(); Position = position; CurTime = TimeSpan.FromSeconds(Position / 1000 * Duration.TotalSeconds); dxPlay.Position = Position / 1000; } ToolsTimer.Delay(() => { timer.Start(); }, TimeSpan.FromMilliseconds(300)); }
public void ShowMe(string text, TimeSpan interval) { TextBlockInfo.Text = text; Panel.SetZIndex(this, 1000); this.Visibility = Visibility.Visible; ToolsTimer.Delay(() => { DoubleAnimation animation = new DoubleAnimation(0, this.ActualWidth, interval); WaitProgressBar1.BeginAnimation(Rectangle.WidthProperty, animation); ToolsTimer.Delay(() => { WaitProgressBar1.BeginAnimation(Rectangle.WidthProperty, null); TextBlockInfo.Text = ""; WaitProgressBar1.Width = 0; this.Visibility = Visibility.Collapsed; }, interval + TimeSpan.FromSeconds(0.05)); }, TimeSpan.FromSeconds(0.05)); if (AditionInstances.Count > 0) //вот так извращенно мы пробросим в другие такие же элементы это событие { foreach (var item in AditionInstances) { item.ShowMe(text, interval); } } }
//И ДА ТАК-И ТУТ СОВСЕМ НЕ MVVM ДАЛЬШЕ. ЧЕСТНО ГОВОРЯ УСТАЛ Я ОТ НЕГО. public void SetPosition(double position)// ЧТО ЭТО ЗА ЖЕСТЬ?!!!!!! { timer.Stop(); if (vlc.MediaPlayer.IsPlaying) { vlc.MediaPlayer.Pause(); timer.Stop(); Position = position; CurTime = TimeSpan.FromSeconds(Position / 1000 * Duration.TotalSeconds); vlc.MediaPlayer.Time = (long)Math.Round(Position * Duration.TotalMilliseconds / 1000); ToolsTimer.Delay(() => { vlc.MediaPlayer.Play(); }, TimeSpan.FromMilliseconds(1000)); } else { timer.Stop(); Position = position; CurTime = TimeSpan.FromSeconds(Position / 1000 * Duration.TotalSeconds); vlc.MediaPlayer.Time = (long)Math.Round(Position * Duration.TotalMilliseconds / 1000); } ToolsTimer.Delay(() => { timer.Start(); }, TimeSpan.FromMilliseconds(1000)); }
public void ShowMe(string text, TimeSpan interval) { TextBlockInfo.Text = text; Panel.SetZIndex(this, 1000); this.Visibility = Visibility.Visible; WaitProgressBar1.BeginAnimation(ProgressBar.ValueProperty, new DoubleAnimation(0, 100, interval)); ToolsTimer.Delay(() => { this.Visibility = Visibility.Hidden; TextBlockInfo.Text = ""; WaitProgressBar1.Value = 0; }, interval); }
public override void Abort() { IsAborted = true; SceneNomer = int.MaxValue; CurScene?.Abort(); End(false); ToolsTimer.Delay(() => { IsAborted = false; }, TimeSpan.FromSeconds(0.5)); }
/// <summary> /// Показывает все элементы пользовательского интерфейса для управления медиа-проигрывателем (из коллекции MediaUI) /// </summary> public void UIMediaShow() { foreach (FrameworkElement UI in UICollection) { UI.Visibility = Visibility.Visible; } foreach (FrameworkElement UI in UICollection) { ToolsTimer.Delay(() => { TDrawEffects.UIOpacityChange(UI, 0, 0, 1); }, new TimeSpan(0, 0, 0, 1, 500)); } }
public void ShowMe(string text, TimeSpan interval) { this.Left = vm.MainWindow.Left + vm.MainWindow.ActualWidth / 2 - this.ActualWidth / 2; this.Top = vm.MainWindow.Top + vm.MainWindow.ActualHeight / 2 - this.ActualHeight / 2; WaitProgressBar.TextBlockInfo.Text = text; Panel.SetZIndex(this, 1000); this.Visibility = Visibility.Visible; this.Activate(); WaitProgressBar.WaitProgressBar1.BeginAnimation(ProgressBar.ValueProperty, new DoubleAnimation(0, 100, interval)); ToolsTimer.Delay(() => { this.Visibility = Visibility.Hidden; WaitProgressBar.TextBlockInfo.Text = ""; WaitProgressBar.WaitProgressBar1.Value = 0; }, interval); }
public void Show(Action complete) { TimeSpan t = TimeSpan.FromSeconds(0.5); Container.GetComponent <HiderShower>().Show(1, t, new Thickness(0), TimeSpan.FromSeconds(0.3), 30000); ToolsTimer.Delay(() => { complete(); }, t); //Container.GetComponent<HaveBody>().Body.HorizontalAlignment = HorizontalAlignment.Center; //Container.GetComponent<HaveBody>().Body.VerticalAlignment = VerticalAlignment.Center; }
/// <summary> /// Делает полупрозрачными все элементы пользовательского интерфейса для управления медиа-проигрывателем (из коллекции MediaUI) /// </summary> public void UIMediaHideNotFull() { ToolsTimer.Delay(() => { if (!IsMouseOverUI()) { foreach (FrameworkElement UI in UICollection) { TDrawEffects.UIOpacityChange(UI, UI.Opacity, 0, 2); } } }, new TimeSpan(0, 0, 2)); }
public void Hide(Action complete) { TimeSpan t = TimeSpan.FromSeconds(0.5); HiderShower H = Container.GetComponent <HiderShower>(); //H.Hide(); H.Show(0, t, new Thickness(0), t); ToolsTimer.Delay(() => { Complete(); complete(); }, t); }
public void AddVideos() { Body.ClearVideoInfoRects(); int i = 1; foreach (var p in TimeDiffMeasuringManager.TimeDiffVideos) { TimeDiffVideoInfoRectVM videoVM = new TimeDiffVideoInfoRectVM(TimeDiffMeasuringManager.TimeDiffVideos.IndexOf(p), p.VideoPlayerVM); VideoInfoRectVMs.Add(videoVM); Body.AddVideo(videoVM); i++; } ToolsTimer.Delay(() => { Body.FormatWindowContent(); }, TimeSpan.FromSeconds(0.1)); }
private void VideoPlayer_OnPlayerSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (Source == null) { return; } //if (dxPlay != null) //{ // dxPlay.Dispose(); // dxPlay = null; //} bool Ok = true; testDx = new DxPlay(VideoPanel2, Source.LocalPath, ref Ok); // тестируем - открываем проверяем.... жуткий просто ужасный костыль //TODO: Нет, братан, ну с этим надо реально что-то делать..... if (!Ok) { return; } testDx.Start(); //ToolsTimer.Delay(() => // { bool RateOk = testDx.TryRate(); bool AllOk = Ok && RateOk; if (!Ok) { return; } dxPlay = new DxPlay(VideoMMM.SelectablePictureBox1, Source.LocalPath, ref RateOk); Duration = dxPlay.Duration; //vlc.Height = ActualHeight - 40; //vlc.Width = ActualWidth - 10; dxPlay.Start(); Volume = 50; testDx.Stop(); dxPlay.Pause(); ToolsTimer.Delay(() => { VideoMMM.FitToFill(); OnResize(); }, TimeSpan.FromSeconds(1.5)); }
/// <summary> /// Показывает все элементы пользовательского интерфейса, а затем их прячет /// </summary> public void UIMediaShowAndHideFull() { foreach (FrameworkElement UI in UICollection) { UI.BeginAnimation(FrameworkElement.OpacityProperty, null); TDrawEffects.UIOpacityChange(UI, UI.Opacity, 1, 0.3); ToolsTimer.Delay(() => { if (!IsMouseOverUI()) { UIMediaHideNotFull(); } }, new TimeSpan(0, 0, 2)); } }
/// <summary> /// Запускаем анимацию появления/исчезновения (прозрачность и отступ изменяем плавно) /// </summary> /// <param name="opacity"></param> /// <param name="opacityDuration"></param> /// <param name="margin"></param> /// <param name="marginDuration"></param> public void Show(double opacity, TimeSpan opacityDuration, Thickness margin, TimeSpan marginDuration) { //вычисляем сколько займет операция TimeSpan fullTime = TimeSpan.FromMilliseconds(Math.Max(opacityDuration.TotalMilliseconds, marginDuration.TotalMilliseconds)); CurMargin = margin; CurOpacity = opacity; FrameworkElement body = Container.GetComponent <HaveBody>().Body; //Удаляем анимацию если какая-то есть и включаем анимацию свою TDrawEffects.AllAnimationNull(body); body.BeginAnimation(FrameworkElement.OpacityProperty, new DoubleAnimation(opacity, opacityDuration)); body.BeginAnimation(FrameworkElement.MarginProperty, new ThicknessAnimation(margin, marginDuration)); //событие Complete вызывается когда все закончилось (это надежнее чем полагаться на complete встроенныый в Animation - тот может и не сработать) ToolsTimer.Delay(() => { Complete(); }, fullTime); }
public void FormatWindowContent() { VideoInfoRect PrevVideoInfoRect = null; foreach (var item in this.MainGrid.Children) { VideoInfoRect videoInfoRect = item as VideoInfoRect; if (item == null) { return; } FormatingVideoInfoRect(videoInfoRect, PrevVideoInfoRect); PrevVideoInfoRect = videoInfoRect; } ToolsTimer.Delay(() => { Width = ColumnStack.ActualWidth + 50; }, TimeSpan.FromSeconds(0.1)); }
private static void RestoreViewModel(ApplicationStateSerialized sets, VM vm) { vm.MainWindow.Left = sets.Position.Left; vm.MainWindow.Top = sets.Position.Top; vm.MainWindow.Width = sets.Position.Width; vm.MainWindow.Height = sets.Position.Height; vm.MainWindow.WindowState = sets.WindowState; //готовим перечень файлов... string[] filenames = new string[sets.Players.Count]; for (int i = 0; i < sets.Players.Count; i++) { if (Settings.stateFilesRestorePathType == "Absolute") { filenames[i] = sets.Players[i].filename; } else { filenames[i] = Path.GetFullPath(Path.Combine(sets.TargetDirectory, sets.Players[i].relativeFilename)); //преобразование относительного пути в абсолютный } } //... и зон размещения проигрывателей для ... Rect[] areas = new Rect[sets.Players.Count]; for (int i = 0; i < sets.Players.Count; i++) { areas[i] = sets.Players[i].Position; } //... открытия vm.OpenVideos(filenames, areas); //Назначаем лидера синхронизации int SyncLeadId = 0; foreach (var v in sets.Players) { if (v.IsSyncLeader) { SyncLeadId = sets.Players.IndexOf(v); } } vm.SyncLeadPlayer = vm.videoPlayerVMs[SyncLeadId]; //Устанавливаем подрегулировку громкости vm.ShiftVolume = sets.ShiftVolume; ToolsTimer.Delay(() => { //переводим все видео на нужный момент foreach (VideoPlayerVM v in vm.videoPlayerVMs) { v.CurTime = sets.Players[vm.videoPlayerVMs.IndexOf(v)].CurTime; v.SyncronizationShiftVM.ShiftTime = sets.Players[vm.videoPlayerVMs.IndexOf(v)].TimeShift; } //Устанавливаем всем нужную громкость foreach (VideoPlayerVM v in vm.videoPlayerVMs) { v.SelfVolume = sets.Players[vm.videoPlayerVMs.IndexOf(v)].SelfVolume; } //Устанавливаем везде нужный зум foreach (VideoPlayerVM v in vm.videoPlayerVMs) { Rect ZoomedArea = sets.Players[vm.videoPlayerVMs.IndexOf(v)].ZoomedArea; if (ZoomedArea.Width > 10 && ZoomedArea.Height > 10 && ZoomedArea.Left + ZoomedArea.Width > 0 && ZoomedArea.Height + ZoomedArea.Top > 0) { v.SetZoom(ZoomedArea); } v.Body.VLC.OnResize(); } }, TimeSpan.FromSeconds(2)); }
private void U_MouseClicked() { if (IsAborted) { return; } needSpeakAgain = false; if (speakAgainTimer != null) { speakAgainTimer.Dispose(); } needFlash = false; if (flashTimer != null) { flashTimer.Dispose(); } bool IsHitSuccess = false; var CurUnittmp = CurUnit; CardUnit HitedUnit = null; foreach (var u in UnitsCol.GetAllUnits()) { u.GetComponent <CardShower>().Show(() => { ReadyToNextUnit = true; }); u.readyToReactionOnMouseDown = false; if (u.GetComponent <Hit>().IsHited) { HitedUnit = u; if (CurUnit.Card.Title == u.Card.Title) { IsHitSuccess = true; } } } if (IsHitSuccess) { CurUnitAlreadyTasked = false; Panel.SetZIndex(CurUnittmp.GetComponent <HaveBody>().Body, 1110); CurUnittmp.GetComponent <CardShower>().Hide(() => { }); CurUnit.GetComponent <UState>().newOld = NewOld.Old; Speak(Settings.GetInstance().SuccessTestText + CurUnit.Card.SoundedText); ToolsTimer.Delay(() => { SpeakSlow(CurUnittmp.Card.SoundedText); }, TimeSpan.FromSeconds(Settings.GetInstance().CardSuccesSpeakAgainTime)); CurUnit = null; Panel.SetZIndex(Game.Owner.WrapPanelBigCards, 30001); var cu = CurUnittmp.DeepCopy(); cu.GetComponent <HaveBody>().Body.Height = Settings.GetInstance().CardSuccesSize; cu.GetComponent <HaveBody>().Body.Width = Settings.GetInstance().CardSuccesSize; HaveBox HB = new HaveBox("HaveBox", Game.Owner, Game.Owner.WrapPanelBigCards, cu); cu.GetComponent <HiderShower>().Show(1, TimeSpan.FromSeconds(1), new Thickness(100), TimeSpan.FromSeconds(1)); CurAttempt.AnswerCard = HitedUnit?.Card; CurAttempt.DateAndTimeEnd = DateTime.Now.ToString(); CurCardPassing.AttemptsNumber++; DBTools.Context.SaveChanges(); } else { CurAttempt.AnswerCard = HitedUnit?.Card; CurAttempt.DateAndTimeEnd = DateTime.Now.ToString(); DBTools.Context.SaveChanges(); CurCardPassing.AttemptsNumber++; SetNewCurAttempt(); DBTools.Context.SaveChanges(); CurUnitAlreadyTasked = true; Speak(Settings.GetInstance().FallTestText); } foreach (var u in UnitsCol.GetAllUnits()) { if (u != CurUnittmp || (!IsHitSuccess && u == CurUnittmp)) { Panel.SetZIndex(u.GetComponent <HaveBody>().Body, 1110); u.GetComponent <CardShower>().Hide(() => { }); } } TimeSpan CardPauseTime; if (IsHitSuccess) { CardPauseTime = TimeSpan.FromSeconds(Settings.GetInstance().CardSuccesTime); } else { CardPauseTime = TimeSpan.FromSeconds(Settings.GetInstance().CardWrongPauseTime); } ToolsTimer.Delay(() => { if (IsAborted) { return; } Panel.SetZIndex(CurUnittmp.GetComponent <HaveBody>().Body, 1110); CurUnittmp.GetComponent <CardShower>().Hide(() => { }); ToolsTimer.Delay(() => { if (IsAborted) { return; } Game.Owner.WrapPanelBigCards.Children.Clear(); NextUnit(); }, TimeSpan.FromSeconds(1)); }, CardPauseTime); }