Programmatically change Font size in .NET Core Console App - c#

I've been searching and searching and I can't seem to find a way to programmatically cross-platform (.NET Core) change the Font size of the .NET Core Console App.
Is this possible at all in .NET Core directly, or do I need to build a .NET Standard library myself that supports all the platforms I need to support with native code?
Thanks in advance!

There is no .NET Core support for this in the framework. Yes - you would have to build your own library to do this. At first blush, this would be non-trivial... In Windows you have both cmd and powershell shells to deal with. On Linux, there are a variety of desktop environments you might have to support to make this truly cross platform.
In the environments I'm aware of, this would have the effect of changing font for all console windows. Is this what you're trying to do?
What is the actual use case for this? Typically, users set their terminal environment up the way they want and leave it. Changing the color of the text is a more trivial endeavor.

Related

How to Install a Driver as Part of a Winforms App

I am currently working on a WinForms app in Visual Studio 2019, which uses a USB to I2C adapter to read EEPROM register values from a device. The manufacturer of the adapter provides the driver for the device in a downloadable zip file on their website which contains the .inf and .sys files among other things. I would like to have it so when the end user installs the app, the driver is automatically installed as well. What is the best way to do this? I have a Setup project in my solution, which I can use to put the driver files in the application folder, but that doesn't mean the driver is actually set up.
I found one potential solution that used System.Configuration.Install, but my targeted framework at the moment is .NET core 3.1, which unlike .NET framework does not have that namespace. I am only expecting users to use Windows 10, so I theoretically could switch to .NET framework for that namespace if necessary. However, I don't know if that will break anything in the app or if that is the easiest way to go about this.
I am very new to deploying apps so I really don't know the best way to go about this. Any direction is appreciated.
There are third-party .net core ways of doing this, such as
Core.System.Configuration.Install
Porting of System.Configuration.Install for .NET Core. (.NET 4.0
version)
Use at your own risk
however, there are also oodles of installers that have this capabilities.
Lastly, this can also be done with powershell, P/invoke and I believe there was talk in github about releasing this source code however you will need to track that down and follow the trail yourself

How can I deploy .NET Framework application on Mac and Windows both? How to Build Cross-Platform(windows and MacOS) .NET Core?

I have Windows version of .NET Framework desktop application. Now I want to make version available for MacOS as well.
Is there any solution available using C#?
Will .NET Core work for both Windows and MacOs?
I have already build application using WinForms C#. I have created exe for window.. Similarly I want to run application on MacOS as well
You can try Mono then. It has (a rather limited) WinForms support. But if you never tested it on any other platforms yet, then be prepared for some issues. Among others:
You will not able to use any WinAPI directly (ie. extern methods to Win32 dlls)
You might expect some behavioral differences. Some of them affect only particular distributions.
Many of these can be handled by special handlings in you code, though. But it means you will need some IsWindowsdistinction here and there, just like in this project of mine.
And do not forget to install libgdiplus, which makes possible to use System.Drawing on non-Windows platforms, as WinForms is built on GDI+.

Net Core 3.0 and desktop applications

I just read that there is possibility to develop Windows Forms using .NET Core 3.0. Unfortunetly designer is still under development and not available. I also read that even if Windows Forms can be done using Core 3.0 that doesn't mean that it can run on either MAC or OS (same with WPF). My question is what is then the sense of it if it cannot be deployed on diffrent systems besides Windows? What type of desktop application can i really develop to be able to deploy on various systems rather than Windows forms?
That's because Microsoft seems to plan to retire the original .net and just focus on developing .netcore. My suggestion is to build application using web technologies. This way you have the best of both worlds either build web application or develop cross platform apps using something like electron.js
there are so many great apps built with electron like Vs Code or Github
There are many use cases for Windows-only desktop applications, particularly in the corporate world where applications are for internal use.
If you need a cross platform application I would suggest either a web application, or you could consider Electron.
AvaloniaUI (A cross platform XAML Framework for .NET Framework, .NET Core and Mono) would be a perfect choice if you are familiar with WPF.
There are many other frameworks to develop cross-platform desktop apps. You can checkout my github repo electron-alternatives for more cross-platform desktop development options.

.net core cross platform desktop app

