use crate::error::Result;
use crate::winrt::{IInspectable, IActivationFactory};
use windows::core::IInspectable as CoreIInspectable;
pub struct WindowsXamlManager {
inspectable: IInspectable,
}
impl WindowsXamlManager {
pub fn initialize_for_current_thread() -> Result<Self> {
println!("🔧 Initializing WindowsXamlManager...");
let factory = IActivationFactory::get("Windows.UI.Xaml.Hosting.WindowsXamlManager")
.map_err(|e| crate::error::Error::initialization(
format!("Failed to get WindowsXamlManager factory: {}", e)
))?;
let inspectable: CoreIInspectable = factory.activate_instance()
.map_err(|e| crate::error::Error::initialization(
format!("Failed to activate WindowsXamlManager: {}", e)
))?;
println!(" ✅ WindowsXamlManager initialized successfully");
Ok(WindowsXamlManager {
inspectable: IInspectable::from(inspectable),
})
}
pub fn as_inspectable(&self) -> &IInspectable {
&self.inspectable
}
}
unsafe impl Send for WindowsXamlManager {}
unsafe impl Sync for WindowsXamlManager {}