|
Hey, for some reason I'm having trouble trying to figure out what the best practice would be for my situation. Let me explain my situation and then I'll explain where I'm stuck. I'm creating a skinning engine, somewhat like Winamps. It uses xml as the "scripting language", I then parse the xml into objects. Heres a simple XML of what a script might look like...
<code>
<pre> <skin_info>
<name>acDesk Default Skin</name>
<version>1.0</version>
...........
</skin_info>
<element id="main_window" source="main_window.xml" />
..............
<element id="tab_strip" source="tab_strip.xml" /></pre>
</code>
I would then parse the skin.xml into an object called SkinDocument wich has all the info in the skin_info node and a collection of SkinElement objects defined by the element tags. The SkinElement then looks at the source file of the element and parses that into SkinComponents (layers, buttons, etc..).. heres what an element source file looks like...
<code>
<pre><!-- Set the properties for this window -->
<setproperty id="folder_path" value="main_window" />
<setproperty id="size" value="205,437" />
<setproperty id="minsize" value="205,437" />
<setproperty id="transkey" value="255,0,255" />
<!-- Create the border layers -->
<layer id="top"
location="0,0"
width="$WIN_WIDTH"
height="5"
image="top_bar.png" /> <!-- This is a SkinComponent -->
<layer id="left"
location="0,0"
width="5"
height="$WIN_HEIGHT"
image="left_bar.png" />
<layer id="right"
location="0,compute($WIN_WIDTH - 5)"
width="5"
height="$WIN_HEIGHT"
image="right_bar.png" />
............
<!-- Create the title bar buttons container -->
<container id="title_buttons" location="compute($WIN_WIDTH - {$WIDTH}), 5" width="autosize-left" height="autosize-down" padding="5">
<button id="close_button"
width="10"
height="10"
action="CLOSE"
toolTip="Close acDesk"
image_strip="close_button.png" />
<button id="minimize_button"
width="10"
height="10"
action="MINIMIZE"
toolTip="Minimize acDesk"
image_strip="minimize_button.png" />
</container>
<!-- Create the content container -->
<container id="content"
location="5,5"
width="compute($WIN_WIDTH - 5)"
height="compute($WIN_HEIGHT - 5)"
padding="0"
source="$WORKSPACE" />
............</pre>
</code>
So, now theres a little background of what I'm doing. And heres my issue.. I'm going to be creating a UI to work around these objects, IE: SkinForm, SkinProgressBar, SkinPanel, etc.. So I need these objects to be exposed only internally, BUT anyone using this component will need the ability to "hot-swap" skins. They might not have access to the internal library to access these objects. So this forces me to make most of them public. My problem with this is that I don't want users to be able to "screw" with the skin. I don't know what some people might do, and I don't wanna even give them the chance to add SkinElements, SkinComponents, etc... at run time. So what I'm thinking of doing is creating another object called SkinManager wich will act as a wrapper for these objects. Then make all the other objects internal only. The SkinManager would contain only static fields so that it could be accessed across a whole application without having a crap load of instaces being created and alot of parsing going on. My question to everyone is what is the best practice here? Should I make all the object public and trust the user won't mess with the skin at runtime and trust they will create their own manager so that they aren't parsing everytime a skin UI object is loaded, or should I go with the SkinManager idea? Maybe both? Any help is appreciated! Thanks in advance!!!
BTW: This is going be under the GPL license, so anything I do will prolly be changed and made better down the road by someone else
|
|
|
|
|
Ignore those <pre> tags.. I was trying to get the forums to show the xml as code, but yet still allow the use of < and > for html code (ie: <code>)
|
|
|
|
|
|
I'm not using XML Serialization. The only reason I'm not is I don't wanna force skin developers to use a skin creation tool created in .net. I myself perfer to make skins by hand.. I don't use any program to make winamp skins and such, so thats the avenue I'm taking. With that in mind, I think I have decided I'm going to go down both paths. I'm going to make all objects public, but I'm also going to provide a SkinManager class so that there is a global class that can be used to manage the current skin. This will cut down on senseless parsing of the skin xml files and will hopefully make it much faster. My skin objects will all reference the SkinManager object. So I will insure that there is one created. I'm still up for other suggestions tho, so if someone out there has some good ideas on what I should do, that'd be great
|
|
|
|
|
Just because you use XML Serialization doesn't mean that other applications have to use XML Serialization (which isn't limited to .NET; Java has it too, and other platforms do too, I'm sure). XML is XML - plain and simple. It could be generated through some sort of XML Serialization, output as text from an XML writer or even from a plain text writer, or even generated by hand. Doesn't matter, and that's part of the beauty of XML and why legacy systems can support it relatively easy. The data is agnostic to how it's written or loaded.
leppie's suggestion is the common way to do this in .NET because it aleviates the burden of creating objects from XML rather easily, but creating skins doesn't have to be done in .NET.
I suggest searching for "skinning" on this site using the text box below the logo on every page, or even just the 'net. There's a lot of examples - both for .NET and not - that you could learn a lot from.
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 have done that, and Its not a matter of actually doing the skinning, I can do that.. its the actual skin objects. And I am aware of the versitility of XML also. When I was talking about Serialization I was talking about the actual serializing/deserializing of my objects. I'm fairly new to this XML stuff with C#. The most work I've done with XML in C# is just DataSets, DataTables, etc.. I do remember reading somewhere about what you're talking about, but I cannot remember where. Maybe you can elaborate a bit on what you mean?
|
|
|
|
|
What I spoke of about XML is generic - nay, essential - to XML. I recommend you read http://www.w3.org/XML/[^].
You should also practice the use of namespaces, which allow you to scope your elements and, optionally, your attributes similar to how methods and properties are defined for different types. This allows your skins to be extended for custom controls, for example.
If you want a primer to XML in .NET, read Employing XML in the .NET Framework[^] 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]
|
|
|
|
|
aye.. that MSDN article is more along the lines of what i need.. I do understand how to use namspaces and all that stuff, thats not the problem. I have a really hard time expressing my ideas on paper, even tho they make perfect sense in my head, so please bare with me Basically, what I'd ideally like to do is take one of my objects, say SkinElement.. point it to a xml file, have it read that file and fill properties, execute methods, etc.. I just went out this morning and bought "Beginning C# XML" - Wrox Press. After a quick look at the book, I noticed some stuff with Serialization. Using attributes on members to "link" them to the xml file. IE: [XmlAttribute] [XmlElement] etc.. Now, this only talks about the actual serialization of the object. It dosen't really talk about "deserializing" an xml file into the object. Is that possible? Because that would be ideal as it would cut down on alot of parsing
|
|
|
|
|
"Serialization" typically implies "deserialization" as well, since the two go hand in hand. If you read the documentation I linked, XML deserialization requires you to implement a public default constructor (no parameters) and use the XmlSerializer.Deserialize method.
Again, search for examples of what you're trying to do here on Code Project. They do exist, and one such implementation (though it's not skinning, but actual form layout and event hook-ups in much the same way) is called "MyXaml".
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 made a simple application (win app) like wordpad,
when user save information from my app, it will create a new file format (*.abc for example), I would like to register an icon for this new file format
Anyway, when I double_click to this file (*.abc) in window Explorer, my app will automatically open and use this file as usual
Show me how to solve this.
Thankz!
|
|
|
|
|
Read Creating a File Association[^] in the MSDN Library. This is typically the job of an installer, and if you use the Windows Installer project in Visual Studio you can do this easily by following the instructions in File Types Management in Deployment[^].
Some applications will conditionally or unconditionally associate file types when the application starts or options are changed. Media players are a good example of conditionally associate file types with an icon (and, more importantly, their application) because common file types (.mp3, .wav, etc.) can be played by multiple players. The more friendly players allow you to select which extensions are handled and whether or not to enforce those while the application is running. It really depends on whether or not you expect other editors to be able to handle your file type.
To do that, you need to follow the instructions in the first link using the Microsoft.Win32.Registry and Microosft.Win32.RegistryKey classes.
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]
|
|
|
|
|
basically, I want to add the url history of ie, each one onto a new line. here's the code I have written thus far. I am druly bedazzled as to why it won't work. thanks for the help. ps, if you know a better way to add the registry values (all that exist in the registry key) onto new lines in a multiline textbox, that is much simpler than my confusing integers way (the rookie way!) of doing it, please let me know. I don't like being ignorant. anyways, thanks and here's the code:
[CODE]
RegistryKey home_page_open = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\Main");
this.textBox3.Text = home_page_open.GetValue("Start Page").ToString();
//load history into textbox
RegistryKey history = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\TypedURLs");
int repeat = history.SubKeyCount;
int init = 1;
while (repeat > 0)
{
textBox4.Text += "\r\n" + history.GetValue("url" + init.ToString()).ToString();
init ++;
repeat --;
}
[/CODE]
|
|
|
|
|
pyrojoe wrote:
int repeat = history.SubKeyCount
SubKeyCount won't get you the number of URL values, you need ValueCount . A SubKey, as you might guess from other code you've got, is the directory-like path to get to the values you are looking for.
Also, your loop is a little crazy, you need to learn about for loops. I suggest changing your loop to:
int count = history.ValueCount;
for(int i = 1; i<=count; i++)
{
}
Does this help?
Do you want to know more?
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
|
|
hello,
i made a program that contains serveral dll's that are included. But when i distribute my program the client mustn’t see the dll's just a package that contains the dll but is encrypte or something like that. Is this possible??
greetings
Sander
|
|
|
|
|
Gedrain wrote:
when i distribute my program the client mustn’t see the dll's
If the client is paying you money to create these DLLs why shouldn't they be able to see them?
There are tools that will make the .NET assemblies difficult to reverse engineer. Dotfuscator Community Edition is included with Visual Studio, which is a cut down version so you may like to buy the full version if it is not secure enough for you.
Do you want to know more?
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
hello colin,
but the dll's are not mine i just them from another project for example firebird dll drivers. But when i distribute my program i don't find it quit nice that people see that i used firebird dll's so how can i compress them into one file.
greetings
Sander
|
|
|
|
|
So, this "package" you talk about, do you mean you don't want the client to see the DLLs on the hard disk, or just the installer? When you create an installer project it creates an MSI file that you can double click on and it will install the application and all its files and perform any other actions that you need the installer to do. The installer is just one MSI file. Would that be acceptable?
Do you want to know more?
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
i mean on the harddisk not with the installation that is allready in a package
greetings
Sander
|
|
|
|
|
If I had created a DLL (OS or CS) I would probably NOT have you distribute my work in encrypted form.
As a matter of fact, doing so might get you into REALLY deep trouble.
Imagine your customer being sued for illegally using copyrighted CS-DLLs he has not obtained a license for. (CS = Closed Source)
Or you being sued by the FSF because you did not follow the license for an OS product (OS = Open Source).
Being honest works best.
Cheers
Sebs
|
|
|
|
|
well the dll's that i distribute with my program are all open source so that is not the problem. But it just looks better i think.
greetings
Sander
|
|
|
|
|
Hello,
I'm developing a client/server application in C# and Windows Forms. When the user is logged in (in my client application) I want to detect when he hasn't used my application in a certain time (say, one hour) to automatically log him out.
Does anyone have any suggestion on where to begin?
I've tought of a timer? but how do I reset it? o mousemove and click events or in any menu item/toolbar event?
Any pointers will be appreciated!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
|
Umm..that's actually quite a wierd one and may not do what he expects.
I previously thought as you do, but recently I added a tool bar tool in a form that has it's text set to the current date and time in OnAppIdle event on the form. (when the user clicks on it, it inserts the current date and time as text in a text field or selects the current date and time if in a date/time editor etc, also as a side effect I expected it to be useful as a clock when in the full screen form).
If you try that you will notice much weirdness about it, the time display will not update on it's own until you do something in the form (opposite of what you would expect) including the fact that if the form doesn't have the focus it won't process unless you move the mouse around over the form, if you open the form but don't click on a control it won't process, in fact the only thing that is guaranteed to fire OnAppIdle is if you click into an editable control and keep focus there, then it will mysteriously start firing regularly.
Of course this is normally perfect since I use OnAppIdle for updating various things on the form in relation to user caused change of states, but in the case of the timer it might not work very well in practice.
I think what it's doing is interpreting what exactly "idle" means, it's not strictly idle when you're not doing anything on the form.
|
|
|
|
|