|
daniel radford wrote: Is there a way that I could achieve this?
Maybe this link can help you implement loading on a background thread.
|
|
|
|
|
That looks like just the thing.. thanks!
|
|
|
|
|
I have a silverlight 3.0 application which is a business data editor.
Up until now I've had only a single group accessing the application and that works just fine. I applied group policies to the folder the application lives in.
Now I am about to publish two editors that open the application up to two other groups. Our company is an ISO company and I have to implement security as follows:
MainProgram -- all groups have access
EditorA EditorB EditorC EditorD EditorE EditorF
RW GrpA RW GrpA RW GrpA RW GrpA RW GrpA RW GrpA
R GrpB R GrpB -- GrpB -- GrpB RW GrpB -- GrpB
R GrpC R GrpC -- GrpC -- GrpC -- GrpC RW GrpC
For the editors that group b and c do not have access to, I should be able to limit access within the menu. But does anyone have suggestions as to how I manage the readonly right for the groups in the other editors?
Thanks,
Michael
|
|
|
|
|
You will need to implement your own logic for this - AFAIK, there is no extra support in Silverlight to implement such permissions.
|
|
|
|
|
I intended to implement my own logic.
I guess I was looking for more guidance on that.
For example, how does the menu get the group the user is in?
|
|
|
|
|
LongRangeShooter wrote: I intended to implement my own logic.
One way could be to load all your permissions (to groups etc - via a web service) during logon and then display only those groups that you have access to in your menu.
|
|
|
|
|
I was running through some code today and noticed that this.Resources (resources defined in resource dictionaries, like styles and such) was EMPTY. Of course, any style I tried to load came back as null. What could I have done to cause this?
MY-FACE-IS-RED SOLUTION
=======================
I was using this.Resources instead of Application.Current.Resources .
.45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
modified on Tuesday, May 4, 2010 1:49 PM
|
|
|
|
|
John Simmons / outlaw programmer wrote: What could I have done to cause this?
Can I buy a first clue? I have none...
|
|
|
|
|
You're not the one that needs a clue. It's me. See OP...
.45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
|
|
|
|
|
In a regular WinForms app, it would be: change the Build Action from "None" to "Embedded Resource". Don't know how Silverlight would affect this though.
See, talking about it sometimes helps...
|
|
|
|
|
Did you use a resource dictionary to store your resources? Or did you use App.xaml?
Check either one to ensure your styles are still there...
|
|
|
|
|
The files are okay. It was a PIBKAC. See solution posted in OP.
.45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
|
|
|
|
|
Hi Gurus,
I have an Image object in my main window XAML file. I need to associate an icon/image to this Image as per the user selection.
<Image x:Name="AssociatedIcon" Margin="2,2,2,2" Width="32" Height="32" Grid.Column="1" Grid.ColumnSpan="1" Source="{Binding Path=AppIcon}"/>
AppIcon is the Image object that i have defined in the class and this changes as per user. For e.f: if I select notepad, then the notepad's icon will be stored in this AppIcon object. However my main problem is that the icon is not getting displayed in the 'Image' object.
How do I overcome this issue?
Thanks in advance for your time and help.
Sunil
|
|
|
|
|
Source does not accept Icon and Bitmap object, you have to convert it into BitmapImage.
The code below is a converter to convert Bitmap to BitmapImage, the code below can convert Bitmap to propert BitmapImage.
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);
public static BitmapSource loadBitmap(Bitmap source)
{
try
{
IntPtr hBitmap = source.GetHbitmap();
try
{
return Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
}
finally
{
DeleteObject(hBitmap);
}
}
catch
{
return new BitmapImage();
}
}
Regards
Joseph Leung
|
|
|
|
|
Thanks Joseph.
Well this is what I have implemented. Can you tell me whether this code will also lead to memory leaks.
Icon icon = Icon.ExtractAssociatedIcon(appPath);
if (null != icon)
{
BitmapImage bi = new BitmapImage();
MemoryStream stream = new MemoryStream();
Bitmap bmp = icon.ToBitmap();
bi.BeginInit();
bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
stream.Seek(0, SeekOrigin.Begin);
bi.StreamSource = stream;
bi.EndInit();
MyObject app = new MyObject();
app.AppIcon = bi;
}
Sunil
|
|
|
|
|
Greetings, I am not sure about Icon, but I used your code and loaded a png without problem.
BitmapImage bi = new BitmapImage();
MemoryStream stream = new MemoryStream();
Bitmap bmp = new Bitmap(@"C:\Temp\Test.png");
bi.BeginInit();
bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
stream.Seek(0, SeekOrigin.Begin);
bi.StreamSource = stream;
bi.EndInit();
AppIcon = bi;
Check if it's the problem for loading Icon (try load a bmp or png).
I suggest the loading code should be placed in MyObject, your BitmapImage may be created by different thread as MyObject.
Regards
Joseph Leung
|
|
|
|
|
Thanks for your inputs.
The code that I pasted works. There are no issues .
I wanted to know if there could be possible memory leaks with my code....
Sunil
|
|
|
|
|
Greetings
Sorry I assumed your code has error in it
as Abhinav S said, there are no leaks, if you checked Bitmap.GetHbitmap() in MSDN you can find more information about the leak.
Thanks for posting your code, I just learnt that I can set SourceStream in BitmapImage directly, but I believe my code use less memory and faster however (Bitmap vs Bitmap + MemoryStream).
Regards
Joseph Leung
|
|
|
|
|
|
sunilkpv wrote: Well this is what I have implemented. Can you tell me whether this code will also lead to memory leaks.
I dont think so - I dont see any calls to unmanaged code in there.
However, it is always good practise to wrap a MemoryStream object within a using statement (as shown here).
|
|
|
|
|
I am trying to put several images dynamically onto a canvas. The images are of bigger size (e.g. 9 MB on disc, 200 MB of physical memory when decoded, resolution of 10200 x 7019, 600DPI).
If I add 2 images, everything is working fine. If I try to add another image, the Image is there on the canvas (meaning it reacts on mouse events) but it is not rendered - meaning it is invisible. I have about 1 GB of free physical memory available. When 2 images are loaded I still have 600 MB of free physical memory - but I cant load any more images. I tried to set the images' DecodeBitmapWith/Height attributes to have a smaller rendersize, but images are rendered black or look weird. Image.Rendersize attribute doesnt work in this context.
I have tried combining 3 big sized images with IrfanView -> same problem. Adobe Photoshop on the other side can handle all 3 Images and display them though PS also consumes nearly 700 MB of phys. memory.
I assume it has something to do with memory management. For better understanding here is my code:
ofd = new OpenFileDialog();
if ((bool)ofd.ShowDialog(this))
{
string[] images = ofd.FileNames;
foreach (string image in images)
{
Uri imgsource = new Uri(image);
BitmapImage bim = new BitmapImage();
bim.BeginInit();
bim.DecodePixelHeight = 10200;
bim.CacheOption = BitmapCacheOption.OnLoad;
bim.UriSource = imgsource;
bim.EndInit();
Image img = new Image();
img.Source = bim
canvas1.Children.Add(img);
img.AllowDrop = true;
Canvas.SetLeft(img, (canvas1.Children.Count)* 20);
Canvas.SetTop(img, (canvas1.Children.Count) * 20);
}
I hope anyone can help me with this.
Thanks in advance and best regards
Nick
|
|
|
|
|
Im guessing you are hitting the memory limit of the GPU. You might want to try TransformedBitmap and scale it that way, I quickly tested this with BitmapCacheOption.None and it seemed to only take up memory for the scaled image. As for the images looking wierd it may be due to a bug in WIC you may need get an updated version. Try Vista SP2 and the Platform Update For Windows Vista
modified on Wednesday, May 5, 2010 3:00 PM
|
|
|
|
|
Thank you very much for your input.
I was also thinking about only having a scaled image in memory and discarding the original sized one. But this would require a lot of additional calculation. What I am trying to do is implementing an application that is capable of combining single images into one image. E.g. an architect's plan (ANSI C) is scanned in into 3 ANSI B paper sized images. Those images are now loaded into my app, repositioned and then combined. The result should be the original plan with respect to its original size, DPI etc.
I was hoping there is another soluion, since Adobe Photoshop is capable of holding all 3 images in memory keeping the original sizes.
But I am starting working on algorithms that will work on scaled images.
best Regards
Dominik
|
|
|
|
|
Good day,
I am developing a system and I have been faced with a situation where I need to store all my forms into a database and all the controls so that at user registration one configures what should be displayed.
Could someone point me to a tutorial or sample code that can hint on this..
Thank you.
Give the world the best you have, And the best will come your Way
|
|
|
|
|
This is a relatively complicated task. Let's ignore the retrieval of the data from the database, the main issue you will face is hooking events up. This post[^] by Rob Relyea contains a lot of information that you will need.
"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
|
|
|
|