public void Init(IBlogPostImageDataContext dataContext)
        {
            _imageDataContext = dataContext;
            // initialization constants
            const int TOP_INSET = 2;

            imageTabPageImage   = new ImageTabPageImageControl();
            imageTabPageLayout  = new ImageTabPageLayoutControl();
            imageTabPageEffects = new ImageTabPageEffectsControl();
            imageTabPageUpload  = new ImageTabPageUploadControl();

            _tabPages = new ImageEditingTabPageControl[] { imageTabPageLayout, imageTabPageImage, imageTabPageEffects, imageTabPageUpload };
            for (int i = 0; i < _tabPages.Length; i++)
            {
                ImageEditingTabPageControl tabPage = _tabPages[i];
                tabPage.DecoratorsManager = dataContext.DecoratorsManager;
                tabPage.TabStop           = false;
                tabPage.TabIndex          = i;
                Controls.Add(tabPage);
                tabLightweightControl.SetTab(i, tabPage);
            }

            // initial appearance of editor
            tabLightweightControl.SelectedTabNumber = 0;

            InitializeCommands();
            InitializeToolbar();

            _imageDataContext.DecoratorsManager.GetImageDecorator(BrightnessDecorator.Id).Command.StateChanged += new EventHandler(Command_StateChanged);

            // configure primary workspace
            // configure primary workspace
            SuspendLayout();
            TopLayoutMargin = TOP_INSET;
            LeftColumn.UpperPane.LightweightControl = tabLightweightControl;
            CenterColumn.Visible = false;
            RightColumn.Visible  = false;
            ResumeLayout();
        }
        /// <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);
            }
        }
예제 #3
0
        public VideoBrowserForm(ArrayList videoSources, string blogID, int selectedTab)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            _videoSources = videoSources;

            //set strings
            btnInsert.Text = Res.Get(StringId.InsertButtonText);
            btnCancel.Text = Res.Get(StringId.CancelButton);
            Text           = Res.Get(StringId.Plugin_Videos_Select_Video_Form);

            if (!MarketizationOptions.IsFeatureEnabled(MarketizationOptions.Feature.VideoCopyright))
            {
                copyrightLinkLabel.Visible = false;
            }
            else
            {
                copyrightLinkLabel.Font = Res.GetFont(FontSize.Small, FontStyle.Regular);
                copyrightLinkLabel.Text = Res.Get(StringId.Plugin_Video_Copyright_Notice);
                string link = MarketizationOptions.GetFeatureParameter(MarketizationOptions.Feature.VideoCopyright, "Glink");
                if (link == null || link == String.Empty)
                {
                    copyrightLinkLabel.LinkArea = new LinkArea(0, 0);
                }
                else
                {
                    copyrightLinkLabel.LinkClicked += copyrightLinkLabel_LinkClicked;
                }
            }

            copyrightLinkLabel.LinkColor = SystemColors.HotTrack;

            //
            // tabs
            //
            tabs = new TabLightweightControl();
            tabs.VirtualBounds = new Rectangle(0, 5, 450, 485);
            tabs.LightweightControlContainerControl = mainTabControl;
            tabs.DrawSideAndBottomTabPageBorders    = false;
            tabs.ColorizeBorder = false;

            int i = 0;

            foreach (VideoSource videoSource in _videoSources)
            {
                videoSource.BlogId = blogID;
                videoSource.Init();
                videoSource.VideoSelected += new EventHandler(videoSource_VideoSelected);
                TabPageControl tab = (TabPageControl)videoSource;
                tab.TabStop = false;
                Controls.Add(tab);
                tabs.SetTab(i++, tab);
            }

            // initial appearance of editor

            SetActiveTab(selectedTab);
            tabs.SelectedTabNumber = selectedTab;

            tabs.SelectedTabNumberChanged += new EventHandler(tabs_SelectedTabNumberChanged);

            if (!DesignMode)
            {
                Icon = ApplicationEnvironment.ProductIcon;
            }

            tabs.VirtualLocation = new Point(0, 5);
            tabs.VirtualSize     = Size;

            Width  = 510;
            Height = 570;
        }
예제 #4
0
        public MediaInsertForm(List <MediaTab> sources, string blogID, int selectedTab, MediaSmartContent content, string title, bool showCopyright, bool isEdit)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            _sources = sources;

            //set strings
            btnCancel.Text = Res.Get(StringId.CancelButton);
            if (!isEdit)
            {
                buttonInsert.Text = Res.Get(StringId.InsertButtonText);
            }
            else
            {
                buttonInsert.Text = Res.Get(StringId.OKButtonText);
            }

            Text = title;

            if (!showCopyright || !MarketizationOptions.IsFeatureEnabled(MarketizationOptions.Feature.VideoCopyright))
            {
                copyrightLinkLabel.Visible = false;
            }
            else
            {
                copyrightLinkLabel.Font = Res.GetFont(FontSize.Small, FontStyle.Regular);
                copyrightLinkLabel.Text = Res.Get(StringId.Plugin_Video_Copyright_Notice);
                string link = MarketizationOptions.GetFeatureParameter(MarketizationOptions.Feature.VideoCopyright, "Glink");
                if (link == null || link == String.Empty)
                {
                    copyrightLinkLabel.LinkArea = new LinkArea(0, 0);
                }
                else
                {
                    copyrightLinkLabel.LinkClicked += copyrightLinkLabel_LinkClicked;
                }
            }

            copyrightLinkLabel.LinkColor = SystemColors.HotTrack;

            //
            // tabs
            //
            tabs = new TabLightweightControl();
            tabs.VirtualBounds = new Rectangle(0, 5, 450, 485);
            tabs.LightweightControlContainerControl = mainTabControl;
            tabs.DrawSideAndBottomTabPageBorders    = false;
            tabs.ColorizeBorder = false;

            int i = 0;

            foreach (MediaTab mediaSource in _sources)
            {
                mediaSource.MediaSelected += videoSource_MediaSelected;
                TabPageControl tab = mediaSource;
                tab.TabStop = false;
                Controls.Add(tab);
                tabs.SetTab(i++, tab);
            }

            // initial appearance of editor

            if (!DesignMode)
            {
                Icon = ApplicationEnvironment.ProductIcon;
            }

            tabs.VirtualLocation = new Point(0, 5);
            tabs.VirtualSize     = Size;

            Width  = 510;
            Height = 570;

            foreach (MediaTab videoSource in _sources)
            {
                videoSource.Init(content, blogID);
            }

            SetActiveTab(selectedTab);
            tabs.SelectedTabNumber = selectedTab;

            tabs.SelectedTabNumberChanged += new EventHandler(tabs_SelectedTabNumberChanged);

            Closing += new CancelEventHandler(MediaInsertForm_Closing);
        }