Example #1
0
        private void InitializePanel(int index, StatusPanel panel)
        {
            // Create a hosting panel for the new panel
            StatusPanelBorder host = new StatusPanelBorder(this);

            host.PaintBackground += new PaintEventHandler(OnPanelPaintBackground);

            // Assign across the panel
            host.StatusPanel = panel;

            // Set correct default border panel (for those defauled)
            if (host.StatusPanel.DefaultPanelBorder)
            {
                host.StatusPanel.PanelBorder = (_style != VisualStyle.Plain) ? PanelBorder.Solid : PanelBorder.Sunken;
            }

            // Add host to the collection of control
            Controls.Add(host);

            // Move to correct index
            Controls.SetChildIndex(host, index);

            // Hook into panel events
            panel.RequestedWidthChanged += new EventHandler(OnRepositionPanels);
            panel.PanelBorderChanged    += new EventHandler(OnRepositionPanels);
            panel.AlignmentChanged      += new EventHandler(OnRepositionPanels);
            panel.TextChanged           += new EventHandler(OnRepositionPanels);
            panel.ImageChanged          += new EventHandler(OnRepositionPanels);
            panel.VisibleChanged        += new EventHandler(OnRepositionPanels);
            panel.AutoSizingChanged     += new EventHandler(OnRepositionPanels);
            panel.PaintBackground       += new PaintEventHandler(OnPanelPaintBackground);
        }
Example #2
0
        /// <summary>
        /// Adds the specified StatusPanel object to the collection.
        /// </summary>
        /// <param name="value">The StatusPanel object to add to the collection.</param>
        /// <returns>The StatusPanel object added to the collection.</returns>
        public StatusPanel Add(StatusPanel value)
        {
            // Use base class to process actual collection operation
            base.List.Add(value as object);

            return(value);
        }
Example #3
0
        private void OnPanelRemoved(int index, object value)
        {
            // Do nothing until we are created
            if (IsHandleCreated && !IsDisposed)
            {
                // Cast to correct type
                StatusPanel panel = value as StatusPanel;

                // Unhook from panel events
                panel.RequestedWidthChanged -= new EventHandler(OnRepositionPanels);
                panel.PanelBorderChanged    -= new EventHandler(OnRepositionPanels);
                panel.AlignmentChanged      -= new EventHandler(OnRepositionPanels);
                panel.TextChanged           -= new EventHandler(OnRepositionPanels);
                panel.ImageChanged          -= new EventHandler(OnRepositionPanels);
                panel.VisibleChanged        -= new EventHandler(OnRepositionPanels);
                panel.AutoSizingChanged     -= new EventHandler(OnRepositionPanels);
                panel.PaintBackground       -= new PaintEventHandler(OnPanelPaintBackground);

                // Get hosting control from indexed position
                StatusPanelBorder host = Controls[index] as StatusPanelBorder;
                host.PaintBackground -= new PaintEventHandler(OnPanelPaintBackground);

                // Remove it from the collection of children
                Controls.Remove(host);

                // Ask for all panels to be repositioned
                OnRepositionPanels(this, EventArgs.Empty);
            }
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the StatusPanel class.
        /// </summary>
        /// <param name="parent">Back reference to recover drawing information.</param>
        public StatusPanelBorder(StatusBarControl parent)
        {
            // Prevent drawing flicker by blitting from memory in WM_PAINT
            SetStyle(ControlStyles.DoubleBuffer |
                     ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint, true);

            // Remember back pointer
            _parent = parent;

            // Not hosting a panel to start with
            _statusPanel = null;
        }
Example #5
0
        private void OnPanelInserted(int index, object value)
        {
            // Do not create child controls until we are created
            if (IsHandleCreated && !IsDisposed)
            {
                // Cast to correct type
                StatusPanel panel = value as StatusPanel;

                // Create hosting border control and add as child
                InitializePanel(index, panel);

                // Ask for all panels to be repositioned
                OnRepositionPanels(this, EventArgs.Empty);
            }
        }
Example #6
0
 /// <summary>
 /// Returns the index of the first occurrence of the given StatusPanel.
 /// </summary>
 /// <param name="value">The StatusPanel to locate.</param>
 /// <returns>Index of object; otherwise -1</returns>
 public int IndexOf(StatusPanel value)
 {
     // Find the 0 based index of the requested entry
     return(base.List.IndexOf(value));
 }
Example #7
0
 /// <summary>
 /// Determines whether a StatusPanel is in the collection.
 /// </summary>
 /// <param name="value">The StatusPanel to locate in the collection.</param>
 /// <returns>true if item is found in the collection; otherwise, false.</returns>
 public bool Contains(StatusPanel value)
 {
     // Use base class to process actual collection operation
     return(base.List.Contains(value as object));
 }
Example #8
0
 /// <summary>
 /// Inserts a StatusPanel instance into the collection at the specified location.
 /// </summary>
 /// <param name="index">The location in the collection where you want to add the StatusPanel.</param>
 /// <param name="value">The StatusPanel object to insert.</param>
 public void Insert(int index, StatusPanel value)
 {
     // Use base class to process actual collection operation
     base.List.Insert(index, value as object);
 }
Example #9
0
 /// <summary>
 /// Removes a StatusPanel from the collection.
 /// </summary>
 /// <param name="value">A StatusPanel to remove from the collection.</param>
 public void Remove(StatusPanel value)
 {
     // Use base class to process actual collection operation
     base.List.Remove(value as object);
 }