Diamonddrake 397 Master Poster

splitting the lines up manually is no longer required. dotnet3.5 has the lines array member of the ritchtextbox control. so it works to just call that..

as for the selecting of lines, you can only select using the start number of the charter, so we can easily use built in functions of the ritchtextbox control to do this all for us. I created two variables and hardcoded them to some easy for testing line numbers, but just set thoes values to a number parsed from a textbox or something to get the dynamic effect you are looking for.

Here is the completed working code, assuming you are using a ritchtextbox control, named ritchtextbox1.

int firstlinenumber = 2;//set this to the line number to start selection with.
            int endlinenumber = 3;// set this to line number to end slection with.
            int selectstart = richTextBox1.GetFirstCharIndexFromLine(firstlinenumber-1);
            int selectend = richTextBox1.GetFirstCharIndexFromLine(endlinenumber-1) + richTextBox1.Lines[endlinenumber-1].Length;
            int selectlenght = selectend - selectstart;
            richTextBox1.Focus();//important. you cant select when the
             //textbox doesn't have focus. so focus it before you select
            richTextBox1.Select(selectstart, selectlenght);

important to note: this can be done the same way in fewer lines, just condensed. I tried to spread it out, so it made more sense of how it works. Its important to learn!

happy coding.

Diamonddrake 397 Master Poster

it very well might be that when the cursor is blinking in the box, that it causes a problem, how about in your delegate the first thing you do is change the focus. just fall object.Focus(); on anything else. most likely the button. which would be a good practice anyway since when a button is clicked it leaves a focus ring around itself, this would make it clear to the user that the update occurred, just as if the button was pressed.

Its likely the problem, and its all I can think of with only that information. Just give it a try. I bet you'll be surprised!

Diamonddrake 397 Master Poster

here we go, this isn't perfect but it works. if you find that its not quite fully sorted, just increase the amount of loops in the main for loop. as many loops as strings seems to work fine. that's what I used here.

then here is the sort.

string[] str = new string[] { "kevin", "adam", "zenith", "taco", "brandy", "david" };
            string j;
            string k;
            for (int g = 0; g<=str.Length; g++)//default on as many loops as strings
            {
                for (int i = 0; i < str.Length - 1; i++)
                {
                    j = str[i];
                    k = str[i + 1];
                    if (j.CompareTo(k) == 1)
                    {
                        str[i + 1] = str[i];
                        str[i] = k;
                    }
                }
              
            }

have fun with it.

Diamonddrake 397 Master Poster

NB!!i did not test this code. ihope it works.:)

lol, it infact does not. tons of syntax errors 9 to start out with, not to mention some of the variable paths don't make sense, first thing it does it set the index of the array to an empty variable, then each time set the next string in the array to whatever the last one was. everything is backwards and you are using index character references that are unneeded on the strings. here is a working code example, although it doesn't work well, it just doesn't have the errors.

string[] str = new string[] {"mar", "bab","fas"};//start with
//text that is acutally out of order!

int length = str.Length; // you dont need this variable
string j;
string k;

for (int i = 0; i < str.Length -1; i++)
{
j = str[i];//this was backwards
k = str[i + 1];//this was backwards
if (j.CompareTo(k)==1)//this was all messed up, 5 errors were here
{
str[i + 1] = str[i];
str[i] = k;
}
}

that works, kind of. comparing returns 1 of 3 values, -1 which means it should be before, 0 which means its the same, and 1 which means it should be after. for example, if j.compareto(k) ==1 then j should come after k.

this code leaves out what to do otherwise, but its written in a way to always compare the the next to the current. so it takes care of that for you. but the problem is, …

Diamonddrake 397 Master Poster
public partial class menuBienvenida : Form
{
private short counter=0;
public short _counter
{
get
{
    return counter;
}
set
{
     counter = value;
}
}
private void botonNuevo_Click(object sender, EventArgs e)
        {
if(counter==0)
{
            principal principalForm = new principal(this);
            principalForm.Show();
            counter++;
}
else
         MessageBox.Show(...);
        }
}

then in principal form mod the constructor to keep track of the main instance.

public partial class principal : Form
{
     Form mMain;
     public principal(Form F);
{
        mMain = f;
       
}
   //create an event handler for on close
   private void principal_onClose(Object sender, EventArgs e)
{
  mMain._counter = 0;
}
}

best of luck.

Diamonddrake 397 Master Poster

you need to pass the instance to the constructor of the new form modify the constructor to take a form type variable and assign it to a local variable. like so.

on the job form

Form MainForm;

JobForm(Form MFrm)
{
    MainForm = MFrm;
}

then you can use the "MainForm" variable to get the properties of the main form.

now be sure to pass the instance to the new jobfor using the "this" keyword when instantiating the new form.

JobForm jbf = new JobForm(this);

and that is all you need to know. there is another way, because of the way that the dot net framework works, there is a way to call the clr and get a list of all the public objects open and search for one with the correct name and type, but its complicated, and the best way is that in which I already shared.

happy coding.

Diamonddrake 397 Master Poster

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/68cc6e07-295d-4df2-b74f-0421a6378b47/

This information seems hand, for files, but just for sake of working code, there is a codeproject example that has a demo app with source code of how to drag a url shortcut to the desktop from you application found here

http://www.codeproject.com/KB/cs/draginternetshortcut.aspx

I wish I had more, I have been putting off working this out for a feature in an app I'm working on myself.

best of luck.

Diamonddrake 397 Master Poster

well, technically you can't but you could dynamically load the assembly, get what you wanted from it, then unload it.

Diamonddrake 397 Master Poster

does anyone know anything about oAuth? I can't find a dot net example that works. and the very little documentation on it is way over my head. I'm just trying to add a secure way to update twitter in the client I'm messing around with. But I can't seem to even come close. I downloaded ever example I could find on it. and i haven't seemed to get anywhere, I'm not posting any code on this because I have 4000 lines im not sure about. i get the concept, most of the resources i could fine where just descriptions and metaphors on how it works. I need a better understanding on how its implemented and used. if anyone is familiar with it. please drop me a line.

also note im working toward a windows forms application, not a asp.net page.

Thanks.

Diamonddrake 397 Master Poster

this is odd actually. Most universities have maps already, simply because laws about large buildings having disaster plans. A point that you aren't being clear on, is are you wanting to create a program that is used to draw maps for printing, or are you looking to create a program that is a map with hot spots you could click on for hall directions?

either way, the best way to get started would be to actually draw out a map on a sheet of paper.but then, since you already have that much, you could just xerox it and pass it out.

Diamonddrake 397 Master Poster

the sender object keeps track of what object invoked the event. So just cast the sender to a button object.

Button B = (Button)sender;

then get what ever information from the button that you need.
example

B.Text//returns text on button
B.Name//returns name of button
Diamonddrake 397 Master Poster

Here is some great text on the matter:

http://en.wikipedia.org/wiki/Constructor_(computer_science)

Diamonddrake 397 Master Poster

It is possible just to create a public method in the form and call it from the panel. though it makes the panel easier to reuse in other forms when you use an event. i'm not sure exactly how he was passing his data between the form and the panel, but another benefit to using an event is you can create a custom event args class, and pass any information you need to your event handler. This would prevent you from needing to create a large amount of properties to send information back to the form.

but in this case, either one would seem to work equally well.

ddanbe commented: Think your solution is better : custom event args... +6
Diamonddrake 397 Master Poster

Im not sure that this question has to do with threading at all... it seems you need to create a custom event in your panel that your form subscribes to. that just tells the from that its done calculating, and just move the code from your FORM's click event handler to the custom event handler method on the form that handles the custom event that is fired when the panels mouse click events code is finished. easy huh lol. Im not 100% on how your code works, so the code I am posting is for referenced only. I can't garantee you can just past it in to get the desired effect. but then again. it will probably work fine.

so in the PANEL you would create a custom event like so

//create delegate for event
        public delegate void panelClickerHandler(object myObject,
                                     EventArgs myEvent);
       //expose delegate for subscription
        public event panelClickerHandler OnPanelClicker;

and add a event throw at the end of your click event.

private void MapEditorPanel_MouseClick(object sender, MouseEventArgs e)
        {

            Point mapCoordinates = getMapPointFromScreen(e.Location);
        
            Tile tileClicked = map.getTileFromPoint(mapCoordinates);

            activeRow = (tileClicked.Row);
            activeColumn = (tileClicked.Column);

             //throw event to notifiy subscribed objects that we are 
             //done here

              OnPanelClicker(this, EventArgs.Empty);
        }

ok. so now we need our FORM to be subscribed to that event. and its clicked event should not be used in this case(I think, im not all that sure how your appy works.)

so we subscribe to the event.

//as I am unsure of your panel instance …
Diamonddrake 397 Master Poster

you could create a dummy file, a little text file or something that serves no purpose but to encourage the creation of the folder, but other than that, you might just have to wait for a new version of VS to fix that.

Diamonddrake 397 Master Poster

If you just want to copy an empty folder, it won't work, but if the folder contains files, you can right click in the soution and click create new folder, then copy your files in explorer to that new folder in your project directory, then go back to your solution and right click on the folder and click add existing, then select the files that are already in that folder, this will add them to your solution under that folder, expand it and select them, you get the copy to output option then, and if you choose to always copy, then it will create the subdirectory and fill it with the files.

Diamonddrake 397 Master Poster

The problem with cosmos is very few people are actually working on the project. and its not truly C#. it just coded in C# and the user kit translates it to a native language. all that said. fine and good. the REAL current drawback, is you are just about limited to console applications. So if you want to turn you desktop in to a $900 calculator that gives "smart a$$" answers then you are game on. but for piratical purposes. its out. not optical support, limited network. its like your own personal dos... kinda.

Diamonddrake 397 Master Poster

if you are looking for a simple solution to just showing a string if you find a place on the desk top that you want it. change your form's borderstyle to none, and its topmost property to true, its startup postion to manual, then just pick your spot for its location. like maybe center screen at the top. it will stay there, always visible, unmovable, and can display any information that you want.

another much more aesthetically pleasing solution would be to create an application that runs on the task bar. or in the background. whatever. and register a hotkey that your system doesn't use much. say F10 or something. then create a simple little notification window. that when the user hits your hot key, a little window pops up for 30 second or so, or until you want it dismissed, via a button, or whatever. and it can share any information you need.

best of luck.

Diamonddrake 397 Master Poster

copy to output directory just makes a copy of the selected resource where the program is compiled to. It has no real significance other than keeping you from having to manual find and copy files to a single location.

if you need a sub directory in the same directory as your application. you are best off checking if it exists, and if not, creating it programmatically. Its simple and effective.

Diamonddrake 397 Master Poster

static... doesn't have to be instantiated, lives in a static class, and can be called at any time by just the method name.

static class classA
{

public static void dosomething()
{
//method that does something
}

}

intance methods live in a class that must be referenced and constructed...

public class classB
{
   classB()
{
//constructor
}
public void dosomething()
{
 //method that does somthing.
}

}

an instance of the class that contains it would have to be created as an object and the method it contained would be referenced via the object variable you created.
ex.

classB clsb = new classB();
clsb.dosomething();

simple. google it next time.

Diamonddrake 397 Master Poster

save as should do it, if it doesn't work then there may be a problem with your links. But as for quicktime playing your media, its because its the default plugin. open the options menu in firefox and click the applications tab. a list of web file types will appear with the codec that will play them. simple browse for mp3 file format, and change its default behavior to "always ask" and it will ask if you want to play it, or download it. respectfully everytime.

best regards.

but also. I don't think this post belongs in this thread of the IT forum. Be careful where you post your questions.

Diamonddrake 397 Master Poster

I would like to add this is an odd inquiry.

a Beginner would simply be anyone, who has written any code at all, with intention of continuing to learn.

Intermediate would be someone who can write and finish a simple application from scratch with only a reference book, or web search for assistance, or a complicated application with only a moderate amount of questions and direct assistance.

experienced, even more simple, If you are accustomed to the syntax, understand the base classes, are comfortable with the compiling tools that you use, and that you have written complete applications that are usefull with a good error handling.

and as for expert, its just a sillly word, It means one who has special skill or knoledge in a particular field. so generally speaking, if you know something about the language that most other programmers don't (immediate beginners excluded) you are technically an expert.

but it doesn't matter what category you are in, any one here can learn something from anyone else. That is the benefit of a forum. were people from different skill levels can come together and share their knowledge, everyone sees a problem differently. and comes up on different solutions. That the reason why each country has its own language. thats the reason there are so many reply's to this post. I don't think its something to worry yourself bout, the only pratical application of this information is building a tutorials website where the tutorials …

Diamonddrake 397 Master Poster

Well maybe they will. I find it unfortunate when a solution has been found, and a thread isn't marked solved. Its much easier when browsing for answers to look search for only solved threads.

Diamonddrake 397 Master Poster

Works perfectly now, thanks again.

No problem, if you could, mark this thread solved.

Diamonddrake 397 Master Poster

this is only a problem in the login form, because you will need it to be able to exit the application in the event that a user cannot logon, but the form needs to close when you do log in, but there is a simple solution.

Just create a bool variable, that will tell your close event if its being closed because you logged in successfully...

//create a variable with the full class scope.
private bool exitClose = True;
//edit the form closed handler to check for flag
 private void frmLogin_FormClosed(object sender, FormClosedEventArgs e)
 {
if(exitClose == True)
{
            Application.Exit();
}

 }

then just set the value to false if the login is successful like so

//Open Main CRM Form
                    CRMMain crmMainForm = new CRMMain();
                    crmMainForm.employee = employee;
                    crmMainForm.Show();
                     exitClose = false; //prevent the app from closing
                   this.Close();
Diamonddrake 397 Master Poster

you need to call the close() method from inside the login form's code...

just add the line to this section

//Open Main CRM Form
                    CRMMain crmMainForm = new CRMMain();
                    crmMainForm.employee = employee;
                    crmMainForm.Show();
                   [B]this.Close();[/B]//this will cause the login form
                   //close  after the main form is opened

otherwise you would need to pass the instance of the login form to the main form in order to reference it to close it. your code actually creates a new form, never shows it, but then closes it.

what is unnecessary, but you could do in that way would be make these changes...

//Open Main CRM Form
                    CRMMain crmMainForm = new CRMMain([B]this[/B]);
                    crmMainForm.employee = employee;
                    crmMainForm.Show();

then in the main form constructor reference that for a close like...

public CRMMain([B]Form lgfrm[/B])
        {
            InitializeComponent();
           [B]lfgrm.Close();[/B] 
        }

best of luck :)

Sailor_Jerry commented: Helped correct my code +4
Diamonddrake 397 Master Poster

This is actually a bit more tricky then its given credit. The problem is, when you run your first form, that is, in the program.cs file, you call Application.Run(new Form1); //or whatever the log in form is called.

It then becomes responsible for the thread, if you close it. Then the application exits. so if you want to Close the login form when you are done with it. your application will exit. To keep this from happening you have multiple viable solutions. you could run the main form (the one that will accept the login information) then hide it, and have it call and create the login form. then simply pass the data into the main from when the login is closed.

or, you could create the login form manually in the Main() method, then call Application.Run() with no args, and when you close any forms or all the forms, the program still runs, and then just create an event handler for you main form for onclosed and call Application.exit();

Now for something a little more advanced, you could created an applicationContext class, that would create all your forms for you, and run them in the pattern of your choosing, then pass that class to your Application.Run(ApplicationContext); method.

These are just some ways to handle it, there are more, but when it comes down to it. Its which ever best suits your application. But either way, its very important to remember, just because visual …

ddanbe commented: Closing the main form can be tricky, you explained why,thanks! +6
Diamonddrake 397 Master Poster

the problem was less the ability to drag and drop, which he already knows how to do, but it was to have an image following the mouse. Just making a copy of the bitmap in memory isn't going to display it on the screen. although copy() may get used in the actual "drop" code. Its not relevant to the original question, which was how to get an image to follow the mouse, without moving the original picturebox that contained it.

Diamonddrake 397 Master Poster

no problem. sorry for the messy code, I knew you could figure out what was going on in it. when I started it I just was messing around with several ways it could be done not intending to show it, so it got kind of sloppy, I'm sure you noticed but I even took a short cut and threw the class that builds the image form right in the same cs file as the main form.

Best of luck friend, and as always, happy coding.

Diamonddrake 397 Master Poster

Im not sure how much clearer i could be, so I am just going to repost your code, with the modifications that fixes the issue.

private void cmdSales_Click(object sender, EventArgs e)
        {
           [B] backgroundWorker1.RunWorkerAsync(this);[/B]
            timer2.Start();
        }
        private void timer2_Tick(object sender, EventArgs e)
        {

            TimeSpan ts = DateTime.Now.Subtract(startDate);

            string sTime ="  ..." + ts.Minutes.ToString("00") +

               ":" + ts.Seconds.ToString("00") +

               ":" + ts.Milliseconds.ToString("000");

            toolStripStatusLabelTime.Text = sTime;

            if (toolStripProgressBar1.Value ==

                toolStripProgressBar1.Maximum)

            {

                toolStripProgressBar1.Value = 0;

            }

            toolStripProgressBar1.PerformStep();

        
        }
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {

     //get instance of main form from eventargs
     [B]Form formInstance = (Form)e.Argument;[/B]
            
toolStripStatusLabel1.Text = "Loading ... " +

                 "Thanks for your patience";

            frmSales objfrmSChild = frmSales.GetChildInstance();
            //set mdiparent to instance passed to dowork event
           [B]objfrmSChild.MdiParent = formInstance;[/B] 
            objfrmSChild.Show();
            objfrmSChild.BringToFront();

        }
        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            toolStripProgressBar1.Value = 100;


            toolStripStatusLabel1.Text = "";

            toolStripProgressBar1.Value = 0;

            timer2.Stop();

            toolStripStatusLabelTime.Text = "";
        }

Happy Coding

Diamonddrake 397 Master Poster

I think you mean if a picture file on the harddisk is replaced by a different one, you want that picture in your program to change as well... Correct? maybe?

Diamonddrake 397 Master Poster

I have posted an example of what I was talking about, I just used that codeproject alphablendform and created a form that inherits from it, used a mousemove to set its position. But inorder to pass the click from one form to another, I had to use a mouse_event interlop to tell windows to release, then click again, without you actually have to do so. I added a picture box, set an image to it, then used some basic stuff to set the positon of the new form over the old text box, told it to create a thumbnail form the image, just incase its a zoomed picture, set the size of the new form to the size of the text box, set the dpp of the image to match requirements, and used bitmap.maketransparent to ensure it has a transparent region require for such a thing, this could all be done a better way, and is not error proof, its all just poped in for sake the demonstration.

the VS2008 project I included has the "debug" prebuilt in the bin folder, give it a try, just click and drag the image I included of a cupcake, it will pop out, be lightly transparent, I used 200 out of 255. and it will follow the mouse til you let go, in which case it just closes the new form. but you can do whatever you want, have it call a function in the main form passing where the mouse was …

ddanbe commented: Thanks for the effoet you put in! +6
Diamonddrake 397 Master Poster

If you are looking for that firefox style drag image, where a "ghost" like copy of the image moves about the screen. I believe a good way to go about it is on drag, to create a new form, topmost, that's window property is set to none, and just set its size to the picture's size, draw the image on it. and have it move with the mouse until the mouse is released, you will get a nice floating image, that can move over anything on the form and even off the form if the use decides to drag the mouse that far. And if you really want a good effect, use a layeredwindow, since you need no controls drawn on it, just an image, it would be an easy fitting solution that would allow for nice transparency so the users could see what's under the image, and also still see the image they are dragging.

not to say that's the best method.

alternatively, to get a copy of the image to drag just across the form, you would need to create a new instance of the control, with the same attributes and have it move, and the other control would have to stay put.

If you want a good look. although it would be very complicated. My first suggestion of a new form, would probably be best. here is an example of what i mean

http://www.codeproject.com/KB/GDI-plus/perpxalpha_sharp.aspx

Happy Coding

Diamonddrake 397 Master Poster

should just have to set their dock property to fill...

Diamonddrake 397 Master Poster

the control housing form of my context menu's mouse leave event was never being fired, still isn't. but the layered window overlay form for it's mouse leave event is being fired. I am using a heavily modified version of the codeproject example of the autoformtranformer control, It has been heavily worked over by me to make it fit everything I need it for, but essentially it has a control that drives from a panel, you set it to fill, then you create an image with an alpha layer, where you want your nice transparent edges on the outside and then you cut out a hole in the middle for your controls, set that image to the background and the control makes that image a new layered window above your form locking them together to move at the same time, and recreates the region of the main form to fit in the hole. but then the leave event is fired when you enter the hole, which is were the controls are held so I imported the getCursorPos user32 method and with some an ifstatment loaded with pointtoscreen conversions on some points. I come up keep track of if the mouse was inside the hole ore outside the form

//Create point to hold mouse position
        Point defPnt = new Point();
        //get cursor position
        [DllImport("user32.dll")]
        public static extern bool GetCursorPos(ref Point lpPoint);
        void m_lwin_MouseLeave(object sender, EventArgs e)
        {
            GetCursorPos(ref defPnt);

            Point P = new Point(2,2);
            Point PW = new Point(98, 0);//width of …
Diamonddrake 397 Master Poster

when you call the runworker method pass to it the instance you need

backgroundWorker1.RunWorkerAsync(this);

then in the dowork event handler extract that instance to a variable casting it to the type that it is, an instance of a form.

Form formInstance = (Form)e.Argument;

Thin just pass that instance on to your new form

objfrmSChild.MdiParent = formInstance;

easy as pie :)

happy coding

Diamonddrake 397 Master Poster

that does in fact work, not yet raising the question about how mousing over controls calls the leave event and checking if it containsFocus will keep it displayed until you focus somthing else then reenter and leave the child form

That works great on a new project containing just 2 forms, one as a main and the other as a faux contex menu. but when using layerd windows, this doesn't seem to work at all. I am going to try later to see if I added a mouseLeave event to the layered window form as well as the control form under it as well might do something, but as its all very complicated Its unclear how it will react.

I will post back when I have something, Thank's for the help. I didn't think about testing it in a new project to see if it was a conflict with something else I did, but of course it is. hopefully I can get this one resolved.

Diamonddrake 397 Master Poster

I created a timer in the deactivated event that calls close and it works, but i have to use a boolean to find out if its the first time its called because it calls it as soon as its created for some reason.

also, I have one of the buttons on the context menu form call a method on the main form that creates a new dialog window, and for some reason it opens and closes immediately for what appears to be no reason.

the function is a
mydialogwindw mdw = new mydialogwindow();
if(mdw.ShowDialog() == DialogResults.OK)
{

}

but the window closes imediatly after opening...

breakpoints aren't helping, because I can't seem to keep extra deactivated events from firing when the break happens.

Ideas anyone?

Diamonddrake 397 Master Poster

I have written a flashy custom context menu using a new form with layeredwindows for my application, I want the context menu form to close when the mouse leaves the form, or when its deactivated. But I can't seem to get it to happen. I have tried the Close() method in the deactivated event handler, in the Mouse leave event, in the form leave event. I'm just not sure how to go about it.

i tried to create a nativewindow class that would watch for the capturechanged message and close the form, but the form never receives that message.

Any pointers or workarounds?

Diamonddrake 397 Master Poster

if you pass the instance of the main form to the background worker then cast it to a form, you can then easily pass that instance to the new form. Simple stuffs, Background workers take an object as a argument in the doworkeventargs, just pass it in, then pull it back out.

no need for anything complicated here.

Diamonddrake 397 Master Poster

I tested the example on some stubborn avi files I have, some of which that use an open source version of aac3 audio and divix for video, they worked fine. I downloaded some random avi files from piratesbay. music videos and stuffs, they all worked fine. I can't seem to recreate any issues with that example, the only problem I found is that sometimes the frame count is missjudged and leads to an object didn't return and instance of an object error, but that's at the end, and all file creation seems to be fine.

There may be a issue with codecs on your computer that cause the problem, there is a free program called GSpot, that will analize a video and tell you if you have the proper codecs installed. I recommend you find and download that program to make sure its a software problem and not something to do with the video files themselfs which could be corrupted, or codec issues.

because as i said. No issues myself with the codeproject example you used.

Diamonddrake 397 Master Poster

This is just a quick step through, it doesn't seem to be a very good method of going about whatever this is for. This method depends on some preexisting instances of objects and variables so I just translated it the best I could Its not guaranteed But im rusty on my VB. but it didn't look like it would have worked the way it was, but then again, it relies on preexisting objects so its kind of confusing.

//create method that accepts bbjVSSVersion Object Instance
private void VSSHandler_BeforeCheckIn(objVSSVersion Item)
{
//set a preexisting variable to false
shouldTakeVersion = False
//Create a for each loop to look through each item in a collection
foreach(objVSSVersion OBJVSS in Item.Versions)
{
//there seems to be unreachable code, because you set should takeversion to false, the use a condition to check if its true, and it never will be
check if shouldtakeversion is true and substring the text to find out if the first 10 characters are the word production
if(shouldTakeVersion && OBJVSS.Label.Substring(0,10) != "production") || (OBJVSS.Label.Substring(0,10) == "production")
{
   //note there is a capitlization difference in your strings, I left it the way it was
//now if any conditions were true
intProdVersion = OBJVSS.VersionNumber;
//if conditions met exit the loop
break;
}
//check if it starts with the string production and if it does set variable to true
            if (OBJVSS.Label.Substring(0, 10) == "Production") 
                        || (OBJVSS.Label.Substring(0, 10) == "production")
            {
                shouldTakeVersion = true;
            }
//end of loop
}
//end of function
}
Diamonddrake 397 Master Poster

You could consider using a background worker thread, but its not really needed for something like this, call This.Refresh(); to refresh the controls on the form, that should do it, but if your methods use loops, try calling Application.DoEvents(); in the lengthy loop it will allow your form to process win messages sent to the application and allow it to paint as well.

Diamonddrake 397 Master Poster

I have a transparent panel control, I don't use double buffering because they clash, and it also interferes with some other controls that I am using. On my panel I have 9 buttons, I have written code to remove a button on its click event, and then move the to the right of the removed buttons all to the left to take the place of the removed button via a slide in animation style movement. I wrote a class that takes the end position, the start position and the amount of steps and moves the buttons using a timer, so to allow the program to handle all its events. I call refresh()in the tick as well on the panel and It works fine except it looks kinda bad, jittery kinda, just doesn't look smooth. Im using a stout machine so I know its not my ability to process it.

It there some standard to doing this kind of thing, would I get best results calling refresh on the panel, or the entire form? I have tried both, and it appears the same to me. But I'm not sure what programmatically yields less work on the system with the desired result.

some other stuff to take into consideration,
the form is actually 2 forms, one that is a layeredwindow for crisp transparent edges, the other, my actual form for holding controls. all the button controls contain images and text and are flat style. the form contains a gradient …

Diamonddrake 397 Master Poster

The problem with the *.avi extension, is that its not definite. It could be compressed with any codec. and not even large software companies grantee 100% playability on video files. avi is tipically an mpeg-4 video format file, but could be many other codecs, ajpg which is a jpeg video format, it could be huffyuv, or bmp or any of the first set of wind-98 included codecs. or it could be DIVXmp47 which will require divxmp47 codec installed to play. you never know what codec you need for the video or the audio in an avi file, its often two completely different unrelated codecs. Its most likely that the trouble you had with the first example was a codec issue, just because WMP will play a file doesn't mean the codec is properly registerd or doesn't require wrapping to be used with managed code.

