Diamonddrake 397 Master Poster

Thanks Ryshad, I didn't think about using enum.parse, that is a better solution than what I come up with, of course the real take for me was the set method, witch I figured out a good solution for, my goal was to only allow setting specific heights, so even in VS if you drag to resize the control it jumps to the closest compatible height.

Thanks again for the suggestion.

Diamonddrake 397 Master Poster

I just finished another Hue Slider control. This time it is a custom drawn Photoshop Hue slider clone, the only difference was I intentionally made the arrow a little bit larger, It always frustrated me how small the arrow was, I like a larger click region.

I am working on the Saturation and luminance clones as well, and when I have completed them, i will release them with code under a noncommercial license.

Tell me what you think :)
included in photo, My custom hue slider control, and the photoshop clone slider control.

Diamonddrake 397 Master Poster

It wouldn't download for me... I didn't see a link to dload after I clicked on the link in the post.

Its rapidshare, its an awful Idea. a website that anyone can host files on, but you have to wait for a minute countdown on the page after clicking a button, before it gives you the option to download the files. just another silly business Idea.

Diamonddrake 397 Master Poster

If a program is written in any .net language it can be decompiled via reflecton, most commonly the free tool from reg gate the dotnet reflector.

but, I don't think anyone here is interesting in helping rip off the work of a fellow programmer, also, I checked. that program is obfuscated, So it cannot simply be decompiled with the reflector.

Diamonddrake 397 Master Poster

thanks also diamonddrake for the quick reply but i prefer the solution antenka found because i do not need to draw a whole new arrow i just call base.drawarrow and presto fresh arrow

yeah. its a much simpler solution.

Diamonddrake 397 Master Poster

very simple solution, just use GDI+ to draw a new arrow :)

at the end just throw in

//e.Graphics.FillPolygon(Brushes.Black, new Point[]{new Point([I]x, y[/I]), new Point([I]x, y[/I]), new Point([I]x,y[/I])});

specify the points as needed. since you only pass 3 points you get a triangle, if two points have the same Y value, and the third point's x value is half way between the first 2 X values then you get a downward facing arrow, which I think is what you want.

now Im not sure what look you were going for so I didn't put in any values here, but I am sure if you are custom drawing your own controls you will be able to figure out the points yourself.

Best of luck. :)


Alternatively, the actual reason that the arrow isn't drawn is because you override the method that calls the method that draws it. called "drawarrow" from the base class, here is an excerpt from the code on the link that Antenka posted above me.

class MyRender : ToolStripRenderer
{
protected override void
OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
{
base.OnRenderSplitButtonBackground(e);
ToolStripSplitButton item = e.Item as ToolStripSplitButton;
base.DrawArrow(new
ToolStripArrowRenderEventArgs(e.Graphics, item, item.DropDownButtonBounds,
SystemColors.ControlText, ArrowDirection.Down));
}
}
Diamonddrake 397 Master Poster

You aren't technically posting in the right place, that appears to be a asp.net question written in C#, there is an asp.net forum here at daniweb for that. you might get better help there.

the error states your code should have the <%runat="server"%> tag.

but it could also be that you didn't name your button with the "name" property, and also your click event code is incorrect. the correct syntax for adding a button click event in C# is button1.Click +=new EventHandler(button1_Click); but I cannot be sure, as I don't frequently use asp.net, my web server only supports classic asp. and I write C# forms applications.

best of luck.

Diamonddrake 397 Master Poster

As less of a discussion answer, and more of a poke at a simple explanation.

header files are a type of include. so when you need some functionality in your program you don't have to start from scratch. Some code is available to start with, and when you program is compiled this is compiled into your application. So it has no prerequisites.

in C# you do the same thing. except you only reference the code that is already available, that code is the .net framework.

my opinion is C++ is better because it makes more portable applications, but C# is my favorite language because its very powerful yet easy to learn and understand.

in C# you want to write a line to console you use the console class of the System library. System.Console.Writeline("blah"); the system library is part of the .net frame work and is installed on the client computer prior to your application.

in C++ if you want to write a line to console you first include the header ostream, then you pass to the output variable the "cout" the text you want to show on the console, cout<<"blah"<< endl; . when the program is compiled, a copy of the ostream code is included in the executable needing no preexisting library.

So its practically the same thing, just if C++ looses its headers, then it will just be unmanaged C#... and who wants that? not me.

Diamonddrake 397 Master Poster

setting any variables as public is considered no longer acceptable in 3.5. because in theory the variable could be attempted to be read from or written to at the same time crashing the app, now you can still do it, the get and set methods are built into .net that let the variable call check if its beeing accessed and wait if it is.

also, setting an objects reference to static is used so that if multiple usergamecontrol objects existed, that object would have the same values throughout all the instances. it should only be used if multiple objects of the same type are expected to always have the same value as the other instances... as far as I can tell, no a static reference isn't a good idea here. just set it to public should be enough, and a property to expose it would technically do the same thing, just be more modern object oriented programming.

glad you got it working!

Best of luck.

DdoubleD commented: good follow up +3
Diamonddrake 397 Master Poster

Sorry, I don't have much time to reply right now. but the reason that the "this" is throwing an error is because using "this" in the context I provided needs to be within a function and not directly in the class.

so you would have to create a variable to hold the instance directly in the class

MindMasterColourForm ColourForm;

then inside a method of some sort, for example the load event of the usergamecontrol create the instance and pass the "this" argument

ColourForm = new MindMasterColourForm(this);

sorry for the confusion. if you are still having trouble I will come back later and try to explain better and maybe post an example project to show you how it could work.

Diamonddrake 397 Master Poster

Apparently up on terms of properties, constructors, and passing references...

you almost got it. the first code chuck i presented was an example of how to set a private control accesible by a public property, you would need to substitute in the type and private control you wanted to expose, in the example I used type of panel, and a non existant panel called mypanel.

the 2nd 2 were actually cut and paste working code.
since in your usergameControl you created the colorform, you tell it which instance of the usergamecontrol you want to access.

in the last codebit I created a variable of type usergamecontorl to hold the reference of the instance to the control. and the public MindMasterColourForm(UserControlGame ucgParam) part is where you capture that "(this)" reference and then its set to that variable we created.

now ugc is a variable that refers to that usergamecontrol instance in all of your color form, so you can access all the public properties using ugc.Proptertynamehere and you set the controls you need availabe using the first code block I posted about creating public properties...

sorry I can't explain better I am actually in a big hurry... best luck and happy coding.

Diamonddrake 397 Master Poster

ok, first thing you need to do is set all the controls you need access to from the outside as properties.

example

public Panel thepanel
{
get
{
return mypanel;
}
set
{
mypanel = value;
}
}

this will let objects see your controls and access them easily.

then all you have to do is pass a reference to the usercontrol to the constructor of the color form like so

MindMasterColourForm ColourForm = new MindMasterColourForm(this);

then catch that in the constructor of the mindmastercolourform

UserControlGame ucg;
        public MindMasterColourForm(UserControlGame ucgParam)
        {
            InitializeComponent();

           ucg = ucgParam;
        }

then when you need a control from the colourform you can access it via its property like so

ucg.thepanel.Location.X;
//or whatever you want to do with it.
Diamonddrake 397 Master Poster

Sorry papanyquiL, apparently I should reload my tabs more often, I had this tab open an hour before I got around to answering, lol, I guess I am over multitasking...

Below is the almost identical answer as above lol, and daniweb doesn't have a delete button, just an edit.

You have a while loop going, its looking for qty to be -1. since your loop never changes the value of qty. it is allays whatever it was set to during read-line, which happens before the loop is created.

since qty is never set to -1 its just going to loop forever.

obviously you just want to check first if qty is -1. so you are better off just using an if statement.

static void Main(string[] args)
{
int qty, prodNum;
double totalRetail;

Console.WriteLine("Enter product number 1, 2, or 3. ");
prodNum = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter in quantity sold of this product or enter -1 to quit: ");
qty = Convert.ToInt32(Console.ReadLine());
totalRetail = 0;
if(qty == -1)
{
Console.WriteLine("Exiting app...");
return;
}

switch (prodNum)
{
case 1 :
totalRetail = 2.98 * qty;
break;
case 2:
totalRetail = 4.50 * qty;
break;
case 3:
totalRetail = 9.98 * qty;
break;

Console.WriteLine("Total Sales: {0:C}", totalRetail);
}

}
}
}

try this instead.

Diamonddrake 397 Master Poster

create a lineargradientbrush and on the forms paint event fill the clientrectangle spluah!

