|
The Graphics class defines several helpful transformation methods like Graphics.RotateTransform for this specific purpose. If you apply this as the world transform, than even your clipping region (whether you fill a Region yourself or use a GraphicsPath (most handy, BTW!) is rotated.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank you. But, I'm sorry, I don`t understand what you mean for "apply this as the world transform". If I extend a Button Class and I call RotateTransform to its Graphic obj it will only change the graphic surface, but not the . Can you give me a little example of your solution?
|
|
|
|
|
Because a Button isn't completely drawn by .NET. You must understand that almost every control in Windows Forms encapsulates the native Windows Common Controls which draws the control unless you completely handle the painting yourself by calling the following in your constructor:
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint,
true); For examples of transforms read the class documentation in the .NET Framework SDK that was installed by default when you installed VS.NET (or the standalone SDK) or available online at http://msdn.microsoft.com/library[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
First I'd like to point out that I am posting this anonymously to protect the identities of myself and those I work with.
At a design review meeting recently, a collegue of mine stated that we shouldn't use the reflection assembly in out software as using reflection was 'cheating'.
I have to say that I was completely speechless. My collegue appears to think that reflection is cheating as it allows you to bypass the class structure.
Personally I think that reflection is a useful addition to the .NET libraries and allows us to write flexible code.
Any views?
|
|
|
|
|
Fear of the unknown is a big reason for people to not like new ideas. Show some examples of how benefical reflection can be. However anything can be abused so make sure your proposed design isn't abusing reflection and that another sound design wouldn't work. Reflection used correctly can add great power, maintainability and flexability to a design.
Examples:
1) A pluggable container system that allows any component to be loaded/unloaded at runtime without the need to stop the server
2) Ability to use different adapters that can be configured through a external text file. I used this quite a bit and it saved an enormous amount of time and coding effort.
What exactly did you propose using reflection for?
-
Drew
|
|
|
|
|
Reflection is not cheating, it is just another tool in the toolbox. Like most other techniques (inheritance, singletone, etc) it can be used inappropriately, but that is no reason to dismiss it out of hand.
my blog
|
|
|
|
|
hello,
i'm looking for an open source implementation of a user modeling for information retrieval project.
the project is written in c# and the part i'm looking for should create a user profile for a specific web pages google retrieves.
if anyone heard of such an open source code, i'll be more than happy to hear about it.
my email is: kruhd@bgu.ac.il
thankyou,
Doron.
|
|
|
|
|
Hi there!
I want to know if you can help me in two little things.
First of all, I´m trying to put a XML new element in an existing XML.
The new element would be like this <name>C:\deco.mpg</name>
I´m trying to make this with this instructions
XmlElement elem = doc.CreateElement("name");
elem.InnerText = C:\deco.mpg;
node.AppendChild(elem);
but in XML appear like this
<name xmlns="">C:\deco.mpg</name>
How can I eliminate the (xmlns="")?!!!
The other doubt is the following, if I want to create an element and elements inside, for example...
<video>
<filetype>mpg</filetape>
<name>deco</name>
</video>
How can I do this?!!
Thank you very much, Sèrgio
|
|
|
|
|
the answer to your second question is simple create a root element instead a child element by adding properties to the new created element
at hte first question i am not sure bu i thing that is the namespace, there must be an option about it, refer to msdn...
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
The xmlns you should not worry about. It will not affect your XML-related code. If you're worried about it for asthetic reasons, then you should either define a namespace (in most cases, your XML documents should have unique namespaces anyway) or write the raw element using an XmlTextWriter instead, calling the WriteRaw method. Other methods in the XmlTextWriter would also help as well, but you need to read the class documentation in the .NET Framework SDK to gain a better understanding.
For second problem, as the other user mentioned below, just create yet another element like you are now, or use elem.InnerXml propety like so:
elem.InnerXml = "<filetype>mgp</filetype><name>deco</name>";
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi!
How to convert the following VC++ code to C# code,what does the corresponding C# code look like?
HKEY CreateRegistryKey(DWORD *pdwStatus)
{
LONG lResult;
DWORD dwDisposition;
HKEY hKey = NULL;
lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
subkey,
0,
NULL,
REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE,
NULL,
&hKey,
&dwDisposition
);
if(lResult == ERROR_SUCCESS)
{
if(dwDisposition == REG_CREATED_NEW_KEY)
{
*pdwStatus = REG_KEY_CREATED;
}
else if(dwDisposition == REG_OPENED_EXISTING_KEY)
{
*pdwStatus = REG_KEY_OPENED;
}
return hKey;
}
}
|
|
|
|
|
Why bother? Just use the Microsoft.Win32.RegistryKey class. Don't P/Invoke code (like RegCreateKeyEx ) if don't have to. This intrudoces additional security restrictions on your code. Microsoft has already define such methods in the BCL - and our assemblies are fully trusted - using the RegistryKey class I mentioned above.
If you want to learn more about P/Invoke, I suggest you start by reading Consuming Unmanaged DLL Functions[^] in the .NET Framework SDK.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi!Heath,
Thank you for your answer^^.
Best regards!
momer
|
|
|
|
|
Hello,
Can any body help me to add wrap text feature for ListView Control in C#.
In listview, we can not increase the width of the column but not height of the row.
I tried keeping a hidden image control and succeded in increasing the height of the row... but text is not wrapping verically.
The features should be just like..MS Excel Cell.
Thanks
Sundar
|
|
|
|
|
The ListView is not a good replacement for Excel-like spreadsheets. If you want something like that, I suggest a third-party control (not that expensive, really) like FarPoint's[^] Spread&tm;.
In order to draw a ListView how you want it, you have to "reach back" to the native APIs and use owner drawing like with the native Common Controls (because most of the Windows Forms controls - like the ListView - encapsulate the Windows Common Controls). Allen Anderson has such a control - and an article to explain it - at http://www.codeproject.com/cs/miscctrl/aa_listview.asp[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
Thank you for your reply.
I already tried Glacial ListView Control. I dont want complete replacement for Excel Spreadsheet. I have to write a custome control be extending the listview control by adding few features.
I did everything except the Word-Wrapping (Like Glacial ListView Control). If I can add this functionality my job is done.
Have any idea how to add this to existing listview?
Thanks
Sundar
|
|
|
|
|
Glacial ListView is using the existing List-View common control. Like I wrote previously, most of the controls - including the ListView control - are simply encapsulating the native common controls.
If you'd rather do this yourself, either look at the source for the Glacial ListView (that's why it's posted) or read the reference documentation for the List-View common control at http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/listview/reflist.asp[^]. If you're not familiar with P/Invoke (calling native functions in .NET), read Consuming Unmanaged DLL Functions[^] in the .NET Framework SDK, as well as Marshaling Data with Platform Invoke[^].
Again, if you want examples look at the Glacial ListView. While he isn't started with the ListView defined in the BCL, it really doesn't matter. He's still constrained by the Control class and almost everything implemented in that control you can implement because it's all going back to native code. The owner drawing is what you're interested in (specifically the NM_CUSTOMDRAW (-12) message, which you can read about at http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/listview/notifications/nm_customdraw_listview.asp[^]). All of these messages are sent through the WndProc defined by the Control class and overridden by every control in the .NET BCL to provide hooks (like to fire events or draw ornaments on controls).
Everything you need to know you can find in the article for the Glacial ListView as well as other articles on this site about owner drawing .NET Windows Forms Controls (which really is about owner drawing the common controls - just using managed code). I see no reason to duplicate those rather long articles here in the forums.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
Thank you veru much. You have given enough information. Now I can write what I require.
Thanks
Sundar
|
|
|
|
|
When Call a WebMothed, WebService transform data to WebApplication to xml. I want to save web method return data as a xml file on disk. How to do it?
|
|
|
|
|
Your .NET web service client is derived from WebClientProtocol . As such, you can override GetWebResponse , save the XML, and call base.GetWebResponse . For a good design, also define a property to turn this off and on (like Debug ) so that you can build a release library without a lot of code changes. Here's how I'd do it (assume implementation is in your proxy class - never update the class automatically or you'll most likely loose your changes):
#if DEBUG
bool debug = true;
[DefaultValue(true)]
#else
bool debug = false;
[DefaultValue(false)]
#endif
public bool Debug
{
get { return debug; }
set { debug = value; }
}
protected override void GetWebResponse(WebRequest request)
{
WebResponse response = base.GetWebResponse(request);
SaveResponse(response);
return response;
}
protected override void GetWebResponse(WebRequest request, IAsyncResult result)
{
WebResponse response = base.GetWebResponse(request, result);
SaveResponse(response);
return response;
}
void SaveResponse(WebResponse response)
{
if (!Debug) return;
using (FileStream file = new FileStream("response.xml", FileMode.Create,
FileAccess.Write, FileShare.Read))
{
int read = 0;
byte[] buffer = new byte[4096];
Stream s = response.GetResponseStream();
while ((read = s.Read(buffer, 0, buffer.Length)) > 0)
file.Write(buffer, 0, read);
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I know that smallguy78 has written an article on how to create the drag drop icon using a floating form but I would like to know why the internal functions can't be used.
Can anyone tell me why the following call to the windows API always returns zero (i.e. fails)
Here's the OnItemDrag statement:
<br />
protected override void OnItemDrag(ItemDragEventArgs e)<br />
{<br />
TreeView tv = this;<br />
Rectangle tnRect = tv.SelectedNode.Bounds;<br />
IntPtr iRet = SendMessage(hWndTV, (int)TreeViewMessages.TVM_CREATEDRAGIMAGE, 0, htiInsert.Handle);<br />
<br />
bool bRes = WinAPI.ImageList_BeginDrag(iRet, tv.ImageList.Images.Count-1,tnRect.X,tnRect.Y);<br />
bool bLast = WinAPI.ImageList_DragEnter(tv.Parent.Handle,0,0);<br />
base.OnItemDrag (e);<br />
}<br />
This are the Dll Import statements:
<br />
[DllImport("user32.dll")]<br />
public static extern IntPtr SendMessage(IntPtr hWnd, int iMsg, int wParam, IntPtr lParam); <br />
<br />
[DllImport("comctl32.dll")]<br />
public static extern bool ImageList_DragEnter(IntPtr hWnd, int x, int y);<br />
<br />
[DllImport("comctl32.dll")]<br />
public static extern bool ImageList_DragMove(int x, int y);
All 3 API calls fail! Huh?
Has this functionality been disabled? The code is there for C++ programmers but sadly ineffectual in C#. Can anyone throw any light on this?
|
|
|
|
|
Tell us the nature of the failure - i.e. what exception is thrown, the stack trace (if any), and the message - would help.
These should work. Native APIs like the 3 above can be called from C# (or any supporting managed language like VB.NET) using Platform Invoke (or P/Invoke). This requires that you have permission to call unmanaged code, however. With the default permissions granted the various zones on your machine, running code from your local machine is the only zone that will give you this permissions. This has to do with Code Access Security.
More information about your execution environment is necessary.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
i've converted a dateTime to a string using the following:
[datetime].Start.ToString("yyyyMMdd'T'HHmmss");
let's say i've saved this out to a text file and now i'm reading the information back in as a string. how would i then convert this dateTime string back to a System.DateTime object?
thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
If you use the built-in format provider with the switch 's' you get aery similar format to yours above and you can use the parse static method on a DateTime...eg:
<br />
string s = DateTime.Now.ToString("s");<br />
Console.WriteLine(s);<br />
DateTime parsedDateTime = DateTime.Parse(s);<br />
Console.WriteLine(parsedDateTime);<br />
the "S" switch is defined as this format in the Docs:
2002-01-03T00:00:00
yyyy'-'MM'-'dd'T'HH':'mm':'ss (SortableDateTimePattern)
If you really want your own format then you can write your own class which implements IFormatProvider, or inherits from DateTimeFormatInfo.
DateTimeFormatInfo[^]
|
|
|
|
|
Hi all.
I have a feeling there is a very simple solution to my problem, but I just can't figure it out. Here goes: I have a form with a treeview (and a listview with the same problem), where I present different items. I have a context menu connected to the view giving the user the option to, for instance, edit or delete the selected item. The problem is that if the user has selected an item and then right clicks on another item and choose to edit, it's the first item that 'opens' to be edited. I would want the right click to FIRST select the item that was being clicked and THEN popping up the context menu so that the user edits or deletes the item that was being right clicked.
Any tips?
Thanks
/EnkelIk
|
|
|
|