Ketsuekiame 860 Master Poster Featured Poster

Agree with most here.

First, you need to start small. Very small. Space invaders is a good example. Build it, learn from it, go back and continually improve it. Gradually increase the difficulty of what you're developing.

Be aware though, that "increasing the difficulty" doesn't mean "improving the graphics". So many times people go "okay I've made space invaders and r-type and want to make a 3d game! What do you suggest?"
I suggest you rethink what makes something more difficult ;)

For example;
Let's say you have your R-Type clone. It's a perfectly good 2D shooter and you're happy with what you've written. If we prescribe to the reasoning that 3D = more difficult, then the next step would be to make your R-Type clone 3D...

What do we now need to change to make your clone 3D.
1. Switch from using sprites to 3D textured models.
2. Add the Z axis.

Not exactly what you'd call difficult. Everything is pretty much the same, the mathematics might be a tad more complicated, but essentially you have the same game just in three dimensions. Not all that hard.

So instead, what could we add to your 2D game that would be difficult.

  1. Artificial Intelligence - Maybe add some "intelligent" enemies that avoid fire or find the best missile paths. This is an entire subject by itself ;)

  2. Multiplayer Networking - Fairly straightforward but some difficult challenges to overcome (such as synchronisation, packet ordering, and bandwidth limitations …

kal_crazy commented: Really helpful :) +0
Ketsuekiame 860 Master Poster Featured Poster

It's also the reason why I don't think that you can use scanner copying as an analagy for DNA copying. Typically you get an exact copy, minus some of the telomeric sequences. If the replication doesn't go correctly, there's actually a process of DNA repair that it goes under.

Otherwise we'd all be dead pretty quickly :P But typically if you get an incorrect DNA sequence, you end up with all sorts of syndromes and genetic disorders and cancers. The human body is miraculous itself.

Ketsuekiame 860 Master Poster Featured Poster

Image files also include header information and some of them are compressed.

If you're talking about bitmaps, the exact file format is written on the wiki

Bitmaps are the easiest to read because they are uncompressed.

Ketsuekiame 860 Master Poster Featured Poster

Yes, for the simple reason that I'm always curious about "tomorrow" or "the future"

I want to know how the species is doing 1000 years from now, I want to see the new technologies and sciences. What discoveries have we made, have we finally conquered the oceans, the stars etc.

I want to know, I'm driven by curiosity. There is an infinite universe within which to spend an infinite long life span.

Ketsuekiame 860 Master Poster Featured Poster

In that case, I suggest you call the method ListDuplicates and the variable minimumNumberOfEntries

ListMultiples is a bit confusing because it shares its name with the mathematical term :)

If you do call it minimumNumberOfEntries then you'll need to change the where clause to be >=.

The only improvement I'd make is, rather than flattening your list, simply select the key. This avoids a lot of sub-processing (you only need to select a single value instead of all of them) and completely removes the need to make a Distinct filter. Updated query below :)

list.GroupBy(x => x).Where(x => x.Count() >= minimumNumberOfEntries).Select(x => x.Key);

ddanbe commented: Thanks for your time and your knowledge! +15
Ketsuekiame 860 Master Poster Featured Poster

I use no queries here

list.GroupBy(x => x).Where(x => x.Count() > multipleNr).SelectMany(x => x).Distinct();

That's a LINQ statement ;)

Ketsuekiame 860 Master Poster Featured Poster

Why don't you use a Mutex instead (or even a simple lock)?

In your class declaration, create a static readonly object
private static readonly object _padLock = new object();

Then in your code, rather than having the "IsPacket...." etc you lock on the object.

lock(_padlock)

Because you put your code inside it's own scope you don't need to both with extra brackets.

private static readonly object _padlock = new object();

public void SendPacket(Packet P)
{
    lock(_padlock)
    {
        using (MemoryStream MS = new MemoryStream())
        {
            //Console.WriteLine("SEND START");
            BinaryFormatter BF = new BinaryFormatter();
            BF.Serialize(MS, P);

            byte[] Payload = MS.ToArray();
            int PayloadSize = Payload.Length;
            int SentSize = 0;

            SentSize += SocketMain.Send(BitConverter.GetBytes(PayloadSize));
            //Console.WriteLine("\tSocket.Send (PayloadSize): " + SentSize);

            SentSize = 0;

            SentSize += SocketMain.Send(Payload);
            //Console.WriteLine("\tSocket.Send (Payload): " + SentSize);

            //Console.WriteLine("\tSent payload:" + P.GetType().ToString() + "," + SentSize + " | " + Utility.GetMD5Hash(Payload));
        }
    }
}

This will give you your thread safety. You can do the same thing on ReadPacket but you will need to use a different object.

Ketsuekiame 860 Master Poster Featured Poster

Use of that timer is perfectly fine. The main difference is that Threading.Timer is more light-weight.

It's better practice to open/close SQL Connections as you use them. MySQL connections are stored in a connection pool anyway (by default in .NET) so just close the connection after you've made the call.

Your error is actually on Connect though from looking at your log and the error message is more indicative that the server you're trying to connect to can't be found (possibly a DNS error or the server went offline). This might be more related to the POP server you're trying to connect to rather than the database (As indicated by the 'POP3 Retrieval' comment in your log). I would put a bit extra logging in there so you know for sure where the log is being generated from.

Ketsuekiame 860 Master Poster Featured Poster

Just to put my nose in...Unless you need to use the counter variable outside the for loop (which in my opinion is bad practice in nearly all cases) you should initialise the counter value in the loop declaration. It ensures that the counter can only be modified in the scope of your loop and is tidier memory management for the GC.

EDIT: This is still the case even if your counter value comes from external sources.

/* Bad IMO */
int counter = HelperClass.GetNumberOfItems();
for(;counter != 0;counter--)
{
}

/* Better IMO */
for(int counter = HelperClass.GetNumberOfItems(); counter != 0; count--)
{
}
// or
int numberOfItems = HelperClass.GetNumberOfItems();
for(int counter = numberOfItems; counter != 0; counter--)
{
}

/* Never EVER use public fields/properties
 * Especially true in threaded applications
 * You're pretty much asking for trouble :P
 */
for(; this.NumberOfItems != 0; this.NumberOfItems--)
{
}

Like tinstaafl, I'd only use a while loop when checking a specific condition where an index/counter isn't required.

So; while(dataReader.Read()){ /* Use datareader */ }
Not;

int n = 0;
while(n < 10)
{
    Console.WriteLine(item[n].DisplayName);
    n++;
}
ddanbe commented: Great clarification! +15
Ketsuekiame 860 Master Poster Featured Poster

It shouldn't be crashing in the first place, but yes, your subsequent sends are out of sync. This could indicate a threading issue with your code.

If you want, PM me with a location that I can download your entire source from and I'll take a look and debug through it. At this point, I think this is the fastest way to help you because I can't see anything wrong now.

Ketsuekiame 860 Master Poster Featured Poster

No, send will block until you've sent the entire buffer to the system buffer, unless you have it in "non-blocking mode", in which case it's not guaranteed to send the entire buffer to the system buffer, but only the amount of space available in the system buffer.

It would be good practice in your case (as you're having issues) to check whether you're sending the correct amount of data before we continue debugging, but I've put millions of bytes into the buffer before and not had issues...

The fact that you end up with skewed numbers indiciates that either you're reading too much or too little data on one of your read operations. It may be that the payload calculation size is off. Have you stepped through and checked all the buffer sizes etc.

As an aside, your first receive isn't looping. Whilst I realise that it's only 4 bytes, there's no guarantee that you received all 4 straight away.

To make it more efficient, the system will attempt to fill as much data as possible into the buffer, until it reaches a certain thresh-hold. If this thresh-hold is not reached, the system will delay the send until a certain period of time, or, there is more data to send. So if your thresh-hold is 128 bytes, your last packet filled 126 and then your payload size for the next item goes on, hits 128, the driver sends the buffer and the rest of your int (the final 2 bytes) …

Ketsuekiame 860 Master Poster Featured Poster

When you write how many bytes are received on line 16, does this match up with the number of bytes sent?

Ketsuekiame 860 Master Poster Featured Poster

Socket.Receive even with the byte length argument, isn't guaranteed to actually have that much data. Essentially, the byte length argument is a "max limit". It will receive as much data as possible up to that value. So if your socket has sent 15 of 30 bytes in the first TCP window, your receive method will pick up the 15 bytes and return. It will not wait for the second 15.

Essentially, I think this is what's happening to you. Although you've sent say 100bytes, if Windows or the network driver decides to only send 98 for example, your receive will be short.

For reliability purposes, you should loop your receive method (it will return to you exactly how many bytes it placed into your buffer) until you have received all data or a timeout occurs.

Ketsuekiame 860 Master Poster Featured Poster

Essentially you only defined the query but you never executed it (this is called deferred execution). You should be able to correct that simply by putting .ToList() on the end of your LINQ.

var words = File.ReadAllLines(path)
                .Where(line => line.StartsWith(intro))
                .Select(line => line.Substring(intro.Length).Trim())
                .ToList();  

This will cause the query to execute and your words variable should contain a List<string>

Your loop can be achieved with foreach

foreach(string movieFileName in words.Where(str => videosnames.Contains(str)))
{
    // Do stuff here
}
Ketsuekiame 860 Master Poster Featured Poster

First, please be patient. It's obvious we're in different time zones, so you're not going to get an immediate response.

Second, tell us what you're expecting to happen and also tell us what is happening.

Unfortunately, pasting code and saying "it doesn't work", especially if the code is valid, isn't enough for us to go on in most cases...

Ketsuekiame 860 Master Poster Featured Poster

To whom do I make the invoice out to?

Ketsuekiame 860 Master Poster Featured Poster

I'll answer in order;

  1. WCF is a framework that can run inside Windows Services. Think of Windows Services as a bucket, doesn't matter what you put inside, so long as it fits.
  2. This is where service communication comes in. If you really can't use WCF, then you should look at .NET Remoting. You will need to review the MSDN and some tutorials. It's too big to talk about here in detail.
  3. It's the service side that I'm talking about :) Your Windows Service will likely run under the account "LOCAL SYSTEM" or "NETWORK SERVICE". Neither of these accounts are attached to the user who logs in to the desktop. So to the service, it has no concept of where that special folder is for the specific client you've logged in as. Where your WPF is concerned, special folders can be used as normal because you're logged in to a desktop session on a standard user account.
  4. Database is the best tool for the job. It will not get that large over the lifetime of the account unless you send huge attachments to it. You could also maintain a maximum age policy whereby everything after say, one month, is automatically deleted from your local store. A good idea here would be to download the headers only (not sure if the OpenPOP client will let you do that) OR download everything and only store the required information for display (such as the subject/datetime/summary) and then download the entire mail later. Depends how …
Ketsuekiame 860 Master Poster Featured Poster

I suggest you use OpenPOP (as deceptikon mentioned) if you're not interested in learning the mechanics behind POP Mail. You will need to build the services around it for your application.

I would first start with building a one-way WCF service (You call it and it gives you a response). Once you have built that up, it will be easier to teach you how to implement callback contracts for two-way service communication.

Visual Studio has a nice template for a basic WCF service. I suggest you take a look at that and run through some WCF tutorials.

A quick google and This looks like a decent WCF Tutorial to get you started.

Ketsuekiame 860 Master Poster Featured Poster

It's because you're making the buttons appear and disappear.

When you move your mouse over them, your mouse "leaves" the form window and enters the button window, causing your Form2_MouseLeave method to execute, causing your buttons to become invisible. This causes your mouse to "enter" the form window, causing Form2_MouseEnter to execute. This makes your button reappear, causing your mouse to "leave" the form window...An infinite cycle now starts of the button appearing and disappearing.

Ketsuekiame 860 Master Poster Featured Poster

Did you check that the file still exists in the output folder of your build? Visual Studio could be deleting the DLL because you're doing a rebuild. (Performs a 'Clean' step)

Ketsuekiame 860 Master Poster Featured Poster

This question is a bit too involved for me to answer quickly in the time I have available. However, there is a tutorial on dynamic control creation available at Tech Pro which should get you headed in the right direction.

