|
Two things:
1:
SaveFileDialog save = new SaveFileDialog();
save.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
save.Title = "Save the File";
if(save.ShowDialog() == DialogResult.OK) Use this to prevent exception on Cancel click
{
string fName = save.FileName;
if (save.FileName != "")
{
System.IO.Stream fileStream = (System.IO.FileStream)save.OpenFile();
switch (save.FilterIndex)
{
case 1:
this.button7.Image.Save(fileStream, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
case 2:
this.button7.Image.Save(fileStream, System.Drawing.Imaging.ImageFormat.Gif);
break;
case 3:
this.button7.Image.Save(fileStream, System.Drawing.Imaging.ImageFormat.Bmp);
break;
}
fileStream.Close();
}
}
}
2: Set Buttons Image Property !!!
|
|
|
|
|
Hi
I have made a report to print a Bill. every thing is working properly but Hight of Table varries according to the no of items.
I m putting Partnos , description , qty, rate, total in TABLE BODY section.
I have used footer section of TABLE control for tax and total amount display.
I have fixed 8 rows/ page.
when 8 rows r in report Tax comes at right place but when 2 or 3 rows r thier then Tax section comes immediatly after item rows.
I want it to come at fix place.
PLease help me out this problem.
Thanks in advance.............
Amitendra
amitendra
|
|
|
|
|
Not sure if this is right, you have a footer to the TABLE that will be based on the table content. I think you need a PAGE footer to do the fixed position at the bottom of the page.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I've got this issue with loading an assembly from a byte array.
What happens?
First I create an assembly from C#-code which is generated. Then I stream the assembly to a byte[] and store this array in the database (column type = image, MSSQL 2000).
When I need the assembly, I retrieve the byte[] from the db and want to load it. I try to load the assembly using Assembly.Load(array), and then it breaks. For some strange reason my VS decided to give me a Dutch error while my language is set to English:
{"Could not load file or assembly '169 bytes loaded from FormuleCompiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Poging om een programma te laden met een onjuiste indeling."}
Which I think translates to:
{"Could not load file or assembly '169 bytes loaded from FormuleCompiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."}
I'm having trouble finding a good solution for it, as I don't know where it goes wrong. It all happens in the same namespace, by the same package. So the creation, streaming and loading happens in the same dll.
Source I use is below:
public CompiledFormula GetCompiledFormula(string cstext)
{
Assembly ass = Compile(cstext);
CompiledFormula result = (CompiledFormula)ass.CreateInstance("Compiler.COMPILEDFORMULA");
return result;
}
The byte conversion as follows:
public byte[] GetArrayFromAssembly(Assembly formula)
{
byte[] assembly;
try
{
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Serialize(stream, formula);
assembly = stream.ToArray();
}
catch(Exception ex)
{
throw ex;
}
}
And this is the loading routine:
public CompiledFormula LoadFormuleFromAssembly(byte[] array)
{
try
{
Assembly assembly = Assembly.Load(array);
CompiledFormula formule = (CompiledFormula)ass.CreateInstance("Compiler.COMPILEDFORMULA");
return formule;
}
catch (System.Exception ex)
{
throw ex;
}
}
Anyone has an idea? Also, tell me if I make a horrible mistake here
The consumer isn't a moron; she is your wife.
|
|
|
|
|
I would be hugely suspicious of your serialisation code. A 169 byte assembly sounds very, very small to me.
Unfortunately, I have no idea how to convert a dynamically created assembly to a byte array (short of using AssemblyBuilder.Save then loading it in from disc).
Not being much help I know, but I can't believe you can use BinaryFormatter.Serialize to save the MSIL of assembly to a stream like that.
Regards,
Rob Philpott.
|
|
|
|
|
The assembly created, as it is now, is a 1 function class which on disk is no more than a 10k .cs file. The dynamic part is the function body which is generated. For me, I think the problem can either be in the byte array generation (the point of your suspicion), or at the load routines. I'm still considering namespaces to be an issue too, but haven't gotten any proof of me being right or wrong.
The hunt continues...
The consumer isn't a moron; she is your wife.
|
|
|
|
|
was carrying a variable trough sessions but realised that my code seemed to be better functional without these, so now am wondering how else i can carry my variable across multiple methods without making it global
|
|
|
|
|
There is the ViewState collection object, similar to Session, with the only difference that object stored in ViewState must be Serializable.
|
|
|
|
|
Exept for ViewState is for a single page. If this is a simple type (i.e. int, string, bool) I would just store it using cache or query string. But if it is a simple type storing it in session is a viable option as well.
|
|
|
|
|
The guy talked about accessing a variable across multiple methods. I assumed that he meant "multiple methods on the same page".
|
|
|
|
|
i want to play multiple video files one after another continously, using axWindowMediaPlayer tool.. For which I wrote the below code....
But here the problem is tat, it plays the last video file only and initial ones are not at all played.....
where am i going wrong ???
plz help ----
*************************************************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
System.IO.FileInfo[] files = null;
int index = 0;
private void Form1_Load(object sender, EventArgs e)
{
System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo("C://
mist");
files = dirInfo.GetFiles("*.avi");
foreach(FileInfo f1 in files)
{
axWindowsMediaPlayer1.URl=f1.FullName;
}
}}}
|
|
|
|
|
I think you should read this.[^]
|
|
|
|
|
Hi,
I have kind of a drawingprogram. I display an image in a canvas and on that canvas with image the user can place multiple custom controls (drawing area's derived from the canvas class) in which the user can draw figures and text. To input the text, I initialize a textbox. When clicking outside the textbox, that textbox must disappear and the text is shown as formatted text (drawingContext.draw) on the control. I do that with textBox.LostFocus and textBox.LostKeyboardFocus.
Problem is that when I click outside the textbox, the textbox does not lose focus! When clicking on the canvas, I use this.focus() . The code when clicking the canvas is called and it passes the focus command but the textbox does not lose focus.
The code to hide the textbox and display the text as formatted text works.
Anybody has an idea? Maybe I missed something in MSDN that I need to do.
Thanks,
Bart
|
|
|
|
|
My idea is to set Canvas.Focusable Property to True
|
|
|
|
|
So easy! Now it works perfect. I never stood still that canvas was standard not focusable.
Thanks very much!!!
|
|
|
|
|
help what does this error mean
Error 8 No overload for method 'GetQuotQuntityItem' takes '0' arguments
|
|
|
|
|
benson.misi wrote: help what does this error mean
Error 8 No overload for method 'GetQuotQuntityItem' takes '0' arguments
It means you've called GetQuotQuntityItem with no parameters, and there isn't a version of this method that has no parameters. You need to specify the parameters it's expecting because Object Orientation isn't psychic coding.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Welcome (you and 'psychic coding') to the CP's memorable quotes list
(you my access the list via http://www.codeproject.com/Members/CPallini since the permalink for the list is broken)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Why thank you sir.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
You have a method GetQuotQuntityItem which takes some parameters and you are calling it without specifying the parameters.
|
|
|
|
|
I have a native C DLL which contains the following function:
int FOO(
UINT A,
UINT B,
int X,
int Y,
void *(*get_Z)(int, int, void*),
void* I,
int G, int* &K, int* &L
) throw () ;
What should I do to be able to use it in my C# program.
The solution: this link[^]
Thanks to Henry Minute
Roman
modified on Tuesday, April 21, 2009 7:35 AM
|
|
|
|
|
Wait no more.
Take a look at this[^].
The tool there should enable you to generate the required code.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I have a program which has a control that gets live web cam video feed and plays it on a rectangle in the main form. I have the following code for the control "Mouse_Click" event:
private void videoSourcePlayer_MouseClick(object sender, MouseEventArgs e)
{
txtMouseX.Text = e.X.ToString();
txtMouseY.Text = e.Y.ToString();
}
i need to convert the e.X and e.Y to integer format, and use those values in the getPixel function of the bitmap image taken from the video source player in the following code:
private void videoSourcePlayer_NewFrame( object sender, ref Bitmap image )
{
bool showOnlyObjects = onlyObjectsCheck.Checked;
Bitmap objectsImage = null;
objectsImage = image;
colorFilter.ApplyInPlace( image );
BitmapData objectsData = objectsImage.LockBits( new Rectangle( 0, 0, image.Width, image.Height ),
ImageLockMode.ReadOnly, image.PixelFormat );
UnmanagedImage grayImage = grayscaleFilter.Apply( new UnmanagedImage( objectsData ) );
objectsImage.UnlockBits( objectsData );
blobCounter.ProcessImage( grayImage );
Rectangle[] rects = blobCounter.GetObjectRectangles( );
if ( rects.Length > 0 )
{
Rectangle objectRect = rects[0];
Graphics g = Graphics.FromImage( image );
using ( Pen pen = new Pen( Color.FromArgb( 160, 255, 160 ), 3 ) )
{
}
g.Dispose( );
}
}
how do i get the mouse x and y coordinate values from the first function into the second function so i can use the "image.getPixel()" call?
|
|
|
|
|
sebogawa wrote: how do i get the mouse x and y coordinate values from the first function into the second function
Short answer, you can't!
Judging from its signature, your videoSourcePlayer_NewFrame method is an event handler for the video player you are using. Its parameters are fixed and interfering with then will break the code.
One possible solution is to make the UnmanagedImage grayImage declaration a class field (Move the declaration outside the handler), then in your MouseClick handler do something like
private void videoSourcePlayer_MouseClick(object sender, MouseEventArgs e)
{
txtMouseX.Text = e.X.ToString();
txtMouseY.Text = e.Y.ToString();
Color selectedColor = grayImage.GetPixel(e.X, e.Y);
SomeMethodThatUsesTheColor(grayImage.GetPixel(e.X, e.Y));
}
Your biggest problem might turn out to depend on how quickly the grayImage changes.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thank you for the help Henry. I was wondering if the videosourcePlayer_NewFrame can inherit the videoSourcePlayer_MouseClick values and apply them to the _NewFrame block? I have been playing around with basic inheritance but involves only classes. I stunbled upon a C# lesson involving polymorphism (inheriting from a method) at the following link:
http://www.softsteel.co.uk/tutorials/cSharp/lesson14.html[^]
Do you think this will help? If not then how can i solve my problem, detaching the greyimage declaration and applying it to mouse click does nothing due to the fact that the greyImage can not be changed. I am trying to make it so that when i click on the live video feed control, it takes the ARGB values of the pixel clicked on (plus or minus 30) and apply it to the ARGB filter textboxes which saturates the image to only show the given color. (color tracking)
the purpose of this app is for a robot that i am working on that tracks while traffic lines, 3 inches thick which the robot must stay in between. I am using webcams, and the AForge library for video processing and I scrapped together pieces of the "Lego Pan and Tilt App" from a Code Project Article. The app works but i have to manually set all the ARGB ranges to find the color i want. It would be easier to just click on the image and get the values. I hope this information helps, im stuck and at a loss for ideas. Any help would be greatly appreciated.
modified on Tuesday, April 21, 2009 3:11 PM
|
|
|
|