public AppBar(Form form, bool autoHide) { this.form = form; this.callbackMessageID = RegisterCallbackMessage(); this.form.FormClosing += new FormClosingEventHandler(Form_Closing); this.autoHide = autoHide; if (this.form.FormBorderStyle != FormBorderStyle.None) throw new Exception("Only forms with a FormBorderStyle of None are supported as an ApplicationDesktopToolbar. This is because the system does not support resizable and draggable AppBars"); if (this.form.TopMost == false) throw new Exception("An AppBar must be topmost to work properly"); this.formSize = PickAppropriateSize(); this.edgeFormSize = GenerateRECTForEdgeForm(1); this.edgeForm = new Form(); this.edgeForm.TopMost = true; this.edgeForm.FormBorderStyle = FormBorderStyle.None; this.edgeForm.ShowInTaskbar = false; this.edgeForm.MouseEnter += new EventHandler(UnhideAppbar); this.edgeForm.MouseHover += new EventHandler(UnhideAppbar); this.edgeForm.MouseMove += new MouseEventHandler(UnhideAppbar); this.timer = new Timer(); this.timer.Tick += new EventHandler(Timer_Tick); this.timer.Interval = 500; this.MakeNew(); }
private ShellApi.RECT PickAppropriateSize() { ShellApi.RECT rt = new ShellApi.RECT(); if ((_Edge == AppBarEdges.Left) || (_Edge == AppBarEdges.Right)) { rt.Top = 0; rt.Bottom = SystemInformation.PrimaryMonitorSize.Height; if (_Edge == AppBarEdges.Left) { rt.Right = this.form.Width; rt.Left = 0; } else { rt.Right = SystemInformation.PrimaryMonitorSize.Width; rt.Left = rt.Right - this.form.Width; } } else { rt.Left = 0; rt.Right = SystemInformation.PrimaryMonitorSize.Width; if (_Edge == AppBarEdges.Top) { rt.Bottom = this.form.Height; } else { rt.Bottom = SystemInformation.PrimaryMonitorSize.Height; rt.Top = rt.Bottom - this.form.Height; } } return rt; }