/// <summary>
        /// commandManager_Changed event handler.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An EventArgs that contains the event data.</param>
        private void commandManager_Changed(object sender, EventArgs e)
        {
            //	Raise the CommandManagerChanged event.
            OnCommandManagerChanged(EventArgs.Empty);

            //	Layout.
            LightweightControlContainerControl.PerformLayout();
            Invalidate();
        }
        /// <summary>
        /// Raises the MouseLeave event.
        /// </summary>
        /// <param name="e">An EventArgs that contains the event data.</param>
        protected override void OnMouseLeave(EventArgs e)
        {
            //	Call the base class's method so that registered delegates receive the event.
            base.OnMouseLeave(e);

            //	Clear the ToolTip.
            if ((tabEntry.TabPageControl.TabToolTipText != null && tabEntry.TabPageControl.TabToolTipText.Length != 0) ||
                !ShowTabText)
            {
                LightweightControlContainerControl.SetToolTip(null);
            }
        }
        /// <summary>
        /// The hook procedure for window messages generated by the FileOpenDialog
        /// </summary>
        /// <param name="hWnd">the handle of the window at which this message is targeted</param>
        /// <param name="msg">the message identifier</param>
        /// <param name="wParam">message-specific parameter data</param>
        /// <param name="lParam">mess-specific parameter data</param>
        /// <returns></returns>
        public IntPtr MyHookProc(IntPtr hWnd, UInt32 msg, Int32 wParam, Int32 lParam)
        {
            try
            {
                if (hWnd == IntPtr.Zero)
                {
                    return(IntPtr.Zero);
                }

                switch (msg)
                {
                // We're not interested in every possible message; just return a NULL for those we don't care about
                default:
                {
                    return(IntPtr.Zero);
                }

                // WM_INITDIALOG - at this point the OpenFileDialog exists, so we pull the user-supplied control
                // into the FileOpenDialog now, using the SetParent API.
                case WM.INITDIALOG:
                {
                    _hWndParent = User32.GetParent(hWnd);

                    //setting a bool for whether the OS is RTL (not the installed language of WLW)
                    IsRTL = (User32.GetWindowLong(_hWndParent, User32.GWL_EXSTYLE) & User32.WS_EX_LAYOUTRTL) > 0;

                    //account for large title bar, borders for adjusting control locations
                    TITLEBARINFO titleBarInfo = new TITLEBARINFO();
                    titleBarInfo.cbSize = (uint)Marshal.SizeOf(titleBarInfo);
                    if (!User32.GetTitleBarInfo(_hWndParent, ref titleBarInfo))
                    {
                        throw new Win32Exception(Marshal.GetLastWin32Error());
                    }

                    WINDOWINFO info = new WINDOWINFO();
                    info.cbSize = (uint)Marshal.SizeOf(info);
                    if (!User32.GetWindowInfo(_hWndParent, ref info))
                    {
                        throw new Win32Exception(Marshal.GetLastWin32Error());
                    }

                    _extraWindowHeight = (titleBarInfo.rcTitleBar.bottom - titleBarInfo.rcTitleBar.top) + 2 * (int)info.cyWindowBorders;
                    _extraWindowWidth  = 2 * (int)info.cxWindowBorders;

                    Rectangle rcClient = new Rectangle(0, 0, 0, 0);
                    // Get client rectangle of dialog
                    RECT rcTemp = new RECT();
                    User32.GetWindowRect(_hWndParent, ref rcTemp);
                    rcClient.X      = rcTemp.left;
                    rcClient.Y      = rcTemp.top;
                    rcClient.Width  = rcTemp.Width;
                    rcClient.Height = rcTemp.Height + TABS_HEIGHT + BUTTONS_HEIGHT;
                    //make the dialog box bigger
                    User32.MoveWindow(_hWndParent, rcClient.Left, rcClient.Top, rcClient.Width, rcClient.Height, true);
                    //move all the controls down
                    AdjustControlLocations();
                    //top tab control
                    mainTabControl = new LightweightControlContainerControl();
                    User32.SetParent(mainTabControl.Handle, _hWndParent);
                    mainTabControl.Location = new Point(0, 0);
                    mainTabControl.Anchor   = AnchorStyles.Left | AnchorStyles.Right;
                    mainTabControl.Size     = new Size(rcClient.Width, TABS_HEIGHT);

                    tabs = new TabLightweightControl();
                    tabs.ColorizeBorder = false;
                    tabs.VirtualBounds  = new Rectangle(0, 0, rcClient.Width, TABS_HEIGHT);
                    tabs.LightweightControlContainerControl = mainTabControl;
                    tabs.DrawSideAndBottomTabPageBorders    = false;

                    InsertImageTabControl tabFromFile = new InsertImageTabControl();
                    tabFromFile.TabText   = Res.Get(StringId.InsertImageInsertFromFile);
                    tabFromFile.TabBitmap = ResourceHelper.LoadAssemblyResourceBitmap("ImageInsertion.Images.TabInsertFromFile.png");
                    tabFromFile.BackColor = SystemColors.Control;
                    User32.SetParent(tabFromFile.Handle, _hWndParent);
                    tabs.SetTab(0, tabFromFile);

                    mainTabControl.BackColor = tabFromFile.ApplicationStyle.InactiveTabTopColor;

                    //now, add tabs for the other controls
                    int i = 1;
                    foreach (InsertImageSource imageSource in imageSources)
                    {
                        InsertImageTabControl tab = new InsertImageTabControl();
                        tab.TabText   = imageSource.TabName;
                        tab.TabBitmap = imageSource.TabBitmap;
                        tab.BackColor = SystemColors.Control;
                        tabs.SetTab(i++, tab);
                    }

                    tabs.SelectedTabNumberChanged += new EventHandler(tabs_SelectedTabNumberChanged);

                    //set the keyboard hook for tab switching
                    tabKeyboardHook = new TabbingHookProc(tabs);
                    tabKeyboardHook.Install(_hWndParent);

                    //add other image source panels
                    _panelImage             = new Panel();
                    _panelImage.Location    = new Point(0, mainTabControl.Size.Height);
                    _panelImage.BorderStyle = BorderStyle.None;
                    _panelImage.Anchor      = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
                    _panelImage.Size        = new Size(rcClient.Width, rcClient.Height - TABS_HEIGHT - BUTTONS_HEIGHT - _extraWindowHeight);
                    _panelImage.Visible     = false;

                    User32.SetParent(_panelImage.Handle, _hWndParent);

                    //initalize the other sources
                    foreach (InsertImageSource source in imageSources)
                    {
                        source.Init(_panelImage.Width, _panelImage.Height);
                        Control c = source.ImageSelectionControls;
                        DisplayHelper.Scale(c);
                        foreach (Control childControl in c.Controls)
                        {
                            DisplayHelper.Scale(childControl);
                        }
                    }
                    DisplayHelper.Scale(_panelImage);

                    //special cancel button
                    _buttonPanel             = new Panel();
                    _buttonPanel.Location    = new Point(rcClient.Width - (int)(0.5 * _extraWindowWidth) - _buttonPanel.Width, _panelImage.Bounds.Bottom);
                    _buttonPanel.Size        = new Size(75, 23);
                    _buttonPanel.BorderStyle = BorderStyle.None;

                    _cancelButton           = new Button();
                    _cancelButton.TextAlign = ContentAlignment.MiddleCenter;
                    if (BidiHelper.IsRightToLeft)
                    {
                        _cancelButton.RightToLeft = RightToLeft.Yes;
                    }
                    _cancelButton.Text      = Res.Get(StringId.CancelButton);
                    _cancelButton.FlatStyle = FlatStyle.System;
                    _cancelButton.Location  = new Point(0, 0);
                    _cancelButton.Size      = new Size(75, 23);
                    _cancelButton.Click    += new EventHandler(_cancelButton_Click);

                    _buttonPanel.Controls.Add(_cancelButton);

                    User32.SetParent(_buttonPanel.Handle, _hWndParent);

                    int    origWidth = _cancelButton.Width;
                    string tmp       = _cancelButton.Text;
                    _cancelButton.Text = Res.Get(StringId.InsertImageButton);
                    int newWidth = Math.Max(origWidth, DisplayHelper.MeasureButton(_cancelButton));
                    _cancelButton.Text = tmp;
                    newWidth           = Math.Max(newWidth, DisplayHelper.MeasureButton(_cancelButton));

                    _buttonPanel.Width = _cancelButton.Width = newWidth;
                    int deltaX = newWidth - origWidth;
                    _buttonPanel.Left -= deltaX;

                    //fixing up button text and tab order
                    IntPtr hWndOpenButton = User32.GetDlgItem(_hWndParent, _OPEN_BUTTON_ID);
                    User32.SetWindowText(hWndOpenButton, Res.Get(StringId.InsertImageButton));

                    mainTabControl.InitFocusManager();
                    mainTabControl.AddFocusableControls(tabs.GetAccessibleControls());
                    foreach (InsertImageSource tabPage in imageSources)
                    {
                        mainTabControl.AddFocusableControl(tabPage.ImageSelectionControls);
                    }

                    state = STATE.FILE;

                    return(IntPtr.Zero);
                }

                case WM.SIZE:
                {
                    ManipulatePanels();
                    return(IntPtr.Zero);
                }

                // WM_NOTIFY - we're only interested in the CDN_SELCHANGE notification message:
                // we grab the currently-selected filename and copy it into the buffer
                case WM.NOTIFY:
                {
                    IntPtr   ipNotify = new IntPtr(lParam);
                    OfNotify ofNot    = (OfNotify)Marshal.PtrToStructure(ipNotify, typeof(OfNotify));
                    Int16    code     = (short)ofNot.hdr.code;
                    if (code == CommonDlgNotification.SelChange)
                    {
                        UpdateChosenImage(false);
                        //CheckOptions(false);
                    }
                    else if (code == CommonDlgNotification.InitDone)
                    {
                        listener = new CommandListener(_hWndParent, this, (int)User32.GetDlgCtrlID(_cancelButton.Handle));
                    }
                    else if (code == CommonDlgNotification.FileOk)
                    {
                        // update the image path (need to do this if the user selected
                        // a file by simpliy typing in the filepath text box)
                        UpdateChosenImage(true);

                        // ok to insert
                        _insertFile = true;
                    }
                    else if ((code == CommonDlgNotification.FolderChange) && (state == STATE.WEB))
                    {
                        // If the user hits the OK button while there is no valid selection
                        // within the File panel, the file dialog sends a CommonDlgNotification.FolderChange
                        // We use this combined with other relevant state to trigger the closing
                        // of the Image dialog
                        HitOpen();
                    }
                    return(IntPtr.Zero);
                }
                }
            }
            catch (Exception ex)
            {
                UnexpectedErrorMessage.Show(ex);
                return(new IntPtr(1));
            }
            finally
            {
                GC.KeepAlive(this);
            }
        }
