Visual Studio for Mac System.Windows.Input reference - c#

I am trying to detect what key is pressed by a user, normally I can use the 'System.Windows.Input' reference, however when I try to reference it, there is no library for it.
Is there something that I am missing or is this just not supported on the Mac version of Visual Studio?
Thanks
Alex

You're right that is not possible (and isn't even logical to be possible).
Visual Studio for Mac is not for developing software for Windows at all and nearly nothing in namespace 'Windows' is available. As I said it shouldn't be even expected - for example in your case keyboards for Windows and Mac are just not 100% same, so even some key enumerations would be purely impossible to port.
Depending on the project type that you use (Mac app, iOS app, Android app, Xamarin forms app) you must find alternative APIs.
No one has ever made one user interface kit to work on another. They are just different. There can be only meta interface like Xamarin forms that brings only common things available everywhere so that they can be translated into every native user interface.

Actually, a big part of System.Windows.Input namespace is located in the WindowsBase.
But it won't help much, since Keyboard class that you're looking for is inside the PresentationCore assembly, which is a part of WPF, that isn't (and, I guess, never will be) supported on Mono.
The only viable (-ish) way to get it is to build from the sources a part of Mono that's never made it to release.
You can use System.Windows.Forms, though.

Related

Getting started with C# on OS X

I'd like to create a few simple C# applications and command line utilities to learn more about C#, affordably. Initially, I tried using Microsoft's free Studio Express in a Windows 8 virtual machine; however, it quickly reported that it could only create apps for the Microsoft app store and failed to build the simplest examples of an XML file transformer.
I also found Mono or rather MonoDevelop. I'm still reading about it. It seems that the SDK is entangled with the MonoDevelop IDE, and the MonoDevelop installer is actually the Xamarin Studio installer. Xamarin is a subscription based IDE and inexpensive versions of it appear to be constrained. Perhaps I need to continue studying; however, I thought I'd ask if anyone has experience getting started with C# on OS X.
Ideally, I'd like the simplest setup. I prefer using command line compilers, simple code editors, and build scripts. Are there Windows and OS X command line compilers for C# applications? Are there framework libraries that can easily be included that work on both OS X and Windows?
First, Mono is not an SDK, but a runtime. The specific point of Mono is to be able to, for the most part, run the same IL on other platforms as what runs on .NET for Windows. This means that, barring the slight hiccups in implementation, you could copy a program, run it via "mono program.exe" (via the console) on OS X, and get the same output (I have tested this with Console applications, at least - UI starts to get a little hairier).
In terms of library, the Mono libraries try to mirror the .NET ones so exactly, that the code you write for one is almost completely compatible with the other.
"MonoDevelop" and "Xamarin Studio" are the same thing, simply having applied a name change after a certain version. They are the most well known tools for building in the .NET language family on a non-Windows system (the only tools I even know of), and tend to mirror the shortcuts of Visual Studio well (at least on windows.) Unlike Mono itself, these are an IDE, and do not constrain you any more than VS constrains you into .NET.
The constraints you'll find with free Xamarin apply mostly to their mobile platforms (iOS, Android) and do not affect working with desktop (ie Windows and OS X) applications.
I've settled on using a Windows 8 virtual machine and Visual Studio Express for Windows Desktop as Dan J recommended. For usage similar to mine, simple desktop and command line apps, be careful not to select and install the "V.S.E. for Windows" version.

Can I use xcode to program in c#?

I develop almost entirely in c#, but own a mac computer. I have windows running in parallels desktop to work with Visual Studio. I wanted to develop in c# for mac os and downloaded monodevelop, which is great except for its GUI designer I completely hate it and don't know how people can even use it. I mean, after how easy it was to create GUI applications with the Visual Studio designer I feel so weird to work with it.
I investigated about it and found out that apple's interface builder could solve that problem for me. However, the only way to get it now apparently is downloading xcode, since apple doesn't distribute it as a stand-alone app now. (That's what I think)
I knew that Xcode doesn't support c#, but I read about some plugins with which you can add those functionalities.
Can you tell me if its possible to add this compatibility to xcode? Or if you know alternatives to monodevelop that have a GUI designer that is more similar to VS.
As of version 2.8, MonoDevelop support using XCode with both MonoTouch (for iOS) and MonoMac. Here is the link to the release documentation.
Yes, you have to download XCode and, if I recall correctly, there may be a nominal charge for it, but the minimal cost (if any) will be worth the improved productivity.
Having said that, using XCode's interface builder takes a LOT of getting used to for someone coming from the VS world.

Cross platform development, GUI and Database - c#

Forgive me for asking a common question, but I couldn't quite get what I needed from what I found so far.
First question - SQLite. I am using this DB as in my C#.NET 3.5 windows service and it works great, I was looking for a portable solution, because I would like port my service to a linux daemon etc, using Mono, which seems to support it. However, I am not sure how to implement this. I had thought the dll was compatable, but it seems there is a seperate dll for Mono/.NET which I should have expected. Does this mean I need to seperately code/compile for each platform or is there something that would allow me use of SQLite with the same code on various platforms? I have encountered this a few times in my searches, csharp sqlite, a "reimplementation". To be honest, this is quite new to me, is it of use? The Mono SQlite page says that they Mono.Data.Sqlite code is based on System.Data.SQlite and goes on to say...
"We have chosen this way as means to
provide a migration path for
developers using SQLite in their .NET
applications"
Are they referring to creating a new, seperate binary? Or could I run my code as is with some adaptation?
Second question - GUI. As far as I can tell the two main options for cross platform dev in .NET would be GTK# and Winforms. Again however, its the specifics of implementation that are a bit hazey. Can I create a win forms GUI in visual studio as I normally would then easily migrate this using mono? Or should I develop this in something like X-Develop or MonoDevelop?
Many thanks for your advice/patience :D
To help out a little bit here I used the full mysql dll file that was provided and I was able to compile my program on windows using visual studio, and then deploy it to Linux without changing anything(except the case of the mysql dll file, which is kind of annoying you'll see what I mean at some point).
Also from what I've heard winforms isn't totally supported by mono yet, but I may be wrong. I haven't done a gui cross platform yet, but I would test winforms first, just so you could develop it in visual studio, and if that doesn't work I think GTK should be fine.
You just need to make sure that the dll's are compiled for .net 3.5 or below and you should be fine(90% of the time).
Check this out here, http://www.mono-project.com/MoMA and also the link that chris provided.

Develop smart applications for Windows 7

I'm looking to create a very -tiny- application(s) in Windows 7. I'm looking for a programming language like C# and a simple framework that
Makes the application very light weight
Doesn't require any libraries or modules (only the *.exe and works on a newly installed Win7)
The IDE (Or the compiler) let me easily implement windows 7 features (like the menu, the graphics...)
The point: I want to create a small application (light weight so it can be easily transported), that focus mainly on Windows 7 graphic design and features.
I don't know if such IDE exists but also asking how will you solve it, mean if you have to create a tiny application (gadget like) how will you proceed?
Lightweight and regarding dependencies: Well, since you want kind of C#, you have the .NET Framework. That's not exactly lightweight, unless you're sure that the target system has it available. Be sure to check which .NET version comes preinstalled with Seven. Addendum: Now that 7 is out, it seems it comes preinstalled with .NET 3.5 SP1 (full framework, not client profile). That's a good thing.
Have a look at the Windows API Code Pack for Windows 7 for access to Windows 7 features. Like tvanfosson, I'd also stick with Visual Studio and .NET.
Personally, I'd stick with Visual Studio. You might want to get a utility like NuGenUnify, which makes it easy to use ILMerge to combine any extra libraries into the main exe if you want to distribute as a single file.
So far I haven't seen any other IDE that beats Visual Studio for windows app development. Especially soon after a Windows release. I'd be surprised if I am proved to be wrong.

Using Mono on Windows

I know it sounds stupid but:
I've found this application written on Mono and it is open source.
While peeking at the source code I've found this two "using" directive that stoped me:
using Gdk;
using Mono.Unix;
I guess they're Mono specific libraries.
So, it is possible to run Mono under Windows? ( perhaps Visual Studio express edition ? )
I'm trying to learn C#
I see there is a Windows branch of the app, but it is empty.
BTW: Is it Mono thought for cross platform in first place?
EDIT
I've downloaded/installed and run the sample code
using Mono.Unix;
class X { static void Main () { System.Console.Write("OK");} }
And the answer to my own question is:
x.cs(1,12): error CS0234: The type or namespace name `Unix' does not exist
in the namespace `Mono'. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings
No, it doesn't work :(
Mono on windows guide
I am not sure you will be able to use code using the Mono.Unix namespace, but generally if you are creating cross platform code, you shouldn't have to.
Gnome Do linux port. For a learning project however, I might suggest starting with code that is actually cross platform, or develop on Linux for now. Tackling cross platform issues and possibly an incomplete port will just complicate the learning process.
So, I suppose in summary to your initial question. Yes, you can run Mono on Windows, but it is possible to write platform specific code, which the example application you have chosen has indeed done. The link I provided above is a port to make that code work on Windows. Without porting ( changing the platform specific code ), that program will not compile on windows.
Yes, you can install mono under windows. There is an experimental installer.
See: http://mono-project.com/Mono:Windows
That page also has information on the gtk libs.
Of course you can run mono under windows:
http://www.go-mono.com/mono-downloads/download.html
The Gdk is a cross-platform library for low-level windowing system stuff, and the code is using .NET binding to Gdk. It is available for windows (as a part of Gtk# package or in Mono installer).
Mono.Unix is a mono library that provides access to unix services (syscalls, stdlib). I do not think that Mono.Unix is available for windows, but Mono.Posix might be available.

Categories