Diamonddrake 397 Master Poster

This is an interesting solution, I hacked up something to do this one time example here http://www.daniweb.com/forums/thread194234.html. But I like your way of handling it a bit better.

Diamonddrake 397 Master Poster

That's a good point, but its my personal site and the only authenticated user will be me. I just wanted a non web.config way of storing my username and password.

If I were really serious about it, since my hosting doesn't support mysql, I would use an access database, But I have recently gotten into using XML file to store all my data for my site and I'm very happy with it so far.

Diamonddrake 397 Master Poster

Alright, Thanks.
The part i didn't get was calling authenticate. Turns out that's not what creates the cookie. The trick was calling FormsAuthentication.RedirectFromLoginPage. That's what authorizes the user. That's where I were confused.

I have seen it done that custom memebership providers were created, and I had it in my head that this was the only way to do it. But apparently calling FormsAuthentication.RedirectFromLoginPage Does all the magic.

thanks, That 4guysfromrolla's a good read.

Diamonddrake 397 Master Poster

I am kinda new to asp.net. I used asp backing flash for most of the site work i have done, but I have shied away from flash and I am having some issues understanding asp.net membership.

I am currently using the web.config file to set the credentials for forms authentication. I would like to store the member credentials in an xml file, but I can only seem to find examples on the net about how to store the credentials in an sql database. I could create my own authentication system using session variables and xml. But it is mentioned all over the net that this is frowned upon.

So how do i save member information in a separate xml file? and if I do. is there a difference in how I authenticate a user?

I would like to also point out that I am using a webserver that supports only asp.net 2.0

Diamonddrake 397 Master Poster

what depends on the video type.

but the idea would be to create a page that contains the activex control you want to play the video with, or a much better idea a flash video player. and pass to that page the video url. Write a javascript that gets tells the flash video player where to stream from. And go from there.

Of course I can't help you an further because this is a big project, and more importantly it sounds illegal. (unless theses are home movies)

Diamonddrake 397 Master Poster

I never use windows media player active x controls, so im not 100% certain.

course if you are starting the next song, why do you enable the play button?

What is the PlayList2 ? does changing its node set the mediaplayer currentmedia?
if not, then you need to set the current media of the mediaplayer to the nodes's value.

For any further assistance we need more code. I can't see the whole picture here.

Diamonddrake 397 Master Poster

Glad you got it working the way you wanted :)

Diamonddrake 397 Master Poster

I am not familiar with that console app, but passing arguments is as simple as.

CurrentProcess.StartInfo.Arguments =  @"-ip 192.168.1.1";
Diamonddrake 397 Master Poster

If you look closely. Console1 is a custom control that derives from textbox. The redirect standard output needs a stream. The Console class redirects text from the stream to a textbox, and vise versa. The console control code from that project is as follows.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace RedirectStandardOutput
{
    public class Console : TextBox
    {
        public Console()
            : base()
        {
            this.Multiline = true;
            this.KeyPress += new KeyPressEventHandler(Console_KeyPress);

            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
        }

        private void Console_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (InputStream != null)
            {
                if ((int)e.KeyChar == 13)
                {
                    InputStream.WriteLine();
                }
                else
                {
                    InputStream.Write(e.KeyChar);
                }
                InputStream.Flush();
            }
        }

        public void Start()
        {
            this.Text = string.Empty;
            if (OutputStream != null)
            {
                MethodInvoker readOutputStream = new MethodInvoker(ReadOutput);
                readOutputStream.BeginInvoke(null, null);
            }
        }

        public void ReadOutput()
        {
            int value;
            while ((value = OutputStream.Read()) != -1)
            {
                Invoke((MethodInvoker)delegate
                {
                    this.Text += (char)value;
                });
            }
        }

        public StreamWriter InputStream
        {
            get;
            set;
        }

        public StreamReader OutputStream
        {
            get;
            set;
        }
    }
}

That is your problem. you are trying to use use a standard textbox to eat the stream, And that is not quite how it works.

Diamonddrake 397 Master Poster

That soundplayer class in the system.media namespace is basically an interlop class that calls this very api. There's nothing wrong with using it. The reason it doesn't work appears to be the command strings. But the link ange1ofD4rkness posted is a great code snippet and if you search the DaniWeb C# code snippet library there are at least 3 code snippets for playing sounds there.

Good luck.

Diamonddrake 397 Master Poster

how you get find what you are looking for.

Dare I say that anything you find in firefox's source code would be a far fetch to use with the native .net webbrowser control. But if you find anything useful. Please do post it for the community to learn from.

Diamonddrake 397 Master Poster

You could easily create a cs file to match your needs dynamically and save it to a temp file, pass the file-name to csc.exe then delete the temp file. That's one possible way.

Diamonddrake 397 Master Poster

you could also call the .net C# compiler from your application details here http://msdn.microsoft.com/en-us/library/78f4aasd%28VS.80%29.aspx

Diamonddrake 397 Master Poster

well I don't have time to work out a solid solution for you. I assume you intend to replace the context menu with your own. I think that the honest best solution for this would be to get a hold of the creation of the context menu and filter out the objects you don't want. But that's advanced and requires a bit of unmanaged code. Similar to the process of adding context menu items to explorer items.

Sorry I can't be more help.

Diamonddrake 397 Master Poster

Also, from the code I gave you. using the webbrowser control's documentCompleted event to add the handler for the mouseup/mousedown event.

then get the element at the mouse location, and check if its tag is "IMG" if it is use its getAttribute method for the "src" and set that to a picturebox's imagelocation property. or use the webbrowser.download. if its not an IMG tag you can loop through that tag's children tags.

But I still don't recommend any of this vs. the webbrowser controls built in "set as background" context menu item.

Diamonddrake 397 Master Poster

Doesn't the webbrowser control already allow you to right click an image and select "set as background" ?

why re-implement it?

Diamonddrake 397 Master Poster

It should be mouse down, I'm not sure what happens there but I was just typing code, I didn't test it. (although minus that error it should work just fine)

This code allows you to get the tag at a mouse point. you could handle the mouse up and use a custom context menu. or whatever you wanted. It should be pretty straightforward to use it for your purpose.

if you have any specific questions give me a post back.

Diamonddrake 397 Master Poster

Are you trying to save an image from a webpage, like Internet Explorer or firefox does?

This is untested and incomplete, But this should easily set you on your way to getting this to work

// somewhere attach the event handler
       webBrowser1.Document.MouseDown += new HtmlElementEventHandler(doc_MouseUp);
        

        //handle the event
        void doc_MouseDown(object sender, HtmlElementEventArgs e)
        {
            //used middle button, could be any
            if (e.MouseButtonsPressed == MouseButtons.Middle)
            {
                var doc = sender as HtmlDocument;
                HtmlElement imagetag = doc.GetElementFromPoint(e.MousePosition);
                string tag = imagetag.InnerHtml;

                //use regex to parse image location then save it to the local path.
            }
        }

Hope this sets you on your way. The HTMLDocument class that represents the actual html that the browser is rendering is exposed by the document property, It has mouse events and the ever handy GetElementFromPoint method that lets you find out what your mouse is over.

Diamonddrake 397 Master Poster

This is not the same effect. It may seem similar. But it's not. Thanks for the input though.

Diamonddrake 397 Master Poster

Turned out it was much easier than I thought. I got it working fine. I though that the stylesheet links wouldn't work correctly since they aren't in the head, but it all seems to work just fine.

Diamonddrake 397 Master Poster

I'm new to ASP.net I am a decent C# programmer, but I usually write windows programs, not web stuff, I did my website in plain html and recently I have started working in asp.net. I've read a few tutorials, but I'm stuck on what to search for, and how to get started.

I am using a css formatted unordered list as a navigation, I have one of those free javascript animated dropdown menus to go along with it. What I would like to do is create a asp.net control I can drop into a page like <asp:sitenav ID="snav" runat="server" /> and have it throw in the nav associate the 3 css files and js file it uses. and have a single aspx file I can edit to change all the links in the nav.

I just really don't know all it entails or how to get started. Anyone have any suggestions, or good links on this kind of thing? or any insight on problems I may run into?

Diamonddrake 397 Master Poster

a wrapper is just an object that acts as a middle ground to communicate with a library, program, or api to simplify its use, they are all different. The .net framework is a big wrapper for windows core functions. All programming involves the abstraction, whether its a layer you created, or one someone else did.

This forum is for helping, but you have to ask a direct question, "how does this work:, "What is this?", or "Does any one want to help?" questions typically don't get answered. Post a particular question about something you need help with and it will be read. and if anyone knows they will post a reply.

kvprajapati commented: nice answer :) +10
Diamonddrake 397 Master Poster

I had read about it, but it was the asp page that would accept it that I was unsure about. Guess the first place I should have looked was MSDN.

Thanks.

Diamonddrake 397 Master Poster

I am working on a couple projects where I need to upload files from a client using my software to my webserver and then do some other things. But I would like the software to handles this automatically so the user doesn't have to worry with it.