예제 #4
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components         = new System.ComponentModel.Container();
     this.mainTabControl     = new OpenLiveWriter.Controls.LightweightControlContainerControl();
     this.btnInsert          = new System.Windows.Forms.Button();
     this.btnCancel          = new System.Windows.Forms.Button();
     this.copyrightLinkLabel = new System.Windows.Forms.LinkLabel();
     ((System.ComponentModel.ISupportInitialize)(this.mainTabControl)).BeginInit();
     this.SuspendLayout();
     //
     // mainTabControl
     //
     this.mainTabControl.AllowDragDropAutoScroll = false;
     this.mainTabControl.AllPaintingInWmPaint    = true;
     this.mainTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                         | System.Windows.Forms.AnchorStyles.Left)
                                                                        | System.Windows.Forms.AnchorStyles.Right)));
     this.mainTabControl.BackColor = System.Drawing.SystemColors.Control;
     this.mainTabControl.Location  = new System.Drawing.Point(0, 0);
     this.mainTabControl.Name      = "mainTabControl";
     this.mainTabControl.Size      = new System.Drawing.Size(450, 485);
     this.mainTabControl.TabIndex  = 14;
     //
     // btnInsert
     //
     this.btnInsert.Anchor    = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.btnInsert.FlatStyle = System.Windows.Forms.FlatStyle.System;
     this.btnInsert.Location  = new System.Drawing.Point(288, 490);
     this.btnInsert.Name      = "buttonInsert";
     this.btnInsert.TabIndex  = 20;
     this.btnInsert.Text      = "Insert";
     this.btnInsert.Click    += new System.EventHandler(this.btnInsert_Click);
     //
     // btnCancel
     //
     this.btnCancel.Anchor       = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     this.btnCancel.FlatStyle    = System.Windows.Forms.FlatStyle.System;
     this.btnCancel.Location     = new System.Drawing.Point(368, 490);
     this.btnCancel.Name         = "buttonCancel";
     this.btnCancel.TabIndex     = 21;
     this.btnCancel.Text         = "Cancel";
     //
     // copyrightLinkLabel
     //
     this.copyrightLinkLabel.Anchor    = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     this.copyrightLinkLabel.AutoSize  = true;
     this.copyrightLinkLabel.FlatStyle = System.Windows.Forms.FlatStyle.System;
     this.copyrightLinkLabel.Location  = new System.Drawing.Point(6, 496);
     this.copyrightLinkLabel.Name      = "copyrightLinkLabel";
     this.copyrightLinkLabel.Size      = new System.Drawing.Size(208, 18);
     this.copyrightLinkLabel.TabIndex  = 19;
     this.copyrightLinkLabel.TabStop   = true;
     this.copyrightLinkLabel.Text      = "Please Respect Copyright";
     //
     // VideoBrowserForm
     //
     this.AcceptButton      = this.btnInsert;
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
     this.CancelButton      = this.btnCancel;
     this.ClientSize        = new System.Drawing.Size(450, 520);
     this.Controls.Add(this.copyrightLinkLabel);
     this.Controls.Add(this.btnCancel);
     this.Controls.Add(this.btnInsert);
     this.Controls.Add(this.mainTabControl);
     this.MaximizeBox   = false;
     this.MinimizeBox   = false;
     this.Name          = "VideoBrowserForm";
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
     this.Text          = "Insert Video";
     ((System.ComponentModel.ISupportInitialize)(this.mainTabControl)).EndInit();
     this.ResumeLayout(false);
 }
