Esempio n. 1
0
        public Window1()
        {
            InitializeComponent();

            mainCanvas.Background = Brushes.Black;

            // worker thread:
            workerThread = new BackgroundWorker();
            workerThread.DoWork += new DoWorkEventHandler(PerformSearch);
            workerThread.ProgressChanged += new ProgressChangedEventHandler(workerThread_ProgressChanged);
            workerThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(workerThread_RunWorkerCompleted);
            workerThread.WorkerReportsProgress = true;
            workerThread.WorkerSupportsCancellation = true;

            // search engines:
            {
                searchEngines = new List<s3dCore.SearchEngines.ISearchEngine>();
                searchEngines.Add(new SearchEngines.FileEngine());
                searchEngines.Add(new SearchEngines.FlickrEngine());
                //searchEngines.Add(new SearchEngines.YouTubeEngine());

                //SearchEngines.YouTubeEngine.DoTest();

                List<s3dCore.SearchEngines.ISearchEngine> plugins = PluginHelper.GetEnginePlugins();
                if (plugins != null)
                {
                    searchEngines.AddRange(plugins);
                }

                engineDescs = new s3dCore.SearchEngines.SearchEngineDescriptionList();
                foreach (s3dCore.SearchEngines.ISearchEngine eng in searchEngines)
                {
                    s3dCore.SearchEngines.SearchEngineDescription desc = eng.GetDescription();
                    engineDescs.Add(desc);
                    enginesCombo.Items.Add(desc);
                }
                currentSearchEngine = null;
                ChangeSearchEngine(searchEngines[searchEngines.Count-1]);
                enginesCombo.SelectedIndex = searchEngines.Count - 1;
            }

            // layouts:
            {
                layouts = new List<s3dCore.ListLayout.IListLayout>();
                layouts.Add(new ListLayout.BasicListLayout());
                layouts.Add(new ListLayout.SpiralLayout());
                layouts.Add(new ListLayout.FloorLayout());

                List<s3dCore.ListLayout.IListLayout> plugins = PluginHelper.GetLayoutPlugins();
                if (plugins != null)
                {
                    layouts.AddRange(plugins);
                }

                foreach (s3dCore.ListLayout.IListLayout layout in layouts)
                {
                    layoutCombo.Items.Add(layout.GetName());
                }

                currentList = new Dictionary<ModelUIElement3D, s3dCore.SearchEngines.ISearchElement>();
                camControler = new CameraController(mainCamera, currentLayout, mainLight);

                ChangeLayout(layouts[1]);
                layoutCombo.SelectedIndex = 1;
            }

            onSearching = this.TryFindResource("OnSearching") as Storyboard;

            help = new HelpSystem(statusLabel);
            HelpSystem.GlobalSystem = help;

            bigPicture.AtEnd = new BigPicture.CallbackAtEnd(AtEndBigPicture);

            if (Properties.Settings.Default.FirstTimeUse == true)
            {
                Properties.Settings.Default.FirstTimeUse = false;
                Properties.Settings.Default.Save();
            }
            else
            {
                HelpSystem.GlobalSystem.Enabled = false;
            }

            HelpSystem.GlobalSystem.ShowHelp("Start searching and move using mouse - drag and mouse roll - in the 3d space...", 1);
        }
Esempio n. 2
0
        void ChangeSearchEngine(s3dCore.SearchEngines.ISearchEngine newEngine)
        {
            if (currentSearchEngine != null && newEngine.GetType() == currentSearchEngine.GetType()) return;

            if (workerThread.IsBusy)
            {
                searchBtn.Content = "Cancelling...";
                workerThread.CancelAsync();
                this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, ((Action)delegate { ChangeSearchEngine(newEngine); }));
            }

            currentSearchEngine = newEngine;
            customUI.Children.Clear();
            if (newEngine.GetSearchControl() != null)
            {
                customUI.Children.Add(newEngine.GetSearchControl());
            }
            currentSearchEngine.Reset();
            searchBtn.Content = currentSearchEngine.GetSearchButtonTitle();

            if (currentSearchEngine.IsSearchTextBoxVisible())
            {
                patternTb.Visibility = Visibility.Visible;
            }
            else
            {
                patternTb.Visibility = Visibility.Collapsed;
            }
        }