void f_brow_Init() { brow_Domain = brow_URL.Split('/')[2]; browser = new WebView(brow_URL, new BrowserSettings()); browser.Dock = DockStyle.Fill; browser.RequestHandler = this; browser.ConsoleMessage += f_brow_onBrowserConsoleMessage; browser.LoadCompleted += f_brow_onLoadCompleted; browser.MenuHandler = new CustomMenuHandler(); brow_Transparent = new ControlTransparent() { Location = new Point(0, 0), Size = new Size(999, 999) }; Panel toolbar = new Panel() { Dock = DockStyle.Top, Height = TOOLBAR_HEIGHT, BackColor = SystemColors.Control, Padding = new Padding(3, 3, 0, 3) }; brow_ShortCutBar = new Panel() { Dock = DockStyle.Top, Height = SHORTCUTBAR_HEIGHT, BackColor = SystemColors.Control, Padding = new Padding(0) }; brow_UrlTextBox = new TextBoxWaterMark() { WaterMark = "HTTP://...", Dock = DockStyle.Fill, Height = 20, Font = font_Title, BorderStyle = BorderStyle.None, BackColor = SystemColors.Control }; brow_UrlTextBox.KeyDown += (se, ev) => { if (ev.KeyCode == Keys.Enter) { f_brow_Go(brow_UrlTextBox.Text.Trim()); } }; brow_UrlTextBox.MouseDoubleClick += (se, ev) => { brow_UrlTextBox.Text = string.Empty; }; var btn_ToggleTab = new Button() { Text = tab_IconToggle, Width = 19, Height = 20, Dock = DockStyle.Right }; btn_ToggleTab.MouseClick += (se, ev) => { f_tab_Toggle(); }; toolbar.Controls.AddRange(new Control[] { brow_UrlTextBox, new Label() { Dock = DockStyle.Right, Width = 100 }, btn_ToggleTab }); this.Controls.AddRange(new Control[] { brow_Transparent, browser, brow_ShortCutBar, toolbar, }); }
////private void f_hook_mouse_HookManager_MouseWheel(object sender, MouseEventArgs e) ////{ //// //Debug.WriteLine(string.Format("Wheel={0:000}", e.Delta)); //// //f_hook_mouse_wheel_CallBack(e); ////} ////private void f_hook_mouse_HookManager_MouseWheelExt(object sender, MouseEventExtArgs e) ////{ //// //Debug.WriteLine(string.Format("Wheel={0:000}", e.Delta)); //// //Debug.WriteLine("Mouse Wheel Move Suppressed.\n"); //// e.Handled = true; //// //e.Handled = true; // true: break event at here, stop mouse wheel at here ////} ///////////////////////////////////////////////////////////// #endregion /*////////////////////////////////////////////////////////////////////////*/ public fMain() { this.Icon = browser.Properties.Resources.icon; this.FormBorderStyle = FormBorderStyle.None; this.StartPosition = FormStartPosition.CenterScreen; var ui_move = new ControlTransparent() { Location = new Point(0, 0), BackColor = Color.Transparent, Height = 45, Width = 99, Visible = false, }; this.Controls.Add(ui_move); ui_move.MouseMove += f_form_move_MouseDown; ui_move.MouseDoubleClick += (se, ev) => { if (this.Width != Screen.PrimaryScreen.WorkingArea.Width) { this.Tag = this.Width; this.Width = Screen.PrimaryScreen.WorkingArea.Width; this.Height = Screen.PrimaryScreen.WorkingArea.Height; this.Left = 0; this.Top = 0; } else { this.Height = Screen.PrimaryScreen.WorkingArea.Height - 27; this.Top = 27; this.Width = (int)this.Tag; this.Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width; } }; var ui_resize = new Label() { Text = string.Empty, Width = _SIZE_BOX, Height = _SIZE_BOX, BackColor = Color.Transparent, }; this.Controls.Add(ui_resize); ui_resize.MouseDown += (se, ev) => { f_hook_mouse_Open(); m_resizing = true; }; ui_resize.MouseUp += (se, ev) => { m_resizing = false; f_hook_mouse_Close(); }; var ui_close = new Label() { Location = new Point(0, 0), Width = 9, Height = 9, TextAlign = ContentAlignment.MiddleCenter, Text = string.Empty, BackColor = Color.LightGray, }; this.Controls.Add(ui_close); ui_close.MouseDoubleClick += (se, ev) => this.Close(); ui_close.MouseMove += f_form_move_MouseDown; ui_browser = new WebView("about:blank", new BrowserSettings() { PageCacheDisabled = true, WebSecurityDisabled = true, ApplicationCacheDisabled = true }); ui_browser.PropertyChanged += (sei, evi) => { if (evi.PropertyName == "IsBrowserInitialized") { ui_browser.Load("http://localhost:56789/"); } }; this.Controls.Add(ui_browser); ui_browser.MenuHandler = new MenuHandler(); ContextMenuStrip myMenu = new ContextMenuStrip(); this.ContextMenuStrip = myMenu; myMenu.Items.Add("Reload Page"); myMenu.Items.Add("Go Url"); myMenu.Items.Add(new ToolStripSeparator()); myMenu.Items.Add("Always Top"); myMenu.Items.Add("Minimize In TaskBar"); myMenu.Items.Add("Show DevTools"); ToolStripMenuItem mySubMenu = new ToolStripMenuItem("Set Width Window"); mySubMenu.DropDownItems.Add("Width = 480"); mySubMenu.DropDownItems.Add("Width = 600"); mySubMenu.DropDownItems.Add("Width = 800"); mySubMenu.DropDownItems.Add("Width = 999"); mySubMenu.DropDownItems.Add("Width = 1024"); mySubMenu.DropDownItems.Add("Width = 1366"); mySubMenu.DropDownItems.Add("Full Screen"); mySubMenu.DropDownItemClicked += (se, ev) => f_menuItem_Click(ev.ClickedItem.Text); myMenu.Items.Add(mySubMenu); myMenu.Items.Add(new ToolStripSeparator()); myMenu.Items.Add("Close Menu"); myMenu.Items.Add("Exit Program"); myMenu.ItemClicked += (se, ev) => f_menuItem_Click(ev.ClickedItem.Text); this.Shown += (se, ev) => { this.Width = 800; this.Height = 480;// Screen.PrimaryScreen.WorkingArea.Height - 27; //this.Top = 27; this.Top = Screen.PrimaryScreen.WorkingArea.Height - this.Height; this.Left = 0;// Screen.PrimaryScreen.WorkingArea.Width - this.Width; //ui_close.Location = new Point(this.Width - _SIZE_BOX, 0); //ui_close.Anchor = AnchorStyles.Top | AnchorStyles.Right; ui_move.Width = this.Width - (123 + 320); ui_move.Height = 48; ui_move.Location = new Point(123, 0); ui_move.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; ui_resize.Location = new Point(this.Width - _SIZE_BOX, this.Height - _SIZE_BOX); ui_resize.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; ui_browser.Dock = DockStyle.Fill; ui_browser.SendToBack(); }; }
public void f_init() { this.TopMost = true; this.Icon = Resources.favicon; this.FormBorderStyle = FormBorderStyle.None; this.BackColor = Color.Black; this.Width = 1; //if (!string.IsNullOrEmpty(title)) this.Text = title; // MEDIA m_media = new AxWindowsMediaPlayer(); m_media.Dock = DockStyle.Fill; m_media.Enabled = true; m_media.PlayStateChange += new _WMPOCXEvents_PlayStateChangeEventHandler(this.f_media_event_PlayStateChange); this.Controls.Add(m_media); // MODAL m_modal = new ControlTransparent(); m_modal.Location = new Point(0, 0); m_modal.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; m_modal.BackColor = Color.Black; m_modal.Opacity = 1; m_modal.MouseMove += f_form_move_MouseDown; m_modal.Click += (se, ev) => { if (m_media.playState == WMPLib.WMPPlayState.wmppsPlaying) { m_media.Ctlcontrols.pause(); } else { m_media.Ctlcontrols.play(); } }; this.Controls.Add(m_modal); m_modal.MouseDoubleClick += (se, ev) => { if (m_media.uiMode == "none") { m_media.uiMode = "full"; m_modal.Height = this.Height - 45; } else { m_media.uiMode = "none"; m_modal.Height = this.Height; } m_media.Ctlcontrols.play(); }; // RESIZE m_resize = new Panel(); m_resize.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; m_resize.BackColor = Color.Black; m_resize.Size = new Size(8, 8); this.Controls.Add(m_resize); m_resize.MouseDown += (se, ev) => { f_hook_mouse_Open(); m_resizing = true; }; m_resize.MouseUp += (se, ev) => { m_resizing = false; f_hook_mouse_Close(); //Debug.WriteLine("RESIZE: ok "); if (m_media.playState == WMPLib.WMPPlayState.wmppsPlaying) { m_media.Ctlcontrols.pause(); m_media.Ctlcontrols.play(); } else if (m_media.playState == WMPLib.WMPPlayState.wmppsPaused) { m_media.Ctlcontrols.play(); m_media.Ctlcontrols.pause(); } }; btn_exit = new IconButton(18) { IconType = IconType.ios_close_empty, Anchor = AnchorStyles.Right | AnchorStyles.Top }; btn_exit.Click += exit_Click; this.Controls.Add(btn_exit); }
void f_brow_Init() { brow_Domain = brow_URL.Split('/')[2]; browser = new GeckoWebBrowser(); browser.Dock = DockStyle.Fill; browser.NavigationError += (s, e) => { Debug.WriteLine("StartDebugServer error: 0x" + e.ErrorCode.ToString("X")); browser.Dispose(); }; browser.DocumentCompleted += (s, e) => { Debug.WriteLine("StartDebugServer completed"); browser.Dispose(); }; brow_Transparent = new ControlTransparent() { Location = new Point(0, 0), Size = new Size(999, 999) }; Panel toolbar = new Panel() { Dock = DockStyle.Top, Height = TOOLBAR_HEIGHT, BackColor = SystemColors.Control, Padding = new Padding(3, 3, 0, 3) }; brow_ShortCutBar = new Panel() { Dock = DockStyle.Top, Height = SHORTCUTBAR_HEIGHT, BackColor = SystemColors.Control, Padding = new Padding(0) }; brow_UrlTextBox = new TextBoxWaterMark() { WaterMark = "HTTP://...", Dock = DockStyle.Fill, Height = 20, Font = font_Title, BorderStyle = BorderStyle.None, BackColor = SystemColors.Control }; brow_UrlTextBox.KeyDown += (se, ev) => { if (ev.KeyCode == Keys.Enter) { f_brow_Go(brow_UrlTextBox.Text.Trim()); } }; brow_UrlTextBox.MouseDoubleClick += (se, ev) => { brow_UrlTextBox.Text = string.Empty; }; var btn_ToggleTab = new Button() { Text = tab_IconToggle, Width = 19, Height = 20, Dock = DockStyle.Right }; btn_ToggleTab.MouseClick += (se, ev) => { f_tab_Toggle(); }; toolbar.Controls.AddRange(new Control[] { brow_UrlTextBox, new Label() { Dock = DockStyle.Right, Width = 100 }, btn_ToggleTab }); this.Controls.AddRange(new Control[] { brow_Transparent, browser, brow_ShortCutBar, toolbar, }); }