/// <summary> /// 调整矩形使其在指定方向上与标准矩形对齐,并加上偏移量,不影响原来的矩形 /// </summary> /// <param name="rect">矩形</param> /// <param name="rectStand">标准矩形</param> /// <param name="align">方向</param> /// <param name="offset">偏移量</param> /// <returns>调整后的矩形</returns> public static Rectangle Align(Rectangle rect, Rectangle rectStand, TabAlignment align, int offset) { int value; switch (align) { case TabAlignment.Top: value = rect.Y - rectStand.Y + offset; rect.Y -= value; rect.Height += value; break; case TabAlignment.Bottom: value = rectStand.Bottom - rect.Bottom + offset; rect.Height += value; break; case TabAlignment.Left: value = rect.X - rectStand.X + offset; rect.X -= value; rect.Width += value; break; case TabAlignment.Right: value = rectStand.Right - rect.Right + offset; rect.Width += value; break; default: break; } return(rect); }
/// <summary> /// Adds a TabStop object to the collection and sets its alignment. /// </summary> public TabStop AddTabStop(Unit position, TabAlignment alignment) { TabStop tab = AddTabStop(position); tab.Alignment = alignment; return(tab); }
public virtual void SeveralTabsInRowTest() { String fileName = "severalTabsInRowTest.pdf"; String outFileName = destinationFolder + fileName; String cmpFileName = sourceFolder + "cmp_" + fileName; Document doc = InitDocument(outFileName); float tabInterval = doc.GetPdfDocument().GetDefaultPageSize().GetWidth() / 8; float[] positions = new float[] { tabInterval * 2, tabInterval * 4, tabInterval * 6 }; TabAlignment[] alignments = new TabAlignment[] { TabAlignment.RIGHT, TabAlignment.CENTER, TabAlignment.CENTER }; // Drawable[] leaders = {null, null, null}; ILineDrawer[] leaders = new ILineDrawer[] { new DottedLine(), new DashedLine(.5f), new SolidLine(.5f) }; Paragraph p = new Paragraph(); p.SetFontSize(8); IList <TabStop> tabStops = new List <TabStop>(); for (int i = 0; i < positions.Length; ++i) { TabStop tabStop = new TabStop(positions[i], alignments[i], leaders[i]); tabStops.Add(tabStop); } p.AddTabStops(tabStops); p.Add(new Tab()).Add("ttttttttttttttttttttttttttttttttttttttttttttt").Add(new Tab()).Add(new Tab()).Add("ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt\n" ); p.Add(new Tab()).Add(new Tab()).Add(new Tab()).Add("ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt\n" ); p.Add(new Tab()).Add(new Tab()).Add("ttttttttttttttttttttttttttttttttttttttttttttt").Add(new Tab()).Add("ttttttttttttttttttttttttttttttttttttttttttt" ); doc.Add(p); DrawTabStopsPositions(positions, doc, 1, 0, 120); doc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff" + outFileName)); }
public virtual void AnchorTabStopsTest01() { String fileName = "anchorTabStopsTest01.pdf"; String outFileName = destinationFolder + fileName; String cmpFileName = sourceFolder + "cmp_" + fileName; Document doc = InitDocument(outFileName); float tabInterval = doc.GetPdfDocument().GetDefaultPageSize().GetWidth() / 8; float[] positions1 = new float[] { tabInterval * 2, tabInterval * 3, tabInterval * 4, tabInterval * 5, tabInterval * 6 }; TabAlignment[] alignments1 = new TabAlignment[] { TabAlignment.ANCHOR, TabAlignment.CENTER, TabAlignment.ANCHOR , TabAlignment.RIGHT, TabAlignment.ANCHOR }; ILineDrawer[] leaders1 = new ILineDrawer[] { new DottedLine(), null, new DashedLine(.5f), null, new SolidLine (.5f) }; char?[] anchors1 = new char?[] { ' ', null, '\\', null, '.' }; Paragraph p = new Paragraph(); p.SetFontSize(8); AddTabbedTextToParagraph(p, text2, positions1, alignments1, leaders1, anchors1); doc.Add(p); DrawTabStopsPositions(positions1, doc, 1, 0, 120); doc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff" + outFileName)); }
/// <summary> /// 按指定边调整矩形,使在该方向上的大小为指定值 /// </summary> /// <param name="rect">矩形</param> /// <param name="align">方向</param> /// <param name="value">大小</param> /// <returns>调整后矩形</returns> public static Rectangle Adjust(Rectangle rect, TabAlignment align, int value) { switch (align) { case TabAlignment.Top: rect.Y += (rect.Height - value); rect.Height = value; break; case TabAlignment.Bottom: rect.Height = value; break; case TabAlignment.Left: rect.X += (rect.Width - value); rect.Width = value; break; case TabAlignment.Right: rect.Width = value; break; default: break; } return(rect); }
/// <summary> /// Creates a TabStop at the appropriate position, with a specified tab /// alignment and an explicitly given line pattern. /// </summary> /// <remarks> /// Creates a TabStop at the appropriate position, with a specified tab /// alignment and an explicitly given line pattern. A tab alignment defines /// the way the textual content should be positioned with regards to this tab /// stop. The line pattern defines a pattern that should be repeated until /// the TabStop is reached. If null, the space leading up to the TabStop will /// be empty. /// </remarks> /// <param name="tabPosition">a <code>float</code>, measured in points</param> /// <param name="tabAlignment"> /// a /// <see cref="iText.Layout.Properties.TabAlignment"/> /// value /// </param> /// <param name="tabLeader"> /// the /// <see cref="iText.Kernel.Pdf.Canvas.Draw.ILineDrawer"/> /// value, a pattern drawing object /// </param> public TabStop(float tabPosition, TabAlignment tabAlignment, ILineDrawer tabLeader) { this.tabPosition = tabPosition; this.tabAlignment = tabAlignment; this.tabLeader = tabLeader; this.tabAnchor = '.'; }
public override void DrawTab(Graphics gr, Rectangle borderrect, int index, bool selected, Color color1, Color color2, Color coloroutline, TabAlignment alignment) { GraphicsPath border = new GraphicsPath(); GraphicsPath fill = new GraphicsPath(); int xfar = borderrect.Right - 1; int ybot = (alignment == TabAlignment.Bottom) ? (borderrect.Y) : (borderrect.Bottom - 1); int ytop = (alignment == TabAlignment.Bottom) ? (borderrect.Bottom-1-((selected)?0:2)) : (borderrect.Y - ((selected) ? 2 : 0)); border.AddLine(borderrect.X, ybot, borderrect.X + shift, ytop); border.AddLine(borderrect.X + shift, ytop, xfar, ytop); border.AddLine(xfar, ytop, xfar + shift, ybot); fill.AddLine(borderrect.X, ybot + 1, borderrect.X + shift, ytop); fill.AddLine(borderrect.X + shift, ytop, xfar, ytop); fill.AddLine(xfar, ytop, xfar + shift, ybot + 1); gr.SmoothingMode = SmoothingMode.Default; using (Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(borderrect, color1, color2, 90)) gr.FillPath(b, fill); gr.SmoothingMode = SmoothingMode.AntiAlias; using (Pen p = new Pen(coloroutline, 1.0F)) gr.DrawPath(p, border); }
// Check if we need to nudge the mosue down and by how much private bool NeedsNudge(Screen ActiveScreen, TabAlignment Dir, out Point NudgeAmount) { NudgeAmount = new Point(0, 0); if (Dir == TabAlignment.Left) { // Hack to get the screen to the left, I couldn't find any API call to get the layout of the screens so this should do for most cases Screen Left = Screen.FromPoint(new Point(Cursor.Position.X - ScreenNudgeMargin * 2, ActiveScreen.Bounds.Bottom - ActiveScreen.Bounds.Height / 2)); if (Cursor.Position.Y <= Left.Bounds.Top) NudgeAmount.Y = Left.Bounds.Top; else if (Cursor.Position.Y > Left.Bounds.Bottom) NudgeAmount.Y = Left.Bounds.Bottom; else return false; return true; } else if (Dir == TabAlignment.Right) { Screen Right = Screen.FromPoint(new Point(Cursor.Position.X + ScreenNudgeMargin * 2, ActiveScreen.Bounds.Bottom - ActiveScreen.Bounds.Height / 2)); if (Cursor.Position.Y <= Right.Bounds.Top) NudgeAmount.Y = Right.Bounds.Top; else if (Cursor.Position.Y > Right.Bounds.Bottom) NudgeAmount.Y = Right.Bounds.Bottom; else return false; return true; } return false; }
/// <summary> /// 在指定的方向和反向放大矩形,不影响原来的矩形 /// </summary> /// <param name="rect">矩形</param> /// <param name="align">方向</param> /// <param name="value">放大量</param> /// <param name="revalue">反向放大量</param> /// <returns>放大后矩形</returns> public static Rectangle Inflate(Rectangle rect, TabAlignment align, int value, int revalue) { switch (align) { case TabAlignment.Top: rect.Y -= value; rect.Height += value + revalue; break; case TabAlignment.Bottom: rect.Y -= revalue; rect.Height += revalue + value; break; case TabAlignment.Left: rect.X -= value; rect.Width += value + revalue; break; case TabAlignment.Right: rect.X -= revalue; rect.Width += revalue + value; break; default: break; } return(rect); }
public GradientColor(Color color1, Color color2, GradientFill gradient) { this.color1 = color1; this.color2 = color2; this.fill = gradient; this.rect = new Rectangle(0, 0, 100, 100); this.align = TabAlignment.Top; }
/// <summary> /// Adds a TabStop object to the collection and sets its alignment and leader. /// </summary> public TabStop AddTabStop(Unit position, TabAlignment alignment, TabLeader leader) { TabStop tab = AddTabStop(position); tab.Alignment = alignment; tab.Leader = leader; return(tab); }
private System.Windows.Forms.TabAlignment m_TabAlignment = System.Windows.Forms.TabAlignment.Bottom; //记录隐藏区按钮的绘制状态 #endregion public HideAreaTabButtonItem(int iBasePanelID, string text, Image image, TabAlignment eAlignment) : base() { base.Text = text; base.Image = image; this.m_BasePanelID = iBasePanelID; this.m_TabAlignment = eAlignment; }
public HideAreaTabButton(int id, string text, Image image, TabAlignment eAlignment) : base() { base.Text = text; base.Image = image; this.m_iID = id; this.eAlignmentStyle = eAlignment; }
public MezStyle SetTabStop(Unit unit, TabAlignment alignment, bool clearAll = false) { if (clearAll) { Style.ParagraphFormat.TabStops.ClearAll(); } Style.ParagraphFormat.TabStops.AddTabStop(unit, alignment); return(this); }
public cnTabColor() { color1 = Color.White; color2 = Color.White; fill = TabControlFill.Solid; brush = null; pen = null; borderPen = null; rect = new Rectangle(0, 0, 100, 100); align = TabAlignment.Top; }
public cnTabColor(Color c1, Color c2, TabControlFill f) { color1 = c1; color2 = c2; fill = f; brush = null; pen = null; borderPen = null; rect = new Rectangle(0, 0, 100, 100); align = TabAlignment.Top; }
public OuterBorderForm(TabAlignment side, int size) { this.BorderSize = size; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.ShowInTaskbar = false; this.Side = side; this.Width = 0; this.Height = 0; this.BackColor = Color.FromArgb(202, 81, 0); this.StartPosition = FormStartPosition.Manual; SetSize(size); }
/// <inheritdoc /> /// <summary> /// Initializes a new instance of the <see cref="T:VisualPlus.Toolkit.Controls.Navigation.VisualTabControl" /> /// class. /// </summary> public VisualTabControl() { SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true); UpdateStyles(); _styleManager = new VisualStyleManager(Settings.DefaultValue.DefaultStyle); _border = new Border(); _alignment = TabAlignment.Top; _arrowSelectorVisible = true; _arrowSpacing = 10; _arrowThickness = 5; _itemSize = new Size(100, 25); _lineAlignment = StringAlignment.Near; _selectorAlignment = TabAlignment.Top; _selectorAlignment2 = TabAlignment.Bottom; _selectorThickness = 4; _separatorSpacing = 2; _separatorThickness = 2F; _backgroundColor = _styleManager.ControlStyle.Background(3); _separator = _styleManager.ControlStyle.Line; _tabMenu = Color.FromArgb(55, 61, 73); _textAlignment = StringAlignment.Center; _tabSelector = Color.Green; _textNormal = Color.FromArgb(174, 181, 187); _textRendererHint = Settings.DefaultValue.TextRenderingHint; _textSelected = Color.FromArgb(217, 220, 227); Font = _styleManager.Font; Size = new Size(320, 160); MinimumSize = new Size(144, 85); LineAlignment = StringAlignment.Center; ItemSize = _itemSize; _tabPageBorder = new Shape(); _tabNormal = _styleManager.TabStyle.TabEnabled; _tabSelected = _styleManager.TabStyle.TabSelected; _tabHover = _styleManager.TabStyle.TabHover; foreach (TabPage page in TabPages) { page.BackColor = _backgroundColor; page.Font = Font; } }
public void TabControl_Alignment_Set_GetReturnsExpected(TabAlignment value, bool expectedMultiline) { var control = new TabControl { Alignment = value }; Assert.Equal(value, control.Alignment); Assert.Equal(expectedMultiline, control.Multiline); // Set same. control.Alignment = value; Assert.Equal(value, control.Alignment); Assert.Equal(expectedMultiline, control.Multiline); }
/// <summary> /// 创建圆角矩形. /// </summary> /// <param name="rect"></param> /// <returns></returns> public static GraphicsPath CreateTabPath(Rectangle rect, TabAlignment alignment, int radius) { GraphicsPath path = new GraphicsPath(); switch (alignment) { case TabAlignment.Top: rect.X++; rect.Width -= 2; path.AddLine(rect.X, rect.Bottom, rect.X, rect.Y + radius / 2); path.AddArc(rect.X, rect.Y, radius, radius, 180F, 90F); path.AddArc(rect.Right - radius, rect.Y, radius, radius, 270F, 90F); path.AddLine(rect.Right, rect.Y + radius / 2, rect.Right, rect.Bottom); break; case TabAlignment.Bottom: rect.X++; rect.Width -= 2; path.AddLine(rect.X, rect.Y, rect.X, rect.Bottom - radius / 2); path.AddArc(rect.X, rect.Bottom - radius, radius, radius, 180, -90); path.AddArc(rect.Right - radius, rect.Bottom - radius, radius, radius, 90, -90); path.AddLine(rect.Right, rect.Bottom - radius / 2, rect.Right, rect.Y); break; case TabAlignment.Left: rect.Y++; rect.Height -= 2; path.AddLine(rect.Right, rect.Y, rect.X + radius / 2, rect.Y); path.AddArc(rect.X, rect.Y, radius, radius, 270F, -90F); path.AddArc(rect.X, rect.Bottom - radius, radius, radius, 180F, -90F); path.AddLine(rect.X + radius / 2, rect.Bottom, rect.Right, rect.Bottom); break; case TabAlignment.Right: rect.Y++; rect.Height -= 2; path.AddLine(rect.X, rect.Y, rect.Right - radius / 2, rect.Y); path.AddArc(rect.Right - radius, rect.Y, radius, radius, 270F, 90F); path.AddArc(rect.Right - radius, rect.Bottom - radius, radius, radius, 0F, 90F); path.AddLine(rect.Right - radius / 2, rect.Bottom, rect.X, rect.Bottom); break; } path.CloseFigure(); return(path); }
/// <summary>Anchors the rectangle to an anchored alignment of the base rectangle.</summary> /// <param name="anchorStyle">Alignment style.</param> /// <param name="baseRectangle">Base rectangle.</param> /// <param name="anchorWidth">Anchor width.</param> /// <returns>The <see cref="Rectangle" />.</returns> public static Rectangle ApplyAnchor(TabAlignment anchorStyle, Rectangle baseRectangle, int anchorWidth) { Point anchoredLocation; Size anchoredSize; switch (anchorStyle) { case TabAlignment.Top: { anchoredLocation = new Point(baseRectangle.X, baseRectangle.Y); anchoredSize = new Size(baseRectangle.Width, anchorWidth); break; } case TabAlignment.Bottom: { anchoredLocation = new Point(baseRectangle.X, baseRectangle.Bottom - anchorWidth); anchoredSize = new Size(baseRectangle.Width, anchorWidth); break; } case TabAlignment.Left: { anchoredLocation = new Point(baseRectangle.X, baseRectangle.Y); anchoredSize = new Size(anchorWidth, baseRectangle.Height); break; } case TabAlignment.Right: { anchoredLocation = new Point(baseRectangle.Right - anchorWidth, baseRectangle.Y); anchoredSize = new Size(anchorWidth, baseRectangle.Height); break; } default: { throw new ArgumentOutOfRangeException(nameof(anchorStyle), anchorStyle, null); } } Rectangle anchoredRectangle = new Rectangle(anchoredLocation, anchoredSize); return(anchoredRectangle); }
public virtual void SimpleTabStopsTest() { String fileName = "simpleTabStopsTest.pdf"; String outFileName = destinationFolder + fileName; String cmpFileName = sourceFolder + "cmp_" + fileName; Document doc = InitDocument(outFileName); float tabInterval = doc.GetPdfDocument().GetDefaultPageSize().GetWidth() / 8; //left alignments float[] positions1 = new float[] { tabInterval * 2, tabInterval * 4, tabInterval * 5 }; TabAlignment[] alignments1 = new TabAlignment[] { TabAlignment.LEFT, TabAlignment.LEFT, TabAlignment.LEFT }; ILineDrawer[] leaders1 = new ILineDrawer[] { null, null, null }; char?[] anchors1 = new char?[] { null, null, null }; Paragraph p = new Paragraph(); p.SetFontSize(8); AddTabbedTextToParagraph(p, text1, positions1, alignments1, leaders1, anchors1); doc.Add(p); doc.Add(new Paragraph("\n")); //right alignments float[] positions2 = new float[] { tabInterval * 3, tabInterval * 4, tabInterval * 6 }; TabAlignment[] alignments2 = new TabAlignment[] { TabAlignment.RIGHT, TabAlignment.RIGHT, TabAlignment.RIGHT }; ILineDrawer[] leaders2 = new ILineDrawer[] { null, null, null }; char?[] anchors2 = new char?[] { null, null, null }; p = new Paragraph(); p.SetFontSize(8); AddTabbedTextToParagraph(p, text1, positions2, alignments2, leaders2, anchors2); doc.Add(p); doc.Add(new Paragraph("\n")); //center alignments float[] positions3 = new float[] { tabInterval * 3, tabInterval * 4, tabInterval * 6 }; TabAlignment[] alignments3 = new TabAlignment[] { TabAlignment.CENTER, TabAlignment.CENTER, TabAlignment.CENTER }; ILineDrawer[] leaders3 = new ILineDrawer[] { null, null, null }; char?[] anchors3 = new char?[] { null, null, null }; p = new Paragraph(); p.SetFontSize(8); AddTabbedTextToParagraph(p, text1, positions3, alignments3, leaders3, anchors3); doc.Add(p); DrawTabStopsPositions(positions1, doc, 1, 0, 120); DrawTabStopsPositions(positions2, doc, 1, 125, 95); DrawTabStopsPositions(positions3, doc, 1, 235, 95); doc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff")); }
private TabControl MakeTab(int x, int y, TabAlignment a, TabAppearance ap) { TabControl tab = new TabControl(); // tab.Padding = new Point(20, 3); tab.Location = new Point (x, y); tab.Alignment = a; tab.Appearance = ap; tab.Controls.Add (CreateTabPage ("Red", Color.FromArgb (255, 255, 0, 0))); tab.Controls.Add (CreateTabPage ("Orange", Color.FromArgb (255, 255, 153, 0))); tab.Controls.Add (CreateTabPage ("Yellow", Color.FromArgb (255, 255, 255, 0))); tab.Controls.Add (CreateTabPage ("Green", Color.Green)); tab.Controls.Add (CreateTabPage ("Blue", Color.FromArgb (255, 0, 0, 255))); tab.Controls.Add (CreateTabPage ("Purple", Color.FromArgb (255, 197, 0, 148))); tab.Height = 200; tab.Width = 200; tab.SelectedIndex = 3; return tab; }
internal static TextFormatFlags TabAlignment2Flag(TabAlignment alignment) { TextFormatFlags flag = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter; switch (alignment) { case TabAlignment.Left: case TabAlignment.Right: flag |= TextFormatFlags.WordBreak; break; case TabAlignment.Bottom: case TabAlignment.Top: flag |= (TextFormatFlags.SingleLine); break; } return(flag); }
public cnTabControl() { SuspendLayout(); AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; BackColor = System.Drawing.Color.FromArgb(255, 251, 250, 251); ForeColor = System.Drawing.SystemColors.ControlText; Name = "cnTabControl"; Size = new System.Drawing.Size(200, 100); ResumeLayout(); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.UserPaint, true); tabPages = new cnTabPageCollection(this); this.tabPages.ClearComplete += new cnTabPageCollection.ClearCompleteEventHandler(TabPagesClearComplete); this.tabPages.InsertComplete += new cnTabPageCollection.InsertCompleteEventHandler(TabPagesInsertComplete); this.tabPages.RemoveComplete += new cnTabPageCollection.RemoveCompleteEventHandler(TabPagesRemoveComplete); this.tabPages.SetComplete += new cnTabPageCollection.SetCompleteEventHandler(TabPagesSetComplete); tabHeight = 25; tabAlignment = TabAlignment.Top; tabOffsetSel = 3; tabOffsetNormal = 6; borderColor = Color.FromArgb(255, 135, 155, 179); buttonStyles = TabButtonStyles.All; closeButton = false; currentPage = -1; offsetX = 0; tabWidth = 70; tabView = TabControlView.OneNote; tabPathSelected = new GraphicsPath(); tabPathNormal = new GraphicsPath(); hoverEnable = true; hoverPage = -1; textDirection = TabTextDirection.Horizontal; tabRadius = 10; toolTipPage = -1; toolTip = new ToolTip(); toolTip.Active = true; CreateColors(); GenerateTitlePath(); }
/* * /// <summary> * /// Указывает, что процесс создания кнопок не завершен и * /// размещение их функцией RelocationButtons невозможно. * /// </summary> * private bool initProcess = true; * * /// <summary> * /// Номер страницы для которой выдается подсказка * /// </summary> * private int toolTipPage; * * // Подсказка для закладки * private ToolTip toolTip;*/ public NetTabControl() { BackColor = Color.FromArgb(255, 251, 250, 251); ForeColor = SystemColors.ControlText; Size = new Size(200, 100); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.UserPaint, true); this.tabPages = new NetTabPageCollection(this); this.tabPages.ClearComplete += new EventHandler <EventArgs>(this.TabPagesClearComplete); this.tabPages.InsertComplete += new EventHandler <NetTabPageEventArgs>(this.TabPagesInsertComplete); this.tabPages.RemoveComplete += new EventHandler <NetTabPageEventArgs>(this.TabPagesRemoveComplete); this.TabHeight = 25; this.tabAlignment = TabAlignment.Top; this.currentPage = -1; this.tabOffsetSel = 3; this.tabOffsetNormal = 6; this.tabView = TabControlView.OneNote; this.buttonStyles = TabButtonStyles.All; this.closeButton = false; this.textDirection = TabTextDirection.Horizontal; this.offsetX = 0; this.tabWidth = 70; this.tabRadius = 10; this.tabPathSelected = new GraphicsPath(); this.tabPathNormal = new GraphicsPath(); this.hoverEnable = true; this.hoverPage = -1; /*this.toolTipPage = -1; * this.toolTip = new ToolTip(); * this.toolTip.Active = true;*/ this.CreateColors(); }
private TabControl MakeTab(int x, int y, TabAlignment a, TabAppearance ap) { TabControl tab = new TabControl(); // tab.Padding = new Point(20, 3); tab.Location = new Point(x, y); tab.Alignment = a; tab.Appearance = ap; tab.Controls.Add(CreateTabPage("Red", Color.FromArgb(255, 255, 0, 0))); tab.Controls.Add(CreateTabPage("Orange", Color.FromArgb(255, 255, 153, 0))); tab.Controls.Add(CreateTabPage("Yellow", Color.FromArgb(255, 255, 255, 0))); tab.Controls.Add(CreateTabPage("Green", Color.Green)); tab.Controls.Add(CreateTabPage("Blue", Color.FromArgb(255, 0, 0, 255))); tab.Controls.Add(CreateTabPage("Purple", Color.FromArgb(255, 197, 0, 148))); tab.Height = 200; tab.Width = 200; tab.SelectedIndex = 3; return(tab); }
private TabBar AddTabBar(DockStyle dockStyle, TabAlignment tabAlignment) { TabBar tabBar = new TabBar(); tabBar.Alignment = tabAlignment; tabBar.Width = 30; tabBar.Dock = dockStyle; tabBar.ShowDropDownButton = true; //tabBar.BackColor = SystemColors.Control;// Color.Silver; //tabBar.SelectedItemBackColor = Color.White; //tabBar.ItemBackColor = SystemColors.Control; //tabBar.ItemForeColor = SystemColors.ControlText; Controls.Add(tabBar); for (int i = 0; i < 5; i++) { tabBar.Items.Add(new TabItem(string.Format("Tab {0}", i))); } return(tabBar); }
public void TabControl_Alignment_SetWithHandle_GetReturnsExpected(TabAlignment value, bool expectedMultiline) { var control = new TabControl(); IntPtr oldHandle = control.Handle; Assert.NotEqual(IntPtr.Zero, oldHandle); control.Alignment = value; Assert.Equal(value, control.Alignment); Assert.Equal(expectedMultiline, control.Multiline); IntPtr newHandle = control.Handle; Assert.NotEqual(IntPtr.Zero, newHandle); Assert.NotEqual(oldHandle, newHandle); // Set same. control.Alignment = value; Assert.Equal(value, control.Alignment); Assert.Equal(expectedMultiline, control.Multiline); Assert.Equal(newHandle, control.Handle); }
public NetTabControl() { BackColor = Color.FromArgb(255, 251, 250, 251); ForeColor = SystemColors.ControlText; Size = new Size(200, 100); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.UserPaint, true); this.tabPages = new NetTabPageCollection(this); this.tabPages.ClearComplete += new EventHandler <EventArgs>(this.TabPagesClearComplete); this.tabPages.InsertComplete += new EventHandler <NetTabPageEventArgs>(this.TabPagesInsertComplete); this.tabPages.RemoveComplete += new EventHandler <NetTabPageEventArgs>(this.TabPagesRemoveComplete); this.tabHeight = 25; this.tabAlignment = TabAlignment.Top; this.currentPage = -1; this.CreateColors(); }
/// <summary>Initializes a new instance of the <see cref="VisualTabControl" /> class.</summary> public VisualTabControl() { SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true); UpdateStyles(); _styleManager = new StyleManager(Settings.DefaultValue.DefaultStyle); _border = new Border { Type = ShapeType.Rectangle }; _alignment = TabAlignment.Top; _selectorVisible = true; _selectorSpacing = 10; _selectorThickness = 5; _selectorAlignment = TabAlignment.Bottom; _itemSize = new Size(100, 25); _tabMenu = Color.FromArgb(55, 61, 73); _tabSelector = _styleManager.Theme.BackgroundSettings.Type4; _textRendererHint = Settings.DefaultValue.TextRenderingHint; _separatorSpacing = 2; _separatorThickness = 2F; _separator = _styleManager.Theme.OtherSettings.Line; _selectorTypes = SelectorTypes.Arrow; Size = new Size(320, 160); DrawMode = TabDrawMode.OwnerDrawFixed; ItemSize = _itemSize; }
/// <summary> /// 在指定的方向的两侧放大矩形,不影响原来的矩形 /// </summary> /// <param name="rect">矩形</param> /// <param name="align">方向</param> /// <param name="value">放大量</param> /// <returns>放大后矩形</returns> public static Rectangle InflateSide(Rectangle rect, TabAlignment align, int value) { int half = value / 2; switch (align) { case TabAlignment.Top: case TabAlignment.Bottom: rect.X -= half; rect.Width += value; break; case TabAlignment.Left: case TabAlignment.Right: rect.Y -= half; rect.Height += value; break; default: break; } return(rect); }
/// <summary> /// Adds a TabStop object to the collection and sets its alignment and leader. /// </summary> public TabStop AddTabStop(Unit position, TabAlignment alignment, TabLeader leader) { return this.TabStops.AddTabStop(position, alignment, leader); }
public ShadowBorderForm(TabAlignment side, int size) : base(side, size) { }
// Draw the actual tab for each alignment. private void DrawTab( Graphics graphics, Rectangle bounds, TabAlignment alignment, bool leftEdge ) { Border3DSide left = Border3DSide.Left; Border3DSide top = Border3DSide.Top; Border3DSide right = Border3DSide.Right; if (alignment == TabAlignment.Bottom) top = Border3DSide.Bottom; if ( leftEdge ) ControlPaint.DrawBorder3D(graphics, bounds, Border3DStyle.RaisedInner, left); ControlPaint.DrawBorder3D(graphics, bounds, Border3DStyle.RaisedInner, top); ControlPaint.DrawBorder3D(graphics, bounds, Border3DStyle.Raised, right); }
public TabControl() { selectedIndex = -1; alignment = TabAlignment.Top; drawMode = TabDrawMode.Normal; itemSize = new Size(42, 21); padding = new Point(6, 3); moveButtonSize = new Size (17, 17); sizeMode = TabSizeMode.Normal; appearance = TabAppearance.Normal; tabPageCollection = new TabPageCollection(this); SetStyle(ControlStyles.UserPaint, true); moveButtonLeftState = ButtonState.Normal; moveButtonRightState = ButtonState.Normal; hotTrackIndex = -1; SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); }
protected OuterBorderForm CreateBorder(TabAlignment side, int borderSize) { return new ShadowBorderForm(side, borderSize); }
public static string DecodeTabAlignmentInverse(TabAlignment t) { return t.ToString(); }
/// <summary> /// Creates a TabStop at the appropriate position, with a specified tab /// alignment. /// </summary> /// <remarks> /// Creates a TabStop at the appropriate position, with a specified tab /// alignment. A tab alignment defines the way the textual content should be /// positioned with regards to this tab stop. /// </remarks> /// <param name="tabPosition">a <code>float</code>, measured in points</param> /// <param name="tabAlignment"> /// a /// <see cref="iText.Layout.Properties.TabAlignment"/> /// value /// </param> public TabStop(float tabPosition, TabAlignment tabAlignment) : this(tabPosition, tabAlignment, null) { }
public override void DrawTab(Graphics gr, Rectangle borderrect, int index, bool selected, Color color1, Color color2, Color coloroutline, TabAlignment alignment) { System.Diagnostics.Debug.Assert(alignment == TabAlignment.Top); int additional = 0; // extra depth for fill if (selected) { additional = 1; borderrect.Height += borderrect.Y; // this one uses any height to get it bigger borderrect.Y = 0; } else { borderrect.Height -= 2; // shorter by this. borderrect.Y += 2; } int xfar = borderrect.Right - 1; int yfar = borderrect.Bottom - 1; GraphicsPath fill = new GraphicsPath(); fill.AddLine(borderrect.X, yfar + additional + 1, borderrect.X, borderrect.Y); fill.AddLine(borderrect.X, borderrect.Y, xfar, borderrect.Y); fill.AddLine(xfar, borderrect.Y, xfar, yfar + additional + 1); GraphicsPath border = new GraphicsPath(); border.AddLine(borderrect.X, yfar, borderrect.X, borderrect.Y); border.AddLine(borderrect.X, borderrect.Y, xfar, borderrect.Y); border.AddLine(xfar, borderrect.Y, xfar, yfar); gr.SmoothingMode = SmoothingMode.Default; using (Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(borderrect, color1, color2, 90)) gr.FillPath(b, fill); using (Pen p = new Pen(coloroutline, 1.0F)) gr.DrawPath(p, border); }
public abstract void DrawTab(Graphics gr, Rectangle borderrect, int index, bool selected, Color color1, Color color2, Color coloroutline, TabAlignment alignment);
public CustomTabControl() : base() { if (this._DisplayManager.Equals(TabControlDisplayManager.Custom)) { this.SetStyle(ControlStyles.UserPaint, true); this.ItemSize = new Size(0, 15); this.Padding = new Point(9,0); } this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.ResizeRedraw = true; _priorSelectedIndex = -1; _priorAlignment = TabAlignment.Left; ImageOffset = new System.Drawing.Point(16, 2); // We are simulating a close button with the close images. The // image is a stylized X from the VS2008 image library. There are // three versions - a regular CloseImage, the greyed version for // tabs that are not currently selected, and the hover image, // which is a highlighted (red) form that gets displayed when the // mouse hovers over the X. The effect is to make the image itself // highlight like a normal button might. // // OnMouseHover doesn't really work for the purposes of the close // "button". The close image isn't really a Control, so it gets no // Hover events. The TabControl is a Control, and it gets hover // events, but only one, on entry to the control. Moving the // mouse around on different tabs doesn't send a new hover event. // Therefore, we need to track the mouse events, and simulate the // effect. We use a timer for that purpose. It gets reset // whenever the mouse moves and is present on the close image. If // the mouse stops moving for a period of _hoverInterval ms, then // the timer fires and the close image is painted with the hover // image (a red X). If the mouse moves away from the closeimage // on the selected tab, the timer gets disabled. _hoverInterval = 110; _hoverTimer = new System.Timers.Timer { Interval = _hoverInterval, AutoReset = false }; // Hook up the Elapsed event for the timer. _hoverTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent); mhs = new MouseHoverState(); // get the images System.Reflection.Assembly assembly = this.GetType().Assembly; System.IO.Stream s1 = assembly.GetManifestResourceStream("CustomControls.Resources.Close.png"); var b = new Bitmap(s1); s1.Dispose(); //b.MakeTransparent(); CloseImage = b; s1 = assembly.GetManifestResourceStream("CustomControls.Resources.Close-grayed.png"); b = new Bitmap(s1); s1.Dispose(); //b.MakeTransparent(); CloseImageGray= b; s1 = assembly.GetManifestResourceStream("CustomControls.Resources.Close-hover.png"); b = new Bitmap(s1); s1.Dispose(); //b.MakeTransparent(); CloseImageHover= b; //System.Console.WriteLine("Images: Close({0}) Gray({1}) Hover({2})", CloseImage, CloseImageGray, CloseImageHover); }
/// <summary> /// Adds a TabStop object to the collection and sets its alignment. /// </summary> public TabStop AddTabStop(Unit position, TabAlignment alignment) { return this.TabStops.AddTabStop(position, alignment); }
/// <summary> /// Adds a TabStop object to the collection and sets its alignment and leader. /// </summary> public TabStop AddTabStop(Unit position, TabAlignment alignment, TabLeader leader) { TabStop tab = AddTabStop(position); tab.Alignment = alignment; tab.Leader = leader; return tab; }
/// <summary> /// Adds a TabStop object to the collection and sets its alignment. /// </summary> public TabStop AddTabStop(Unit position, TabAlignment alignment) { TabStop tab = AddTabStop(position); tab.Alignment = alignment; return tab; }