|
You can use classes in System.IO namespace
|
|
|
|
|
System.IO.File.Move("oldFileName", "newFileName");
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
Hello,
I have two C# Applications one client side, one server side, which communicate via a web service that I am creating also. I wanted to create a class library so that classes that are used between the three applications can be re-used. I want to allow one of the webmethods in the web service to accept an object of one of the classes I have created in the class library but when I try and pass it from either application it says I can't because the types are different.
ABSWebService.Market doesn't equal ABSClassLibrary.Market (Event though in the web service it is referencing the Class Library to get the Market).
I have tried to cast it to the other type, but this isn't allowed either.
Any suggestions?
|
|
|
|
|
If you are using a WCF Service, when you add the service reference there is a setting for "Re-use classes in referenced assemblies".
If you're using old-fashioned web methods I think you're S.O.L.
|
|
|
|
|
Well I have only just started creating this, so I was using Web Services as that is what I know. But if it will work with WCF I will try that instead.
Just to add to the complexity the class library needs to be able to access another external web service that isn't mine, and all the applications need to create and pass objects of this web service type. Should I just forget Class Libraries?
|
|
|
|
|
Hello ,
how we can transform a file from Word to PDF and from PDF to Word?
Thank you verry mutch
|
|
|
|
|
You can do it using Adobe Acrobat. If you want to do it programmatically you need to search for third party library. There are several free and commercial ones available.
|
|
|
|
|
You can use the PDFCreator(PDF Printer) for transform any file to a PDF file.
Any developers write a program to convert in PDF but I don't have a program to convert PDF to Word.
|
|
|
|
|
Thank you for your answer, i would transform pdf to word and word to pdf using myprogram in C#, thank you verry mutch.
|
|
|
|
|
I am having difficulty in keeping the alpha channels in my images when I open them into a c# pictureBox.
Having spent a couple of days searching forums and things I gather that a pictureBox doesn't actually keep the alpha channel and that I need to store the info in memory and work on the data there, pre-multiplying the alpha channels and doing any other calculations I need to with the raw data and then display the result when all is done.
Unfortunately as a total noob I have no idea of how to do this.
My code so far:
Bitmap bitmap = new Bitmap(ImagePath + PBox1);
Bitmap layer = new Bitmap(ImagePath + PBox2);
for (int x = 0; x < layer.Width; x++)
{
for (int y = 0; y < layer.Height; y++)
{
Color BitmapPixel = bitmap.GetPixel(x, y);
Color LayerPixel = layer.GetPixel(x, y);
int r = (LayerPixel.A * (BitmapPixel.R - LayerPixel.R)) / 256 + LayerPixel.R;
int g = (LayerPixel.A * (BitmapPixel.G - LayerPixel.G)) / 256 + LayerPixel.G;
int b = (LayerPixel.A * (BitmapPixel.B - LayerPixel.B)) / 256 + LayerPixel.B;
Color newColor = Color.FromArgb(r, g, b);
bitmap.SetPixel(x, y, newColor);
}
progressBar1.PerformStep();
Update();
}
pictureBox3.Image = bitmap;
Basically what I want to do is take two images, both with an alpha layer in them. Overlay the second one onto the first one, using its alpha layer for transparency, and finally save out a new 32bpp image from the result.
Any help would be much appreciated.
Thankyou.
|
|
|
|
|
Doof369 wrote: I am having difficulty in keeping the alpha channels in my images when I open them into a c# pictureBox.
What did you expect the PictureBox to do?? It's only a "noobie" control used to quick'n'dirty show a single image. It doens't do any magical transformations on the image it's showing.
Doof369 wrote: I gather that a pictureBox doesn't actually keep the alpha channel
Yes it does, becuase it doesn't manipulate the Image object you passed to it in any way. Just because it doesn't show the results of the alpha channel, doesn't mean that it complete tossed it.
Doof369 wrote: I need to store the info in memory and work on the data there, pre-multiplying the alpha channels and doing any other calculations I need to with the raw data and then display the result when all is done.
That's exactly what you have to do. Check out the excellent series of articles Christian Grauss put together on image filters, here[^].
|
|
|
|
|
Doof369 wrote: Basically what I want to do is take two images, both with an alpha layer in them. Overlay the second one onto the first one, using its alpha layer for transparency, and finally save out a new 32bpp image from the result.
Just draw one image onto the other. Use Graphics.FromImage to create a Graphics object for one of the images, then use the DrawImage method to draw the other image on it.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks for the replies.
ok. So this is what I have now, which actually works ))
public static void ArgbOverlay(Bitmap bm2, Bitmap bm1, out Bitmap bm3)
{
int[,] a1 = new int[bm1.Width, bm1.Height];
int[,] a2 = new int[bm2.Width, bm2.Height];
int[,] a3 = new int[bm2.Width, bm2.Height];
int[,] r1 = new int[bm1.Width, bm1.Height];
int[,] r2 = new int[bm2.Width, bm2.Height];
int[,] r3 = new int[bm2.Width, bm2.Height];
int[,] g1 = new int[bm1.Width, bm1.Height];
int[,] g2 = new int[bm2.Width, bm2.Height];
int[,] g3 = new int[bm2.Width, bm2.Height];
int[,] b1 = new int[bm1.Width, bm1.Height];
int[,] b2 = new int[bm2.Width, bm2.Height];
int[,] b3 = new int[bm2.Width, bm2.Height];
Rectangle rect1 = new Rectangle(0, 0, bm1.Width, bm1.Height);
BitmapData bd1 = bm1.LockBits(rect1, ImageLockMode.ReadWrite, bm1.PixelFormat);
int bytes1 = bd1.Stride * bd1.Height;
byte[] argbValues1 = new byte[bytes1];
IntPtr ptr1 = bd1.Scan0;
Marshal.Copy(ptr1, argbValues1, 0, bytes1);
Rectangle rect2 = new Rectangle(0, 0, bm2.Width, bm2.Height);
BitmapData bd2 = bm2.LockBits(rect2, ImageLockMode.ReadWrite, bm2.PixelFormat);
int bytes2 = bd2.Stride * bd2.Height;
byte[] argbValues2 = new byte[bytes2];
IntPtr ptr2 = bd2.Scan0;
Marshal.Copy(ptr2, argbValues2, 0, bytes2);
bm3 = new Bitmap(bm1.Width, bm1.Height, PixelFormat.Format32bppArgb);
Rectangle rect3 = new Rectangle(0, 0, bm3.Width, bm3.Height);
BitmapData bd3 = bm3.LockBits(rect3, ImageLockMode.ReadWrite, bm3.PixelFormat);
int bytes3 = bd3.Stride * bd3.Height;
byte[] argbValues3 = new byte[bytes3];
for (int x = 0; x < bm1.Width; x++)
{
for (int y = 0; y < bm1.Height; y++)
{
int BitPos1 = (x * 4) + (y * bd1.Stride);
b1[x, y] = (int)argbValues1[BitPos1];
g1[x, y] = (int)argbValues1[BitPos1 + 1];
r1[x, y] = (int)argbValues1[BitPos1 + 2];
a1[x, y] = (int)argbValues1[BitPos1 + 3];
b2[x, y] = (int)argbValues2[BitPos1];
g2[x, y] = (int)argbValues2[BitPos1 + 1];
r2[x, y] = (int)argbValues2[BitPos1 + 2];
a2[x, y] = (int)argbValues2[BitPos1 + 3];
r3[x, y] = (r2[x, y] * a2[x, y]) / 256 + ((r1[x, y] * (256 - a2[x, y])) / 256);
g3[x, y] = (g2[x, y] * a2[x, y]) / 256 + ((g1[x, y] * (256 - a2[x, y])) / 256);
b3[x, y] = (b2[x, y] * a2[x, y]) / 256 + ((b1[x, y] * (256 - a2[x, y])) / 256);
if (a1[x, y] < a2[x, y])
{
a3[x, y] = a2[x, y];
}
else
{
a3[x, y] = a1[x, y];
}
argbValues3[BitPos1] = (byte)b3[x, y];
argbValues3[BitPos1 + 1] = (byte)g3[x, y];
argbValues3[BitPos1 + 2] = (byte)r3[x, y];
argbValues3[BitPos1 + 3] = (byte)a3[x, y];
}
}
IntPtr ptr3 = bd3.Scan0;
Marshal.Copy(argbValues3, 0, ptr3, bytes3);
bm3.UnlockBits(bd3);
return;
}
Was wondering if anyone can see any glaring ways to optimise this further to make it a less cumbersome piece of code and also to make it run faster if poss.
It is fine as it is, but less is more.
|
|
|
|
|
Who I Send data from textbox to datagridview in a diferent form?
Plesea give me the code.
Thanks.
|
|
|
|
|
Can you explain little bit more what exactly you mean in "different form". Do you mean different format or different "FORM"? If you give more details somebody will be able to help you out.
|
|
|
|
|
you need a public propety or method in the from with the datagridview thagt will take textbox value
then you need a reference to the instance of the form, possibly a static instance somewhere
then you just do
StaticInstance.ProcessFunction(textbox1.Text);
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
When you want to send the data, raise a custom event.
In the other form subscribe to that event and react accordingly.
Don't be tempted (as previously suggested) to send forms or textboxes as parameters (to constructors or methods) or static properties to other forms. It's bad design. You will end up coupling forms too closely together which is non OOP and will lead to maintanence nightmares as your application grows.
Basic outline below:
using System;
using System.Windows.Forms;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Shown += new EventHandler(Form1_Shown);
}
void Form1_Shown(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.TextUpdated += new EventHandler<TextUpdatedEventArgs>(form2_TextUpdated);
form2.Show();
}
void form2_TextUpdated(object sender, TextUpdatedEventArgs e)
{
Console.WriteLine(e.Text);
}
}
using System;
using System.Windows.Forms;
public partial class Form2 : Form
{
public event EventHandler<TextUpdatedEventArgs> TextUpdated;
public Form2()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
OnTextUpdated(new TextUpdatedEventArgs(textBox1.Text));
}
protected virtual void OnTextUpdated(TextUpdatedEventArgs e)
{
EventHandler<TextUpdatedEventArgs> eh = TextUpdated;
if (eh != null)
eh(this, e);
}
}
using System;
public class TextUpdatedEventArgs : EventArgs
{
private string m_Text;
public TextUpdatedEventArgs(string text)
{
m_Text = text;
}
public string Text
{
get { return m_Text; }
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
You should try using delegates and events.
It will work great, and you can even catch the event on another form too.
|
|
|
|
|
Hi out there,
Has anybody an idea how i can do the following with c# and visual studio 2008:
I want to recognize when the user is right clicking a desktop icon.
If the right clicked desktop icon has a special feature (name or tag or something else)
i want to open my own custom context menu.
Is it possible to override the desktop context menu ?
Or is there something like an global "object clicked event"
thanx in advance
Peter
modified on Wednesday, February 11, 2009 10:07 AM
|
|
|
|
|
Yeah, totally. I remember using the Registry (regedit) to add a custom menu a while back but for the life of me I cannot remember how I did it. I'm going through my files looking for the snippet, if I find it I'll post it.
j.t.
|
|
|
|
|
Hi,
thanx for your rapid answer.
But i want to do this programmatically.
The context menu should be created dynamically depending on
the type of clicked icon.
ciao
Peter
|
|
|
|
|
There are several articles at codeproject that show how to make your own context menu items you need a simple search.
|
|
|
|
|
Hi,
Perhaps you did not understand what i want:
Yes i found ways to add items to the default desktop context menu !
I dont want to add items, i want to replace or override the desktop context menu in
special context.
For example:
If the right clicked desktop icon represents a directory i want to rise a custom
context menu with all the entries in this directory. The selected
context menu item should then be started.
Peter
|
|
|
|
|
Hi All,
I was wondering if it would at all be possible to create my own very small and simple programming language using C# Express Edition? And how one might go about doing so? I'd appreciate any help I can get on this. Thanks in advance
j.t.
j.t.
|
|
|
|
|
Basically you will need to learn assembly language i.e. how an executable is created
Then you would need to parse you language and produce your assembly code based on the parsed values
Quite a simple theory really :P
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|