|
i want to create a negative filter of any image..
i am trying this...
public void Negative()
{
Bitmap copy=new Bitmap(m.Width,m.Height);
ImageAttributes ia = new ImageAttributes();
ColorMatrix cm = new ColorMatrix();
cm.Matrix00 = cm.Matrix11 = cm.Matrix22 = 0.99f;
cm.Matrix33 = cm.Matrix44 = 1;
cm.Matrix40 = cm.Matrix41 = cm.Matrix42 = .04f;
ia.SetColorMatrix(cm);
Graphics g=Graphics.FromImage(copy);
g.DrawImage(m,new Rectangle(0, 0,m.Width, m.Height), 0, 0, m.Width, m.Height, GraphicsUnit.Pixel, ia);
g.Dispose();
m.Dispose();
}
but here is some error occur in this.......
error is:
Error 2 Argument '2': cannot convert from 'I_M_Editor.Rectangle' to 'System.Drawing.Rectangle' D:\dot.net.programs.using.c#\0eh066\I'M Editor\I'M Editor\frmEditable.cs 688 15 I'M Editor
and
Error 1 The best overloaded method match for 'System.Drawing.Graphics.DrawImage(System.Drawing.Image, System.Drawing.Rectangle, float, float, float, float, System.Drawing.GraphicsUnit, System.Drawing.Imaging.ImageAttributes)' has some invalid arguments D:\dot.net.programs.using.c#\0eh066\I'M Editor\I'M Editor\frmEditable.cs 688 1 I'M Editor
}
hghghgh
|
|
|
|
|
You may have a problem with namespace and refer to wrong Rectangle. Try adding the namespace like:
maifs wrote: g.DrawImage(m,new Rectangle(0, 0,m.Width, m.Height), 0, 0, m.Width, m.Height, GraphicsUnit.Pixel, ia);
g.DrawImage(m,new System.Drawing.Rectangle(0, 0,m.Width, m.Height), 0, 0, m.Width, m.Height, GraphicsUnit.Pixel, ia);
The need to optimize rises from a bad design
|
|
|
|
|
it doesnt effect on picture dear...
i think ,it happens for reason of picturebox.
actually picture is in picturebox..
if soo then what should i do?
hghghgh
|
|
|
|
|
I really don't understand your question. You have the following line in the code:
g.DrawImage(m,new Rectangle(0, 0,m.Width, m.Height), 0, 0, m.Width, m.Height, GraphicsUnit.Pixel, ia);
and the compiler reports an error:
Error 2 Argument '2':
cannot convert from 'I_M_Editor.Rectangle' to 'System.Drawing.Rectangle'
D:\dot.net.programs.using.c#\0eh066\I'M Editor\I'M Editor\frmEditable.cs 688 15 I'M Editor
So what I believe is that you have defined a class named Rectangle in your namespace (I_M_Editor ) and the compiler tries to use it instead of the expected System.Drawing.Rectangle class. That's why I suggested adding the namespace information to the call to new Rectangle class.
The need to optimize rises from a bad design
|
|
|
|
|
I created a C# Windows Application. I used a Setup Project to Deploy the intial software to my users.
I now have patchs and minor enhancements that I want to Deploy. What is the easiest way to do this?
I have updated the Assembly info for my project and my setup project. I modified the setup project to not uninstall previous version. This appears to work just fine, but when I view my Add/Remove programs window I show multiple installs of the software.
Any help would be greatly appreciated!
Scott K
|
|
|
|
|
Go to the properties of Setup Project and the set value true of "RemovePreviousVersion". And also change the version property. After setting these properties build the project and then install on your client machine. You have only on instance in Add/Remove programs.
|
|
|
|
|
Yes, I understand that by setting this property to true it will remove the version I just installed. Here is the issue: When I set this property to true it uninstalls my DB and replaces it with an empty one. My users loose their data.
Is there a way for me to exclude this file?
|
|
|
|
|
Use the simple way but this is not technical
Remove the database from setup project.
Database place on other location.
Make new connection string for that, then bulid and deploy.
|
|
|
|
|
What is my alternative than doing that? I have a lot of installs of the software out there?
sk
|
|
|
|
|
There is no alternative - do as MSF suggested, remove the DB from your update distribution. This is a common newbie error, you need to think through your deployment method better. You should ALWAYS have at least 2 deployments, install and update.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Is possible to create an XmlDataSource that has 50 columns merge an sql database with 14 columns into and force the other 36 columns except and false or any value I want with c#
Learning to Code
|
|
|
|
|
i don´t know i to do that but xml is kind of a language you can use to comunicate between diferent languages.
you can do that but i don´t know how.
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
You might try asking this in the linq forum, there may be a way to do it via a linq select and join query.
You could do it in c# by opening the 2 datasets and manipulating the column rows manually, bloody ugly solution though.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I don't know linq have any sites on samples I could look at.
also can you give and example in c#.
Learning to Code
|
|
|
|
|
i am trying this...but it doesn't affect on picture.
public void OnZoom25(bool zoomEnable)
{
zoom25Enable = zoomEnable;
if (zoom25Enable)
{
Zoom = 5.25;
this.AutoScrollMinSize = new Size((int)(m.Width * Zoom), (int)(m.Height * Zoom));
pbx.Image = m;
this.Invalidate();
}
}
i want to zoom up the picture but picture is in picture box(pbx)..
the form's size increses but picture stay there how can i zoom up it with picture ox?
hghghgh
|
|
|
|
|
tell me if you find out how.
try this, i place the picturebox inside a panel(220size) and i allow scroll.
maybe you only need this.
...
Image img = Image.FromFile(open_file_dialog.FileName);
if (img.Height > 220 || img.Width > 220)
{
mypicturebox.SizeMode = PictureBoxSizeMode.AutoSize;
mypicturebox.Dock = DockStyle.None;
mypicturebox.Location = new System.Drawing.Point(0, 0);
}
else
{
mypicturebox.SizeMode = PictureBoxSizeMode.CenterImage;
mypicturebox.Dock = DockStyle.Fill;
}
good luck
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
|
I am developing an application where we store the password in the config file. (Windows Forms application, C#).
Now i don't want to save it in plain text. i have found the following code to actually de/encrypt. But i don't know exactly where/when i am supposed to use them.
Do i use them:
a. Program.Run , then on disposing the main form
or
b. decrypt before settings read/write, encrypt after settings read/write
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
object configSection;
ConfigurationSection;
configSection = config.ConnectionStrings;
if (!(configSection == null)) {
if (!configSection.ElementInformation.IsLocked) {
configSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
configSection.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
}
}
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
object configSection;
ConfigurationSection;
configSection = config.ConnectionStrings;
if (!(configSection == null)) {
if (!configSection.ElementInformation.IsLocked) {
configSection.SectionInformation.UnprotectSection();
configSection.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
}
}
|
|
|
|
|
We decrypt the password just prior to being used in the connection string. The encrypt/decrypt is part of the DAL and the apps pass in the encrypted string which is stored in config and database tables.
Drawback is that if we wish to change the encryption keys we need to redeploy the apps.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I 'm using a ScrollableControl and I want to draw it's
client area according to the position of its scrollbars.
I 've set "AutoScroll" to false and all the properties of
the horizontal & vertical scrollbars to the desired values.
However, when the user tries to scroll the scrollbars, their
position (Value) becomes zero. You can download a demo project
of my problem from:
http://rapidshare.com/files/149469756/ScrollableControl_Bug.zip.html
Could it be a bug of the ScrollableControl ?
Thanks in advance.
kostas KEL
|
|
|
|
|
Here is the code (just in case you don't like downloading):
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ScrollableControl_Bug
{
public partial class Form1 : Form
{
ScrollableControl scrl = new ScrollableControl();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Controls.Add(scrl);
this.Resize += new EventHandler(Form1_Resize);
scrl.Dock = DockStyle.Fill;
scrl.AutoScroll = false;
scrl.Visible = true;
scrl.HorizontalScroll.Minimum = 0;
scrl.HorizontalScroll.Maximum = 400;
scrl.HorizontalScroll.LargeChange = this.Height;
scrl.HorizontalScroll.SmallChange = 10;
scrl.HorizontalScroll.Value = 30;
scrl.HorizontalScroll.Visible = true;
scrl.VerticalScroll.Minimum = 0;
scrl.VerticalScroll.Maximum = 400;
scrl.VerticalScroll.LargeChange = this.Width;
scrl.VerticalScroll.SmallChange = 10;
scrl.VerticalScroll.Value = 30;
scrl.VerticalScroll.Visible = true;
scrl.Scroll += new ScrollEventHandler(scrl_Scroll);
scrl.Paint += new PaintEventHandler(scrl_Paint);
}
void scrl_Paint(object sender, PaintEventArgs e)
{
Graphics gr = e.Graphics;
string str = "Horiz. Scroll Value = " + scrl.HorizontalScroll.Value.ToString() +
"\r\nVert. Scroll Value = " + scrl.VerticalScroll.Value.ToString() +
"\r\n\r\nTry to scroll...";
gr.DrawString(str, new Font("Arial", 10.0f), new SolidBrush(Color.Black), 0.0f, 0.0f);
}
void Form1_Resize(object sender, EventArgs e)
{
scrl.VerticalScroll.LargeChange = this.Height;
scrl.HorizontalScroll.LargeChange = this.Width;
scrl.Refresh();
}
void scrl_Scroll(object sender, ScrollEventArgs e)
{
scrl.Refresh();
}
}
}
kostas KEL
|
|
|
|
|
Thanks to Anonymous poster at some Blogger.com site...
---
Just in case someone stumbles across this post searching for a way to disable the AutoScroll behavior of scrolling to the focused control, the cleanest solution is provided in .NET 2.0: There is an overrideable ScrollToControl method in the ScrollableControl now. Replace the call to the base class implementation to return DisplayRectangle.Location and problem solved.
protected override Point ScrollToControl(Control activeControl)
{
return DisplayRectangle.Location;
}
---
Hope it helps.
- Erpizn13
|
|
|
|
|
This didn't work for me - my panel still scrolls to the top of the selected control when the panel is reactivated after some other window has the focus. But thanks to you I did find a solution.
I was able to disable scrolling by overriding method AdjustFormScrollbars(). I use a class-level flag (_enableScroll) to control when I want scrolling enabled, as follows:
protected override void AdjustFormScrollbars(bool displayScrollbars)
{
if (_enableScroll)
{
base.AdjustFormScrollbars(displayScrollbars);
}
}
I set _enableScroll false when my main form is deactivated and use a timer to set it true again a second after my main form is re-activated.
|
|
|
|
|
Overriding ScrollToControl() in my custom UserControl as above almost worked for me. It did prevent the scroll from moving when my UserControl regained focus. But, the scroll would still move unexpectedly when I did something else, such as changing the location of a child of the UserControl.
However, returning the AutoScrollPosition, instead of the DisplayRectangle's location, does work for me.
<br />
protected override Point ScrollToControl( Control c )<br />
{<br />
return AutoScrollPosition;<br />
}<br />
I got the clue from http://yue-gao.blogspot.com/2009/02/c-want-scroll-to-stay-still.html
|
|
|
|
|
What is the best way create new tables in an access Database?
I am building the connection string to the database in my program as the database could be located anywhere on the computer.
I need to be able to create primary keys and setup relations between the tables that are created.
Is it possible to use a dataset to lay out the tables and then write it to the database? Since i am creating the database connection in the program I don't see a way to build the table adapter.
if anyone has good links to tutorials on datasets that would be great aslo
Thanks!
|
|
|
|