예제 #5
0
 internal LCCCFocusAndAccessibilityController(LightweightControlContainerControl control, bool wrap)
     : this(control)
 {
     _wrap = wrap;
 }
예제 #6
0
 internal LCCCFocusAndAccessibilityController(LightweightControlContainerControl control)
 {
     _control  = control;
     _controls = new ArrayList();
 }
예제 #7
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.mainTabControl     = new OpenLiveWriter.Controls.LightweightControlContainerControl();
     this.buttonInsert       = new System.Windows.Forms.Button();
     this.btnCancel          = new System.Windows.Forms.Button();
     this.copyrightLinkLabel = new System.Windows.Forms.LinkLabel();
     ((System.ComponentModel.ISupportInitialize)(this.mainTabControl)).BeginInit();
     this.SuspendLayout();
     //
     // mainTabControl
     //
     this.mainTabControl.AllowDragDropAutoScroll = false;
     this.mainTabControl.AllPaintingInWmPaint    = true;
     this.mainTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                         | System.Windows.Forms.AnchorStyles.Left)
                                                                        | System.Windows.Forms.AnchorStyles.Right)));
     this.mainTabControl.BackColor = System.Drawing.SystemColors.Control;
     this.mainTabControl.Location  = new System.Drawing.Point(0, 0);
     this.mainTabControl.Name      = "mainTabControl";
     this.mainTabControl.Size      = new System.Drawing.Size(450, 480);
     this.mainTabControl.TabIndex  = 14;
     //
     // buttonInsert
     //
     this.buttonInsert.Anchor       = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.buttonInsert.DialogResult = System.Windows.Forms.DialogResult.OK;
     this.buttonInsert.FlatStyle    = System.Windows.Forms.FlatStyle.System;
     this.buttonInsert.Location     = new System.Drawing.Point(282, 486);
     this.buttonInsert.Name         = "buttonInsert";
     this.buttonInsert.Size         = new System.Drawing.Size(75, 23);
     this.buttonInsert.TabIndex     = 20;
     this.buttonInsert.Text         = "Insert";
     //
     // btnCancel
     //
     this.btnCancel.Anchor       = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     this.btnCancel.FlatStyle    = System.Windows.Forms.FlatStyle.System;
     this.btnCancel.Location     = new System.Drawing.Point(363, 486);
     this.btnCancel.Name         = "btnCancel";
     this.btnCancel.Size         = new System.Drawing.Size(75, 23);
     this.btnCancel.TabIndex     = 21;
     this.btnCancel.Text         = "Cancel";
     //
     // copyrightLinkLabel
     //
     this.copyrightLinkLabel.Anchor       = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     this.copyrightLinkLabel.AutoSize     = true;
     this.copyrightLinkLabel.FlatStyle    = System.Windows.Forms.FlatStyle.System;
     this.copyrightLinkLabel.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
     this.copyrightLinkLabel.LinkColor    = System.Drawing.SystemColors.HotTrack;
     this.copyrightLinkLabel.Location     = new System.Drawing.Point(7, 493);
     this.copyrightLinkLabel.Name         = "copyrightLinkLabel";
     this.copyrightLinkLabel.Size         = new System.Drawing.Size(140, 15);
     this.copyrightLinkLabel.TabIndex     = 19;
     this.copyrightLinkLabel.TabStop      = true;
     this.copyrightLinkLabel.Text         = "Please Respect Copyright";
     //
     // MediaInsertForm
     //
     this.AcceptButton = this.buttonInsert;
     this.CancelButton = this.btnCancel;
     this.ClientSize   = new System.Drawing.Size(450, 520);
     this.Controls.Add(this.copyrightLinkLabel);
     this.Controls.Add(this.btnCancel);
     this.Controls.Add(this.buttonInsert);
     this.Controls.Add(this.mainTabControl);
     this.MaximizeBox = false;
     this.MinimizeBox = false;
     this.Name        = "MediaInsertForm";
     this.Text        = "Insert Video";
     ((System.ComponentModel.ISupportInitialize)(this.mainTabControl)).EndInit();
     this.ResumeLayout(false);
     this.PerformLayout();
 }