|
|
A common way to do this is to use the index API which requires you to use the IFilter[^] interface.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I am making a game in XNA and I have a component that accepts some parameters (rows,columns and tile size) and renders a two-dimensional grid where I like (its visual).
As I have started to plan my software I know that some of the Grid settings such as "Tile Width/Height" may need to be read from other objects later on such as a Windows form that can change the grid settings...
I have read that a "interface between components" is good practice so would any one advise me to create a class that allows another class to receive data from the grid?
Such functionality :
GetTileWidth,GetTileHeight,GetRows .....
So for example:
GridEditorForm ---->gets the tile height from ---> GridDetails --> gets tile height from ---> Grid
instead of:
GridEditorForm ---> gets the tile height from ---> Grid
?
Another idea I had was to have some kind of "Struct" that stores the grid data that may be read from other objects and make an interface to pass about its information?
Such as:
struct GridDetails:
tilewidth,tile height,rows
....
Thanks
|
|
|
|
|
It sounds to me your game has properties such as Width, Height, and others. So whoever creates such game instance should be able to set those properties, just like you do with a Panel or any other Control. Hence my suggestion is: make it passive, go tell it its properties when you need to, don't let it go and search its parameters on its own.
|
|
|
|
|
The Grid can have its dimension changed at runtime though by a separate windows form, ie when the form changes "tile width" (logical part) the grid will automatically change its tile size (visual part) but im trying to separate the logical and visual.
My grid is generated by the from however other components need to access the grids properties thus making the "Who ever created it can change its properties" not work well :/
Thanks for your comment!
|
|
|
|
|
I'm trying to query a DataSet like this:
DataTable ResultSet = new DataTable();
csCOSApp.ActiveProject.dsDataStore.Tables[0].Select("ProductId > 0").CopyToDataTable(ResultSet, LoadOption.PreserveChanges, delegate { });
if (ResultSet.Rows.Count > 0)
{
LoadProducts(ResultSet, true);
}
csCOSApp.ActiveProject.dsDataStore.Tables[0].Select("ProductId = 0").CopyToDataTable(ResultSet, LoadOption.PreserveChanges, delegate { });
if (ResultSet.Rows.Count > 0)
{
LoadParts(ResultSet, true);
}
The first query, "ProductId > 0" works fine. The second one, "ProductId = 0" throws the error "Input array is longer than the number of columns in this table.". They're both pulling from the same data table. At runtime there are 2 rows where ProductId = 0.
Why would one work and the other fail?
Everything makes sense in someone's mind
|
|
|
|
|
Hi,
I don't know the answer. However, I do know entering such an error message into Google is a great first step at solving such problems. Chances are this discussion[^] applies.
|
|
|
|
|
Golly geee!!! Why didn't I think of that???
Did you look at any of the Google results? Apparently not, because no where in my code am I using LoadDataRow. None of the Google rsults I found are relevant to my issue - which is why I posted here.
Everything makes sense in someone's mind
|
|
|
|
|
Kevin Marois wrote: Why would one work and the other fail?
Because the parts table and the products table don't have the same number of columns, but you've already initialized the DataTable ResultSet in the first call, and not cleared it before re-using it? I'd suggest disposing it and creating a new empty one rather than just re-using the same one.
|
|
|
|
|
I have a c# windows application with sql server databse.i need to deploy this project on my client's machine where sql server is not installed. so please clarrify my doubts
1.how to attach my database to set up file so that it is available to the client's machine.
2. as there is no sql server on the client machine, can i add sql server installer to the
set up file?if so how ...
if not ... any other way
3. and there are some problems with the sql server instances... help me out plz
|
|
|
|
|
Hi , have a good day
1- Don't Attach your database , Use Creation Script , INSERT Script , instead !
2- you can't add Sql files to the VS setup , the best way is to use http://www.installaware.com/[^]
Or you can Add the MSDE folder ( Sql Client ) next to your setup project
So the client can install it manually .
- I run the sql script to create database from my Application NOT from the setup
class InitSchema
{
private static string strScript = global::BuyerQty.Properties.Resources.Scheme;
public static void InitSchemaScript()
{
DBConnect.DBCommand = new OleDbCommand("USE " + clsSetting.DataBase, DBConnect.DBConnection);
DBConnect.DBCommand.ExecuteNonQuery();
strScript = strScript.Replace("GO", "~");
foreach (string strQuery in strScript.Split('~'))
{
try
{
DBConnect.DBCommand = new OleDbCommand(strQuery, DBConnect.DBConnection);
DBConnect.DBCommand.ExecuteNonQuery();
}
catch
{
}
}
}
}
I am C# Windows Applications , Sql programmer , and I have been through this case many times
- Only for my very stupid customers I use Click once installation for Sql like Installaware
- I use NSIS setup to deploy the Application and DotNet , and the Customer must install Sql Manually
P.S:
I hate to have 2 or more Sql Instance on my customer machine
Hope this help
I know nothing , I know nothing ...
modified on Sunday, July 18, 2010 5:38 PM
|
|
|
|
|
does c# support inherit attributes to for the child class ?
|
|
|
|
|
The ugly answer is some do, some don't.
For example, Serializable doesn't - because the class author has no idea if derived classes are serializable, it is up to the derived class author.
However it is possible to create class attributes with "Inherited=true" See Attributes in C#[^]
for details.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
|
thanx..OriginalGriff. it really nice..i was also having the problem with serializable attribute, because the object class holds that attribute . it must be marked as false for inheritance .
thanx Abhinav S .
|
|
|
|
|
Hi
i have a simple app which display emplyees organization chart from northwind database. here is my code to accomplish this :
private void btnLoadData_Click(object sender, EventArgs e)
{
this.treeView1.Nodes.Clear();
this._dtEmployees = this.GetEmployees();
this.FillHieraricalData(this._dtEmployees, this.treeView1, "LastName", "EmployeeID", "ReportsTo");
this.treeView1.ExpandAll();
}
private DataTable GetEmployees()
{
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection(Properties.Settings.Default.NorthwindConnectionString))
{
SqlCommand cmd = con.CreateCommand();
cmd.CommandText = "select * from employees";
con.Open();
dt.Load(cmd.ExecuteReader());
con.Close();
}
return dt;
}
private void FillHieraricalData(DataTable dt, TreeView treeView, string infoColumnName,
string pkColumnName, string parentColumnName)
{
TreeNode node = null;
foreach (DataRow row in dt.Rows)
{
node = new TreeNode(row[infoColumnName].ToString());
node.Tag = row[pkColumnName];
if (row[parentColumnName] != DBNull.Value)
{
List<TreeNode> foundNodes = new List<TreeNode>();
SearchNodeInTreeView(treeView.Nodes, Convert.ToInt32(row[parentColumnName]), foundNodes);
if (foundNodes.Count > 0)
foundNodes[0].Nodes.Add(node);
}
else
treeView.Nodes.Add(node);
}
}
private void SearchNodeInTreeView(TreeNodeCollection nodesToSearch, int value, List<TreeNode> foundNodes)
{
for (int i = 0; i < nodesToSearch.Count; i++)
{
if (Convert.ToInt32(nodesToSearch[i].Tag) == value)
foundNodes.Add(nodesToSearch[i]);
SearchNodeInTreeView(nodesToSearch[i].Nodes, value, foundNodes);
}
}
However, when i update data in memory (via dataTable) and redisplay data in treeView, the row that has been modfied has been removed from treeView and not display. for example, when i change 'Reports To' of any employee, that employee does not display in treeView! here is my code to accomplish this :
private void btnSave_Click(object sender, EventArgs e)
{
this.UpdateDataRowFromUI(this._currentRow);
this._dtEmployees.AcceptChanges();
this.treeView1.Nodes.Clear();
this.FillHieraricalData(this._dtEmployees, this.treeView1, "LastName", "EmployeeID", "ReportsTo");
this.treeView1.ExpandAll();
}
private void UpdateDataRowFromUI(DataRow row)
{
row["LastName"] = txtLastName.Text;
row["FirstName"] = txtFirstName.Text;
row["ReportsTo"] = cmbReportsTo.SelectedValue;
}
Where is my problem and how to solve it ?
thanks in advance ?
|
|
|
|
|
You are putting the row id into the tag property
node.Tag = row[pkColumnName];
But I don't see where you find that row to update the record when editing. You may be updating row[0] all the time.
I have been known to stick the entire row object into the tag property.
node.Tag = row;
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks Mycroft
but still i have the same problem.
|
|
|
|
|
|
If you have a question, post it here.
If you want us to download anonymous files from unknown people, think again.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Hi
I'm creating an application using the avicap dll. Currently it is still a testing app. There are two pictureboxes on the form, which are passed to the dll. Each picturebox is used for a different webcam. This all works beautifully. However when I activated both the webcams at the same time I noticed an extreme delays between the pictures from different cams and the application demands as low delays as possible. So I did some testing. First I ran two instances of the app. This showed no delays. So I thought, perhaps the delays are from running in the same thread. But that can't be, because the dll uses callbacks. So I ran a single instance of the app, but covered one of the pictures with another app (notepad). Delay was gone for as long I covered one of the pictures entirely. So it has to be the paint event. Is there a way to tell the application to sync these events? Or catch them and to sync myself?
Steven
|
|
|
|
|
Hi,
1.
I'm not sure I follow the logic in your post. However:
2.
Turning an image (probably JPEG file or stream) into a visible image on screen takes some time. If you want to have several new images appear as close together as possible, I would:
- create bitmaps of the right size
- when all of them are available, assign those to the PictureBoxes' Image properties (with PictureNoxSizeMode.Normal)
so I would not let the PB do any decoding nor resizing.
3.
And in fact I would not even be using PictureBoxes at all, they are pretty useless anyway, except for the simplest of jobs, which you can easily deal with otherwise, e.g. using a Panel and a Paint event handler.
PS: don't forget to dispose of images/bitmaps you no longer need!
|
|
|
|
|
Hi
You're completely right about the picturebox, I will change it with a panel right away.
Saving the images and applying them when the are all ready is not an option. It's a live video feed.
The picturesboxes are passed on with their handle, so I don't really know how the dll does it, but I guess it simply draws the image in the region of the control. The performance here is sufficient at the moment, except when I run two cams at once AND in the same app window. On seperate instances the performance is again optimal. I came to the conclusion that the dll invokes the paint method, but since two cams are active they continuously call the paint method. Hereby using (theoretically) the double amount of time. This wouldn't occur when I can sync the paint events, so the form is only invalidated when both cams send data. Or an other idea... Since running two instances, each with an other cam, doesn't give any performance loss either. I could split the paint event into a left and right section of the form somehow...
I hope this explanation was a bit more helpful
Steven
Off-topic: Were you on the news today? I saw your name passing by, but maybe it was someone else. Just curious though
|
|
|
|
|
if two processes work fine for you, you can have three of them: two camera ones, and a master; each camera would display into its own Form, the master would host those Forms using TopLevel=false;
What news?
|
|
|
|
|
Wow... what??
Do you mean two forms inside a master form? Or am I misreading that?
Something about children getting sick at a camp due to food poisoning.
|
|
|
|
|