I have to draw a rectangle using lines whose co-ordinates and measures are already provided.
In the below code, if I call CloseFigure function. C# assumes the drawing is incomplete and hence it draws an another line diagonally to close the rectangle.
If I use a AddRectangle function, the drawing is complete. No issues with that.
How can I complete a drawing, properly using lines?
private void OnPaint(object sender, PaintEventArgs e)
Pen redPen = new Pen(Color.Red, 2);
// Create a graphics path
GraphicsPath path = new GraphicsPath();
// Add two lines, a rectangle and an ellipse
Graphics g = e.Graphics;
You are creating a GraphicsPath, but that doesn't draw it, or indeed anything, until you use one of the Graphics.DrawXXX methods.
In your case, add this:
g.DrawPath(redPen, path); // And draw it.
But do note that CloseFigure draws between teh first and last points - so you will get a diagonal as well!
Me? I'd draw your rectangle like this:
privatevoid OnPaint(object sender, PaintEventArgs e)
using (Pen redPen = new Pen(Color.Red, 2))
Graphics g = e.Graphics;
g.DrawLine(redPen, 20, 20, 20, 400); // left
g.DrawLine(redPen, 20, 20, 400, 20); //top
g.DrawLine(redPen, 400, 20, 400, 400); // right
g.DrawLine(redPen, 20, 400, 400, 400); // bottom
And save Paths and Regions for the more complex shapes!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
Hi all, suppose I have a text file that contains hundreds of entries with each entry surrounded by an opening @ symbol and a closing /@ symbol, and each entry is separated from the next by a blank line like below:
If I want to get all the inputs of a particular user with a certain UserID, how would I go about doing that? I know I have to use string.contain method to check if a certain UserID exist and if it does, use the characters "@", "/@", "Input:", and "," as the delimiters to refine the search. But I'm not real clear on how to go about it. Any suggestions will be greatly appreciated, thanks in advance.
I would create an object that will hold all the bits of your info,
Depending on the size of the file I would either read it all into memory or read it 1 line at a time.
If the line starts with your open token @ set a flag, keep reading till your line ends with your end token /@, appending the line(s) to a string variable.
Depending on your structure I would then pass the string variable to a parser which chops up the crap you are getting for data, it looks like the start of the record is reasonable and it deteriorates into rubbish with no structure.
The parser should return an instance of the object which is then added to a List<>.
Repeat until you get to the end of the file.
Never underestimate the power of human stupidity
I'm with Mycroft Holmes.
You need an object eg Entry with several properties:
Then read in the file. You have several options: read line per line or in one piece and then split.
If there are more then one message per userid you can more cleverly make a dictionary holding all the data for that user...
First get all matches between @ and /@ tags,
then write a method which takes a single block and returns UserID (you can do it by indexof and substring methods)
then iterate all matches and take appropriate ids.
MatchCollection matchList = Regex.Matches(yourInput, yourPattern);
var list = matchList.Cast<Match>().Select(match => match.Value).ToList();
var result = list.Where(p=> GetUserID(p) == "XXXXX").ToList();
privatestring GetUserID(string singleBlock)
Extract user id and return it;
What it currently can do: rename types and remove namespaces, rename methods and fields, remove properties and events declarations, rename (private) assembly files. Basically, my primary goal was to make it remove all meaningful information that can help reverse engineers to analyze the program.
It provides 2 features, that I needed and couldn't find in existing products:
1. Flexible settings system that allows fine-grained control over classes and members obfuscation parameters.
2. It can obfuscate public types and members (useful for assemblies that are not exposed outside of your program)
I've been working on a custom component which acts as a 'view' control, such that it manually paints cells for child items. The component can contain hundreds of child items, which means that I've had to utilise the BufferedGraphics object for maintaining the graphics, and reset it only when the component is resized or when the child items are changed. Each child items also owns it's own BufferedGraphics object to maintain the rendering of each item (since these items can contain an Image in the graphics, it speeds up the painting considerably.)
A problem surfaces when I start to take into account scrolling through the use of AutoScroll and AutoScrollPosition. I've spent a good while trying to search for an answer to applying the scroll position offset to a BufferedGraphics and I've yet yielded unsuccessful results. Several problems are standing in the way of the scrolling functionality:
1. Graphics.TranslateTransform() or Graphics.Transform = new Matrix() does not translate a BufferedGraphics.Render() operation. I believe this is namely because the Render() function just paints directly onto the Graphics handle for the region it was allocated by.
For example, the below does not work:
overridevoid OnPaint(PaintEventArgs e)
// code here which deals with allocating the buffer if it needs creating
// translate by the auto scroll position
// render the buffered graphics onto the graphics handle for the paint event
2. Following the code in this example [^] results in many invalidations, which causes the graphics to lag to the point that it's infeasible for the component.
My question is, is there a reliable method of being able to translate the buffered graphics of a BufferedGraphics object when painting onto a Graphics handle? For instance, could I allocate my BufferedGraphics as I do in point #1, and intrinsically invalidate the component upon scrolling and simply offset the buffered graphics depending on the position the user has scrolled to?
If not, can anyone recommend a suitable replacement for rendering like this? Obviously, components such as the ListView class have the ability to render many items with scrolling, with little issues with performance (depending on which double-buffering and CreateParams changes are made.)
Just for anyone with a similar question in the future, I managed to resolve this quite simply.
Upon the OnScroll event method, simply invalidate the BufferedGraphics object by disposing it, and reset it back to null. Invalidate the whole component, and when constructing the new BufferedGraphics object, set the targetRectangle parameter's X and Y values to the respective AutoScrollPosition values.
But this is not what I was expecting. I require every requirement to get displayed individually though they are associated to the same test case in test explorer window.
I want to get it displayed as (in test explorer):-
and so on....
So, if I am associating n number of Requirements to a test case, the test explorer should display the same test case n times under different requirements. Please let me know how could this be achieved ??
I have used T4 Text Templating For my Vs Package.am using Customlinecommandhost for transformation.After Transformation the Output file contains Unnecessary lines.the output is as follows.
line :1 C:\Users\kanimozhikp\Documents\Visual Studio 2012\Projects\samp
Public override string TextTransform()
}...and so on.i dont need the above mentioned line in my output.Please any one give me the solution.and more over this problem arises on windows 8.1 only,it works fine at windows 7 and 8 :(
most of the time we point store procedure or table and then SSRS report designer show us field and we just drag drop those field on to report designer surface. after all we call those report programmatically and pass parameter and report shown on report viewer.
now my company want that customer will customize the report who will see the report. they want to display all the fields in a form and just customer will select each field and place on report designer surface and give some input like filter condition like date range or employee id etc and report will be shown. also at run time if customer want they can add text or move existing field etc on report viewer surface.
i do not have any idea how could i do this with SSRS. if this is possible with SSRS then please guide me in such a way as a result i can start the job or if possible give me few relevant url of that kind from where i can get the idea. thanks
I thought SSRS had a deployable report designer. However I can't locate it so it has probably been deprecated from lack of use.
I have deployed a number of user targeted report designers, not a single one has ever been used, your users will not invest the time and resource into learning the data structure, learning how to build the report. They also may not have the experience to build the reports.
I suggest you get give them a read only connection to the database and let them choose their own tool.
Never underestimate the power of human stupidity
Last Visit: 31-Dec-99 18:00 Last Update: 2-Sep-14 15:42