|
Create a texture brush of your bitmap. Create a path out of the movement of the mouse, and paint that path using the texture brush. The bits of the bitmap that are in the path will be drawn.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I'm missing something here, obviously, here's the test code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
Image scratchimage;
public Form1()
{
InitializeComponent();
scratchimage = Image.FromFile(@"C:\usntps\aircraft\fa-18b.bmp");
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
GraphicsPath graphicsPath = new GraphicsPath();
graphicsPath.AddEllipse(new Rectangle(e.X - 10, e.Y - 10, 20, 20));
pictureBox1.Region = new Region(graphicsPath);
pictureBox1.BackgroundImage = scratchimage;
graphicsPath.Dispose();
}
}
}
}
This will paint a circle of the correct part of the image to the picturebox after I release the mousebutton, but I can only click within that painted portion on subsequent attempts, and only the new image portion is maintained.
|
|
|
|
|
Throw away the picturebox, it's useless for what you want to do. Do what I said to do, create a texturebrush, and then draw with it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks, figured it out:
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
{
TextureBrush myBrush = new TextureBrush(new Bitmap(@"C:\usntps\aircraft\fa-18b.bmp"));
public Form1()
{
InitializeComponent();
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Graphics g = pictureBox1.CreateGraphics();
g.FillEllipse(myBrush, new Rectangle(e.X - 10, e.Y - 10, 20, 20));
}
}
}
}
|
|
|
|
|
How do you make a text box that will let you only format certain words? For example, in Word, you can change the font and size of a certain word. Is there such a Control that will do this? Thanks in advance.
-----
Note: *** Never give me an answer have anything to do with Visual Studio. I don't have this program, and it'll be that way for a long, long time. ***
|
|
|
|
|
The RichTextBox control can do this. There are some articles on this site regarding how to do this, as well as plenty of documentation on MSDN.
|
|
|
|
|
Could anyone tell me how I could get my program to go from this...
Old[^]
to this?
New[^]
Sorry for the links... I don't think you can post actual images onto the forums.
I would like for the toolbar and main menu to resemble those of Office 2003.
-----
Note: *** Never give me an answer have anything to do with Visual Studio. I don't have this program, and it'll be that way for a long, long time. ***
|
|
|
|
|
If you're working with .NET 2.0, the default ToolStrip and MenuStrip controls look like Office 2003.
If you're still using .NET 1.1, taske a look at this[^] for menus; for toolbars, you'll have to find something or write your own custom drawing code.
|
|
|
|
|
I am working with .NET 2.0, and using Application.EnableVisualStyles(); . The first image is the end product.
-----
Note: *** Never give me an answer have anything to do with Visual Studio. I don't have this program, and it'll be that way for a long, long time. ***
|
|
|
|
|
Have you made sure that you're using the ToolStrip and MenuStrip classes instead of the old MenuBar and Toolbar classes, and that their RenderMode properties are set to ToolStripRenderMode.Professional , or are set to ToolStripRenderMode.ManagerRenderMode with the Renderer set to an instance of the ToolStripProfessionalRenderer class?
|
|
|
|
|
The first one is using the System.Windows.Forms.Menu. The second one is using the System.Windows.Forms.MenuStrip.
|
|
|
|
|
Ahh... Thanks!
-----
Note: *** Never give me an answer have anything to do with Visual Studio. I don't have this program, and it'll be that way for a long, long time. ***
|
|
|
|
|
Hi all!
Having some trouble with converting this logic into some nice C# code! can anyone help??
1. Get the "twos complement" of a number (invert, add 1)
2. Get the LSB of that result...
Example with: 1506
1506 = 10111100010
Invert = 01000011101
Add 1 = 01000011110
2*LSB = 00011110
Result = 00011110 (or 1E in hex)
Can anyone point me in the right direction to get these results in C# please!
|
|
|
|
|
int val = 1506;
int result = (~val + 1) & 0X000000FF;
|
|
|
|
|
What would be a good C# programming manner to extract from a 32-bit value the different bytes (MSB to LSB) in big or little endian format?
|
|
|
|
|
Do an && to strip the bits you don't want, and shift them down with >>
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
There is an alternative, that may be interesting when many variables need to
available in both packed and unpacked form.
Using structs you can obtain a "union" effect in C# in the following way:
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Explicit)]
public struct Overlay {
[FieldOffset(0)]public uint u32;
[FieldOffset(0)]public byte u8_0;
[FieldOffset(1)]public byte u8_1;
[FieldOffset(2)]public byte u8_2;
[FieldOffset(3)]public byte u8_3;
}
public override void Run() {
Overlay overlay=new Overlay();
overlay.u32=0x12345678;
log("lo to hi: "+overlay.u8_0.ToString("X2")+" "+overlay.u8_1.ToString("X2")+
" "+overlay.u8_2.ToString("X2")+" "+overlay.u8_3.ToString("X2"));
}
On a little-endian machine (such as Intel x86) the Run method will log
"lo to hi: 78 56 34 12"
Be careful though, you are responsible for the offset values !
-- modified at 11:54 Sunday 4th February, 2007
Luc Pattyn
|
|
|
|
|
I want my program to be able to dock on any side of the screen and have all of the other windows to resize so that my program gets its own space. (Bad example, but kind of like the taskbar)
thanks!
|
|
|
|
|
hi
i want to set focus on specified row in My datagridview, how to do ?
thanks
|
|
|
|
|
Try this:
DatGridView1.CurrentCell = DatGridView1.Rows[RowIndex].Cells[0];
|
|
|
|
|
I'm not asking for a complete program or anything, but if I was going to make an application that would allow people to communicate from different computers via the web (similar to AOL Instant Messenger), how would I go about doing it? Something to get me started would be helpful. Thanks!
-----
Note: *** Never give me an answer have anything to do with Visual Studio. I don't have this program, and it'll be that way for a long, long time. ***
|
|
|
|
|
max29297 wrote: I'm not asking for a complete program or anything, but if I was going to make an application that would allow people to communicate from different computers via the web (similar to AOL Instant Messenger), how would I go about doing it? Something to get me started would be helpful. Thanks!
This article[^] should give you some pointers.
|
|
|
|
|
Thanks a lot!
-----
Note: *** Never give me an answer have anything to do with Visual Studio. I don't have this program, and it'll be that way for a long, long time. ***
|
|
|
|
|
can anyone tell me how wrappers are created. im relatively new to c#. i want to create wrappers to a c++ process code in C#?
|
|
|
|
|
To get from C++ to C#, you probably want to use p/invoke, if the C++ code is in a dll. Another option is to write it in C++/CLI, which .NET can call. Depending on the process and the code involved, a C# rewrite may be an option ( this is usually best, with p/invoke for any calls you need to make to Win32 functions )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|