|
Only 1 thing wrong that I spotted:
azazel00 wrote: Addionally you need to know how many elements you have in your array in order to iterate through them
Array has a .Length property.
|
|
|
|
|
hi all,
can someone please tell me why this code fails at the while loop to get remote data, commented // ?? error here ??
i cant understand why it is failing, when i debug it, it pauses for about 5 seconds at the m_gatewaySocket.Receive(receiveBytes) line and returns 0 at this line, there fore breaking loop condition.
it is making the conneciton keep-alive when i test as well, dont know if this helps diagnosis much, cause i get same problem if i comment out the check for keep-alive.
sorry for all the code, syntax highlighting would be good on this forum
btw this is running in its own thread that is spawned from TcpListener.AcceptSocket()
<br />
Debug.WriteLine(" ------------- start request ----------------- ");<br />
int bytes = ReadMessage(read, ref m_clientSocket, ref message);<br />
if (bytes < 1)<br />
{<br />
return;<br />
}<br />
HttpHeaderParser parser = new HttpHeaderParser(message);<br />
uriString = parser.RequestUri;<br />
host = parser.Host;<br />
<br />
Debug.WriteLine("Connecting to: " + host);<br />
Debug.WriteLine("Connection from: " + m_clientSocket.RemoteEndPoint);<br />
<br />
<br />
IPEndPoint gatewayEndPoint = new IPEndPoint(parser.AddressList[0] , 80);<br />
m_gatewaySocket = new Socket(m_clientSocket.AddressFamily, SocketType.Stream, ProtocolType.Tcp);<br />
<br />
if (parser.KeepAlive)<br />
{<br />
m_gatewaySocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, 1);<br />
} <br />
m_gatewaySocket.Connect(gatewayEndPoint);<br />
<br />
string output = "Connected to remote host: ";<br />
output += (m_gatewaySocket.Connected) ? "OK" : "ERROR";<br />
Debug.WriteLine(output);<br />
<br />
byte[] bytesToSend = m_ascii.GetBytes(message);<br />
m_gatewaySocket.Send(bytesToSend); <br />
<br />
byte[] receiveBytes = new byte[4096];<br />
int returnBytes = m_gatewaySocket.Receive(receiveBytes);<br />
<br />
Debug.WriteLine("Received " + returnBytes + " bytes from remote host");<br />
<br />
string returnPage = m_ascii.GetString(receiveBytes);<br />
<br />
while (returnBytes > 0)<br />
{ <br />
returnBytes = m_gatewaySocket.Receive(receiveBytes);<br />
returnPage += m_ascii.GetString(receiveBytes);<br />
}<br />
<br />
m_gatewaySocket.Shutdown(SocketShutdown.Both);<br />
m_gatewaySocket.Close();<br />
<br />
Debug.WriteLine(" ------------- end request ----------------- ");<br />
also if i test with site, www.google.com.au
the first call to int returnBytes = m_gatewaySocket.Receive(receiveBytes); that is before the while loop returns 1765 bytes as this
"HTTP/1.0 200 OK\r\nCache-Control: private\r\nContent-Type: text/html\r\nSet-Cookie: PREF=ID=56a9d4d131124690:TM=1131335053:LM=1131344693:IG=2:S=NKFaVbclxQhPNUPz; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com.au\r\nContent-Encoding: gzip\r\nServer: GWS/2.1\r\nContent-Length: 1363\r\nDate: Mon, 07 Nov 2005 06:24:53 GMT\r\nX-Cache: MISS from syd-nxg-pr3.tpgi.com.au\r\nProxy-Connection: keep-alive\r\n\r\n?
plus a whole lot more gibberish
kind regards,
g00fy
|
|
|
|
|
would this be better acheived with HttpWebRequest ? and similar classes
regs,
g00fy
|
|
|
|
|
Alright,
First, let me thank you for taking the time for reading my post.
Second, if I posted in the wrong place, I apologize. This is my first post.
Now on to my question:
If you are familiar with MySQL Administrator, you've seen the nice (at least, I like it) interface they use. It's a graphical menu on the left (ListView, perhaps), and something that looks to me like panels, on the right, that change when you press an item in the left menu. Sort of similar to outlook.
If you are not familiar with it, you can see exhibits A and B:
http://img481.imageshack.us/img481/3415/mysql19fq.png
http://img481.imageshack.us/img481/3504/mysql27zi.png
I’m relatively new to .NET, and Im not even a professional developer, so the question may seem obvious to some. But how would I go around achieving that kind of navigation system? I've thought of some ways, but the first one already failed, after banging my head against the keyboard for a while.
I attempted to use a "TabControl", and to make the top buttons not visible. Either it is not possible, or I just don’t know how.
My second option was to throw a lot of panels in the form, and make them visible/invisible when the "menu" items were pressed. After playing with it for a while, I found the fact that I couldn’t see the objects, behind the panel I could see, too disturbing. I gave up on the method.
I’m out of ideas. Any suggestions?
azazel
|
|
|
|
|
other than using alot of panels that gets messy, change your tab control to display buttons and cover them with a label or panel, no need to generate a member for it cause its just a cover up of the tab control buttons.
if you dont change to buttons you do not get a complete line across the top the active tab.
as for the left side it is fairly straight forward.
you might want to do some looking for 'explorer bar' or 'outllok sidebar' for some other ideas for the left side navigation
if anyone has a better idea for a multipage 'card type' layout please offer you 2cents worth cause this is the quickest way i know to do it
hope that helps
g00fy
|
|
|
|
|
|
I'll put my 2 cents worth in for Infragisitcs[^] then too. but they dont have a card layout.
i will download your suggestion and try it
regs,
g00fy
|
|
|
|
|
i had a quick fiddle with developer express and i like infragistics better
also like my idea for quick and easy card layout, no overhead and its fast.
this post is getting interesting though
regs,
g00fy
|
|
|
|
|
I have a PagePanel class that I use for this kind of thing. I use it with MyXaml mainly but you can download it here[^].
If I get sometime tonight, I'll build a non-MyXaml sample.
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
I am having problem in saving and closing excel files in excel automation.can u anyone help me on that
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace mlist_intializer_tool
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private Excel.Application ExcelObj = null;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
ExcelObj = new Excel.Application();
// See if the Excel Application Object was successfully constructed
if (ExcelObj == null)
{
MessageBox.Show("ERROR: EXCEL couldn't be started!");
System.Windows.Forms.Application.Exit();
}
// Make the Application Visible
ExcelObj.Visible = true;
//
// 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 );
}
string[] ConvertToStringArray(System.Array values)
{
// create a new string array
string[] theArray = new string[values.Length];
// loop through the 2-D System.Array and populate the 1-D String Array
for (int i = 1; i <= values.Length; i++)
{
if (values.GetValue(1, i) == null)
theArray[i-1] = "";
else
theArray[i-1] = (string)values.GetValue(1, i).ToString();
}
return theArray;
}
#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()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(80, 80);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(136, 64);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(
"F:\\HAI.XLS", 0, true, 5,
"", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,
0, true);
// get the collection of sheets in the workbook
Excel.Sheets sheets = theWorkbook.Worksheets;
// get the first and only worksheet from the collection
// of worksheets
Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(2);
// loop through 10 rows of the spreadsheet and place each row in the list view
for (int i = 1; i <= 100; i++)
{
Excel.Range range = worksheet.get_Range("A"+i.ToString(), "S" + i.ToString());
System.Array myvalues = (System.Array)range.Cells.Value;
range.Cells.Value="value";
string[] strArray = ConvertToStringArray(myvalues);
for (int k = 1; k < strArray.Length; k++)
{
char chr='A';
int ch=chr;
ch+=k;
chr=(char)ch;
string str=new string(chr,1);
//axSpreadsheet1.ActiveSheet.get_Range(str+i.ToString(),str+ i.ToString()).Value=strArray[k];
//axSpreadsheet1.ActiveSheet.get_Range("B"+i.ToString(),"B"+ i.ToString()).Value=strArray[1];
}
//}
theWorkbook.Save();
}
theWorkbook.Close(0,0,0);
ExcelObj.Quit();
}
}
}
Life Is A journey,But destination is what we make out of it
-- modified at 0:03 Monday 7th November, 2005
|
|
|
|
|
I'd like to create my own c# browser to display my own pages with some links.
Then I want my browser to popup my C# Window form when I click a link.
Please help me how can I like this.
|
|
|
|
|
This[^] article describes how to embed the web browser into your C# application.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thank you very much. But my main problem is not how to create browser, it's how can I pop my windows form up when a link is clicked.
|
|
|
|
|
Hi,
Can someone please tell me how can I zoom in and out of an image that is displayed in a picture box control???
Please Help...
Thanks,
E.A.
|
|
|
|
|
You can't. So many people seem to think a picture box control should be a full featured image viewer, and it's not. It's for showing a picture. If you want to do anything more, you'll have to write the code yourself. I prefer to put a panel on my form and use it to work out the bounds to draw my own images for this very reason, it means I have full control. The Graphics.DrawImage method has a number of overloads, and all are designed to be able to zoom into an area of an image and/or draw only part of the image.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yup, ehat Christian said. Or you can use the search function of Codeproject : PictureBox with zooming and scrolling[^].
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
Inconsistent accessibility: parameter type 'HDRImaging.HDRImage' is less accessible than method 'HDRImaging.ImagePyramid.ImagePyramid(HDRImaging.HDRImage)'
What does this mean ? The error is here :
public class ImagePyramid
{
private HDRImage source;
public ImagePyramid(HDRImage bitmap) <----- error !!!
{
source = bitmap;
}
in the constructor. The HDRImage class is in the namespace and has several public constructors.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Don't worry, I found it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am writing a C# app and I want to store the bits of a bitmap in an array. So I have declared an array to hold the right number of bytes, and I have a byte *, but is there any way to copy the data into the array in one go, instead of one item at a time ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Marshall.Copy seems to do the trick
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
There doesn't seem to be a SelectedIndex property for a listview control. As I did with a listbox's SelectedIndex I need to be able to get the int index value of whichever item is selected in the listview. I have set the listview's multiple selection to false as I only want one item selected.
How can i find out what the index is of the selected item??
Could someone please show me in code??
|
|
|
|
|
Look again, there _is_ a SelectedIndices and a SelectedItems property.
mav
|
|
|
|
|
Yes but these are read only. SelectedIndices returns a collection not an index number and SelectedItems also returns a collection. I need just the selected items index number.
|
|
|
|
|
Ermm SelectIndices return a collection of Items Index Number that has been selected, isnt that what you wanted? I thought Mav.Northwind hit the mark.
|
|
|
|
|
if (this.listView1.SelectedIndices.Count > 0)
{
/*
* This will simply return the first index.
* If you set the MultiSelect property to false,
* that's all you need. Otherwise, just iterate
* through the array with a for
*/
int i = this.listView1.SelectedIndices[0];
}
This should do the trick.
Hope it helps,
azazel
|
|
|
|
|