private void listBoxPostSources_SelectedIndexChanged(object sender, EventArgs e)
        {
            IPostEditorPostSource postSource = listBoxPostSources.SelectedPostSource;

            if (postSource != null)
            {
                listBoxPostSources.Update();

                listBoxPosts.PostSource = null; // prevent reloading until we have set all values

                // update # of posts combo
                comboBoxPosts.Items.Clear();
                int indexOf50 = -1;
                RecentPostRequest[] requests = listBoxPostSources.SelectedPostSource.RecentPostCapabilities.ValidRequests;
                for (int i = 0; i < requests.Length; i++)
                {
                    comboBoxPosts.Items.Add(requests[i]);
                    if (requests[i].NumberOfPosts <= 50)
                    {
                        indexOf50 = i;
                    }
                }

                if (indexOf50 != -1)
                {
                    comboBoxPosts.SelectedIndex = indexOf50;
                }

                // update post list
                RestorePostListViewSettings();
                listBoxPosts.PostSource = listBoxPostSources.SelectedPostSource;

                ManageControls(true);
            }
        }
        private void RestorePostListViewSettings()
        {
            IPostEditorPostSource postSource = listBoxPostSources.SelectedPostSource as IPostEditorPostSource;

            using (SettingsPersisterHelper postSourceSettings = _recentPostsSettings.GetSubSettings(postSource.UniqueId))
            {
                // number of posts
                RecentPostRequest recentPostRequest = new RecentPostRequest(postSourceSettings.GetInt32(NUMBER_OF_POSTS, postSource.RecentPostCapabilities.DefaultRequest.NumberOfPosts));
                if (comboBoxPosts.Items.Contains(recentPostRequest))
                {
                    comboBoxPosts.SelectedItem = recentPostRequest;
                }

                // pages
                if (postSource.SupportsPages)
                {
                    radioButtonPages.Checked = postSourceSettings.GetBoolean(SHOW_PAGES, false);
                }
                else
                {
                    radioButtonPages.Checked = false;
                }
                radioButtonPosts.Checked = !radioButtonPages.Checked;
            }
        }
示例#3
0
 public GetRecentPostsAsyncOperation(IBlogClientUIContext uiContext, IPostEditorPostSource postSource, RecentPostRequest request, bool getPages)
     : base(uiContext)
 {
     _uiContext  = uiContext;
     _postSource = postSource;
     _request    = request;
     _getPages   = getPages;
 }
示例#4
0
        private void AddPostSource(IPostEditorPostSource postSource, int imageIndex)
        {
            ListViewItem item = new ListViewItem();

            item.Text       = postSource.Name;
            item.Tag        = postSource;
            item.ImageIndex = imageIndex;
            Items.Add(item);
        }
        private void ManageControls(bool fullManage)
        {
            SuspendLayout();

            // get post source
            IPostEditorPostSource selectedPostSource = listBoxPostSources.SelectedPostSource;

            // manage posts vs. pages
            if ((selectedPostSource) != null && selectedPostSource.SupportsPages)
            {
                labelPosts.Visible = false;
                panelType.Visible  = true;
                if (fullManage)
                {
                    panelType.Left = labelPosts.Left + ScaleX(5);
                }
            }
            else
            {
                labelPosts.Visible = true;
                panelType.Visible  = false;
            }

            // manage delete button
            bool allowDelete = _allowDelete && (selectedPostSource != null) && (selectedPostSource.SupportsDelete);

            buttonDelete.Visible = allowDelete;
            buttonDelete.Width   = buttonDelete.GetPreferredSize(new Size(Int32.MaxValue, buttonDelete.Height)).Width;
            buttonDelete.Left    = textBoxFilter.Right - buttonDelete.Width;

            listBoxPosts.AllowDelete = allowDelete;

            // control enabled state
            bool postSelected = listBoxPosts.SelectedIndex != -1;

            buttonDelete.Enabled = postSelected;
            buttonOK.Enabled     = postSelected;

            RearrangeControls();

            ResumeLayout();

            // force immediate re-rendering of controls
            PerformLayout();
            Update();
        }
 public PostSourceItem(string accName, IPostEditorPostSource source, BlogPostSourceListBox ownerControl)
 {
     _source = source;
     _accName = accName;
     _listbox = ownerControl;
 }
