|
|
yes.. it is alpha blend images.
e.g. I used the simple program to seperate the color image into C,M,Y,K 4 images. They are same, but different color seperation layers
Now I wnat to generate a correct color image as same as origion one in C#, and then preview it. I don't know how can I do this blending process..
Can you help me ? Thank you
|
|
|
|
|
Check out Joe Pardue's tutorial on alpha blending here http://www.codeproject.com/cs/media/CsTranspTutorial1.asp
or Rakesh Rajan's article here
http://www.codeproject.com/cs/media/alphafx.asp
|
|
|
|
|
Hello!
I want to create a method that connects to a sql db and retrives some values. I want the connection in a method so I can reuse the code. My question is if I can return a data in the same way you return a string or int? And how do i do this?
|
|
|
|
|
_Searcher_ wrote:
My question is if I can return a data in the same way you return a string or int?
Yes
_Searcher_ wrote:
And how do i do this?
For example:
public DataReader MyMethod()
{
DataReader dr = myCommand.ExecuteDataReader();
return dr;
}
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
|
|
|
|
|
Well the earlier response I guess answers your question. I just would like to add that you may go through Microsoft Data Application Block(downloadable from Microsoft site) and use their ready made methods to connect to database and retrieve or insert data. It is damn simple to use and very very efficient... believe me... and lines of code???... Imagine writing just 2 lines of code to retrieve data from database...
To give you a picture... the application block manages the connection... you only need to supply the query...
Cheers...
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
Thanks so much for the answers!
It worked out great. I didnt try the data application block, but I will look in to that later!
|
|
|
|
|
hi
friends i am working with listbox
The problem :Horizontal scroll is not working as expected when i use
OwnerDraw mode
MeasureItemEventHandler
please help
regards
and thank you in advance
/**************** code ************/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication1
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// 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 );
}
#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()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
InitializeOwnerDrawnListBox();
}
internal System.Windows.Forms.ListBox ListBox1;
private void InitializeOwnerDrawnListBox()
{
this.ListBox1 = new System.Windows.Forms.ListBox();
// Set the location and size.
ListBox1.Location = new Point(20, 20);
ListBox1.Size = new Size(100, 100);
// Populate the ListBox.ObjectCollection property
// with several strings, using the AddRange method.
this.ListBox1.Items.AddRange(new object[]{"System.Windows.Forms",
"System.Drawing", "System.Xml", "System.Net", "System.Runtime.Remoting",
"System.Web"});
// Turn off the scrollbar.
ListBox1.ScrollAlwaysVisible = true;
// Set the border style to a single, flat border.
//ListBox1.BorderStyle = BorderStyle.FixedSingle;
// Set the DrawMode property to the OwnerDrawVariable value.
// This means the MeasureItem and DrawItem events must be
// handled.
ListBox1.DrawMode = DrawMode.OwnerDrawVariable;
ListBox1.MeasureItem +=
new MeasureItemEventHandler(ListBox1_MeasureItem);
ListBox1.DrawItem += new DrawItemEventHandler(ListBox1_DrawItem);
this.Controls.Add(this.ListBox1);
}
// Handle the DrawItem event for an owner-drawn ListBox.
private void ListBox1_DrawItem(object sender, DrawItemEventArgs e)
{
// If the item is the selected item, then draw the rectangle
// filled in blue. The item is selected when a bitwise And
// of the State property and the DrawItemState.Selected
// property is true.
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
{
e.Graphics.FillRectangle(Brushes.CornflowerBlue, e.Bounds);
}
else
{
// Otherwise, draw the rectangle filled in beige.
e.Graphics.FillRectangle(Brushes.Beige, e.Bounds);
}
// Draw a rectangle in blue around each item.
e.Graphics.DrawRectangle(Pens.Blue, e.Bounds);
// Draw the text in the item.
e.Graphics.DrawString(ListBox1.Items[e.Index].ToString(),
this.Font, Brushes.Black, e.Bounds.X, e.Bounds.Y);
// Draw the focus rectangle around the selected item.
e.DrawFocusRectangle();
}
// Handle the MeasureItem event for an owner-drawn ListBox.
private void ListBox1_MeasureItem(object sender,
MeasureItemEventArgs e)
{
// Cast the sender object back to ListBox type.
ListBox theListBox = (ListBox) sender;
// Get the string contained in each item.
string itemString = (string) theListBox.Items[e.Index];
// Split the string at the " . " character.
string[] resultStrings = itemString.Split('.');
// If the string contains more than one period, increase the
// height by ten pixels; otherwise, increase the height by
// five pixels.
if (resultStrings.Length>2)
{
e.ItemHeight += 10;
//theListBox.HorizontalScrollbar = true ;
}
else
{
e.ItemHeight += 5;
}
e.ItemWidth +=100000 ;
}
}
}
P.S. PATWAL
|
|
|
|
|
hi,
I guess you need to set the
"listBox1.HorizontalScrollbar = true"
property of the ListBox... and that will do the magic...
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
i did that !!!! for c#'s sake !!!
check the code
P.S. PATWAL
|
|
|
|
|
hi,
But your code shows that the line is commented... for your ease let me point out the line with repeated "*"s...
// Handle the MeasureItem event for an owner-drawn ListBox.
private void ListBox1_MeasureItem(object sender,
MeasureItemEventArgs e)
{
// Cast the sender object back to ListBox type.
ListBox theListBox = (ListBox) sender;
// Get the string contained in each item.
string itemString = (string) theListBox.Items[e.Index];
// Split the string at the " . " character.
string[] resultStrings = itemString.Split('.');
// If the string contains more than one period, increase the
// height by ten pixels; otherwise, increase the height by
// five pixels.
if (resultStrings.Length>2)
{
e.ItemHeight += 10;
/*********** you have commented here**********************/
//theListBox.HorizontalScrollbar = true ;
/********************************************************/
}
else
{
e.ItemHeight += 5;
}
e.ItemWidth +=100000 ;
}
and if it has still not worked...
then try declaring the same when you are instantiating or rather creating the listbox...
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
How to check Maximize button click event of a Form or how to check whether present size of form is maximum available size.
please guide...
|
|
|
|
|
hi,
Handle the "SizeChanged" event of the Form and use the following code :
private void Form1_SizeChanged(object sender, System.EventArgs e)
{
if(this.WindowState == FormWindowState.Maximized)
{
MessageBox.Show("the window is maximized !!");
}
}
Hope this solves your prob...
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
Or at any time check the Form.WindowState to see if it's maximized or not. If you need to check if the form isn't maximized but fills the entire desktop area, you can also compare Form.Bounds with SystemInformation.WorkingArea or Screen.WorkingArea (using a certain screen on a multi-monitor system).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
static void Main(string[] args)
{
XPathNavigator nav;
XPathNodeIterator NodeIterator;
System.String line = "<a> " +
"<b>" +
"<c>100</c>" +
"<d>20</d>" +
"</b>" +
"</a>";
System.Xml.XmlTextReader textReader=new System.Xml.XmlTextReader(new System.IO.StringReader(line));
nav=new System.Xml.XPath.XPathDocument(textReader).CreateNavigator();
NodeIterator = nav.Select("a/b");
while(NodeIterator.MoveNext())
{
System.Console.WriteLine("Value: " + NodeIterator.Current.Value);
}
}
This code prints value of the node 'a/b' as '10020'. Actually the value should have been empty. Can any one explain the correct way of retrieving the value of the parent node.
regards,
Dhananjay
DHANANJAYA.V E-mail: dhananjayav@yahoo.co.in
|
|
|
|
|
The child elements of b are part of the node set of b , so they will be displayed using an XPathNodeIterator .
Also, you should simply create a new System.IO.StringReader in your XmlTextReader constructor. You should dispose this when finished, and you can't like this. ASsign it to a local variable and call Dispose when you're finished with it (or use a using block which automatically disposes the object when it falls out of scope regardless of any exceptions thrown).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear helpers out there
1. how do I display data from database into a checkbox list?
2. how do I display a new data into that checkbox list (into its database as well), when I add the new data from a AddButton_click?
Thank You A Bunch !!
|
|
|
|
|
You set the DataSource property to a valid data source, like a DataSet or DataTable . If your data source implements IListSource (like a DataSet ), then you should set the DataMember to the name of the object (like the name of the DataTable you want to bind to).
Then, set the DataTextField and DataValueField to the names of the columns or properties (depending on whether you bind against a ADO.NET data source or a list of objects).
If you add a row to the CheckBoxList , make sure it gets added to the data source (like a DataSet ). If you want to add this to the database as well, you should either use a DataAdapter derivative (like a SqlDataAdapter for SQL Server) with the command properties set accordingly and call Update , passing the DataSet . You could also just add it manually to the database and to the DataSet , but then you have a synchronization problem (they might get out of sync).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear all
I have tried to open a tcplistener on a server and i have accept many connection and redirect every conncetion to a thread, for splitting sended data from every client but unfortunatlly i have get corrupted data which is merged from many senders from the network i could not split them so if anynody have an idea about this problem could send it to me
Thanks for help
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
Hi folks,
Having just discovered the delights of using IDisposable properly, I have a question concerning the disposal of collections of IDisposable objects.
The scenario is as follows:
I have a class implementing IDisposable. This class owns a collection of other objects that implement IDisposable.
So, when I dispose the main object, should I dispose the contents of the array as well?
Any advise, comments and/or opinions welcome.
PS: Sorry for any typos I suffering mild RSI (three days of furious coding)
Dr Herbie @ Autoscribe
Remember, half the people out there have below average IQs.
|
|
|
|
|
If the class "owns" the objects (e.g., private fields) then, yes, you should dispose them.
If the class is merely a container for the objects (e.g., a collection like ArrayList), then no, the class user is responsible for that.
Due to technical difficulties my previous signature, "I see dumb people" will be off until further notice. Too many people were thinking I was talking about them...
|
|
|
|
|
I'm not sure how to explain this.
E.G. on a Data Grid Control (Design Time) in the Property Window there is a Auto Format..., Property Builder... Link.
When Clicked on, a window opens up and you can change the properties in a Windows Form.
now my Question is How do I create the Same thing on a control of mine.
|
|
|
|
|
Implement your own designer class (like a ControlDesigner ) and override the Verbs property. Attribute your control or component with the Type of your designer using the DesignerAttribute class.
See the ComponentDesigner.Verbs property documentation in the .NET Framework SDK for more details. You should also read Enhancing Design-Time Support[^] in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
problem with using VNC hooking
--------------------------------------------------------------
i have got a vnchood.dll and its source code.
the vnchood.dll use a global hook to monitor the desktop's changed area. i want to implement it in my c# project. but i dont know how to use it.
after my study on the source code ,i draw a conclusion: the hook posts messages to its calling thread, and the thread handle the coming message and to do something.
in my c# project,i invoke peekMessage() to gain the message from the hook. but the message seems wrong for it is always an invalide massage.
here is my part code:
private void hookthread()
{
while(true)
{
if(PeekMessage( ref msg,IntPtr.Zero,0,0,1))
{
if ( msg.message == UPDATEMSG )
{
idle_skip = true;
Console.WriteLine("hwnd:"+msg.hwnd);
}
else if ( msg.message == MOUSEMSG )
{
idle_skip = true;
Console.WriteLine("hwnd:"+msg.hwnd);
}
else if ( msg.message == WNDMSG )
{
Console.WriteLine("hwnd:"+msg.hwnd);
}
else if ( msg.message == WM_QUIT )
{
break;
}
else if ( msg.message == WM_USER )
{
Console.WriteLine("hwnd:"+msg.hwnd);
}
else if ( msg.message == WM_USER+2 )
{
Console.WriteLine("hwnd:"+msg.hwnd);
}
else if ( msg.message == WM_USER+1 )
{
}
else
{
TranslateMessage(ref msg); <--- the Loop always be here
DispatchMessage(ref msg);
idle_skip = true;
}
}
else
{
dosomthing();
}
}
---------------------------------
can u give me a suggestion ? or other C# sample using VNC hooking ?
|
|
|
|
|
Are you saying that you're rewriting the vnchook.dll in C#?
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|