protected void sizeElements() { ScrollBarDirections barsToShow = 0x0; resizeScrollPanel(); System.Drawing.Size scrlSize = _scrolledPanel.Size; switch (_displayPolicy) { case ScrollBarDisplay.Always: barsToShow = _directionPolicy; break; case ScrollBarDisplay.Never: barsToShow = ScrollBarDirections.None; break; case ScrollBarDisplay.AsNeeded: barsToShow = barsNeeded(); break; } int intWidth = this.Size.Width; int intHeight = this.Size.Height; if ((ScrollBarDirections.Vertical & barsToShow) > 0) { intWidth -= VSCROLL_WIDTH; base.Controls.Add(_vertBar); } else if (((Control)this).Controls.Contains(_vertBar)) { base.Controls.Remove(_vertBar); } // determine settings for the scrollbar if ((ScrollBarDirections.Vertical & barsToShow) > 0) { _vertBar.Minimum = 0; _vertBar.Maximum = scrlSize.Height; _vertBar.LargeChange = intHeight; _vertBar.SmallChange = scrlSize.Height / 20; _vertBar.Location = new System.Drawing.Point(intWidth, 0); _vertBar.Size = new System.Drawing.Size(VSCROLL_WIDTH, intHeight); } System.Drawing.Size newInternalSize = new System.Drawing.Size(intWidth, _scrolledPanel.Size.Height); bool bcmp = !newInternalSize.Equals(_scrolledPanel.Size); _scrolledPanel.Size = newInternalSize; if (bcmp && this.ClientResized != null) { ClientResized(this, new EventArgs()); } }
private void UpdateFormPositionOnUIThread() { try { var posX = _configManager.GetProperty <long>("behaviour.frame.chat.position.x"); var posY = _configManager.GetProperty <long>("behaviour.frame.chat.position.y"); var width = _configManager.GetProperty <long>("behaviour.frame.chat.size.width"); var height = _configManager.GetProperty <long>("behaviour.frame.chat.size.height"); var location = new System.Drawing.Point((int)posX, (int)posY); var size = new System.Drawing.Size((int)width, (int)height); if (!IsFrameOnScreens(new System.Drawing.Rectangle(location, size))) { // location and size invalid, fallback to default location logger.Info("Overlay off screen, reseting position and size"); ResetFrameToDefaultLocation(); return; } if (!location.Equals(_overlay.Location)) { _overlay.Location = location; } if (!size.Equals(_overlay.Size)) { _overlay.Size = size; } } catch (Exception ex) { logger.Warn(ex); } }
public void TestDeckSize() { PlayedDeck deck = new PlayedDeck("AAECAf0ECvsMoM4Cws4Cm9MCnOICo+sCpvACt/ECw/gCxvgCCk3JA+wHm8IC08UClscCm8sC1+ECluQC4vgCAA=="); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(1, 1); System.Drawing.Graphics tempGr = System.Drawing.Graphics.FromImage(bmp); System.Drawing.Size drawSize = deck.DrawToGraphics(tempGr); Assert.IsTrue(drawSize.Equals(deck.GetSize())); }
private void CompletionWindowOnSizeChanged(object sender, SizeChangedEventArgs args) { var oldSize = new System.Drawing.Size((int)args.PreviousSize.Width, (int)args.PreviousSize.Height); var newSize = new System.Drawing.Size((int)args.NewSize.Width, (int)args.NewSize.Height); Logger.DebugFormat("CompletionWindow.SizeChanged({0} => {1})", oldSize, newSize); if (oldSize.Equals(newSize)) { Logger.DebugFormat(" ignoring - size hasn't changed"); _ignoreSizeChange = false; return; } if (_ignoreSizeChange) { Logger.DebugFormat(" ignoring - flag set"); _ignoreSizeChange = false; // Now that we've set the final width and height of the window, we can auto-select the first completion item. // If we always auto-selected the first completion item every time a resize event occurred, the tooltip // would be incorrectly positioned because Avalon doesn't reposition it when the window size changes. SelectFirstItem(); _completionWindow.SetTimeout(window => RePositionToolTip(), 10); return; } _ignoreSizeChange = true; _maxHeight = (int)_completionWindow.MaxHeight; _sizeToContent = _completionWindow.SizeToContent; _completionWindow.MaxWidth = double.PositiveInfinity; _completionWindow.MaxHeight = double.PositiveInfinity; _completionWindow.SizeToContent = SizeToContent.WidthAndHeight; var fullWidth = _completionWindow.Width; var fullHeight = _completionWindow.Height; Logger.DebugFormat(" full size = {0}, {1}", fullWidth, fullHeight); _completionWindow.MaxHeight = _maxHeight; _completionWindow.SizeToContent = _sizeToContent; if (HasCompletions) { var newWidth = fullWidth; if (fullHeight > _maxHeight) { newWidth += SystemParameters.VerticalScrollBarWidth + RightPadding; } _completionWindow.Width = newWidth; RePositionToolTip(); } else { _completionWindow.Width = oldSize.Width; HideToolTip(); } }