Ketsuekiame 860 Master Poster Featured Poster
DateTimePicker dateTimePicker = new DateTimePicker
{
    Format = DateTimePickerFormat.Time,
    ShowUpDown = true // Set to false if you don't want the up and down arrows to select the time
};
ddanbe commented: Definitly the way to do it. +15
Ketsuekiame 860 Master Poster Featured Poster

If you call PlaySync instead of Play it will queue the audio so that they play one after the other, not over the top of each other.

If you want any more complicated scenarios then you will need to create your own audio manager.

Mike Askew commented: Epeen++; +7
Ketsuekiame 860 Master Poster Featured Poster

Did you add the viewmodel to the window datacontext?

<Window /* Add a namespace location for your viewmodel class eg. vm */>
    <Window.DataContext>
        <vm:MultipleDatumFilterVM />
    </Window.DataContext>
....
</Window>

Then in your code behind, in the constructor, point your Window DataContext to the ViewModel instantiation.

public partial class MyWindow : Window
{
    public MultipleDatumFilterVM ViewModel = new MultipleDatumFilterVM();

    public MyWindow()
    {
        IntialiseComponent();

        DataContext = ViewModel;
    }

    ...
}

Remember that when you fire the checkbox changed event, to fire OnPropertyChanged for the other items you're bound to, otherwise they won't pick up the changes (if you don't make manual adjustments).

eg

public class CheckBoxViewModel : INotifyPropertyChanged
{
    public CheckBoxViewModel()
    {
        IsChecked = false;
    }

    private bool _isChecked;

    public bool IsChecked
    {
        get { return _isChecked; }
        set { _isChecked = value; FireEvent("IsChecked"); FireEvent("Output"); }
    }

    public string Output
    {
        get { return IsChecked.ToString(); }
    }

    private void FireEvent(string paramName)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(paramName));
    }

    public event PropertyChangedEventHandler PropertyChanged;
}

If I didn't manually fire the event for "Output" then anything watching that property would never get updated.

Ketsuekiame 860 Master Poster Featured Poster

Personally speaking, a combobox is the wrong object for this job. It would be much better (and simpler) for the user, if you populated DataTables. Your functionality would still exist, only they UI would be better.

I would do this in a class structure that your ViewModel will utilise.

Create a Table and column class such as:

class TableViewModel : INotifyPropertyChanged
{
    string TableName;
    List<Column> Columns;
    bool IsSelected;

    /* Interface Implementation */
}

class ColumnViewModel : INotifyPropertyChanged
{
    TableViewModel ParentTable;
    String ColumnName;
    bool IsSelected;

    /* Interface Implementation */
}

Then in your Window ViewModel:

class CreateQueryViewModel
{
    List<TableViewModel> Tables;
}

Then you need to bind your first DataGridView (or even a TreeView) to the Tables object on your ViewModel.
Hook into the OnPropertyChanged event for each of your TableViewModel and everytime you detect that one has been selected, add a DataGridView for that Table and bind the column list to the Columns property.

Ketsuekiame 860 Master Poster Featured Poster

My point still stands; we know that the way you've declared CommandProperty works, so we don't need it complicating matters.
There is a need to go over a process of elimination, no matter how we think it ought to work, we should perform the steps anyway.

Whilst it might not be that the framework is 'confused', if it suddenly starts working afterwards, then we have a more defined route to trouble shoot, rather than just guessing.

Ketsuekiame 860 Master Poster Featured Poster

Hi, just a report to say that when you click on a link to go directly to a post, the page scrolls too far and it becomes hidden under the top menu banner. In order to see the beginning of the post you have to scroll back up.

This is happening on the latest version of Chrome. I haven't checked any other browsers.

Ketsuekiame 860 Master Poster Featured Poster

Set a property such as IsHeader on the object you're adding to true. This will act as a marker for your style trigger.

MyObject cbiHeader = new MyObject { Text = "Header 1", IsHeader = true };

You also need to set up a style trigger based on your databinding.

So if you have a ComboBox object in your WPF...

