예제 #1
0
        private void frmPalette_Paint(object sender, PaintEventArgs e)
        {
            // draw title bar and frame.  Somewhat copied from Accordion
            Color c = Color.FromArgb(unchecked ((int)0xFFF6FCFC));

            if (this.ContainsFocus)
            {
                c = Color.FromArgb(unchecked ((int)0xFFE0FFE0));                // roughly above with DrawImageGreenTint colour matrix applied
            }
            using (SolidBrush br = new SolidBrush(c))
            {
                e.Graphics.FillRectangle(br, new Rectangle(0, 0, Width, Accordion.TITLEHEIGHT));
            }

            Accordion.DrawPaletteHeaderContent(m_Palette, this, e.Graphics);
            // not using the header images as we can't get the round edge (no transparent background), and the open one is almost flat colour anyway
            //	Accordion.DrawHeaderImages(New Image() {My.Resources.AM.PALETTELEFT, My.Resources.AM.ACCORDIONMIDOPEN, My.Resources.AM.ACCORDIONRIGHTOPEN}, Me, e.Graphics, DrawImageNormal)

            if (Controls.Count == 0 && m_Palette.Preview != null)
            {
                // if we don't have the actual control, draw the preview instead
                e.Graphics.DrawImage(m_Palette.Preview, BORDER, Accordion.TITLEHEIGHT);
            }
            // frame is drawn over the top of all that, so that it does not get obscured:
            using (Pen pn = new Pen(Accordion.OpenBorderColour))
            {
                e.Graphics.DrawRectangle(pn, new Rectangle(0, 0, Width - 1, Height - 1));
                e.Graphics.DrawLine(pn, 0, Accordion.TITLEHEIGHT - 1, Width, Accordion.TITLEHEIGHT - 1);
            }
        }
예제 #2
0
 public void EndBuild()
 {
     if (m_Build == null)
     {
         m_Building = false;
         Utilities.LogSubError(new Exception("AccordionContainer EndBuild with m_Build = Nothing"));
         ResumeLayout();
         return;
     }
     m_Build.Sort();             // sorts by Palette.DockIndex
     foreach (Accordion accordion in m_Build)
     {
         this.Controls.Add(accordion);
     }
     m_Build    = null;
     m_Building = false;
     // We can't really try and sort out all the heights as the controls are added, because many of the button panels might be added
     // during the form construction; but the buttons will only be added afterwards, so we don't know how high they need to be until somewhat later
     for (int index = 0; index <= this.Controls.Count - 1; index++)
     {
         Accordion accordion = (Accordion)Controls[index];
         accordion.Width = this.Width - 1 - RESIZEWIDTH;                 // would be done by Me.ResumeLayout(),
         accordion.InitialisePosition();
         // make ones at bottom 'oldest' so they collapse first
         accordion.LastAccessed = accordion.LastAccessed.AddMinutes(-index);
     }
     CheckSizes(-1);
     SetVerticalPositions();
     ResumeLayout();
 }
예제 #3
0
        public const int RESIZEWIDTH = 2;     // it is required that one of the above = RESIZEWIDTH and the other = 0; therefore the sum = RESIZEWIDTH

        private void SetVerticalPositions()
        {
            if (m_Repositioning)
            {
                return;
            }
            Debug.Assert(m_LeftResize == RESIZEWIDTH || m_RightResize == RESIZEWIDTH && (m_LeftResize == 0 || m_RightResize == 0));
            int Y = 0;

            m_Repositioning = true;
            try
            {
                for (int index = 0; index <= this.Controls.Count - 1; index++)
                {
                    Accordion control = (Accordion)this.Controls[index];
                    if (control.Visible)
                    {
                        control.Bounds = new Rectangle(m_LeftResize, Y, Width - 1 - RESIZEWIDTH, control.Height);
                        Y += control.Height + SPACING;
                    }
                }
            }
            finally
            { m_Repositioning = false; }
        }
예제 #4
0
        public void AccordionContainer_ControlRemoved(object sender, ControlEventArgs e)
        {
            Accordion control = (Accordion)e.Control;

            if (!this.DesignMode)
            {
                control.Opening -= Accordion_Opening;
            }
        }
예제 #5
0
        public void AccordionContainer_ControlAdded(object sender, ControlEventArgs e)
        {
            if (!(this.Controls[this.Controls.Count - 1] is Accordion))
            {
                throw new InvalidOperationException("AccordionContainer can only contain accordion objects");
            }
            Accordion control = (Accordion)e.Control;

            if (!this.DesignMode)
            {
                control.Opening += Accordion_Opening;
            }
        }
예제 #6
0
        private int OldestOpen(int excluding = -1)
        {
            DateTime oldestTime  = DateTime.MaxValue;            // Now.AddDays(-1) ' DateTime.MinValue doesn't seem to work (returns time only?)
            int      oldestIndex = -1;

            for (int index = 0; index <= this.Controls.Count - 1; index++)
            {
                Accordion accordion = (Accordion)this.Controls[index];
                if (accordion.Open && accordion.LastAccessed < oldestTime && index != excluding)
                {
                    oldestIndex = index;
                    oldestTime  = accordion.LastAccessed;
                }
            }
            return(oldestIndex);
        }