|
It's not a question.
If you have a complete set of distances (edges) between every two of all points then the shortest way between two given points will be line segment that connects these two points.
If you mean one of typical graph problems then try reading this article.
|
|
|
|
|
dead_link wrote: If you have a complete set of distances (edges) between every two of all points then the shortest way between two given points will be line segment that connects these two points.
Not neccesarily. Your statement also requires the triangle inequality to hold true.
AB 1
BC 1
AC 10
The shortest path from A to C is AB-BC, not AC.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Correct me if I'm wrong, but those segments (AB, BC, and AC) cannot be a triangle (the length of one side HAS to be less than the sum of the lengths of the other two sides).
If I'm misunderstanding the discussion, it wouldn't be a first time, so just tell me, "That's not what we're talking about," and I'll back out gracefully. Just thought I'd throw in two cents.
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
You're completely correct, on a flat surface the segments don't make a triangle. The triangle inequality states that for any A, B, and C that AB + BC > AC. Dead_link's answer implictly assumed that the inequality was in place, but the OP never made it an actual condition of his problem.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Oh, yes. I know it. But the word "distance" lets me think about points on a surface and about simple geometric task.
|
|
|
|
|
I want my application to behave like MSWord 2003. i.e. Multiple-SDI Application.
I am facing problem with the code that first window always close all other windows. Please identify changes.
<br />
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using System.IO;<br />
<br />
<br />
namespace MultipleSDI<br />
{<br />
public partial class TopLevelForm : Form<br />
{<br />
<br />
string fileName;<br />
static int formCount = 0;<br />
<br />
public TopLevelForm()<br />
{<br />
InitializeComponent();<br />
<br />
MultiSDIApplication.Application.AddTopLevelForm(this);<br />
MultiSDIApplication.Application.AddWindowMenu(this.windowToolStripMenuItem);<br />
<br />
<br />
++formCount;<br />
this.Text += ": " + formCount.ToString();<br />
}<br />
<br />
<br />
public static TopLevelForm CreateTopLevelWindow(string fileName) <br />
{<br />
<br />
if (!string.IsNullOrEmpty(fileName))<br />
{<br />
foreach (TopLevelForm openForm in Application.OpenForms)<br />
{<br />
if (string.Compare(openForm.FileName, fileName, true) == 0)<br />
{<br />
openForm.Activate();<br />
return openForm;<br />
}<br />
}<br />
}<br />
<br />
TopLevelForm form = new TopLevelForm();<br />
form.OpenFile(fileName);<br />
form.Show();<br />
<br />
form.Activate();<br />
return form;<br />
<br />
}<br />
<br />
private void openToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
if (this.openFileDialog.ShowDialog() == DialogResult.OK)<br />
{<br />
TopLevelForm.CreateTopLevelWindow(this.openFileDialog.FileName);<br />
}<br />
<br />
}<br />
<br />
void OpenFile(string fileName)<br />
{<br />
this.fileName = fileName;<br />
if (!string.IsNullOrEmpty(fileName))<br />
{<br />
using (StreamReader reader = new StreamReader(fileName))<br />
{<br />
textBox.Text = reader.ReadToEnd();<br />
}<br />
}<br />
else this.fileName = "untitled" + formCount.ToString();<br />
this.Text = this.Text + " (" + this.fileName + ")";<br />
}<br />
<br />
string FileName<br />
{<br />
get { return this.fileName; }<br />
}<br />
<br />
private void newToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
TopLevelForm.CreateTopLevelWindow(null);<br />
}<br />
<br />
<br />
<br />
}<br />
}<br />
<br />
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using Microsoft.VisualBasic.ApplicationServices;<br />
using System.Collections.ObjectModel;<br />
<br />
<br />
<br />
namespace MultipleSDI<br />
{<br />
class MultiSDIApplication : WindowsFormsApplicationBase<br />
{<br />
<br />
static MultiSDIApplication application;<br />
internal static MultiSDIApplication Application<br />
{<br />
get<br />
{<br />
if (application == null)<br />
{<br />
application = new MultiSDIApplication();<br />
}<br />
return application;<br />
}<br />
}<br />
<br />
public MultiSDIApplication()<br />
{<br />
<br />
<br />
<br />
this.IsSingleInstance = true;<br />
<br />
<br />
this.ShutdownStyle = ShutdownMode.AfterAllFormsClose;
<br />
<br />
}<br />
<br />
protected override void OnCreateMainForm()<br />
{<br />
this.MainForm = this.CreateTopLevelWindow(this.CommandLineArgs);<br />
}<br />
<br />
TopLevelForm CreateTopLevelWindow(ReadOnlyCollection<string> args)<br />
{<br />
<br />
string fileName = (args.Count > 0 ? args[0] : null);<br />
<br />
return TopLevelForm.CreateTopLevelWindow(fileName);<br />
}<br />
<br />
protected override void OnStartupNextInstance(StartupNextInstanceEventArgs e)<br />
{<br />
this.CreateTopLevelWindow(e.CommandLine);<br />
}<br />
<br />
public void AddTopLevelForm(Form form)<br />
{<br />
<br />
form.Activated += Form_Activated;<br />
form.FormClosed += Form_FormClosed;<br />
<br />
if (this.OpenForms.Count == 1) this.MainForm = form;<br />
}<br />
<br />
void Form_Activated(object sender, EventArgs e) <br />
{<br />
this.MainForm = (Form)sender;<br />
}<br />
<br />
void Form_FormClosed(object sender, FormClosedEventArgs e) <br />
{<br />
if( ((Form)sender == this.MainForm) && (this.OpenForms.Count > 0) ) <br />
{<br />
MessageBox.Show("I reached here" + this.OpenForms.Count.ToString());<br />
this.MainForm = (Form)this.OpenForms[0];<br />
}<br />
<br />
MainForm.Activated -= Form_Activated;<br />
MainForm.FormClosed -= Form_FormClosed;<br />
}<br />
<br />
public void AddWindowMenu(ToolStripMenuItem windowMenu) <br />
{<br />
windowMenu.DropDownOpening += windowMenu_DropDownOpening;<br />
}<br />
<br />
<br />
void windowMenu_DropDownOpening(object sender, EventArgs e) <br />
{<br />
ToolStripMenuItem menu = (ToolStripMenuItem)sender;<br />
<br />
if( menu.DropDownItems.Count > 0 ) <br />
{<br />
menu.DropDown.Dispose();<br />
}<br />
<br />
menu.DropDown = new ToolStripDropDown();<br />
<br />
foreach( Form form in this.OpenForms ) <br />
{<br />
ToolStripMenuItem item = new ToolStripMenuItem();<br />
item.Text = form.Text;<br />
item.Tag = form;<br />
menu.DropDownItems.Add(item);<br />
item.Click += WindowMenuItem_Click;<br />
<br />
if( form == this.MainForm ) item.Checked = true;<br />
}<br />
}<br />
<br />
void WindowMenuItem_Click(object sender, EventArgs e)<br />
{<br />
((Form)((ToolStripMenuItem)sender).Tag).Activate();<br />
}<br />
<br />
<br />
<br />
}<br />
}<br />
<br />
<br />
<br />
|
|
|
|
|
First of all, putting large amounts of code in a post is not a good idea, since few people will take the time to check it out. And if you don't explain what's going on, it is hard to understand at first glance.
But here is an idea: maybe your message loop is running on your first window, so when it is closed the message loop returns and the app is closed. I would create an invisible window, run the message loop on it, and when the last window is closed, kill that window. You can also use that hidden window to get a list of all windows (for the Window menu, for example).
I hope this helps.
|
|
|
|
|
Is there a way to use reflection to get the variable name that a method is called on ?
For instance ...
<br />
class foo {<br />
public override string ToString() {<br />
return GetType().toString() + " " + GetType().??? VaraibleName ???;<br />
}<br />
}<br />
<br />
.<br />
.<br />
.<br />
<br />
foo myFoo = new foo();<br />
Console.WriteLine( myFoo.toString());<br />
Should ouput
foo myFoo
|
|
|
|
|
I wouldn't expect you could because variable names are stored only in your code, once you've compiled they go away. You could tell things like class name, etc., but not variable name.
|
|
|
|
|
That figures. I just wanted to do some screen dumps while I develop/run and see the values of the variables. I was hoping the variable names could be auto-generated.
Anyway, thank you for the quick reply.
|
|
|
|
|
RascalRobot wrote: wanted to do some screen dumps while I develop/run and see the values of the variables
It's called the debugger, it comes with VS
only two letters away from being an asset
|
|
|
|
|
That would work if I were allowed to install VS on the target machine.
I am only allowed to install the final .exe on the target which is not
connected to our network. In other words, no debug tools allowed.
|
|
|
|
|
There is the thing about being specific in your request. You said, "while I develop/run". To me this implied a development environment.
Your left with trace output, event logs, remote debugging, etc.
only two letters away from being an asset
|
|
|
|
|
Two thoughts - one you could either use Tracing or you could do the following:
http://blogs.msdn.com/yosit/archive/2003/06/20/9024.aspx[^]
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
possible if and only if it is a class level variable! it becomes a fields, if it just has a scope in a method alone, 100 % not possible
experiencing the experience
|
|
|
|
|
I have a nifty little app that saves information from a richtextbox to an access table and retrieves it. doing inserts, deletes and selects work fantastic every time, but the portion where i try to do a simple Update statement fails miserably.
here is the updat ecode i am using:
OleDbCommand oc = ocom;<br />
<br />
oc.CommandText = "UPDATE hold SET nm = @nm, content = @cont WHERE [id] = @id";<br />
<br />
oc.Parameters.Add("@id", OleDbType.Integer).Value = id;<br />
oc.Parameters.Add("@nm", OleDbType.VarChar).Value = nm;<br />
oc.Parameters.Add("@cont", OleDbType.VarBinary).Value = b;<br />
<br />
oc.Connection.Open();<br />
<br />
oc.ExecuteNonQuery();<br />
oc.Connection.Close();<br />
whener i run this, i get no exceptions or cute messages, and it isnt hidden in a try/catch statement and just getting overlooked, it just runs, but doesnt actually update the table. Has anyone seen this before?
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
I already figured it out... This has been bothering me for months, too. the difference is pretty subtle:
OleDbCommand oc = ocom;<br />
<br />
oc.Connection.Open();<br />
<br />
oc.CommandText = "UPDATE Hold SET content = @cont WHERE [id] = " + id.ToString();<br />
<br />
<br />
oc.Parameters.Add("@cont", OleDbType.VarBinary).Value = b;<br />
oc.ExecuteNonQuery();<br />
oc.Connection.Close();<br />
oc.Connection.Dispose();<br />
oc.Dispose();
Apparently, Access doesnt like it when you parameterize the id in the where section.
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
Hi!
I have MS SQL Server 2005 installed on my system. I am using NHibernate to interact with my database named 'BRUSDB'. I have set the following configuration for nhibernate:
<configuration>
<configsections>
<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvi der"
="">
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2005Dialect"
="">
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver"
="">
<add
key="hibernate.connection.connection_string"
value="server=server; database=BRUSDB;user=sa;pwd=sorcim"
="">
when i run the program The type initializer for 'NHibernate.Cfg.Configuration' threw an exception:
'System.TypeInitializationException'
at line:
Configuration cfg = new Configuration();
If any one has know then kindly guid me.
Thanks.
|
|
|
|
|
Don't post the same question twice, esepcially an hour apart.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
The contents a pasted in the first post were completely appeared there. I tried it again to enable the viewer interpret the message. But agin the same hell occured.
|
|
|
|
|
First, I am using sql statement to create table like "CREATE TABLE"; I have several tables to create with a lot of fields and I find out it is very inconvenient to do. I keep getting sentax error and it takes me time to fix. I want to know if there is any other way to do that if I don't wnat to do the wizard.
Does microsoft access provides a translator for sql. Assume that I have the table in access, can it gives me the correspondent sql statement for that table?
The sedcond question I have, I also wnat to create an access file (.mdb) for that table. Right now I have to create an empty file than put the table to it. I mean an empty access file from ms access. So how can I create an access file
here is the way I do it
<br />
OleDbConnection dbConnection;<br />
dbConnection = new OleDbConnection();<br />
string tableName = "Table Name";<br />
dbConnection.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0; " +<br />
"Data Source = " + Application.StartupPath + "\\EmptyFile.mdb";<br />
show how can I use the OleDbConnection to create a new access file before I put any table to it
also how to autoincrement the primary field or set it to true?
-- modified at 13:53 Friday 8th December, 2006
|
|
|
|
|
Sorry if this sounds rather blunt, but, for a beginner, you are trying to do stuff that is too advanced. Suggest that your take your time learning the basics using those on-line tutorials that I pointed you towards before you try anything more complicated. When you have learned the basics (don't expect to run before you can walk), you can then think about learning more advanced stuff or you will end up being totally confused.
Two good books for you to study after you have learned the basics are ...
(1) Programming SQL Server 2005. By Bill Hamilton. Publisher : O'Reilly
(2) Microsoft SQL Server 2005 Stored Procedure Programming in T-SQL & .NET, Third Edition. by Dejan Šunderi. Publisher : McGraw-Hill/Osborne
modified 1-Aug-19 21:02pm.
|
|
|
|
|
I'm developing restaurant software for my family business and need some input as to how to implement an ordering system. I will have 2 computers networked together, one being at the cash register (REGISTER), and the other in the kitchen (KITCHEN). Here is the scenario that I'm envisioning.
Waitress(er) takes the order, submits to the cash register. Order gets inputted into (REGISTER) and is stored into a database. Database will have 2 linked tables, the main table will have [table_number, number_of_people, total_due, date, order_number (primary key)] The second table will use order_number as the foreign key and then have order information[ quantity, item, subtotal]. I think I've got a handle on the REGISTER software...
My problem is, what type of client software must be put onto KITCHEN so that it can monitor the database for changes? Ideally I would like a messageBox to pop up with the order information that can be dismissed when the order is completed. Would the CLIENT software check (every 5 secs?) the up to date of the DB? Not quite sure what to do. Please help
Henry
|
|
|
|
|
i would recommend u to go for event driven programming,
subscriber / publicher architecture,
u can also go for message queuing so that u can put ur orders in a queue and process them
|
|
|
|
|
You could use this type of mechanism
http://www.codeproject.com/cs/database/chatter.asp[^]
You are starting out simple enough but you'll probably find you'll need, or want, the system to do a whole lot more, like tying the order items and qty to your inventory so you can analyze loss and effeciency etc. I've built retail systems in the past to control grocery store check and inventory management.
only two letters away from being an asset
|
|
|
|