protected override void  OnPaint(PaintEventArgs e)
        {
 	      base.OnPaint(e);

          using (LinearGradientBrush lgb = new LinearGradientBrush(this.ClientRectangle, Color.Blue, Color.Black, 90f))
          {

              e.Graphics.FillRectangle(lgb, this.ClientRectangle);

          }
        }

don't forget to add the namespaces:

using System.Drawing.Drawing2D;
using System.Drawing;

have fun!

Diamonddrake 397 Master Poster

Ok, the simple solution is to have your program save the embedded resource swf movie to disk if it doesn't' already exist. then pass the path to your load movie function.

more importantly, instead of using the loadMovie function, the appropriate way to load a flash movie is using the axShockwaveFlash.Movie property.

now using that there is a more complicated way to go about it, if you set embedmove to true, when the program is ran, it will embed the movie into the control itself. so the movie is playing from memory not disk. unfortunately, this happens at run time and not compile time. although I heard that some people have found ways to make it work.

for now, stick with answer 1.

sknake commented: well said +15
Diamonddrake 397 Master Poster

the image returned will be the same size as the rectangle it was cropped from, not the original image, as for any other problem. you might want to look at how the cropping rectangle is created.

The code you have posted looks sound, there is no reason why it shouldn't work, aside from the croppedAreaRectangle. that's probably where the problem is.

Diamonddrake 397 Master Poster

OK! overriding the height works fine when bound to an enum so long as you do some checking to make sure the values set to it follow the values in the enum. Here is an example of how I did it.

//create height enum
        public enum ContorlHeight
        {
            Short = 36,
            Normal = 40,
            Tall = 50
        }

        [Bindable(true), Category("Appearance"),
        DefaultValue(typeof(ContorlHeight), "Normal"), 
        public new ContorlHeight Height
        {
            get
            {
                if (base.Height < 38)
                    return ContorlHeight.Short;
                else if (base.Height >= 38 && base.Height < 46)
                    return ContorlHeight.Normal;
                else
                    return ContorlHeight.Tall;
            }
            set
            {
                if ((int)value < 38)
                    base.Height = (int)ContorlHeight.Short;
                else if ((int)value >= 38 && (int)value < 46)
                    base.Height = (int)ContorlHeight.Normal;
                else
                    base.Height =  (int)ContorlHeight.Tall;

            }
        }

now when I drag the resize handles in visual studio, it jumps to the closest setting.

thanks for all the help sknake. Lots to do before its officially finished. but I am well on my way. Just lots of cleaning up to do.

Diamonddrake 397 Master Poster
Button B = this.Controls[buttonname];

That should work for what you are looking for.
or you could add each control to a list and access it that way, I can think of a lot of ways, but this is the simplest.

ddanbe commented: As Einstein said: "Keep it simple, but not simpler" +13
sknake commented: most reliable way to go about it +15
Diamonddrake 397 Master Poster

Yeah, I haven't yet learned the art of obfuscation yet... so maybe not.

I changed the inherit from UserControl to Control and and it still worked fine. I then was able to override the Height property successfully.

I could then even easily just set it as a type of my enum. but that led to the problem that all my code that does calculations will have to be changed to cast the enum to an int. and I think I use the height in calculations 20 or 30 times.

and I have no idea what effect it will have on the designer, I will have to look into it. but that is after the movie, thanks for all your help sknake!

Diamonddrake 397 Master Poster

Im hesitant to release the code... I kinda want it to be unique to my application for a while, before I release it upon the world, that and the code's current state is horrible, I use a lot of hacky looking code, and I probably have 800 lines commented out. not really ready to be shared.

I can post a sample exe with the control in it. so you can see that it does infact work. I'm headed out to the movies now, I will do it when I get back. I just don't want all my messy code out right now.

It inherits from UserControl. which seems to cause some problems, I can't acually use new Height. it gives a compiler error and doesn't show up in intellisense.

should I not inherit from UserControl? but instead Control? or completely from scratch???

I would love to hear more about your system of custom user controls sknake.

also, I currently have an extra property called ctrlheight that is bound to an enum. so when you set it it jumps to the predefined heights, but when you just set the height, or drag it in the designer, it stays whatever size you set it too. and I don't like it.

also, just a little tid bit of knowledge on the control, the hue spectrum is drawn in GDI+ as well, so the control is all code and do binary images or resources of anykind.

Diamonddrake 397 Master Poster

I like the idea, but I would like to see an enum for the height. could that be done?

so the height property would no longer be a int, but an emum.

pubic enum ControlHeight
{
    short = 18,
    normal = 25,
    tall = 40
}

public enum ControlHeight new height  --?
{
  get??

set
{
//I know this is wrong, but idk what to do.
   base.height = ControlHeight.Value;
}

}

any Ideas how this could be done, I realize all this code is BS, but how could I achieve this?

Diamonddrake 397 Master Poster

Pretty :)

