Exemplo n.º 1
0
 void Synchronize_Click(object sender, RoutedEventArgs e)
 {
     if (model.Montage.SynchronizationShift != 0)
     {
         var response = MessageBox.Show("Вы уже синхронизировали это видео. Точно хотите пересинхронизировать?", "", MessageBoxButton.YesNoCancel);
         if (response != MessageBoxResult.Yes)
         {
             return;
         }
     }
     model.Montage.SynchronizationShift = model.WindowState.CurrentPosition;
     model.WindowState.CurrentPosition  = model.WindowState.CurrentPosition + 1;
     model.Save();
 }
Exemplo n.º 2
0
        void MainWindow_Initialized(object sender, EventArgs e)
        {
            model = (EditorModel)DataContext;
            model.WindowState.PropertyChanged += WindowState_PropertyChanged;


            FaceVideo.Source           = new Uri(model.Locations.FaceVideo.FullName);
            ScreenVideo.Source         = new Uri(model.Locations.DesktopVideo.FullName);
            FaceVideo.LoadedBehavior   = MediaState.Manual;
            ScreenVideo.LoadedBehavior = MediaState.Manual;
            ScreenVideo.Volume         = 0;


            ModeChanged();
            PositionChanged();
            PausedChanged();
            RatioChanged();
            videoAvailable = model.Locations.FaceVideo.Exists;


            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromMilliseconds(timerInterval);
            timer.Tick    += (s, a) => { CheckPlayTime(); };
            timer.Start();

            PreviewKeyDown      += MainWindow_KeyDown;
            ModelView.MouseDown += Timeline_MouseDown;
            Slider.MouseDown    += Timeline_MouseDown;

            FadesSwitcher.Content = model.Montage.CrossfadesEnabled ? "Fades ON" : "Fades OFF";

            Save.Click += (s, a) =>
            {
                model.Save();
            };

            Montage.Click += (s, a) =>
            {
                model.Save();
                RunProcess(Services.Montager, model.VideoFolder);
            };

            Assembly.Click += (s, a) =>
            {
                model.Save();
                RunProcess(Services.Assembler, model.VideoFolder);
            };

            RepairFace.Click += (s, a) =>
            {
                model.Save();
                IsEnabled = false;
                new Tuto.TutoServices.RepairService().DoWork(model.Locations.FaceVideo, true);
                IsEnabled = true;
            };

            RepairDesktop.Click += (s, a) =>
            {
                model.Save();
                IsEnabled = false;
                new Tuto.TutoServices.RepairService().DoWork(model.Locations.DesktopVideo, false);
                IsEnabled = true;
            };

            NoiseReduction.Click += (s, a) =>
            {
                model.Save();
                if (!model.Locations.ClearedSound.Exists)
                {
                    var serv = new Tuto.TutoServices.NoiseReductionService();
                    serv.CreateCleanedMP3(model);
                    MessageBox.Show("Cleaned.mp3 created");
                }
                else
                {
                    MessageBox.Show("Already cleared. Will be assembled with new sound.");
                }
            };

            FadesSwitcher.Click += (s, a) =>
            {
                if (model.Montage.CrossfadesEnabled == false)
                {
                    model.Montage.CrossfadesEnabled = true;
                    FadesSwitcher.Content           = "Fades ON";
                    MessageBox.Show("Crossfades enabled");
                }
                else
                {
                    FadesSwitcher.Content           = "Fades OFF";
                    model.Montage.CrossfadesEnabled = false;
                    MessageBox.Show("Crossfades disabled");
                }
                model.Save();
            };

            Help.Click += (s, a) =>
            {
                var data = HelpCreator.CreateModeHelp();
                var wnd  = new HelpWindow();
                wnd.DataContext = data;
                wnd.Show();
            };

            GoTo.Click += (s, a) =>
            {
                var wnd = new FixWindow();
                wnd.Title = "Enter time";
                var result = wnd.ShowDialog();
                if (!result.HasValue || !result.Value)
                {
                    return;
                }
                var parts = wnd.Text.Text.Split(',', '.', '-', ' ');
                int time  = 0;
                try
                {
                    time = int.Parse(parts[0]) * 60 + int.Parse(parts[1]);
                }
                catch
                {
                    MessageBox.Show("Incorrect string. Expected format is '5-14'");
                    return;
                }
                time *= 1000;
                int current = 0;
                foreach (var z in model.Montage.Chunks)
                {
                    if (z.IsNotActive)
                    {
                        time += z.Length;
                    }
                    current += z.Length;
                    if (current > time)
                    {
                        break;
                    }
                }
                model.WindowState.CurrentPosition = time;
            };

            Synchronize.Click += Synchronize_Click;

            Infos.Click += Infos_Click;
        }