I am currently using FTP from my C# application, and it works simple enough. But I don't want to distribute software that depends on my ftp login. I would like to find some other way, maybe a http post method that sends a file to a .asp file on the server that writes to a read/write directory.

I just can't seem to figure out how to do it. All my search results keep leaning me toward upload "pages" that require the user to interact with a webpage.

any insight on this?

Diamonddrake 397 Master Poster

directX will play wav files too, and since all your methods do the same thing... you could just have 1 method, playSound, and it would play any sound that your system has a codec for.

also, where do you declare the variable "music" in these methods? They are initialized, but never declared.

A better way to do this would be to create a sound object so you could control volume, see the position, and create less objects, and you could wrap it in a try block for unknown formats with a error event to notify the program that a sound with an unavailable codec was attempted to load.

Thanks for contributing.

Diamonddrake 397 Master Poster

This is dirt simple, Please google your questions before you waste space on daniweb.

The webclient's downloadstring method gets the "HTML Source" of any webpage.

using System;
using System.Net;

class Program
{
    static void Main()
    {
        // Create web client.
        WebClient client = new WebClient();

        // Download string.
        string value = client.DownloadString("http://dotnetperls.com/");

        // Write values.
        Console.WriteLine("--- WebClient result ---");
        Console.WriteLine(value.Length);
        Console.WriteLine(value);
    }
}

~~~ Output of the program ~~~
    The program prints the page length in characters.
    The program prints the HTML source for the download.
Diamonddrake 397 Master Poster

Although it is partially possible, its not a good idea for a thousand reasons. Find another way to accomplish your goal.

Diamonddrake 397 Master Poster

You can easily use separate methods and call them from the one thread and retain that reusability. But that's up to you friend. As long as it works.

Diamonddrake 397 Master Poster

Its not a great idea to just spinning off threads like that, if you have some lengthy processes that needs to be done on a separate thread it might be best to do them in the same worker thread one after another, especially if the main program isn't going to be continuing on till both are done. Unless the user has a quad core processor, there will be no speed benefit from using 2 worker threads.

A background worker control is a good way to do simple synchronous operations like this. Reporting progress is simple, and you can pass to, and back from the worker thread an object very easily. that object could be an object array that has an infinite amount of information. Plus there is a lot of examples out there to work from.

Diamonddrake 397 Master Poster

lol, don't worry about it. I'm here to offer my opinion when you need it.

Threading can be complicated, but its not that bad. Use a background worker control when you can.

Diamonddrake 397 Master Poster

I argue that, no its not the only way. There is NEVER an "only way". As a programmer, finding ways to get around limitations is only the first step of reaching a goal.

But first, why do you need to change the font color and properties to show a selection? is not highlighting the selection with the select method not enough? I don't know why it wouldn't be.

But if you do want to change the font, and you are set on it. Then you have some key choices. You can implement your own stack and custom undo, which isn't that hard at all, just google it. its out there in a million places. Or you can custom draw your rich text box like it typically done for spell correction here is a link to how to do that Owner Drawing a Text Box. But those are only 2 of what could be a hundred possible solutions. you could even inherit from the rich text box and override some methods and add the begin and end change events, or decompile the code and add them and recompile it in your solution.

There is always a way. Here is 4 to try. Good luck and happy coding!

Diamonddrake 397 Master Poster

Sorry. I couldn't begin to understand why you would want to do such a thing, but I'm not sure how to help, and I don't think that could possibly be the best way to handle the situation.

Diamonddrake 397 Master Poster

I don't understand why you would do this, but here's the dig. Form 1's "load" event fires before it is shown, if you want to show form 2 after form 1, then put the obj.show() code in the form's "shown" event, not its "load" event.

But first, evaluate why you are doing this, and be sure you are really benefiting from 2 forms.

Diamonddrake 397 Master Poster

Honestly your solution is totally backwoods.

If you create a new process you can redirect its standard output to a stream, then do whatever you want with it. ex.

CurrentProcess = new Process();
CurrentProcess.StartInfo.FileName = exepath;
				
CurrentProcess.StartInfo.UseShellExecute = false;
CurrentProcess.StartInfo.CreateNoWindow = true;
CurrentProcess.StartInfo.RedirectStandardOutput = true;
CurrentProcess.StartInfo.RedirectStandardInput = true;
CurrentProcess.StartInfo.RedirectStandardError = true;

CurrentProcess.StandardOutput; will return a stream reader object that you can use to do anything you want with the output, for example write it to a text box.

You don't have to resort to a temp file.