<ComboBox ItemsSource="{Binding}" DisplayMemberPath="Text">
    <ComboBox.ItemContainerStyle>
        <Style TargetType="MyObject">
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsHeader}" Value="True">
                    <Setter Property="IsEnabled" Value="False"/>
                    <Setter Property="FontWeight" Value="Bold"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </ComboBox.ItemContainerStyle>
</ComboBox>
Ketsuekiame 860 Master Poster Featured Poster

Make the header a seperate control and change the font of that control.

Label headerLabel = new Label
{
    Text = mychk.Content.ToString(),
    FontWeight = FontWeight.Bold
};

GroupBox myGroupBox = new GroupBox
{
    myGroupBox.Header = headerLabel,
    myGroupBox.Content = myStack
};
Ketsuekiame 860 Master Poster Featured Poster

I meant, comment out the CommandProperty not the CommandParameterProperty, essentially to check that it's not seeing these as the same property. It shouldn't, but you know, WPF... :/

We need to check if there is something wrong with the way you're registering the property (ie. It still doesn't work after you comment out the other one) or if the framework is getting confused by a double registration of the same type (even though it has a different name).

Ketsuekiame 860 Master Poster Featured Poster

This is also where I'm as lost as yourself. In your original code set I can't see any reason why it wouldn't work.

With respect to UIElement that doesn't mean you need to use a UIPropertyMetadata as you aren't dealing with Animation. Try switching them to FrameworkPropertyMetadata as you're actually dealing with WPF framework commands (binding).

Finally, just to eliminate a possible dual registration issues, did you try commenting out the CommandProperty declaration and registration to check if it will register the CommandParameterProperty one by itself.

Ketsuekiame 860 Master Poster Featured Poster

What exactly is not happening? I understand the part about not be able to pass events, but I'm not sure where from and where to.

I can't particularly see anything wrong with what you've done. The only thing that stands out is that you've not provided any callback information, essentially making them readonly properties of the control.

You should probably switch to using FrameworkPropertyMetadata or PropertyMetadata instead of UIPropertyMetadata (which is for Animation really).

Ketsuekiame 860 Master Poster Featured Poster

Unfortunately, there's nothing communicating over your COM1 port. However, you might be able to get a list of the com ports available on your machine and then select the correct one for your device.

SerialPort.GetPortNames will return a list of com ports to you. But you might need to do some registry queries to get the right com port by the vendor and device id.

Otherwise, you will have to treat your scanner as a Keyboard emulator (probably the default mode) and make sure that the relevant text boxes are focussed when a scan takes place.

Ketsuekiame 860 Master Poster Featured Poster

Hi P,

Useful site if you need to know the signatures of WinAPI methods is http://www.pinvoke.net/

It also has a plugin to automatically insert them for you if you use VS 2010/2012 :)

pritaeas commented: Nice. +14
Ketsuekiame 860 Master Poster Featured Poster

You will need to create you rown kind of control, possibly a list of picture boxes or labels to hold the date. You will need to dynamically create controls, or place extra text in your labels to indicate an appointment.

To save appointments, look at the ics format.

Ketsuekiame 860 Master Poster Featured Poster

Well, you need to bind your checkbox to something like an MarkForDelete on the thing you want to delete. When you click on Delete, iterate through all the data and filter out based on this flag. Delete as required.

On the last point, you could set your datagrid into edit mode when you click, then pick up the OnKeyPressed event and check for the Return key, or any mouseclick outside the control.

Ketsuekiame 860 Master Poster Featured Poster

First, expand your catch to retrieve the exception.

catch(XmlException exc)

Then, actually log/display the exception message that is contained in exc.Message. It will also give you a handy point to break on.

Unfortunately you can't tell if XML is well formed before you load it unless you write your own parser.

Ketsuekiame 860 Master Poster Featured Poster

Settings are stored on the file system. Whilst under normal operation that's perfectly fine, if you're running under the context of say NETWORK SERVICE then you won't have, or want to give, access to the file system. Registry makes sense at this point.

Using resources is a bad idea in general because you can't change the values entered.

ddanbe commented: Thanks for the clarification! +14
Ketsuekiame 860 Master Poster Featured Poster

