r2d25551
r2d25551
CC#
Created by r2d25551 on 2/24/2024 in #help
Connect
How to upgrade repo to .Net 7 or .Net 8 (https://github.com/CommunityToolkit/Lottie-Windows). I have been trying on and off now probably since November 2023. I spent a lot of time on something I consider to be trivial. Any help is appreciated. Visual Studio output is:
Framework: Microsoft.NET.CoreRuntime.2.2/X64, app package version 2.2.29713.2 is not currently installed. Framework: Microsoft.NET.CoreFramework.Debug.2.2/X64, app package version 2.2.29301.2 is not currently installed. Installing missing frameworks... DEP0800: The required framework "C:\Users\Jerry.nuget\packages\runtime.win10-x64.microsoft.net.uwpcoreruntimesdk\2.2.12\build..\tools\Appx\Microsoft.NET.CoreRuntime.2.2.appx" failed to install. [0x80073CF0] Common::Deployment::MsixvcStagingSession::GetManifestReader in MsixvcStagingSession failed with error 0x80070570. Creating a new clean layout... Copying files: Total 13 mb to layout... Checking whether required frameworks are installed... ========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== ========== Build completed at 8:22 AM and took 14.201 seconds ========== ========== Deploy: 0 succeeded, 2 failed, 0 skipped ========== ========== Deploy completed at 8:22 AM and took 14.201 seconds ========== Framework: Microsoft.NET.CoreRuntime.2.2/X64, app package version 2.2.31331.1 is not currently installed. Framework: Microsoft.NET.CoreFramework.Debug.2.2/X64, app package version 2.2.31327.1 is not currently installed. Installing missing frameworks... DEP0800: The required framework "C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\runtime.win10-x64.microsoft.net.uwpcoreruntimesdk\2.2.14\build..\tools\Appx\Microsoft.NET.CoreRuntime.2.2.appx" failed to install. [0x80073CF0] Common::Deployment::MsixvcStagingSession::GetManifestReader in MsixvcStagingSession failed with error 0x80070570.
Framework: Microsoft.NET.CoreRuntime.2.2/X64, app package version 2.2.29713.2 is not currently installed. Framework: Microsoft.NET.CoreFramework.Debug.2.2/X64, app package version 2.2.29301.2 is not currently installed. Installing missing frameworks... DEP0800: The required framework "C:\Users\Jerry.nuget\packages\runtime.win10-x64.microsoft.net.uwpcoreruntimesdk\2.2.12\build..\tools\Appx\Microsoft.NET.CoreRuntime.2.2.appx" failed to install. [0x80073CF0] Common::Deployment::MsixvcStagingSession::GetManifestReader in MsixvcStagingSession failed with error 0x80070570. Creating a new clean layout... Copying files: Total 13 mb to layout... Checking whether required frameworks are installed... ========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== ========== Build completed at 8:22 AM and took 14.201 seconds ========== ========== Deploy: 0 succeeded, 2 failed, 0 skipped ========== ========== Deploy completed at 8:22 AM and took 14.201 seconds ========== Framework: Microsoft.NET.CoreRuntime.2.2/X64, app package version 2.2.31331.1 is not currently installed. Framework: Microsoft.NET.CoreFramework.Debug.2.2/X64, app package version 2.2.31327.1 is not currently installed. Installing missing frameworks... DEP0800: The required framework "C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\runtime.win10-x64.microsoft.net.uwpcoreruntimesdk\2.2.14\build..\tools\Appx\Microsoft.NET.CoreRuntime.2.2.appx" failed to install. [0x80073CF0] Common::Deployment::MsixvcStagingSession::GetManifestReader in MsixvcStagingSession failed with error 0x80070570.
1 replies
CC#
Created by r2d25551 on 11/8/2023 in #help
❔ How to connect events
I am trying to connect the ISKGLViewController.GetCanvasSize event (https://learn.microsoft.com/en-us/dotnet/api/skiasharp.views.maui.controls.iskglviewcontroller.getcanvassize?view=skiasharp-views-maui-2.88) to my implementation.
using Microsoft.Maui.Graphics.Skia;

using SkiaSharp;
using SkiaSharp.Views.Maui;
using SkiaSharp.Views.Maui.Controls;
using System;

namespace OpenGLTest;

public partial class OGLWidget : SKGLView, ISKGLViewController
{
protected GRContext glContext;
protected SKSize canvasSize = new SKSize(640, 480);

protected SKCanvas canvas;
protected SKImageInfo info;
protected SKRect drawRect;
protected SKSurface surface;

public OGLWidget() : base()
{
}

public SKSize GetCanvasSize(GetPropertyValueEventArgs<SKSize> args)
{
return canvasSize;
}

public GRContext GetGRContext(GetPropertyValueEventArgs<GRContext> args)
{
return glContext;
}

protected override void OnPaintSurface(SKPaintGLSurfaceEventArgs args)
{
// call the base method
base.OnPaintSurface(args);

ICanvas icanvas = new SkiaCanvas() { Canvas = args.Surface.Canvas };
icanvas.EnableDefaultShadow(1.0f);

surface = args.Surface;
drawRect = new SKRect(0, 0, info.Width, info.Height);

canvas = surface.Canvas;

// draw on the canvas

canvas.Flush();
}

protected override void OnTouch(SKTouchEventArgs e)
{
base.OnTouch(e);
}
}
using Microsoft.Maui.Graphics.Skia;

using SkiaSharp;
using SkiaSharp.Views.Maui;
using SkiaSharp.Views.Maui.Controls;
using System;

namespace OpenGLTest;

public partial class OGLWidget : SKGLView, ISKGLViewController
{
protected GRContext glContext;
protected SKSize canvasSize = new SKSize(640, 480);

protected SKCanvas canvas;
protected SKImageInfo info;
protected SKRect drawRect;
protected SKSurface surface;

public OGLWidget() : base()
{
}

public SKSize GetCanvasSize(GetPropertyValueEventArgs<SKSize> args)
{
return canvasSize;
}

public GRContext GetGRContext(GetPropertyValueEventArgs<GRContext> args)
{
return glContext;
}

protected override void OnPaintSurface(SKPaintGLSurfaceEventArgs args)
{
// call the base method
base.OnPaintSurface(args);

ICanvas icanvas = new SkiaCanvas() { Canvas = args.Surface.Canvas };
icanvas.EnableDefaultShadow(1.0f);

surface = args.Surface;
drawRect = new SKRect(0, 0, info.Width, info.Height);

canvas = surface.Canvas;

// draw on the canvas

canvas.Flush();
}

protected override void OnTouch(SKTouchEventArgs e)
{
base.OnTouch(e);
}
}
But I do not know how to do so.
3 replies
CC#
Created by r2d25551 on 9/20/2023 in #help
❔ How do I pass in the parent ContentView to a class contained in the XAML? Is it possible?
For example:
<ContentView x:Class="MyView>
<local:MyClass>
<x:Arguments>
<ContentView />
</x:Arguments>
</local:MyClass>
<ContentView x:Class="MyView>
<local:MyClass>
<x:Arguments>
<ContentView />
</x:Arguments>
</local:MyClass>
And have the constuctor of MyClass get the type MyView.
public class MyClass
{
public MyClass(object obj)
{
MyView myView = obj as MyView;
:
}
}
public class MyClass
{
public MyClass(object obj)
{
MyView myView = obj as MyView;
:
}
}
Also tried variations of <x:Arguments> to include the x:Class="", ...
<x:Arguments>
<local:MyView />
</x:Arguments>
<x:Arguments>
<local:MyView />
</x:Arguments>
15 replies
CC#
Created by r2d25551 on 9/6/2023 in #help
❔ UTF8 Project Wide Default
Anyway to set the Visual Studio Project to use UTF8 as the default? >
4 replies
CC#
Created by r2d25551 on 9/4/2023 in #help
❔ .NET MAUI GetSystemService returns null
All the calls to GetSystemService return null. Has anyone used this before? Am I doing something wrong?
string[] serviceNames = new string[]
{
"ACCESSIBILITY_SERVICE",
"ACCOUNT_SERVICE",
"ACTIVITY_SERVICE",
"ALARM_SERVICE",
"APP_OPS_SERVICE",
:
};

foreach (string serviceName in serviceNames)
{
Java.Lang.Object? service = Android.App.Application.Context.GetSystemService(serviceName);
:
}
string[] serviceNames = new string[]
{
"ACCESSIBILITY_SERVICE",
"ACCOUNT_SERVICE",
"ACTIVITY_SERVICE",
"ALARM_SERVICE",
"APP_OPS_SERVICE",
:
};

foreach (string serviceName in serviceNames)
{
Java.Lang.Object? service = Android.App.Application.Context.GetSystemService(serviceName);
:
}
3 replies
CC#
Created by r2d25551 on 9/4/2023 in #help
❔ .NET MAUI Android Filesystem
I am getting a Read-only access violation when I try to create a directory in the path returned from MediaStore.Files.GetContentUri:
Android.Net.Uri? uri = MediaStore.Files.GetContentUri("external");
"content://media/external/file".AbsolutePath;
"/external/file"
Android.Net.Uri? uri = MediaStore.Files.GetContentUri("external");
"content://media/external/file".AbsolutePath;
"/external/file"
Android.Net.Uri? uri = MediaStore.Images.Media.ExternalContentUri;
"content://media/external/images/media"
Android.Net.Uri? uri = MediaStore.Images.Media.ExternalContentUri;
"content://media/external/images/media"
Android.Net.Uri? uri = MediaStore.Audio.Media.ExternalContentUri;
"content://media/external/audio/media"
Android.Net.Uri? uri = MediaStore.Audio.Media.ExternalContentUri;
"content://media/external/audio/media"
Android.Net.Uri? uri = MediaStore.Video.Media.ExternalContentUri;
"content://media/external/video/media"
Android.Net.Uri? uri = MediaStore.Video.Media.ExternalContentUri;
"content://media/external/video/media"
Are these return values correct? Am I using the AbsolutePath correctly? Any suggestions on how to resolve the Read-only access violation is appreciated.
2 replies
CC#
Created by r2d25551 on 9/1/2023 in #help
❔ Bind derived class and base class to CollectionView and Picker
I am trying to bind a derived class to a Picker, and the base class to a CollectionView. Should this work? My picker is always empty:
<CollectionView ItemsSource="{Binding MyData}"
<Picker Grid.Row="1" Title="Language" ItemsSource="{Binding Languages}" ItemDisplayBinding="{Binding Name}" . . . />
<CollectionView ItemsSource="{Binding MyData}"
<Picker Grid.Row="1" Title="Language" ItemsSource="{Binding Languages}" ItemDisplayBinding="{Binding Name}" . . . />
The base class bindings are fine. . . but my picker is having trouble.
7 replies
CC#
Created by r2d25551 on 8/29/2023 in #help
❔ await nullable return values
I have a function returning a nullable class. The compiler complains at the await line it cannot implicity perform the conversion even though they are both the same type.
15 replies
CC#
Created by r2d25551 on 8/26/2023 in #help
When creating C# generic classes with static functions should the return type concreate class types?
For example:
public class MyClass<TKey, TValue> : IBase
{
TValue v;
public Dictionary<TKey, TValue> myData = new Dictionary<TKey, TValue>();

public Dictionary<TKey, TValue> GetData() { return myData; }

public static MyClass<string, MyData> CreateMyData()
{
MyClass<string, MyData> tmp = new MyClass<string, MyData>();
return tmp;
}
}
public class MyClass<TKey, TValue> : IBase
{
TValue v;
public Dictionary<TKey, TValue> myData = new Dictionary<TKey, TValue>();

public Dictionary<TKey, TValue> GetData() { return myData; }

public static MyClass<string, MyData> CreateMyData()
{
MyClass<string, MyData> tmp = new MyClass<string, MyData>();
return tmp;
}
}
And what about returning the same class from deserialization?
public static MyClass<string, MyData> Deserialize(string filename)
{
string jsonString = File.ReadAllText(filename);
MyCall<string, MyData> tmp = JsonSerializer.Deserialize<MyClass<string, MyData>>(jsonStrin);
return tmp;
}
public static MyClass<string, MyData> Deserialize(string filename)
{
string jsonString = File.ReadAllText(filename);
MyCall<string, MyData> tmp = JsonSerializer.Deserialize<MyClass<string, MyData>>(jsonStrin);
return tmp;
}
20 replies
CC#
Created by r2d25551 on 8/24/2023 in #help
❔ Navigation.PushModalAsync() not modal
I am trying to popup a modal ConetPage using:
await Navigation.PushModalAsync(new DetailsPage());
await Navigation.PushModalAsync(new DetailsPage());
From a class inheritance of:
MainPage = new AppShell();
MainPage = new AppShell();
Sadly neither of these worked:
await Application.Current.MainPage.Navigation.PushModalAsync(popup);
await Shell.Current.Navigation.PushModalAsync(popup);
await Application.Current.MainPage.Navigation.PushModalAsync(popup);
await Shell.Current.Navigation.PushModalAsync(popup);
During a button event I am trying to display another page in modal form and wait for the user response. This page is based on ContentPage, contains a VerticalStackLayout, ScrollView, and CollectionView.
2 replies
CC#
Created by r2d25551 on 8/21/2023 in #help
❔ Class with Func<> and class initializers
If I define a class with members to be passed to known create type functions how do I set the Func<> member to the known function? For example,
public class Known
{
public string param1;
public string param2;
public IRet myObj;
public Func<string, string, IRet> Create;
}

Dictionay<string, Known> myData = new Dictionary<string, Known>()
{
{
"one", // dictionary key
{
"abc", // func parameters
"xyz",
null, // func returrn value

CreateFunc, // PROBLEM HERE?
}
}
};


public static IRet CreateFunc(string param1, string param2)
{
IRet iret = new IRet(param1, param2);
return iret;
}
public class Known
{
public string param1;
public string param2;
public IRet myObj;
public Func<string, string, IRet> Create;
}

Dictionay<string, Known> myData = new Dictionary<string, Known>()
{
{
"one", // dictionary key
{
"abc", // func parameters
"xyz",
null, // func returrn value

CreateFunc, // PROBLEM HERE?
}
}
};


public static IRet CreateFunc(string param1, string param2)
{
IRet iret = new IRet(param1, param2);
return iret;
}
Thank you in advance.
76 replies
CC#
Created by r2d25551 on 8/18/2023 in #help
❔ Guid from TappedEventArgs
For the TapGestureRecognizer event handler I am passing in a GUID. I have not figured out how to convert the TappedEventArgs.Parameter to a GUID:
protected async void OnItemSelected(object sender, TappedEventArgs args)
{
Guid guid = args.Parameter as Guid;
}
protected async void OnItemSelected(object sender, TappedEventArgs args)
{
Guid guid = args.Parameter as Guid;
}
Any help is appreciated.
5 replies
CC#
Created by r2d25551 on 8/17/2023 in #help
❔ How To Refresh ContentPage Controls
When routing from the MainPage to my details page I pass in:
MyData myData = currentSelectedItems.FirstOrDefault() as MyData;
Dictionary<string, object> navParams = new Dictionary<string, object>
{
{ "MyData", myData }
};

await Shell.Current.GoToAsync($"MyDetailsPage", navParams);
MyData myData = currentSelectedItems.FirstOrDefault() as MyData;
Dictionary<string, object> navParams = new Dictionary<string, object>
{
{ "MyData", myData }
};

await Shell.Current.GoToAsync($"MyDetailsPage", navParams);
The detail page properly receives the passed parameter. But there is caveat. It is not available to OnLoaded is called. The initial control values are nearly empty, except for DateTime, etc. Also, there are times when the passed parameters are null, and new detail item is being created. The BindingContext is set in the page constructor, and XAML references the x:DataType:
x:DataType="local:MyData"

public MyData myData;

public MyDetailsPage()
{
InitializeComponent();
BindingContext = this;
}


protected void OnLoaded(object sender, EventArgs e)
{
if (myData == null)
{
isNew = true;
myData = new MyData();
myData.GUID = Guid.NewGuid();
}
}
x:DataType="local:MyData"

public MyData myData;

public MyDetailsPage()
{
InitializeComponent();
BindingContext = this;
}


protected void OnLoaded(object sender, EventArgs e)
{
if (myData == null)
{
isNew = true;
myData = new MyData();
myData.GUID = Guid.NewGuid();
}
}
At this point my controls are blank. How do I ask the page to refresh? Do I need to do so manually for each control?
3 replies
CC#
Created by r2d25551 on 8/14/2023 in #help
❔ CollectionView Questions
Does the Grid.GestureRecognizers work? The Image.GestureRecognizers does but I am having trouble getting the Grid events. Where does the Grid.GestureRecognizers go? I have tried the top; below row/col definitions; and bottom. How do I store the "this" pointer in a collection view? TreeView we stored our own pointer to the underlying data. What is the equivalent of c# collection view?
3 replies
CC#
Created by r2d25551 on 8/13/2023 in #help
✅ Async PushButton Functions
What is the proper way to handle FileIO asynchronously? I have a Utility class that performs various functions, one in particular:
public static async Task<string> PickPhoto()
{
return await Task.Run(() =>
{
Task<FileResult> task = MediaPicker.Default.PickPhotoAsync();
if (task != null)
{
FileResult result = task.GetAwaiter().GetResult();
return result.FullPath;
}

return string.Empty;
});
}


protected async void OnPickPhoto(object sender, EventArgs args)
{
await MainThread.InvokeOnMainThreadAsync(() =>
{
if (MediaPicker.Default.IsCaptureSupported)
{
Task<string> task = await Utils.PickPhoto();
if (task != null)
{
string filename = task.GetAwaiter().GetResult();
imageFilename.Source = filename;
}
}
});
}
public static async Task<string> PickPhoto()
{
return await Task.Run(() =>
{
Task<FileResult> task = MediaPicker.Default.PickPhotoAsync();
if (task != null)
{
FileResult result = task.GetAwaiter().GetResult();
return result.FullPath;
}

return string.Empty;
});
}


protected async void OnPickPhoto(object sender, EventArgs args)
{
await MainThread.InvokeOnMainThreadAsync(() =>
{
if (MediaPicker.Default.IsCaptureSupported)
{
Task<string> task = await Utils.PickPhoto();
if (task != null)
{
string filename = task.GetAwaiter().GetResult();
imageFilename.Source = filename;
}
}
});
}
The compiler complains at the await Utils.PickPhoto(); If I remove it, and satisfy the complier errors no result is returned. Is my setup correct? What am I doing wrong? Thank you in advance.
14 replies
CC#
Created by r2d25551 on 8/11/2023 in #help
✅ Return Proper Dictionary
At the moment my return value is null.
public class Data
{
}

public class MyData : Data
{
}

public interface IHelper
{
public Dictionary<string, T> GetDictionary<T>();
}

public class MyClass : IHelper
{
public Dictionary<string, MyData> myData = new Dictionary<string, MyData>();

public Dictionary<string, Data> GetDictionary<Data>()
{
return myData as Dictionary<string, Data>;
}
}
public class Data
{
}

public class MyData : Data
{
}

public interface IHelper
{
public Dictionary<string, T> GetDictionary<T>();
}

public class MyClass : IHelper
{
public Dictionary<string, MyData> myData = new Dictionary<string, MyData>();

public Dictionary<string, Data> GetDictionary<Data>()
{
return myData as Dictionary<string, Data>;
}
}
24 replies