|
Thanks, James. I didn't get it to work that way, either, but I tried something else with better results.
I set the build property of each image I wanted to reference to 'Embedded Resource' rather than 'Content'. Then, I used the following routine to grab the icon from the assembly.
public static Icon GetIcon(string iconName)
{
Assembly assemb = Assembly.GetEntryAssembly();
return new Icon(assemb.GetManifestResourceStream("mynamespace.myfolder." + iconName));
}
Note that the case must be correct and the file extension and folder name must be included.
vaMope
|
|
|
|
|
I'm trying to draw a simple ellipse over a bitmap, and the user can move this ellipse with the mouse. And of course, there seems to be a lot of flicker associated with it.
The previous solution was to use a memory based DC (MemDC). What does C# have to solve the flicker problem?
Thanks guys!!
Phillip Davis
www.afix.net
|
|
|
|
|
Where's the dang delete button?
ControlStyles.DoubleBuffering
|
|
|
|
|
well, although i like to store my data into xml style, i find the .net's SOAP serialization is too slow to accept.
To state my opinion i think it better to show you what i am doing. althouth i hate to take up too much space in codeproject.
i write a simple xml schema as example
a schema to describe a book ---- book.xsd
======================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v4.2 U (http://www.xmlspy.com) by nova (RSGS) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="article">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="abstract" type="xs:string"/>
</xs:sequence>
<xs:attribute name="id" type="xs:ID" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="book">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="article" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
======================================================================
a implementation of schema ---- book.xml
======================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v4.2 U (http://www.xmlspy.com) by nova (RSGS) -->
<book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\vcnet_proj\book.xsd">
<article>
<title>first</title>
<abstract>first article</abstract>
</article>
<article>
<title>second</title>
<abstract>second article</abstract>
</article>
</book>
======================================================================
Framework provide a tool call xsd.exe to get a class from schema, I take it make book.cs
======================================================================
using System.Xml.Serialization;
/// <remarks/>
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public class article {
/// <remarks/>
public string title;
/// <remarks/>
public string @abstract;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, DataType="ID")]
public string id;
}
/// <remarks/>
[System.Xml.Serialization.XmlRootAttribute("book", Namespace="", IsNullable=false)]
public class book {
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("article")]
public article[] article;
}
========================================================================
Then make a simple demo to serailize the class ----usebook.cs
========================================================================
using System;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
public class Test
{
book mybook;
public static void Main(string[] args)
{
Test t = new Test();
DateTime time1,time2;
time1=DateTime.Now;
t.DeserializeObject(@"book.xml");
time2=DateTime.Now;
TimeSpan span;
span=time2-time1;
Console.WriteLine("Cost {0}",span);
t.Tell();
}
private void DeserializeObject(string filename)
{
Console.WriteLine("Reading with XmlReader");
// Create an instance of the XmlSerializer specifying type and namespace.
XmlSerializer serializer = new
XmlSerializer(typeof(book));
// A FileStream is needed to read the XML document.
FileStream fs = new FileStream(filename, FileMode.Open);
XmlReader reader = new XmlTextReader(fs);
// Use the Deserialize method to restore the object's state.
mybook = (book) serializer.Deserialize(reader);
}
private void Tell()
{
Console.WriteLine("Dump information");
for (int i=0; i<mybook.article.Length; i++)
Console.WriteLine("{0}",mybook.article[i].title);
}
}
========================================================================
Okay!!
I will show you the effience i meet in my P4 256M pc.
=============================
D:\vcnet_proj>usebook
Reading with XmlReader
Cost 00:00:00.5808352
Dump information
first
second
=============================
Do you think it acceptable? So simple a object cost it almost 1 second to process?
But i find it will not get the time longer when i paste the articles in book element to hundreds more.
What are the .net doing in this second?
|
|
|
|
|
Execute the read more than just one time to get the real amount of time it takes.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I have tried it many time.
Only the first time cost much more almost 3 second. i think it will be caused by some dll or server be loaded or something like JIT in .net.
But in the sequent runs , it cost 0.56 second around.
maybe soap serializer must take so long to prepare for a procession.
I still not use it on somethink like webservice. In that situation 1 second is quite unacceptable i think.
|
|
|
|
|
Maybe you should write this up as an article. You could elaborate a bit more. I'm always interested in unique ideas like this, but you need to compare and contrast a bit more between the strengths and weaknesses of SOAP as opposed to your concept.
"There's a slew of slip 'twixt cup and lip"
|
|
|
|
|
What you have is not SOAP, since SOAP is a specialized version of XML; but thats a minor detail.
What is happening is the .NET framework is creating a class at runtime to serialize the data. This is why after the first time you serialize the class there is a delay; it is creating and compiling code then caching it away.
If speed is that incredibly important search through the DOTNET mailing list archives and see if anyone had figured out how to keep that serializer class after the program has run. I remember some people working on it, they had gotten pretty far with it too. I do not remember when the discussion about it was, but I know it has been since early February.
Hope that gives you some idea what is going on
Just out of curiosity do you see the speed problem with the SOAP formatter? IIRC the SOAP formatter just uses reflection to generate the packet rather than creating a class at runtime.
James
Sonork ID: 100.11138 - Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
I can't find the right function to get the time in C#.
Any one can lend me a hand?
|
|
|
|
|
DateTime structure
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Thank you. Then i can get the time cost in my work...
|
|
|
|
|
I have a printpreview dialog,How can I make it be maximize when it create or set size for?It seems that this dialog do not have those properties?
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
According to MSDN it has the Size property available to it. I don't have a project setup where I can test this though.
James
Sonork ID: 100.11138 - Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
Yes,that exists,but what about Maximize and Minimize?
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Set the WindowState property to FormWindowState.Maximized
James
Sonork ID: 100.11138 - Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
James T. Johnson wrote:
WindowState
I know it James,the point is that I can't find it for PrintPreviewDialog,thats the reason I said it does not exist Have you test it for PrintPreviewDialog?
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
The documentation shows it being there; but Intellisense doesn't....
Oddly enough this compiles and works correctly.
PrintPreviewDialog foo = new PrintPreviewDialog();
foo.WindowState = FormWindowState.Maximized; I still don't know why some items don't appear in IntelliSense, especially when its parent class contains something and its not changed in the sub-class.
James
Sonork ID: 100.11138 - Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
James T. Johnson wrote:
I still don't know why some items don't appear in IntelliSense, especially when its parent class contains something and its not changed in the sub-class.
Me too. Thanks again James.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Hi,
Could anyone suggest how to get a list of SQL servers and a list of databases using ADO.NET?
In VB6, SQLDMO could be used for this, but how it is done in .NET?
Any help would be appreciated.
Thanks,
Denis
|
|
|
|
|
I know how to get the list of database, but list of SQL servers.
It's simply just the following query statement
SELECT name FROM sysdatabases
sysdatabases is located in Master Database.
Please let me know when you get the list of SQL servers ![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
I have a DataView.in some part of my application I I use filter statement to filter it..Then I want to read records in FILTERED dataiview.When I use myDataView.Table.Rows.Count or myDataView.Table.Rows[i][k] it gives me all records not filter ones.
Any suggestion?
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
myDataView.Table refers to the original table, not the filtered data. Just use myDataView[i][k]; .
James
Sonork ID: 100.11138 - Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
wowww,I didn't know it is possible,I have to test it now.
Thanks
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Neither did I, this is the second look I've taken at the DataView class and I just noticed it had an indexer on it (so you can use the myDataView[] syntax).
James
Sonork ID: 100.11138 - Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
I have another question about it,I used myDataView[][] and it was ok.Now How can I return NUMBER of filterd ROW,myDataView[] is index of recordset not row.
Thanks.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|