|
Web services run in the IIS process and can only be executed within this process. What you're looking to do is called Remoting but it does not use Web Services.
|
|
|
|
|
Hey
I am Working on a Server/Client application in Asynchronous mode. I am using simple Socket when Asynchronous dont simes to be suported by TcpClient och TcpListener.
I am using Serializable on some objects(in a DLL file) to be abled to send this objects easy between the Server and Client, by this i dont want to work with a byte buffer, insted i want somthing like this.
<br />
stream = socket.GetStream(); <br />
formatter.Serialize(stream,user);<br />
There i easely can get the objects(if there is any in the stream. Tha abow code is not with a regular socket but a TcpClient.
Right now my Program looks like this
<br />
private void SetupRecieveCallback(Socket server)<br />
{<br />
try<br />
{<br />
if(server != null)<br />
{<br />
AsyncCallback recieveData = new AsyncCallback(OnRecievedData);<br />
<br />
<br />
}<br />
}<br />
catch(Exception ex)<br />
{ MessageBox.Show("Error in ForumClient - Connection - SetupRecieveCallback : " + ex.Message);<br />
}<br />
}<br />
<br />
<br />
public void OnRecievedData(IAsyncResult ar)<br />
{<br />
Socket server = (Socket)ar.AsyncState;<br />
try<br />
{<br />
int nbyte<br />
}<br />
catch(Exception ex)<br />
{<br />
MessageBox.Show("Error in ForumClient - Connection - OnRecievedData : " + ex.Message);<br />
}<br />
}<br />
How do i get the stream from the socket? and how do i implement it in my program ?
//SnowJim
|
|
|
|
|
Have manage to get a stream no by using NetStream! ofcource =)
Now i have another question!
In the SetupRecieveCallback i am using server.BeginReceive(m_byBuffer,0,m_byBuffer.Length,SocketFlags.None,recieveData, server);
This will trigger so that OnRecievedData is thown if someone is sending data, but if i dont whant to use this buffert and insted use this
ForumPack.command user = (ForumPack.command)formatter.Deserialize(stream);
is there any way to do the same thing but with this stream? or do i have to use the buffert(and set the size) and then translate the byte in to the object?
BestRegards
SnowJim
|
|
|
|
|
I've a windows form, on which a picturebox is placed. I've loaded images into the picturebox. I've implemented the Zoom In and Zoom out functinality. Now my problem is when I zoom in, the picturebox is not spreading equally in the form. I mean the distance between picturebox and the container form should be equal, on four sides, as I zoom in and out ( the picturebox should be exactly centered). How can I achive this? Any help?
Here is the piece of code for Zoom In and Out
For Zooming In :
pictureBox1.Top= (int)(pictureBox1.Top - (pictureBox1.Height * 0.025));
pictureBox1.Left = (int)(pictureBox1.Left - (pictureBox1.Width * 0.025));
pictureBox1.Height = (int)(pictureBox1.Height + (pictureBox1.Height* 0.05));
pictureBox1.Width = (int)(pictureBox1.Width + (pictureBox1.Width * 0.05));
For Zooming Out :
pictureBox1.Top = (int)(pictureBox1.Top + (pictureBox1.Height * 0.025));
pictureBox1.Left = (int)(pictureBox1.Left + (pictureBox1.Width * 0.025));
pictureBox1.Height = (int)(pictureBox1.Height - (pictureBox1.Height* 0.05));
pictureBox1.Width = (int)(pictureBox1.Width - (pictureBox1.Width * 0.05));
Stay cool
|
|
|
|
|
I bet you can do a lot better than this with some custom drawing code.
To answer your question about centering... the standard way of center goes like this:
int newX = (form.Width - picBox.Width) / 2;
int newY = (form.Height - picBox.Height) / 2;
...
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
anyone knows the function for checking if the system had been idle for a specified amount of time, i.e., the user had not performed any action for n seconds. tnx for helping me out!
vicky
|
|
|
|
|
Have a look at http://www.codeproject.com/csharp/uim.asp.
|
|
|
|
|
Hi,
I had made one user control and i am adding this user control into one win form.Now problem is that whenever i am drawing any rectangle on the control which is on the form the images goes down side,which looks very bad.
if i will put autoscroll=false then when image is larger then required size then user will not able to see whole image.
so what is the way can any one help me?
thanks
regards.,
montu3377
|
|
|
|
|
how do u draw the image as abackgroung image
or at all write the code tthat u used to do it
ByMindOnlyYouCanDoIt
|
|
|
|
|
> whenever i am drawing any rectangle on the control which is on the form the images goes down side
Please explain what "down side" means. I don't exactly understand the problem.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Hi,
Yeah down side means that my image is scrolled bottom side of the screen.The whole scenerio is that whenever i draw a Rectangle on that image,vertical scrollbar is gone slightly down and due to that whole image gone down or say bottom side.
this is main problem.
regards.,
montu3377
|
|
|
|
|
Hello,
I am using a datagrid and l have update and delete, based on what the user clicked on.
Double click - display a form and with the details of the row what was double clicked to be able to update the customer.
Single click - click once on the row and then press a button to delete this customer.
My problem is, when l have these 2 events, it always goes into the single click event, wheather l double click the grid or single click the grid.
The code that l have to be able to update and delete works fine. But l can't do my update as the double click will always execute the single click event and not go into the double click. I have tried using mouse down event but that does not work either.
Is there way round this problem.
Many thanks in advance,
Steve
|
|
|
|
|
|
Hello Every one first of all wish u happy new year to all code project partners.any way at the movement i'm in analyzing phase of web base project management system.which is going to develop using c#.
i'm looking gantt chart design control for this Asp dot net projet.can any one help me to develop a this kind of control or provide me a source code so i can customize it according to my requirement.
Thanks
Amael
|
|
|
|
|
any gantt charts for datagrid's available to customise ??
|
|
|
|
|
I have a checkbox that if checked, textBox1 gets enabled (texBox1.Enable=true) if uncheck it textBox1 gets disable.
I did this using another textBox to store the state and then compare. Is there an simple way to do this?
appreciate any help
|
|
|
|
|
Yes. The simple way is not to have the other textbox that stores the state. Since the checkbox control has a Checked property, what would you be storing in that other textbox? Let's see the code.
Matt Gerrans
|
|
|
|
|
It's this simple:
void CheckBox1_CheckedChanged()
{
txtBox1.Enabled = CheckBox1.Checked;
} Check the event name, but it's something like that.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Its because i'm making a list control from scratch (a REAL list control, extends nothing more then System.Windows.Forms.Control)...and i'm looking for info to tell me what iterfaces my collection should implement...what should i extend...(i extended collectionbase, but some of the controls i seen just implement interfaces).
I already made a collection that works with designer, but i have no idea if its a good collection and i want the control to have a good foundation.
p.s. know of any other opensource truely custom(not extending any list control), besides glacialList?
|
|
|
|
|
I wrote one that does not extend the ListView
http://www.codeproject.com/cs/miscctrl/vivantlist.asp
However, I would suggest you wait until I publish the rewrite. I have a post about version 3.0 on the page. I am currently using it in a project, so it is basically done. I just need to clean it up and write an article on how to use it. So far results are good, on my 1 GHz machine; it can load 100,000 items in 18 seconds, and 10,000 in under a second, where each item has two controls in it. On a 1.4 GHz, it has done 100,000 in 8 seconds.
I dissected the Shape Library example published by Microsoft many times to get a control designer working on a component. I would recommend if you want to learn more on the subject of controls, you take a good look at the Shape Library.
http://windowsforms.net/articles/shapedesigner.aspx
|
|
|
|
|
Thx for links...that m$ thing looks to have alot of good stuff inside.
|
|
|
|
|
I am a newbie to C# so please excuse if this problem is really something simple.
I am trying to create an app that sets a window to maximized state after it recieves a certain command over a TCP port. I can get the tcp listener to work but I cant get the form to display. The form never even shows up. I only get the runtime error "Object reference not set to an instance of an object" after I enter the command via the network to set the form to maximized. I think the problem has to do with my calling a method from within the constructor when the constructor has not yet finished. I have attached my code if anyone is willing to look and suggest where I might find where I am going wrong.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
namespace networkScreenBlanker
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.Run();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
}
#endregion
private void Run()
{
IPAddress localAddr = IPAddress.Parse("127.0.0.1");
TcpListener tcpListener = new TcpListener(localAddr, 65000);
tcpListener.Start();
for(;;)
{
Socket socketForClient = tcpListener.AcceptSocket();
if (socketForClient.Connected)
{
//Console.WriteLine("Client connected");
//SendFileToClient(socketForClient);
NetworkStream networkStream = new NetworkStream(socketForClient);
System.IO.StreamReader streamReader = new System.IO.StreamReader(networkStream);
string inputString;
inputString = streamReader.ReadLine();
if (inputString != null)
{
if (inputString == "blankScreen")
{
Form1.ActiveForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
}
//Console.WriteLine("Disconnecting from client...");
socketForClient.Close();
//Console.WriteLine("Exiting...");
break;
}
}
}
}
//[STAThread]
public static void Main()
{
Application.Run(new Form1());
}
}
}
|
|
|
|
|
Yes you are correct. The code is halting within Form1.Run() (called from the constructor) so execution never reaches Application.Run(new Form1()), which is the reason you never see the form open.
To acheive the result you require can be acheived by running the Form1.Run() method as a seperate worker thread which can be achieved something like:-
public class Form1 : System.Windows.Forms.Form
{
private Thread trdTcpActivityListener = null;
public Form1()
{
InitializeComponent();
trdTcpActivityListener = new Thread(new ThreadStart(this.Run));
trdTcpActivityListener.Start();
}
public void Run()
{
TcpListener tcpListener = new TcpListener(IPAddress.Any, 65000);
tcpListener.Start();
while (true)
{
if (tcpListener.Pending())
{
Socket socketForClient = tcpListener.AcceptSocket();
socketForClient.Close();
this.WindowState = FormWindowState.Maximized;
}
Thread.Sleep(30);
}
}
}
Now whilst the worker thread waits for a TCP connection, the main thread is allowed to continue,
the constructor completes and the form opens (minimized). Ill leave it up to you to work out when you should stop the worker thread.
|
|
|
|
|
Thanks for the suggestion. This worked. Now to read that chapter on threading.....
Jackson
|
|
|
|
|
I have a Windows Forms app, with two listviews, separated by a splitter control. Both listviews have vertical scrollbars. I want to make sure that if the user moves the scrollbar in either of the listviews, the other scrollbar should also move.
Any ideas?
Thanks a lot in advance.
-KMAnsari
|
|
|
|