Attached is an example of GUI based console, its just as completely basic as it could be, I encourage you to use this method over using the disk.

Diamonddrake 397 Master Poster

It sounds good in theory. But for testing the intuitiveness of the wizards if you are that concerned, I suggest that you throw them into a test app and let some friends not from a programming or power user background run through the wizards and see if they have trouble with any of the options. Make sure its friends who daily user computers, but not so much that they really understand how program's work. this will target your typical user, see how they feel.

A good idea would also to have a failsafe option marked something like:
MSAccess (recommended for most users)

Also, as for threading the system that checks for the prerequisites, that's not a bad idea, but don't get crazy with it, just a background worker should do fine, and i would probably do a progress bar on a wizard with a label that said something like "Checking for prerequisites" or "Checking for database compatibility". Then automatically go the next wizard screen when that finishes instead of waiting for a "next" click.

But these are just suggestions based on my opinion, which I humbly offer. Feel free to attache some images. I'll have a whack at them.

Diamonddrake 397 Master Poster

It's hard to say how much is too much, that depends on the software. Just like with anything. With power comes complication. It's your place as a programmer to make the program as simple to use as possible while still performing all the necessary functions to it's purpose.

Diamonddrake 397 Master Poster

This is a very valid question, But this is more complicated then it seems. First ask your self this: "Who will be using my application?". If a large company that will have many clients connecting to the database you are creating, and top speed and reliability is the most important feature, Then maybe you should only support the use of a SQL database. But if only a one or a few clients will be using the database then Access would suffice and just fine and you could just use that.

But if you really want to offer the user a choice, which can be a very sensible thing to do, why not just have on first run a quick wizard with the option of either "automatically configure data sources" or "Advanced Data source Configuration". Where one would just use access, where as the Advanced option would allow the users to choose between the two and run your wizards.

Many programs use SQL server express and use it. But I have written asp.net pages that use simple access databases larger than 3bg in size with no problems, so if you aren't needing a super fast database for hundreds of users MSAccess isn't a bad choice.

Diamonddrake 397 Master Poster

Before you spend 200 bucks, just try and create your own. See what happens. GDI+ is not all that complicated, just draw and fill a few gradient rounded rectangles. Even still, first be sure your app benefits from a ribbon type interface.

Diamonddrake 397 Master Poster

WPF uses a different drawing system, so it works better for flashy/fancy interfaces, But winforms isn't going away. Ribbon interfaces isn't really anything complicated. Its just a custom drawn tab bar with custom drawn buttons. If you just user draw the standard controls using images. Throw a tab control with a few buttons and pages and you're practically half way done. As a programmer you get all caught up in how you do things, but when a normal PC user runs your program they don't care if you used GDI or WPF or just lined up some images. All that matters is that it looks ok, it works, and its familiar.

Personally I do not like ribbon interfaces, on today's wide-screen monitors and the standard portrait style document the last thing I want is something to make the viewable document have less real estate.

In the beginning users knew, menus were on top. soon people wanted access to their favorite menu items, so then came tool bars, then someone said, tool bars would be awesome with tabs, so then came the ribbon with huge buttons and tabs. Every program doesn't need to look like MS Office.

A good place to start is with the code that's already out there for drawing on the form's non client area, then just going from there. And if you want some good pop up control code I have a good article about it on codeproject just search articles from user DiamondDrake.

Diamonddrake 397 Master Poster

"BeginInvoke" is used to run a method on another thread using the thread pool, just "Invoke" is used to call a method to run on the thread the control is on.(Control.Invoke lol get it.)

Like I said your code looks odd, but if the problem is gone then best of luck.

Diamonddrake 397 Master Poster

I spent a lot of time working on tightening the delay. The sound files are buffered into memory when the program opens so it doesn't use the disk the sound is played from a separate thread using a free lib I had found. I'm glad you liked it. I am still developing it, but I have been a bit busy and unable to work on it. I just moved myself. I believe that you must be a member of got hub to access files and you must use the "git" software available on the
Site to ssh it to a local source. I put a Lot of time into it and I just put it on github so people could find it, I didn't want my work to be in vane.

Feel free to add me as a friend on github and then you can branch my repository and it will build a file history tree showing your changes as a child of my original project.

Again, I'm really glad you liked it. I drove my GF crazy testing it.

Diamonddrake 397 Master Poster

The problem is the other thread is still running when you are exiting the GUI thread. Try using the "formclosing" event instead of the "formclosed" event to stop the other thread.

Although the invoke code you are using appears odd out of context. Its hard to tell exactly why its hanging.

