Interaction logic for HelpWindow.xaml
Inheritance: Editor.Window
Beispiel #1
0
        // Corresponds to "Help/Show Help Dialog"
        private void Help_Click(object sender, RoutedEventArgs e)
        {
            var helpWin = new HelpWindow();

            helpWin.ShowDialog();
        }
Beispiel #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;
        }