Ketsuekiame 860 Master Poster Featured Poster

Don't re-invent the wheel :) VB SysInfo control

Ketsuekiame 860 Master Poster Featured Poster

If you want to program for MS Windows, and you want a desktop application that's not using something like OpenGL or DirectX, then you really don't want C++. The framework for Windows UI apps in C++ is MFC, which...I don't even want to go there, the nightmares never stop... However, C# is a good intermediate language. Like already said, it's similar in syntax to Java with subtle differences but you should pick those up fine.

If you want to write automation utilities, services, underlying libraries where performance is more important than productivity, C++ is the right tool for the job. If you want to program for Linux, again C++ is probably the wrong choice (python and GTK+ is probably the right choice). Don't use a programming language because you think it's more powerful, or has better control unless you need it. Nowadays there are so many options it's more about using the right tool for the job.

Ketsuekiame 860 Master Poster Featured Poster

IE != Visual Studio browser control. It's a very thin shim only really used for rendering pure HTML. If you want more advanced functionality I would look at using WebKit or Chromium.

Ketsuekiame 860 Master Poster Featured Poster

If you're in kernel mode (driver level) then this will register a method that will be executed when a new process on the machine starts.

If you want to do the same thing in C# you can use WMI. Use the ManagementEventWatcher, execute a query against Win32_ProcessStartTrace and register a method to be called when a new process is detected.

I wouldn't recommend doing this at the driver level; you will need to get it MS (WHQL) certified or it won't work on 64bit systems (without the user putting the OS in debug mode)

Ketsuekiame 860 Master Poster Featured Poster

If you really really want to go ahead with C# as your single language, you should look up TAO GL

Without making the COM calls to the Windows API yourself, this is about as good as it gets.

If I were you, pick up an existing game engine (Unity/Unreal) and start there.

Ketsuekiame 860 Master Poster Featured Poster

There is no functional benefit, you are correct. But it does mean that some things compress down nicely so instead of being 5 lines they're only 1. That's pretty much it.

Also watch out @deceptikon, there is already a ForEach method on List<T> I don't know what the interaction would be here.

Ketsuekiame 860 Master Poster Featured Poster

Actually we use a similar construct here; it's great for doing something X times but be warned that there are three levels of indirection and a delegate object construction plus the delegate invocation.
It has an impact when you get into large numbers.

Ketsuekiame 860 Master Poster Featured Poster

Make sure you're running it in Debug mode. In Release this could have been optimised away because you're not using the variable.

ddanbe commented: Great! +15
Ketsuekiame 860 Master Poster Featured Poster

If you have an image in code then you should be able to get the byte array out of the object that contains the data. It might be called GetBytes() or something. In any case, look for a method which will give you a byte array.

I also noticed that you specified a length of 50 bytes. That's not going to be enough to store a decently sized image. Try 2Mb instead. That will let you have a JPEG of decent size.

To store, you pass the byte array of the image data as the Value of that parameter.

Ketsuekiame 860 Master Poster Featured Poster

Have a try at doing it first. If you enjoy it then there's no problem! Right? :)

If you get stuck come back with what you've done and what your specific problem is. Then we can help. Doing your work for you is cheating at best and plagiarism at the worst. Neither of which are good for you as a learner ;)

ddanbe commented: Nice +15
ChrisHunter commented: diplomatic response +7
Ketsuekiame 860 Master Poster Featured Poster

Ok so the only way this would really provide security is if you used some unknown password (referred to as salt) to generate the hashes. Otherwise, anyone would be able to modify the table and then generate the hash to make it look like it hadn't been tampered with.

Using a salt could be as simple as hardcoding a string into your application and appending it to your value that will be hashed.

...

string myVal = "ValueToBeHashed";
const string Salt = "asgG&T£$Juu";

string computeValue = String.Concat(myVal, Salt);
SHA512Managed hasher = new SHA512Managed();
byte[] hashValue = hasher.ComputeHash(computeValue);

...

Secondly, you don't want to make anything but your application be able to automatically compute the value. If you set your database to do it, then you don't gain anything in terms of security. This is because as soon as the offender updates the database, the database would recompute the hash value for them.

To compare the two, you simply need to perform the hash step again and perform a Array.SequenceEqual between the two hashed byte arrays.

I supposed I ought to point out that this won't help protect your database, but it will help discover evidence of tampering.

