public static Overlay CreateOverlay(IServiceRegistry services, DirectXViewer application) { Overlay overlay = new Overlay(services) { Width = 576, Height = 576 }; overlay.BeginDesign(); Button bCaptureFrame = new Button() { Width = 64, Height = 64, Content = new TextBlock { Text = "D" } }; Button bSwitchToCube = new Button() { Width = 64, Height = 64, Content = new TextBlock { Text = "C" } }; overlay.Add(bCaptureFrame); overlay.Add(bSwitchToCube); overlay.EndDesign(); return(overlay); }
public void PlayerSetup() { OverlayManager overlay = GameWorld.GetObject("overlay") as OverlayManager; Overlay hud = overlay.GetOverlay("hud") as Overlay; hud.Add(skill1); hud.Add(skill2); hud.Add(skill3); }
private IDisposable SetOverlay(View view, Drawable drawable) { #if __ANDROID_18__ if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Kitkat) { using (PreventRequestLayout()) { Overlay.Add(drawable); } return(Disposable.Create( () => { using (PreventRequestLayout()) { Overlay.Remove(drawable); } } )); } else #endif { #pragma warning disable 0618 // Used for compatibility with SetBackgroundDrawable and previous API Levels // Set overlay is not supported by this platform, set use the background instead. // It'll break some scenarios, like having borders on top of the content. view.SetBackgroundDrawable(drawable); return(Disposable.Create(() => view.SetBackgroundDrawable(null))); #pragma warning restore 0618 } }
public ComboBox(string displayName, IEnumerable <string> textValues, int defaultIndex = 0) : base(displayName, 30) { var values = textValues.ToList(); if (defaultIndex >= values.Count) { throw new IndexOutOfRangeException("Default index cannot be greater than values count!"); } // Initialize properties TextObjects.Add(TextHandle = new Text(displayName, DefaultFont) { Color = DefaultColorGold, TextOrientation = Text.Orientation.Center }); ControlHandle = new ComboBoxHandle(values[defaultIndex]); _currentValue = defaultIndex; OverlayControl = new OverlayContainer(this) { IsVisible = false, BackgroundColor = Color.FromArgb(200, 14, 27, 25) }; // Add a button to the container for each combo box entry foreach (var value in values) { Overlay.Add(new Button(Button.ButtonType.ComboBoxSub, value)); } // Add handle to base Add(ControlHandle); // Initalize theme specific properties OnThemeChange(); // Listen to required events ControlHandle.OnActiveStateChanged += delegate { // Set visibility state of the overlay Overlay.IsVisible = ControlHandle.IsActive; }; Messages.OnMessage += delegate(Messages.WindowMessage args) { switch (args.Message) { // Collapse combo box on blacklist message case WindowMessages.KeyUp: case WindowMessages.LeftButtonDoubleClick: case WindowMessages.LeftButtonDown: case WindowMessages.MiddleButtonDoubleClick: case WindowMessages.MiddleButtonDown: case WindowMessages.MouseWheel: case WindowMessages.RightButtonDoubleClick: case WindowMessages.RightButtonDown: CloseOverlayOnInteraction(args.Message == WindowMessages.MouseWheel); break; } }; }
//setup skill public void Setup() { GameWorld.Add(this); OverlayManager overlay = GameWorld.GetObject("overlay") as OverlayManager; Overlay hud = overlay.GetOverlay("hud") as Overlay; //add timer to the hud overlay hud.Add(timer); }
public static Overlay New(IServiceRegistry services) { var settings = services.GetService <IDirectXDeviceSettings>(); var overlay = new Overlay(services) { Width = settings.PreferredBackBufferWidth, Height = settings.PreferredBackBufferHeight }; overlay.BeginDesign(); var stackPanel = new StackPanel() { Width = 256, Height = 92, Position = new Vector2(8, 8) }; DataTemplate commandTemplate = new DataTemplate() { DataType = typeof(StackPanel), Key = "CommandTemplate", VisualTree = new Button() { Width = 64, Height = 64, Margin = new Thickness(4), Name = "Button", Content = new TextBlock() { Name = "TextBlock", TextStyleClass = "Small" } }, }; commandTemplate.Bindings.Add("Text", new Binding("TextBlock", "CommandName")); stackPanel.DataTemplate = commandTemplate; stackPanel.ItemsSource = new SampleVM[] { new SampleVM() { CommandName = "AA" }, new SampleVM() { CommandName = "BB" }, }; overlay.Add(stackPanel); overlay.EndDesign(); return(overlay); }
protected override void OnInitialize(InitializeDirectXEventArgs e) { IDirect2DProvider direct2D = e.DirectX.Direct2D; BitmapProperties1 bitmapProperties = new BitmapProperties1() { DpiX = e.Settings.Dpi, DpiY = e.Settings.Dpi, PixelFormat = new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied), BitmapOptions = BitmapOptions.Target, }; uiSurface = ToDispose(new Bitmap1(direct2D.Context, new Size2(e.Settings.ScreenWidth, e.Settings.ScreenHeight), bitmapProperties)); Overlay = ToDispose(Overlay.FromDescription( new OverlayDescription(width: e.Settings.ScreenWidth, height: e.Settings.ScreenHeight))); Overlay.BeginDesign(); Panel panel = new Panel() { Position = new SharpDX.Vector2(512, 192), Width = 320, Height = 92 }; Label label = new Label() { Position = new SharpDX.Vector2(8, 8), Text = "stereo" }; panel.Add(label); Overlay.Add(panel); Overlay.EndDesign(e.DirectX); effectGraph = CreateEffectGraph(direct2D); direct2D.Context.TextAntialiasMode = SharpDX.Direct2D1.TextAntialiasMode.Grayscale; }
public void Add(string value) { Overlay.Add(new Button(Button.ButtonType.ComboBoxSub, value)); }
public void Run() { Gtk.Application.Init(); SetupTheme(); ApiExtensibility.Register(typeof(Windows.UI.Core.ICoreWindowExtension), o => new GtkCoreWindowExtension(o)); ApiExtensibility.Register <Windows.UI.Xaml.Application>(typeof(Uno.UI.Xaml.IApplicationExtension), o => new GtkApplicationExtension(o)); ApiExtensibility.Register(typeof(Windows.UI.ViewManagement.IApplicationViewExtension), o => new GtkApplicationViewExtension(o)); ApiExtensibility.Register(typeof(ISystemThemeHelperExtension), o => new GtkSystemThemeHelperExtension(o)); ApiExtensibility.Register(typeof(Windows.Graphics.Display.IDisplayInformationExtension), o => _displayInformationExtension ??= new GtkDisplayInformationExtension(o, _window)); ApiExtensibility.Register <TextBoxView>(typeof(ITextBoxViewExtension), o => new TextBoxViewExtension(o, _window)); ApiExtensibility.Register(typeof(ILauncherExtension), o => new LauncherExtension(o)); ApiExtensibility.Register <FileOpenPicker>(typeof(IFileOpenPickerExtension), o => new FileOpenPickerExtension(o)); ApiExtensibility.Register <FolderPicker>(typeof(IFolderPickerExtension), o => new FolderPickerExtension(o)); ApiExtensibility.Register(typeof(IClipboardExtension), o => new ClipboardExtensions(o)); ApiExtensibility.Register <FileSavePicker>(typeof(IFileSavePickerExtension), o => new FileSavePickerExtension(o)); _isDispatcherThread = true; _window = new Gtk.Window("Uno Host"); Size preferredWindowSize = ApplicationView.PreferredLaunchViewSize; if (preferredWindowSize != Size.Empty) { _window.SetDefaultSize((int)preferredWindowSize.Width, (int)preferredWindowSize.Height); } else { _window.SetDefaultSize(1024, 800); } _window.SetPosition(Gtk.WindowPosition.Center); _window.Realized += (s, e) => { // Load the correct cursors before the window is shown // but after the window has been initialized. Cursors.Reload(); }; _window.DeleteEvent += delegate { Gtk.Application.Quit(); }; bool EnqueueNative(DispatcherQueuePriority priority, DispatcherQueueHandler callback) { Dispatch(() => callback()); return(true); } Windows.System.DispatcherQueue.EnqueueNativeOverride = EnqueueNative; void Dispatch(System.Action d) { if (Gtk.Application.EventsPending()) { Gtk.Application.RunIteration(false); } GLib.Idle.Add(delegate { if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Trace)) { this.Log().Trace($"Iteration"); } try { d(); } catch (Exception e) { Console.WriteLine(e); } return(false); }); } Windows.UI.Core.CoreDispatcher.DispatchOverride = Dispatch; Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride = () => _isDispatcherThread; _window.Realized += (s, e) => { WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(_window.AllocatedWidth, _window.AllocatedHeight)); }; _window.SizeAllocated += (s, e) => { WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(e.Allocation.Width, e.Allocation.Height)); }; _window.WindowStateEvent += OnWindowStateChanged; var overlay = new Overlay(); _eventBox = new EventBox(); _area = new UnoDrawingArea(); _fix = new Fixed(); overlay.Add(_area); overlay.AddOverlay(_fix); _eventBox.Add(overlay); _window.Add(_eventBox); /* avoids double invokes at window level */ _area.AddEvents((int)GtkCoreWindowExtension.RequestedEvents); _window.ShowAll(); void CreateApp(ApplicationInitializationCallbackParams _) { var app = _appBuilder(); app.Host = this; } WUX.Application.Start(CreateApp, _args); UpdateWindowPropertiesFromPackage(); Gtk.Application.Run(); }