public void SelectDocumentWorkspace(DocumentWorkspace selectMe) { UI.SuspendControlPainting(this); this.selectedDocument = selectMe; if (this.thumbs.ContainsKey(selectMe)) { RenderArgs thumb = this.thumbs[selectMe]; Bitmap bitmap = thumb.Bitmap; } else { QueueThumbnailUpdate(selectMe); } foreach (ImageStrip.Item docItem in this.documentButtons) { if ((docItem.Tag as DocumentWorkspace) == selectMe) { EnsureItemFullyVisible(docItem); docItem.Checked = true; } else { docItem.Checked = false; } } UI.ResumeControlPainting(this); Invalidate(true); }
/// <summary> /// This method is called many times per second, called by the DocumentWorkspace. /// </summary> protected virtual void OnPulse() { if (this.panTracking && this.lastButton == MouseButtons.Right) { Point position = this.lastMouseXY; RectangleF visibleRect = DocumentWorkspace.VisibleDocumentRectangleF; PointF visibleCenterPt = Utility.GetRectangleCenter(visibleRect); PointF delta = new PointF(position.X - visibleCenterPt.X, position.Y - visibleCenterPt.Y); PointF newScroll = DocumentWorkspace.DocumentScrollPositionF; this.trackingNub.Visible = true; if (delta.X != 0 || delta.Y != 0) { newScroll.X += delta.X; newScroll.Y += delta.Y; ++this.ignoreMouseMove; // setting DocumentScrollPosition incurs a MouseMove event. ignore it prevents 'jittering' at non-integral zoom levels (like, say, 743%) UI.SuspendControlPainting(DocumentWorkspace); DocumentWorkspace.DocumentScrollPositionF = newScroll; this.trackingNub.Visible = true; this.trackingNub.Location = Utility.GetRectangleCenter(DocumentWorkspace.VisibleDocumentRectangleF); UI.ResumeControlPainting(DocumentWorkspace); DocumentWorkspace.Invalidate(true); Update(); } } }
public void ClearItems() { SuspendLayout(); UI.SuspendControlPainting(this); while (this.items.Count > 0) { RemoveItem(this.items[this.items.Count - 1]); } UI.ResumeControlPainting(this); ResumeLayout(true); Invalidate(); }
private void MouseStatesToItemStates() { UI.SuspendControlPainting(this); for (int i = 0; i < this.items.Count; ++i) { this.items[i].CheckRenderState = UI.ButtonState.Normal; this.items[i].CloseRenderState = UI.ButtonState.Normal; this.items[i].ImageRenderState = UI.ButtonState.Normal; this.items[i].Selected = false; } if (this.mouseDownApplyRendering) { if (this.mouseDownIndex < 0 || this.mouseDownIndex >= this.items.Count) { this.mouseDownApplyRendering = false; } else { this.items[this.mouseDownIndex].SetPartRenderState(this.mouseDownItemPart, UI.ButtonState.Pressed); this.items[this.mouseDownIndex].Selected = true; } } else if (this.mouseOverApplyRendering) { if (this.mouseOverIndex < 0 || this.mouseOverIndex >= this.items.Count) { this.mouseOverApplyRendering = false; } else { this.items[this.mouseOverIndex].SetPartRenderState(this.mouseOverItemPart, UI.ButtonState.Hot); this.items[this.mouseOverIndex].Selected = true; } } UI.ResumeControlPainting(this); Invalidate(); }
protected override void OnLayout(LayoutEventArgs e) { bool plentyWidthBefore = (this.MainMenu.Width >= this.MainMenu.PreferredSize.Width) && (this.CommonActionsStrip.Width >= this.CommonActionsStrip.PreferredSize.Width) && (this.ViewConfigStrip.Width >= this.ViewConfigStrip.PreferredSize.Width) && (this.ToolChooserStrip.Width >= this.ToolChooserStrip.PreferredSize.Width) && (this.ToolConfigStrip.Width >= this.ToolConfigStrip.PreferredSize.Width); if (!plentyWidthBefore) { UI.SuspendControlPainting(this); } else { // if we don't do this then we get some terrible flickering of the right scroll arrow UI.SuspendControlPainting(this.documentStrip); } this.MainMenu.Location = new Point(0, 0); this.MainMenu.Height = this.MainMenu.PreferredSize.Height; this.ToolStripContainer.Location = new Point(0, this.MainMenu.Bottom); this.ToolStripContainer.RowMargin = new Padding(0); this.MainMenu.Padding = new Padding(0, this.MainMenu.Padding.Top, 0, this.MainMenu.Padding.Bottom); this.CommonActionsStrip.Width = this.CommonActionsStrip.PreferredSize.Width; this.ViewConfigStrip.Width = this.ViewConfigStrip.PreferredSize.Width; this.ToolChooserStrip.Width = this.ToolChooserStrip.PreferredSize.Width; this.ToolConfigStrip.Width = this.ToolConfigStrip.PreferredSize.Width; if (!this.computedMaxRowHeight) { ToolBarConfigItems oldTbci = this.ToolConfigStrip.ToolBarConfigItems; this.ToolConfigStrip.ToolBarConfigItems = ToolBarConfigItems.All; this.ToolConfigStrip.PerformLayout(); this.maxRowHeight = Math.Max(this.CommonActionsStrip.PreferredSize.Height, Math.Max(this.ViewConfigStrip.PreferredSize.Height, Math.Max(this.ToolChooserStrip.PreferredSize.Height, this.ToolConfigStrip.PreferredSize.Height))); this.ToolConfigStrip.ToolBarConfigItems = oldTbci; this.ToolConfigStrip.PerformLayout(); this.computedMaxRowHeight = true; } this.CommonActionsStrip.Height = this.maxRowHeight; this.ViewConfigStrip.Height = this.maxRowHeight; this.ToolChooserStrip.Height = this.maxRowHeight; this.ToolConfigStrip.Height = this.maxRowHeight; this.CommonActionsStrip.Location = new Point(0, 0); this.ViewConfigStrip.Location = new Point(this.CommonActionsStrip.Right, this.CommonActionsStrip.Top); this.ToolChooserStrip.Location = new Point(0, this.ViewConfigStrip.Bottom); this.ToolConfigStrip.Location = new Point(this.ToolChooserStrip.Right, this.ToolChooserStrip.Top); this.ToolStripContainer.Height = Math.Max(this.CommonActionsStrip.Bottom, Math.Max(this.ViewConfigStrip.Bottom, Math.Max(this.ToolChooserStrip.Bottom, this.ToolConfigStrip.Visible ? this.ToolConfigStrip.Bottom : this.ToolChooserStrip.Bottom))); // Compute how wide the toolStripContainer would like to be int widthRow1 = this.CommonActionsStrip.Left + this.CommonActionsStrip.PreferredSize.Width + this.CommonActionsStrip.Margin.Horizontal + this.ViewConfigStrip.PreferredSize.Width + this.ViewConfigStrip.Margin.Horizontal; int widthRow2 = this.ToolChooserStrip.Left + this.ToolChooserStrip.PreferredSize.Width + this.ToolChooserStrip.Margin.Horizontal + this.ToolConfigStrip.PreferredSize.Width + this.ToolConfigStrip.Margin.Horizontal; int preferredMinTscWidth = Math.Max(widthRow1, widthRow2); // Throw in the documentListButton if necessary bool showDlb = this.documentStrip.DocumentCount > 0; this.documentListButton.Visible = showDlb; this.documentListButton.Enabled = showDlb; if (showDlb) { int documentListButtonWidth = UI.ScaleWidth(15); this.documentListButton.Width = documentListButtonWidth; } else { this.documentListButton.Width = 0; } // Figure out the DocumentStrip's size -- we actually make two passes at setting its Width // so that we can toss in the documentListButton if necessary if (this.documentStrip.DocumentCount == 0) { this.documentStrip.Width = 0; } else { this.documentStrip.Width = Math.Max( this.documentStrip.PreferredMinClientWidth, Math.Min(this.documentStrip.PreferredSize.Width, ClientSize.Width - preferredMinTscWidth - this.documentListButton.Width)); } this.documentStrip.Location = new Point(ClientSize.Width - this.documentStrip.Width, 0); this.documentListButton.Location = new Point(this.documentStrip.Left - this.documentListButton.Width, 0); this.imageListMenu.Location = new Point(this.documentListButton.Left, this.documentListButton.Bottom - 1); this.imageListMenu.Width = this.documentListButton.Width; this.imageListMenu.Height = 0; this.documentListButton.Visible = showDlb; this.documentListButton.Enabled = showDlb; // Finish setting up widths and heights int oldDsHeight = this.documentStrip.Height; this.documentStrip.Height = this.ToolStripContainer.Bottom; this.documentListButton.Height = this.documentStrip.Height; int tsWidth = ClientSize.Width - (this.documentStrip.Width + this.documentListButton.Width); this.MainMenu.Width = tsWidth; this.ToolStripContainer.Width = tsWidth; this.Height = this.ToolStripContainer.Bottom; // Now get stuff to paint right this.documentStrip.PerformLayout(); if (!plentyWidthBefore) { UI.ResumeControlPainting(this); Invalidate(true); } else { UI.ResumeControlPainting(this.documentStrip); this.documentStrip.Invalidate(true); } if (this.documentStrip.Width == 0) { this.MainMenu.Invalidate(); } if (oldDsHeight != this.documentStrip.Height) { this.documentStrip.RefreshAllThumbnails(); } base.OnLayout(e); }