Ketsuekiame 860 Master Poster Featured Poster

In C# you can think of all classes as references (pointers)

Like ddanbe said above, if you really want the pointer, you can use the unsafe keyword and then use it like C++. A more safe way is to marshall it out into an IntPtr object, but this is generally reserved for interop (Win32 API) code.

Given that your code looks to be self-contained you don't need the actual pointer reference.

Quick overview:

Nearly all objects are of two basic types; value and reference. A reference type can be treated almost identically to the pointer type in C++ and value types are the same as normal definitions and primitives (such as int, float, long CMyClass)
A quick easy rule as to whether something is a value type or reference type;
structs are value types and classes are reference types.

You can also say that anything that inherits Object is also a reference type but there are special rules around this too (such as boxing and unboxing).

To make it relevant to your code:

List<CAccount> list = new List<CAccount>(); in C# is the equivalent of
std::vector<CAccount*> list; in C++

ddanbe commented: Could not have explained it better. +15
Ketsuekiame 860 Master Poster Featured Poster

Like I said, uniqueness may not be relevant for your scenario, however, you should look at ways to stop things being duplicated (such as constraints against having the same Name for example)

Ketsuekiame 860 Master Poster Featured Poster

Only two things strike me as a little off.

  1. You have no way of uniquely identifying a single "Fact". This could be important, might not be, up to you.
  2. Lists shouldn't be publically accessible. You should allow readonly access to your lists and manage them internally via class methods.
Ketsuekiame 860 Master Poster Featured Poster

If you don't want to be able to "read" your serialised list, or to be able to import from a common format, don't use XML. It can be quite slow once you get into large amounts of objects.

Have you considered using SQL Express? That way you can have a "LocalDB" that is deployed with your application and can be used to store your data. It might also be worth looking at Document Databases for something like this. A local store is small, powerful and can be updated in real-time. Using file based storage, this would be tricky (but possible, leading to a lot of disk IO)

ddanbe commented: Good advise +15
Ketsuekiame 860 Master Poster Featured Poster

Depends what you want to do with it. What scenarios are you looking for?

Ketsuekiame 860 Master Poster Featured Poster

Have you tried making the properties in the base class virtual?

Ketsuekiame 860 Master Poster Featured Poster

Try setting the order weights to a negative number in your base class.

Ketsuekiame 860 Master Poster Featured Poster

If you look at the available constructors for StreamWriter you will see that one of them can be used to indicate you want to append to the file.

Ketsuekiame 860 Master Poster Featured Poster

You could use Username/Password based authentication over TLS, but that's not as secure as having a certificate solution in my opinion. But it's a better solution if money is a problem or you can't establish a valid certificate chain.

WCF can be configured in code or in web.config, so technically speaking, you could implement the certificate solution in code ;)

Ketsuekiame 860 Master Poster Featured Poster

There's a couple of ways.

As well as using TLS (standard SSL solution) you can also use Certificate based authentication (effectively enforcing that both client and server have valid certificates)

You can also use Username and Password based authentication (including domain authentication if you have that available)

The easiest, if you ask me, is using certificates in a Client/Server auth process. As you're using Server-Server communication, I would recommend this.

Additionally, if you're worried about MITM attacks, you can encrypt and sign your messages in addition to the transport.

I should point out that client/server cert authentication is pretty easy to set up so don't let the idea of using certificates put you off.

Ketsuekiame 860 Master Poster Featured Poster

You need to add it as an application in IIS. If you upload the code files using FTP, you can use IIS Manager to add the WCF application (as an application) to your website.

Note that you must have the HTTP Activation Service enabled on your server in order for this to work.

Ketsuekiame 860 Master Poster Featured Poster

You might be better using a small database like SQLExpress to write your data to rather than a text file. Sharing read/write access is a dangerous game...

Ketsuekiame 860 Master Poster Featured Poster

DHEC alone wont authenticate the server. For example, after establishing a key, you still need to make sure you established it with the right person! Though it is often used in conjunction with signing (which involves certificates unfortunatly).

True, but this isn't the requirement as far as I read it. The requirement being "I want to encrypt some data on the connection". If you want any kind of server validation (which is generally why TLS is used) then some information must have been exchanged beforehand.

Attempts to do so will be vunerable to a MITM attack. It doesn't matter how you look at it.

Agreed, but at least with ECDH they have to have intercepted the start of the exchange to make it easy. It's not perfect, but if you don't want/can't have pre-shared information it's the best place to start.