Diamonddrake 397 Master Poster

Here it is
This is a fully working free example.

Diamonddrake 397 Master Poster

That was my solution :) I still prefer GDI+ and win forms. WPF's drawing technique has much better performance, But on a todays machines its typically not a big deal. I have done some pretty amazing custom controls in GDI+.

Diamonddrake 397 Master Poster

Cosmos isn't currently ready for anything real. They just offer you a working project system to encourage people to donate money or help with the project. It doesn't really let you do anything substantial yet.

Diamonddrake 397 Master Poster

This program has been moved to open source and is located on GitHub.com

Diamonddrake 397 Master Poster

I personally never got into WPF, I like my old winform applications.

in C# you can't do true gradient transparency but you can achieve that look a multitude of ways. If you set the formborderstyle to none and set an image as a background you can use a color key to make a single color transparent like any gif image on the web does. to bring that further to light you can layer your form and add true full 255 levels of transparency but that requires 2 forms one for the border and another for the use-able part of the form. Looks great but gets complicated, then the last honorable option would be to capture the desktop and draw it on any transparent areas and use that as the form's background.

Anyway, once you get your borders looking how you want you just create custom buttons that have the desired effect for the Minimize/maximize/close.

Anyway, Attached is an example of using an image with a transparency key, custom image rollover buttons for shell, with all the code there, even for moving the form. I was working on this for an article that I never got around to working on. I'm sure its right up your alley. It even includes the photoshop psd files of the images i created.

i hope it servers you well.

nssltd commented: Thanks just what i needed plus i like the minature shell design you added in on the project its so simple yet so effective :D +1
Diamonddrake 397 Master Poster

Instead of creating the file separate, you could just add an empty database as a resource into either your exe or a dll and have a method that extracts the stream to the new location. The user will have no idea that your program isn't creating the file from scratch, it won't rely on any apis and its only a couple lines of code.

Diamonddrake 397 Master Poster

I found this for mpeg 1/2

public class MPEGInfo

{

    #region index structures from mpgtx source

    int[, ,] BitRateIndex = new int[2, 3, 16]

            {

                { // MPEG 1

                    {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,0}, // layer 1

                    {0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,0}, // layer 2

                    {0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,0}  // layer 3

                },

                {// MPEG 2 or 2.5

                    {0,32,48,56, 64, 80, 96,112,128,144,160,176,192,224,256,0}, // layer 1

                    {0, 8,16,24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160,0}, // layer 2

                    {0, 8,16,24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160,0}  // layer 3

                }

            };

 

    int[,] SamplingIndex = new int[3, 4]

            {

                {44100,48000,32000,0}, // mpeg 1

                {22050,24000,16000,0}, // mpeg 2

                {11025,12000, 8000,0}  // mpeg 2.5

            };

 

    double[] FrameRateIndex = new double[9]

        {

            0d, 24000d/1001d, 24d, 25d,

            30000d/1001d, 30d, 50d,

            60000d/1001d, 60d

        };

 

    string[] AspectRatioIndex = new string[5]

            {

                "Invalid",

                "1/1 (VGA)",

                "4/3 (TV)",

                "16/9 (Large TV)",

                "2.21/1 (Cinema)"

            };

 

    public string[] ModeIndex = new string[4] // these can change anytime specs change so be careful

            {

                "Stereo",

                "Joint Stereo",

                "Dual Channel",

                "Mono",

            };

 

    public string[] EmphasisIndex = new string[4] // same as above

            {

                "No Emphasis",

                "50/15 Micro seconds",

                "Unknown",

                "CCITT J 17",

            };

    #endregion

 

    #region properties

 

    public class Video

    {

        public int GopHeaders;

        public int Height; // px

        public int Width;

        public double FrameRate; // fps

        public int AspectRatioCode;

        public string AspectRatio;

        public int BitRate;

        public double Duration; // seconds

        public double MuxRate;

        public int ChromaFormat;

        public string ChromaFormatText;

        public int Format;

        public string FormatText;

        public int Frames;

        public int Version = 1; // by default …
Diamonddrake 397 Master Poster

I hear that quicktime has a COM api that allows for automatic parsing of file headers. But it's unconfirmed. Its just an idea. there is a Mpeg 1/2 class floating around.

This link might help It has a good amount of information about the mpeg-4 file format.

Parsing a header is complicated, especially with video headers as the container file has a header, and each stream has a header. So even with the most simple video there are actually 3 headers to parse. The container header, the video header, and the audio header. Its a serious task and not something you will throw together very quickly, But good luck.