Ciao a tutti, un'iniziativa interessante per chi vuol muovere i primi passi con Android.
Se siete interessati ecco il link: http://goo.gl/SDV354
During my day to day work, I frequently find useful information, from various blogs spread all over the Internet. In order to avoid others repeating my same researches, I decided to share my findings in this blog, with no claiming to be exhaustive nor teaching anything to anyone. These postings are provided 'AS IS' with no warranties, and confer no rights. The views expressed on this weblog are mine alone.
venerdì 7 febbraio 2014
giovedì 30 gennaio 2014
Community Days 2014
Organized by Italian community and user group devoted to Microsoft products and technologies, to offer study days in the form of technical conferences.
martedì 14 gennaio 2014
Calling a WCF service through a proxy server.
C# .NET
Framework 4.0
I have an
application client that calls a WCF service and in this client uses a proxy for
the internet connection, so when I call my service I must first provide the
proxy authentication.
I have
created a class that implements the IWebProxy interface:
namespace Utililty {
public class ProxyConfig : IWebProxy {
public ICredentials Credentials {
get
{
using (var context = new AOEntities())
{
var query =
from data in context.ConnectionParameters
where data.ServerName.Equals("Proxy")
select data;
if (query.Any())
{
var parameters =
query.FirstOrDefault();
if (parameters != null) return new NetworkCredential(parameters.UserName,
parameters.Password);
}
return null;
}
}
set { }
}
public Uri GetProxy(Uri destination) {
return WebRequest.GetSystemWebProxy().GetProxy(destination);
}
public bool IsBypassed(Uri host) {
return WebRequest.GetSystemWebProxy().IsBypassed(host);
}
}
}
In this example,
I retrieve the credentials from a SQL Server database, but if you prefer you
can put in the application configuration file.
Then in the
application configuration file (app.config), I have added this section:
<system.net>
<defaultProxy>
<module type=" Utililty.ProxyConfig, Utililty"/>
</defaultProxy>
</system.net>
and the attribute useDefaultWebProxy="true" at the WCF binding configuration.
The ProxyConfig
object will have call automatically before your call to service.
Peace & Love!
martedì 17 dicembre 2013
Merge several TIFF images to single multipage TIFF
C# .NET
Framework 4.0
In my application,
I have wanted to merge and compress several TIFF images to single multipage
TIFF, for this purpose I used the framework Bitmap object with EncoderParameters like
explained in this link http://stackoverflow.com/questions/3478292/whats-the-recommended-tiff-compression-for-color-photos/3480411#3480411
. Unfortunately, this solution was very slow! 3’:20’’ for merging of 1420
images.
So I searched
in the web and I found this awesome solution http://bitmiracle.com/libtiff/help/merge-several-tiff-images-to-single-multipage-tiff.aspx : the time for merging images
has dropped to 26’’!
That’s miracle!
giovedì 28 novembre 2013
WPF (MVVM) - Retrieve the Listbox SelectedItems property
C# .NET
Framework 4.0 MVVM Light Toolkit
In my WPF (MVVM)
application, I want to use the Listbox SelectedItems property but this property
has no setter and for this reason it’s not “bindable“ to my view model.
I have
tried to use the property (IsSelected) in my object and in the XAML this item
container style.
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter
Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
</Style>
</ListBox.ItemContainerStyle>
This solution
works fine if the Listbox SelectionMode property is set to Single but if the
selection mode is “Extended” (SelectionMode="Extended") it doesn’t work correctly,
sometimes a few items remain selected.
Finally, I
found a solution that works for me. I use the MenuItem’s CommandParameter for accessing
to the Listbox SelectedItems property.
Like this.
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem
Command="{Binding
AddImagesSelectedCommand}" CommandParameter="{Binding
PlacementTarget.SelectedItems,
RelativeSource={RelativeSource
AncestorType={x:Type
ContextMenu}}}" Header="{Binding Source={StaticResource
CustomResources}, Path=LocalizedStrings.mnuAddImagesSelected}"
/>
</ContextMenu>
</ListBox.ContextMenu>
Then in the view model:
AddImagesSelectedCommand
= new RelayCommand<object>(OnAddImagesSelected,
CanAddImagesSelected);
private void
OnAddImagesSelected(object param)
{
var
selectedImages = ((IEnumerable)param).Cast<CaptureImage>().ToList();
//To do
something …
}
private bool
CanAddImagesSelected(object param)
{
if
(param != null)
{
var
selectedImages = ((IEnumerable) param).Cast<CaptureImage>().ToList();
return (selectedImages != null && selectedImages.Count
> 0);
}
return false;
}
We must use the PlacementTarget object because
the ContextMenu is not in the same part of the Visual Tree, so that
is why you cannot use ElementName etc. to reference the ListBox.
See you soon for the next trick!
lunedì 11 novembre 2013
WPF - Zoom an image with the slider control.
C# .NET
Framework 4.0
In a WPF (XAML) view I want to zoom an image using a slider control and also in this occasion
the binding help me to do this with a few code rows.
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
</Grid.RowDefinitions>
<Image Grid.Row="0" Name="ImgReader" Source="Images/Exit.png" Stretch="Uniform" RenderTransformOrigin="0.5, 0.5" >
<Image.RenderTransform>
<ScaleTransform ScaleX="{Binding ElementName=SliderDocument, Path=Value}" ScaleY="{Binding ElementName=SliderDocument, Path=Value}"/>
</Image.RenderTransform>
</Image>
<Slider Grid.Row="1" Name="SliderDocument" VerticalAlignment="Center" Minimum="0.1" Maximum="1" />
</Grid>
It’s great!
Strange error: 'DockingManager' does not exist in XML namespace ...' - Unblock DLL
C# .NET Framework 4.0
I have had a strange error in my WPF application when I referenced an external library (Xceed.Wpf.AvalonDock.dll).
This error
Error The tag 'DockingManager' does not exist in XML namespace 'http://avalondock.codeplex.com'. Line 41 Position 10.
appeared at design time but not at run-time, so after a few hours I’ve founded that this was a “security error”, because Windows protects you from components downloaded from the Internet.
After that I clicked on “Unblock” and the error is missed.
Thanks Microsoft … :-|
I have had a strange error in my WPF application when I referenced an external library (Xceed.Wpf.AvalonDock.dll).
This error
Error The tag 'DockingManager' does not exist in XML namespace 'http://avalondock.codeplex.com'. Line 41 Position 10.
appeared at design time but not at run-time, so after a few hours I’ve founded that this was a “security error”, because Windows protects you from components downloaded from the Internet.
After that I clicked on “Unblock” and the error is missed.
Thanks Microsoft … :-|
Iscriviti a:
Post (Atom)

