Example #1
0
 public bool Equals(TabViewerHitTestInfo obj)
 {
  if(obj == null)
   return false;
  bool res = true;
  res &= IsButton == obj.IsButton;
  res &= TabIndex == obj.TabIndex;
  res &= IsSelected == obj.IsSelected;
  res &= TabRect == obj.TabRect;
  res &= BtnRect == obj.BtnRect;
  return res;
 }
Example #2
0
 //-------------------------------------------------------------------------------------
 private TabViewerHitTestInfo HitTest(MouseEventArgs e)
 {
  for(int a = 0; a < TabPages.Count; a++)
  {
   TabViewerHitTestInfo t = new TabViewerHitTestInfo();
   Rectangle r = this.GetTabRect(a);
   if(r.Contains(e.Location) == false)
    continue;
   t.TabIndex = a;
   t.TabRect = r;
   t.IsSelected = SelectedIndex == a;
   t.BtnRect = new Rectangle(r.X + r.Width - 20, r.Y+3, 14, 14);
   t.IsButton = t.BtnRect.Contains(e.Location);
   return t;
  } 
  return null;
 }
Example #3
0
 //-------------------------------------------------------------------------------------
 protected override void WndProc(ref Message m)
 {
  if(m.Msg == WM.LBUTTONDOWN)
  {
   MouseEventArgs e = new MouseEventArgs(MouseButtons.Left, 1,
    (short)(m.LParam), (short)((int)m.LParam >> 16), 0);
   TabViewerHitTestInfo t = HitTest(e);
   if(t != null && t.IsButton)
   {
    using(Graphics g = this.CreateGraphics())
     g.DrawImage(global::Sim.Shell.Properties.Resources.Xbutton_Pushed, t.BtnRect);
    return;
   }
   else if(prev != null)
    using(Graphics g = this.CreateGraphics())
    {
     LinearGradientBrush b;
     if(prev.IsSelected)
     {
      Rectangle gr = prev.TabRect;
      gr.Y--;
      gr.Height += 2;
      using(b = new LinearGradientBrush(gr, SystemColors.ControlLightLight,
                                  SystemColors.Control, LinearGradientMode.Vertical))
       g.FillRectangle(b, new Rectangle(prev.BtnRect.X, 1, prev.BtnRect.Width, prev.TabRect.Height));
     }
     else
      using(b = new LinearGradientBrush(this.ClientRectangle, SystemColors.GradientInactiveCaption,
                                  SystemColors.ControlLightLight, LinearGradientMode.Horizontal))
       g.FillRectangle(b, prev.BtnRect);
     if(prev.IsSelected)
      g.DrawImage(global::Sim.Shell.Properties.Resources.Xbutton, prev.BtnRect);
     prev = null;
    }
  }
  base.WndProc(ref m);
 }
Example #4
0
  //-------------------------------------------------------------------------------------
  protected override void OnMouseUp(MouseEventArgs e)
  {
   if(e.Button == System.Windows.Forms.MouseButtons.Left)
   {
    TabViewerHitTestInfo t = HitTest(e);
    if(t != null && t.IsButton)
    {
     CancelEventArgs<TabPage> arg = new CancelEventArgs<TabPage>(TabPages[t.TabIndex]);
     if(NeedPageClose != null)
      NeedPageClose(this, arg);
     if(arg.Cancel)
      return;

     prev = null;
     TabPages.RemoveAt(t.TabIndex);
    } 
   }
   base.OnMouseUp(e);
  }
Example #5
0
 //-------------------------------------------------------------------------------------
 protected override void OnMouseLeave(EventArgs e)
 {
  Graphics g = this.CreateGraphics();
  try
  {
   if(prev != null)
   {
    //System.Diagnostics.Debug.Write("l");
    LinearGradientBrush b;
    if(prev.IsSelected)
    {
     Rectangle gr = prev.TabRect;
     gr.Y--;
     gr.Height += 2;
     using(b = new LinearGradientBrush(gr, SystemColors.ControlLightLight,
                                 SystemColors.Control, LinearGradientMode.Vertical))
      g.FillRectangle(b, new Rectangle(prev.BtnRect.X, 1, prev.BtnRect.Width, prev.TabRect.Height));
    }
    else
     using(b = new LinearGradientBrush(this.ClientRectangle, SystemColors.GradientInactiveCaption,
                                 SystemColors.ControlLightLight, LinearGradientMode.Horizontal))
      g.FillRectangle(b, prev.BtnRect);
    if(prev.IsSelected)
     g.DrawImage(global::Sim.Shell.Properties.Resources.Xbutton, prev.BtnRect);
    prev = null;
   }
  }
  catch(Exception Err)
  {
   Sim.Controls.ErrorBox.Show(Err);
  }
  finally
  {
   g.Dispose();
   base.OnMouseLeave(e);
  }
 }
Example #6
0
 //-------------------------------------------------------------------------------------
 protected override void OnMouseMove(MouseEventArgs e)
 {
  Graphics g = this.CreateGraphics();
  try
  {
   TabViewerHitTestInfo t = HitTest(e);
   if((t == null && prev == null) || (t != null && t.Equals(prev)))
    return;
   if(prev != null)
   {
    //System.Diagnostics.Debug.Write("c");
    LinearGradientBrush b;
    if(prev.IsSelected)
    {
     Rectangle gr = prev.TabRect;
     gr.Y --;
     gr.Height += 2;
     using(b = new LinearGradientBrush(gr, SystemColors.ControlLightLight,
                                 SystemColors.Control, LinearGradientMode.Vertical))
      g.FillRectangle(b, new Rectangle(prev.BtnRect.X, 1, prev.BtnRect.Width, prev.TabRect.Height));
    }
    else
    {
     using (b = new LinearGradientBrush(this.ClientRectangle, SystemColors.GradientInactiveCaption,
                                 SystemColors.ControlLightLight, LinearGradientMode.Horizontal))
      g.FillRectangle(b, prev.BtnRect);
    }
    if(prev.IsSelected)
     g.DrawImage(global::Sim.Shell.Properties.Resources.Xbutton, prev.BtnRect);
    prev = null;
   }
   if(t != null)
   {
    if(t.IsButton)
    {
     if(e.Button == MouseButtons.Left)
      g.DrawImage(global::Sim.Shell.Properties.Resources.Xbutton_Pushed, t.BtnRect);
     else
      g.DrawImage(global::Sim.Shell.Properties.Resources.Xbutton_Raised, t.BtnRect);
    }
    else
     g.DrawImage(global::Sim.Shell.Properties.Resources.Xbutton, t.BtnRect);
    prev = t;
    //System.Diagnostics.Debug.Write("d");
   }
  }
  catch(Exception Err)
  {
   Sim.Controls.ErrorBox.Show(Err);
  }
  finally
  {
   g.Dispose();
   base.OnMouseMove(e);
  }
 }