|
|
Terry Price wrote: Program.cs 28
Compiler messages and run-time errors/exceptions tend to include useful information such as class name, file name, and line number. Now tell your IDE to always display the line numbers in source windows and start relying on them.
28
|
|
|
|
|
I have to say this really is a case of 'RTFM', the M being 'message' in this case. The error message tells you which line is broken, what the problem is and how to fix it!
You should use List<ushort> but I guess you are and you just didn't manage to type your post correctly (eaten by the HTML parser?) since there is no List class in .Net.
The answer is: toAdd = (ushort)(lhs + rhs)
... but I must ask why you're using ushorts in the first place. Unless you're declaring these lists to directly interface to a ushort-taking API, there's no reason not to just use uint or int in most cases. Arithmetic operations are optimised for 32 bit numbers and you're just slowing yourself down by using 16 bit.
|
|
|
|
|
BobJanova wrote: but I must ask why you're using ushorts in the first place. Well, he mentioned this being part of a class called "image", so I'd guess its for space reasons. So I'm not very sure that it would be slower either, usually yes (that extra AND at the end costs time, if not that much), but if he's saving cache misses that way then they probably make up for it.
|
|
|
|
|
ushort and int take up the same space on the stack. No memory saving there. Same as bool, they all take up 4 bytes.
"You get that on the big jobs."
|
|
|
|
|
Yes so I wasn't talking about those three local variables, but about the List, which is backed by an array, not by a million local variables.
|
|
|
|
|
But since the OP has not responded to any of our messages this discussion becomes largely academic.
|
|
|
|
|
Maybe the OP will come back on Monday, but I don't actually expect that.
|
|
|
|
|
Here I am using follwing code for the Draw RoundRect.The Path geomatric use for the save RoundRect Points . there is only fault with round rect geometry when combine. single Roundrect geometry is appeared during drawing .but after combine its only Ellips geometry appeared and round rect not appeared.
// --------------------------------------------------------------- //
Below Function generate Round rect PathGeometry...........
// ---------------------------------------------------------------
public PathGeometry RoundRect() { Rect rect = new Rect(30, 30, 200, 200);
Pen pen = new Pen(null, 50); Brush brush = null;
CornerRadius cornerRadius = new CornerRadius(10, 10, 10,10);
var geometry = new StreamGeometry();
using (var context = geometry.Open()) { bool isStroked = pen != null;
const bool isSmoothJoin = true;
context.BeginFigure(rect.TopLeft + new Vector(0, cornerRadius.TopLeft), brush != null, true);
context.ArcTo(new Point(rect.TopLeft.X + cornerRadius.TopLeft, rect.TopLeft.Y), new Size(cornerRadius.TopLeft, cornerRadius.TopLeft), 90, false, SweepDirection.Clockwise, isStroked, isSmoothJoin);
context.LineTo(rect.TopRight - new Vector(cornerRadius.TopRight, 0), isStroked, isSmoothJoin);
context.ArcTo(new Point(rect.TopRight.X, rect.TopRight.Y + cornerRadius.TopRight), new Size(cornerRadius.TopRight, cornerRadius.TopRight), 90, false, SweepDirection.Clockwise, isStroked, isSmoothJoin);
context.LineTo(rect.BottomRight - new Vector(0, cornerRadius.BottomRight), isStroked, isSmoothJoin); context.ArcTo(new Point(rect.BottomRight.X - cornerRadius.BottomRight, rect.BottomRight.Y), new Size(cornerRadius.BottomRight, cornerRadius.BottomRight), 90, false, SweepDirection.Clockwise, isStroked, isSmoothJoin);
context.LineTo(rect.BottomLeft + new Vector(cornerRadius.BottomLeft, 0), isStroked, isSmoothJoin);
context.ArcTo(new Point(rect.BottomLeft.X, rect.BottomLeft.Y - cornerRadius.BottomLeft), new Size(cornerRadius.BottomLeft, cornerRadius.BottomLeft), 90, false, SweepDirection.Clockwise, isStroked, isSmoothJoin);
context.Close(); } PathGeometry pt = new PathGeometry();
pt = PathGeometry.CreateFromGeometry(geometry);
return pt;
}
//------------------------------------------------ Below Function generate Ellips PathGeometry...........
//----------------------------------------------- public PathGeometry ellips() { EllipseGeometry eGeo = new EllipseGeometry(new Rect(30, 30, 200, 200));
return eGeo.GetFlattenedPathGeometry();
} --------------------------------------------------------------- Below Function Combine both pathgeometry and make new pathgeometry --------------------------------------------------------------- PathGeometry pathGeometry = new PathGeometry();
PathGeometry pathGeometry1 = new PathGeometry();
PathGeometry pathGeometry2 = new PathGeometry(); protected override void OnRender(DrawingContext dc) { pathGeometry1 = this.RoundRect(); pathGeometry2 = ellips();
pathGeometry = PathGeometry.Combine(pathGeometry1, pathGeometry2, GeometryCombineMode.Union, null);
dc.DrawGeometry(null, new Pen(new SolidColorBrush(Colors.Red), 1), pathGeometry);
}
//---------------------------------------------------------------
// Output //
---------------------------------------------------------------
But here in outPut ,RoundRect Geometry is not appeared after combined , Only Ellips is appeared Please let me know the mistakee in My Code. Or suggest any other way to achive this functionality
modified 26-May-12 1:38am.
|
|
|
|
|
Please edit your question, reformat your code and put it between <pre> tags so it is readable thus:
public PathGeometry RoundRect()
{
Rect rect = new Rect(30, 30, 200, 200);
...
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
suppose i have label and button on textbox and i want that if i resize my win form then my label and button size and position will change. i got the solution in wpf but i am working with win form apps. here i am giving the url from where you can see what kind of output i am looking form. the url is http://i.stack.imgur.com/QeoVK.png . please see the image and tell me how can i implement the same output in win form apps. please help me with code snippet in c#.thanks.
|
|
|
|
|
Use of Anchor property will help you in this case
Layout has different properties like Anchor, Margin, Dock, Size, Min size Max size.
Use these in combination to achieve the output you are looking for
Happy Coding
|
|
|
|
|
Hi everybody
How can i receive text data from a web page
|
|
|
|
|
From the documentation[^];
using System;
using System.IO;
using System.Net;
using System.Text;
namespace Examples.System.Net
{
public class WebRequestGetExample
{
public static void Main ()
{
WebRequest request = WebRequest.Create ("http://www.contoso.com/default.html");
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse ();
Console.WriteLine (response.StatusDescription);
Stream dataStream = response.GetResponseStream ();
StreamReader reader = new StreamReader (dataStream);
string responseFromServer = reader.ReadToEnd ();
Console.WriteLine (responseFromServer);
reader.Close ();
dataStream.Close ();
response.Close ();
}
}
}
Good luck
Bastard Programmer from Hell
|
|
|
|
|
Here is the link through that you will get some hint.
when you are requesting for some resource on web, on return of that you will get webpage content. so you need to learn WebRequest/WebResponse.
-Amit
|
|
|
|
|
hello guys... I was thinking if there is any way to compare two times which are in different format. Like if I have these times
time1 = "01/12/2005";
time2 = "Dec 1, 2005";
Is it possible to compare these two times? Thanks
This world is going to explode due to international politics, SOON.
|
|
|
|
|
Yes.
Never ever, ever try to compare dates, or any other numbers as strings: convert them to an appropriate class first.
In this case, that class is DateTime:
DateTime dt1 = DateTime.Parse("01/12/2005");
DateTime dt2 = DateTime.Parse("Dec 12 2005");
TimeSpan diff = dt2 - dt1; You may need to use ParseExact, or TryParseExact if you know what format the date will be in to avoid problems like 03/04/05 - is that 3rd Apr 2005, or 4th March 2005, or 5th Apr 2003?
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Hey, i didn't seen your full reply. although both the code are same
|
|
|
|
|
DateTime time1 = DateTime.Parse("01/12/2005");
DateTime time2 = DateTime.Parse("Dec 1, 2005");
if (time1==time2)
{...
}
else
{
...
}
|
|
|
|
|
Hi,
You can use Parse,TryParse,TryParseExact to parse your string to convert it into DateTime object. each have their own pros/cons.
Here is the sample code for finding difference between dates.
DateTime dt1 = DateTime.Parse("firstDate");
DateTime dt2 = DateTime.Parse("secondDate");
TimeSpan dateDifference = dt1.Subtract(dt2);
-Amit
|
|
|
|
|
Hey i want to create a table at run time and want to bind it with grid View how it would be possible
|
|
|
|
|
Create a new DataTable, add the data columns, assign the data table as the datasource of the gridview.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi all!
I am developing web app (asp.net) like http://dethi.violet.vn/present/show/entry_id/7650679 allow users preview document file.
The users will upload .doc or .ppt, .pdf; how to convert these file to .swf to display in web.
I uses Google view document, but if the document has mathematical formula, google view display not correct!
Hope all directions!
|
|
|
|
|
You can use:
Adobe FlashPaper Or Print2Flash
Both tools provide facility to convert any printable document to swf, there is also facility to convert document programetically.
|
|
|
|
|
And same time !the file size don't Exceed 10MB
|
|
|
|
|