How can I efficiently and effectively detect the version and, for that matter, any available information about the instance of Silverlight currently running on the browser?
The Silverlight control only has an IsVersionSupported function, which returns true / false when you give it a version number, e.g.:
if(slPlugin.isVersionSupported("2.0")) {
alert("I haz some flavour of Silverlight 2");
You can be as specific as you want when checking the build, since the version string can include all of the following:
major - the major number
minor - the minor number
build - the build number
revision - the revision number
So we can check for a specific build number as follows:
if(slPlugin.isVersionSupported("2.0.30523")) {
alert("I haz Silverlight 2.0.30523, but could be any revision.");
Silverlight 1.0 Beta included a control.settings.version property, which was replaced with the isVersionSupported() method. The idea is that you shouldn't be programming against specific versions of Silverlight. Rather, you should be checking if the client has at least verion 1.0, or 2.0, etc.
That being said, you can get the Silverlight version number in Firefox by checking the Silverlight plugin description:
alert(navigator.plugins["Silverlight Plug-In"].description);
Shows '2.0.30523.8' on my computer.
Note that it is possible to brute force it by iterating through all released version numbers. Presumably that's what BrowserHawk does - they'll report which version of Silverlight the client has installed.
I got this from http://forums.asp.net/p/1135746/1997617.aspx#1997617 which is the same link Stu gave you. I just included the code snippet.
Silverlight.isInstalled = function(d)
{
var c = false, a = null;
try
{
var b = null;
if(Silverlight.ua.Browser == "MSIE")
b = new ActiveXObject("AgControl.AgControl");
else
if(navigator.plugins["Silverlight Plug-In"])
{
a = document.createElement("div");
document.body.appendChild(a);
a.innerHTML = '<embed type="application/x-silverlight" />';
b = a.childNodes[0]
}
if(b.IsVersionSupported(d))
c = true;
b = null;
Silverlight.available = true
}
catch(e)
{
c=false
}
if(a)
document.body.removeChild(a);
return c
};
found this site that detects the full version of silverlight- silverlight version (aka silverlightversion.com)
As mentioned in the above comments there is currently no efficient direct way to get the installed Silverlight version number (that works cross browser platform).
I wrote a post on how to workaround this problem and detect the Silverlight major version number (including version 3) programmatically and more efficiently using JavaScript.
You can find the code and the post at:
http://www.apijunkie.com/APIJunkie/blog/post/2009/04/How-to-programmatically-detect-Silverlight-version.aspx
Good luck!
Environment.Version will do what you want! Supported since Silverlight 2.0
Look in silverlight.js:
http://forums.asp.net/p/1135746/1997617.aspx#1997617
Related
The problem shows on all Win8 systems, all brands, all types of desktop, laptop, all-in-one, and tablets (tested on nearly every system at BestBuy which there's a ton of them so I can't be the first person to see this.)
What is happening is shown in below image (note captions below each surface), where the rendering on Win8 is brighter than Win7 for native code and WinForm which is based off a windowed ID3D11Device/Context; and to make things worse; the rendering is darker via WPF and WPFs shared surface/texture features though using similar device/context. The actual rendering loop and shaders are identical. Win7/Vista render the same/ideal brightness via native type render target or WPF shared surface.
The DirectX 11 code was developed on Win7. It's very basic DX stuff and the shader is as simple a shader as possible; very similar to the most basic DirectX SDK examples.
Why is DX11 Win8 brightness not consistent with Win7? Gradients seem different too.
Why would Win8 WPF shared surface/texture create even more difference?
What is the best strategy to solve such rendering brightness differences?
I did end up answering, but welcome improvements or expand with related answers to brightness/lighting problems between win7 and win8 as searching the net for such topic shows little results.
After much work between me and MS, (MS wanted a repro without using DXUT even though I told them PNTriangles11 caused the issue and it was a wild goose chase.) I found it was related to EnumOutputs failing on Win8 (MS still to provide an official reason, I will update) and DXUT portions that call EnumOutputs fail resulting in the problematic section of code DXUTApplyDefaultDeviceSettings(DXUTDeviceSettings *modifySettings)
where...
modifySettings->d3d11.sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
should be changed to...
modifySettings->d3d11.sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
which resolves the issue and color is consistent between Win7 and Win8. MS pointed this out. Though I'd like to know why EnumOutputs is failing on Win8 and MS is likely the only one possible to answer this. EnumOutputs failed on every Win8 system at BestBuy, all types of systems.
As for another DXUT modification needed for Win8 compatibility, within DXUTChangeDevice, adding a test for nonzero hAdapterMonitor is likely wanted...
bool bNeedToResize = false;
if(hAdapterMonitor && DXUTGetIsWindowedFromDS( pNewDeviceSettings ) && !bKeepCurrentWindowSize )
{
UINT nClientWidth;
UINT nClientHeight;
if( ::IsIconic( DXUTGetHWNDDeviceWindowed() ) )
For completeness as relates to topic title, gamma correction information can be found at directx gamma correction and new windows 8 brightness control features for integrated displays win8 brightness control
I'm currently testing my C++,DX10 program (based on DXUT June 2010) on Windows 8,
And I'm having the same problems.
Here are additional changes/advice that I advice to do on DXUT:
1) do NOT use the arguments /width, /height, /windowed, /fullscreen in the strExtraCommandLineParams of DXUTInit
2) in DXUTGetMonitorInfo, s_pFnGetMonitorInfo( hMonitor, lpMonitorInfo ); returns FAIL on my system.
So I have replaced this line by something like:
BOOL success = s_pFnGetMonitorInfo( hMonitor, lpMonitorInfo );
//try to return the less wrong result
if ( !success )
{
RECT rcWork;
if ( lpMonitorInfo &&
( lpMonitorInfo->cbSize >= sizeof( MONITORINFO ) ) &&
SystemParametersInfoA( SPI_GETWORKAREA, 0, &rcWork, 0 )
)
{
lpMonitorInfo->rcMonitor.left = 0;
lpMonitorInfo->rcMonitor.top = 0;
lpMonitorInfo->rcMonitor.right = GetSystemMetrics( SM_CXSCREEN );
lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics( SM_CYSCREEN );
lpMonitorInfo->rcWork = rcWork;
lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
return TRUE;
}
return FALSE;
}
else
{
return TRUE;
}
3) Concerning the brightness (gamma correction),
if have added:
if ( BackBufferFormat == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB )
{
return false;
}
in my callback IsD3D10DeviceAcceptable, so I ban every gamma correction device.
And now everything seems to work
(BTW, I'm not sure to understand your "hAdapterMonitor &&" modification, because it doesn't use directly this pointer, but maybe we don't have the same DXUT version )
How can Neo4j embedded be used from either Java or Scala version of Play framework? I'm having trouble finding any information on that.
I wrote AnormCypher for REST, based on Play's Anorm. I'm actually planning on adding some embedded support in 0.4.
However, Fynn came out with ACE (AnormCypherEmbedded), which I haven't tried--but it looks like it might fit your bill:
http://fynnfeldpausch.github.com/ace/
You can also use the neo libraries directly via their Java API (or via SpringData).
I got Neo4j version v1.9.M05 to work (on Windows) by including in Build.scala
val appDependencies = Seq(
...
"org.neo4j.app" % "neo4j-server" % "1.9.M05" classifier "static-web" classifier "",
"ch.qos.logback" % "logback-core" % "1.0.3" force(),
"ch.qos.logback" % "logback-classic" % "1.0.3" force()
There's a thread about having to use older logbacks (otherwise causes some exception) - Play 2.1 and Neo4J WrappingNeoServer errors with Logback.xml
Details on the milestone build is here -http://docs.neo4j.org/chunked/milestone/server-embedded.html. I haven't tried for the stable release, but the documentation is similar - http://docs.neo4j.org/chunked/stable/server-embedded.html
E.g. test if it works
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);
// get all the nodes
Iterable<Node> nodes = GlobalGraphOperations.at(graphDb).getAllNodes();
I have a application previously developed in Visual Studio Express 2010. It uses localized winforms and resx resources used in code.
When the project is opened and compiled using Visual Studio Express 2012 on the same computer the localized strings are not applied, only the default code was found.
The application runs fine and in the winforms designer I can change language to see and edit the localized text of the controls.
I also tried the following code to determine if the languages used were there at runtime, which did report the ones used.
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
foreach (CultureInfo culture in cultures)
{
try
{
ResourceSet rs = resources.GetResourceSet(culture, true, false);
// or ResourceSet rs = rm.GetResourceSet(new CultureInfo(culture.TwoLetterISOLanguageName), true, false);
if (rs == null)
continue;
string isSupported = (rs == null) ? " is not supported" : " is supported";
Console.WriteLine(culture + isSupported);
}
catch (Exception)
{
Console.WriteLine(culture + " is not available on the machine or is an invalid culture identifier.");
}
}
Still when the application is running all I get is the resources for the default language.
I retrieve the resources using:
ResourceManager resources = new ResourceManager(form.GetType());
form.Text = resources.GetString("$this.Text", lang);
where I have verified that lang is correct, but also using
System.Threading.Thread.CurrentThread.CurrentUICulture = lang;
System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang.Name);
followed by usage of MyLangResxFile.MyStringResource.
The strings returned are still only the default ones.
Might there be changes or limitations in resx localization support between Visual Studio Express 2010 - 2012?
Update:
I noticed that the localisation works if compiled using msbuild.exe from 3.5 but when using 4.0... the localisations are missing as described above.
sorry for "answering" that question but commenting is not working.
I just want to ask if you could solve that issue in the meantime because I have exactly the same issue.
I even noticed that this issue only happens when target framework < 4.0 is selected. For target framework 4.0 and 4.5 localization is working as before in VS 2010...
I have a Silverlight app that I hand off to the IT people you are supposed to publish it. This does not always happen correctly, they might forget, put in the wrong loc, or get the wrong version.
So I want to add something to the app itself to easily tell the latest version. This is for SL 3 and 4 so context menu probably not an option. I don't think the users would want a splash screen so that also probably not a choice.
Has anyone done this? Is there a clean, unobtrusive way of doing this?
If you have done this do you just use the assembly version or do use some custom value?
thanks
Here is code to check the assembly version of a running application:
string GetAssemblyVersion()
{
var assemblyName = new AssemblyName(Application.Current.GetType().Assembly.FullName);
if (assemblyName == null)
{
return string.Empty;
}
Version v = assemblyName.Version;
if (v == null)
{
return string.Empty;
}
return v.ToString();
}
I'm developing an application in C# (Windows Forms), which uses Mono to run on Mac OS X.
It contains some dynamic controls, for example a custom groupbox which contains some labels and textboxes, a button, etc.These boxes can both be added and removed dynamically.
My CustomGrpBx inherits from GroupBox and this is the contructor I use:
public CustomGrpBx(Point CreateHere,Info Inf)
{
this.Name = Inf.Name;
this.Location = CreateHere;
CreateHere.Y = 10;
CreateHere.X = 10;
CreateHere.Y += 7;
Button btnPress = new Button();
btnPress.Location = CreateHere;
btnPress.Size = new Size(40, 24);
btnPress.Text = Name;
btnPress.Enabled = false;
this.Controls.Add(btnPress);
CreateHere.X += 45;
CreateHere.Y += 2;
TextBox txtName = new TextBox();
txtName.Location = CreateHere;
txtName.Size = new Size(75, 20);
txtName.Text = Name;
txtName.ReadOnly = true;
this.Controls.Add(txtName);
CreateHere.X += 80;
//More code here, but the same pattern as above
this.Size = new Size(CreateHere.X + 30, CreateHere.Y + 35);
}
The problem arises both when they are created, and removed, or even when a messagebox is shown.
What happens is that sometimes on rendering white boxes appears, or some labels are not drawn correctly. And sometimes when a messagebox appears, it first opens up like 5 dummies which are just blank, and which you can't close.
Am I doing something wrong, should I sleep the GUI thread a bit after each creation, or should I invalidate stuff on my own? Or should I try GTK#?
Many thanks on input on this.
It is hard to advise something without seeing actual code, but first of all, check your assembly with MoMa for incompatibility issues (for example, pinvoke's), if you primarily developed your project targeting .NET platform. Then, mono team claims that windows form support in mono is complete:
Support for Windows Forms 2.0 is complete. At this point, we are largely just fixing bugs and polishing our code.
So, you can try to run your project under .NET and see if the bug persists.
As for Gtk#. I think it is better to use gtk# if a primary OS for your project is OSX. At the very least you will be able to use some OSX-specific stuff, for example, integrate in it's toolbar. Look here for an open-source example of Gtk# project which uses some native OSX features and integrates well in it's environment. There also is a support for gtk# in MonoDevelop's designer.
P.S.
Some interesting Gtk# projects to play with:
Beagle,
Tomboy