Exemplo n.º 1
0
        //=------------------------------------------------------------------=
        // addAndRemoveButton_Click
        //=------------------------------------------------------------------=
        /// <summary>
        ///   In this function, we will add, remove and reorder frames from
        ///   the TaskPane control, so you can see how it's done.  Basically,
        ///   it's just a collection like any other control with a collection
        ///   of controls hanging off it.  We will show you a few different
        ///   ways to do this.
        /// </summary>
        ///
        private void addAndRemoveButton_Click
        (
            System.Object sender,
            System.EventArgs e
        )
        {
            TaskFrame tf;

            //
            // first, we'll go and create a new TaskFrame control to add to
            // our parent TaskPane.  This isn't terribly difficult, and
            // mirrors closely what is done in the code generated by the
            // Forms Designer.
            //
            tf                       = new TaskFrame();
            tf.BackColor             = Color.Blue;
            tf.CollapseButtonVisible = true;
            tf.Text                  = "Newly Added Frame";

            // Add it to the parent .  You could also use the code:
            // Me.TaskPane1.Controls.Add(tf)
            //
            this.TaskPane1.TaskFrames.Add(tf);

            //
            // now, let's go and delete one of the frames that we don't want
            //
            this.TaskPane1.TaskFrames.Remove(this.TaskFrame0);

            //
            // Did you notice in the designer that there was a hidden
            // TaskFrame there with its Visible property set to False?
            // It still shows up in the Designer, but not at runtime until
            // its Visible property is set to True ...
            //
            this.hiddenTaskFrame.Visible = true;

            //
            // okay, let's go and add TaskFrame0 back, but this time at the
            // end of the list of frames ...
            //
            this.TaskPane1.Controls.Add(this.TaskFrame0);
        }
Exemplo n.º 2
0
        //=------------------------------------------------------------------=
        // OnSelectionChanged
        //=------------------------------------------------------------------=
        /// <summary>
        /// The ISelectionService tells us when the selection has changed.
        /// We'll use this to help us track which TaskFrame was last selected
        /// by the user.
        /// </summary>
        ///
        private void OnSelectionChanged(object sender, System.EventArgs e)
        {
            ISelectionService selsvc;
            TaskFrame         tf;
            object            c;

            selsvc = (ISelectionService)GetService(typeof(ISelectionService));
            if (selsvc != null)
            {
                c = selsvc.PrimarySelection;
                if (c != null)
                {
                    if (c is TaskFrame)
                    {
                        tf = (TaskFrame)c;
                        this.m_lastFrameSelected = tf;
                        tf.Parent.Refresh();
                    }
                }
            }

            checkVerbStatus();
        }
Exemplo n.º 3
0
        //=------------------------------------------------------------------=
        // checkVerbStatus
        //=------------------------------------------------------------------=
        /// <summary>
        /// Figures out whether we should enable/disable the Remove TaskFrame
        /// verb.
        /// </summary>
        ///
        private void checkVerbStatus()
        {
            TaskPane tp;

            if (this.m_removeVerb == null)
            {
                return;
            }

            //
            // If there's a last frame active, make sure it's still valid.
            //
            if (this.m_lastFrameSelected != null)
            {
                tp = (TaskPane)this.Control;
                if (tp != null)
                {
                    if (!tp.TaskFrames.Contains(this.m_lastFrameSelected))
                    {
                        this.m_lastFrameSelected = null;
                    }
                }
            }

            //
            // Okay, if we've still got it, then go and enable the remove verb
            //
            if (this.m_lastFrameSelected != null)
            {
                this.m_removeVerb.Enabled = true;
            }
            else
            {
                this.m_removeVerb.Enabled = false;
            }
        }