Пример #1
0
        /// <summary>
        /// This method is called when the tvControls's BeforeSelect event has been fired.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> that fired the event.</param>
        /// <param name="e">The <see cref="TreeViewCancelEventArgs"/> of the event.</param>
        private void tvControls_BeforeSelect(object sender, TreeViewCancelEventArgs e)
        {
            if (splitContainer1.Panel2.Controls.Count == 0)
            {
                return;
            }
            if (activeControl == null)
            {
                return;
            }
            IFinanceControl fc = e.Node.Tag as IFinanceControl;

            if (fc == null)
            {
                return;
            }
            if (fc == activeControl)
            {
                return;
            }
            UnloadFinanceControlEventArgs uea = new UnloadFinanceControlEventArgs();

            activeControl.UnloadControl(uea);
            e.Cancel = uea.Cancel;
        }
Пример #2
0
        /// <summary>
        /// This method is called when the tvControls's AfterSelect event has been fired.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> that fired the event.</param>
        /// <param name="e">The <see cref="TreeViewEventArgs"/> of the event.</param>
        private void tvControls_AfterSelect(object sender, TreeViewEventArgs e)
        {
            IFinanceControl fc = e.Node.Tag as IFinanceControl;

            if (fc == null || fc == activeControl)
            {
                return;
            }
            if (splitContainer1.Panel2.Controls.Count > 0)
            {
                splitContainer1.Panel2.Controls[0].Dispose();
                splitContainer1.Panel2.Controls.Clear();
            }
            if (e.Node == null)
            {
                return;
            }
            activeControl = fc;
            Control c = fc.CreateUI();

            if (c == null)
            {
                return;
            }
            //Panel pnl = new Panel();
            //pnl.AutoScroll = true;
            //pnl.AutoSize = true;
            //pnl.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            //pnl.Dock = DockStyle.Fill;
            //pnl.BackColor = System.Drawing.Color.Red;
            //pnl.Width = c.Width;
            //pnl.Height = c.Height;
            //c.Dock = DockStyle.Fill;
            //pnl.Controls.Add( c );
            c.Width  = splitContainer1.Panel2.Width;
            c.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
            ClearPluginMenuItems();
            splitContainer1.Panel2.Controls.Add(c);
        }