I'd like to develop a cross platform desktop app by using .net Core. The app needs to be executed on linux, mac os, and windows. For that purpose, should i create a console app and put below lines in settings xml?
<PropertyGroup>
<RuntimeIdentifiers>win10-x64;osx.10.12-x64;debian.8-x64</RuntimeIdentifiers>
</PropertyGroup>
Will it be sufficient? If so, should i write all platforms and separate by comma e.g.
win7-x32;win10-x64;...
If it is not the answer, how can i generate cross platform desktop app with .net Core?
As the other answer alludes to, .NET Core itself is cross-platform, but it doesn't offer any GUI solution. You can run console/terminal applications, as well as web applications, but not desktop applications.
As of right now, there is no official Microsoft tech that solves a multi-platform GUI. The two that I know of are Avalonia and Eto.Forms. Both have their pros and cons, and both are kinda buggy. Not in the sense that it's unusable, but in the sense that it's evolving tech, don't expect them to blow your mind right off the bat.
Guides to get you started :
Avalonia - https://docs.avaloniaui.net/
Eto.Forms - https://dotnetcoretutorials.com/2018/03/19/cross-platform-winforms-kinda/
1) Console apps in .NET core are already cross-platform.
2) For those working with a GUI, .NET core finally has a cross-platform GUI option officially supported by Microsoft called .NET MAUI
This builds on the same APIs as Xamarian Forms.
Official .NET MAUI Github Repo
If I understand your question correctly, it could be devided into two questions.
1) Howto create a cross platform .net core app
2) Howto create a cross platform .net core UI app
To answer the second (2) question: It's not possible to create cross platform apps using only .net core and microsoft libraries. What you need is a cross platform UI library with binding for all of your your target platforms. The first search result I get is Avalonia https://github.com/AvaloniaUI/Avalonia
I doubt it will be an easy task to get it working as all the alternatives seems to be experimental and/or beta. But you can certainly prove me wrong.
Good luck!
You can try electron.js instead . At present its quite difficult to build a cross platform desktop application only with .NET Core
You have many solutions for making a cross platform application with .NET Core:
Electron.NET
Avalonia
...
If you want detailed information about how to do that you should check a dedicated book who provide project samples for .NET Core 3 Here . With that you will find the most adapted UI for your app.

Is it possible to create a Mono bundle that includes WPF libraries?

I know WPF libraries arenĀ“t implemented by mono class library, however(as far as I know) the mono 2.6 runtime is fully compatible with the .NET 2.0/3.5 runtime, so if the WPF libraries only make PInvoke calls to windows api it is theoretically possible to run a wpf application on windows using the mono runtime.
The reason for wanting that is deploying a wpf application as a standalone executable for windows. Has anyone tried something like that before? If so, what were the results?
In short... No
At this point, the Mono project does not have plans to implement Windows Presentation Foundation APIs as part of the project
Mono will provide Moonlight support which, from what I understand, would also use a subset of XAML to create its UI (the same as Silverlight does) but there are legal complications involved. Such as, it's limited to non-microsoft and non-mac platforms.
If you want to find a list of open-source cross-platform alternatives to WPF/XAML I'm working to compile a list of viable alternatives.
Well I did give it a try with little success. I first checked with corflags if required dll-s are implemented in mixed mode (PresentationFramework, PresenationCore, WindowsBase, System.Xaml). They are all pure CIL implementations so that should work fine with mono. Next I installed mentioned DLLs into mono's GAC and tried running a very simple WPF application. This is what I got:
Assertion at mini-codegen.c:1186, condition `reginfo [sreg].born_in
0' not met
This application has requested the Runtime to terminate it in an
unusual way. Please contact the application's support team for more
information.
So although in theory this should all work, WPF is probably way to complex to run out of the box on mono, it would be cool if there was a pure CIL implementation of WPF that was compatabile with both mono and .NET Framework.
As much as I know, Mono does not support WPF.
Also, WPF uses graphics modules and interacts directly with the GPU. So I can't see how u can use WPF with no hidden pinvokes.
Sounds like you need to read about WPF architecture to better understand it.
http://msdn.microsoft.com/en-us/library/ms750441.aspx
Many pieces are missing in Mono and solely available in .NET. Therefore, your "theory" is not correct, and you cannot run WPF applications on Mono, even on Windows.
At MIX 2010 Miguel de Icaza said in his session that Mono isn't going to support WPF. Anything tangentially related to WPF-like support is only to provide what is needed for Moonlight.
Not fully, but..
You can use Moonlight 4 ( silverlight 4 ) in a desktop mode:-
https://github.com/inorton/MoonBase - MVVM helpers
https://github.com/inorton/XamlPreviewer - XamlPad clone

Categories