|
martin_hughes wrote: what in your experience lead you to that conclusion.
I haven't a bloody clue
|
|
|
|
|
|
hi
i need an algorithm like 'Word Wrap' in notepad that place my words in some lines that fit in my border(like richtextBox), i wrote this code, but it's not work correctly :
private void ShowText()<br />
{ <br />
string mainText = System.IO.File.ReadAllText("test.txt");<br />
Graphics g = this.richTextBox1.CreateGraphics();<br />
int widthBorder = this.richTextBox1.Width;<br />
StringBuilder sb = new StringBuilder();<br />
SizeF sizeText = new SizeF();<br />
SizeF sizeCurrentLine = new SizeF();<br />
ArrayList allLines = new ArrayList();<br />
string firstWordNextLine = string.Empty;<br />
<br />
string[] textCol = mainText.Split(new char[] { ' ' });<br />
foreach (string text in textCol)<br />
{ <br />
if (firstWordNextLine != string.Empty)<br />
{<br />
sb.Append(firstWordNextLine);<br />
firstWordNextLine = string.Empty;<br />
}<br />
int widthText = (int)g.MeasureString(text, this.richTextBox1.Font).Width;<br />
int widthCurrentLine = (int)g.MeasureString(sb.ToString(), this.richTextBox1.Font).Width;<br />
int totalWidthLine = widthText + widthCurrentLine;<br />
if (widthCurrentLine <= widthBorder && totalWidthLine <= widthBorder)<br />
{<br />
if (sb.ToString() == "")<br />
sb.Append(text);<br />
else<br />
sb.Append(" " + text);<br />
}<br />
else<br />
{<br />
sw.WriteLine(sb.Length.ToString()); <br />
allLines.Add(sb.ToString());<br />
firstWordNextLine = text;<br />
sb = new StringBuilder();<br />
}<br />
}<br />
<br />
for (int i = 0; i <= allLines.Count - 1; i++)<br />
{<br />
this.richTextBox1.Text += allLines[i].ToString() + "\n";<br />
} <br />
}
how to solve my problem and where does my mistake in code ?
thanks
|
|
|
|
|
RichTextBox class has WordWrap property. Setting it to true will make it wrap the text. Why don't use it?
|
|
|
|
|
Hi there,
I'm trying to solve a little problem. I created a simple web service in Java that sends a file as a byte array to the client. This array is sended as a MTOM attachment. Now, I'm trying to make a C# client application like this:
using System; <br />
using System.Collections.Generic; <br />
using System.ComponentModel; <br />
using System.Data; <br />
using System.Drawing; <br />
using System.Text; <br />
using System.Windows.Forms; <br />
<br />
namespace ImgClient <br />
{ <br />
public partial class Form1 : Form <br />
{ <br />
public Form1() <br />
{ <br />
InitializeComponent(); <br />
} <br />
<br />
private void button1_Click(object sender, EventArgs e) <br />
{ <br />
ImageService.ImageServiceService service = new ImageService.ImageServiceService(); <br />
byte[] data = service.getJavaImage(); <br />
MessageBox.Show(data.Length.ToString()); <br />
} <br />
} <br />
}
but when I click on the button I'll receive an InvalidOperationException with this message:
Client found response content type of 'multipart/related;type="application/xop+xml";boundary="uuid:44b8d14c-dcbb-4024-996d-078c5985a152";start-info="text/xml", but expected "text/xml"... on line :
byte[] data = service.getJavaImage(); <br />
I made also a Java client application like this and it worked. So web service realy works. I also downloaded WSE 3.0 and set messaging->client mode to "on". But it didn't help.
Has anybody ever solved a problem like this? Or could anybody help with this?
thx in advance.
|
|
|
|
|
|
Well, thx. I read it twice. The only thing I could do else was:
"Sometimes VS misbehaves and does not generate this class. I don't understand why, but the work-around is to Show-all-files in the WinForms project and expand the web service > Reference.map > Reference.cs. Edit this file and change public partial class MTOM : System.Web.Services.Protocols.SoapHttpClientProtocol to public partial class MTOMWse : Microsoft.Web.Services3.WebServicesClientProtocol. Also make sure to update the constructor to match the new class name. Then it should compile fine."
Still no change. I'm still receiving the same exception. Here I'm giving a piece of web service code written in java to show how is the mtom composed.
package imageservice;
import javax.annotation.Resource;
import javax.jws.WebService;
import javax.xml.ws.BindingType;
import javax.xml.ws.WebServiceContext;
import javax.jws.WebMethod;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.File;
import java.io.IOException;
/**
*
* @author Hellburn
*/
@WebService()
@BindingType(value=javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING)
public class ImageService {
@Resource
private WebServiceContext wsContext;
/**
* Web service operation
*/
@WebMethod
public byte[] getJavaImage() {
byte[] data = null;
wsContext.getMessageContext().put(com.sun.xml.ws.developer.JAXWSProperties.MTOM_THRESHOLOD_VALUE,0);
// TODO implement operation
try{
File f = new File("c:/SomeFile.jpg");
FileInputStream fis = new FileInputStream(f);
long length = f.length();
data = new byte[(int)length];
int offset = 0;
int numRead = 0;
while (offset < data.length && (numRead=fis.read(data, offset, data.length-offset)) >= 0) {
offset += numRead;
}
fis.close();
}catch(FileNotFoundException fnfe){
fnfe.printStackTrace();
}catch(IOException ioe){
ioe.printStackTrace();
}
return data;
}
}
Maybe someone will come up with something what else I should do with my C# client application to make it run. I really don't know.
-- modified at 18:00 Sunday 9th September, 2007
|
|
|
|
|
Good afternoon gentlemen,
I was hoping somebody could explain what is wrong with the following implementation of a simple Generic function
<br />
protected void SetValue<<T>>(T value, int length)<br />
{<br />
byte[] data = BitConverter.GetBytes(value);<br />
if (SrbData.Length < (length + data.Length))<br />
throw new InvalidOperationException();<br />
Array.Copy(data, 0, SrbData, length, data.Length);<br />
}<br />
ps, the <<t>> is because I could not work out how to get a single greater than to display and SrbData is a byte array
The Visual Studio error is
Error 1 The best overloaded method match for 'System.BitConverter.GetBytes(bool)' has some invalid arguments C:\Documents and Settings\Paul\My Documents\Visual Studio 2005\Projects\Comet\SrbLibrary\SrbHeader.cs 17 27 SrbLibrary
I do not have much experience with Generics so this is most likely a silly problem, but thanks for the help anyway
Paul
|
|
|
|
|
BitConverter.GetBytes() accepts only several types. It seams that the type that you are substituting T with cannot be expected by BitConverter.GetBytes(). Msdn has more information about this function
|
|
|
|
|
Thanks for the response
However this I understand, but I was hoping to overcome the need to duplicate a function for each type that I need to add to the bit array. Hence the attempt with Generics.
My understanding is that the type T will become what ever T i pass in to it!
Is the problem because the base function will only accept 9 types and generics potentially means that far more types could be passed in??
Ta
Paul
Help, Urgent, Need answers Urgent, Quick Help arggggghhhhhhhhhh
|
|
|
|
|
Yes, T will become the type that you pass but GetBytes can accept only 9 types. So either the type of T should be one of them or you should write a new class like that acts like bitconverter and has a function called GetBytes that accepts many types but that means quite a lot of work
|
|
|
|
|
Is it possible to limit the types that T can become??
Ta
Paul
Help, Urgent, Need answers Urgent, Quick Help arggggghhhhhhhhhh
|
|
|
|
|
Yes you can by adding the where clause and specifying the restriction you want to apply but I'm not sure if you can limit T to only those nine types. For the constraint that you can apply have a look at this: Types of generic constraints[^]
|
|
|
|
|
Out of bound question but here there may be some one who might be coped with the following
when ipress CTRl+ALT+DEl the comp says ur task manager has been disabled and in my tools drop down there is no folder options this is a virus what will be a spcific antivirus
sas
|
|
|
|
|
Is there a C# programming question in the post somewheres I missed? If not, you are in the wrong forum. General Discussion Forum might be better.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
I am using Datagrid control in WinForms...So iam iam Using command buttons are Insert,Update,Delete,Cancel. so i need coding part for these commands..So pls help me...
thanks
Somasundaram
|
|
|
|
|
somagunasekaran wrote: so i need coding part for these commands..So pls help me...
You need to be more specific.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi all
I want to make a very basic rythm game in c#. What would be the best way to get the grahics to run in time with a music file? Some basic ideas of how it could be done would be great to get me started.
thanx
|
|
|
|
|
The easiest and most accurate would be to simply use known music and store the time offset and duration of the beats for each song.
To use it with any music, you would typically do fourier analysis of the music waveform to detect patterns in the intensity at different frequencies.
---
single minded; short sighted; long gone;
|
|
|
|
|
You obviously know what your talking about but sadly i had no idea ... any chance you could break it down a bit for me (which music file is best to use?, how do i find the beat durations? etc.)
I was thinking of having an editor and plotting the notes on a timeline ... saying that I dont think there would be another way to do it!
Thanks for your response
|
|
|
|
|
select names from employee
and the query returns names
aa
bb
cc
dd
ee
how can i store this values into array
|
|
|
|
|
Create an array with the same length as the number of records. Loop through the records and copy the values into the array.
How you loop through the records depends entirely on how you fetch the records from the database.
---
single minded; short sighted; long gone;
|
|
|
|
|
this is the function written in javascript to load pictures.
function loadPics()
{
pic0=new Image();
pic0.src="1.jpg";
pic1=new Image();
pic1.src="2.jpg";
pic2=new Image();
pic2.src="3.jpg";
pic3=new Image();
pic3.src="4.jpg";
pict=new Array();
pict[0]=pic0.src;
pict[1]=pic1.src;
pict[2]=pic2.src;
pict[3]=pic3.src;
}
i retrive the image src from database and stored it in the array like this..
try
{
if (con.State != ConnectionState.Open) con.Open();
cmd.Connection = con;
cmd.CommandText = "select varImageSrc from mtblGallery";
dt.Clear();
ada.SelectCommand = cmd;
ada.Fill(dt);
recCount = dt.Rows.Count;
string[] imgArray = new string[recCount];
for (i = 0; i < recCount; i++)
{
imgArray[i] = (dt.Rows[i][0].ToString());
}
if (con.State != ConnectionState.Closed) con.Close();
}
and now my problem is how can i load the imagesrc from this imgArray to the javascript function to make the loadPics() function dynamically load the images.
can anyone help.. its urgent.
thanks in advance
|
|
|
|
|
Hi All,
I am facing two problems while accessing the Sharepoint server URL using HttpWebRequest/HttpWebResponse.
Sample Code:
try
{
string Url = "http://<sharepoint server>/<site>/<docment library>;
Uri destUri = new Uri(Url);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(destUri);
CredentialCache cache = new CredentialCache();
cache.Add(req.RequestUri, "Negotiate", new NetworkCredential(strUserName, strPassword, strDomain));
cache.Add(req.RequestUri, "NTLM", new NetworkCredential(strUserName, strPassword, strDomain));
req.Credentials = cache;
HttpWebResponse ores = (HttpWebResponse)req.GetResponse();
ores.Close();
if(ores.StatusDescription.ToLower() == "ok")
{
MessageBox.Show("Success");
}
else
{
MessageBox.Show(ores.StatusDescription);
}
}
catch (WebException we)
{
MessageBox.Show("Web Exception : " + we.Message);
}
catch (Exception ex)
{
MessageBox.Show("General Exception : " + ex.Message);
}
Issue #1:
I have created the folder inside a folder under sharepoint document library(ex: DocumentLibrary\Folder1\Folder2)
Using the above code I am testing the connection, it returns Success up to Folder1(ex: http://<server>/<site>/DocumentLibrary/Folder1)
I am trying the add the Folder2 in URL, It returns web exception UnAuthorized for the same credential.(eg: http://<server>/<site>/DocumentLibrary/Folder1/Folder2)
Issue #2: If there is any space in document library name, it returns web exception "Bad URL"
(eg: http://<server>/<site>/Shared Documents)
Can any one know how to fix these problems?
Thanks
Ram
-- modified at 16:03 Saturday 8th September, 2007
|
|
|
|
|
hi
My application is related to sockets and I m using threads in it.I closed sockets as well as threads but now still
Y I m getting this exception and how to remove this error
"
Unhandled exception at 0x7c81eb33 in Playback1.exe: 0xE0434F4D: 0xe0434f4d."
plz help me out as soon as possible
B!Z
|
|
|
|