/// <summary> /// 保存菜单权限配置 /// </summary> /// <param name="roleid">角色ID</param> /// <param name="arrayMune">菜单集合</param> /// <returns></returns> public ActionResult SaveRoleButton(string roleid, List <RoleMenuOrButtonModel> array) { try { SystemRole role = _SystemRoleService.GetKey(roleid); List <SystemButton> buttonList = _SystemButtonService.GetAll().ToList(); if (role != null) { role.Button.Clear(); //arrayMune若为null则实例化一个空对象 foreach (RoleMenuOrButtonModel model in array == null ? new List <RoleMenuOrButtonModel>() : array) { Predicate <SystemButton> match = delegate(SystemButton m) { if (m.ButtonCode.ToLower() == model.Button.ToLower()) { return(true); } else { return(false); } }; SystemButton button = buttonList.Find(match); role.Button.Add(button); } _SystemRoleService.Edit(role); _SystemRoleService.Save(); return(Json(new { Code = 1, msg = "保存成功" }, JsonRequestBehavior.AllowGet)); } return(Json(new { Code = -1, msg = "保存失败" }, JsonRequestBehavior.AllowGet)); } catch (Exception error) { return(Json(new { Code = -1, msg = "保存失败:" + error.Message }, JsonRequestBehavior.AllowGet)); } }
public void Add(SystemButton button, Action<Boolean> callback) { if (button == SystemButton.None) throw new ArgumentOutOfRangeException("button"); if (callback == null) throw new ArgumentNullException("callback"); m_callbackmap[(Int32)button] = callback; }
public ActionResult InitSystemButton() { List <SystemButton> btnlist = new List <SystemButton>(); IList <ActionPermission> allActions = new unity().GetAllActionByAssembly(); foreach (ActionPermission ap in allActions) { //这种方法会产生垃圾数据,比如废弃的action或controller、area会一直存在Systembutton表 SystemButton btn = new SystemButton(); btn = _SystemButtonService.GetWhere(b => b.ButtonCode == ap.AreaName + "." + ap.ControllerName + "." + ap.ActionName).FirstOrDefault(); if (btn == null) { btn = new SystemButton(); btn.ActionName = ap.ActionName; btn.AreaName = ap.AreaName; btn.ControllerName = ap.ControllerName; btn.Description = ap.Description; btn.Title = ap.Description; btn.ButtonCode = ap.AreaName + "." + ap.ControllerName + "." + ap.ActionName; _SystemButtonService.Add(btn); _SystemButtonService.Save(); } else { btn.Description = ap.Description; btn.Title = ap.Description; _SystemButtonService.Save(); } } return(Json(new { code = 1 }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 注册每个按钮 /// </summary> /// <param name="buttonName"></param> /// <param name="sysButton"></param> /// <param name="visible"></param> private void RegisterButton(SystemButton sysButton, bool visible) { if (!visible) { return; } object obj = this.Template.FindName(sysButton.ToString() + "Button", this); if (obj != null) { Button bt = obj as Button; bt.Visibility = System.Windows.Visibility.Visible; bt.CommandParameter = sysButton; bt.SetBinding(Button.CommandProperty, new Binding("ActionCommand") { Source = this.DataContext }); bt.SetBinding(Button.ContentProperty, new Binding("Content" + sysButton.ToString()) { Source = this.DataContext }); bt.SetBinding(Button.IsEnabledProperty, new Binding("Allow" + sysButton.ToString()) { Source = this.DataContext }); } }
public RecordingData(Int32 system, Int32 player1, Int32 player2, Int32 player3, Int32 player4) { SystemInput = (SystemButton)system; Player1Input = (PlayerButton)player1; Player2Input = (PlayerButton)player2; Player3Input = (PlayerButton)player3; Player4Input = (PlayerButton)player4; }
/// <summary> /// Add a new input callback for a SystemButton. /// </summary> /// <param name="button">The button associated with the callback.</param> /// <param name="callback">The callback to be fired.</param> public void Add(SystemButton button, Action <bool> callback) { if (callback == null) { throw new ArgumentNullException(nameof(callback)); } Add((int)button, callback); }
/// <summary> /// Add a new input callback for a SystemButton. /// </summary> /// <param name="button">The button associated with the callback.</param> /// <param name="callback">The callback to be fired.</param> public void Add(SystemButton button, Action <Boolean> callback) { if (callback == null) { throw new ArgumentNullException("callback"); } Add((Int32)button, callback); }
private Office2007ButtonItemStateColorTable GetColorTable(MDISystemItem mdi, SystemButton button) { Office2007ButtonItemColorTable colors = m_ColorTable.ButtonItemColors[eButtonColor.Orange.ToString()]; Office2007ButtonItemStateColorTable ct = colors.Default; if (mdi.MouseDownButton == button) ct = colors.Pressed; else if (mdi.MouseOverButton == button) ct = colors.MouseOver; return ct; }
//private void InitUserCenterButton() //{ // systemButton_UserCenter = new SystemButton(); // systemButton_UserCenter.Image = global::Aurora_Player.Properties.Resources.UserCenter; // systemButton_UserCenter.Name = "UserCenter"; // systemButton_UserCenter.ToolTip = "个人中心"; // systemButton_UserCenter.NormalBackColor = System.Drawing.Color.Transparent; // systemButton_UserCenter.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(200)))), ((int)(((byte)(200)))), ((int)(((byte)(200))))); // systemButton_UserCenter.PressBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100))))); // systemButton_UserCenter.Size = new Size(30, 22); // this.SystemButtons.Add(systemButton_UserCenter); //} private void InitFullScreenButton() { systemButton_FullScreen = new SystemButton(); systemButton_FullScreen.Image = global::Aurora_Player.Properties.Resources.FullScreenF; systemButton_FullScreen.Name = "FullScreen"; systemButton_FullScreen.ToolTip = "全屏"; systemButton_FullScreen.NormalBackColor = System.Drawing.Color.Transparent; systemButton_FullScreen.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(200)))), ((int)(((byte)(200)))), ((int)(((byte)(200))))); systemButton_FullScreen.PressBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100))))); systemButton_FullScreen.Size = new Size(30, 22); this.SystemButtons.Add(systemButton_FullScreen); }
private void InitFeedBackButton() { systemButton_FeedBack = new SystemButton(); systemButton_FeedBack.Image = global::Aurora_Player.Properties.Resources.FeedBack; systemButton_FeedBack.Name = "FeedBack"; systemButton_FeedBack.ToolTip = "关于"; systemButton_FeedBack.NormalBackColor = System.Drawing.Color.Transparent; systemButton_FeedBack.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(200)))), ((int)(((byte)(200)))), ((int)(((byte)(200))))); systemButton_FeedBack.PressBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100))))); systemButton_FeedBack.Size = new Size(30, 22); this.SystemButtons.Add(systemButton_FeedBack); }
private void InitSettingsButton() { systemButton_Settings = new SystemButton(); systemButton_Settings.Image = global::Aurora_Player.Properties.Resources.Settingss; systemButton_Settings.Name = "Settings"; systemButton_Settings.ToolTip = "设置"; systemButton_Settings.NormalBackColor = System.Drawing.Color.Transparent; systemButton_Settings.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(200)))), ((int)(((byte)(200)))), ((int)(((byte)(200))))); systemButton_Settings.PressBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100))))); systemButton_Settings.Size = new Size(30, 22); this.SystemButtons.Add(systemButton_Settings); }
public void Add(SystemButton button, Action <bool> callback) { if (button == SystemButton.None) { throw new ArgumentOutOfRangeException(nameof(button)); } if (callback == null) { throw new ArgumentNullException(nameof(callback)); } m_callbackmap[(int)button] = callback; }
public void Add(SystemButton button, Action <Boolean> callback) { if (button == SystemButton.None) { throw new ArgumentOutOfRangeException("button"); } if (callback == null) { throw new ArgumentNullException("callback"); } m_callbackmap[(Int32)button] = callback; }
public void Call(SystemButton button, Boolean pressed) { if (button == SystemButton.None) throw new ArgumentOutOfRangeException("button"); if (m_callback != null) { m_callback(button, pressed); } else { Action<Boolean> callback; if (m_callbackmap.TryGetValue((Int32)button, out callback) == true) callback(pressed); } }
private void InitScreenShotButton() { systemButton_ScreenShot = new SystemButton(); systemButton_ScreenShot.Image = global::Aurora_Player.Properties.Resources.Camera; systemButton_ScreenShot.Name = "ScreenShot"; systemButton_ScreenShot.ToolTip = "截图"; systemButton_ScreenShot.NormalBackColor = System.Drawing.Color.Transparent; systemButton_ScreenShot.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(200)))), ((int)(((byte)(200)))), ((int)(((byte)(200))))); systemButton_ScreenShot.PressBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100))))); //systemButton_Skin.NormalImage = global::Aurora_Stock.Properties.Resources.skinNormal; //systemButton_Skin.PressImage = global::Aurora_Stock.Properties.Resources.skinPress; systemButton_ScreenShot.Size = new Size(30, 22); this.SystemButtons.Add(systemButton_ScreenShot); }
public MDISystemItem(string sName):base(sName) { this.GlobalItem=false; this.SetSystemItem(true); m_IsSystemIcon=false; m_Icon=null; m_MinimizeEnabled=true; m_RestoreEnabled=true; m_CloseEnabled=true; m_MouseOver=SystemButton.None; m_MouseDown=SystemButton.None; m_LastButtonClick=SystemButton.None; this.CanCustomize=false; this.Tooltip=""; this.ShowSubItems=false; m_ShouldSerialize=false; this.IsAccessible=false; }
public void Call(SystemButton button, Boolean pressed) { if (button == SystemButton.None) { throw new ArgumentOutOfRangeException("button"); } if (m_callback != null) { m_callback(button, pressed); } else { Action <Boolean> callback; if (m_callbackmap.TryGetValue((Int32)button, out callback) == true) { callback(pressed); } } }
public void Call(SystemButton button, bool pressed) { if (button == SystemButton.None) { throw new ArgumentOutOfRangeException(nameof(button)); } if (m_callback != null) { m_callback(button, pressed); } else { Action <bool> callback; if (m_callbackmap.TryGetValue((int)button, out callback)) { callback(pressed); } } }
internal static void EnableSystemButtons(Window window, SystemButton buttons) { var hwnd = GetWindowHwnd(window); var value = GetWindowLong(hwnd, GWL_STYLE); if (buttons.IsSet <SystemButton>(SystemButton.Minimize)) { value |= WS_MINIMIZEBOX; } if (buttons.IsSet <SystemButton>(SystemButton.Maximize)) { value |= WS_MAXIMIZEBOX; } if (buttons.IsSet <SystemButton>(SystemButton.Close)) { EnableCloseButton(window); } SetWindowLong(hwnd, GWL_STYLE, value); }
internal static void DisableSystemButtons(Window window, SystemButton buttons) { var hwnd = GetWindowHwnd(window); var value = GetWindowLong(hwnd, GWL_STYLE); if (buttons.IsSet<SystemButton>(SystemButton.Minimize)) { value = value & ~WS_MINIMIZEBOX; } if (buttons.IsSet<SystemButton>(SystemButton.Maximize)) { value = value & ~WS_MAXIMIZEBOX; } if (buttons.IsSet<SystemButton>(SystemButton.Close)) { DisableCloseButton(window); } SetWindowLong(hwnd, GWL_STYLE, value); }
private void PaintButton(Graphics g, MDISystemItem mdi , SystemButton button, Rectangle r, Office2007ButtonItemStateColorTable ct, ColorScheme colorScheme) { Region oldClip = g.Clip; g.SetClip(r); Office2007ButtonItemPainter.PaintBackground(g, ct, r, RoundRectangleShapeDescriptor.RoundCorner2); r.Inflate(-1, -1); r.Offset(1, 0); using (Bitmap bmp = mdi.GetButtonBitmap(g, button, r, colorScheme)) { if (button == SystemButton.Minimize && !mdi.MinimizeEnabled || button == SystemButton.Restore && !mdi.RestoreEnabled || button == SystemButton.Close && !mdi.CloseEnabled) { float[][] array = new float[5][]; array[0] = new float[5] { 0, 0, 0, 0, 0 }; array[1] = new float[5] { 0, 0, 0, 0, 0 }; array[2] = new float[5] { 0, 0, 0, 0, 0 }; array[3] = new float[5] { .5f, .5f, .5f, .5f, 0 }; array[4] = new float[5] { 0, 0, 0, 0, 0 }; System.Drawing.Imaging.ColorMatrix grayMatrix = new System.Drawing.Imaging.ColorMatrix(array); System.Drawing.Imaging.ImageAttributes disabledImageAttr = new System.Drawing.Imaging.ImageAttributes(); disabledImageAttr.ClearColorKey(); disabledImageAttr.SetColorMatrix(grayMatrix); g.DrawImage(bmp, r, 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, disabledImageAttr); } else { if (button == mdi.MouseDownButton) r.Offset(1, 1); g.DrawImageUnscaled(bmp, r); } } g.Clip = oldClip; }
public void SetInput(Input.InputState inputstate) { if (inputstate == null) { throw new ArgumentNullException("inputstate"); } foreach (PlayerButton button in Enum.GetValues(typeof(PlayerButton))) { PlayerButton buttonindex = button; inputstate[1].Add(buttonindex, x => RecieveInput((Int32)buttonindex, 1, x)); inputstate[2].Add(buttonindex, x => RecieveInput((Int32)buttonindex, 2, x)); inputstate[3].Add(buttonindex, x => RecieveInput((Int32)buttonindex, 3, x)); inputstate[4].Add(buttonindex, x => RecieveInput((Int32)buttonindex, 4, x)); } foreach (SystemButton button in Enum.GetValues(typeof(SystemButton))) { SystemButton buttonindex = button; inputstate[0].Add(buttonindex, x => RecieveInput((Int32)buttonindex, 0, x)); } }
public override void InternalClick(System.Windows.Forms.MouseButtons mb, System.Drawing.Point mpos) { if(this.IsSystemIcon) { m_LastButtonClick=SystemButton.None; base.InternalClick(mb,mpos); return; } Point p=mpos; //System.Windows.Forms.Control ctrl=this.ContainerControl as System.Windows.Forms.Control; //if(ctrl!=null) // p=ctrl.PointToClient(p); m_LastButtonClick=this.GetButton(p.X,p.Y); // Make sure that button is enabled if(m_LastButtonClick==SystemButton.Close && !m_CloseEnabled || m_LastButtonClick==SystemButton.Minimize && !m_MinimizeEnabled || m_LastButtonClick==SystemButton.Restore && !m_RestoreEnabled || m_LastButtonClick == SystemButton.Maximize && m_RestoreEnabled) m_LastButtonClick=SystemButton.None; if (m_LastButtonClick != SystemButton.None) base.InternalClick(mb, mpos); }
/// <summary> /// Allows to specify which buttons (minimize, maximize and close) shall be displayed on a given window. /// To be called after a call to DisableButtons to re-enable buttons. /// </summary> /// <param name="target"></param> /// <param name="buttons">The button to be activated - multiple buttons combined via | are possible.</param> public static void EnableSystemButtons(this Window target, SystemButton buttons) { Internal.SystemMenuManager.EnableSystemButtons(target, buttons); }
public void SetFlash(SystemButton button, byte color1, byte color2) => _renderer.SetFlash(_systemButtonMap[(byte)button].Midi, color1, color2);
public void SetPulse(SystemButton button, byte color) => _renderer.SetPulse(_systemButtonMap[(byte)button].Midi, color);
/// <summary> /// Initializes a new instance of this class for a system ButtonMap. /// </summary> /// <param name="buttonmap">The index of the ButtonMap.</param> /// <param name="button">The SystemButton to reference.</param> public ButtonWrapper(Int32 buttonmap, SystemButton button) { m_buttonmap = buttonmap; m_button = (Int32)button; }
/// <summary> /// Allows to specify which buttons (minimize, maximize and close) shall be displayed on a given window. /// To be called after a call to DisableButtons to re-enable buttons. /// </summary> /// <param name="target"></param> /// <param name="buttons">The button to be activated - multiple buttons combined via | are possible.</param> public static void EnableSystemButtons(this Window target, SystemButton buttons) { Internal.SystemMenuManager.EnableSystemButtons(target, buttons); }
/// <summary> /// Initializes a new instance of this class for a system ButtonMap. /// </summary> /// <param name="buttonmap">The index of the ButtonMap.</param> /// <param name="button">The SystemButton to reference.</param> public ButtonWrapper(Int32 buttonmap, SystemButton button) { m_buttonmap = buttonmap; m_button = (Int32)button; }
/// <summary> /// Initializes a new instance of this class for a system ButtonMap. /// </summary> /// <param name="buttonmap">The index of the ButtonMap.</param> /// <param name="button">The SystemButton to reference.</param> public ButtonWrapper(int buttonmap, SystemButton button) { MapIndex = buttonmap; ButtonIndex = (int)button; }
public override void InternalMouseMove(System.Windows.Forms.MouseEventArgs objArg) { base.InternalMouseMove(objArg); SystemButton btn=this.GetButton(objArg.X,objArg.Y); if (btn == SystemButton.Help) { // Help if (m_MouseOver != SystemButton.Help) { m_MouseOver = SystemButton.Help; if (this.ToolTipVisible) { this.HideToolTip(); this.ResetHover(); } this.Refresh(); } return; } if(btn==SystemButton.Minimize) { // Minimize if(m_MouseOver!=SystemButton.Minimize) { m_MouseOver=SystemButton.Minimize; if(this.ToolTipVisible) { this.HideToolTip(); this.ResetHover(); } this.Refresh(); } return; } if(btn==SystemButton.Restore) { // Restore if(m_MouseOver!=SystemButton.Restore) { m_MouseOver=SystemButton.Restore; if(this.ToolTipVisible) { this.HideToolTip(); this.ResetHover(); } this.Refresh(); } return; } if (btn == SystemButton.Maximize) { // Restore if (m_MouseOver != SystemButton.Maximize) { m_MouseOver = SystemButton.Maximize; if (this.ToolTipVisible) { this.HideToolTip(); this.ResetHover(); } this.Refresh(); } return; } if(btn==SystemButton.Close) { // Close if(m_MouseOver!=SystemButton.Close) { m_MouseOver=SystemButton.Close; if(this.ToolTipVisible) { this.HideToolTip(); this.ResetHover(); } this.Refresh(); } return; } if(m_MouseOver!=SystemButton.None) { m_MouseOver=SystemButton.None; if(this.ToolTipVisible) { this.HideToolTip(); this.ResetHover(); } this.Refresh(); } }
private Bitmap GetSysImage(SystemButton btn) { if(btn==SystemButton.None) return null; Rectangle rBtn = new Rectangle(0, 0, GetButtonSize().Width - 2, GetButtonSize().Height - 2); Bitmap bmp=new Bitmap(rBtn.Width,rBtn.Height,System.Drawing.Imaging.PixelFormat.Format24bppRgb); //bmp.GetHbitmap(); Graphics gBmp=Graphics.FromImage(bmp); rBtn.Inflate(0,-1); Rectangle rClip=rBtn; rClip.Inflate(-1,-1); using(SolidBrush brush=new SolidBrush(SystemColors.Control)) gBmp.FillRectangle(brush,0,0,bmp.Width,bmp.Height); //gBmp.Clear(SystemColors.Control); gBmp.SetClip(rClip); System.Windows.Forms.ControlPaint.DrawCaptionButton(gBmp,rBtn,(System.Windows.Forms.CaptionButton)btn,System.Windows.Forms.ButtonState.Flat); gBmp.ResetClip(); gBmp.Dispose(); bmp.MakeTransparent(SystemColors.Control); return bmp; }
private void MenuClick(object sender, System.EventArgs e) { // System items need to be collapsed by us on Click see RaiseClick method on BaseItem BaseItem.CollapseAll(this); BaseItem objItem=sender as BaseItem; if(objItem==null) return; m_LastButtonClick=SystemButton.None; if(objItem.Name=="dotnetbarsysmenurestore") m_LastButtonClick=SystemButton.Restore; else if(objItem.Name=="dotnetbarsysmenuminimize") m_LastButtonClick=SystemButton.Minimize; else if(objItem.Name=="dotnetbarsysmenuclose") m_LastButtonClick=SystemButton.Close; else if(objItem.Name=="dotnetbarsysmenunext") m_LastButtonClick=SystemButton.NextWindow; if(m_LastButtonClick!=SystemButton.None) this.RaiseClick(); }
internal static void PaintSystemButton(System.Drawing.Graphics g, SystemButton btn, Rectangle r, bool MouseDown, bool MouseOver, bool Disabled) { // Draw state if any if (MouseDown) { g.FillRectangle(new SolidBrush(ColorFunctions.PressedBackColor(g)), r); NativeFunctions.DrawRectangle(g, SystemPens.Highlight, r); } else if (MouseOver) { g.FillRectangle(new SolidBrush(ColorFunctions.HoverBackColor(g)), r); NativeFunctions.DrawRectangle(g, SystemPens.Highlight, r); } Bitmap bmp = new Bitmap(r.Width, r.Height, g); Graphics gBmp = Graphics.FromImage(bmp); Rectangle rBtn = new Rectangle(0, 0, r.Width, r.Height); rBtn.Inflate(0, -1); Rectangle rClip = rBtn; rClip.Inflate(-1, -1); using (SolidBrush brush = new SolidBrush(SystemColors.Control)) gBmp.FillRectangle(brush, 0, 0, r.Width, r.Height); gBmp.SetClip(rClip); System.Windows.Forms.ControlPaint.DrawCaptionButton(gBmp, rBtn, (System.Windows.Forms.CaptionButton)btn, System.Windows.Forms.ButtonState.Flat); gBmp.ResetClip(); gBmp.Dispose(); bmp.MakeTransparent(SystemColors.Control); if (Disabled) { float[][] array = new float[5][]; array[0] = new float[5] { 0, 0, 0, 0, 0 }; array[1] = new float[5] { 0, 0, 0, 0, 0 }; array[2] = new float[5] { 0, 0, 0, 0, 0 }; array[3] = new float[5] { .5f, .5f, .5f, .5f, 0 }; array[4] = new float[5] { 0, 0, 0, 0, 0 }; System.Drawing.Imaging.ColorMatrix grayMatrix = new System.Drawing.Imaging.ColorMatrix(array); System.Drawing.Imaging.ImageAttributes disabledImageAttr = new System.Drawing.Imaging.ImageAttributes(); disabledImageAttr.ClearColorKey(); disabledImageAttr.SetColorMatrix(grayMatrix); g.DrawImage(bmp, r, 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, disabledImageAttr); } else { if (MouseDown) r.Offset(1, 1); g.DrawImageUnscaled(bmp, r); } }
public override void InternalMouseUp(System.Windows.Forms.MouseEventArgs objArg) { base.InternalMouseUp(objArg); if(m_MouseDown!=SystemButton.None) { m_MouseDown=SystemButton.None; this.Refresh(); } }
internal Bitmap GetButtonBitmap(Graphics g, SystemButton btn, Rectangle r, ColorScheme colorScheme) { Bitmap bmp = new Bitmap(r.Width, r.Height, g); Graphics gBmp = Graphics.FromImage(bmp); Rectangle rBtn = new Rectangle(0, 0, r.Width, r.Height); rBtn.Inflate(0, -1); Rectangle rClip = rBtn; rClip.Inflate(-1, -1); using (SolidBrush brush = new SolidBrush(SystemColors.Control)) gBmp.FillRectangle(brush, 0, 0, r.Width, r.Height); gBmp.SetClip(rClip); System.Windows.Forms.ControlPaint.DrawCaptionButton(gBmp, rBtn, (System.Windows.Forms.CaptionButton)btn, System.Windows.Forms.ButtonState.Flat); gBmp.ResetClip(); gBmp.Dispose(); if (!colorScheme.MdiSystemItemForeground.IsEmpty) { Bitmap bitmap = new Bitmap(bmp, bmp.Width, bmp.Height); using (Graphics graphics2 = Graphics.FromImage(bitmap)) { graphics2.Clear(Color.Transparent); ImageAttributes imageAttrs = new ImageAttributes(); ColorMap map = new ColorMap(); map.OldColor = Color.Black; map.NewColor = colorScheme.MdiSystemItemForeground; imageAttrs.SetRemapTable(new ColorMap[] { map }, ColorAdjustType.Bitmap); graphics2.DrawImage(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, imageAttrs, null, IntPtr.Zero); } bmp.Dispose(); bmp=bitmap; } bmp.MakeTransparent(SystemColors.Control); return bmp; }
public override void InternalMouseLeave() { base.InternalMouseLeave(); //if(m_MouseOver==SystemButton.None && (System.Windows.Forms.Control.MouseButtons!=System.Windows.Forms.MouseButtons.Left || m_MouseDown==SystemButton.None)) //return; m_MouseDown=SystemButton.None; m_MouseOver=SystemButton.None; this.Refresh(); }
/// <summary> /// 手动注册按钮 /// </summary> /// <param name="sysButton"></param> public void RegisterButton(SystemButton sysButton) { RegisterButton(sysButton, true); }
public override void InternalMouseDown(System.Windows.Forms.MouseEventArgs objArg) { base.InternalMouseDown(objArg); if (objArg.Button != System.Windows.Forms.MouseButtons.Left || this.DesignMode || !this.GetEnabled()) return; if(this.IsSystemIcon) { if(m_Parent!=null) { if(this.Expanded) m_Parent.AutoExpand=false; else m_Parent.AutoExpand=true; } this.Expanded=!this.Expanded; return; } SystemButton btn=this.GetButton(objArg.X,objArg.Y); if (btn == SystemButton.Help) { m_MouseDown = SystemButton.Help; this.Refresh(); } else if(m_MinimizeEnabled && btn==SystemButton.Minimize) { m_MouseDown=SystemButton.Minimize; this.Refresh(); } else if(m_RestoreEnabled && btn==SystemButton.Restore) { m_MouseDown=SystemButton.Restore; this.Refresh(); } else if (!m_RestoreEnabled && btn == SystemButton.Maximize) { m_MouseDown = SystemButton.Maximize; this.Refresh(); } else if(m_CloseEnabled && btn==SystemButton.Close) { m_MouseDown=SystemButton.Close; this.Refresh(); } else// if(m_MouseDown!=btn) { m_MouseDown=SystemButton.None; this.Refresh(); } }
public void Set(SystemButton button, byte red, byte green, byte blue) => _renderer.Set(_systemButtonMap[(byte)button].Midi, red, green, blue);
private void PaintButton(ItemPaintArgs pa, SystemButton btn, Rectangle r) { System.Drawing.Graphics g=pa.Graphics; if(this.IsThemed) { System.Windows.Forms.Control container=this.ContainerControl as System.Windows.Forms.Control; if(container!=null) { ThemeWindow theme=pa.ThemeWindow; ThemeWindowParts part=ThemeWindowParts.MdiMinButton; ThemeWindowStates state=ThemeWindowStates.ButtonNormal; switch(btn) { case SystemButton.Close: { part=ThemeWindowParts.MdiCloseButton; break; } case SystemButton.Help: { part=ThemeWindowParts.MdiHelpButton; break; } case SystemButton.Restore: { part=ThemeWindowParts.MdiRestoreButton; break; } } if(btn==m_MouseDown) state=ThemeWindowStates.ButtonPushed; else if(btn==m_MouseOver) state=ThemeWindowStates.ButtonHot; theme.DrawBackground(g,part,state,r); return; } } // Draw state if any if(btn==m_MouseDown) { if(pa.Colors.ItemPressedBackground2.IsEmpty) g.FillRectangle(new SolidBrush(pa.Colors.ItemPressedBackground),r); else { System.Drawing.Drawing2D.LinearGradientBrush gradient=BarFunctions.CreateLinearGradientBrush(r,pa.Colors.ItemPressedBackground,pa.Colors.ItemPressedBackground2,pa.Colors.ItemPressedBackgroundGradientAngle); g.FillRectangle(gradient,r); gradient.Dispose(); } NativeFunctions.DrawRectangle(g,SystemPens.Highlight,r); } else if(btn==m_MouseOver) { if(!pa.Colors.ItemHotBackground2.IsEmpty) { System.Drawing.Drawing2D.LinearGradientBrush gradient=BarFunctions.CreateLinearGradientBrush(r,pa.Colors.ItemHotBackground,pa.Colors.ItemHotBackground2,pa.Colors.ItemHotBackgroundGradientAngle); g.FillRectangle(gradient,r); gradient.Dispose(); } else g.FillRectangle(new SolidBrush(pa.Colors.ItemHotBackground),r); NativeFunctions.DrawRectangle(g,new Pen(pa.Colors.ItemHotBorder),r); } using (Bitmap bmp = GetButtonBitmap(g, btn, r, pa.Colors)) { if (btn == SystemButton.Minimize && !m_MinimizeEnabled || btn == SystemButton.Restore && !m_RestoreEnabled || btn == SystemButton.Close && !m_CloseEnabled) { float[][] array = new float[5][]; array[0] = new float[5] { 0, 0, 0, 0, 0 }; array[1] = new float[5] { 0, 0, 0, 0, 0 }; array[2] = new float[5] { 0, 0, 0, 0, 0 }; array[3] = new float[5] { .5f, .5f, .5f, .5f, 0 }; array[4] = new float[5] { 0, 0, 0, 0, 0 }; System.Drawing.Imaging.ColorMatrix grayMatrix = new System.Drawing.Imaging.ColorMatrix(array); System.Drawing.Imaging.ImageAttributes disabledImageAttr = new System.Drawing.Imaging.ImageAttributes(); disabledImageAttr.ClearColorKey(); disabledImageAttr.SetColorMatrix(grayMatrix); g.DrawImage(bmp, r, 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, disabledImageAttr); } else { if (btn == m_MouseDown) r.Offset(1, 1); g.DrawImageUnscaled(bmp, r); } } }
public void Set(SystemButton button, Light light) => _renderer.Set(_systemButtonMap[(byte)button].Midi, light);
/// <summary> /// Add a new input callback for a SystemButton. /// </summary> /// <param name="button">The button associated with the callback.</param> /// <param name="callback">The callback to be fired.</param> public void Add(SystemButton button, Action<Boolean> callback) { if (callback == null) throw new ArgumentNullException("callback"); Add((Int32)button, callback); }
public void SetOff(SystemButton button) => _renderer.SetOff(_systemButtonMap[(byte)button].Midi);