|
Hello
I am about to write an application which will be responsible to transfer files between two servers. Can someone suggest me the best possible way to do that? Should I go for socket programming? or dot net remoting? or web-services?
I am open for suggestions or comments.
saq!b
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
I need to do an client-server application that send images to a client. The client will be a mobile phone with windows mobile.
Many Thanks
modified on Friday, May 22, 2009 6:54 AM
|
|
|
|
|
Raquel Barata wrote: I need to do an client-server application
then you need to start code it.
dhaim
ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro"
in the front line gave a lead, in the middle line build goodwill, in the behind give power support
|
|
|
|
|
I have two coordinates on the screen x1 and y1 and i have an object at that location.. now i have x2 and y2 which will be the destination point of my object.. I am planning to move my object 1 pixel at a time following the path from x1, y1 to x2, y2.. is there a formula that you can recommend?
|
|
|
|
|
Just work out the ratio of x2 - x1 to y2 - y1, and that will tell you the ratio of pixels to move in x versus y.
If you want reasonably smooth movement you'll need to track positions in floats.
If you want very smooth movement you'll need to take the time per update frame into account.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
yeah i was asking for the ratio formula
|
|
|
|
|
Try something like :-
float ratio = (float)(x2 - x1) / (float)(y2 - y1);
The casts make sure you don't truncate the result.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
well actually from what i understand the locations in the C# controls such as a form and a panel are by pixels and of the INT data type. I'm trying to move it pixel by pixel.. I do remember I had a formula taught to me by my math teacher that given the coordinates of both ends of a straight line, you can solve all the POINTS in between.
|
|
|
|
|
What you are looking for is called Bresenham's algorithm
Clickity[^]
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
|
|
|
|
|
Silvyster wrote: from what i understand the locations in the C# controls such as a form and a panel are by pixelsand of the INT data type.
The problem you'll have is that unless you're moving your object exactly along the X or Y direction, or at 45 degrees, you won't have an integer number of pixels in each direction.
What you need to do is something like :-
float ratio = (float)(y2 - y1) / (float)(x2 - x1);
int step = (x2 > x1)? 1 : -1;
float newFloatY = y1;
int newX = x1;
for (int loop=x1; loop!=x2; loop+=step)
{
newX++;
newFloatY += ratio;
int newY = (int)(newFloatY);
}
You'll need to modify it if you want to move by 1 pixel in Y, and cope with special cases like moving exactly horizontally or vertically, but those are "left as an exercise for the reader"...
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Hi,
I am working in windows application in which I need to create Timers dynamically based on number of records in database. I am able to do that but the problem is I can't identify which timer is raising the tick event.
Below is the sample code on which I am working.
public Form1()
{
InitializeComponent();
System.Timers.Timer timer1 = new System.Timers.Timer;
timer1.Enabled = true;
timer1.Interval = 5000;
timer1.Elapsed += new ElapsedEventHandler(TimerTick);
timer1.Start();
}
public void TimerTick(object source, ElapsedEventArgs e)
{
string s = ((System.Timers.Timer)source);
string s1 = e.ToString();
}
Thanks in advance
|
|
|
|
|
Hmmm.. i have a feeling your going about this the wrong way...
What are you trying to do with each timer?
There is nothing in your example code that shows you doing anything with the instance of a timer that would need it to be identified
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi
Thanks a lot for reoplying so soon
I cant tell the requirement completely. Let me explain in brief.In database I have a set of records in this structure.
ID ConsumerID Time Interval
1 5 5
2 6 7
3 8 9
Now I have 3 records in database. I need to create 3 timers and set intervals accordingly.
For every 5 secs I should get details regarding ConsumerID-5
For every 7 secs I should get details regarding ConsumerID-6
For every 9 secs I should get details regarding ConsumerID-8
Thanks
|
|
|
|
|
Ok well you could go with Davey's idea of inheritance or you could use the timer's 'Tag' property as follows...
when creating...
Timer t = new Timer();
t.Tag = contactID;
then in event handler...
Timer t = (Timer)sender;
if(t.Tag != null)
{
string contactID = (string)t.Tag;
}
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
The System.Timers.Timer doesn't have a Tag property - only System.Windows.Forms.Timer - an int ID property for each MyTimer : System.Timers.Timer would be the easiest way to go here.
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)
|
|
|
|
|
DaveyM69 wrote: The System.Timers.Timer doesn't have a Tag property
My bad
Yeah, in that case I agree with you method
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
You can cast to a Timer from the sender
if(sender is System.Timers.Timer)
{
System.Timers.Timer thisTimer = sender as System.Timers.Timer;
} If you want you can give it a property such as an int for ID or a string for Name etc by subclassing e.g.
public class MyTimer : System.Timers.Timer
{
public string Name
{
get;
set;
}
} ... and then use MyTimer instead of Timer .
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 a lot Dav I got it by using your method
|
|
|
|
|
No problem, you're welcome
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)
|
|
|
|
|
hello sir about timer dynamically .can i copy the code? I do not understand how to do it
|
|
|
|
|
i have a form:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Din_Checkers
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public Board gameBoard { get; set; }
private void Form1_Load(object sender, EventArgs e)
{
this.Text = "Dins Checkers";
this.Width = 600;
this.Height = 600;
gameBoard = new Board();
for (int i = 0; i < Board.x_bounds; i++)
{
for (int j = 0; j < Board.y_bounds; j++)
{
this.Controls.Add(gameBoard.checkers_board[i, j].checkerCell);
}
}
this.Controls.Add(gameBoard.score);
}
}
}
as you can see i have created new Board instance
the Board class is:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Din_Checkers
{
public class Board
{
public const int x_bounds = 8;
public const int y_bounds = 8;
public CheckerCell[,] checkers_board { get; set; }
public Label score = new Label();
public ImageList imageList1 = new ImageList();
public int goldEaten = 0;
public int silverEaten = 0;
public Image loadGold;
public Image loadSilver;
public Board()
{
checkers_board = new CheckerCell[x_bounds, y_bounds];
imageList1.Images.Add(Image.FromFile("Images\\silver.jpg"));
imageList1.Images.Add(Image.FromFile("Images\\gold.jpg"));
loadSilver = imageList1.Images[0];
loadGold = imageList1.Images[1];
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
checkers_board[i, j] = new CheckerCell();
if (i < 3)
{
if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
{
checkers_board[i, j].checkerCell.BackgroundImage = loadSilver;
}
}
else if (i > 4)
{
if (((i + j) % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
{
checkers_board[i, j].checkerCell.BackgroundImage = loadGold;
}
}
checkers_board[i, j].checkerCell.BorderStyle = BorderStyle.Fixed3D;
if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
{
checkers_board[i, j].checkerCell.BackColor = Color.White;
}
if (checkers_board[i, j].checkerCell.BackColor != Color.White)
{
checkers_board[i, j].checkerCell.BackColor = Color.Black;
}
checkers_board[i, j].checkerCell.Top = 30 + 55 * i;
checkers_board[i, j].checkerCell.Width = 61;
checkers_board[i, j].checkerCell.Height = 53;
checkers_board[i, j].checkerCell.Left = 30 + 65 * j;
}
}
score.Top = 510;
score.Left = 250;
score.Width = 500;
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
checkers_board[i, j].checkerCell.Click += new EventHandler(checkers_board[i, j].ChooseEvent_Click);
}
}
}
public void DrawScore()
{
score.Text = "תוצאה: זהובים אכולים- " + goldEaten.ToString() + " כסופים אכולים- " + silverEaten.ToString();
}
}
}
and i have another class (that is used in Board class)- the CheckerCell class:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Din_Checkers
{
public class CheckerCell
{
public PictureBox checkerCell { get; set; }
public int x = 0;
public int y = 0;
public CheckerCell()
{
checkerCell = new PictureBox();
}
public static void ChooseEvent_Click(object sender, EventArgs e)
{
string eventChoose = "";
for (int i = 0; i < Board.x_bounds; i++)
{
for (int j = 0; j < Board.y_bounds; j++)
{
if (eventChoose == "")
{
if (Form.
{
eventChoose = "Handle_Board";
}
}
if (checkers_board[i, j].BackColor == Color.Green)
{
eventChoose = "move";
}
}
}
if (eventChoose == "move")
{
MoveChecker_Click(sender, e);
}
else
{
HandleBoard_Click(sender, e);
}
}
public void HandleBoard_Click(object sender, EventArgs e)
{
for (int i = 0; i < Board.x_bounds; i++)
{
for (int j = 0; j < Board.y_bounds; j++)
{
if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
{
checkers_board[i, j].BackColor = Color.White;
}
if (checkers_board[i, j].BackColor != Color.White)
{
checkers_board[i, j].BackColor = Color.Black;
}
}
}
for (int i = 0; i < Board.x_bounds; i++)
{
for (int j = 0; j < Board.y_bounds; j++)
{
if (checkers_board[i, j] == ((PictureBox)sender))
{
x = i;
y = j;
}
}
}
score.Text = x.ToString() + " " + y.ToString() + "fun0";
int start_x = x - 1, start_y = y - 1, end_x = x + 1, end_y = y + 1;
if (start_x < 0)
{
start_x = 0;
}
if (start_y < 0)
{
start_y = 0;
}
if (end_x > Board.x_bounds - 1)
{
end_x = Board.x_bounds - 1;
}
if (end_y > Board.y_bounds - 1)
{
end_y = Board.y_bounds - 1;
}
for (int i = start_x; i <= end_x; i++)
{
for (int j = start_y; j <= end_y; j++)
{
if (checkers_board[i, j].BackColor == Color.White && checkers_board[x, y].BackgroundImage != null && checkers_board[i, j].BackgroundImage != loadGold && checkers_board[i, j].BackgroundImage != loadSilver)
{
checkers_board[i, j].BackColor = Color.Green;
}
}
}
}
public void MoveChecker_Click(object sender, EventArgs e)
{
for (int i = 0; i < Board.x_bounds; i++)
{
for (int j = 0; j < Board.y_bounds; j++)
{
if (checkers_board[i, j] == ((PictureBox)sender))
{
x = i;
y = j;
}
}
}
score.Text = x.ToString() + " " + y.ToString() + "func";
checkers_board[x, y].BackColor = Color.White;
checkers_board[x + 1, y - 1].BackColor = Color.White;
checkers_board[x - 1, y - 1].BackgroundImage = null;
checkers_board[x, y].BackgroundImage = loadSilver;
for (int i = 0; i < Board.x_bounds; i++)
{
for (int j = 0; j < Board.y_bounds; j++)
{
if (checkers_board[i, j].BackColor == Color.Green)
{
checkers_board[i, j].BackColor = Color.White;
}
}
}
}
public void EatChecker()
{
}
}
}
what i want is that CheckerCell Class will be able to access the:
Form1.gameBoard.checkers_board array and i cant success to do it
thanks for the helpers and sorry for my bad english
|
|
|
|
|
you might want to look into events[^]. you can create one for your checkers cell and then to board can listen for that event. and do whatever it needs to then.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hello,
How can i make that the datagrid column displayed index (datagridview1.DisplayIndex) will be equal to the real index (datagridview1.column[name].index)?
I mean for example if i drag-drop a column (reorder column) - the displayindex will be different then the real index? i want the real index (datagridview1.column[name].index) will be changed according the displayindex
|
|
|
|
|
michaelgr1 wrote: i want the real index (datagridview1.column[name].index) will be changed according the displayindex
Why, they do 2 different jobs. If you want to reset the display to the original that is a different matter. Loop through the cols and set the display index = the col index (guess only).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
No , i want to opposite thing- the original index will be changed according the displayed index.
|
|
|
|