Ejemplo n.º 1
0
        private void Init(DataTable tree)
        {
            InitializeComponent();
            displayOptionsDialog1 = new TimeSeries.Forms.DisplayOptionsDialog(input);
            this.tblTree          = tree;

            SetupScenarios();

            if (!tblTree.Columns.Contains("DataSource"))
            {
                tblTree.Columns.Add("DataSource");
                tblTree.Columns["DataSource"].DefaultValue = "";
            }

            viewer1        = new Viewer();
            viewer1.Parent = this.splitContainer1.Panel2;
            viewer1.BringToFront();
            viewer1.Dock    = DockStyle.Fill;
            viewer1.Visible = true;

            if (input.DatabaseList.SupportExpertQueries)
            {
                this.expertSiteSelection1.Tree = tree;
            }
            else
            {
                this.tree1.Parent = this.splitContainer1.Panel1;
                this.tabControlSiteSelection.SendToBack();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Opens an object using the main thread containing a message handler.
        /// </summary>
        /// <param name="viewerObject">The object to be opened.</param>
        private void OpenObjectInForeground(object viewerObject)
        {
            try
            {
                // Activate the application when opening an object.  This is used in situations where a notification comes in while
                // another application is active.  When the user clicks on the notification widow, they will be routed to this
                // application, which then needs to be active to take the user's input.
                this.Activate();

                // Close down any documents that are currently open in the viewer.
                if (this.activeViewer != null)
                {
                    this.activeViewer.Close();
                }

                // If an object type was selected that doesn't have a viewer (or the viewer couldn't be loaded), then
                // reject the operation and leave the last viewer up.
                Viewer viewer = this.viewerTable[viewerObject.GetType()];
                if (viewer == null)
                {
                    throw new Exception("Viewer not found");
                }

                // This will synchronize the navigators with the open document.
                this.folderList.Open(viewerObject);
                this.guardianBar.Open(viewerObject);
                this.Text = viewerObject.ToString() + " - " + Properties.Settings.Default.ApplicationName;

                // This is an optimization: if the viewer for the current object is the same as the viewer for the last
                // object, then we'll skip the step of swapping the screen elements around and just reuse the current
                // viewer.  Otherwise, there's some modest reorgainization of the screen required to activate the proper
                // viewer.
                if (this.activeViewer != viewer)
                {
                    // The code below will modify the layout of the FormMain frame window.  It will swap out the current
                    // viewer its menus and toolbars and replace it with the new viewer and it's resources.  Suspending
                    // the layout will minimize the screen distractions.
                    SuspendLayout();

                    // Swap the new active viewer with the previous one.  Also, have the viewer cleared out so it's empty
                    // the next time it's activated.  This gets rid of the disturbing effect of seeing the previous data
                    // when you select a new report.  It shows up momentarily while the new document is constructed.
                    // Clearing it out now will give it a chance to create a blank report in the background.
                    viewer.BringToFront();

                    this.menuStrip.SuspendLayout();
                    this.toolStrip.SuspendLayout();

                    // Clear the previous menu and tools from the child viewer out of the main container area.
                    ToolStripManager.RevertMerge(this.menuStrip);
                    ToolStripManager.RevertMerge(this.toolStrip);

                    // Merge the container's menu with the menu of the active viewer.
                    ToolStripManager.Merge(viewer.MenuStrip, this.menuStrip);
                    ToolStripManager.Merge(viewer.ToolBarStandard, this.toolStrip);

                    this.menuStrip.ResumeLayout();
                    this.toolStrip.ResumeLayout();

                    // Let the screen process the changes.
                    this.ResumeLayout();

                    this.activeViewer = viewer;
                }

                // Opening is a somewhat involved operation.  Because it may take a few seconds to open a report, the
                // message loop can't be suspended while the user waits.  The operation is done asynchronously.  This
                // operation will kick off an asynchronous operation in the viewer that will gather all the resources
                // needed and draw the document.  When that operation is complete, the viewer will kick off an event that
                // will signal the 'Open' operation is complete.  At that point, a message will be broadcast from the
                // control and picked up by the 'viewer_EndOpenDocument' method below which will complete the operation of
                // opening the viewer and document.
                this.activeViewer.Open(viewerObject);
            }
            catch (Exception exception)
            {
                // These user interface errors need to be show to the users.
                MessageBox.Show(exception.Message, "Guardian Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }