|
Thanks for your replay.
I've tried different things out, but I don't seem to get it right.
The closest I've come is getteing a light-blue background (using PNG).
You don't have a code-snipp that could get me in the right direction.
Thanks
Thomas
|
|
|
|
|
As I said, I have used a transparent PNG, and I had no problem at all with the transparency.
How do you use the resized image? Are you saving it as a file? If so, what file format are you using?
---
b { font-weight: normal; }
|
|
|
|
|
I'm creating small icons of images in an ASP page, so I'm writing the images to the output stream.
First I'm resizing the image, witch data I get from a memory stream (this data is an transparent image):
public Bitmap _bitmap = null;
private void getGraphicsFromImageNotStretched(MemoryStream ms, int hight, int width)
{
Image image = Image.FromStream(ms, true);
double orgHight = (double)image.Height;
double orgWidth = (double)image.Width;
if((orgHight * hight) > (orgWidth * width))
{
double ratio = (orgWidth * width) / (orgHight * hight);
_bitmap = new Bitmap(image, (int)((double)width * ratio), hight);
_bitmap.Palette = image.Palette;
_bitmap.MakeTransparent();
}
else
{
double ratio = (orgHight * hight) / (orgWidth * width);
_bitmap = new Bitmap(image, width, (int)((double)hight * ratio));
_bitmap.Palette = image.Palette;
_bitmap.MakeTransparent();
}
image.Dispose();
}
Then I write the data to the output stream:
public static byte[] GenerateImageBytes(Bitmap theBitmap)
{
byte[] bytes = null;
// save the image to the output stream
System.IO.MemoryStream ms = new System.IO.MemoryStream();
theBitmap.Save(ms, ImageFormat.Png);
bytes = ms.ToArray();
ms.Close();
return bytes;
}
This result in an image that is not treansparent
Thanks
Thomas
|
|
|
|
|
If you call the MakeTransparent method without specifying a color, it will set the default transparent color as transparent. Do you know what color this is, and that it's the correct color to set as transparent?
---
b { font-weight: normal; }
|
|
|
|
|
No I don't know, but won't it be different from image to image?
Theres mabye a way to get it from the Pallete?
Thanks
Thomas
|
|
|
|
|
Hello again! I'm making a web app which generates data from a database and posts it in a datagrid. Now my problem is how could i post data from 2 separate tables in 1 datagrid. Here are the facts:
table1 composes of 14 columns and numerous rows depending on the result (no problem whatsoever)
table2 composes of 4 columns and with only 1 row (clueless)
Now i already have table1 posted on the grid, I was wondering how i could insert table2 on top of table1 creating a few spaces between them in the process. Thanx for all your replies!!
I'm new to programing so the syntax to implement these functions are still quite alien to me. I'd appreciate all your replies thanx in advance!
|
|
|
|
|
|
|
Hi - really if table 1 and table 2 have completely different data, then you should put two datagrids in there. You can't do what you want, because the grid needs consistent column names to display, and at a minimum, the same number of columns.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
oh...coz i was thinking of merging the datas 2gether into 1 main datatable then creating a buffer-like columns and rows as spaces. i mean is that possible? here's the code i tried to use:
public DataTable fMain(string strMonth,string strYear)
{
DataTable dt_emper = new DataTable();
dt_emper = objDS.fGet_employer();
DataTable dt_emp = new DataTable();
dt_emp = objDS.fGet_emp_deduct(strMonth,strYear);
//DataTable dtMain = new DataTable();
DataRow drow;
DataTable dtMain = new DataTable("dtbl");
DataColumn dcolMain = new DataColumn();
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
dtMain.Columns.Add("");
drow=dtMain.NewRow();
drow[0]=dt_emper.Rows[0][0].ToString();
drow[1]=dt_emper.Rows[0][1].ToString();
drow[2]=dt_emper.Rows[0][2].ToString();
drow[3]="";
drow[4]="";
drow[6]="";
drow[7]="";
drow[8]="";
drow[9]="";
drow[10]="";
drow[11]="";
drow[12]="";
drow[13]="";
drow[14]="";
dtMain.Rows.Add(drow);
for (int ctr=0;ctr<dt_emp.rows.count;ctr++)
{=""
="" drow[0]="dt_emper.Rows[ctr][0];
" drow[1]="dt_emper.Rows[ctr][1];
" drow[2]="dt_emper.Rows[ctr][2];
" drow[3]="dt_emper.Rows[ctr][3];
" drow[4]="dt_emper.Rows[ctr][4];
" drow[5]="dt_emper.Rows[ctr][5];
" drow[6]="dt_emper.Rows[ctr][6];
" drow[7]="dt_emper.Rows[ctr][7];
" drow[8]="dt_emper.Rows[ctr][8];
" drow[9]="dt_emper.Rows[ctr][9];
" drow[10]="dt_emper.Rows[ctr][10];
" drow[11]="dt_emper.Rows[ctr][11];
" drow[12]="dt_emper.Rows[ctr][12];
" drow[13]="dt_emper.Rows[ctr][13];
" drow[14]="dt_emper.Rows[ctr][14];
" drow[15]="dt_emper.Rows[ctr][15];
" dtmain.rows.add(drow);
="" }
="" return="" dtmain;
="" }
i've="" used="" the="" debugging="" technique="" and="" it="" stops="" before="" <code="">dtMain.Rows.Add(drow);. Is it sill possible or do I really need to have 2 grids for the 2 tables?
thanx again!
|
|
|
|
|
What you're thinking of doing is a hack. Do the two tables have data that relate to one another ? If not, then there is no reason to show them in one grid. If so, write a stored procedure that returns the data from both tables in a single dataset. That's what the database is for.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
no they don't have a data that can relate with the other. Darn and i thought i could get away with that. hehe oh well. thanx again Chris! I'l do the 2 grid process
thanx
|
|
|
|
|
Hi,
I am using the following code for Asynchronous webservice but it is getting hang in WebResponse result = req.GetResponse(); Please let me know what mistake i'm doing.
public XmlNode AForwardRequest(string webRequest, string userName, string password)
{
XmlNode resultNode = null;
try
{
XmlDocument webdoc = new XmlDocument();
string url = "";
string payload = "";
if (webRequest.IndexOf('?') != -1)
{
url = webRequest.Substring(0, webRequest.IndexOf('?'));
payload = webRequest.Substring(webRequest.IndexOf('?') + 1);
}
else
url = webRequest;
WebRequest req = WebRequest.Create(url);
req.Credentials = new NetworkCredential(userName, password);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] SomeBytes = null;
if (payload != null)
{
SomeBytes = Encoding.UTF8.GetBytes(payload);
req.ContentLength = SomeBytes.Length;
IAsyncResult r = (IAsyncResult)req.BeginGetRequestStream(new AsyncCallback(MyClientCallback), req);
}
else
{
req.ContentLength = 0;
}
req.Timeout = Timeout.Infinite;
WebResponse result = req.GetResponse();// In this line it gets hang
Stream ReceiveStream = result.GetResponseStream();
webdoc.Load(ReceiveStream);
result.Close();
resultNode = webdoc.DocumentElement;
}
catch (Exception e)
{
}
return resultNode;
}
public void MyClientCallback(IAsyncResult asyncResult)
{
WebRequest req = (WebRequest)asyncResult.AsyncState;
req.EndGetRequestStream(asyncResult);
}
bye,
Vinoth
|
|
|
|
|
Im creating an application that would be used for a WaveOn wireless device. The application is created using C# and the device runs with CE OS. I was trying to update the system date/time information programmatically depending on the time zone offset that the system pickups from an xml config file. I have done several ways (using APIs and all)... for some time, I have succeeded in my ordeal. Unfortunately as I was modifying the application to make it more flexible, the result seems to be varying ever so often & i couldn't get the correct results I was once able to get. Is WIndows CE really that unstable? Any help would do. Thanks.
|
|
|
|
|
hi, i want to now c# code for delete from the database 'Access'
|
|
|
|
|
Short question, short answer.
OleDbCommand[^]
The SQL Syntax you want goes along the lines of:
DELETE FROM tableName WHERE condition
Where tableName is obvious and condition is something like myField=123
|
|
|
|
|
I am experiencing a very strange and annoying problem . It's gonna take a while to describe it, so be ready to read a long post...
I have a Windows service written in C# that works as a scheduler - it loads objects implementing certain interface from other assemblies, and executes some of their methods when the time comes to do that. Nothing too complex... Let's say this interface looks like this:
public interface IPlugin<br />
{<br />
void Execute();<br />
}
There's a core class - say SvcManager - which has Start(), Stop(), Pause() and Resume() methods that are called from the service' OnStart, OnStop, OnPause and OnContinue methods correspondingly. SvcManager.Start() creates one monitoring thread that is responsible for starting and aborting worker threads according to the schedule.
Worker thread creates an instance of an object implementing IPlugin interface, runs its Execute() method, and exits. The execution could take a while (several hours), so monitoring thread might need to stop the worker thread by calling Abort() method. SvcManager.Stop() aborts the monitoring thread and all worker threads (I keep all the plugin objects loaded, and running threads in the ArrayList), and waits for them to finish. Pause() and Resume() just pauses/resumes all these threads. It doesn't matter what the plugin objects do - they are all loaded from separate assemblies, and supposedly could do anything. Well, everything works perfect, unless any of the plugins implements SOAP client. After each SOAP call memory usage is increasing significantly, making it neccesserily to restart the service every 2 days or so, otherwise it eats all the memory on the machine at the rate of 100-150 Mb/day. It doesn't matter if I create a new instance of soap client proxy (inherited from SoapHttpClientProtocol ) for each call and then explicitly call its Dispose() method in the finally block, or if I create just a single instance of a proxy which is called multiple times in a loop - in both cases memory leaks. I used .NET Memory Profiler from SciTech, and found that after each SOAP call a new set of objects appears in memory and never goes away - these are instances of AsyncCallback, HttpAbortDelegate, GCHandle[], Overlapped, OverlappedAsyncCallback , byte arrays and some other internal classes used by WebClientProtocol implementation - all referring to each other, and somehow keepeng themselfs in memory. When the thread executing SOAP calls exits normally - all these objects stay in memory. I tried to call GC.Collect() - it did not help. And if after Collect() I call GC.WaitForPendingFinalizers() method - it locks my app for several minutes, and still does not release the memory! But - and here comes interesting part - if I terminate the thread by calling Abort() method - the GC immediately destroys all these objects, and from now on the service starts working properly - all new threads executing SOAP calls do not fill up the memory anymore, and the counters for existing instances of all these classes stay below 10 all the time (although before aborting the thread they increase by 1000s/min), and memory does not grow. The tricky part is that thread must be aborted after at least one SOAP call has been made, and before it exits normally. Well, that's a very weird and unclean workaround for the problem ..
Also, as you may notice, the implementation of SvcManager class makes it very easy to execute exactly the same process in a standalone Win32 app (not a service). Actually, it is even the same application - if there is certain parameter in a command line, it starts as a normal WinForms application. And if I set it up to call SvcManager.Start() on start, and SvcManager.Stop() on exit - it makes it to do exactly what the service does. And in the case of standalone app memory does not leak!!! No tricks needed with aborting threads - it just works perfectly fine from the beginning and not accumulating any of these internal objects after SOAP calls...
So I am absolutely lost now. I used to work with unmanaged code, and never had any memory leak problems in the last 6 (or more) years, just making sure to always call the destructor/release the resources in a finally block... Now, when managed environment is supposed to take care of everything, I ran into this issue which drives me crazy
Anyone from Microsoft, or just a guru who knows well the internals of .NET framework - please help! Even though without looking at the code it's really hard to figure out what's going on (believe me - it's not easy when you're staring at the code either!), maybe based on my description you can just give me some hints and lead me to a nicier workaround then the one with aborting the threads... And it's actually not a small app - with complex scheduling etc, so rewriting it from scratch is really not an option right now. I could not track down the reason for GC for not collecting these objects, I do not know what ThreadAbortException exactly does does to the threads so it magically makes GC to start working properly, and I do not see why it could happen only if app is running as a service. If somebody could shed light upon these questions, it might help a lot.
Thanks!
|
|
|
|
|
hi...
i'm trying to create a crystal report, which will load data from my application and display the data. my application no database... just wanna display the data generate by class,.....
totally no idea how to do that.... pls help, if anyone knows that....
thanks a lot....
|
|
|
|
|
You can put your data in a dataset at runtime and then set the datasource of crystal report to that DataSet dynamically !
[ _ Always there is another way _ ]
|
|
|
|
|
How do you recieve input from a user on a console?
|
|
|
|
|
try following
string myValue;
myValue = Console.ReadLine();
- ashish
|
|
|
|
|
hi,
I am making Windows Service(User defined)
I have written code inside OnStart within Windows Service
Inside the onstart i want that suppose a.exe is already running
I want to close that a.exe and start a.exe from windows Service
When i run the windows Service two exe runs cocuurently.
On Start i have written
Process.Start(@"c:\a.exe");
I want to identify in beginning of any process of a.exe if exist
how can i check in windows service OnStart()
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
Process[] aProcesses1;
if (aProcesses1.Length > 0)
{
if(rd1==true)
{
// The last excel process is the orphaned process which is killed
aProcesses1[aProcesses1.Length-1].Kill();
rd1=false;
}
}
int intExcelPID;
aProcesses1=Process.GetProcessesByName("a");
string strProc="These are the processes running \n";
for (int i = 0; i <= aProcesses1.GetUpperBound(0); i++)
{
intExcelPID = aProcesses1[i].Id;
strProc+=intExcelPID.ToString()+ " ";
}
//Retrive from registry the value of Path
RegistryKey hklm =Registry.LocalMachine;
hklm=hklm.OpenSubKey("SOFTWARE\\man");
Object obp=hklm.GetValue("Path");
string file=obp.ToString() + "\\man.exe";
Process.Start(@file);
}
Thanks
sanjeev
|
|
|
|
|
|
hi,
I am making Windows Service(User defined)
I have written code inside OnStart within Windows Service
Inside the onstart i want that suppose a.exe is already running
I want to close that a.exe and start a.exe from windows Service
When i run the windows Service two exe runs cocuurently.
On Start i have written
Process.Start(@"c:\a.exe");
I want to identify in beginning of any process of a.exe if exist
how can i check in windows service OnStart()
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
Process[] aProcesses1;
if (aProcesses1.Length > 0)
{
if(rd1==true)
{
// The last excel process is the orphaned process which is killed
aProcesses1[aProcesses1.Length-1].Kill();
rd1=false;
}
}
int intExcelPID;
aProcesses1=Process.GetProcessesByName("a");
string strProc="These are the processes running \n";
for (int i = 0; i <= aProcesses1.GetUpperBound(0); i++)
{
intExcelPID = aProcesses1[i].Id;
strProc+=intExcelPID.ToString()+ " ";
}
//Retrive from registry the value of Path
RegistryKey hklm =Registry.LocalMachine;
hklm=hklm.OpenSubKey("SOFTWARE\\man");
Object obp=hklm.GetValue("Path");
string file=obp.ToString() + "\\man.exe";
Process.Start(@file);
}
Thanks
sanjeev
|
|
|
|
|
Going back to your original post, I already pointed out HUGE problems with your code, that by looking at this post, you haven't fixed at all.
But, to find all the "a" processes and kill them, then restart a new one:
Process[] foundProcs = Process.GetProcessesByName(@"a");
foreach (Process proc in foundProcs)
{
proc.Kill();
}
Process.Start(@"notepad");
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|