private void HandleInactiveDocument(DocumentContent previousDocument)
        {
            if (previousDocument == null)
            {
                return;
            }

            Tracer.Verbose("MainWindow.HandlePreviousActiveDocument", "[{0}] '{1}' becomes inactive",
                           DateTime.Now.ToLongTimeString(), previousDocument.Title);

            //remove the previous doc from event handling
            if (previousDocument is ZoomDocument)
            {
                ZoomDocument zd = (ZoomDocument)previousDocument;

                this.MainStatusBar.ZoomChanged -= new EventHandler <ZoomRoutedEventArgs>(zd.OnZoomChanged);
                zd.ZoomChanged -= new ZoomDocument.ZoomChangedEventHandler(this.MainStatusBar.OnZoomChanged);
            }

            //manage the contextual tab in the ribbon
            if (previousDocument is QueryDocument)
            {
                SyntaxedDocumentGroup.Visibility = System.Windows.Visibility.Collapsed;
                return;
            }
            if (previousDocument is TemplateDocument)
            {
                SyntaxedDocumentGroup.Visibility = System.Windows.Visibility.Collapsed;
                return;
            }
        }
        private void HandleActiveDocument(DocumentContent newDocument)
        {
            if (newDocument == null)
            {
                return;
            }

            Tracer.Verbose("MainWindow.HandleActiveDocument", "[{0}] '{1}' becomes active", DateTime.Now.ToLongTimeString(), newDocument.Title);

            //plug to zoom event handling if needed
            if (newDocument is ZoomDocument)
            {
                ZoomDocument zd = (ZoomDocument)newDocument;

                this.MainStatusBar.CanZoom          = true;
                this.MainStatusBar.sliderZoom.Value = zd.Scale;

                //root status bar update to the document
                this.MainStatusBar.ZoomChanged += new EventHandler <ZoomRoutedEventArgs>(zd.OnZoomChanged);

                //root doc evet to the status bar
                zd.ZoomChanged += new ZoomDocument.ZoomChangedEventHandler(this.MainStatusBar.OnZoomChanged);
            }
            else
            {
                this.MainStatusBar.CanZoom = false;                //disable the zoom slider
            }
            //manage the contextual tab in the ribbon
            if (newDocument is QueryDocument)
            {
                SyntaxedDocumentGroup.Visibility = System.Windows.Visibility.Visible;
                return;
            }
            if (newDocument is TemplateDocument)
            {
                SyntaxedDocumentGroup.Visibility = System.Windows.Visibility.Visible;
                return;
            }
        }