The top one looks a little funny on the far left. It looks like the area to the left of the slider knob is a "stop" of some sort. It looks like a block to me.

I'm not 100% sure what you are referring to.
but if you mean how the top of the slider knob covers a pixel of the spectrum in the backcolor on either side, then yeah. I couldn't figure out how to stop that from happening.

if the control is on an image, then a pixel of the image shows through there. but an easy fix was to keep the control sized where the hue image doesn't extend above the knob at the point where it has a curve.

but when the control is too tall it happens anyhow. because the knob is currently a fixed size.

also if you drag the knob to 0 there is a ugly blocky explosion of pixels behind the knob I can't see any reason or solution of that.

any ideas would be great.
also, if any one knows how to give a control a fixed height, that would help here, or maybe attach it to an enum that only allows like 3 variations like (short, normal, tall).

and thanks for the compliments. I have worked hard on it.
I have plans for a more compact version as well, and eventually an entire library of custom drawn controls.

Diamonddrake 397 Master Poster

Thanks Ramy I have put a lot of work into it so far. I added a little gloss to the top of the color spectrum. I think maybe now its complete... In the final product I think I will put a property to disable the gloss effects.

Still open to suggestions.

Diamonddrake 397 Master Poster

I have been working on a custom Hue Slider, when you drag the knob the color of it changes to its hue value. (ex 0 is red). I added a little gloss to the knob, I feel its not done, I Just don't have any Ideas as to how to give it finishing touches...

any ideas people?
I would like it to look a little more professional.

image attached:

serkan sendur commented: good question +9
Diamonddrake 397 Master Poster

Oh yes! I forgot to answer the "official" question about diagonal lines! lol

ok here's the dig, pixels don't have to be square! they can be rectangular!
but as far as images in .net 3.5 are concerned, there are only square pixles. (even if you have a funny screen resolution and the pixels are stretched, they are still offically square in a .net Image)

to test this just check the horizontalResolution and VerticalResolution of the image, you of course will get 96 for both, showing you that the pixels are square. This means, using our rule, that a line 300 px long drawn on a new bitmap will always be 3.125 in long on paper, REGARDLESS of what direction it goes, be it vertical, horizontal, diagonal, 10 degrees or 70 degrees!

Best of luck!

sknake commented: excellent answer +14
Diamonddrake 397 Master Poster

Welcome my friend to the most complicated question you may have ever asked. but I am here to show you the way!

First off, all drawing in GDI+ is done based on pixels... now that means nothing to a printer, because of a little concept called pixel density! better known as dots per inch, or! DPI!!!

now DPI varies from display to display. and according to printer settings! so in theory, if your printer was set up to directly print whatever you sent to it... and you drew a 300 px line, and printed it at a 300 DPI you would then have a 1 inch long line!

but wait!!! that means every picture you printed off the web would look like a postage stamp! YUK!!!

that's because we forgot about resolution... now the resolution of an image is how many Pixels there are in any given unit of measurement.
standard web resolution is 72 pixels per inch. so if your line is 300 px wide, and the printer is set to a DPI of 300 the actual print size on paper would be approximately 4.2 inches!

now to keep things looking consistent printer drivers scale images based on their resolution and DPI, so images of the same pixel size always come out the same size on paper, they just look better with more dots. so ignore the target printer DPI settings in your battle to create print graphics.

you need to focus …

Diamonddrake 397 Master Poster

Glad i could help, and as for the padding, just place the control the distance from the anchored sides that you want it to stay, and then the anchor property handles it for you , it will stay the same distance from the anchored edges at all times.

Diamonddrake 397 Master Poster

ok lets jump off this dock.

the X and Y properties of a location type cannot be set directly. so no you can't set them that way.