Video codecs is a deep rabit whole, so the next question really is, do you want to try and find out what went wrong with the example you found, which could be a inconsistency on your system due to codecs, or do you want to start custom building codec graph wrappers in managed code, because its unsupported directly? so I guess its the blue or the red pill eh? Either way, play to pull out a copy of graph edit anyway. Just to be on the safe side. you can see all the codecs installed on the system. build a graph that works with the …

Diamonddrake 397 Master Poster

Using a csv file would only be a good choice if the program would allow for multiple users, or for multiple sets of data, or on a portable media such as a flash drive and you wanted to be able to save settings and data together for load when necessary.

the C# system settings located in the properties namespace actually saves the preferences in the user folder on the harddrive, C:\Documents and Settings\User\Local Settings\Application Data\programname\exename and identifiing data\buildnumber\user.settings

and is very simple to use, automatically creates the file on run if the system lacks one. and the data stays persistant. So even if it was a standalone app. and you were running it off a flash drive, as long as its used on the same computer and the same user. The settings would load.

So, in most cases. I agree with ddanbe. the properties.settings method is the best and easiest way to go about something simple like this.

ddanbe commented: I'm just a simple guy, your knowhow is unquestionable! +5
Diamonddrake 397 Master Poster

In C# events are handled in a fashion where their are "publishers" and "subscribers". the "publisher" must define and fire the event, and all subscribed objects (which can be any object) will handle that event.

Delegates for an event typically accept 2 params, the object that fired the event, and the arguments to be passed to the event handler.

exmpl

public delegate void boolChangeHandler(object sender, EventArgs e);
public event boolChangeHandler boolChanged;

boolChangeHandler is the name of the delegate, sender is the object that fired the event. EventArgs is defined under the System namespace. boolChanged is the name of the event, which is published to the Subscriber

now in the code on the object that raises the event, we can create a private virtual method to fire the event, that will first check to make sure that there are subscribers, and if not. then don't fire the event

protected virtual void OnboolChanged()
            {
                if (boolChanged != null)
                {
                    boolChanged();  // Fire the event!
                }
            }

and now to call the event
just calling

OnboolChanged();

would fire your event in all your subscribers, but as for checking for change in a Boolean value, Im not sure of the best way, But you could use something like this

private bool checkBOOL(bool theBool, bool theHolder)
{
    if(theBool != theHolder)
      {
        OnboolChanged();//fire event
        return theBool;
       }
    else
       {
         return theHolder;
       }
}

and just put a call to that method inside a timers tick event with some …

Diamonddrake 397 Master Poster

here it is, this, being a modified version of a code project has only the original license, I choose not to add any additional licenses.

I wish you the best in your programing endeavors, and please do remember to mark this thread as solved when you are satisfied.

Happy coding

Diamonddrake 397 Master Poster

ok, I have edited the example that comes with the download you linked me to to support a background thread that supports cancellation. It works perfect. Turns out with that code several things had to be done, the whole framegrabber object needed to be created in the new thread,(which is what I was trying to get at before) also the paths needed to be passed to the thread by and object. the preview image needed to be passed as a progress object argument and set via the progressed changed event. a check had to be added to the loop that extracts the frames to check for a cancellation. and since cancel and grab will never need to be pused at the same time, I simply added a switch to make them the same button.

This is the entire class from the project edited. replace the entire class in your project with this one, or just edit it to match. If you have any questions just ask. remember to add a background worker and set its event handers to the ones I added to the class.

This code is tested and effective, if you need a VS2008 Example. I have it and can post the finished working code if need be.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using User.DirectShow;

namespace FrameGrabberTester
{
	public partial class Form1 : Form
	{
		//private FrameGrabber fg;
        private string pathFILE;

		public Form1()
		{
			InitializeComponent();
		} …
Ramy Mahrous commented: Done well! perfect. +7
Diamonddrake 397 Master Poster

i was just saying, in that code,
FrameGrabber.Frame and picBoxFrame.Image
both refer to objects from the originating thread. you can't access them directly from the worker thread. that's a cross thread exception.

These classes would need to be instantiated in the worker thread, or at least that is my understanding of threading. which I have used recently on 2 projects.