XNA windows phone 7 how to load from Content? - c#

"
If you want to play along, you can create a Visual Studio project named NaiveTextMovement
and add the 14-point Segoe UI Mono font to the Content directory. The fields in the Game1
class are defined like so: "
how to add 14-point Segoe UI Mono font to the Content directory?
iv tried creating a folder in the solution and placing the font in it then i try to load it using Content.Load ... but it doesnt work. how is that?

You need to create a content project, then create a font description file. Reference the content project from your main XNA project.
In fact, a content project should already have been generated for you.
The font description file is an XML file. Editing it will be self-explanatory once you open it, as it will be auto-generated and well-commented.

When you create a new Windows Phone 7 game project, the template creates two different projects in your solution. One is the WindowsPhoneGame project and the other is the WindowsPhoneGameContent project.
The Game project is where you'll be adding all your code and the Content project is where you'll be adding all your game assets like sprites, textures and spritefonts.
You can see in the image below the two projects shown in the Solution Explorer (that's the pane in the upper right if you have the default configuration for Visual Studio).
The "Content" project is the one highlighted in the above image.
To add a SpriteFont, simple right click on the Content project and select "Add" and then "New Item" from the Add menu. This will open up the below dialog.
From the "Add New Item" dialog, simply select SpriteFont and give it the name you want. That will add a new SpriteFont object to your Content project and to your game.

Related

Visual Studio Installer Project - shortcut icons not set

I've created a WinForm application with .NET 4.6.1 and C#. I'm using Visual Studio 2017, with latest fixes updated (up to 29-Sept-2018).
The application uses a custom icon, and it's correctly shown: exe file is displayed with the proper icon.
I've created an Installer Project using the "Microsoft Visual Studio 2017 Installer Projects" extension. The installer copies sets of files in different locations (under Program Files, under the user's App Data, etc), and the files are correctly copied. EXE files correctly display the custom icon I've set.
Now, here comes the problem.
I've set a shortcut on the desktop.
The shortcut is created and actually works, but the icon is wrong: the default windows icon is shown instead.
I've tried several solutions and read from several forums.
1- I've tried to "Create New Shortcut" from the File System view (Desktop folder), and then set the Icon from the Properties window.
2- I've tried to right-click the output exe and select "Create a shortcut to primary output", and then dragged the shortcut to the desktop folder.
3- I've tried to select the icon referencing directly the Application Output exe: the wizard allows me to select the correct icon, I select it and confirm.
4- I've tried to select the icon referencing the source ICO file: once again, the wizard allows me to select the correct icon, I select it and confirm.
Any solution I've tried, I ALWAYS obtain a shortcut displayed with the default icon and NOT with the custom icon.
Whatsmore, if I try to manually "Create a shortcut" by right-clicking on the EXE, in window's File Explorer, the shortcut is created using the correct custom icon! So, it's strange that Visual Studio (or the installer) is not able to do the same thing during the installation.
Do you have any idea of the cause of the problem, and how to fix it?
Thanks!
I had the same issue, and tried every combination the OP also tried.
In the end my issue was down to the fact my .ICO file did not have the correctly sized images for the desktop shortcut. (It would have been nice if Visual Studio had told me that!!!!)
Oddly like the OP generating a shortcut by hand did make the icon appear, so I find the above a bit strange!
Anyway I was generating my .ICO file using GIMP to convert a PNG. I had clearly got this stage wrong.
I'd suggest trying a different .ICO file first and see if that is the cause.
It was for me and I solved it by using the following site:
http://icoconvert.com/
I then ticked the relevant boxes for the sizes, used this new .ICO file and hey presto it all works
I'd the same problem.
I had fix it simply select the main ouput (.exe) and not the .ico in the shortcut property icon option. I suppose installer not recognize the .ico file correctly.
I encountered the same problem. Just ensure you set the icon for the project to the same icon file as for the desktop shortcut and user program shortcut.
The icon file must follow the dimensions of Windows 7.
You can use http://icoconvert.com/ for changing the icon dimensions.
I had the same problem, using VS 2019 with the Visual Studio Installer extension.
I checked my icon had the correct dimensions (16x16, 32x32 and 48x48 within the ICO file), so it wasn't this.
Also, I had previously installed the app and the icon had worked fine. I'm using the "replace previous version", but I'm not sure if this is cause.
I double-checked the installers Outputs, and yes, the .ico was being copied/included... however I found that the defined shortcut (in VSI editor) did not have the icon property defined anymore - it had reverted to "(None)".
1
I resolved it in VSI, by using the Properties window for the shortcut, on the Icon property, select Browse from the DDL, then set the .ico from the source file. (The VSI detail tab still shows the default "text doc" icon, but result after install is the one I wanted/selected).
This is not the first time VSI has done this to my projects, so I'm guessing it is a slight bug of this otherwise great extension.
The problem for me was that the .ico was compressed with PNG.
Do not export using Vista PNG compression! Use normal BMP frames instead.

