I am working on a Xamarin forms project to use OpenGL/OpenTK. I am trying to load a shader using GetManifestResourceStream. Whatever I do I get null
code is being run from .Shared project, shaders are in .ios / .Android resources directory
string prefix;
#if __IOS__
prefix = "OpenGLTesting.iOS.";
#endif
#if __ANDROID__
prefix = "OpenGLTesting.Droid.";
#endif
var assembly = typeof(App).GetTypeInfo ().Assembly;
Stream stream = assembly.GetManifestResourceStream (prefix + shaderName + ".glsl");
Add some debugging code, like calling assembly.GetManifestResourceNames (); so make sure you have both the right name and that it was embedded in your assembly.
Related
I'm actually working on a Maui Blazor project to work on Windows, and for this project, I created a custom top bar, where I include some buttons etc... (see 2 on the picture below).
But I would like to know how can I remove the default window bar (see 1 on the picture). I didn't found a propertie that can fill this purpose (except for WPF).
Any tips?
Thank you.
Regards, Samih.
This can be achieved by setting SetBorderAndTitleBar(Boolean, Boolean) to false and then set ExtendsContentIntoTitleBar to false. Please use the MauiProgram.cs like below:
using MauiApp13blazor.Data;
using Microsoft.Maui.LifecycleEvents;
#if WINDOWS
using Microsoft.UI;
using Microsoft.UI.Windowing;
using Windows.Graphics;
#endif
namespace MauiApp13blazor;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
})
.ConfigureLifecycleEvents(events =>
{
#if WINDOWS
events.AddWindows(wndLifeCycleBuilder =>
{
wndLifeCycleBuilder.OnWindowCreated(window =>
{
IntPtr nativeWindowHandle = WinRT.Interop.WindowNative.GetWindowHandle(window);
WindowId nativeWindowId = Win32Interop.GetWindowIdFromWindow(nativeWindowHandle);
AppWindow appWindow = AppWindow.GetFromWindowId(nativeWindowId);
var p = appWindow.Presenter as OverlappedPresenter;
window.ExtendsContentIntoTitleBar = false;
p.SetBorderAndTitleBar(false, false);
});
});
#endif
});
builder.Services.AddMauiBlazorWebView();
#if DEBUG
builder.Services.AddBlazorWebViewDeveloperTools();
#endif
builder.Services.AddSingleton<WeatherForecastService>();
return builder.Build();
}
}
I am using a Xamarin solution (VS2015), with shared code then a separate project for UWP, IOS and Android.
In the shared project, how do I change which code is greyed out when using #if?
e.g:
#if (WINDOWS_PHONE || WINDOWS_UWP || WINDOWS_APP)
StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
StorageFile sampleFile = await storageFolder.GetFileAsync(fileName);
string text = await FileIO.ReadTextAsync(sampleFile);
return text;
#elif (__IOS__ || __ANDROID__)
var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
var filePath = Path.Combine(documentsPath, fileName);
return await Task.Run(() => File.ReadAllText(filePath));
#endif
Currently the __ANDROID__ section is being colourised by VS, and the WINDOWS_PHONE part is greyed out. How can I tell VS that I want it the other way around?
Drop down this box and select the appropriate project to run, in your case, the UWP project
I'm working on a small documentation website and the content is stored in files. For instance I have two files chapter1.jade and chapter2.jade in a module1/ directory.
I'd like to read the module1/ directory and dynamically include all the chapterX.jade files in it.
I tried to have do directory = fs.readDirSync('module1/') and then in my view:
each item in directory
include item
But jade include doesn't support dynamic values (even `include #{item}) doesn't work. Do you have any idea how I could implement this ?
EDIT: I'd like to generate some code under the each loop (anchor for easy linking) so the solution would preferabily be in the view. I could obviously manually add the anchor in the included files but it is not ideal.
Thanks
Here is the short version of what I've done to make it work. It uses the jade Public API.
var directory = __dirname+'/views/bla/'
, files
, renderedHTML = '';
if( !fs.existsSync(directory) ) {
// directory doesn't exist, in my case I want a 404
return res.status(404).send('404 Not found');
}
// get files in the directory
files = fs.readdirSync(directory);
files.forEach(function(file) {
var template = jade.compile(fs.readFileSync(directory+file, 'utf8'));
// some templating
renderedHTML += '<section><a id="'+file+'" name="'+file+'" class="anchor"> </a>'+template()+'</section>';
});
// render the actual view and pass it the pre rendered views
res.render('view', {
title: 'View',
files: files,
html: renderedHTML
})
And the view just renders the html variable unescaped:
div(class="component-doc-wrap")
!{html}
As #user1737909 say, that's not possible using just jade.
The best way to do this (tho) is building a little Express Dynamic (view) Helpers
DEPECATED IN EXPRESS 3.XX
Check these: Jade - way to add dynamic includes
in addition to kalemas answer you can also write your includes to a file which is included in jade.
in this example I write my includes to include_all.jade. This file is included in a jade file.
If it does not work, check the path ;-)
e.g.
in your app.js
var includes = "path/to/include1\n";
includes += "path/to/include2";
...
incPath = "path/to/include_all.jade";
fs.open(incPath,'w',function(err,fd){
if(err){
throw 'error open file: ' + incPath +" "+ err;
}
var buffer = new Buffer(includes);
fs.write(fd,buffer,0,buffer.length,null,function(err){
if (err)
throw 'error writing file: ' +err;
fs.close(fd,function(){
console.log('file written ' + incPath);
});
});
});
in your jade file
include path/to/include_all.jade
Here's my setup for compilation for Release and debug.
What if I want to create a compilation build for client called "clientX" and "ClientY".
So I need a setup for ClientX.Debug, ClientX.Release and ClientY.Debug, ClientY.Release.
How do I setup these symbols in visual studio 2010? In order for #if (ClientX.Debug) to work?
Extension code to check for release build:
public static bool IsReleaseBuild(this HtmlHelper helper)
{
#if DEBUG
return false;
#else
return true;
#endif
}
How this is used for any view (razor syntax):
#if(Html.IsReleaseBuild())
***** Update I made the following changes:******
Open the project's Property Pages dialog box.
Click the Configuration Properties folder.
Click the Build property page.
Modify the Conditional Compilation Constants property.
I created the following: AMS_Debug, AMS_Release, GM_Release and GM_Debug
I added the following code in the layout pages:
#{
#if (AMS_Debug)
Layout = "~/Views/Shared/_AMSLayout.cshtml";
#else
Layout = "~/Views/Shared/_GMLayout.cshtml";
#endif
}
For some reason, it never hits AMS_Debug?
I have two silverlight assemblies, CaseManager.Applet and CaseManager.Applet.Sample. The Sample assembly has a reference to the base Applet assembly. The sample assembly has an embedded resource png image. The base applet assembly has a view xaml that I wish to display that image programmatically.
In the sample assembly I have a bit of code that creates a Uri like so:
var icon = new AppletIcon()
{
ImageUri = new Uri("CaseManager.Applet.Sample;component/images/guiness_2.png", UriKind.Relative),
ModuleType = GetType(),
Text = "Sample Module"
};
When I execute this code all the properties of ImageUri throw InvalidOperationException. I am not sure why. Anyone have suggestions?
The following code does the job:
var icon = new AppletIcon()
{
ImageUri = new Uri("/CaseManager.Applet.Sample;component/images/guiness_2.png", UriKind.Relative),
Module = this,
Text = "Sample Icon"
};
Things to note here:
The slash at the start of the Uri string.
The short name of the assembly containing the resource.
the ;component/ section.
From there it is basically the path inside your project to the image. Hope this helps someone else.
For what it was worth I was missing the very first slash.