|
hi all ...
I found that alot of (server , client) applications have this part of code in the "server"
<br />
void StartMethod()<br />
{<br />
<br />
<br />
mytcpl = new TcpListener(5020);
mytcpl.Start();
mysocket = mytcpl.AcceptSocket();
myns = new NetworkStream(mysocket);
mysr = new StreamReader(myns);
string order = mysr.ReadLine();<br />
if (order == "SD")<br />
<br />
<br />
<br />
else MessageBox.Show(order + " Request Not Found");<br />
mytcpl.Stop();
<br />
<br />
<br />
<big>if (mysocket.Connected == true)
{<br />
while (true)<br />
{<br />
StartMethod();
}<br />
}<br />
}</big><br />
the Question is :
why to check if the 'socket' is connected where it is already closed by stoping the 'TCP Listener' ?
thanx
|
|
|
|
|
A_A wrote: else MessageBox.Show(order + " Request Not Found");
mytcpl.Stop(); // Close TCP Session
//when stop the tcp listener doesn't that mean that we stop 'disconnect' the socket
No when we stop the TCP listener it does not mean that we will be disconnected .
To make it more clear , a TCP listener is a class which waits for the connection to happen at specified port and IP , the listener does not participate in actual connection and data transfer , the actual connection and data transfer is carried out object of class Socket (mysocket variable in above code) , mytcpl.Stop(); stop the listener that mean that we are no more accepting new connection , the the already connected connection are still there
I hope this is understandable
Thanks
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
thank you
|
|
|
|
|
i have imagelist inside listview box. i need to add that imagelist images in to another imagelist.how can i do that......
i can get imgage index by
ListViewItem item = e.Dtat.GetData(typeof(ListViewItem)) as ListViewItem;
item.imageindex by this i can get image index of fistlist view.
so how can i add the image in to new image list using this image index??
or is there got any other possible way...
A S E L A
|
|
|
|
|
Hi,
I haven't used ImageList class yet, but I just read some of the documentation, and that helps.
An ImageList has a Images property, which is a collection, meaning you can get one of its members by using an index, you can clear the collection by calling Clear(), and adding to the collection by calling Add(). So this would be my first attempt:
foreach(Image image in ImageList1) {
myListView.Images.Add(image);
}
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:56 AM
|
|
|
|
|
ya but how can i call image by image index.....i don't have image path oretc have pnly image index of other image list....
A S E L A
|
|
|
|
|
Hi,
as I already told you, you can use an index or an enumerator.
Here is an index example:
myListView2.Images.Add(myListView1.Images[0]); // "copy" first image
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:57 AM
|
|
|
|
|
im doing drag drop to listview imagelist images....selected images.my drag drop part cannot work...i tried so many type of coding but could't now im tring....creat another image list in listview 2 and add those selected items images in to that list view...i can add item text but cannot add image....anyone if can pl help me.....
thanks a lot here is my code...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
namespace Project_import_1
{
public partial class ImportForm : Form
{
public ImportForm()
{
InitializeComponent();
}
OpenFileDialog dlg = new OpenFileDialog();
private void import(object sender, EventArgs e)
{
ImageList imageList = new ImageList();
imageList.ImageSize = new Size(100, 80);
imageList.ColorDepth = ColorDepth.Depth32Bit;
int i = 0;
string[] files = dlg.FileNames;
string[] pathes = new string[files.Length];
foreach (string file in files)
{
pathes[i] = file;
i++;
}
foreach (string path in pathes)
{
FileInfo fileInfo = new FileInfo(path);
String strDir = fileInfo.Name;
listView1.Items.Add(strDir);
imageList.Images.Add(Bitmap.FromFile(path));
listView1.TileSize = new System.Drawing.Size(100, 80);
}
for (int j = 0; j < pathes.Length; j++)
{
this.listView1.Items[j].ImageIndex = j;
}
this.listView1.View = View.LargeIcon;
this.listView1.LargeImageList = imageList;
}
private void btnImport_Click(object sender, EventArgs e)
{
dlg.Filter = "All Image Files|*.bmp;*.ico;*.gif;*.jpeg;*.jpg;" +
"*.jfif;*.png;*.tif;*.tiff;*.wmf;*.emf|" +
"Windows Bitmap (*.bmp)|*.bmp|" +
"Windows Icon (*.ico)|*.ico|" +
"Graphics Interchange Format (*.gif)|*.gif|" +
"JPEG File Interchange Format (*.jpg)|" +
"*.jpg;*.jpeg;*.jfif|" +
"Portable Network Graphics (*.png)|*.png|" +
"Tag Image File Format (*.tif)|*.tif;*.tiff|" +
"Windows Metafile (*.wmf)|*.wmf|" +
"Enhanced Metafile (*.emf)|*.emf|" +
"All Files (*.*)|*.*";
dlg.InitialDirectory = @"C:\Documents and Settings\All Users\Desktop\";
dlg.Multiselect = true;
try
{
if (dlg.ShowDialog() == DialogResult.OK)
{
import(sender, e);
}
dlg.Reset();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnsave_Click_1(object sender, EventArgs e)
{
try
{
SaveFileDialog dlgSave = new SaveFileDialog();
saveFileDialog1.Filter = "*.jpg|*.jpg|*.bmp|*.bmp|*.gif|*.gif";
saveFileDialog1.ShowDialog();
if (dlgSave.ShowDialog() == DialogResult.OK)
{
if (dlgSave.FileName != "")
{
}
}
catch
{
MessageBox.Show("there is no Pic selected please select a Pic first", "Dear " + System.Environment.UserDomainName);
}
}
private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
{
this.listView1.DoDragDrop(this.listView1.SelectedItems[0], DragDropEffects.Copy);
}
private void listView1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(ListViewItem)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void listView2_ItemDrag(object sender, ItemDragEventArgs e)
{
this.listView2.DoDragDrop(this.listView2.SelectedItems[0], DragDropEffects.Copy);
}
private void listView2_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(ListViewItem)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void listView2_DragDrop(object sender, DragEventArgs e)
{
ListViewItem item = e.Data.GetData(typeof(ListViewItem)) as ListViewItem;
this.listView2.View = View.LargeIcon;
ImageList imageList = new ImageList();
imageList.ImageSize = new Size(100, 100);
imageList.ColorDepth = ColorDepth.Depth32Bit;
foreach (ListViewItem each in listView1.SelectedItems)
{
listView2.Items.Add(item.Text, item.ImageIndex);
imageList.Images.Add(Bitmap.FromFile(
*********** HOW CAN I TAKE SELECTED IMAGES TO HERE*********************));
listView2.TileSize = new System.Drawing.Size(100, 80);
}
for (int j = 0; j < listView1.SelectedItems.Count; j++)
{
this.listView1.Items[j].ImageIndex = j;
}
this.listView2.View = View.LargeIcon;
this.listView2.LargeImageList = imageList;
foreach (ListViewItem removeItem in listView1.SelectedItems)
{
listView1.Items.Remove(removeItem);
}
}
private void listView1_MouseDown(object sender, MouseEventArgs e)
{
ListViewItem item = e.Data.GetData(typeof(ListViewItem)) as ListViewItem;
DirectoryInfo dir = new DirectoryInfo(Directory.GetCurrentDirectory());
String strDir = fileInfo.Name;
listView1.Items.Add(strDir);
tbxPath.Text = dir.FullName;
}
protected void DisplayFileInfo(FileInfo TheFile)
{
}
}
}
|
|
|
|
|
asw.asela wrote: HOW CAN I TAKE SELECTED IMAGES TO HERE
this.listView1.LargeImageList[each.ImageIndex]
|
|
|
|
|
LargeImageList like property but is used like a method....telling that error....
A S E L A
|
|
|
|
|
Sorry...
this.listView1.LargeImageList.Images[each.ImageIndex]
|
|
|
|
|
no still no...i think should be somthing like add or insert etc method....
A S E L A
|
|
|
|
|
|
Hi,
don't take it personal. Seems like all articles are unreachable right now...
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:57 AM
|
|
|
|
|
Since the string "qwerty" does not contain a small letter l with a double bar (\u2c61) one would expect that when the code below is executed, both p and q would get the value -1. However, the second call to IndexOf does in fact return 0 instead of -1. After some further experimenting I found that this happens with several characters from Latin Extended-C (probably all of them) and that the return value is the same as the value of the second argument, i.e. the starting position for the search.
Is this a known bug? And can it be circumvented other than by writing my own search method?
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int p = "qwerty".IndexOf('\u2c61', 0);
System.Console.WriteLine(p);
int q = "qwerty".IndexOf("\u2c61", 0);
System.Console.WriteLine(q);
System.Console.ReadKey();
}
}
}
|
|
|
|
|
Hi,
running Vista SP1 and Visual Studio 2008, targeting either .NET 3.5 SP1 or .NET 2.0 I get correct values for IndexOf(char) but your phenomena for IndexOf(string).
[ADDED]
Reflector tells me string.IndexOf is using CultureInfo.CurrentCulture.CompareInfo.IndexOf
(and it gets very messy when diving into that)
so it may go wrong in some cultures only, making it more likely to go unnoticed for a long time...
[/ADDED]
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Monday, March 2, 2009 9:02 AM
modified on Sunday, June 12, 2011 8:58 AM
|
|
|
|
|
Yes, it is probably a locale problem. Today I found out that I can solve the problem by applying a Unicode normalization to the strings and then calling IndexOf() with StringComparison.Ordinal as the third argument, so that the method just checks the bytes.
|
|
|
|
|
hi there!
I build one c# application and now I want to add a setup project, so I can have setup for my application. I am selecting all the files from the application and going through all the steps required for creating the setup, and at the end I am getting error: Specified cast is not valid. Does anyone knows how to solve this issue? Please help me, I will really appreciate. Greetings and thanks in advance, Laziale
|
|
|
|
|
Try and run the setup wizard first, you also don't want all the files from your app, only content and primary output.
|
|
|
|
|
I tried just with content and primary output as well, but it gives me the same error, I don't have any idea how I can solve that.
|
|
|
|
|
What is virtual node algorithm or graph embedded ring..?
|
|
|
|
|
Hey,
I've just looked up your questions on Google and there's quite a few hits for you to read. If you want me to write a synopsis for you then get back to me!
Results 1 - 10 of about 1,840,000 for virtual node algorithm. (0.36 seconds)
Results 1 - 10 of about 543,000 for graph embedded ring. (0.30 seconds)
Alan.
|
|
|
|
|
I would appreciate that..
|
|
|
|
|
can u suggets me some website only for delegates where we can find all the details by example
rizvan sivally
|
|
|
|
|