Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
        public EditorPanel()
        {
            InitializeComponent();
            DataContextChanged += EditorPanel_DataContextChanged;

            Func <bool> areEpisodesNamed    = () => { return(model.Montage.Information.Episodes.Count(x => x.Name == "") == 0); };
            Action      requestEpisodeNames = () =>
            {
                MessageBox.Show("Please, fill episodes info.");
                titles_Click("", null);
            };

            backButton.Click += (s, a) =>
            {
                if (model != null)
                {
                    model.Save();
                    if (!areEpisodesNamed())
                    {
                        requestEpisodeNames();
                    }
                    else
                    {
                        model.WindowState.OnGetBack();
                    }
                }
            };

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

            saveButton.Click += (s, a) =>
            {
                if (model != null)
                {
                    model.Save();
                }
            };

            play.Click += (s, a) =>
            {
                if (model != null)
                {
                    model.WindowState.Paused = false;
                }
            };

            pause.Click += (s, a) =>
            {
                if (model != null)
                {
                    model.WindowState.Paused = true;
                }
            };

            previewMode.Click += (s, a) =>
            {
                if (model != null)
                {
                    model.WindowState.CurrentMode = EditorModes.General;
                }
            };

            borderMode.Click += (s, a) =>
            {
                if (model != null)
                {
                    model.WindowState.CurrentMode = EditorModes.Border;
                }
            };
            patchMode.Click += (s, a) =>
            {
                if (model != null)
                {
                    model.WindowState.CurrentMode = EditorModes.Patch;
                }
            };

            titles.Click += titles_Click;
            sync.Click   += sync_Click;
        }