the "anchor" property should do what you want, but only if the position of your controls is set prior to the setting of the anchor property. ( in code execution order)
that looks something like this. Control.Anchor = AnchorStyles.Top | AnchorStyles.Right the control.Right property is "get" only. that means it tells you the distance in pixels from the right edge of the control to the right edge of the parent control, you can't set it because its actually just a calculation, it doesn't point toward an actual variable. it looks something like this...

Public Int string Right()
{ 
get
{
     return (this.Location.X + this.Width) - this.Parent.Width;
}
}

So setting it will fail.


you can also manually stick a control to the top right corner using the forms on resize event, but the anchor property does just fine.

ddanbe commented: Good explanation! +13
Diamonddrake 397 Master Poster

I just wanted to mention, if you still were having troubles with this you could look into the class drawreversibleframe, is what is used to draw selection rectangles, so long as you are only drawing rectangles it will draw on top of controls. although you don't get definite choice of color...

Diamonddrake 397 Master Poster

Nevermind I got it sorted out. Its really a beautiful control... I can't seem to get a true transparency. But I figured out enough to get things looking well.

Diamonddrake 397 Master Poster

I am writing a custom slider control, All its functionality is accounted for but now the aesthetics (which was the reason for writing it in the first place) has become problematic.

It starts with a custom class that converts true hls and rgb, thats 360 stops not 255. then I have a class that loops through all 360 stops and draws a vertical line on an image, this gives me a 360px wide hue rotation image.

I then create a new bitmap, and draw on it a rounded rectangle using a texture brush with the first image. So now I have 360px rounded rectangle image.

i draw this image on my control starting at 1/4 from the top and ending 1/4 from the bottom, so centered in my control is the rounded hue rotation image. I have the userpaint flags and the allow transparent backcolor flags set and the back color set to transparent. but since the parent control is a transparent panel, and behind that is an image, I get a gray box.

I need to fix this...
but why do I need the padding around my image, why not just cut the region and be done with it you say? glad you asked.

the 2nd problem that helps cause the first problem is the actual handle for the slider. the handle is a usercontrol that is custom drawn as well, it has rounded corners and a gloss, its color is depended on …

Diamonddrake 397 Master Poster

Its not in a class, the method has to be interloped from shell32.dll

here's an example on codeproject http://www.codeproject.com/KB/cs/iconhandler.aspx

Please try and search google for answers before posting questions in our forums. they tend to get crowded with links to codeproject or dream in code.

Diamonddrake 397 Master Poster

thanks... I'll try this one, but could I make a my own without creating "private string removedDup(string s)" like this? thanks a lot..

if you didn't want it to be a method, you could easily just remove that part, start with a sting called s and the final product here is declared as final.

Diamonddrake 397 Master Poster

please keep in mind that we are not apt to giving out free code. but this is so simple it only took me 3 minutes to write it.

private string removedDup(string s)
        {

            string[] allnumbers =s.Split(new char[] { ' ' });

            List<string> cutnumbers = new List<string>();

            foreach (string num in allnumbers)
            {
                if (!cutnumbers.Contains(num))
                {
                    cutnumbers.Add(num);
                }
            }

            string final = "";

            foreach(string ss in cutnumbers)
            {
                final += ss + " ";
            }

            return final.Trim();


        }

just a simple method, pass to it a string with numbers separated by spaces, and it returns a string with numbers separated by spaces. That simple.

Diamonddrake 397 Master Poster

do you need to worry with the order of the numbers? if not you could easily work with the numbers as strings. split them into an array by the space, create a destination and list and loop through them, if the dest list doesn't already contain the value, then add it.

pretty simple.

Diamonddrake 397 Master Poster

Creating a web browser from scratch is an amazing feat, its hardly ever done by one programmer and a simple tutorial wouldn't cut it.

but if you really want to, a good place to start would be learning to parse HTML. this could be done several ways, but the problem is finding a fast way to do it. regular expressions just wouldn't cut it. plus this entails that you have a complete and in depth knowledge of HTML in the first place.

a good web browser is going to need to be able to parse html, dhtml, javascript, ect. Then when it comes to secure pages there's a whole new and complicated headache.

I guess if you were really serious about it you have 2 ways to get started. you can get the source for the actual webcontrol from .net and read up, or you could download the source for firefox and start transalting it into C#.

Best of luck.

