system.drawing

Portable class library - Reference to type 'MarshalByRefObject' claims it is defined in 'mscorlib', but it could not be found

半世苍凉 提交于 2019-12-08 11:26:26
I have a normal Class Library with a function that converts a Byte Array to an Image. Now I've deleted that Class Library and created a Portable Class Library with the same name and now the code does not seem to work anymore and gives me an error on the "FromStream"-function: Reference to type 'MarshalByRefObject' claims it is defined in 'mscorlib', but it could not be found using System; using System.Drawing; using System.IO; namespace App.Converters { public static class Converter { public static Image ToImage(this byte[] byteArray) { try { return Image.FromStream(new MemoryStream(byteArray)

Proportional Translation

只谈情不闲聊 提交于 2019-12-08 08:24:23
问题 I'd like to update a list of points (PointFs) by performing a rotation (around a new origin) and translating each point by an amount that is proportional to its current distance from the origin (so not an absolute translation). I currently do this for each point in turn but performance is poor when moving more than a handful of points. I'd like to make the transformation more efficient so wanted to use a matrix. The rotation is no problem, but I don't know how to do the proportional

How to adjust size of programatically created Bitmap to match text drawn on it?

自作多情 提交于 2019-12-08 07:33:17
问题 I have the following .ashx page that takes some query string parameters and returns a bitmap with the specified text written on it. The problem I have is that I am currently just manually setting the initial size of the bitmap at 100 X 100 when what I really want is to have the bitmap be just big enough to include all the text that was written to it. How can I do this? public void ProcessRequest (HttpContext context) { context.Response.ContentType = "image/png"; string text = context.Request

Drag and Drop Function with Drawing Rectangle C# .net - Forms

余生长醉 提交于 2019-12-08 06:40:54
问题 I want to drag and drop that I have drawn on the forms. Here is my code for drawing the rectangle. An this works fine. Rectangle rec = new Rectangle(0, 0, 0, 0); public Form1() { InitializeComponent(); this.DoubleBuffered = true; } protected override void OnPaint(PaintEventArgs e) { e.Graphics.FillRectangle(Brushes.Aquamarine, rec); } protected override void OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { rec = new Rectangle(e.X, e.Y, 0, 0); Invalidate(); } } protected

Portable class library - Reference to type 'MarshalByRefObject' claims it is defined in 'mscorlib', but it could not be found

心不动则不痛 提交于 2019-12-08 04:07:05
问题 I have a normal Class Library with a function that converts a Byte Array to an Image. Now I've deleted that Class Library and created a Portable Class Library with the same name and now the code does not seem to work anymore and gives me an error on the "FromStream"-function: Reference to type 'MarshalByRefObject' claims it is defined in 'mscorlib', but it could not be found using System; using System.Drawing; using System.IO; namespace App.Converters { public static class Converter { public

Why System.Drawing + ClearType font have ugly black fragments?

空扰寡人 提交于 2019-12-08 03:58:13
问题 I'm using following C# code to make a picture with a text in it // Create font. Parameter is a global variable Font objFont = new Font(fontname, fontsize, fontstyle, System.Drawing.GraphicsUnit.Pixel); // Grab an existing image from picture box. (target is picturebox's name) Bitmap result; if (target.Image != null) { result = new Bitmap(target.Image); } else { result = new Bitmap(target.Width, target.Height); } Graphics objGraphics = Graphics.FromImage(result); // And draw to it. Select a

getting additional PaperSource details

随声附和 提交于 2019-12-07 13:15:56
问题 I'm trying to get the correct details of trays of various printers however have come across a problem. After a bit of research I've added the ReachFramework.dll and also using System.Drawing.Printing; To get the names of the trays for a printer I run the following code... PrintDocument printDocument = new PrintDocument(); printDocument.PrinterSettings.PrinterName = "<Windows Printer Name>"; foreach (PaperSource paperSource in printDocument.PrinterSettings.PaperSources) { Console.WriteLine

Get System.Drawing.Font width?

ε祈祈猫儿з 提交于 2019-12-07 06:27:12
问题 I'm using .Net tools to do some 2D drawing. System.Drawing.Font uses a GetHeight() that returns the height in pixels. I'm missing a GetWidth() to retrieve the width! What should I use? 回答1: Use Graphics.MeasureString Method (String, Font) : Eg. // Set up string. string measureString = "Measure String"; Font stringFont = new Font("Arial", 16); // Measure string. SizeF stringSize = new SizeF(); stringSize = e.Graphics.MeasureString(measureString, stringFont); // This will give you string width,

How can I make label text scale-able in Winforms application

孤者浪人 提交于 2019-12-07 02:15:27
问题 I am looking for a way to make text in a label scale-able to it fit in entire parent container. The one way I can think of is to get the container size on window re-size and then increase or decrease font size accordingly, but that would limit its possibilities. Wondering if there is a better way of doing this, that may work more like an anchor property in Winforms application. 回答1: I knew the answer is hidden somewhere in graphic object and paint event, playing around with these 2 keywords

Drag and Drop Function with Drawing Rectangle C# .net - Forms

本秂侑毒 提交于 2019-12-07 01:03:29
I want to drag and drop that I have drawn on the forms. Here is my code for drawing the rectangle. An this works fine. Rectangle rec = new Rectangle(0, 0, 0, 0); public Form1() { InitializeComponent(); this.DoubleBuffered = true; } protected override void OnPaint(PaintEventArgs e) { e.Graphics.FillRectangle(Brushes.Aquamarine, rec); } protected override void OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { rec = new Rectangle(e.X, e.Y, 0, 0); Invalidate(); } } protected override void OnMouseMove(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { rec.Width = e.X - rec