Creates a human-readable string that represents this .
internal override Size GetPreferredSize(IArrangedElement container, Size proposedConstraints) { #if DEBUG if (CompModSwitches.FlowLayout.TraceInfo) { Debug.WriteLine("FlowLayout::GetPreferredSize(" + "container=" + container.ToString() + ", " + "proposedConstraints=" + proposedConstraints.ToString() + ")"); Debug.Indent(); } #endif Rectangle measureBounds = new Rectangle(new Point(0, 0), proposedConstraints); Size prefSize = xLayout(container, measureBounds, /* measureOnly = */ true); if(prefSize.Width > proposedConstraints.Width || prefSize.Height> proposedConstraints.Height) { // Controls measured earlier than a control which couldn't be fit to constraints may // shift around with the new bounds. We need to make a 2nd pass through the // controls using these bounds which are gauranteed to fit. measureBounds.Size = prefSize; prefSize = xLayout(container, measureBounds, /* measureOnly = */ true); } #if DEBUG if (CompModSwitches.FlowLayout.TraceInfo) { Debug.Unindent(); Debug.WriteLine("GetPreferredSize returned " + prefSize); } #endif return prefSize; }
private void OnDisplaySettingsChanged(object sender, EventArgs e) { System.Drawing.Size screenSize = Screen.FromRectangle(new Rectangle(_parent.Location, _parent.Size)).Bounds.Size; Debug.WriteLine("DisplaySettingsChanged: " + screenSize.ToString()); if (_stateByResolution.ContainsKey(screenSize)) { Debug.WriteLine("Back in familiar territory."); _thisState = (WindowSizeLocation)_stateByResolution[screenSize]; } else { Debug.WriteLine("This is a new frontier."); WindowSizeLocation newState = new WindowSizeLocation(_parent.Size, _parent.Location, screenSize); if (_parent.WindowState != FormWindowState.Normal) { newState.Location = _thisState.Location; newState.Size = _thisState.Size; } _thisState = newState; _stateByResolution[_thisState.ScreenSize] = _thisState; } //If the form is offscreen, move it back on. Rectangle windowRect = new Rectangle(_thisState.Location, _thisState.Size); Rectangle workingArea = Screen.FromRectangle(windowRect).WorkingArea; if (!workingArea.IntersectsWith(windowRect)) { Point newLoc = new Point(_thisState.Location.X, _thisState.Location.Y); if (_thisState.Location.X < workingArea.X) { newLoc.X = workingArea.X; } else if (_thisState.Location.X > workingArea.Right) { newLoc.X = workingArea.Right - _thisState.Size.Width; } if (_thisState.Location.Y < workingArea.Y) { newLoc.Y = workingArea.Y; } else if (_thisState.Location.Y > workingArea.Bottom) { newLoc.Y = workingArea.Bottom - _thisState.Size.Height; } _thisState.Location = newLoc; } SetWindowState(); }
public void Run() { String[] Input; Console.WriteLine("Please specify the size of the Mars Plateu:"); Console.WriteLine("The first number is the width, and the second number is the height."); Input = Console.ReadLine().Split(' '); Size plateu = new Size(Convert.ToInt32(Input[0]), Convert.ToInt32(Input[1])); Console.WriteLine("Initializing Plateau with size: {0}.", plateu.ToString()); Bus.Send<RequestSurfaceMessage>(m => { m.MessageID = Guid.NewGuid(); m.Width = plateu.Width; m.Height = plateu.Height; }); while (true) { Console.WriteLine(""); Console.WriteLine("Please specify the starting position and direction of the rover:"); Console.WriteLine("The first number is the horizontal coordinate, the second number is the vertical coordinate"); Console.WriteLine("The third value is a single character representing a Cardinal Point (N, S, E, or W)"); Console.WriteLine("Please enter a blank line to indicate you have no more rovers to enter."); Input = Console.ReadLine().Split(' '); try { Point roverStartingPosition = new Point(Convert.ToInt32(Input[0]), Convert.ToInt32(Input[1])); String roverDirection = Input[2].ToUpper(); Console.WriteLine("Please provide a string of directions for the rover to follow. No spaces are requred."); Console.WriteLine("{ L = Turn Left; R = Turn Right; M = Move 1 unit forward }"); String roverCommands = Console.ReadLine().Replace(" ", "").ToUpper(); Console.WriteLine("Sending message to rover..."); Bus.Send<RequestRoverMessage>(m => { m.MessageID = Guid.NewGuid(); m.StartingPositionX = roverStartingPosition.X; m.StartingPositionY = roverStartingPosition.Y; m.StartingDirection = roverDirection; m.Commands = roverCommands; }); } catch { break; } } }
public Bitmap GetImage(Size size) { try { IEnumerable<XElement> images = artistElement.Elements().Where(e => e.Name.LocalName == "image"); string imageUrl = (from xElement in images where xElement.Attributes().Where(a => a.Name.LocalName == "size").First().Value == size.ToString().ToLower() select xElement.Value).FirstOrDefault(); WebRequest request = WebRequest.Create(imageUrl); Stream responseStream = request.GetResponse().GetResponseStream(); return new Bitmap(responseStream); } catch (Exception) { //TODO: write to logger return null; } }
internal static void Save() { XmlTextWriter XMLobj; try { if (!System.IO.Directory.Exists(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\Cryptotext Editor")) { System.IO.Directory.CreateDirectory(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\Cryptotext Editor"); } XMLobj = new XmlTextWriter(settingsPath, System.Text.Encoding.UTF8); } catch (UnauthorizedAccessException) { return; } XMLobj.Formatting = Formatting.Indented; XMLobj.WriteStartDocument(); XMLobj.WriteStartElement("Settings"); XMLobj.WriteAttributeString("program", "Cryptotext Editor"); XMLobj.WriteStartElement("EditorSize"); XMLobj.WriteAttributeString("Width", EditorSize.Width.ToString()); XMLobj.WriteAttributeString("Height", EditorSize.Height.ToString()); XMLobj.WriteValue(EditorSize.ToString()); XMLobj.WriteEndElement(); XMLobj.WriteStartElement("CurrentFilePath"); XMLobj.WriteValue(CurrentFilePath); XMLobj.WriteEndElement(); XMLobj.WriteStartElement("CurrentFileSaved"); XMLobj.WriteValue(CurrentFileSaved.ToString()); XMLobj.WriteEndElement(); XMLobj.WriteStartElement("WordWrap"); XMLobj.WriteValue(WordWrap.ToString()); XMLobj.WriteEndElement(); XMLobj.WriteStartElement("DetectUrls"); XMLobj.WriteValue(DetectUrls.ToString()); XMLobj.WriteEndElement(); XMLobj.WriteStartElement("AutoSave"); XMLobj.WriteValue(AutoSave.ToString()); XMLobj.WriteEndElement(); XMLobj.WriteStartElement("LastOpenedFile"); XMLobj.WriteValue(LastOpenedFile); XMLobj.WriteEndElement(); XMLobj.WriteStartElement("editorLocation"); XMLobj.WriteAttributeString("x", editorLocation.X.ToString()); XMLobj.WriteAttributeString("y", editorLocation.Y.ToString()); XMLobj.WriteValue(editorLocation.ToString()); XMLobj.WriteEndElement(); XMLobj.WriteStartElement("editorLangPath"); XMLobj.WriteValue(editorLangPath); XMLobj.WriteEndElement(); XMLobj.WriteStartElement("editorToolBox"); XMLobj.WriteValue(editorToolBox.ToString()); XMLobj.WriteEndElement(); XMLobj.WriteEndElement(); XMLobj.WriteEndDocument(); XMLobj.Close(); }
/// <summary> /// Form load event handler. Populate the list view /// </summary> /// <param name="sender">event sender</param> /// <param name="e">event args</param> private void Form1_Load(object sender, EventArgs e) { float currentAspectRatio = (float)ClientSize.Height / ClientSize.Width; Log.Debug("HIHIHI AspectRatio: " + currentAspectRatio + ", design: " + _designTimeAspectRatio); if (_designTimeAspectRatio != 0.0f && currentAspectRatio != _designTimeAspectRatio) { ClientSize = new System.Drawing.Size(ClientSize.Width, (int)(_designTimeAspectRatio * ClientSize.Width)); Log.Debug("HIHIHI New clientsize: " + ClientSize.ToString()); } Log.Debug("HIHIHI currentsize: " + Size.ToString()); CenterToScreen(); TopMost = false; TopMost = true; var appList = Program.Settings.Applications; checkBoxHideWhenMinimized.Checked = Program.Settings.HideWhenMinimzied; Debug.WriteLine("applist.Count: " + appList.Length); var files = new List <FileInfo>(); var appsIncluded = new List <AppInfo>(); foreach (var appInfo in appList) { try { Debug.WriteLine("appInfo.Path: " + appInfo.Path); var fullPath = Path.GetFullPath(appInfo.Path); Debug.WriteLine("fullPath: " + fullPath); var bitmap = getIconAsBitmap(fullPath); if (bitmap != null) { var b = ResizeImage(bitmap, _iconSize, _iconSize); imageList1.Images.Add(b); files.Add(new FileInfo(fullPath)); appsIncluded.Add(appInfo); } else { Debug.WriteLine("Icon is null"); } } catch (Exception ex) { Debug.Write(ex.ToString()); } } listView1.View = View.LargeIcon; imageList1.ImageSize = new Size(_iconSize, _iconSize); listView1.LargeImageList = imageList1; for (var imageIndex = 0; imageIndex < imageList1.Images.Count; imageIndex++) { var item = new ListViewItem { ImageIndex = imageIndex, Text = !String.IsNullOrEmpty(appsIncluded[imageIndex].Name) ? appsIncluded[imageIndex].Name : Path.GetFileNameWithoutExtension((files[imageIndex].Name)), //Font = new Font("Arial", 14, FontStyle.Regular), Tag = new object[] { files[imageIndex], appsIncluded[imageIndex] } }; item.ToolTipText = item.Text; listView1.Items.Add(item); } listView1.ShowItemToolTips = true; listView1.MultiSelect = false; arrangeIconsAndSetWindowSize(); listView1.Activation = ItemActivation.OneClick; CenterToScreen(); }
/// <devdoc> /// Called by the dataGrid when it needs the caption /// to repaint. /// </devdoc> internal void Paint(Graphics g, Rectangle bounds, bool alignRight) { Size textSize = new Size((int) g.MeasureString(text, this.Font).Width + 2, this.Font.Height + 2); downButtonRect = GetDetailsButtonRect(bounds, alignRight); int downButtonWidth = GetDetailsButtonWidth(); backButtonRect = GetBackButtonRect(bounds, alignRight, downButtonWidth); int backButtonArea = backButtonVisible ? backButtonRect.Width + xOffset + buttonToText : 0; int downButtonArea = downButtonVisible && !dataGrid.ParentRowsIsEmpty() ? downButtonWidth + xOffset + buttonToText : 0; int textWidthLeft = bounds.Width - xOffset - backButtonArea - downButtonArea; textRect = new Rectangle( bounds.X, bounds.Y + yOffset, Math.Min(textWidthLeft, 2 * textPadding + textSize.Width), 2 * textPadding + textSize.Height); // align the caption text box, downButton, and backButton // if the RigthToLeft property is set to true if (alignRight) { textRect.X = bounds.Right - textRect.Width; backButtonRect.X = bounds.X + xOffset * 4 + downButtonWidth; downButtonRect.X = bounds.X + xOffset * 2; } Debug.WriteLineIf(CompModSwitches.DGCaptionPaint.TraceVerbose, "text size = " + textSize.ToString()); Debug.WriteLineIf(CompModSwitches.DGCaptionPaint.TraceVerbose, "downButtonWidth = " + downButtonWidth.ToString(CultureInfo.InvariantCulture)); Debug.WriteLineIf(CompModSwitches.DGCaptionPaint.TraceVerbose, "textWidthLeft = " + textWidthLeft.ToString(CultureInfo.InvariantCulture)); Debug.WriteLineIf(CompModSwitches.DGCaptionPaint.TraceVerbose, "backButtonRect " + backButtonRect.ToString()); Debug.WriteLineIf(CompModSwitches.DGCaptionPaint.TraceVerbose, "textRect " + textRect.ToString()); Debug.WriteLineIf(CompModSwitches.DGCaptionPaint.TraceVerbose, "downButtonRect " + downButtonRect.ToString()); // we should use the code that is commented out // with today's code, there are pixels on the backButtonRect and the downButtonRect // that are getting painted twice // g.FillRectangle(backBrush, bounds); if (backButtonVisible) { PaintBackButton(g, backButtonRect, alignRight); if (backActive) { if (lastMouseLocation == CaptionLocation.BackButton) { backButtonRect.Inflate(1,1); ControlPaint.DrawBorder3D(g, backButtonRect, backPressed ? Border3DStyle.SunkenInner : Border3DStyle.RaisedInner); } } } PaintText(g, textRect, alignRight); if (downButtonVisible && !dataGrid.ParentRowsIsEmpty()) { PaintDownButton(g, downButtonRect); // the rules have changed, yet again. // now: if we show the parent rows and the mouse is // not on top of this icon, then let the icon be depressed. // if the mouse is pressed over the icon, then show the icon pressed // if the mouse is over the icon and not pressed, then show the icon SunkenInner; // if (lastMouseLocation == CaptionLocation.DownButton) { downButtonRect.Inflate(1,1); ControlPaint.DrawBorder3D(g, downButtonRect, downPressed ? Border3DStyle.SunkenInner : Border3DStyle.RaisedInner); } } }
// Idea from Gabest (http://www.gabest.org) and modify by me public virtual void VideoResizer(VideoSizeMode videoZoomMode, bool keepAspectRatio, PointF offset, double zoom, double aspectRatioFactor) { Trace.WriteLineIf(trace.TraceInfo, "VideoResizer(...)"); int hr = 0; Rectangle windowRect = this.hostingControl.ClientRectangle; currentVideoTargetRectangle = windowRect; currentVideoSourceSize = new Size(); FilterState filterState = GetGraphState(); if (filterState == FilterState.Paused || filterState == FilterState.Running) { if (videoZoomMode != VideoSizeMode.StretchToWindow) { int arX, arY; int arX2 = 0, arY2 = 0; if (useEVR) { Size videoSize = new Size(), arVideoSize = new Size(); hr = evrVideoDisplayControl.GetNativeVideoSize(out videoSize, out arVideoSize); //IMFVideoDisplayControlEx evrVideoDisplayControlPlus = evrVideoDisplayControl as IMFVideoDisplayControlEx; //hr = evrVideoDisplayControlPlus.GetNativeVideoSize(out videoSize, out arVideoSize); //hr = evrVideoDisplayControlPlus.GetIdealVideoSize(videoSize, arVideoSize); arX = videoSize.Width; arY = videoSize.Height; arX2 = arVideoSize.Width; arY2 = arVideoSize.Height; Trace.WriteLineIf(trace.TraceVerbose, string.Format(("\tvideoRenderer.GetNativeVideoSize({0}, {1})"), videoSize.ToString(), arVideoSize.ToString())); } else hr = (this.videoRenderer as IVMRWindowlessControl9).GetNativeVideoSize(out arX, out arY, out arX2, out arY2); if (hr >= 0 && arY > 0) { //DsError.ThrowExceptionForHR(hr); //Trace.WriteLineIf(trace.TraceVerbose, string.Format("\tGetNativeVideoSize(width: {0}, height: {1}, arX {2}, arY: {3}", arX, arY, arX2, arY2)); if (arX2 > 0 && arY2 > 0) { arX = arX2; arY = arY2; } currentVideoSourceSize.Width = arX; currentVideoSourceSize.Height = arY; Size windowSize = windowRect.Size; double newAspectRation = aspectRatioFactor * (double)arX / (double)arY * (this.useVideo169Mode ? 3.0 / 4.0 : 1.0); int height = windowSize.Height; int width = (int)((double)height * newAspectRation); if (videoZoomMode == VideoSizeMode.FromInside || videoZoomMode == VideoSizeMode.FromOutside) { if (videoZoomMode == VideoSizeMode.FromInside && width > windowSize.Width || videoZoomMode == VideoSizeMode.FromOutside && width < windowSize.Width) { width = windowSize.Width; height = (int)((double)width / newAspectRation); } } Size size = new Size((int)(zoom * width), (int)(zoom * height)); Point pos = new Point( (int)(offset.X * (windowRect.Width * 3 - size.Width) - windowRect.Width), (int)(offset.Y * (windowRect.Height * 3 - size.Height) - windowRect.Height)); //Point pos = new Point( // (int)(offset.X * (windowRect.Width - size.Width)), // (int)(offset.Y * (windowRect.Height - size.Height))); currentVideoTargetRectangle = new Rectangle(pos, size); } } if (useEVR) { //hr = evrVideoDisplayControl.SetVideoWindow(this.hostingControl.Handle); MFVideoNormalizedRect pnrcSource = new MFVideoNormalizedRect(0.0f, 0.0f, 1.0f, 1.0f); hr = this.evrVideoDisplayControl.SetVideoPosition(pnrcSource, (MediaFoundation.Misc.MFRect)currentVideoTargetRectangle); this.hostingControl.ModifyBlackBands(GetBlackBands(), Settings.VideoBackgroundColor); } else hr = (this.videoRenderer as IVMRWindowlessControl9).SetVideoPosition(null, DsRect.FromRectangle(currentVideoTargetRectangle)); //Trace.WriteLineIf(trace.TraceVerbose, string.Format(("\tPos {0:F2} {1:F2}, Zoom {2:F2}, ARF {4:F2}, AR {4:F2}"), offset.X, offset.Y, zoom, aspectRatioFactor, (float)videoTargetRect.Width / videoTargetRect.Height)); Trace.WriteLineIf(trace.TraceVerbose, string.Format(("\tvideoRenderer.SetVideoPosition({0})"), currentVideoTargetRectangle.ToString())); } }
private void ComputeCrop(Size videoSize) { Size mySize = ClientSize; Debug.WriteLine("Video Sizes = " + videoSize.ToString() + ", " + mySize.ToString()); Debug.WriteLine("Crop = " + cropLeft.ToString() + ", " + cropTop.ToString() + ", " + cropRight.ToString() + ", " + cropBottom.ToString()); this.topBlocker.Visible = false; this.bottomBlocker.Visible = false; this.leftBlocker.Visible = false; this.rightBlocker.Visible = false; double myAspect = Convert.ToDouble(mySize.Width) / Convert.ToDouble(mySize.Height); if ((this.cropTop == 0) && (this.cropBottom == 0) && (this.cropLeft == 0) && (this.cropRight == 0)) { double vlcAspect = Convert.ToDouble(videoSize.Width) / Convert.ToDouble(videoSize.Height); if (vlcAspect > myAspect) { // gray borders on the top and bottom int perfectHeight = Convert.ToInt32(mySize.Width / vlcAspect); this.innerVlc.Bounds = new Rectangle(new Point(0, (mySize.Height - perfectHeight) / 2), new Size(mySize.Width, perfectHeight)); //Debug.WriteLine("vlcAspect > myAspect " + this.innerVlc.Bounds.ToString()); } else { // gray borders on the left and right int perfectWidth = Convert.ToInt32(mySize.Height * vlcAspect); this.innerVlc.Bounds = new Rectangle(new Point((mySize.Width - perfectWidth) / 2, 0), new Size(perfectWidth, mySize.Height)); //Debug.WriteLine("vlcAspect < myAspect " + this.innerVlc.Bounds.ToString()); } } else { double realVlcAspect = Convert.ToDouble(videoSize.Width - this.cropRight - this.cropLeft) / Convert.ToDouble(videoSize.Height - this.cropTop - this.cropBottom); if (realVlcAspect > myAspect) { // gray borders on the top and bottom, and possible blocking panels // first, position and size the innerVlc as if there was no top or bottom cropping int videoPixelWidth = videoSize.Width - this.cropRight - this.cropLeft; double fakeVlcAspect = Convert.ToDouble(videoPixelWidth) / Convert.ToDouble(videoSize.Height); int perfectHeight = Convert.ToInt32(mySize.Width / fakeVlcAspect); Debug.WriteLine("perfectHeight = " + perfectHeight.ToString()); double scalingFactor = Convert.ToDouble(mySize.Width) / Convert.ToDouble(videoPixelWidth); int innerVlcLeft = -Convert.ToInt32(Convert.ToDouble(this.cropLeft) * scalingFactor); int innerVlcWidth = Convert.ToInt32(Convert.ToDouble(videoSize.Width) * scalingFactor); int offTheTop = Convert.ToInt32(Convert.ToDouble(this.cropTop) * scalingFactor); int offTheBottom = Convert.ToInt32(Convert.ToDouble(this.cropBottom) * scalingFactor); int innerVlcTop = (mySize.Height - (perfectHeight - offTheTop - offTheBottom)) / 2; innerVlcTop -= offTheTop; this.innerVlc.Bounds = new Rectangle(new Point(innerVlcLeft, innerVlcTop), new Size(innerVlcWidth, perfectHeight)); Debug.WriteLine("toowide innerVlc.Bounds = " + this.innerVlc.Bounds.ToString()); // then, add blocking panels if necessary for the top and bottom cropping if (this.cropTop != 0) { if (offTheTop + innerVlcTop > 0) { this.topBlocker.Bounds = new Rectangle( new Point(0, innerVlcTop), new Size(mySize.Width, offTheTop)); this.topBlocker.Visible = true; Debug.WriteLine("topBlocker.Bounds = " + this.topBlocker.Bounds.ToString()); } } if (this.cropBottom != 0) { if (innerVlcTop + perfectHeight - offTheBottom < mySize.Height) { this.bottomBlocker.Bounds = new Rectangle( new Point(0, innerVlcTop + perfectHeight - offTheBottom), new Size(mySize.Width, offTheBottom)); this.bottomBlocker.Visible = true; Debug.WriteLine("bottomBlocker.Bounds = " + this.bottomBlocker.Bounds.ToString()); } } } else { // gray borders on the left and right, and possible blocking panels // first, position and size the innerVlc as if there was no left or right cropping int videoPixelHeight = videoSize.Height - this.cropBottom - this.cropTop; double fakeVlcAspect = Convert.ToDouble(videoSize.Width) / Convert.ToDouble(videoPixelHeight); int perfectWidth = Convert.ToInt32(mySize.Height * fakeVlcAspect); Debug.WriteLine("perfectWidth = " + perfectWidth.ToString()); double scalingFactor = Convert.ToDouble(mySize.Height) / Convert.ToDouble(videoPixelHeight); int innerVlcTop = -Convert.ToInt32(Convert.ToDouble(this.cropTop) * scalingFactor); int innerVlcHeight = Convert.ToInt32(Convert.ToDouble(videoSize.Height) * scalingFactor); int offTheLeft = Convert.ToInt32(Convert.ToDouble(this.cropLeft) * scalingFactor); int offTheRight = Convert.ToInt32(Convert.ToDouble(this.cropRight) * scalingFactor); int innerVlcLeft = (mySize.Width - (perfectWidth - offTheLeft - offTheRight)) / 2; innerVlcLeft -= offTheLeft; this.innerVlc.Bounds = new Rectangle(new Point(innerVlcLeft, innerVlcTop), new Size(perfectWidth, innerVlcHeight)); Debug.WriteLine("toohigh innerVlc.Bounds = " + this.innerVlc.Bounds.ToString()); // then, add blocking panels if necessary for the left and right cropping if (this.cropLeft != 0) { if (offTheLeft + innerVlcLeft > 0) { this.leftBlocker.Bounds = new Rectangle( new Point(innerVlcLeft, 0), new Size(offTheLeft, mySize.Height)); this.leftBlocker.Visible = true; Debug.WriteLine("leftBlocker.Bounds = " + this.leftBlocker.Bounds.ToString()); } } if (this.cropRight != 0) { if (innerVlcLeft + perfectWidth - offTheRight < mySize.Width) { this.rightBlocker.Bounds = new Rectangle( new Point(innerVlcLeft + perfectWidth - offTheRight, 0), new Size(offTheRight, mySize.Height)); this.rightBlocker.Visible = true; Debug.WriteLine("rightBlocker.Bounds = " + this.rightBlocker.Bounds.ToString()); } } } } }
public static void Show(Size Msg) { System.Windows.Forms.MessageBox.Show("【Size类型】\r\n" + Msg.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
/// <summary> /// Utility function that converts a constraintSize provided to GetPreferredSize into a /// DataGridViewRadioButtonFreeDimension enum value. /// </summary> private static DataGridViewRadioButtonFreeDimension GetFreeDimensionFromConstraint(Size constraintSize) { if (constraintSize.Width < 0 || constraintSize.Height < 0) { throw new ArgumentException("InvalidArgument=Value of '" + constraintSize.ToString() + "' is not valid for 'constraintSize'."); } if (constraintSize.Width == 0) { if (constraintSize.Height == 0) { return DataGridViewRadioButtonFreeDimension.Both; } else { return DataGridViewRadioButtonFreeDimension.Width; } } else { if (constraintSize.Height == 0) { return DataGridViewRadioButtonFreeDimension.Height; } else { throw new ArgumentException("InvalidArgument=Value of '" + constraintSize.ToString() + "' is not valid for 'constraintSize'."); } } }
public void bug_82358 () { //Console.WriteLine ("Starting bug_82358"); int sizeable_factor; int title_bar; int tool_bar; int tool_border; int d3; int d2; // WinXP, default theme sizeable_factor = 2; title_bar = 26; tool_bar = 18; tool_border = 6; d3 = 10; d2 = 6; // WinXP, Win32 theme: sizeable_factor = 2; title_bar = 19; tool_bar = 16; tool_border = 6; d3 = 10; d2 = 6; Size size = new Size (200, 200); // Universal theme?? using (Form f = new Form ()) { f.FormBorderStyle = FormBorderStyle.FixedSingle; f.Visible = true; d2 = f.Size.Width - f.ClientSize.Width; title_bar = f.Size.Height - f.ClientSize.Height - d2; } using (Form f = new Form ()) { f.FormBorderStyle = FormBorderStyle.Sizable; f.Visible = true; sizeable_factor = f.Size.Width - f.ClientSize.Width - d2; } using (Form f = new Form ()) { f.ClientSize = size; f.FormBorderStyle = FormBorderStyle.FixedToolWindow; //f.Visible = true; tool_border = f.Size.Width - f.ClientSize.Width; tool_bar = f.Size.Height - f.ClientSize.Height - tool_border; } using (Form f = new Form ()) { f.FormBorderStyle = FormBorderStyle.Fixed3D; f.Visible = true; d3 = f.Size.Width - f.ClientSize.Width; } FormBorderStyle style; //Console.WriteLine ("Universal theme says: d2={0}, d3={1}, title_bar={2}, sizeable_factor={3}, tool_border={4}, tool_bar={5}", d2, d3, title_bar, sizeable_factor, tool_border, tool_bar); // Changing client size, then FormBorderStyle. using (Form f = new Form ()) { style = FormBorderStyle.FixedToolWindow; //Console.WriteLine ("Created form, size: {0}, clientsize: {1}", f.Size, f.ClientSize); f.ClientSize = size; //Console.WriteLine ("Changed ClientSize, size: {0}, clientsize: {1}", f.Size, f.ClientSize); f.FormBorderStyle = style; //Console.WriteLine ("Changed FormBorderStyle, size: {0}, clientsize: {1}", f.Size, f.ClientSize); Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A1"); Assert.AreEqual (new Size (size.Width + tool_border, size.Height + tool_border + tool_bar).ToString (), f.Size.ToString (), style.ToString () + "-A2"); f.Visible = true; //Console.WriteLine ("Made visible, size: {0}, clientsize: {1}", f.Size, f.ClientSize); Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A3"); Assert.AreEqual (new Size (size.Width + tool_border, size.Height + tool_border + tool_bar).ToString (), f.Size.ToString (), style.ToString () + "-A4"); } using (Form f = new Form ()) { style = FormBorderStyle.SizableToolWindow; f.ClientSize = size; f.FormBorderStyle = style; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A1"); Assert.AreEqual (new Size (size.Width + tool_border + sizeable_factor, size.Height + tool_border + tool_bar + sizeable_factor).ToString (), f.Size.ToString (), style.ToString () + "-A2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A3"); Assert.AreEqual (new Size (size.Width + tool_border + sizeable_factor, size.Height + tool_border + tool_bar + sizeable_factor).ToString (), f.Size.ToString (), style.ToString () + "-A4"); } using (Form f = new Form ()) { style = FormBorderStyle.Fixed3D; f.ClientSize = size; f.FormBorderStyle = style; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A1"); Assert.AreEqual (new Size (size.Width + d3, size.Height + title_bar + d3).ToString () , f.Size.ToString (), style.ToString () + "-A2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A3"); Assert.AreEqual (new Size (size.Width + d3, size.Height + title_bar + d3).ToString (), f.Size.ToString (), style.ToString () + "-A4"); } using (Form f = new Form ()) { style = FormBorderStyle.FixedDialog; f.ClientSize = size; f.FormBorderStyle = style; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A1"); Assert.AreEqual (new Size (size.Width + d2, size.Height + title_bar + d2).ToString (), f.Size.ToString (), style.ToString () + "-A2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A3"); Assert.AreEqual (new Size (size.Width + d2, size.Height + title_bar + d2).ToString (), f.Size.ToString (), style.ToString () + "-A4"); } using (Form f = new Form ()) { style = FormBorderStyle.FixedSingle; f.ClientSize = size; f.FormBorderStyle = style; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A1"); Assert.AreEqual (new Size (size.Width + d2, size.Height + title_bar + d2).ToString (), f.Size.ToString (), style.ToString () + "-A2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A3"); Assert.AreEqual (new Size (size.Width + d2, size.Height + title_bar + d2).ToString (), f.Size.ToString (), style.ToString () + "-A4"); } using (Form f = new Form ()) { style = FormBorderStyle.None; f.ClientSize = size; f.FormBorderStyle = style; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A1"); Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-A2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A3"); Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-A4"); } using (Form f = new Form ()) { style = FormBorderStyle.Sizable; f.ClientSize = size; f.FormBorderStyle = style; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A1"); Assert.AreEqual (new Size (size.Width + d2 + sizeable_factor, size.Height + title_bar + d2 + sizeable_factor).ToString (), f.Size.ToString (), style.ToString () + "-A2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-A3"); Assert.AreEqual (new Size (size.Width + d2 + sizeable_factor, size.Height + title_bar + d2 + sizeable_factor).ToString (), f.Size.ToString (), style.ToString () + "-A4"); } // Changing size, then FormBorderStyle. using (Form f = new Form ()) { style = FormBorderStyle.FixedToolWindow; f.Size = size; f.FormBorderStyle = style; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-B1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-B2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-B3"); Assert.AreEqual (new Size (size.Width - tool_border, size.Height - tool_border - tool_bar).ToString (), f.ClientSize.ToString (), style.ToString () + "-B4"); } using (Form f = new Form ()) { style = FormBorderStyle.SizableToolWindow; f.Size = size; f.FormBorderStyle = style; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-B1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-B2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-B3"); Assert.AreEqual (new Size (size.Width - tool_border - sizeable_factor, size.Height - tool_border - tool_bar - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-B4"); } using (Form f = new Form ()) { style = FormBorderStyle.Fixed3D; f.Size = size; f.FormBorderStyle = style; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-B1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-B2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-B3"); Assert.AreEqual (new Size (size.Width - d3, size.Height - title_bar - d3).ToString (), f.ClientSize.ToString (), style.ToString () + "-B4"); } using (Form f = new Form ()) { style = FormBorderStyle.FixedDialog; f.Size = size; f.FormBorderStyle = style; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-B1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-B2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-B3"); Assert.AreEqual (new Size (size.Width - d2, size.Height - title_bar - d2).ToString (), f.ClientSize.ToString (), style.ToString () + "-B4"); } using (Form f = new Form ()) { style = FormBorderStyle.FixedSingle; f.Size = size; f.FormBorderStyle = style; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-B1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-B2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-B3"); Assert.AreEqual (new Size (size.Width - d2, size.Height - title_bar - d2).ToString (), f.ClientSize.ToString (), style.ToString () + "-B4"); } using (Form f = new Form ()) { style = FormBorderStyle.None; f.Size = size; f.FormBorderStyle = style; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-B1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-B2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-B3"); Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-B4"); } using (Form f = new Form ()) { style = FormBorderStyle.Sizable; f.Size = size; f.FormBorderStyle = style; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-B1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-B2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-B3"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-B4"); } // Changing FormBorderStyle, then client size using (Form f = new Form ()) { style = FormBorderStyle.FixedToolWindow; f.FormBorderStyle = style; f.ClientSize = size; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-C1"); Assert.AreEqual (new Size (size.Width + tool_border, size.Height + tool_border + tool_bar).ToString (), f.Size.ToString (), style.ToString () + "-C2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-C3"); Assert.AreEqual (new Size (size.Width + tool_border, size.Height + tool_border + tool_bar).ToString (), f.Size.ToString (), style.ToString () + "-C4"); } using (Form f = new Form ()) { style = FormBorderStyle.SizableToolWindow; f.FormBorderStyle = style; f.ClientSize = size; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-C1"); Assert.AreEqual (new Size (size.Width + tool_border + sizeable_factor, size.Height + tool_border + tool_bar + sizeable_factor).ToString (), f.Size.ToString (), style.ToString () + "-C2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-C3"); Assert.AreEqual (new Size (size.Width + tool_border + sizeable_factor, size.Height + tool_border + tool_bar + sizeable_factor).ToString (), f.Size.ToString (), style.ToString () + "-C4"); } using (Form f = new Form ()) { style = FormBorderStyle.Fixed3D; f.FormBorderStyle = style; f.ClientSize = size; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-C1"); Assert.AreEqual (new Size (size.Width + d3, size.Height + title_bar + d3).ToString (), f.Size.ToString (), style.ToString () + "-C2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-C3"); Assert.AreEqual (new Size (size.Width + d3, size.Height + title_bar + d3).ToString (), f.Size.ToString (), style.ToString () + "-C4"); } using (Form f = new Form ()) { style = FormBorderStyle.FixedDialog; f.FormBorderStyle = style; f.ClientSize = size; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-C1"); Assert.AreEqual (new Size (size.Width + d2, size.Height + title_bar + d2).ToString (), f.Size.ToString (), style.ToString () + "-C2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-C3"); Assert.AreEqual (new Size (size.Width + d2, size.Height + title_bar + d2).ToString (), f.Size.ToString (), style.ToString () + "-C4"); } using (Form f = new Form ()) { style = FormBorderStyle.FixedSingle; f.FormBorderStyle = style; f.ClientSize = size; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-C1"); Assert.AreEqual (new Size (size.Width + d2, size.Height + title_bar + d2).ToString (), f.Size.ToString (), style.ToString () + "-C2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-C3"); Assert.AreEqual (new Size (size.Width + d2, size.Height + title_bar + d2).ToString (), f.Size.ToString (), style.ToString () + "-C4"); } using (Form f = new Form ()) { style = FormBorderStyle.None; f.FormBorderStyle = style; f.ClientSize = size; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-C1"); Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-C2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-C3"); Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-C4"); } using (Form f = new Form ()) { style = FormBorderStyle.Sizable; f.FormBorderStyle = style; f.ClientSize = size; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-C1"); Assert.AreEqual (new Size (size.Width + d2 + sizeable_factor, size.Height + title_bar + d2 + sizeable_factor).ToString (), f.Size.ToString (), style.ToString () + "-C2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-C3"); Assert.AreEqual (new Size (size.Width + d2 + sizeable_factor, size.Height + title_bar + d2 + sizeable_factor).ToString (), f.Size.ToString (), style.ToString () + "-C4"); } // Changing FormBorderStyle, then size using (Form f = new Form ()) { style = FormBorderStyle.FixedToolWindow; f.FormBorderStyle = style; f.Size = size; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-D1"); Assert.AreEqual (new Size (size.Width - tool_border, size.Height - tool_border - tool_bar).ToString (), f.ClientSize.ToString (), style.ToString () + "-D2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-D3"); Assert.AreEqual (new Size (size.Width - tool_border, size.Height - tool_border - tool_bar).ToString (), f.ClientSize.ToString (), style.ToString () + "-D4"); } using (Form f = new Form ()) { style = FormBorderStyle.SizableToolWindow; f.FormBorderStyle = style; f.Size = size; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-D1"); Assert.AreEqual (new Size (size.Width - tool_border - sizeable_factor, size.Height - tool_border - tool_bar - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-D2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-D3"); Assert.AreEqual (new Size (size.Width - tool_border - sizeable_factor, size.Height - tool_border - tool_bar - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-D4"); } using (Form f = new Form ()) { style = FormBorderStyle.Fixed3D; f.FormBorderStyle = style; f.Size = size; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-D1"); Assert.AreEqual (new Size (size.Width - d3, size.Height - title_bar - d3).ToString (), f.ClientSize.ToString (), style.ToString () + "-D2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-D3"); Assert.AreEqual (new Size (size.Width - d3, size.Height - title_bar - d3).ToString (), f.ClientSize.ToString (), style.ToString () + "-D4"); } using (Form f = new Form ()) { style = FormBorderStyle.FixedDialog; f.FormBorderStyle = style; f.Size = size; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-D1"); Assert.AreEqual (new Size (size.Width - d2, size.Height - title_bar - d2).ToString (), f.ClientSize.ToString (), style.ToString () + "-D2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-D3"); Assert.AreEqual (new Size (size.Width - d2, size.Height - title_bar - d2).ToString (), f.ClientSize.ToString (), style.ToString () + "-D4"); } using (Form f = new Form ()) { style = FormBorderStyle.FixedSingle; f.FormBorderStyle = style; f.Size = size; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-D1"); Assert.AreEqual (new Size (size.Width - d2, size.Height - title_bar - d2).ToString (), f.ClientSize.ToString (), style.ToString () + "-D2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-D3"); Assert.AreEqual (new Size (size.Width - d2, size.Height - title_bar - d2).ToString (), f.ClientSize.ToString (), style.ToString () + "-D4"); } using (Form f = new Form ()) { style = FormBorderStyle.None; f.FormBorderStyle = style; f.Size = size; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-D1"); Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-D2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.ClientSize.ToString (), style.ToString () + "-D3"); Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-D4"); } using (Form f = new Form ()) { style = FormBorderStyle.Sizable; f.FormBorderStyle = style; f.Size = size; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-D1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-D2"); f.Visible = true; Assert.AreEqual (size.ToString (), f.Size.ToString (), style.ToString () + "-D3"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-D4"); } // Set clientsize, then change size, then FormBorderStyle. using (Form f = new Form ()) { style = FormBorderStyle.FixedToolWindow; f.ClientSize = f.ClientSize; f.Size = size; f.FormBorderStyle = style; // Here we subtract the Sizable borders (default) then add FixedToolWindow's border. // Note how now the sizes doesn't change when creating the handle. Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor + tool_border, size.Height - title_bar - d2 - sizeable_factor + tool_border + tool_bar).ToString (), f.Size.ToString (), style.ToString () + "-E1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-E2"); f.Visible = true; Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor + tool_border, size.Height - title_bar - d2 - sizeable_factor + tool_border + tool_bar).ToString (), f.Size.ToString (), style.ToString () + "-E3"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-E4"); } using (Form f = new Form ()) { style = FormBorderStyle.SizableToolWindow; f.ClientSize = f.ClientSize; f.Size = size; f.FormBorderStyle = style; Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor + tool_border + sizeable_factor, size.Height - title_bar - d2 - sizeable_factor + tool_border + tool_bar + sizeable_factor).ToString (), f.Size.ToString (), style.ToString () + "-E1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-E2"); f.Visible = true; Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor + tool_border + sizeable_factor, size.Height - title_bar - d2 - sizeable_factor + tool_border + tool_bar + sizeable_factor).ToString (), f.Size.ToString (), style.ToString () + "-E3"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-E4"); } using (Form f = new Form ()) { style = FormBorderStyle.Fixed3D; f.ClientSize = f.ClientSize; f.Size = size; f.FormBorderStyle = style; Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor + d3, size.Height - title_bar - d2 - sizeable_factor + title_bar + d3).ToString (), f.Size.ToString (), style.ToString () + "-E1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-E2"); f.Visible = true; Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor + d3, size.Height - title_bar - d2 - sizeable_factor + title_bar + d3).ToString (), f.Size.ToString (), style.ToString () + "-E3"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-E4"); } using (Form f = new Form ()) { style = FormBorderStyle.FixedDialog; f.ClientSize = f.ClientSize; f.Size = size; f.FormBorderStyle = style; Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor + d2, size.Height - title_bar - d2 - sizeable_factor + title_bar + d2).ToString (), f.Size.ToString (), style.ToString () + "-E1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-E2"); f.Visible = true; Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor + d2, size.Height - title_bar - d2 - sizeable_factor + title_bar + d2).ToString (), f.Size.ToString (), style.ToString () + "-E3"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-E4"); } using (Form f = new Form ()) { style = FormBorderStyle.FixedSingle; f.ClientSize = f.ClientSize; f.Size = size; f.FormBorderStyle = style; Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor + d2, size.Height - title_bar - d2 - sizeable_factor + title_bar + d2).ToString (), f.Size.ToString (), style.ToString () + "-E1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-E2"); f.Visible = true; Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor + d2, size.Height - title_bar - d2 - sizeable_factor + title_bar + d2).ToString (), f.Size.ToString (), style.ToString () + "-E3"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-E4"); } using (Form f = new Form ()) { style = FormBorderStyle.None; f.ClientSize = f.ClientSize; f.Size = size; f.FormBorderStyle = style; Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.Size.ToString (), style.ToString () + "-E1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-E2"); f.Visible = true; Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.Size.ToString (), style.ToString () + "-E3"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-E4"); } using (Form f = new Form ()) { style = FormBorderStyle.Sizable; f.ClientSize = f.ClientSize; f.Size = size; f.FormBorderStyle = style; Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor + d2 + sizeable_factor, size.Height - title_bar - d2 - sizeable_factor + d2 + sizeable_factor + title_bar).ToString (), f.Size.ToString (), style.ToString () + "-E1"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-E2"); f.Visible = true; Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor + d2 + sizeable_factor, size.Height - title_bar - d2 - sizeable_factor + d2 + sizeable_factor + title_bar).ToString (), f.Size.ToString (), style.ToString () + "-E3"); Assert.AreEqual (new Size (size.Width - d2 - sizeable_factor, size.Height - title_bar - d2 - sizeable_factor).ToString (), f.ClientSize.ToString (), style.ToString () + "-E4"); } }
//Size /// <summary> /// Stores the specified Size Objectas a setting in the current SettingsKey. /// </summary> /// /// <param name="settingName"> /// The name of the setting to store. /// </param> /// /// <param name="settingValue"> /// The Size to store for this setting. /// </param> /// /// <exception cref="UnauthorizedAccessException"> /// This current SettingsKey is the root SettingsKey or is read-only. /// </exception> /// /// <exception cref="ArgumentNullException"> /// The specified 'settingName' /// is a null reference or an empty string or the specified /// 'settingValue' is null. /// </exception> /// /// <remarks> /// To retrieve a stored Size from the settings file use the <see cref="GetSize"/> method. /// <para> /// Since many settings can be stored in each SettingsKey, /// the 'settingName' parameter specifies the particular setting you wish to manipulate. /// </para> /// /// <para> /// The key that is opened with the setting being set must have been /// opened with write access, and not be a read-only key. /// Once you have been granted write-access to a key, you can change /// the data associated with any of the settings in that key. /// </para> /// /// <para> /// The parameter 'settingName' is case-sensitive. /// </para> /// /// <para> /// If the specified setting name does not exist in the key, /// it will be created, and the sepecified settingValue is stored. /// </para> /// </remarks> public void StoreSize(string settingName, Size settingValue) { #region conditions //Removed because a size of 0,0 should be valid. // // is the settingValue parameter null // if (settingValue == Size.Empty) // { // this.throwParameterNullException("setting"); // } #endregion StoreSetting(settingName,settingValue.ToString()); }
public static void TaskMain(string[] args) { if (args == null || args.Length != 4) { throw new Exception("Usage: ImageBlur.exe --Task <blobpath> <storageAccountName> <storageAccountKey>"); } string blobName = args[1]; string storageAccountName = args[2]; string storageAccountKey = args[3]; string workingDirectory = Environment.GetEnvironmentVariable("AZ_BATCH_TASK_WORKING_DIR"); int numberToBlur = 3; Console.WriteLine(); Console.WriteLine(" blobName: <{0}>", blobName); Console.WriteLine(" storageAccountName: <{0}>", storageAccountName); Console.WriteLine(" number to blur: <{0}>", numberToBlur); Console.WriteLine(); // get source image from cloud blob var storageCred = new StorageCredentials(storageAccountName, storageAccountKey); CloudBlockBlob blob = new CloudBlockBlob(new Uri(blobName), storageCred); using (MemoryStream inStream = new MemoryStream()) { blob.DownloadToStream(inStream); Image img = Image.FromStream(inStream); int imgWidth = img.Width; int imgHeight = img.Height; Size size = new Size(imgWidth, imgHeight); ISupportedImageFormat format = new JpegFormat { Quality = 70 }; // Print image properties to stdout Console.WriteLine(" Image Properties:"); Console.WriteLine(" Format: {0}", FormatUtilities.GetFormat(inStream)); Console.WriteLine(" Size: {0}", size.ToString()); Console.WriteLine(); for (var i = 0; i < numberToBlur; i++) { using (ImageFactory imageFactory = new ImageFactory(preserveExifData: true)) { int blurIndex = (i * 5) + 10; imageFactory.Load(inStream); imageFactory.Resize(size) .Format(format) .GaussianBlur(blurIndex) .Save(workingDirectory + "/resultimage" + i + ".Jpeg"); //.Save(@"C:/Users/jiata/Desktop/imageblur/results/resultimage" + i + ".Jpeg"); } } } // TODO - not working for (var i = 0; i < numberToBlur; i++) { blob.UploadFromFile(workingDirectory + "/resultimage" + i + ".Jpeg", FileMode.Open); } Environment.Exit(1); }
public void Accumulate(Size size) { this.Accumulate(size.ToString()); }
static internal DataGridViewFreeDimension GetFreeDimensionFromConstraint(Size constraintSize) { if (constraintSize.Width < 0 || constraintSize.Height < 0) { throw new ArgumentException(SR.GetString(SR.InvalidArgument, "constraintSize", constraintSize.ToString())); } if (constraintSize.Width == 0) { if (constraintSize.Height == 0) { return DataGridViewFreeDimension.Both; } else { return DataGridViewFreeDimension.Width; } } else { if (constraintSize.Height == 0) { return DataGridViewFreeDimension.Height; } else { throw new ArgumentException(SR.GetString(SR.InvalidArgument, "constraintSize", constraintSize.ToString())); } } }
//static Random r = new Random(); public void FrameBufferResized() { // run this entire thing exactly twice, since the first resize may adjust the menu stacking for (int i = 0; i < 2; i++) { var video = Global.Emulator.VideoProvider(); int zoom = Global.Config.TargetZoomFactor; var area = Screen.FromControl(this).WorkingArea; int borderWidth = Size.Width - PresentationPanel.Control.Size.Width; int borderHeight = Size.Height - PresentationPanel.Control.Size.Height; // start at target zoom and work way down until we find acceptable zoom Size lastComputedSize = new Size(1, 1); for (; zoom >= 1; zoom--) { lastComputedSize = GlobalWin.DisplayManager.CalculateClientSize(video, zoom); if ((((lastComputedSize.Width) + borderWidth) < area.Width) && (((lastComputedSize.Height) + borderHeight) < area.Height)) { break; } } Console.WriteLine("Selecting display size " + lastComputedSize.ToString()); // Change size Size = new Size((lastComputedSize.Width) + borderWidth, ((lastComputedSize.Height) + borderHeight)); PerformLayout(); PresentationPanel.Resized = true; // Is window off the screen at this size? if (area.Contains(Bounds) == false) { if (Bounds.Right > area.Right) // Window is off the right edge { Location = new Point(area.Right - Size.Width, Location.Y); } if (Bounds.Bottom > area.Bottom) // Window is off the bottom edge { Location = new Point(Location.X, area.Bottom - Size.Height); } } } }
public void SetWindowSize(Size size, ILogger log) { try { log?.INFO($"Resize window using size: {size.ToString()}"); _container.Value.Driver.Manage().Window.Size = size; log?.INFO("Window resizing completed"); } catch (Exception ex) { log?.ERROR($"Error occurred during window resizing"); throw new CommandAbortException($"Error occurred during window resizing", ex); } }
/// <summary> /// Provides a default implementation for performing dst = F(dst, src) or F(src) over some rectangle /// of interest. May be slightly faster than calling the other multi-parameter Apply method, as less /// variables are used in the implementation, thus inducing less register pressure. /// </summary> /// <param name="dst">The Surface to write pixels to, and from which pixels are read and used as the lhs parameter for calling the method <b>ColorBgra Apply(ColorBgra, ColorBgra)</b>.</param> /// <param name="dstOffset">The pixel offset that defines the upper-left of the rectangle-of-interest for the dst Surface.</param> /// <param name="src">The Surface to read pixels from for the rhs parameter given to the method <b>ColorBgra Apply(ColorBgra, ColorBgra)</b>b>.</param></param> /// <param name="srcOffset">The pixel offset that defines the upper-left of the rectangle-of-interest for the src Surface.</param> /// <param name="roiSize">The size of the rectangles-of-interest for all Surfaces.</param> public void ApplyBase(Surface dst, Point dstOffset, Surface src, Point srcOffset, Size roiSize) { // Create bounding rectangles for each Surface Rectangle dstRect = new Rectangle(dstOffset, roiSize); if (dstRect.Width == 0 || dstRect.Height == 0) { return; } Rectangle srcRect = new Rectangle(srcOffset, roiSize); if (srcRect.Width == 0 || srcRect.Height == 0) { return; } // Clip those rectangles to those Surface's bounding rectangles Rectangle dstClip = Rectangle.Intersect(dstRect, dst.Bounds); Rectangle srcClip = Rectangle.Intersect(srcRect, src.Bounds); // If any of those Rectangles actually got clipped, then throw an exception if (dstRect != dstClip) { throw new ArgumentOutOfRangeException ( "roiSize", "Destination roi out of bounds" + ", dst.Size=" + dst.Size.ToString() + ", dst.Bounds=" + dst.Bounds.ToString() + ", dstOffset=" + dstOffset.ToString() + ", src.Size=" + src.Size.ToString() + ", srcOffset=" + srcOffset.ToString() + ", roiSize=" + roiSize.ToString() + ", dstRect=" + dstRect.ToString() + ", dstClip=" + dstClip.ToString() + ", srcRect=" + srcRect.ToString() + ", srcClip=" + srcClip.ToString() ); } if (srcRect != srcClip) { throw new ArgumentOutOfRangeException("roiSize", "Source roi out of bounds"); } // Cache the width and height properties int width = roiSize.Width; int height = roiSize.Height; // Do the work. unsafe { for (int row = 0; row < roiSize.Height; ++row) { ColorBgra *dstPtr = dst.GetPointAddress(dstOffset.X, dstOffset.Y + row); ColorBgra *srcPtr = src.GetPointAddress(srcOffset.X, srcOffset.Y + row); Apply(dstPtr, srcPtr, width); } } }
public override string ToString() { return("{ " + Name + "; " + Size.ToString() + "; " + Style.ToString() + " }"); }