|
i understand what you are asking about, so i think the answer is number 2 from this link.
interesting project, best luck.
|
|
|
|
|
having followed Midnights link do you have a more detailed question to ask or are you just here to ask for the code.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
I am sending data from mobile app to REST in binary format like this:
"firstname=Mike&lastname=Smith&..binary represenation for the image here.."
class Employee{
string firstname;
string lastname;
Stream photo;
}
public string PostMethod(Stream streamObj)
{
using (FileStream filetoUpload = new FileStream(filePath + filename, FileMode.Create))
{
byte[] byteArray = new byte[10000];
int bytesRead = 0;
do
{
bytesRead = streamObj.Read(byteArray, 0, byteArray.Length);
if (bytesRead > 0)
{
filetoUpload.Write(byteArray, 0, bytesRead);
}
}
while (bytesRead > 0);
}
return "Uploaded " + filePath + filename;
}
I do know how to get the contents of the Stream into a byte array. What do I need to do to be able to read the bytes from the StreamObj into the class? Some pseudo code would be helpful.
employee.firstname = ...
employee.lastname=...
employee.photo=....
modified 3-Jul-12 0:09am.
|
|
|
|
|
First you need to split your array into sections as delineated by the & character. You can then convert the first two to properly encoded character strings using the System.Text.Encoding.GetChars() [^] method, and then split them based on the = character.
|
|
|
|
|
Might not work - I think he needs to look a little more closely at his data. The third section is raw binary by my interpretation, so it probably shouldn't be in a string at all or he runs the risk of unicode conversion problems.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
My suggestions were largely guesswork, but I wasn't proposing to convert section 3 to a string, just the first two.
|
|
|
|
|
Software2007 wrote: I do know how to get the contents of the Stream into a byte array.
Google for Serialize/deserialize - takes only a few lines of code. You'll be wanting the BinaryFormatter .
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
OriginalGriff is correct that the image section is raw binary. So, what to do again?
|
|
|
|
|
Serialize your employee, using the binaryformatter
Serializing means that you'd encode it in a portable format. You can use different formatters, but the Xml-version doesn't sound too appropriate under these circumstances, hence the binaryformatter.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Can you elaborate a bit. So, I have a stream
"firstname=Mike&lastname=Smith&..binary represenation for the image here.."
in binary format.
[Serializable]
public class Employee {
Serialize()..
Deserialize()..
}
This sounds like I need a file for the serialization, but I thought this was memory data type of thing.
Anyways, what after this, how do I read it in to the class members what I don't get?
How do I go from Stream type which is sent to me to Employee? Note, stream comes from iphone app.
modified 3-Jul-12 14:09pm.
|
|
|
|
|
Hi,
I have created a Texteditor using C#. In this I am using Spellchecker with the help of NHunspell.
When i am entering more than 60000 characters its hanged. Its performance is too slow. But its very fast while the spellchecker is off.
How can i achieve the spellchecker is on for the customer view page only onto the entire.
The following code that i can used for dictionary on/off
if (btnsCheck.BackColor==Color.Green)
{
this.NHunspellTextBoxExtender1.SetSpellCheckEnabled(this.TextEditor, false);
this.NHunspellTextBoxExtender1.SpellAsYouType = false;
btnsCheck.BackColor = Color.Red;
}
else
{
this.NHunspellTextBoxExtender1.SetSpellCheckEnabled(this.TextEditor, true);
string TempSt = this.TextEditor.SelectedText;
this.NHunspellTextBoxExtender1.SpellAsYouType = true;
this.TextEditor.SelectedText = " quot;;
btnsCheck.BackColor = Color.Green;
}
}
Thanks,
Murugavel S
|
|
|
|
|
|
|
|
This is one of the uses of the Windows SetWindowPos function and is demonstrated with an annoying program that makes all open Notepad windows topmost for 10 seconds. That's just long enough to click on them a few times to confirm the modified behaviour before they revert to normal.
Alan.
using System;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;
namespace MakeTopMost {
internal sealed class App {
[Flags]
public enum SWP : uint {
NOSIZE = 0x0001,
NOMOVE = 0x0002,
NOZORDER = 0x0004,
NOREDRAW = 0x0008,
NOACTIVATE = 0x0010,
DRAWFRAME = 0x0020,
FRAMECHANGED = 0x0020,
SHOWWINDOW = 0x0040,
HIDEWINDOW = 0x0080,
NOCOPYBITS = 0x0100,
NOOWNERZORDER = 0x0200,
NOREPOSITION = 0x0200,
NOSENDCHANGING = 0x0400,
DEFERERASE = 0x2000,
ASYNCWINDOWPOS = 0x4000
}
public const Int32 HWND_TOPMOST = -1;
public const Int32 HWND_NOTOPMOST = -2;
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(
[In] IntPtr hWnd,
[In] IntPtr hWndInsertAfter,
Int32 X, Int32 Y, Int32 cx, Int32 cy,
SWP Flags);
internal static void Main() {
Process[] ps = Process.GetProcessesByName("notepad");
foreach (Process p in ps) {
Console.WriteLine("TopMost");
MakeTopMost(p.MainWindowHandle);
}
Thread.Sleep(10000);
foreach (Process p in ps) {
Console.WriteLine("Not TopMost");
RemoveTopMost(p.MainWindowHandle);
}
Console.WriteLine("...end");
Console.ReadLine();
}
private static void MakeTopMost(IntPtr targetHwnd) {
const SWP flags = SWP.NOSIZE | SWP.NOMOVE;
SetWindowPos(targetHwnd, (IntPtr)HWND_TOPMOST, 0, 0, 0, 0, flags);
}
private static void RemoveTopMost(IntPtr targetHwnd) {
const SWP flags = SWP.NOSIZE | SWP.NOMOVE;
SetWindowPos(targetHwnd, (IntPtr)HWND_NOTOPMOST, 0, 0, 0, 0, flags);
}
}
}
|
|
|
|
|
|
Colin,
In the following method is there something missing as I don't see how _hWnd1 is set.
private void StartOtherProcesses()
{
Process.Start(APP_1);
SetWindowPos(_hWnd1, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
}
Assuming there is some missing code, i.e. SetHwnd() , have you checked that the GetWindowsHandler method does actually get a non zero handle. Handle creation will be some time after process start and it not uncommon for Process.MainWindowHandle to be IntPtr.Zero for several hundred milliseconds even after Process.WaitForInputIdle() has returned (despite what MSDN says!).
By the way, I have verified by reading the extended style bits with GetWindowLong, that SetWindowPos will remove the WS_EX_TOPMOST style from a maximized topmost window.
Alan.
modified 3-Jul-12 21:00pm.
|
|
|
|
|
Alan N's solution is a very good one.
However, check if they have some modal / non-modal type if property which you can set in this control.
This will allow you to get away without writing sooo much more code.
|
|
|
|
|
Please. Can help.... I need to filter the color red, Green and yellow in a image contained in the control Emgu.CV.UI.ImageBox.
Please can guide as I detect any of the three colors (red, green, yellow).
filter using HSV
modified 2-Jul-12 16:36pm.
|
|
|
|
|
|
I have a form containing a DataGridView which I want to populate immediately upon creating the new form. The DataGridView is populated from a SQL query and I do it as follows:
using (SqlCommand mySqlCommand = new SqlCommand("SELECT * FROM MyTable", mySqlConnection))
{
using (SqlDataReader mySqlDataReader = sqlCommand.ExecuteReader())
{
DataSet myDataSet = new DataSet();
DataTable myDataTable = new DataTable();
myDataSet.Tables.Add(myDataTable);
myDataSet.Load(mySqlDataReader, LoadOption.PreserveChanges, myDataSet.Tables[0]);
myDataGridView.DataSource = myDataSet.Tables[0];
}
}
myDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
foreach(DataGridViewRow myRow in myDataGridView.Rows)
Now, the above code works perfectly except for the last two lines of code, which automatically resizes each column to fit the widest cell and which iterates through the DataGridView and does something with some of the values. The reason this won't work is because, by the time they are executed, the databinding for the DataGridView might not yet be finished.
One solution is to add
myDataGridView.DataBindingComplete += new DataGridViewBindingCompleteEventHandler(myDataGridView_DataBindingComplete);
And then put those lines of code inside the event handler.
For various reasons, it happens from time to time that I'd rather have those lines of code inside the original function that populates the form. I'd be quite happy to enter a loop that will wait for the data binding to complete before I continue but I don't know how. Any suggestions?
|
|
|
|
|
Can't you just call the DataBind function explicitly?
like... myDataGridView.Databind();
Everything should be ready to go after that...
|
|
|
|
|
No, I believe that works only for Webforms, not for Winforms as is the case here.
I don't understand why that method is not available in winforms as it would have been the perfect solution for this problem of mine.
|
|
|
|
|
Hi, I need to edit the pdf using axAcroPdf component but, buttons used to edit are disabled. I cannot click on the buttons??? Thx.
|
|
|
|