Winform in unity is not displaying as it should

I'm facing a problem with displaying a Winform I've created in the unity editor, for some reason the form is not displaying as it should in the unity editor...
most controls in the form have the "autosize" property set to true
and the "autoSizeMode" property set to "GrowAndShrink". and whenever
I display the form in the unity editor, these controls just vanish..
their size is set to (0,0) regardless of the inner controls they
hold. (setting manually the "minimumSize" property of these controls does makes them visible again.)
the "sutoScroll" property is not displaying the sliders.
the "dock" property is not acting as it should.
some of the majors I've taken:
I've added the right dlls (such as the "system.windows.forms.dll) to the unity project.
I've merged the ".cs" and ".designer.cs" of each form into a single file, so I won't face this problem "Form and designer files not linking in Solution Explorer", and I copied them to the unity project.
I've tried making a "class library" project and copy the forms into it.
placing the build/debug dll in the unity project and displaying the form. (still the same result though)
I've copied the ".exe" of the winform project to unity, and
calling/displaying the exe does show the form correctly, but I want
to be able to share collection references between the exe and unity
editor... and from what I've read online don't think it's passable ..
any suggestions on how to resolve the issue? or no how to display a Winform in unity editor without it getting all messed up, and share argument references between the both?
this is an image of the winform running in visual studio:
this is an image of the form displayed through unity:
this is a link to the Winform project

How to change application icon in Xamarin.Forms?

I replaced all the images everywhere (by this I mean in drawable folders and all Windows Assets folders and iOS Resources folder), but it still shows me the default Xamarin icon for the app. I tried this code, too, but it doesn't seem to work either. Can someone tell me the solution?
[assembly: Application(Icon = "#drawable/icon")]
Updating Icon and Name (Android)
If you changed the icon file name please ensure you update the Icon reference in MainActivity.cs:
[Activity(Label = "MyName", Icon = "#mipmap/myicon", Theme = "#style/MainTheme"]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
}
You should also update the names of icon.xml and icon_round.xml in the mipmap-anydpi folder to match to new icon name. If launcher-foreground.png was renamed then update the value of <foreground...> in corresponding icon.xml.
Summary (Android)
Replace the png's in mipmap folders with your new icon
If name was changed, update Icon value in MainActivity.cs
If name was changed, update name of (or create a new copy of) icon.xml and icon_round.xml
If name of launcher-foreground.png was changed then update value in icon.xml. Eg:
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="#color/my_launcher_background"/>
<foreground android:drawable="#mipmap/my_launcher_foreground"/>
</adaptive-icon>
If name wasn't changed and you've cleaned and re-built project but still your new icons are not deploying: Delete obj folder from Android project directory
Details and Issues if not updating (Android)
Xamarin Forms/Android puts 2 icons in each mipmap folder (mipmap-mdpi, mipmap-hdpi, mipmap-xhdpi, etc) - icon.png and launcher-foreground.png.
Replace both these images in each of the mipmap folders. I kept the same names but it should be possible to use a different name.
If you rename launcher-foreground.png then you must update the values in icon.xml and icon_round.xml (or their equivalent new names). The value in the <foreground...> tag references the icon/png. So, if launcher-foreground.png was updated to my_launcher-foreground.png this should be reflected in the icon.xml (see step 4 in summary above).
If the icons still don't update even after cleaning/re-building it could be that the original/default icons still existed in the Android project obj folder. The solution is to delete the obj folder from the Android project directory.
iOS
For iOS, please see Managing Icons with Asset Catalogs. A summary taken from the linked page is provided below:
For icons, a special AppIcon image set can be added to the Assets.xcassets file in the app's project.
To use an Asset Catalog, do the following:
Double-click the Info.plist file in the Solution Explorer.
Click on the Visual Assets tab and click on the Use Asset Catalog button under App Icons.
From the Solution Explorer, expand the Asset Catalog folder.
Double-click the Media file to open it in the editor.
Under the Properties Explorer the developer can select the different types and sizes of icons required.
Click on given icon type and select an image file for the required type/size.
Click the Open button to include the image in the project and set it in the xcasset.
MacOs
The guide for MacOs is Application icon for Xamarin.Mac apps. You need to consider the following steps:
Required image sizes and filenames
Packaging the icon resources
Using the icon
detailed in the linked docs above.
For Android try to set the icon app like this:
[Activity(Icon = "#drawable/icon")]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
.....
}
Make sure that you have changed all the icon images on all drawable folders ( drawable, drawable-hdpi, drawable-xhdpi and drawable-xxhdpi ).
For iOS I like set the app icons and splash screen with Asset Catalogs, here you can find a guide to how to use it:
https://developer.xamarin.com/guides/ios/application_fundamentals/working_with_images/app-icons/
For iOS in visual studio...
Step1: Generate all the app icons from https://appicon.co/
Step2: In solution explorer, under iOS project, expand 'Asset Catalogs' and double click on 'Assests'. You can change the existing 'AppIcon' icons or Add a new Asset and attach the icons.
This is how you add a new asset...
Step3: In solution explorer, under iOS project, double click on Info.plist.
Go to 'Visual Assets' tab, click on 'App Icons' and change the 'Source' to the
asset that you just created.
Done.
Hope this helps someone!
Answer is deprecated
If I understood you correctly, for iOS project: Properties -> iOS Application
For Android: Properties -> Android Manifest
I had the same problem, but the following helped resolve it:
Go to MainActivity.cs (in the Solution Explorer)
Look for where it says 'Icon ='
Change the location of the Icon, but don't include the extension, i.e. jpg, png, etc. (For ex. Icon = "#drawable/weatherIcon")
Save the file
Restart debugging (the little restart icon beside the stop and pause icon around the top right-hand side of your screen)
If you get stuck on any part of this check out this short video from 02:47 onwards https://youtu.be/5g8lWPQZFxs?t=167. It helped me a lot.
Try to replace all the icon on iOS project > Properties > iOS Application > Iphone Icons/IPad Icons.
I change all of them, the settings icon do change. Images that on Resouces can be created by just insert images on there.
Tested this today and noticed that you only need to change the icon images in all drawable folders,
drawable,
drawable-hdpi,
drawable-xhdpi
drawable-xxhdpi.
Depending on the device it's going to use different images. For me i used "Visual Studio Android Emulator" using:
- 5" KitKat(4,4) XXHDPI Phone (Android 4,4 - API 19)
Did not need to uninstall and reinstall the app in the emulator, it updated on it's own after starting the project with "build" checked in the menu Build/Configuration manager.
On top of that no code changes were made!
If you replace the Icon.png and still nothing changed on the device, than change "Copy to Output Directory" propertiy to "Copy if newer" or "Copy always".
That was my solution.
All of these solutions are great, but
THE SIMPLEST WAY:
You can now just use ResizetizerNT's nuget package and upload one svg file and set IsAppIcon to true. That should generate everything needed.
If the existing app icon is icon.png, just name the svg to icon.svg and it should automatically work.
Alternatively, you can also add another SVG for the background in order to support adaptive icons on Android.
Context: ResizetizerNT was created by the Xamarin.Forms/MAUI Engineering Manager, Jonathan Dick

