Exemple #1
0
        public MainWindow()
        {
            // create command

            OpenCommand              = new OpenCommand(this);
            ExportCommand            = new ExportCommand(this);
            ExitCommand              = new ActionCommand(this, () => Close(), true);
            LoadScaleCommand         = new LoadScaleCommand(this, true);
            LoadScaleFromWaveCommand = new LoadScaleCommand(this, false);
            UseOperatorCommand       = new ActionCommand(this, (plugin) =>
            {
                var name = plugin.GetType().FullName;
                foreach (var item in UseOperatorMenu.Items.Cast <MenuItem>())
                {
                    item.IsChecked = item.CommandParameter.GetType().FullName == name;
                }
                ApplicationSettings.Setting.PitchOperation.UseOperatorName = name;
                MainView.PluginName = SelectedOperator.PluginName;

                if (WaveData != null)
                {
                    OpenFile(WaveData.FilePath);
                }
            });
            PreviewCommand    = new PreviewCommand(this);
            ClearCacheCommand = new ActionCommand(this, () => CacheFile.ClearChaceFile(), true);
            OptionCommand     = new ActionCommand(this, () =>
            {
                var window   = new OptionWindow();
                window.Owner = this;
                window.ShowDialog();
            }, true);
            AboutCommand = new ActionCommand(this, () =>
            {
                var window   = new AboutWindow();
                window.Owner = this;
                window.ShowDialog();
            });

            // initialize

            InitializeComponent();
            Top         = ApplicationSettings.Setting.General.Position.Y;
            Left        = ApplicationSettings.Setting.General.Position.X;
            Width       = ApplicationSettings.Setting.General.Size.Width;
            Height      = ApplicationSettings.Setting.General.Size.Height;
            WindowState = ApplicationSettings.Setting.General.State;

            LoadPlugin();
            CacheFile.CreateCacheDirectory();

            CompositionTarget.Rendering += (sender, e) =>
            {
                MainView.PreviewableSampleRanges = PreviewStream?.PreviewableSampleRanges;
                if (Player?.PlaybackState == PlaybackState.Playing)
                {
                    var nowIndicatorIsVisible = MainView.IndicatorIsVisible;
                    MainView.IndicatorPosition = Player.GetCurrentSample();
                    if (nowIndicatorIsVisible && nowIndicatorIsVisible != MainView.IndicatorIsVisible)
                    {
                        MainView.ScrollToIndicatorIfOutOfScreen();
                    }
                }
            };
        }