|
I have a custom control which inherits from Windows.Forms.Label - it adds some field and properties which enable the user to draw a color border around it. In the OnDraw method i first call base.OnPaint, and then draw the border. It has a disadvantage - some text may become covered by the border. Is there a way to avoid this? I can draw the text myself in a smaller rectangle than the client rectangle, but then I loose the control's ability to dynamically wrap the text. Help me!
|
|
|
|
|
Try to make the text aligment in the middle horizontal of the label
|
|
|
|
|
Yes, it works, bu I want to be able to have all the remaining styles to choose from. Any other options?
|
|
|
|
|
Just don't make the custom border so thick .
|
|
|
|
|
Hi All,
I'm having a problem with TraceSwitches. When I create one it doesn't seem to read the values from the XML .config file and nothing gets logged. Here's what I have done:
1) I've created a TraceSwitch:
static public TraceSwitch Logger = new TraceSwitch("TDLog", "Application Log");
2) I created a file stream:
FileStream filestream = new FileStream("c:\mylogfile.log", FileMode.Create);
3) I've created a <b>TextWriterTraceListener</b>
private TextWriterTraceListener _logfile = new TextWriterTraceListener(filestream);
4) I've added the TextWriterTraceListener to the Listeners collection:
Trace.Listeners.Add(_logfile);
5) I've also set up a .config file to give startup parameters to the TraceSwitch (the config file is called: myapp.exe.config since my app is called: myapp.exe. Here is the contents o my .config file:
<configuration>
<system.diagnostics>
<switches>
<add name="TDLog" value="4" />
<trace autoflush="true" />
</switches>
</system.diagnostics>
</configuration>
When my app run the Trace Level is initiall set to OFF dispite the fact I set it to verbose explicitly inside the .config file. For good measure I've also added a #define TRACE in the top of my .cs file to no avail. Any ideas on what I'm doing wrong ? Thanks in advance...
-Pete
|
|
|
|
|
Hello All,
I have several COM components that I reference. Unfortunately, they are referenced at a rather low level of the solution, which makes strongly naming the projects within the solution difficult. I have seen a couple of "work around" ways to strongly name those COM components, which enables me to strongly name the rest of my project. I was wondering if anyone had a good suggestion as to the best way to strongly name referenced COM components.
Thanks in advance for the advice,
Ryan
|
|
|
|
|
I have Labels controls with some properties set in an ArrayList. I want to be able to easily qrite and read it from a file. Is Label serializable or do I have to mess with it's properties, store them as strings and use o lot of string handling while reading it from a file? Is ArrayList serializable?
|
|
|
|
|
Why don't you try? It should be.. as it derives from Control , and Control has SerializableAttribute attribute, and I don't see Inherit=false anywhere - so derived classes (e.g Label ) should be seriazable
Anonymous wrote:
Is ArrayList serializable?
dunno... look at MSDN.com, search for ArrayList ... if you see [Serializable] as attribute in class declaration, than it is forshizzle serializable.
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
Yes to both. You can figure the answer out yourself for other classes by looking to see if the base classes implement ISerializable or have a [Serializable] attribute.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Contrary to what dnh and Marc say above, Label s (or any other Control s) are NOT serializable. ArrayList s are serializable, but how much success you have depends on whether the objects contained inside are serializable.
Take a look at my article Themed Windows XP style Explorer Bar[^] for a way to get around the "Control s aren't serializable" problem. Also, it's probably wise to read what MSDN has to say about serializing[^]
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
I need to do something like the following. The problem occurs because the Class library doesn't recognized the "CMainForm" class. I can make things compile and work if both classes are in the same file but I need them to be in separate files.
I can't use the "namespace" directive because the CMainForm class isn't a DLL/library.
Any help would be greatly appreciated.
Carol
File #1. EXE
---------------------------------------------------------
namespace ExampleCode
{
public class CMainForm : System.Windows.Forms.Form
{
}
}
File #2. DLL
---------------------------------------------------------
namespace MyClassLibNamespace
{
public class MyClassLib
{
CMainForm m_MainForm;
public CFactory(CMainForm MainForm)
{
m_MainForm = MainForm;
}
}
}
|
|
|
|
|
Sorry. I had a typo in my initial code. here's the same code with a minor correction:
File #1. EXE
---------------------------------------------------------
namespace ExampleCode
{
public class CMainForm : System.Windows.Forms.Form
{
}
}
File #2. DLL
---------------------------------------------------------
namespace MyClassLibNamespace
{
public class MyClassLib
{
CMainForm m_MainForm;
public MyClassLib(CMainForm MainForm)
{
m_MainForm = MainForm;
}
}
}
|
|
|
|
|
Add a reference to your dll in the IDE and then place them in the same directory and they will work.
|
|
|
|
|
hi,
you have to add reference to your aplication (to reference assembly in which CMainForm is defined) - because they are two different projects. Hope I won't make idiot from myself when I say you can reference .exe (.NET assembly) - in case you can't then* move your CMainForm to class library... you can then reference library in your application. (right click in project explorer ->Add reference->project tab) - or like that.
* just checked, you can't add reference to anything but .dll
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
I have a dillema: I am writing 2 programs, and among others they use some classes which are the same. I have two choices: copy the cs files to them both, or create a Dll with them? Is it possible to do so? How? Thanks in advance!
|
|
|
|
|
It's possible...
Create a class library project...put your code into it...compile it, then reference the assembly in your other projects.
|
|
|
|
|
Ok, but what means "reference the assembly"?
|
|
|
|
|
Right click on your project in Project Explorer (if you have VisualStudio(.NET) - if not, read documentation to your IDE) and select "Add reference" Then there should be tab "from project" and list of your projects in solution.. select your class library and double click or something (I don't have VS opened now) and you should add reference to your library ( = assembly)
hope it helps.
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
I have a DLL I wrote that uses a web service. I set the 'Web Reference URL' to dynamic. I see in the app.config file that the value is present.
My problem is when I compile the DLL the config file is not generated.
Question #1: Is this normal behavior for a DLL.
Question #2: Could copy and rename the app.config file to '<assemblyname>.dll.config' and the DLL use it normally?
Any help would be greatly appreciated!
Thanks in advance!
I reject to reality and subsitute my own!
- Adam Savage, Mythbuster
life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
|
|
|
|
|
There are no config files for .DLL's like there are for applications (app.config.) Any settings code you write would be looking at the host application's config file, whatever that may be.
And your signature should be fixed:
I reject your reality and substitute my own
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
Any settings code you write would be looking at the host application's config file, whatever that may be.
I thought that to, but it doesn't seem to be true. So I guess the only true way of doing this would be to modify the Web Reference source file and modify it's constructor to require the URL to the web service. The only problem with this solution would be when you update the web reference then this file would be recreated and the changes would be lost.
As for my signature, the quote is correct as stated. Pay close attention to the opening of Mythbusters.
|
|
|
|
|
Why don't you have your own .config XML file, and access it like XML file not like config file? e.g. with XPath document... or am I missing something badly??? (I admit I more read that sig/quote part )
jklucker wrote:
As for my signature, the quote is correct as stated. Pay close attention to the opening of Mythbusters.
Yeah you won[^]
Looks like you are both wrong, guys... Dave with quote and you because you misspelled word "substitute" ;P
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
You are right I can create my own config file and access like XML. I was looking to use the app.config functionality that System.Configuration.AppSettings gives us access to.
I like the google fight, I never heard that before. I'll have to remember that.
It just goes to show how spell checkers are relied upon.:->
I reject to reality and subsitute my own!
- Adam Savage, Mythbuster
life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
|
|
|
|
|
Im making a game, but i need to give different objects different depths, y'know so you could walk BEHIND a tree or something.
I just need to know how you do it.
With game making software (which im not using right now)
You can give the tree a depth of 50 for example and the guy a depth of 60, the guy would walk behind the tree right. Or if the guy had a depth of 40 he would walk infront of it.
So any ideas?
I also would like to know how to have a window that follows the character around a larger room, this is necessary because i cant fit the whole of one 'room' on the screen and you need to be able to see what your doing, so any info on that would be good to.
|
|
|
|
|
This could be answered in many different ways depending on the technology you're using. GDI+? Windows Forms? DirectX's Direct3d? Managed DirectX? DirectX's DirectDraw? OpenGL? A 3rd party 3d engine? A 3rd party 2d engine?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|