|
|
Antonio David Gonzalez wrote: This article explains several ways to clone objects in C#:
netJP12L wrote: IHTMLDocument2
Antonio, IHTMLDocument2 is a COM Interface, not a managed object.
led mike
|
|
|
|
|
So what do you guys think how should i copy the data. The problem is that I want to see if doc1 objects has been changed or not by comparing the initial state of the doc1 and storing in doc2.
i.e
if(doc1.body.innerhtml!=doc2.body.innerhtml)
{
MessageBoxshow("doc1 object has been changed");
}
|
|
|
|
|
netJP12L wrote: I want to see if doc1 objects has been changed or not by comparing the initial state of the doc1 and storing in doc2.
i.e
if(doc1.body.innerhtml!=doc2.body.innerhtml)
By comparing the html string? Why do you need a second COM object to compare strings?
led mike
|
|
|
|
|
Thanks for replying but it doesn't work by comparing the two strings may be iam doing something very silly, that's why i am trying to create two object. The 2nd object holds the 1st object inital state data.
|
|
|
|
|
netJP12L wrote: but it doesn't work by comparing the two strings
I don't understand. You posted the code showing that you wanted to compare the two strings
netJP12L wrote: if(doc1.body.innerhtml!=doc2.body.innerhtml)
All I am saying is that you don't need another COM object to compare strings. If you don't know what your requirements are I certainly don't. If you ever figure out what the requirements are maybe you could post them and someone could help you.
led mike
|
|
|
|
|
|
Antonio David Gonzalez wrote: Anybody knows a better way to do this?
Do what?
led mike
|
|
|
|
|
If you are not using a sql database do it will help of xml.
You add new row with data from where?
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
I am trying to put together a quick and dirty app, but have hit a problem and need a litle help!!
basically i have a DataAdpter and fill a datatable. This is then bound to a grid, and the user can edit the data (not add or delete records tho)
Easy so far!
Then they can click save and i call
_adapter.Update(_dataTable);
now if some of the data has been changed in the database i get an DBConcurrencyException. What i really want to do is prompt the user for each record that has changed by another app in the database, and ask if they want to force their values on the record or abort that record update, and continue with the rest. Can i do this, still using the _adapter.Update method? if not, whats the easyest (sp) way to do it
Many Thanks
Mark
|
|
|
|
|
after some digging, i have found the answer
adapter.ContinueUpdateOnError = true; will make sure it continues after an error
and
SqlCeCommandBuilder builder = new SqlCeCommandBuilder(adapter);
builder.ConflictOption = ConflictOption.OverwriteChanges;
Makes it a last in wins, which will do for my app.
|
|
|
|
|
Hi all.
I have a problem and i can't seem to solve it.
I have a DataTable with all the Data a need. From time to time i need to make a call to the DataBase to refresh the DataTable. I need to add/update/remove the rows from the DataTable comparing them to the rows that came from the DataBase.
How can i do that? I can add the new rows, but if some rows where deleted/updated in the DataBase how can i delete/update them from my DataTable?
|
|
|
|
|
How about just clearing the DataTable and re-grabbing the data from the database. since you're bring all the data down anyway, it would probably save some CPU time as well.
Hogan
|
|
|
|
|
Thats right. But theres only one problem. If the user has scroll down the Grid and i clear the DataTable and refill-it then scroll will go to the first item in the list. Is there a way of avoinding that?
Thanks for your reply.
|
|
|
|
|
My file contains records which look like this:
EMPLOYEE001,M,20081105
First column is employee ID, second is gender and third is date.
I want to read this from a comma separated variable text file and think a regular expression is the way to do it. I do not want to create a dataset from the file.
Help much appreciated
|
|
|
|
|
Member 5646867 wrote:
Help much appreciated
To do what? You haven't asked a question, and a regular expression will not read records from a file.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Sorry for not being more clear. I will use a regular expression to validate my record I read from the .csv file.
Like this:
Regex regex = new Regex(expression);
string[] parts = regex.Split(record);
Sorry again
|
|
|
|
|
Member 5646867 wrote: and think a regular expression is the way to do it.
And you are basing that on? If you don't know how to use regular expressions, why do you think that's the way to do it?
led mike
|
|
|
|
|
Please see my answer above
Sorry, but I thought I wouldn't need to explain that I could get the record from the .csv text file.
|
|
|
|
|
This:
<br />
",(?=([^\"]*\"[^\"]*\")*(?![^\"]*\"))"
Evil cannot be conquered in the world... It can only be resisted within oneself.
|
|
|
|
|
I have done a code on 3D office. I would like to do it in interactive way which by pressing the arrow button, the object can be viewed from different perspective. However, my result come out with static image and my objects all disappear. The object exists if i doesn't include the Checkmovement function inside. I wonder what mistake i have done. Could anyone please kindly help me review my code and give comment. Thanks.
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MTV3D65;
namespace TrueVisionTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Main_Quit();
Application.Exit();
}
//Declare the TrueVision3D 'parts'
TVMesh _meshRoom = null;
TVMesh _meshFan = null;
TVMesh _meshTable = null;
TVMesh _meshSofa = null;
TVMesh _meshComputer = null;
TVMesh _Lamp = null;
TVMesh _Cabinet = null;
TVMesh _meshChair = null;
TVEngine TV = null;
TVScene _scene = null;
TVGlobals global = new TVGlobals();
TVLightEngine _TVLightEngine = null;
TVInputEngine InputEngine;
TVTextureFactory TexFactory = new TVTextureFactory();
TVMaterialFactory MatFactory = new TVMaterialFactory();
TVLandscape Land;
TVScene Scene;
float sngPositionX;
float sngPositionY;
float sngPositionZ;
float sngLookAtX;
float sngLookAtY;
float sngLookAtZ;
float sngWalk;
float sngStrafe;
float sngAngleX, sngAngleY;
int tmpMouseX, tmpMouseY;
bool tmpMouseB1, tmpMouseB2, tmpMouseB3, tmpMouseB4;
int tmpMouseScrollOld, tmpMouseScrollNew;
float x_move = 30.0f, y_move = -30.0f, z_move = 150.0f;
void InitializeTrueVision()
{
TV = new TVEngine();
TV.Init3DWindowed(this.pictureBox1.Handle, true);
TV.SetSearchDirectory(System.Windows.Forms.Application.ExecutablePath);
TV.SetAngleSystem(CONST_TV_ANGLE.TV_ANGLE_DEGREE);
TV.DisplayFPS(true);
}
TV_LIGHT light;
///
/// Set up the lighting for the scene
///
void SetupLighting()
{
_TVLightEngine = new TVLightEngine();
//Initializing the light with values
light.type = CONST_TV_LIGHTTYPE.TV_LIGHT_POINT; ;
light.ambient.a = 0.8f;
light.ambient.r = 0.8f;
light.ambient.g = 0.8f;
light.ambient.b = 0.8f;
light.diffuse.a = 1.0f;
light.diffuse.r = 1.0f;
light.diffuse.g = 1.0f;
light.diffuse.b = 1.0f;
light.specular.a = 1f;
light.specular.r = 0.2f;
light.specular.g = 0.2f;
light.specular.b = 0.2f;
light.direction = global.Vector3(0.0f, 1.0f, 0.0f);
light.position = global.Vector3(0.0f, 400.0f, 10.0f);
light.range = 1000.0f;
//light.Attenuation0 = 0.5f;
light.fFallOff = 1;
light.phi = ((float)Math.PI) / 4.0f;
light.theta = light.phi / 2;
//Create the light in the scene
_TVLightEngine.CreateLight(ref light, "light");
//_scene.SetSpecularLightning(true);
}
//private float _rotationvalue = 5;
private void Form1_Load(object sender, EventArgs e)
{
// set up the initial scene
SetupTheInitialScene();
// show the form and give it focus
this.Show();
this.Focus();
Scene = new TVScene();
InputEngine = new TVInputEngine();
sngPositionX = 0;
sngPositionY = 20;
sngPositionZ = 0;
sngLookAtX = 0;
sngLookAtY = 20;
sngLookAtZ = 50;
sngWalk = 0;
sngStrafe = 0;
//Set the Scene camera
Scene.SetCamera(sngPositionX, sngPositionY, sngPositionZ, sngLookAtX, sngLookAtY, sngLookAtZ);
// start up the main loop, setting the loop guard to ON
DoLoop = true;
Main_Loop();
}
private void SetupTheInitialScene()
{
// initialize true vision details
InitializeTrueVision();
// create a new scene
_scene = new TVScene();
// set the scene background color
_scene.SetBackgroundColor(0f, 0.3f, 0.9f);
// set the lighting of the scene
SetupLighting();
// Load Textures
LoadTextures();
// create wall
CreateWalls();
//Set the position of the room mesh
//_meshRoom.SetPosition(x_move, y_move, z_move);
// create different shapes in the room
CreateMeshShapes();
}
private void CreateMeshShapes()
{
// create a table
CreateTable();
// create coomputer
CreateComputer();
// create a sofa
CreateSofa();
// create cabinet
CreateCabinet();
// create chair
CreateChair();
//CreateDie2();
//create ceiling fan
CreateFan();
// create table lamp
CreateLamp();
}
private void CreateTable()
{
_meshTable = (TVMesh)_scene.CreateMeshBuilder("table");
_meshTable.LoadXFile(@"meshes\table.x", true, true);
_meshTable.SetPosition(130f, -120.0f, 300.0f);
_meshTable.SetScale(2, 2, 2);
_meshTable.SetTexture(global.GetTex("table"), -1);
}
private void CreateChair()
{
_meshChair = (TVMesh)_scene.CreateMeshBuilder("chair");
_meshChair.LoadXFile(@"meshes\chair.x", true, true);
_meshChair.SetPosition(10.0f, -80.0f, 140.0f);
_meshChair.SetScale(1, 1, 1);
_meshChair.RotateY(35.0f, true);
_meshChair.SetTexture(global.GetTex("steel"), -1);
}
private void CreateLamp()
{
_Lamp = (TVMesh)_scene.CreateMeshBuilder("lamp");
_Lamp.LoadXFile(@"meshes\lamp.x", true, true);
_Lamp.SetPosition(70f, 10.0f, 250.0f);
_Lamp.SetScale(2, 2, 2);
_Lamp.SetTexture(global.GetTex("lamp"),-1);
}
private void CreateCabinet()
{
_Cabinet = (TVMesh)_scene.CreateMeshBuilder("cabinet");
_Cabinet.LoadXFile(@"meshes\cabinet.x", true, true);
_Cabinet.SetPosition(200.0f, -140.0f, 340.0f);
_Cabinet.SetScale(4, 4, 4);
// rotate the cabinet slightly
_Cabinet.RotateY(90.0f, true);
_Cabinet.SetTexture(global.GetTex("steel"), -1);
}
private void CreateComputer()
{
_meshComputer = (TVMesh)_scene.CreateMeshBuilder("computer");
_meshComputer.LoadXFile(@"meshes\computer.x", true, true);
_meshComputer.SetPosition(-50.0f, 20.0f, 340.0f);
_meshComputer.SetScale(5, 5, 5);
_meshComputer.RotateY(90.0f, true);
_meshComputer.SetTexture(global.GetTex("black"), -1);
}
private void CreateSofa()
{
_meshSofa = (TVMesh)_scene.CreateMeshBuilder("sofa");
_meshSofa.LoadXFile(@"meshes\sofa.x", true, true);
_meshSofa.SetPosition(-140.0f, -80.0f, 340.0f);
_meshSofa.RotateY(180.0f, true);
_meshSofa.SetTexture(global.GetTex("brown"), -1);
}
private void CreateFan()
{
_meshFan = (TVMesh)_scene.CreateMeshBuilder("fan");
_meshFan.LoadXFile(@"meshes\fan.x",true,true);
_meshFan.SetPosition(-40.0f, 180.0f, 310.0f);
_meshFan.SetScale(3, 3, 3);
//rotate the fan
_meshFan.RotateY(35.0f, true);
_meshFan.RotateX(180.0f, true);
_meshFan.SetTexture(global.GetTex("white"), -1);
}
private void CreateWalls()
{
_meshRoom = (TVMesh)_scene.CreateMeshBuilder("room");
_meshRoom.AddWall3D(global.GetTex("wall"), 350.0f, -350.0f, -350.0f, -350.0f, 350.0f, 5.0f, true, false, -50.0f, 5.0f, 5.0f);
_meshRoom.AddWall3D(global.GetTex("wall"), -350.0f, -350.0f, -350.0f, 350.0f, 350.0f, 5.0f, true, false, -50.0f, 5.0f, 5.0f);
_meshRoom.AddWall3D(global.GetTex("wall"), -350.0f, 350.0f, 350.0f, 350.0f, 350.0f, 5.0f, true, false, -50.0f, 5.0f, 5.0f);
_meshRoom.AddWall3D(global.GetTex("wall"), 350.0f, 350.0f, 350.0f, -350.0f, 350.0f, 5.0f, true, false, -50.0f, 5.0f, 5.0f);
_meshRoom.AddFloor(global.GetTex("sandstone"), -350.0f, -350 - 0f, 350.0f, 350.0f, -50.0f, 10.0f, 10.0f, true);
}
private void LoadTextures()
{
int textureID1 = TexFactory.LoadTexture("textures\\lamp.jpg", "lamp", -1, -1);
int textureID2 = TexFactory.LoadTexture("textures\\wall.jpg", "wall", -1, -1);
int textureID3 = TexFactory.LoadTexture("textures\\granite.bmp", "granite", -1, -1);
int textureID4 = TexFactory.LoadTexture("textures\\metal.bmp", "metal", -1, -1);
int textureID5 = TexFactory.LoadTexture("textures\\sandstone.bmp", "sandstone", -1, -1);
int textureID6 = TexFactory.LoadTexture("textures\\table.jpg", "table", -1, -1);
int textureID7 = TexFactory.LoadTexture("textures\\white.jpg", "white", -1, -1);
int textureID8 = TexFactory.LoadTexture("textures\\brown.jpg", "brown", -1, -1);
int textureID9 = TexFactory.LoadTexture("textures\\black.jpg", "black", -1, -1);
int textureID10 = TexFactory.LoadTexture("textures\\steel.jpg", "steel", -1, -1);
}
bool DoLoop = false;
private void Main_Quit()
{
DoLoop = false;
}
void RotateSomeObjects()
{
if (_rotateFan)
{
_meshFan.RotateY(5, true);
}
}
private void Main_Loop()
{
int fps;
while (DoLoop == true)
{
System.Windows.Forms.Application.DoEvents();
//CheckInput();
CheckMovement();
fps = (int)TV.GetFPS();
TV.Clear(false);
RotateSomeObjects();
_scene.RenderAllMeshes(true);
TV.RenderToScreen();
}
Main_Quit();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
DoLoop = false;
}
private bool _rotateFan = true;
private void CheckMovement()
{
if (InputEngine.IsKeyPressed(CONST_TV_KEY.TV_KEY_UP))
{
sngWalk = 1.0f;
}
if (InputEngine.IsKeyPressed(CONST_TV_KEY.TV_KEY_DOWN))
{
sngWalk = -1.0f;
}
if (InputEngine.IsKeyPressed(CONST_TV_KEY.TV_KEY_LEFT))
{
sngStrafe = 1.0f;
}
if (InputEngine.IsKeyPressed(CONST_TV_KEY.TV_KEY_RIGHT))
{
sngStrafe = -1.0f;
}
tmpMouseScrollOld = tmpMouseScrollNew;
InputEngine.GetMouseState(ref tmpMouseX, ref tmpMouseY, ref tmpMouseB1, ref tmpMouseB2, ref tmpMouseB3, ref tmpMouseB4, ref tmpMouseScrollNew);
sngAngleX = sngAngleX - ((float)tmpMouseY / 100);
sngAngleY = sngAngleY - ((float)tmpMouseX / 100);
if (sngAngleX > 1.3)
{
sngAngleX = 1.3f;
}
if (sngAngleX < -1.3)
{
sngAngleX = -1.3f;
}
if (sngWalk > 0)
{
sngWalk = sngWalk - 0.05f;
if (sngWalk < 0)
{
sngWalk = 0.0f;
}
}
if (sngWalk < 0)
{
sngWalk = sngWalk + 0.05f;
if (sngWalk > 0)
{
sngWalk = 0;
}
}
if (sngStrafe > 0)
{
sngStrafe = sngStrafe - 0.05f;
if (sngStrafe < 0)
{
sngStrafe = 0;
}
}
if (sngStrafe < 0)
{
sngStrafe = sngStrafe + 0.05f;
if (sngStrafe > 0)
{
sngStrafe = 0;
}
}
sngPositionX = sngPositionX + (float)(System.Math.Cos((double)sngAngleY) * sngWalk * TV.TimeElapsed()) + (float)(System.Math.Cos((double)sngAngleY + 3.141596 / 2) * sngStrafe * TV.TimeElapsed());
sngPositionZ = sngPositionZ + (float)(System.Math.Sin((double)sngAngleY) * sngWalk * TV.TimeElapsed()) + (float)(System.Math.Sin((double)sngAngleY + 3.141596 / 2) * sngStrafe * TV.TimeElapsed());
sngLookAtX = sngPositionX + (float)System.Math.Cos((double)sngAngleY);
sngLookAtY = sngPositionY + (float)System.Math.Tan((double)sngAngleX);
sngLookAtZ = sngPositionZ + (float)System.Math.Sin((double)sngAngleY);
Scene.SetCamera(sngPositionX, sngPositionY, sngPositionZ, sngLookAtX, sngLookAtY, sngLookAtZ);
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
}
}
|
|
|
|
|
Why would anyone want to wade through over 400 lines of unformatted code to work out what you have done wrong? Try running in debug mode and see where things go wrong.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Agreed.
Reading the unformatted code is not easy, especially since you don't limit it down to what's important.
|
|
|
|
|
I would assume you've just got some bad math going on in the camera position calculations.
I would look at your values you're calculating for the following line of code and verify you're not moving the camera into a position/angle that is away from your 'office'.
Scene.SetCamera(sngPositionX, sngPositionY, sngPositionZ, sngLookAtX, sngLookAtY, sngLookAtZ);
Your initial values are:
sngPositionX = 0;
sngPositionY = 20;
sngPositionZ = 0;
sngLookAtX = 0;
sngLookAtY = 20;
sngLookAtZ = 50;
So, see if you're pointing your camera in the wrong direction.
|
|
|
|
|
Thanks to Andrew for kindly answer my question. Sorry to Ashfield if i have ask a stupid question but i have debugged it and it appeared no error. So, i just want to get what is wrong behind my logic. Anyway, thank you!
|
|
|
|
|