示例#1
0
        public static void PreviewExec(object sender, ExecutedRoutedEventArgs e)
        {
            string filePath = e.Parameter as string;

            if (!String.IsNullOrEmpty(filePath))
            {
                LocalFilesSource source = new LocalFilesSource()
                {
                    SearchPathPattern = filePath,
                    DefaultFilePath   = "",
                    MaximumResults    = 1
                };
                source.SearchCompleted += new EventHandler(delegate
                {
                    if (source.Results.Count > 0)
                    {
                        var previewWindow      = Common.NewPreviewWindow(GetWindow(sender) as IAppWindow);
                        var albumArt           = source.Results[0];
                        albumArt.FilePath      = filePath;
                        previewWindow.AlbumArt = albumArt;
                    }
                    else
                    {
                        System.Diagnostics.Trace.TraceError("Could not obtain AlbumArt for local file: " + source.SearchPathPattern);
                    }
                });
                source.Search(null, null);
            }
        }
示例#2
0
        /// <summary>
        /// Sets the LocalFilesSource image search path.
        /// </summary>
        /// <param name="path"></param>
        public void SetLocalImagesPath(string path)
        {
            //TODO: Could there ever be more than one local files source?
            LocalFilesSource localFilesSource = mSources.OfType <LocalFilesSource>().FirstOrDefault();

            if (localFilesSource != null)
            {
                localFilesSource.SearchPathPattern = path;
            }
        }
示例#3
0
        public ArtSearchWindow()
        {
            mAutoDownloadFullSizeImagesThread          = new Thread(new ThreadStart(AutoDownloadFullSizeImagesWorker));
            mAutoDownloadFullSizeImagesThread.Name     = "Auto Download Full Size Images";
            mAutoDownloadFullSizeImagesThread.Priority = ThreadPriority.BelowNormal;

            InitializeComponent();

            //Bind the SelectAll checkbox
            Binding selectAllBinding = new Binding("AllEnabled");

            selectAllBinding.Source = mSources;
            selectAllBinding.Mode   = BindingMode.TwoWay;
            BindingOperations.SetBinding(mSelectAll, CheckBox.IsCheckedProperty, selectAllBinding);

            //Bind the Search button being enabled
            Binding sourceEnabledBinding = new Binding("AllEnabled");

            sourceEnabledBinding.Source    = mSources;
            sourceEnabledBinding.Mode      = BindingMode.OneWay;
            sourceEnabledBinding.Converter = new NotFalseConverter();
            BindingOperations.SetBinding(mSearch, Button.IsEnabledProperty, sourceEnabledBinding);

            mSources.CombinedResults.CollectionChanged += new NotifyCollectionChangedEventHandler(OnResultsChanged);

            //Commands:
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Find, new ExecutedRoutedEventHandler(FindExec)));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, new ExecutedRoutedEventHandler(CopyExec)));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Save, new ExecutedRoutedEventHandler(SaveExec)));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.SaveAs, new ExecutedRoutedEventHandler(SaveAsExec)));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, new ExecutedRoutedEventHandler(DeleteExec)));
            CommandBindings.Add(new CommandBinding(CommonCommands.Preview, new ExecutedRoutedEventHandler(PreviewExec)));
            CommandBindings.Add(new CommandBinding(Commands.GetMoreScripts, new ExecutedRoutedEventHandler(GetMoreScriptsExec), new CanExecuteRoutedEventHandler(GetMoreScriptsCanExec)));
            CommandBindings.Add(new CommandBinding(Commands.ShowAutoDownloadedScripts, new ExecutedRoutedEventHandler(ShowAutoDownloadedScriptsExec)));

            //Stop All is bound only when doing a search (so the Stop All button only appears while searching)
            mStopAllCommandBinding = new CommandBinding(ApplicationCommands.Stop, new ExecutedRoutedEventHandler(StopExec));

            mSourcesViewer.ItemsSource = mSources;
            mResultsViewer.ItemsSource = mSources.CombinedResults;

            foreach (IScript script in ((App)Application.Current).Scripts)
            {
                ScriptSource scriptSource = new ScriptSource(script);
                mSources.Add(scriptSource);
                //Hook the complete event to know when to hide the Stop All button
                scriptSource.SearchCompleted += OnSourceSearchCompleted;
                //Hook the Property Changed event to know when to recalculate whether the search will be extended
                scriptSource.PropertyChanged += OnSourcePropertyChanged;
            }

            LocalFilesSource localFilesSource = new LocalFilesSource();

            localFilesSource.DefaultFilePath = mDefaultSaveFolder.PathPattern;
            //Update the default file path if the pattern changes
            mDefaultSaveFolder.PathPatternChanged += delegate(object sender, DependencyPropertyChangedEventArgs e) { localFilesSource.DefaultFilePath = (string)e.NewValue; };
            mSources.Add(localFilesSource);
            localFilesSource.SearchCompleted += OnSourceSearchCompleted;
            localFilesSource.PropertyChanged += OnSourcePropertyChanged;

            LoadSettings();
            //Initial value of AutoClose is taken from settings. May be overriden by command line parameters
            AutoClose = Properties.Settings.Default.AutoClose;

            this.Loaded += new RoutedEventHandler(OnLoaded);

            //Tab auto-select all for Artist and Album boxes
            mArtist.GotKeyboardFocus += OnAutoSelectTextBoxFocusChange;
            mAlbum.GotKeyboardFocus  += OnAutoSelectTextBoxFocusChange;

            //If the default file path pattern does not containg %preset%, the presets context menu is coerced into being hidden
            mDefaultSaveFolder.PathPatternChanged += delegate { CoerceValue(PresetsContextMenuProperty); };

            //Notify when scripts have been auto downloaded
            Updates.AutoDownloadedScripts.CollectionChanged += OnAutoDownloadedScriptsChanged;
        }