public virtual MetroVisualManager VisualManager(bool bSet = false, MetroVisualManager vm = null) { if (bSet) { _visualManager = vm; return(null); } else { if (_visualManager == null) { IMetroControl parentControl = Owner as IMetroControl; if (parentControl != null) { return(parentControl.VisualManager()); } IMetroWindow parentWindow = Owner as IMetroWindow; if (parentWindow != null) { return(parentWindow.VisualManager()); } throw new ArgumentException("Impissibile recuperare il MetroVisualManager"); } else { return(_visualManager); } } }
public MetroWindow() { try { SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true); FormBorderStyle = FormBorderStyle.None; Name = "MetroWindow"; StartPosition = FormStartPosition.CenterScreen; MetroWindowButtons = new Dictionary <MetroWindowButton.TipoMetroWindowButton, MetroWindowButton>(); _visualManager = new MetroVisualManager(); PosizioneTitolo = MetroWindowTextPos.Centro; StileBordo = MetroWindowBorderStyle.Ridimensionabile; AltezzaBarraTitolo = 30; LarghezzaPulsanti = 30; BackColor = Color.Black; TransparencyKey = Color.Black; CloseBox = true; ShowShadowForm = true; MostraBordo = true; _bIsMaximizing = false; MostraBarraTitolo = true; _mdiClientController = new MdiClientController(); _mdiClientController.ParentForm = this; _mdiClientController.BorderStyle = BorderStyle.None; if (System.ComponentModel.LicenseManager.UsageMode != System.ComponentModel.LicenseUsageMode.Designtime) { _metroShadowForm = new MetroShadowForm(this); _metroShadowForm.Visible = true; } _refreshTimer = new Timer(); //_refreshTimer.Interval = 1000; //_refreshTimer.Tick += _refreshTimer_Tick; //_refreshTimer.Enabled = true; OnCombinazioneColoriChanged = null; OnStileMetroChanged = null; Icona = null; MostraIcona = false; MDIFormsTab = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected virtual void DrawChildrenTabs(Graphics g) { MetroVisualManager vm = VisualManager(); Rectangle totalRC = new Rectangle(0, 0, MdiClient.Width, 23); Rectangle rcBordoInf = new Rectangle(0, 21, MdiClient.Width, 2); g.FillRectangle(new SolidBrush(vm.WindowBackColor), totalRC); g.FillRectangle(new SolidBrush(vm.WindowBorderColor), rcBordoInf); foreach (MDITab tab in _mdiTabs) { if (tab.TabRect.Location.X + tab.TabRect.Width > MdiClient.Width - 25) { continue; } MetroWindow mw = tab.AssociateForm; if (tab.State == MDITab.EMDITabState.SELECTED) { g.FillRectangle(new SolidBrush(vm.MDIWindowTabSelected), tab.TabRect); TextRenderer.DrawText(g, mw.Text, vm.MDITabFont, tab.TabRect, vm.MDIWindowTextSelected, TextFormatFlags.Left | TextFormatFlags.VerticalCenter); if (tab.CloseButtonState == MDITab.EMDITabCloseButtonState.HOVER) { g.FillRectangle(new SolidBrush(vm.MDIWindowTabButtonHover), tab.CloseTabRect); } else if (tab.CloseButtonState == MDITab.EMDITabCloseButtonState.PRESSED) { g.FillRectangle(new SolidBrush(vm.MDIWindowTabButtonPressed), tab.CloseTabRect); } TextRenderer.DrawText(g, "r", vm.SmallSystemButtonFont, tab.CloseTabRect, vm.MDIWindowTextSelected, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); } else if (tab.State == MDITab.EMDITabState.HOVER) { g.FillRectangle(new SolidBrush(vm.MDIWindowTabHover), tab.TabRect); TextRenderer.DrawText(g, mw.Text, vm.MDITabFont, tab.TabRect, vm.MDIWindowTextHover, TextFormatFlags.Left | TextFormatFlags.VerticalCenter); if (tab.CloseButtonState == MDITab.EMDITabCloseButtonState.HOVER) { g.FillRectangle(new SolidBrush(vm.MDIWindowTabButtonHover), tab.CloseTabRect); } else if (tab.CloseButtonState == MDITab.EMDITabCloseButtonState.PRESSED) { g.FillRectangle(new SolidBrush(vm.MDIWindowTabButtonPressed), tab.CloseTabRect); } TextRenderer.DrawText(g, "r", vm.SmallSystemButtonFont, tab.CloseTabRect, vm.MDIWindowTextSelected, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); } else { g.FillRectangle(new SolidBrush(vm.MDIWindowTabNormal), tab.TabRect); TextRenderer.DrawText(g, mw.Text, vm.MDITabFont, tab.TabRect, vm.MDIWindowTextNormal, TextFormatFlags.Left | TextFormatFlags.VerticalCenter); } } }
public void Draw(MetroVisualManager vm, Graphics g) { if (Posizione.X == 0) { return; } Color clr = vm.MetroLinearProgressColor; g.FillRectangle(new SolidBrush(clr), new Rectangle(new Point(Posizione.X - 2, Posizione.Y - 2), new Size(3, 3))); }
void mdiClient_ControlAdded(object sender, ControlEventArgs e) { MetroWindow mw = e.Control as MetroWindow; if (mw == null) { throw new ArgumentException("Si possono aggiungere solo finestre di tipo MetroWindow"); } MDITab tab = new MDITab(); tab.AssociateForm = mw; tab.State = MDITab.EMDITabState.NORMAL; tab.CloseButtonState = MDITab.EMDITabCloseButtonState.NORMAL; Rectangle lastTabRect = new Rectangle(); Rectangle newTabRect = new Rectangle(); if (_mdiTabs.Count > 0) { lastTabRect = _mdiTabs[_mdiTabs.Count - 1].TabRect; } Graphics g = CreateGraphics(); if (g == null) { throw new NullReferenceException(); } MetroWindow p = ParentForm as MetroWindow; if (p == null) { throw new Exception("Il form padre deve essere una finestra di tipo MetroWindow"); } MetroVisualManager vm = p.VisualManager(); int width = (int)(g.MeasureString(mw.Text, vm.MDITabFont).Width + 30); newTabRect.Location = new Point(lastTabRect.Location.X + lastTabRect.Width, 0); newTabRect.Size = new Size(width, 21); tab.TabRect = newTabRect; _mdiTabs.Add(tab); _dropDownFileList.AddItem(mw.Text); }
public void Draw(MetroVisualManager vm, Graphics g) { if (_angoloCorrente <= 90) { return; } Point p = CalcolaPosizioneDaAngolo(); Color clr = vm.MetroCircularProgressColor; if (Width < 70) { g.FillEllipse(new SolidBrush(clr), new Rectangle(new Point(p.X - 2, p.Y - 2), new Size(3, 3))); } else { g.FillEllipse(new SolidBrush(clr), new Rectangle(new Point(p.X - 3, p.Y - 3), new Size(5, 5))); } }
public virtual MetroVisualManager VisualManager(bool bSet = false, MetroVisualManager vm = null) { MetroWindow wnd = ParentForm as MetroWindow; if (wnd == null) { throw new ArgumentException(); } if (bSet) { wnd.VisualManager(true, vm); return(null); } else { return(wnd.VisualManager()); } }
protected virtual void DrawDropDownFilesButton(Graphics g) { MetroVisualManager vm = VisualManager(); Rectangle rc = _dropDownFileListButtonRect; rc.Location = new Point(rc.Location.X + 1, rc.Location.Y - 1); if (_dropDownFileListButtonState == EDropDownFileListButtonState.NORMAL) { g.FillRectangle(new SolidBrush(vm.MDIDropDownFilesButtonNormal), _dropDownFileListButtonRect); TextRenderer.DrawText(g, "6", _dropDownFileListSymbolFont, rc, vm.MDIDropDownFilesButtonTextNormal, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); } else if (_dropDownFileListButtonState == EDropDownFileListButtonState.HOVER) { g.FillRectangle(new SolidBrush(vm.MDIDropDownFilesButtonHover), _dropDownFileListButtonRect); TextRenderer.DrawText(g, "6", _dropDownFileListSymbolFont, rc, vm.MDIDropDownFilesButtonTextHover, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); } else if (_dropDownFileListButtonState == EDropDownFileListButtonState.OPENED) { g.FillRectangle(new SolidBrush(vm.MDIDropDownFilesButtonPressed), _dropDownFileListButtonRect); TextRenderer.DrawText(g, "6", _dropDownFileListSymbolFont, rc, vm.MDIDropDownFilesButtonTextPressed, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); } }
protected virtual void OnPaint(PaintEventArgs e) { MetroVisualManager vm = VisualManager(); e.Graphics.FillRectangle(new SolidBrush(vm.WindowForeColor), MdiClient.DisplayRectangle); }