Additionally, we are using the WAN to establish a connection, but the WWW isn't really in use. If we're verifying that the server is correct, the server should also verify that the client is correct.

Finally, it's important to note that certs aren't the be-all and end-all of security. Any cryptographically strong pre-shared key would suffice as a mechanism of client/server validation. Certs just happen to contain this information. The downside is that you need to pay for them and that might not be necessary, depending on your requirement.

For example; if you had a crypto pre-shared key of 512 bytes, you could use the …

Ketsuekiame 860 Master Poster Featured Poster

They don't get installed into a browser, they're installed in the computers certificate store. (either by user or by machine)

Certificate/SSL Certificate no difference. Certificates are produced to a well defined standard and they include a key of a certain size along with descriptor information. That is a certificate. You could make one yourself with the right knowledge of the protocol :)

Encrypting a connection still involves using a key to encrypt data and relies on the secrecy of said key for it to be secure (otherwise known as the private key)

There is something that exists called the Diffie-Hellman Elliptic Curve. This is a good place to look for connection based, non-certificate based symmetrical encryption.

ECDH relies on generating a private key and sending a public key to the client. The client starts the ECDH process by using the public key to generate their own private key. The server responds with its own public key and the client generates the same private key. These private keys can be used to encrypt over the wire without ever being sent to one another.

Example;

// Client Side

public byte[] GeneratePrivateKey()
{
    using(var keyGenerator = new ECDiffieHellmanCng())
    {
        keyGenerator.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
        keyGenerator.HashAlgorithm = CngAlgorithm.Sha256;

        byte[] clientPublicKey = keyGenerator.PublicKey.ToByteArray();
        byte[] serverPublicKey = myService.ExchangeKey(clientPublicKey);

        byte[] privateKey = keyGenerator.DeriveKeyMaterial(serverPublicKey);

        return privateKey;
    }
}

// Server Side
public byte[] ExchangeKey(byte[] clientPublicKey, out byte[] privateKey)
{
    using(var keyGenerator = new ECDiffieHellmanCng())
    {
        keyGenerator.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;
        keyGenerator.HashAlgorithm = CngAlgorithm.Sha256;

        byte[] serverPublicKey = keyGenerator.PublicKey.ToByteArray();

        privateKey = keyGenerator.DeriveKeyMaterial(clientPublicKey);

        return …
Ketsuekiame 860 Master Poster Featured Poster

In terms of geometry isn't a dimension simply an axis that is perpendicular to all other axes?

Quaternion mathematics for rotation for example.

Also I don't believe in time as a dimension but as an artifact of something else. If time were a spatial dimension, why do we get relativity issues when approaching the speed of light? Seeing as even at the speed of light we're still travelling in 3 dimensional space.

Ketsuekiame 860 Master Poster Featured Poster

Aggregate is incredibly useful. As an explanation to Chris, Aggregate takes the result of the function and passes it as the parameter into the next iteration of the function. This makes it possible to create an aggregate of data from your list (hence the function name) :)

Ketsuekiame 860 Master Poster Featured Poster

You could use

Custom item = data.OrderByDescending(obj => obj.Index).FirstOrDefault();

Does the same thing but looks tidier :)

Ketsuekiame 860 Master Poster Featured Poster

If you won't include a third library with common functionality/types, you need to re-design your application so that you no longer have the circular dependency. How you do that is down to you as the application designer.

Ketsuekiame 860 Master Poster Featured Poster

In C# objects and structs are treated differently by what basic type they are.

An Object (class) in C# is a reference type and so whenever you pass an instance of that class to a method, you're really only passing a reference to that class. This has the benefit of saving memory, but has the disadvantage that any modifications you make inside that method, will also affect the original object you passed in (it's the same one after all).

Structs and primitives (like int, float etc) are value types. This means that when you pass a struct to a method, the method gets a copy of it on the stack (as opposed to the heap where objects are created). Important to note that this is a copy, so this has the disadvantage of being slower and using more memory, however, any work done to this struct is completely isolated.

They can be used pretty much the same way (there are some advanced limitations on structs).

Hope this helps.

Ketsuekiame 860 Master Poster Featured Poster

Ok. I was going to do that as a last resort since multiple people might connect at once and mix up the names. Thanks anyway.

