|
Thanks... it works just great now...!
QzRz
|
|
|
|
|
Just use the overload of SteamWriter's Write method which takes a string as parameter.
www.troschuetz.de
|
|
|
|
|
Hello,
I would like to simulate CMYK printing by drawing four halftoned images on the screen, one after the other, as a printing press would do, i.e. print cyan, then magenta, then yellow and finally black. Now, If I use:
g.DrawImage(cyanImage, 0,0);
g.DrawImage(magentaImage, 0,0);
g.DrawImage(yellowImage, 0,0);
g.DrawImage(blackImage, 0,0);
the white pixels of an image will paint over the previous colors. If I use alpha blending, colors will be merged, but they unfortunately become fainter by the aplha factor.
What I would like to see happening is to draw one image on the graphics or canvas such that only these pixels of that image will be painted which are above a certain threshold, i.e. not blank, or the areas where in a real printing role the paint would be.
Alternatively, I could combine these images, like professional tools can do. Then it would be sufficient to draw the combined image.
How could I achieve that in C# using the Graphics/Imaging classes?
What I started doing is the following code. Thanks for any hints.
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.Data;
using System.Windows.Forms;
namespace MergedImages
{
public class MergedImage : System.Windows.Forms.UserControl
{
private System.ComponentModel.Container components = null;
private System.Drawing.Image cyanImage;
private System.Drawing.Image magentaImage;
private System.Drawing.Image yellowImage;
private System.Drawing.Image blackImage;
public MergedImage()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
private void InitializeComponent()
{
cyanImage = Image.FromFile(@"c:\tmp\cyan.bmp" );
magentaImage = Image.FromFile(@"c:\tmp\magenta.bmp");
yellowImage = Image.FromFile(@"c:\tmp\yellow.bmp" );
blackImage = Image.FromFile(@"c:\tmp\black.bmp" );
//
// MergedImage
//
this.BackColor = System.Drawing.Color.White;
this.Name = "MergedImage";
this.Size = new System.Drawing.Size(620, 620);
}
#endregion
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
g.Clear(this.BackColor);
float[][] ptsArray ={
new float[] {1, 0, 0, 0, 0},
new float[] {0, 1, 0, 0, 0},
new float[] {0, 0, 1, 0, 0},
new float[] {0, 0, 0, 0.25f, 0},
new float[] {0, 0, 0, 0, 1}};
ColorMatrix clrMatrix = new ColorMatrix(ptsArray);
ImageAttributes imgAttributes = new ImageAttributes();
imgAttributes.SetColorMatrix(clrMatrix,
ColorMatrixFlag.Default,
ColorAdjustType.Bitmap);
g.DrawImage(cyanImage, 10,10);
g.DrawImage(magentaImage, 110,10);
g.DrawImage(yellowImage, 210,10);
g.DrawImage(blackImage, 310,10);
g.DrawImage(cyanImage, 0,0);
g.DrawImage(magentaImage, 0,0);
g.DrawImage(yellowImage, 0,0);
g.DrawImage(blackImage, 0,0);
g.DrawImage(cyanImage,
new Rectangle(300,300, cyanImage.Width, cyanImage.Height),
0, 0, cyanImage.Width, cyanImage.Height,
GraphicsUnit.Pixel, imgAttributes);
g.DrawImage(magentaImage,
new Rectangle(300,300, magentaImage.Width, magentaImage.Height),
0, 0, magentaImage.Width, magentaImage.Height,
GraphicsUnit.Pixel, imgAttributes);
g.DrawImage(yellowImage,
new Rectangle(300,300, yellowImage.Width, yellowImage.Height),
0, 0, yellowImage.Width, yellowImage.Height,
GraphicsUnit.Pixel, imgAttributes);
g.DrawImage(blackImage,
new Rectangle(300,300, blackImage.Width, blackImage.Height),
0, 0, blackImage.Width, blackImage.Height,
GraphicsUnit.Pixel, imgAttributes);
}
}
}
|
|
|
|
|
|
Code using Windows/Web Forms have both "Code View" and "Design View". AFAIK, the IDE knows when to provide the "Design View" by checking the first class declaration in the codefile.
What if I create an alternate editor for a codefile, something like "Design View", is it possible to integrate it into the IDE? If so, can anyone give me a pointer or two to an article or documentation?
-Maki
|
|
|
|
|
Hey,
This is driving me up the wall!
I have a set of 3 grids.
They bind correctly as follows
//Parent Grid
dataGrid1.DataSource=parent;
//Child Grid
dataGrid2.DataSource=parent;
dataGrid2.DisplayMember="Parent.Child";
//Grand Child Grid
dataGrid3.DataSource=parent;
dataGrid3.DisplayMember="Parent.ChildToGrandChild";
The relation works beautifully.Been working for months now.
Here is the issue:
I have to filter out data in the child grid ie dataGrid2, which in turn will affect dataGrid3 which is fine.
so I have tried using the RowFilter property of the DefaultView exposed by the DataTable, but to no avail.
These are the methods i have tried.
1. ((System.Data.DataTable) dataGrid2.DataSource).ChildRelations["Parent.Child"].ChildTable.DefaultView.RowFilter = " [FilterMeNow] = 1";
does not work.
2. I tried setting up the filter before establishing the databinding but after the relation is set, again it wont work.
3. Googling it leads to me to think setting the row filter is the way to go....but nothing seems to happen.
I know RowFilter works because I have been using it for single grid all year long.
So how do i go about using it in master-child relation datagrid.
Am I just supposed to refresh the grids after they are bound, resulting in the row filter to take affect. If so, how?
A frusturated Looney Tunezez
Cheers!
<bold>Looney Tunezez
"If you build it....
.....BUGS will come!" -JB
Application.Run(new Form1(this.Dispose())); <--WHAT :wtf::confused::eek:
"Stability. What an interesting concept" - Chris Maunder
<bold>
|
|
|
|
|
Does anyone know how to clear the clipboard so that neither Windows or Office can use what was copied?
|
|
|
|
|
If your using the Clipboard class, all you need to do is use the SetDataObject(object, bool); version of SetDataObject . The bool parameter tells the clipboard wheather or not to clear its contents when your application exists.
If you wanted to clear the clipboard at the click of a button, or other control, then you'll have to P/Invoke the Win32 OLE function OleSetClipboard[^]. It takes a single parameter, a pointer to an IDataObject , but in order to clear the clipboard, you'll pass in null .
[DllImport("ole32.dll")]
static extern int OleSetClipboard(IDataObject pDataObj);
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
In my application there is requirement that once the application is started then other opened windows on desktop should not be visible to the user.
I want to know if there is any way by which I can minimize all the open windows (on desktop).
|
|
|
|
|
Yes, however you will need to P/Invoke several Win32 functions. Your P/Invoke statements will look like the following:
const Int32 SW_HIDE = 0 ;
const Int32 SW_SHOWNORMAL = 1 ;
const Int32 SW_NORMAL = 1 ;
const Int32 SW_SHOWMINIMIZED = 2 ;
const Int32 SW_SHOWMAXIMIZED = 3 ;
const Int32 SW_MAXIMIZE = 3 ;
const Int32 SW_SHOWNOACTIVATE = 4 ;
const Int32 SW_SHOW = 5 ;
const Int32 SW_MINIMIZE = 6 ;
const Int32 SW_SHOWMINNOACTIVE = 7 ;
const Int32 SW_SHOWNA = 8 ;
const Int32 SW_RESTORE = 9 ;
const Int32 SW_SHOWDEFAULT = 10 ;
const Int32 SW_FORCEMINIMIZE = 11 ;
const Int32 SW_MAX = 11 ;
[DllImport("user32.dll")]
static extern int ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll")]
static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
[DllImport("user32.dll")]
static extern bool IsWindowVisible(IntPtr hWnd);
The implementation part would look something like this if you were invoking this from a button click:
private void bClick(object sender, EventArgs e)
{
EnumWindowsProc proc = new EnumWindowsProc(MinimizeWindow);
EnumWindows(proc, IntPtr.Zero);
}
private bool MinimizeWindow(IntPtr hWnd, IntPtr lParam)
{
if(IsWindowVisible(hWnd))
ShowWindow(hWnd, SW_SHOWMINIMIZED);
return true;
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hello..
Plz could any one help me on how to embed a numeric updown column in a DataGrid..
And thanks..
bhshs
|
|
|
|
|
Does anyone know the equivalent of
SetWindowExt
SetViewportExt
in C#.
I have an old dll that i need to use which draw object to a device context using the resilution of the device, this is fine where the device is a screen e.g 96dpi but if I use my printer 1200dpi then the object being displayed is tiny, so I would like to scale it up by a factor of deviceDPI / 96.0.
does anyone know hoe to do this
|
|
|
|
|
How about something like the following:
[DllImport("gdi32.dll")]
static extern bool SetWindowExtEx(IntPtr hdc, int nXExtent, int nYExtent, IntPtr lpSize);
[DllImport("gdi32.dll")]
static extern bool SetViewportExtEx(IntPtr hdc, int nXExtent, int nYExtent, IntPtr lpSize);
- Nick Parker My Blog | My Articles
|
|
|
|
|
HI,
I have add Refernce to COM DLL in ASP.NET.
Now how can i use it, means create its object
and calls its Functions etc,
DLL name is COMDLL.dll
and after creating its refernce nameis Interop.COMDLLLib .
so how i can use it
thanx
Regards.
|
|
|
|
|
One, you haven't set a reference in ASP.NET. ASP.NET is a technology, not a language...
You've set a reference to the .DLL in your C# project.
Second, without the docs on the .DLL, you're pretty much groping around in the dark.
What is this .DLL supposed to do? Where did you get it from?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am using FileSystemWatcher component to monitor a folder for file creation. My folder is basically an FTP folder where file take time to upload, but as its creation starts, file creation event is raised.
Now when i get the file size at the same time, it gives returns me 0 bytes. Kindly tell me how to deal with this issue. how to check if file creation is complete.
Also how can i know if a file has been fully copied???
Thanks in advance
|
|
|
|
|
I had a similar problem, I dint find any direct approaches like filecopied event or something similar,may be this will be of some help.
Use the Changed event, select the LastWrite notify filter.
u will get approx 3 events raised for each file activity.
keep a counter when it has reached 3 u can be relatively
sure that the file has been fully copied then u can check for file size.
cool man
|
|
|
|
|
There really seems to be no built-in way to do this.
Usually to determine if a file has been copied completely you try to open the file with exclusive access (for example using a File.Open() overload), and if this fails you know that another program is still accessing (i.e. copying) the file.
If the
Repeat until your File.Open() succeeds (or a certain number of retries has been made to avoid deadlocks).
Regards,
mav
|
|
|
|
|
Hi,
I'm a bigginer in programing C# and I have a simple problem that and I hope some one can help me out. I'm sending IP multicast from a server and after 10 packets I want to make a break for 10 sekunds before I transfer the next 10 packets. So my question is basically what is the command for making a delay?
Thanks in a million
|
|
|
|
|
hi,
If you are using threads then you can go ahead with the method
Thread.Sleep(1000)
parameter is in millisecond.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I want to do a user control. It can input number only and can check Integer's length and real's length. Can give me a sample?
|
|
|
|
|
hi,
Create a user control with a textbox or something. And provide a error provider which you will get from toolbox.
private void textBox1_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
if(textBox1.Text.ToString().Length > 5)
{
errorProvider1.SetError(textBox1,"can't be > 5");
}
else
errorProvider1.SetError(textBox1,"");
}
See this is a small hint to achive. Remaining is upto you to develop. And don't expect entire source code from here.
;P
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
int year = int.Parse(cboYear.Text);
int month = int.Parse(cboMonth.Text);
int day = int.Parse(cboDay.Text);
System.DateTime moment = new System.DateTime( year,month,day);
string dMy = moment.ToShortDateString();
string test_SQL = "Select * From test Where startDay <= " + (dMy) + "And endDay >= " + (dMy);
System.Data.OleDb.OleDbCommand test_cmd = new System.Data.OleDb.OleDbCommand (test_SQL, test_conn);
System.Data.OleDb.OleDbDataAdapter test_adapter = new System.Data.OleDb.OleDbDataAdapter(test_cmd);
System.Data.DataSet test_ds = new DataSet(); test_adapter.Fill(test_ds,"test");
// bind datagrid to dataset
dataGrid2.DataSource = test_ds;
dataGrid2.DataMember = "test";
test - table name
startDay (MM/dd/yyyy)- column name
endDay (MM/dd/yyyy)- column name
when the user select the date, month and year, my program will grab this value and compare it into the database. if found, it will display into the datagrid. i wanna use the date format (MM/dd/yyyy) to compare those in the database. Is not working!!!! help!!!!
Chris
|
|
|
|
|
hi,
After getting the date from user. here this line
System.DateTime moment = new System.DateTime( year,month,day);
Suppose your date is (value of moment ) 22-05-2004
You can convert it into string like
string dMy = moment.ToString("mm/DD/yyyy"); result will be->05/22/2004
string dMy = moment.ToString("dd/MM/yyyy"); result will be->22/05/2004
string dMy = moment.ToString("dd-MMM-yyyy"); result will be->22-May-2004
string dMy = moment.ToString("mmm-DD-yyyy"); result will be->May-22-2004
i think this will serve your need.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
thanks but it doesn't work. in my database, for example the startDay is 1/10/2005. whereas in my program, after extracting the date value from the user, it displays as 01/10/2005.. will there be any problem if there is a zero infornt ->01/10/2005 whereas in my database is just 1/10/2005???
|
|
|
|
|