Diamonddrake 397 Master Poster

That's interesting sknake, I never would have thought of catching the close method like that.

But as far as all these answers go, the Simple response is the X button does only call the form to close. and however you catch that close call, either by wndproc or by a simple form closing event, the trick is to set a flag, just a simple Boolean variable, if its true, cancel the closing and handle your business, if its false, do nothing and allow the form to close.

when you need to call this.Close(); first change your variable. else you can create a public method for your form called DoClose() or something and change the flag there and call close, its up to you.

ddanbe commented: Simple things are often the best! +12
sknake commented: Thats what I would do +14
Diamonddrake 397 Master Poster

I would also like to point out that the code sknake posted is a "per machine" list of installed programs, some programs are installed on a "user" level and would not appear in this list.

also most MSI installed applications won't appear in this list either. I am not sure where they are all stored. But this method is no longer considered a solution.

serkan sendur commented: nice attendum +8
sknake commented: good addition +14
Diamonddrake 397 Master Poster

Alright! I figured it out. I modified your deserialize method to return a list of custom objects contains just the extra data members that will be marked in the extendedbutton control class that way I can loop through them and create my buttons form them. I used all concept code because I don't like practicing in my real projects but I decided I would post the result for learning purposes for future visitors to the site.

Thanks for everything sknake! without your help I'm not sure I could have done it.

modified deserialize method.

public static List<extrabutondata> DeserializeObject(Stream s)
        {
            XmlSerializer ser = new XmlSerializer(typeof(List<List<NameValuePair>>));
            List<List<NameValuePair>> lst = (List<List<NameValuePair>>)ser.Deserialize(s);

            List<extrabutondata> extralist = new List<extrabutondata>();

            for (int i = 0; i < lst.Count; i++)
            {
                extrabutondata o = new extrabutondata();


                PropertyInfo[] properties = GetProperties(o);
                foreach (PropertyInfo pi in properties)
                {
                    NameValuePair nvp = FindInList(lst[i], pi.Name);
                    if (nvp != null)
                    {
                        pi.SetValue(o, nvp.PropertyValue, null);
                    }
                }

                extralist.Add(o);
            }

            return extralist;
        }
// and example type class it uses
    public class extrabutondata
    {
        public extrabutondata()
        {

        }
        public string name {get; set;}
        public int number { get; set;}
    }

Thanks again! that's another Daniweb form post solved by Sknake!

Diamonddrake 397 Master Poster

because the buttons are not predefined. they are created dynamically by a user. I can't hardcode them. they will have to be added to a list upon creation. then multiple instances of this class will need to be serialized.

I can't seen any other way to do it besides serializing a list of lists!

am I wrong?

Diamonddrake 397 Master Poster

Thanks for the reply!

what i meant was, your serializer/dematerializer methods accept an object. but that object is expected to be a class with members, I need those functions to accept a list of objects. not just an object.

I can't seem to figure out how to get it to work right. I got a result, but the XML file is then fairly confusing and for some reason the resulting XML file's objects are always backwards, as in the last object in the list is first in the xml file.

public static void SerializeObject(Stream stream, List<object> objlist)
        {

            List<List<NameValuePair>> newObjList = new List<List<NameValuePair>>();
            
            foreach (object o in objlist)
            {
                PropertyInfo[] properties = GetProperties(o);
                List<NameValuePair> lst = new List<NameValuePair>();
                foreach (PropertyInfo pi in properties)
                {
                    lst.Add(new NameValuePair(pi.Name, pi.GetValue(o, null)));
                }
                newObjList.Add(lst);
            }
            //now I have a lists of lists right? now what do I do do I serialize each one separately then add the resulting stream to another serializer? I'm kind of at a loss. this serialization thing is new to me.

            //or would I just serialize the list of lists and this actually work? like?

            XmlSerializer ser = new XmlSerializer(typeof(List<List<NameValuePair>>));
            ser.Serialize(stream, newObjList);
        }

note, code is modified from the code you posted previously.

and as far as the deserialzing such a thing. I can't even get started.

-->a briefing of my final goal is to have a bar of dynamically created buttons with special values that need to be saved. then when the app opens …

Diamonddrake 397 Master Poster

idk about authentication, but I have done much heavy scripting in flash, as far as I know, if a flash application is not scripted to accept external modifications of its variables. then you won't be able to.

