WindowsImagingComponent or System.Windows.Media.Imaging - windows

I need to work with some bitmaps in managed code and save them as PNG files. Should I use Microsoft.WindowsAPICodePack.DirectX.WindowsImagingComponent, or System.Windows.Media.Imaging? They both seem very similar, and I'm not sure why I would choose one over the other. Can anybody compare and contrast them?

They both use WIC, that's why they are so similar. The Windows API Code pack is retired content, you'll want to use the WPF namespace since it is available on .NET 3 and up and doesn't require a separate install.

Microsoft.WindowsAPICodePack.DirectX.WindowsImagingComponent is in the Windows API Code Pack, which is a source code library that you would need to build into your application. On the other hand, System.Windows.Media.Imaging is included in the .NET Framework.
If you have no other use for the Windows API Code Pack, I would recommend using System.Windows.Media.Imaging. I believe the inclusion of a WIC API in the Windows API Code Pack is primarily for interoperability with the DirectX APIs in the Code Pack, which have no equivalents in the .NET Framework.

Related

Xamarin Cross Platform Development .net

We are developing a cross platform mobile application using Xamarin. I have noticed there are different ways of structuring your code using Shared code or PCL/.net standard.
I attempted to use .net standard and what i have found is that it doesn't include all the libraries such as using ado stuff , datatable/datasets using system.data. Or using system.net for example. Other functions have less overloads and seems that its a stripped version of .net to work across platforms. Is there any way to add this functionality or use a broader range of .net?
You are correct - .Net Standard and .Net Core are stripped down versions of the full .Net framework. They contain only features that can be used on all platforms (Mac, Android, iOS, Linux, Windows, etc.)
The full .Net framework only needs to work on Windows, so there are additional things that you can do based on the fact that there is less complexity in implementing and that the code base is more mature (cross platform is still pretty new by C# standards). To the best of my memory, System.Net should work if you have your references correct, but System.Data will not (or at least direct database access is not possible)
You can regain some functionality through NuGet packages, but it won't be the same as using WinForms or something like that...
My best advice would be to program against an API. You can use a web server that runs on the normal (full) .Net framework, and does all the heavy lifting using all the .Net features that you are accustomed to. Your Xamarin app would send and receive data from the API and basically provide a mobile front end for whatever you are doing. This approach makes sense for most apps anyway, and is generally what you would be doing anyway if you used Swift and Java to create separate iOS and Android apps.

DirectX sample code c++

I'm looking for source code (as I bet a lot of others are / were and will) for learning purposes of DirectX. I would like something similar to the vs2013 Graphics Editor when dealing with *.fbx files, etc. Every thing I find is old and outdated, or way to simple and does not show the basics like transformation cursor, picking objects or points on objects. I'm just looking for something basic.
many thanks in advance
The DirectX Tool Kit is a good place to start and includes some tutorial content as well. It supports loading models using the VS 2013 content pipeline that produces CMOs from FBX files.
You didn't state if you were looking to write a Windows desktop application (aka a Win32 application) or if you were looking to write for Windows Store / Windows phone. DirectX Tool Kit supports either, although the tutorial is written using a Windows desktop application template so that developers using Windows 7 could also utilize it.
You should also refer to the DirectX SDK Samples Catalog for locations of updated versions of the legacy DirectX SDK samples that build fine using VS 2013 only.

manipulation docx for windows phone 7

I want to manipulate docx files in wp7,c#. In windows I always use : http://docx.codeplex.com/ but it can't be added as a reference to a wp7 project.
Is there any control or alternative dll? Or is there any simple documentation about making doxc file? I read msdn documentation and I just got confused!
As far as I know there isn't a library for editing docx files for WP7 / Silverlight. However, the DocX library you link to is only dependant on the ./NET 4.0 framework. As DocX is most likely composed of non-UI code, there is a good chance that if you place the code into a WP7 Silverlight class library, you will be able to compile it.
Independentsoft has set of Office APIs compiled as Portable Class Library. It works on Silverlight, Windows Phone 7/8 and .NET Windows Store Apps.

What languages require no external libraries/references/dependencies?

Have a quick project I need to put together for windows that can have no external references or dependencies; the stalwarts like C are obvious but if you are a .NET developer and need to build something like this very quick what language/tool would you use?
EDIT: Ultimately I want to be able to take JUST the exe produced by the compiler and put it alone on a windows machine and have the app run.
If you're a .net developer, you could consider something like using Remotesoft's Salamander or another similar tool that compiles everything into a single executable (including the framework).
This option lets you develop in .net, but not install the .net framework on your client's systems. If you're deploying on non-MS systems, you can use the Mono's deployment tools to accomplish the same thing for free.
In general, I'd say stick to the tools and languages you know. It's easier to build an installer to install the .net framework then it is to learn a new suite of tools, libraries, etc.
You can do it for practically any language (I'm excluding the obvious C/C++)
You can bundle the .NET runtime into your .exe and write the app in C#
You can write the app in Python and bundle everything into a single .exe using a tool like py2exe. I do this regularly. One can create great-looking and powerful applications with Python and PyQt, bundle everything into a single no-dependencies executable and deploy to users w/o a need to install anything else. The executable is a few MB large (~9 with PyQt), and loads and runs quickly.
Etc.
It's more important which language / environment do you currently know well. Focus on that, because the tools do exist for anything you'd want to use.
Delphi has always been the best product for producing stand-alone .EXEs for Windows. No Microsoft product has ever come near it in that regard.
I think a good allround answer to this is Free Pascal via the Lazarus IDE.
Free Pascal applications are native and dependency-free, and a lot of platforms are supported. Too many to list here! Free Pascal itself is a free and open source compiler.
For better convenience, I strongly recommend using the Lazarus IDE. Now you even get a RAD IDE for cross-platform GUI applications (as well as console), with a sizable set of builtin features, like database support. Really a pretty lovely all-in-one, often underestimated or even unknown, platform that produces self contained, native executables. There aren't all too many of those tools if you think about it. You can even cross-compile from it, for example to compile a GUI application for Linux on Windows, no virtual machines necessary.
One day, I wish .NET Native could get this far, but it is currently far from capable and I'm not sure if Microsoft even intends to go there. Google's Go language is also nice in that it compiles to native cross-platform code, but lacks a GUI library. Python can have its code packaged into executables but it's kind of a kludge and not native code. And so on...
C/C++ would be your language but don't use any fancy libraries like MFC, MSVCRT, etc. or if you do link them statically to your executable.
"No external references" is a bit vague. Are you talking about a deployment solution for an application?
For example, you can use Tcl which supports the ability to create a single file executable that contains both the application code and a virtual filesystem that can contain any other files needed by the application. If your goal is to create a single file that can be deployed without having to install extra files, read up about "starkits" and "starpacks".
If you target a Windows Vista .NET 3.0 is preinstalled,
If you target a Windows 7 .NET 3.5 is preinstalled, if you use no other libraries than the ones included in those distributions then you app will run. Installing .NET isn't really that much work anyway, just ship with the redistributable.
Assembler. Your only dependency is the CPU
Here's a left field answer...
Tcl
combined with starkits, you can create a simple double-clickable .exe with no need for an installer.
the downside, of course, is that it'll be written in tcl.
As an added bonus, you'll be able to port your app trivially to mac or linux (or a range of other odd operating systems)
Do you consider the .NET Framework "external"? If you stick to .NET Framework and use C#, your code should run anywhere the .NET Framework of appropriate version is installed, and you'll only need to deploy your .exe and .exe.config.
It is not possible to run a .NET program without the .NET Framework. If you can't require the .NET Framework to already be installed, then you cannot use a .NET program. That's what I meant.
I've no clue what the downvotes are about, but let me try once more to clarify. The original post said:
the stalwarts like C are obvious but
if you are a .NET developer and need
to build something like this very
quick what language/tool would you
use?
The answer is that if you are a .NET developer, there is no tool or language you can use for this purpose, as every .NET program requires the .NET Framework be installed. If you need a program that is entirely independant, then don't use .NET. As others have replied, you can bundle .NET into your exe. You can also have .NET installed with your application, if you're willing to ship a .MSI file and not just your exe.
But, by definition, a .NET program cannot be independent of the .NET Framework.

C# mono from windows to mac

I wanted to know what i shouldn't do in code that will prevent my C# app from running on mac.
In general you shouldn't use anything from the Microsoft.* namespaces, no PInvoke (DllImport in C#) and UI might be problematic as well.
Further information on Mono compatibility is contained in the Mono Guide Porting Winforms Applications. Existing applications can be checked for compatibility using the Migration Analyzer tool.
UPDATE: PInvoke actually works in Mono, but if you want to have it working cross-platform you must provide a native shared library with the same interface for each platform (i.e. Win API most likely will not work).
Mono's Application Portability guide is a good reference.
In addition to divo's recommendations, I would recommend the Mono Migration Analyzer (MoMA) tool: "The Mono Migration Analyzer (MoMA) tool helps you identify issues you may have when porting your .Net application to Mono"
Also, I would keep an eye on Miguel de Icaza's blog, and the Mono Project website.
In his presentation for the Boston.NET Users Group this month, he showed a preview of a Visual Studio plugin that launches your app on Mono using a VM! This lets you test compatibility during the development process.
I believe their goal was to release it at TechEd 2009, so look for an update over the next month or so.
You will, at the very least, want to try and avoid using Windows Forms, since that is just a paper-thin layer on top of the Windows native UI.
Mono emulates it somewhat with help from WINE, but I wouldn't trust that.
Mono did this a while ago but the effort was abandoned. See WinForms on Mono for more information. Thanks jpobst.
Try using GTK# or Qt# (although I'm not too sure the latter one actually exists) for cross platform support. You might also consider using Java with SWT or even Swing instead of C#, but that will probably not be an option you're willing to consider.
Using anything related to P/Invoke is probably also a bad idea, since that invokes native code which will probably not be portable (unless you write it yourself, then you can choose to make it portable).
I'm not sure if it is possible with mono, but WIN32 API calls will definitly not work ;)

Resources