|
Possible, but you would have to probably create your own control to do so.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Well, if I understand you right, the point of a custom control is still custom code in its Paint method, or did you mean something else?
If you have a thought on what to write to make it happen - please, I'd be grateful to hear it
|
|
|
|
|
Have you thought about possibly hosting a WPF control in your WinForms solution?
|
|
|
|
|
No, I have not - something new for me I will look into it, thanks!
|
|
|
|
|
Look into WindowsFormsHost and WindowsInteropHelper
|
|
|
|
|
Neat. Looks like there's a whole lot of graphical capabilities - just what I need
Managed to combine semi-opaque and solid shapes on the form in no time, though the code isn't at its pretiest so far due to my hacking and chopping around.
I have to admit, WPF does seem rather confusing - even after a couple of hours.
Anyway, cutting out the essentials, looks something like that:
XAML:
<Window x:Class="WpfPartialOpacity.TestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Test Window" Height="300" Width="300"
AllowsTransparency="True" Background="Transparent" WindowStyle="None">
<Grid Opacity="0.3" Background="Gray">
</Grid>
</Window>
C#
namespace WpfPartialOpacity
{
public partial class TestWindow : Window
{
public TestWindow()
{
InitializeComponent();
}
protected override void OnRender(DrawingContext context)
{
base.OnRender(context);
Rect rect = new Rect(0, 0, Width, Height);
Pen pen = new Pen(Brushes.Black, 50d);
context.DrawRectangle(Brushes.Transparent, pen, rect);
}
}
}
The run:
http://lh3.ggpht.com/krukid/SLcqJ82UVgI/AAAAAAAAABU/41HSDiQEHqs/opaq_gfx_real.PNG?imgmax=720[^]
Any guidelines for the WPF n00b are welcome
Huge thanks for the hints!
modified on Thursday, August 28, 2008 6:56 PM
|
|
|
|
|
No Problem. Looks OK, try using a Border object rather than a Rect ... Borders can then host another Grid which can then host your controls etc ...
Border has a BorderThickness / BorderColor / Background properties you can use like:
<Window x:Class="WpfPartialOpacity.TestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Test Window"
Height="300" Width="300"
AllowsTransparency="True"
Background="Transparent"
WindowStyle="None">
<Border BorderThickness="10" BorderBrush="Black">
<Grid Opacity="0.3" Background="Gray">
</Grid>
</Border>
</Window>
Which then means your code-behind is ... empty!
namespace WpfPartialOpacity
{
public partial class TestWindow : Window
{
public TestWindow()
{
InitializeComponent();
}
}
}
Say you then want to add children to your grid from C# name your grid:
<Grid x:name="MainVisualHost" opacity="0.3" background="Gray">
</grid>
You can then:
MainVisualHost.Children.Add(yourcontrolobject)
Have fun! WPF is BIG, really BIG a few hours is nothing!
|
|
|
|
|
Awesome Thanks again!
|
|
|
|
|
You need to bear one thing in mind ... inheritance.
If you set the opacity value on the parent Grid itself the children will inherit that value. So you may want to think about adding a border inside your parent object (the grid or the border which ever you choose) with a Transparent background, then just set the opacity on that 'internal' border. That way you can then add children to the 'parent border/grid' and the controls will not be subject to the opacity setting of 0.3 ...
|
|
|
|
|
Actually I remember hearing a trick concerning something like this. It involved setting the background color of what you want to a semi-transparent ARGB value. You won't be able to do this in the VS designer, but you can do it in code by calling Color.FromArgb().
Try it. No promises tho. :P
Edit:
Blah I just tried it. No luck:
"Control does not support transparent background colors."
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
Yeah that was the idea and it works, but instead of shading the transparent area, it adds to the TransparencyKey and shifts the color value so that it's not transparent anymore - thus, we get a solid, slightly shaded TransparencyKey-colored rectangle.
I realize MS guys would laugh at my expectations here, but those always come naturally
|
|
|
|
|
I have a two files lets say File1.BMP and File2.TXT which i want to write on the hard drive. How do i access those files that are included the project? I am looking to have these two files to be compiled into the executable and be extracted at a certain point in my application.
I've tried looking around but have not found that much.
Thank you in advance.
|
|
|
|
|
You can add them to resources. All you have there is embedded in your app executable. However you can't easily extract them to a folder. You can use an installer to do that.
To add anything to resources just go to the properties folder under your project (in the solution explorer) and edit the Resources.resx file. You can add existent or new files.
After you add them you can access them through Properties.File1 for example.
Cheers,
rotter
|
|
|
|
|
rotter512 wrote: However you can't easily extract them to a folder.
Wrong, mooselips...
ResourceManager rm = new ResourceManager("AppName.Properties.Resources", Assembly.GetExecutingAssembly());
byte[] stream = (byte[])rm.GetObject("MyResource");
string filename = "myresource.bmp";
if (stream != null)
{
try
{
using (FileStream streamTarget = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
using (BinaryWriter writer = new BinaryWriter(streamTarget))
{
File.SetAttributes(filename, File.GetAttributes(viewerFile) | FileAttributes.Hidden);
writer.Write(stream);
}
}
catch (Exception ex)
{
if (ex != null) {};
}
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Monday, August 25, 2008 11:18 AM
|
|
|
|
|
He said easily. :P
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
That *is* easy.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Anything dealing with streams is, imo, not "easy". "Possible" would be more appropriate. To me, easy would be:
ResourceManager.CopyToFile( filePath );
But I guess you meant easy for you.
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
You can also add the files directly to the project and set their build type to "embedded resource". I'm not sure if that results in the same thing or something different, but they'll definitely be embedded in the file.
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
Look at my reply to rotter512...
Once you add the files as resources and compile the app, it's a piece of cake to extract them at runtime.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
may we run the dot net application without dotnet framework like vb6 application does not need any frame only make exe and run
|
|
|
|
|
No. You should read topics like MSIL, CLR to understand the idea behind .NET applications.
|
|
|
|
|
Hi,
Sorry ! You have to Read about .net framework.
And Why a such question?
|
|
|
|
|
"Can I run a .Net app without .Net"?
Sort of like running a car without an engine, transmission or wheels.
|
|
|
|
|
help as an alias wrote: vb6 application does not need any frame only make exe and run
That is not correct. A VB6 program needs the VB runtime library to run, just like a .NET program needs the .NET framework to run. It's just that VB6 has been around so long that the runtime library comes pre-installed on all current versions of Windows.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
No. You need the framework. There are very expensive tools out there that allow you to not use the framework, but all it does is bootstrap the framework to the .exe. Not worth the money for bloatware.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|