You can use a Timer which can be set to execute a method at certain time intervals. MSDN Link

Ketsuekiame 860 Master Poster Featured Poster

Most
International
Schools
Solicit
Internship
Showing
Scholarship
Is
Principally
Profit
Induced

BOOM! :D

Ultra Epic Hard Mode
Deinstitutionalisation

Stuugie commented: Nice! lol, I'm leaving Deinstitutionalisation alone. +0
<M/> commented: thank god i didn't attempt it +0
Ketsuekiame 860 Master Poster Featured Poster

Horticultural Oratory Rallies Occupationalists With Immediate Zeal!

M you aren't even trying :P

Awareness

Ketsuekiame 860 Master Poster Featured Poster

Xenophobic Yobs Livid Over Interracial Dependence

(Why do I always have to do the hard ones? :P)

Nomenclature

Ketsuekiame 860 Master Poster Featured Poster

jwenting is correct where the UK is concerned. Unless you didn't give permission for your photograph to be taken in any place where you expect a "right to privacy" the copyright belongs to the photographer. When you hire a photographer, you pay for their time, any editing they do and (typically) a single use licence.

If a photograph is taken without your permission in a public place (typically, anywhere outside) you have no legal recourse over the use of the image. However, if someone took a picture of you in your home and it was not comissioned, you can take the photographer to court over that.

Ketsuekiame 860 Master Poster Featured Poster

" " indicates a string of characters, aka. char * where as each individual element is a char. To indicate a single character, use ' ' (apostrophe)

Ketsuekiame 860 Master Poster Featured Poster

You're given all the information, including the mathematics you need as part of the question.

Why did you only decide this was worth looking at two days before the deadline? If you'd have at least read the assignment a week ago, you could have approached someone and asked for help, including your lecturer.

My suggestion is that you fail the course and re-take it. It's obvious you either A) skipped class a lot, B) don't understand the core course material. So I know it sounds a bit harsh, but failing the module is probably the best thing for you to do.

At the very least go to your lecturer, be honest and perhaps they will give you a small extension in which you can get it done.

By asking someone else to work for you, you're only hurting yourself.

---------

At the very least, start reading about object oriented programming and design something on paper. At least you'll have something to present to your lecturer.

Ketsuekiame 860 Master Poster Featured Poster
timmyjoshua commented: pls, can you help me.. have done the one for .txt but my c# form has got a .jpg picture that i want it to show in the file... +0
Ketsuekiame 860 Master Poster Featured Poster

Apart from the fact your question is poorly formatted because you copy pasted your assignment, we aren't in the habit of openly gifting code to those who haven't attempted it themselves.

If you need help with a specific point, please re-phrase your question to ask about this directly.

stbuchok commented: I see this type of thing far too often +8
Ketsuekiame 860 Master Poster Featured Poster

Well, release mode is where you put in all your optimisations. The idea is that in release mode you want your application to un as efficiently as possible. Also, any test data or settings you might've set need to be removed. By going into "Release" mode, you have the option to turn these off without altering the code of your application. Strictly speaking, "Release" mode is just a configuration, you could have "Release_64" for 64bit releases or "Release_OGL_FPS" which is release mode with opengl and an fps counter...

What you do in release mode is pretty much up to you as the developer.

Ketsuekiame 860 Master Poster Featured Poster

When you define DEBUG you can adjust what your code does based on this definition.

So you could do;

#define _DEBUG
#include <iostream>

int main(int argc, char** argv)
{
#ifdef _DEBUG
    std::cout << "DEBUG MODE ON" << std::endl;
#else
    std::cout << "DEBUG MODE OFF" << std::endl;
#endif

    return 0;
}

In this case, when you compile, only the line of code that says "DEBUG MODE ON" is compiled into the application, the other condition is completely skipped and not part of the binary.

Many people do this when developing for cross-compatibility. Such as #ifdef _WIN32 so you can switch between code that will only work on a particular system.

Ketsuekiame 860 Master Poster Featured Poster

You will need to use ScriptManager.RegisterClientScriptBlock and register the control that calls the script to the block of code that you want to call.

This is a link about the ScriptManager