You can't. Data comes down each socket from a specific client (unless you're using Broadcast). So if you keep that socket in a particular method that expects a certain "Initialisation" data, then there's no chance of mixing names up.

Ketsuekiame 860 Master Poster Featured Poster

Depends what you're talking about (again). Unfortunately there are two meanings for "4K".

One is the industry standard, 4096x2160 and the other is UHDTV which is 3840x2160. I will continue to assume 4K means 3840x2160 as this is what monitors and TV broadcasts will be.

Assuming that you're watching on a standard TV at 24fps a 10bpp RAW, video only, 4K video will consume ~79.1MB/frame or ~1898.44MB/sec.

H.264 can achieve a compression ratio of approximately 64% (ref)

For the purpose of mathematics, we will assume that this is the average of all frames and therefore, that every frame produces the same compression ratio.
This means that with HEVC, 4K will consume approximately 683.44MB/sec

Hope this helps.

EDIT: This calculated ratio is somewhat better than the first movie available in 4K which was 160GB for 129seconds

Ketsuekiame 860 Master Poster Featured Poster

It depends how you've implemented you view, which I can't see from the code there.

If you're using a datagrid then if you make the control editable, adding new lines should be automatic. If you're using custom binding, you will need to add a "Create New..." button or similar. That way you will add a new, empty object to your control and set the bindings to it. When you click Save, as the object has been inserted into your datacontext, it should automatically create it in the database.

You may have to call the Insert method on your datacontext. If so, find some way of knowing that you're adding a new record and call "Insert"/"Add".

Ketsuekiame 860 Master Poster Featured Poster

Well it should all work the same way, how are you initiating the "Create New" logical task? It should be as simple as adding the data object to your context and saving, but you will need code logic to handle that case rather than updating existing model data.

Ketsuekiame 860 Master Poster Featured Poster

You can use a Binding Converter to get what you need. It will allow you to do pretty much anything to the data before it is used.

Very useful, very powerful and not too hard to get the hang of :)

Ketsuekiame 860 Master Poster Featured Poster

When you set up EF, did you use Code First or Database First design methods?
It looks like hex_srv_start is the wrong variable type for what you're trying to enter. Is the variable definitely a string type? If so, it may be that you're recording too much data.

Example;
21st Jan 2014 has 13 characters
21/01/2014 00:00:00 has 19 characters

Ketsuekiame 860 Master Poster Featured Poster

Yep =)

Ketsuekiame 860 Master Poster Featured Poster

Are there any hard coded paths? You need to list what the runtime errors are.

Ketsuekiame 860 Master Poster Featured Poster

What does the EntityValidationErrors property contain?

Ketsuekiame 860 Master Poster Featured Poster

Not sure if it's just me but the home page doesn't work. It's just presenting the background colour but no content.

The following is received by the browser:

<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en-US" lang="en-US">
<head>
    <!-- CSS -->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width" />
    <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400" />
    <link rel="stylesheet" type="text/css" href="/articles/article_css/nogroup4637896363" />
    <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <!-- Javascript -->
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="/articles/js_article_scripts/nogroup995122999598"></script>   
    <script type="text/javascript">

    // Add a script element as a child of the body
    function downloadJSAtOnload() {
        var element = document.createElement("script");
        element.src = "/articles/js_deferred_scripts/nogroup109951229995600";
        document.body.appendChild(element);
    }

    // Check for browser support of event handling capability
    if (window.addEventListener)
        window.addEventListener("load", downloadJSAtOnload, false);
    else if (window.attachEvent)
        window.attachEvent("onload", downloadJSAtOnload);
    else window.onload = downloadJSAtOnload;    
    </script>    

    <!-- CSRF Hash -->
            <script type="text/javascript">var csrf_hash = '08a7741386e2c74267869908dd0a5bb0';</script>

    <!-- Microdata -->
    <meta property="og:site_name" content="DaniWeb" />
    <meta property="og:image" content="http://static.daniweb.com/images/icon.png" />
    <link rel="image_src" type="image/png" href="http://static.daniweb.com/images/icon.png" />
    <meta property="fb:admins" content="509930074" />
    <link href="https://plus.google.com/+DaniWebCommunity" rel="publisher" />

            <link rel="home" href="http://www.daniweb.com/" />   
        <link rel="search" href="http://www.daniweb.com/search/query" />


    <!-- Google Analytics -->
        <script type="text/javascript">

      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-98289-1']);
      _gaq.push(['_trackPageview']);
      _gaq.push(['_trackPageLoadTime']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();

    </script>    

You can get on the site by navigating to a sub-forum directly.

Ketsuekiame 860 Master Poster Featured Poster

If the host doesn't have any documentation, find another host. If you pay for a simple development website that uses ASP.NET, they often come with database hosting. i realise you're looking for free but they can have some rather aggressive limitations.

Connecting to a SQL instance is done via ConnectionStrings. This site is good for figuring out connection strings. Typically you need the server address and the Instance name. You then treat it exactly as you would the local one, although expect latency.

Ketsuekiame 860 Master Poster Featured Poster

The actual approach would be fairly easy (although long-winded) if it weren't for the following case:

112014

112014
20th Nov 2014 or;
112014
1st Jan 2014 or;
112014
12th Jan 2014

All three are valid according to your interpretation rules, the code can make no distinction between any of them. Your only option here to ask the user which they mean. A problem that I don't think any heuristics would really be able to solve without an input/result history.

So you could gradually make the system better at guessing. But it won't ever really be 100% perfect.

Ketsuekiame 860 Master Poster Featured Poster

Hi AoD, I think it's because you're disposing of something that's being passed to your method.

This is pretty much a big no-no. You don't know what happens to that object outside of the method you've written, disposing of it could present problems.

Whilst I understand that calling dispose is freeing memory, you need to dispose of it further away. Essentially, the thing creating the object is also responsible for disposing of it (Unless you know for a fact that you should be disposing it. ie In the Dispose call or "OnUnload" etc.)

There are some things we need to know about how your method is used before making a committed decision however. How is that method called (what calls it and when), is the return signature important (your image is passed by reference, the caller may be expecting the reference to change).

I believe (personally) the mistake made here is that you're disposing in a location that doesn't indicate it's being disposed and as such has no responsibility for disposing (this method did not create the reference)

Ketsuekiame 860 Master Poster Featured Poster

blackmiau
Nope... it's fried.

t'was a joke :)

Ketsuekiame 860 Master Poster Featured Poster

It looks like you're using a high dpi setting for your fonts and the DirectX layer migh be trying to anti-alias it (this can give the experience of blurred lines as that's pretty much its job ;) )

Check that you don't have some kind of AA switch set and if you havem, set it to an even number of 4+ (Which I find fixes that)

You could also try reducing your "Font Size" in the Windows Personalise screen (looks like you're using Windows 8)

Ketsuekiame 860 Master Poster Featured Poster

This sounds very much like Coded UI

So it might be worth checking that out first. Otherwise, I'd recommend that you decide on what possible actions you can have. Examples might include "EnterURL", "Click Hyperlink", "Submit Form Details" etc.
Then whenever a user did something on your built in control, you could capture that action (with the enum) and provide some data. So in the case of "EnterURL" you would record the hyper link.

The action of recording would probably need to be done as it happened, which should be able to be picked up in your host (Fire an event).

Ketsuekiame 860 Master Poster Featured Poster

Give it a bit of a clean and it'll be fine ;)

Ketsuekiame 860 Master Poster Featured Poster

They are my babies and I love them so! :)

I've never had great luck with Panoramic shots. This one isn't great, the lighting isn't very good, probably needed some kind of dynamic exposure to increase the brightness of the surounding landscape. Still I find it quite pretty :)

Ketsuekiame 860 Master Poster Featured Poster

Here's a few of my photos :)

http://puu.sh/8TOCA <--- So relaxed. When I picked my camera up she was on her back, but she rolled onto her side as I got the camera in place.

http://puu.sh/8TPZa <--- Food coma time! They've just eaten and now it's time for a nap :)

http://puu.sh/8TOW1 <--- How many rats can you fit in a hammock designed for one? :P

http://puu.sh/8TP5O <--- Panoramic view of a sunset on Blackpool beach. I have some normal photos that are easier to look at of this sunset, but this is my first panoramic that came out correctly

Ketsuekiame 860 Master Poster Featured Poster

These things are called Command Line Arguments (for your reference).

You can retrieve them in a WinForms app by calling Environment.GetCommandLineArgs()

Command line arguments are space delimited, so if you entered /f:myfile.txt you would get "/f:myfile.txt" as a single argument in your application.

When you drag and drop, it simply passes the file path as an argument, which is exaclty what you want.