private void ProjectBrowser_Load(object sender, EventArgs e)
        {
            _model = new ProjectBrowserModel(_windowManager);
            _treeView.Model = new SortedTreeModel(_model);

            // Need this to select nodes in the load on demand tree model we're using here.
            _treeView.LoadOnDemand = false;

            _project = new ProjectDefinition();
            _watcher = new ProjectWatcher(_windowManager, this, _watcher_WatchChanged);

            _timerSelect = new Timer();
            _timerSelect.Interval = 200;
            _timerSelect.Tick += new EventHandler(_timerSelect_Tick);

            _timerRefresh = new Timer();
            _timerRefresh.Interval = 1000;
            _timerRefresh.Tick += new EventHandler(_timerRefresh_Tick);
            _timerRefresh.Start();
        }
        public void LoadProject(string filename, bool noPlugins)
        {
            try
            {
                _projectFilename = filename;

                _project.Filenames.Clear();
                _model.Clear();
                _lookup.Clear();
                _watcher.Clear();
                _rootItem.Files.Clear();

                if (!File.Exists(filename))
                {
                    _windowManager.Logger.LogStr("Project file was not found:" + filename);
                    return;
                }

                // Load the project file.
                string s = File.ReadAllText(_projectFilename);
                Hwd.Serialization.Decoder decoder = new Hwd.Serialization.Decoder();
                _project = (ProjectDefinition)decoder.Decode(s);

                if (_project == null)
                {
                    _windowManager.Logger.LogStr("Failed to deserialize project file:" + _projectFilename);
                    _project = new ProjectDefinition();
                    return;
                }

                // Check the filename list.
                List<string> remove = new List<string>();
                foreach (string name in _project.Filenames)
                {
                    if (!File.Exists(name))
                    {
                        remove.Add(name);
                    }
                    else
                    {
                        MatchFileToModel(name);
                    }
                }
                foreach (string name in remove)
                {
                    _project.Filenames.Remove(name);
                    _windowManager.Logger.LogStr("Warning : Project contains a file that was not found:" + name);
                }

                // Load item structure in advance, so we can "goto" items.
                foreach (KeyValuePair<string, BaseItem> pair in _model.Files)
                {
                    ReadItem(pair.Value, false);
                    _watcher.AddWatch(pair.Value);
                }

                // This must be done before we set current item in the tree.
                RefreshModel();
                SetCaption();

                // Load favourites, global ignores, and plugin options as part of the project.
                _windowManager.Favourites.AddAll(_project.Favourites);
                _windowManager.SetCaption(_projectFilename);

                // Load settings for windows.
                if (!noPlugins)
                    _windowManager.SetWindowItems(_project.Windows, _project.Items);

                // Load the project item. We avoid selecting it here because each
                // window will load it's own current item anyway, above.
                BaseItem item = Lookup(_project.ProjectItem);
                try
                {
                    _ignoreSelect = true;
                    SetActiveItem(item, this);
                }
                finally
                {
                    _ignoreSelect = false;
                }

                // Notify files changed.
                if (!noPlugins)
                    if (OnFilesChanged != null)
                        OnFilesChanged(_rootItem, new EventArgs());

                _watcher.Start();
            }
            catch (SerializationException exc)
            {
                _windowManager.Logger.LogExcStr(exc, "Deserializing project failed");
            }
            catch (IOException exc)
            {
                _windowManager.Logger.LogExcStr(exc, "Load project failed");
            }
        }