but I could be wrong. if the variables are on the root of the flash movie, then its possible to use query strings or params to change them, but in that case your C# application would need to be showing the flash animation in a webcontrol, and not as a com object.

MOST important, there are sometimes 3 problems with what you are trying to do.

1. a well written flash game will be comprised of many different swf files, and need to be ran from the same directory.

2. a well secured flash game will check its domain for consistancy, and choose not to run unless its in its home.

3. some games use shared resources, in which multiple swfs must be loaded on screen simultaneously.( I one time saw a flash game that used the site logo from the site's header flash, and if they weren't on the same page the game would fail to load.)

best of luck.

ddanbe commented: Good explanation. +12
Diamonddrake 397 Master Poster

if you can keep formatting when you paste into your text box, its a richtext box.

inorder to save and open ritch text formatting to a ritchtext box you must you richtextbox.SaveFile(). and richtextbox.LoadFile() receptively.

not just read and set its text property.

Diamonddrake 397 Master Poster

static methods are used when you will need to access a method from many different classes or forms, you wouldn't want to create an object every time you needed that method. and you certainly wouldn't want to retype or copy and paste the same method into every class you needed it in.

an example would be the static method "Show" from the static class MessageBox.

when you need a messagebox, you just call a static method to show it. ex.

System.Windows.Forms.MessageBox.Show("some message");

if it weren't static, you would first have to create an instance of the class that contains it it would be like

System.Windows.Forms.MessageBox MB = new System.Windows.Forms.MessageBox();

MB.Show("some Message");

now wouldn't that suck?

it can have other purposes but that's the deciding factor for me.

Diamonddrake 397 Master Poster

depends on what you consider a reference, a temporary one using reflection is the one only way without using a reference at design time.

here's an example
http://mahiways.spaces.live.com/Blog/cns!6A1F270FEA8CDD8C!338.entry

serkan sendur commented: nice idea +7
Diamonddrake 397 Master Poster

If you are asking if Visual Studio will do if for you no. It won't and doesn't support a "circular" reference.

you can alternatively achieve this through reflection. But you won't have all the neat perks visual studio would normally give you with a design time reference.

I would suggest if its possible to redesign 2 projects to not need such a thing.

Diamonddrake 397 Master Poster

I know this has been handled... but after reading through, why go so complicated? why not just use a timer control?

seems odd to create a new thread for the sole purpose of sleeping it.

Diamonddrake 397 Master Poster

Scott you never cease to amaze me! This is some great code, let me ask so questions to make sure I got it.

these Bindingflags allow you to tell the serializer to only serialize the public members declared in that object, not the inherited members?
--if so this is awesome.

and could this be modified to serialize a list of classes?

from what I can follow the data is saved just as pairs of property names and the values of each, so multiple objects that have the same property names... just not sure how I could handle that.

Thanks!

Diamonddrake 397 Master Poster

In my project I had been using a set of arrays to hold some data, realized it was a bad design, so then I decided to create an object that holds all the relevant data, and add them to an arraylist, this work great except all the data was information that extended a complicated dynamic button. So then, since the button was a custom user control anyway. I just added the fields i needed to store to the button class its self and everything was simple and right with the world.

then I come to the problem of saving the date, XML serialization is the method of choice, but I have a problem, This would want to save ALL the public properties of the button, not just the custom ones, so I ask.

Is there a way to denote that just these X amount of properties be serialized without going through and overriding all the properties in the base class and and adding a bracket that asks for it to be omitted?

alternatively, say I created a class that just holds my data properties and had my button class additionally inherit from that. giving it those fields, would there be a way to just serialize the members gained from that 2nd inheritance? (since # only supports 1 baseclass I refer of course to a linear inheritance) even still I just don't think this is the solution, I just don't know how to go about this, Other than …

Diamonddrake 397 Master Poster

not even that complicated. if your control inherits from Control, or UserControl just throw this code in the constructor of your controls.

this.SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | 
    ControlStyles.AllPaintingInWmPaint | ControlStyles.SupportsTransparentBackColor,
    true);

feel free to remove any of those flags you want, the OptimizedDoubleBuffer is the one that does the magic, of course all the others help make things look nice too. but the transparentbackcolor you might not need in this instance.

.net then handles all the double buffering for you, of course you could do it manually, but why bother when .net does it for you.