示例#7
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            // screen invalid drawing states
            if (DesignMode || e.Index == -1)
            {
                return;
            }

            // get post-source we are rendering
            IPostEditorPostSource postSource = (Items[e.Index] as PostSourceItem).PostSource;

            // determine image and text to use
            Image postSourceImage;

            if (e.Index == _draftsIndex)
            {
                postSourceImage = _showLargeIcons ? _draftsImageLarge : _draftsImage;
            }
            else if (e.Index == _recentPostsIndex)
            {
                postSourceImage = _showLargeIcons ? _recentPostsImageLarge : _recentPostsImage;
            }
            else
            {
                postSourceImage = _showLargeIcons ? _weblogImageLarge : _weblogImage;
            }


            // determine state
            bool selected = (e.State & DrawItemState.Selected) > 0;

            // calculate colors
            Color backColor, textColor;

            if (selected)
            {
                if (Focused)
                {
                    backColor = _theme.backColorSelectedFocused;
                    textColor = _theme.textColorSelectedFocused;
                }
                else
                {
                    backColor = _theme.backColorSelected;
                    textColor = _theme.textColorSelected;
                }
            }
            else
            {
                backColor = _theme.backColor;
                textColor = _theme.textColor;
            }

            BidiGraphics g = new BidiGraphics(e.Graphics, e.Bounds);

            // draw background
            using (SolidBrush solidBrush = new SolidBrush(backColor))
                g.FillRectangle(solidBrush, e.Bounds);

            if (_showLargeIcons)
            {
                // center the image within the list box
                int imageLeft = e.Bounds.Left + ((e.Bounds.Width / 2) - (ScaleX(postSourceImage.Width) / 2));
                int imageTop  = e.Bounds.Top + ScaleY(LARGE_TOP_INSET);
                g.DrawImage(false, postSourceImage, new Rectangle(imageLeft, imageTop, ScaleX(postSourceImage.Width), ScaleY(postSourceImage.Height)));

                // setup string format
                TextFormatFlags stringFormat = TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl | TextFormatFlags.ExpandTabs | TextFormatFlags.WordEllipsis | TextFormatFlags.HorizontalCenter;

                // calculate standard text drawing metrics
                int leftMargin = ScaleX(ELEMENT_PADDING);
                int topMargin  = imageTop + ScaleY(postSourceImage.Height) + ScaleY(ELEMENT_PADDING);
                int fontHeight = g.MeasureText(postSource.Name, e.Font).Height;

                // caption
                // calculate layout rectangle
                Rectangle layoutRectangle = new Rectangle(
                    leftMargin,
                    topMargin,
                    e.Bounds.Width - (2 * ScaleX(ELEMENT_PADDING)),
                    fontHeight * TITLE_LINES);

                // draw caption
                g.DrawText(postSource.Name, e.Font, layoutRectangle, textColor, stringFormat);
            }
            else
            {
                // draw post icon
                g.DrawImage(false, postSourceImage,
                            new Rectangle(e.Bounds.Left + ScaleX(ELEMENT_PADDING), e.Bounds.Top + ScaleY(SMALL_TOP_INSET),
                                          ScaleX(postSourceImage.Width), ScaleY(postSourceImage.Height)));

                // setup string format
                TextFormatFlags stringFormat = TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl | TextFormatFlags.ExpandTabs | TextFormatFlags.WordEllipsis;

                // calculate standard text drawing metrics
                int leftMargin = ScaleX(ELEMENT_PADDING) + ScaleX(postSourceImage.Width) + ScaleX(ELEMENT_PADDING);
                int topMargin  = e.Bounds.Top + ScaleY(SMALL_TOP_INSET);
                int fontHeight = g.MeasureText(postSource.Name, e.Font).Height;

                // caption
                // calculate layout rectangle
                Rectangle layoutRectangle = new Rectangle(
                    leftMargin,
                    topMargin,
                    e.Bounds.Width - leftMargin - ScaleX(ELEMENT_PADDING),
                    fontHeight * TITLE_LINES);

                // draw caption
                g.DrawText(postSource.Name, e.Font, layoutRectangle, textColor, stringFormat);
            }

            // draw focus rectange if necessary
            e.DrawFocusRectangle();
        }
示例#8
0
 public PostSourceItem(string accName, IPostEditorPostSource source, BlogPostSourceListBox ownerControl)
 {
     _source  = source;
     _accName = accName;
     _listbox = ownerControl;
 }
 public GetRecentPostsAsyncOperation(IBlogClientUIContext uiContext, IPostEditorPostSource postSource, RecentPostRequest request, bool getPages)
     : base(uiContext)
 {
     _uiContext = uiContext;
     _postSource = postSource;
     _request = request;
     _getPages = getPages;
 }
 private void AddPostSource( IPostEditorPostSource postSource, int imageIndex )
 {
     ListViewItem item = new ListViewItem();
     item.Text = postSource.Name ;
     item.Tag = postSource ;
     item.ImageIndex = imageIndex ;
     Items.Add(item) ;
 }