Adding content in MonoGame

I'm new to Monogame. I'm trying to add content (An image), but I can't do this. In each tutorial that I have seen, the solution explorer has a folder where I can put assets, but not mine.
I tried to add an image to the root folder, but it doesn't work.
hero = Content.Load<Texture2D>(#"Image1.png");
Right click on your solution and click Add, then New Project.
From there, select Installed > Visual C# > Monogame, and click on the MonoGame Content Project
After you do this, you will see your content project in your solution. In order to allow your game to use it, look under your Game project, and right click References. Navigate to Solution > Projects and tick the checkbox next to your Content project.
You can now add your images to your Content project, and use them like a regular XNA game.
Check out these links:
Managing Content |
Monogame
Loading Content in XNA
(MSDN)

How to change launching icon of windows form application in microsoft visual c# 2010 express

When we start debugging the project, a form is available displaying the items. It has a default icon containing a square block. Can we change that icon??
In the Properties of the Form you have the property Icon. If you click on it you will get a little button where you can select a local file.
If you want to change the Icon of the compiled exe file you need to go to the properties of your project (right click on projrct in project explorer -> properties) and change the default icon.
goto form properties and choose icon select path of the images.....
form properties>icon>select>icon image.
Visual Studio 2010 Express C# has no icon editor,
If you want to use custom icons, you need a way to create them. The free GIMP graphics program will export images as .ico files, just use one layer per icon (say 16x16, 32x32, 48x48 & 64x64).
The .ico file can then be dragged and dropped onto the Project Properties tab Resources/Icons pane. CustomIcon.ico will be named as (and recognised by IntelliSense) as CustomIcon. This is built in at compile time and has no need to reference external files at run time.
It can be used to change the window title bar icon from the Form Code as follows:
Size size = new Size(16,16);
this.Icon = new Icon(YourProject.Properties.Resources.CustomIcon, size);
You could read this msdn article
http://msdn.microsoft.com/en-us/library/339stzf7.aspx
In the Form Code Side:
this.Icon = new Icon(#"C:\...");
In the Designer is in the Property-Window a property for the Form.
Right mouse click on form => Properties => Icon

Categories

Resources