|
I have three unknowns..
float hours;
float minutes;
float seconds;
I use them to draw correct pointers, which are refreshing all the time.
Now i want to know how to retrieve elapsed seconds, minutes and hours from timer start to write them in those three unknowns all the time for drawing??
|
|
|
|
|
see timespan
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I created a program to capture the video from 4 cameras, would have access to the live image from the Internet, What is the best way to view the Internet.
|
|
|
|
|
Alex_xso wrote: What is the best way to view the Internet
Open a web browser??
Alex_xso wrote: I created a program to capture the video from 4 cameras, would have access to the live image from the Internet,
Are you saying that you want to view the live video over the Internet?? In that case, you would need a streaming server, such a Microsoft's Windows Media Encoder[^]. Then you just provide links to the streams exposed by that server. The streams will open up in Media Player on the client machines.
|
|
|
|
|
Any example?
|
|
|
|
|
Don't have any. If you're using webcams, then you just need to setup the Media Exocding Server once. You wouldn't need a code example for something you do by hand.
|
|
|
|
|
How does one have mdichildren forms automatically sized to fit the parent form?
My situation is I may have 5 to 10 child form at once and I would like to see all at once.
I'm developing in C# in Visual Studio 2005
Any and all suggestion are appreciated.
Thanks
|
|
|
|
|
If I recall correctly you have to set a property in the parent called MdiLayout
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanks,
I'm developing in VS2005 and it doesn't have that setting in the property view.
But that gives me an idea of what to look for and I'll still take any other answer
Thanks
|
|
|
|
|
I've just checked it and it's a method you need to call in the Parent, check the MdiLayout enum on MSDN for values.
this.LayoutMdi(MdiLayout.Cascade);
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Let's say that you have a SortedList with the Key as a string and the Value as a struct. Also, the string Key is one of the data elements in the struct. Example:
using System;
using System.Collections.Generic;
namespace SortedListStructure
{
public struct Product
{
public string model;
public string description;
public int weight;
public int height;
public int width;
public int length;
};
class Program
{
static void Main(string[] args)
{
SortedList<string, Product> sl = new SortedList<string, Product>();
Product test;
test.model = "1X-3PA2Q94";
test.description = "Tractor Motor Sensor";
test.weight = 3;
test.height = 3;
test.width = 3;
test.length = 3;
sl.Add(test.model, test);
string m = test.model;
if (sl.ContainsKey(m))
{
Console.WriteLine("Description: {0}, Weight: {1}", sl[m].description, sl[m].weight);
}
else
{
Console.WriteLine("{0} not found", m);
}
Console.ReadLine();
}
}
}
While this works, the model is stored twice (I think? Is it?), once for the Key and once as one of the elements of the Product Value. One way to eliminate this redundancy would be to leave model out of the Product struct, but assume that this is not preferable. What is the most efficient approach when the Key is part of the Value?
|
|
|
|
|
Yes, the model is stored twice. But I think that is right and proper. I would not be happy removing "model" from "Product" as it is obviously a proper part of the data. Equally, it is a very sensible key for your sorted list.
You could save space (and maybe some processing time, but I doubt it) by using the hash value of the model string as the key, but then it is unlikely that the sort order would be the same. I assume you are using a SortedList because you want to iterate in model order - so the model itself has to be the key.
I would live with this. Removing "model" from "Product" means that that infromation is incomplete when processing in methods that don't know about your list.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Yes, removing model from Product should be considered off the table. I was just wondering (purely hypothetical ) if there was a more elegant solution in which rather than having two separate lists of models, if somehow the Key referenced the model within product. I don't know if this is actually worth the trouble or even possible. It is not necessary to work but would be nice in terms of memory overhead. You could imagine a scaled up version of this problem in which the Key itself is a big complex struct or object and the Value is an even bigger struct or object that has the Key as one of its data elements (don't know how often this would actually come up since big numbers can index anything).
|
|
|
|
|
Yes, when it gets scaled up it is a problem. I think then that you have to come up with a hashing scheme which preserves your sort order, and use that as the key instead. The only other way I can think of immediately is to use an unsorted list, and sort it by model. Yeuch.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi,
the content of the "model" string, i.e. the actual characters, are stored only once. What is stored twice is the reference to the string, which takes 4 or 8 bytes depending on Win32/Win64; so the penalty for having the key also in the struct is very low.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
|
I'd forgotten that (still not completely used to managed code hiding the details).
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Actually, you would only have redundant references to the Product model string when using the SortedList<K, T> type. The model string is not actually duplicated in memory. While I've never done any performance analysis of SortedList or any of the other .NET collection types, I think what you are doing now is probably your best solution.
If this isn't acceptable and you can use .NET 3.5, you could use LINQ to create a sorted List<T> that would only include your Product structs.
IList<Product> sl = (from p in ul
orderby p.model
select p).ToList<Product>();
|
|
|
|
|
What I'm looking is a source code to show me how to make and use menus. Here's a
sample of what I have. and Some of it works and some of it doesn't
--------------------------------------------------------
//Main Menu
MainMenu:
terminal.ClearScreen();
terminal.WriteLine();
terminal.WriteLine("Welcome :" + name);
terminal.WriteLine("1) Game Menu");
terminal.WriteLine("2) N/A");
terminal.WriteLine("3) Help");
terminal.WriteLine("9) Quit");
terminal.TranslateFile("Menu.txt", true);
terminal.Write("Choice : (1,2,3 0r 9)");
int caseSwitch = terminal.ReadDigit();
switch (caseSwitch)
{
case 1:
Functions NewGame = new Functions();
NewGame.GameMenu();
goto MainMenu;
case 2:
terminal.WriteLine("Case 2");
goto MainMenu;
case 9:
break;
default:
terminal.WriteLine("Invalid Key");
terminal.PromptEnter("Press ENTER to Continue..");
goto MainMenu;
}
------------------------------------------------
|
|
|
|
|
bigjoe11a wrote: Some of it works and some of it doesn't
Are we supposed to guess which parts work and which don't?
Every time you use a goto a kitten gets punched in the face. Why do you hate kittens so much?
|
|
|
|
|
Ok, why not. LOL. I mean it doesn't work at all. When I press 1. it just returns to the menu. and so on. Or the default just loads.
DO you know of a sample source code that will show me how to do this the right way.
--------------------------------------------------------------------
MainMenu:
terminal.ClearScreen();
terminal.WriteLine();
terminal.WriteLine("Welcome :" + name);
terminal.WriteLine("1) Game Menu");
terminal.WriteLine("2) List Users");
terminal.WriteLine("3) Help");
terminal.WriteLine("9) Quit");
terminal.Write("Choice : (1,2,3 0r 9)");
int caseSwitch = terminal.ReadDigit();
switch (caseSwitch)
{
case 1:
Functions NewGame = new Functions();
NewGame.GameMenu();
goto MainMenu;
case 2:
terminal.WriteLine("Case 2");
goto MainMenu;
case 3:
Functions NewHelp = new Functions();
NewHelp.Help();
goto MainMenu;
case 9:
break;
default:
terminal.WriteLine("Invalid Key");
terminal.PromptEnter("Press ENTER to Continue..");
goto MainMenu;
}
-----------------------------------------
|
|
|
|
|
Seriously, goto s are the biggest indicator in the world of poorly structured code. Code flow should be handle by conditionals and loops and I'm guessing that's the main cause of your problems. My beginners attempt would start like this:
Semi-Psuedo Code:
bool done = false;
while (!done)
{
int userInput = 0;
do
{
PrintMainMenu();
userInput = GetNextInput();
} while (!InputIsValid(userInput));
switch (userInput)
{
case 0:
PrintHelpMenu();
break;
case 1:
RunGamesMenu();
break;
case 2:
Console.WriteLine("Exiting");
done = true;
break;
}
}
P.S. put pre tags around code snippets to preserve formatting
|
|
|
|
|
Thanks, Can you give me an idea about what the PrintMainMenu would look like and a sample of the code used to make it. Or make be I'm getting to old to program.
Thanks
|
|
|
|
|
it would contain something like this (from your original post):
terminal.ClearScreen();
terminal.WriteLine();
terminal.WriteLine("Welcome :" + name);
terminal.WriteLine("1) Game Menu");
terminal.WriteLine("2) N/A");
terminal.WriteLine("3) Help");
terminal.WriteLine("9) Quit");
I just stuck a function there to save space in the post
|
|
|
|
|
Rule 1: Use the "code block" button below to preserve formatting. It makes things easier to read.
Rule 2: unless you are a seriously experienced programmer and there is a very good reason, do not use goto. It will earn you nothing but grief and abuse here.
Rule 3: Learn about loops. Learn about data types. Learn at least the basics of C#.
Rule 4: Learn there is a difference between "Console" and "Terminal" (one exists, the other doesn't)
Having said that, I'm in a good mood:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Demo
{
class Program
{
static void Main(string[] args)
{
string name;
Console.Write("Enter your name: ");
name = Console.ReadLine();
Console.WriteLine("\nWelcome : " + name);
Console.WriteLine("1) Game Menu");
Console.WriteLine("2) List Users");
Console.WriteLine("3) Help");
Console.WriteLine("9) Quit");
Console.Write("Choice : (1,2,3 or 9) ");
int i = 0;
do
{
string s = Console.ReadLine();
if (s == "")
{
continue;
}
i = s[0];
switch (i)
{
case '1':
Console.WriteLine("Game selected");
break;
case '2':
Console.WriteLine("List selected");
break;
case '3':
Console.WriteLine("Help selected");
break;
case '9':
Console.WriteLine("Quit selected");
break;
default:
Console.WriteLine("Invalid Key");
break;
}
}
while (i != '9');
}
}
}
This is not perfect (I threw it together from your code), but it has the advantage of working...
Now, for your homework, please post a complete explaination of how it works.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|