public static void InvokeAsync(WindowContainer container, Action action, DispatcherPriority priority = DispatcherPriority.Normal, AsyncInvokeMode mode = AsyncInvokeMode.AsyncOnly)
        {
            if (container == null || !container.IsInitialized)
            {
                return;
            }

            if (container.Window != null)
            {
                InvokeAsync(container.Window, action, priority, mode);
            }
            else
            {
                InvokeAsync(container.Form, action, mode);
            }
        }
 static void DisableWindow(WindowContainer container, SplashScreenLock lockMode)
 {
     if (lockMode == SplashScreenLock.Full)
     {
         SplashScreenHelper.SetWindowEnabled(container.Handle, false);
     }
     else
     {
         UIElement visual = lockMode == SplashScreenLock.InputOnly ? container.Window : container.WindowObject as UIElement;
         if (visual != null)
         {
             visual.SetCurrentValue(UIElement.IsHitTestVisibleProperty, false);
             visual.PreviewKeyDown += OnWindowKeyDown;
         }
     }
 }
Exemple #3
0
        public static WindowContainer CreateWindowPanel(BindingSource source, string FileName = null)
        {
            var panel = new WindowContainer();

            panel.SetDataSource(source);
            if (FileName != null)
            {
                panel.Text = System.IO.Path.GetFileName(FileName) + " -> " + "Gtk::Window";
            }
            else
            {
                panel.Text = "Gtk::Window";
            }

            return(panel);
        }
Exemple #4
0
        public override void Render(SpriteBatch spriteBatch, WindowContainer windowContainer)
        {
            foreach (var tile in _tiles)
            {
                for (var x = 0; x < windowContainer.ResolutionX / _textureMaps[tile.TextureId].Width + 1; x++)
                {
                    var tilePosition = tile.Position;
                    tilePosition.X = x * _textureMaps[tile.TextureId].Width;

                    spriteBatch.Draw(_textureMaps[tile.TextureId],
                                     tilePosition,
                                     new Rectangle(0, 0, _textureMaps[tile.TextureId].Width, _textureMaps[tile.TextureId].Height),
                                     Color.White);
                }
            }
        }
Exemple #5
0
    private void Start()
    {
        /* Create a window container */
        WindowContainer winContainer = WindowContainer.Create("main");

        IUIViewLocator  locator = context.GetService <IUIViewLocator>();
        LoadingGameView window  = locator.LoadWindow <LoadingGameView>(winContainer, "UI/popup_loading");

        window.Create();
        window.Show();

        for (int i = 0; i < listPopup.Length; i++)
        {
            SmartPool.Instance.Preload(listPopup[i], 1);
        }
    }
Exemple #6
0
    /// <summary>
    /// this function is responsible for creating the various window it is passed
    /// </summary>
    /// <param name="windowScheme">Window scheme.</param>
    public GameObject CreateWindow(WindowSchematic windowScheme)
    {
        Debug.Log($"Creating the window {windowScheme.windowName}");

        // chose which window we're using
        GameObject      window    = Instantiate(windowStarter[(int)windowScheme.type], this.transform);
        WindowContainer component = window.GetComponent <WindowContainer>();

        foreach (GameObject obj in windowScheme.uiObjects)
        {
            GameObject.Instantiate(obj, component.content);
        }

        component.ShowThisWindow(windowScheme.ScreenOrder);

        return(window);
    }
Exemple #7
0
        IEnumerator Start()
        {
            /* Create a window container */
            WindowContainer winContainer = WindowContainer.Create("MAIN");

            yield return(null);

            IUIViewLocator locator = context.GetService <IUIViewLocator>();
            StartupWindow  window  = locator.LoadWindow <StartupWindow>(winContainer, "UI/Startup/Startup");

            window.Create();
            ITransition transition = window.Show().OnStateChanged((w, state) =>
            {
                //log.DebugFormat("Window:{0} State{1}",w.Name,state);
            });

            yield return(transition.WaitForDone());
        }
Exemple #8
0
        static SplashScreenLock GetActualLockMode(WindowContainer container, SplashScreenLock lockMode)
        {
            SplashScreenLock result = SplashScreenLock.None;

            if (lockMode == SplashScreenLock.Full || (lockMode == SplashScreenLock.InputOnly && container.Form != null))
            {
                result = SplashScreenLock.Full;
            }
            else if (lockMode == SplashScreenLock.LoadingContent && container.WindowObject == container.Window)
            {
                result = SplashScreenLock.InputOnly;
            }
            else if ((lockMode == SplashScreenLock.InputOnly && container.Window != null) || lockMode == SplashScreenLock.LoadingContent)
            {
                result = lockMode;
            }

            return(result);
        }
Exemple #9
0
        void CompleteContainerInitialization(WindowContainer container)
        {
            if (!container.IsInitialized)
            {
                container.Initialized += OnContainerInitialized;
                return;
            }

            if (container == Parent)
            {
                SubscribeParentEvents();
            }
            else
            {
                SubscribeChildEvents();
            }

            CompleteInitialization();
        }
Exemple #10
0
                internal void ReleaseResources()
                {
                    InternalThread = null;
                    Callbacks.Dispose();
                    Callbacks  = null;
                    Owner      = null;
                    Dispatcher = null;
                    RelationInfo.Do(x => x.Release());
                    RelationInfo         = null;
                    SplashScreen.Content = null;
                    SplashScreen         = null;
#if DEBUGTEST || DEBUG
                    WaitEvent = null;
                    if (closingTask != null && !closingTask.Task.IsCompleted)
                    {
                        closingTask.SetResult(true);
                    }
#endif
                }
        private void SetWindowCommandBindings(object viewModel, WindowContainer window)
        {
            var windowCommandsInViewModel = viewModel as IWindowCommandBindings;

            var windowCommandBindings = windowCommandsInViewModel?.WindowCommandBindings;

            if (windowCommandBindings == null)
            {
                throw new ArgumentException($"IWindowCommandBindings not implemented for ViewModel: '{viewModel.GetType().FullName}'");
            }

            window.SetWindowCommandBindings(windowCommandBindings);

            /*var baseViewModel = viewModel as BaseModel;
             *
             * if (baseViewModel == null)
             * {
             *  throw new ArgumentException($"ViewModel isn't implementing the BaseModel: '{viewModel.GetType().FullName}'");
             * }*/
        }
        internal WindowContainer CreateOwnerContainer(WindowStartupLocation splashScreenStartupLocation)
        {
            WindowContainer result = null;

            if (splashScreenStartupLocation == WindowStartupLocation.CenterOwner)
            {
                result = new WindowArrangerContainer(Owner, SplashScreenLocation.CenterWindow)
                {
                    ArrangeMode = SplashScreenArrangeMode.ArrangeOnStartupOnly
                }
            }
            ;
            if (result == null || !result.IsInitialized)
            {
                result = new WindowContainer(Owner);
            }

            return(result);
        }
    }
Exemple #13
0
        IEnumerator Start()
        {
            /* Create a window container */
            //创建一个窗口容器,默认会在全局窗口管理器中创建
            WindowContainer winContainer = WindowContainer.Create("MAIN");

            yield return(null);

            IUIViewLocator locator = context.GetService <IUIViewLocator>();
            StartupWindow  window  = locator.LoadWindow <StartupWindow>(winContainer, "UI/Startup/Startup");

            window.Create();
            //返回一个transition对象,窗口显示一般会有窗口动画,所以是一个持续过程的操作
            ITransition transition = window.Show().OnStateChanged((w, state) =>
            {
                //log.DebugFormat("Window:{0} State{1}",w.Name,state);
            });

            yield return(transition.WaitForDone());
        }
 static void EnableWindow(WindowContainer container, WindowLockInfo lockInfo)
 {
     if (lockInfo.LockMode == SplashScreenLock.Full)
     {
         SplashScreenHelper.SetWindowEnabled(container.Handle, true);
     }
     else if (lockInfo.LockMode == SplashScreenLock.InputOnly)
     {
         container.Window.IsHitTestVisible = lockInfo.IsHitTestVisible;
         container.Window.PreviewKeyDown  -= OnWindowKeyDown;
     }
     else if (lockInfo.LockMode == SplashScreenLock.LoadingContent)
     {
         FrameworkElement content = container.WindowObject as FrameworkElement;
         if (content != null)
         {
             content.PreviewKeyDown  -= OnWindowKeyDown;
             content.IsHitTestVisible = lockInfo.IsHitTestVisible;
         }
     }
 }
        public static void UnlockWindow(WindowContainer container)
        {
            if (container.Handle == IntPtr.Zero)
            {
                return;
            }

            IntPtr handle = container.Handle;

            lock (locker) {
                WindowLockInfo lockInfo;
                if (!lockedWindowsDict.TryGetValue(handle, out lockInfo))
                {
                    return;
                }

                if (--lockInfo.LockCounter == 0)
                {
                    lockedWindowsDict.Remove(handle);
                    EnableWindow(container, lockInfo);
                }
            }
        }
Exemple #16
0
        static void EnableWindow(WindowContainer container, ContainerLockInfo lockInfo)
        {
            switch (lockInfo.LockMode)
            {
            case SplashScreenLock.InputOnly:
                container.Window.IsHitTestVisible = lockInfo.IsHitTestVisible;
                container.Window.PreviewKeyDown  -= OnWindowKeyDown;
                break;

            case SplashScreenLock.Full:
                SplashScreenHelper.SetWindowEnabled(container.Handle, true);
                break;

            case SplashScreenLock.LoadingContent:
                FrameworkElement content = container.WindowObject as FrameworkElement;
                if (content != null)
                {
                    content.PreviewKeyDown  -= OnWindowKeyDown;
                    content.IsHitTestVisible = lockInfo.IsHitTestVisible;
                }
                break;
            }
        }
        private static void StoreInternal(WindowContainer container, Window instance)
        {
            if (double.IsInfinity(instance.RestoreBounds.Left) == false)
            {
                container.Left = (int)instance.RestoreBounds.Left;
            }

            if (double.IsInfinity(instance.RestoreBounds.Top) == false)
            {
                container.Top = (int)instance.RestoreBounds.Top;
            }

            if (double.IsInfinity(instance.RestoreBounds.Width) == false)
            {
                container.Width = (int)instance.RestoreBounds.Width;
            }

            if (double.IsInfinity(instance.RestoreBounds.Height) == false)
            {
                container.Height = (int)instance.RestoreBounds.Height;
            }

            container.IsMaximized = instance.WindowState == WindowState.Maximized;
        }
        public void Release(bool activateWindowIfNeeded)
        {
            if (Container == null)
            {
                return;
            }

            Container.Initialized -= OnOwnerInitialized;
            var container = Container;

            Container = null;
            if (lockMode == SplashScreenLock.None)
            {
                return;
            }

            if (container.Form != null && container.Form.IsDisposed)
            {
                UnlockContainer(container);
            }
            else
            {
                SplashScreenHelper.InvokeAsync(container, () => {
                    bool activateWindow = activateWindowIfNeeded && !SplashScreenHelper.ApplicationHasActiveWindow();
                    UnlockContainer(container);
                    if (activateWindow)
                    {
                        container.ActivateWindow();
                    }
                    else if (Keyboard.FocusedElement == null)
                    {
                        SplashScreenHelper.GetApplicationActiveWindow(false).Do(x => x.Focus());
                    }
                }, DispatcherPriority.Render);
            }
        }
        private static bool?ShowInternal <T>(bool isModal, object argument) where T : Window
        {
            WindowContainer container = RestorePositionInternal <T>();
            Window          window    = container.Instance;

            if (window is IWindow win)
            {
                win.OnOpen(window.IsVisible, argument);
            }

            FitInScreen(window);

            if (isModal)
            {
                return(window.ShowDialog());
            }
            else
            {
                window.Show();
                window.Activate();

                return(true);
            }
        }
Exemple #20
0
 protected internal WindowRelationInfo(WindowContainer parent)
 {
     AttachParent(parent);
 }
 void CreateLocker(WindowContainer parentContainer, SplashScreenLock lockMode) {
     ParentLocker = new ContainerLocker(parentContainer, lockMode);
 }
Exemple #22
0
 public override void Render(SpriteBatch spriteBatch, WindowContainer windowContainer)
 {
     spriteBatch.Draw(_texture, Vector2.One, new Rectangle(0, 0, windowContainer.ResolutionX, windowContainer.ResolutionY), Color.White);
 }
Exemple #23
0
 public override void Render(SpriteBatch spriteBatch, WindowContainer windowContainer)
 {
     spriteBatch.Draw(_airplaneTexture, Position, Color.White);
 }
 void CreateLocker(WindowContainer parentContainer, SplashScreenLock lockMode)
 {
     ParentLocker = new ContainerLocker(parentContainer, lockMode);
 }
 private void Awake()
 {
     Instance = this;
 }
Exemple #26
0
 public AsyncReducer(
     int windowSize,
     IAsyncReducer <TReduction, IList <T> > next) : base(next)
 {
     Container = new WindowContainer(windowSize);
 }
        /// <summary>
        /// </summary>
        private void CreateSubHeaders()
        {
            SubHeaderBackground = new Sprite
            {
                Parent    = CustomizeContainer,
                Y         = 2,
                Alignment = Alignment.TopCenter,
                Size      = new ScalableVector2(CustomizeContainer.Width - 4, 47),
                Tint      = ColorHelper.HexToColor("#212121")
            };

            // ReSharper disable once ObjectCreationAsStatement
            new SpriteTextBitmap(FontsBitmap.GothamRegular, "Presets")
            {
                Parent    = SubHeaderBackground,
                Alignment = Alignment.MidLeft,
                X         = 18,
                FontSize  = 18
            };

            var addButton = new BorderedTextButton("Add", Color.Lime, (sender, args) =>
            {
                var windows = new JudgementWindows()
                {
                    Name = "Preset"
                };

                var presetCount = JudgementWindowsDatabaseCache.Presets.FindAll(x => !x.IsDefault).Count;
                JudgementWindowsDatabaseCache.Insert(windows);

                windows.Name = $"Preset {presetCount + 1}";
                JudgementWindowsDatabaseCache.Update(windows);

                WindowContainer.AddObject(windows);
                JudgementWindowsDatabaseCache.Selected.Value = windows;
            })
            {
                Parent    = SubHeaderBackground,
                Alignment = Alignment.MidRight,
                X         = -15,
                Text      =
                {
                    FontSize = 14,
                    Font     = Fonts.Exo2SemiBold
                }
            };

            addButton.Size = new ScalableVector2(addButton.Width * 0.85f, addButton.Height * 0.85f);

            EditButton = new BorderedTextButton("Edit Name", Color.Yellow, (sender, args) =>
            {
                DialogManager.Show(new JudgementWindowRenameDialog(JudgementWindowsDatabaseCache.Selected.Value, WindowContainer));
            })
            {
                Parent    = SubHeaderBackground,
                Alignment = Alignment.MidRight,
                X         = addButton.X - addButton.Width - 12,
                Text      =
                {
                    FontSize = 14,
                    Font     = Fonts.Exo2SemiBold
                }
            };

            EditButton.Size = new ScalableVector2(EditButton.Width * 0.85f, EditButton.Height * 0.85f);

            DeleteButton = new BorderedTextButton("Delete", Color.Crimson, (sender, args) =>
            {
                var index = JudgementWindowsDatabaseCache.Presets.IndexOf(JudgementWindowsDatabaseCache.Selected.Value);

                JudgementWindowsDatabaseCache.Delete(JudgementWindowsDatabaseCache.Selected.Value);
                WindowContainer.Remove(JudgementWindowsDatabaseCache.Selected.Value);

                JudgementWindowsDatabaseCache.Selected.Value = JudgementWindowsDatabaseCache.Presets[index - 1];
            })
            {
                Parent    = SubHeaderBackground,
                Alignment = Alignment.MidRight,
                X         = EditButton.X - EditButton.Width - 12,
                Text      =
                {
                    FontSize = 14,
                    Font     = Fonts.Exo2SemiBold
                }
            };

            DeleteButton.Size = new ScalableVector2(DeleteButton.Width * 0.85f, DeleteButton.Height * 0.85f);

            ResetToDefaultButton = new BorderedTextButton("Reset", Color.Orange, (sender, args) =>
            {
                Sliders[Judgement.Marv].BindedValue.Value  = (int)JudgementWindowsDatabaseCache.Standard.Marvelous;
                Sliders[Judgement.Perf].BindedValue.Value  = (int)JudgementWindowsDatabaseCache.Standard.Perfect;
                Sliders[Judgement.Great].BindedValue.Value = (int)JudgementWindowsDatabaseCache.Standard.Great;
                Sliders[Judgement.Good].BindedValue.Value  = (int)JudgementWindowsDatabaseCache.Standard.Good;
                Sliders[Judgement.Okay].BindedValue.Value  = (int)JudgementWindowsDatabaseCache.Standard.Okay;
                Sliders[Judgement.Miss].BindedValue.Value  = (int)JudgementWindowsDatabaseCache.Standard.Miss;
            })
            {
                Parent    = SubHeaderBackground,
                Alignment = Alignment.MidRight,
                X         = DeleteButton.X - DeleteButton.Width - 12,
                Text      =
                {
                    FontSize = 14,
                    Font     = Fonts.Exo2SemiBold
                }
            };

            ResetToDefaultButton.Size = new ScalableVector2(ResetToDefaultButton.Width * 0.85f, ResetToDefaultButton.Height * 0.85f);
        }
Exemple #28
0
        public void FirstUpdate(string name, Size size, ref bool open, double backgroundAlpha,
                                WindowFlags flags,
                                long currentFrame, Window parentWindow)
        {
            //short names
            var g = Application.ImGuiContext;
            var w = g.WindowManager;

            this.Active          = true;
            this.BeginCount      = 0;
            this.LastActiveFrame = currentFrame;

            // update viewport
            UpdateWindowViewport(this);
            w.CurrentViewport = Viewport;
            if (Viewport != null)
            {
                Viewport.LastFrameActive = g.FrameCount;
            }

            // determine if window is collapsed
            if (!flags.HaveFlag(WindowFlags.NoTitleBar) && !flags.HaveFlag(WindowFlags.NoCollapse))
            {
                // Collapse window by double-clicking on title bar
                if (w.HoveredWindow == this && g.IsMouseHoveringRect(this.TitleBarRect) &&
                    Mouse.Instance.LeftButtonDoubleClicked)
                {
                    this.Collapsed = !this.Collapsed;
                    w.FocusWindow(this);
                    open = !this.Collapsed; //overwrite the open state
                }
            }

            this.Collapsed = !open;

            //window container
            using (var dc = WindowContainer.RenderOpen())
            {
                dc.DrawBoxModel(WindowContainer);
            }

            //update title bar
            var windowRounding = (float)this.WindowContainer.RuleSet.Get <double>(StylePropertyName.WindowRounding);

            if (!flags.HaveFlag(WindowFlags.NoTitleBar))
            {
                // background
                using (var dc = this.titleBar.RenderOpen())
                {
                    dc.DrawBoxModel(this.titleBar.RuleSet, this.titleBar.Rect);
                }

                //icon
                using (var dc = titleIcon.RenderOpen())
                {
                    dc.DrawImage(@"assets/images/logo.png", this.titleIcon.Rect);
                }

                //title
                using (var dc = titleText.RenderOpen())
                {
                    dc.DrawGlyphRun(titleText.RuleSet, this.Name, titleText.Rect.TopLeft);
                }
            }

            this.ShowWindowClientArea(!this.Collapsed);

            if (!this.Collapsed)
            {
                //show and update window client area
                using (var dc = clientArea.RenderOpen())
                {
                    dc.DrawBoxModel(clientArea);
                }

                if (!flags.HaveFlag(WindowFlags.NoResize))
                {
                    if (this.ResizeGripNode == null)
                    {
                        var id   = this.GetID("#RESIZE");
                        var node = new Node(id, "Window_ResizeGrip");
                        this.ResizeGripNode = node;
                        this.AbsoluteVisualList.Add(node);
                    }

                    //resize grip
                    this.ResizeGripNode.ActiveSelf = true;
                    var resizeGripColor = Color.Clear;
                    var br = this.Rect.BottomRight;
                    if (!flags.HaveFlag(WindowFlags.AlwaysAutoResize) && !flags.HaveFlag(WindowFlags.NoResize))
                    {
                        // Manual resize
                        var resizeRect = new Rect(
                            br - new Vector(this.WindowContainer.PaddingLeft + this.WindowContainer.BorderLeft,
                                            this.WindowContainer.PaddingBottom + this.WindowContainer.BorderLeft),
                            br);
                        var resizeId = this.GetID("#RESIZE");
                        GUIBehavior.ButtonBehavior(resizeRect, resizeId, out var hovered, out var held,
                                                   ButtonFlags.FlattenChilds);
                        resizeGripColor =
                            held
                                ? this.WindowContainer.RuleSet.Get <Color>(StylePropertyName.ResizeGripColor, GUIState.Active)
                                : hovered
                                    ? this.WindowContainer.RuleSet.Get <Color>(StylePropertyName.ResizeGripColor, GUIState.Hover)
                                    : this.WindowContainer.RuleSet.Get <Color>(StylePropertyName.ResizeGripColor);

                        if (hovered || held)
                        {
                            Mouse.Instance.Cursor = (Cursor.NwseResize);
                        }
                        else
                        {
                            Mouse.Instance.Cursor = (Cursor.Default);
                        }

                        if (held)
                        {
                            // We don't use an incremental MouseDelta but rather compute an absolute target size based on mouse position
                            var t             = Mouse.Instance.Position - g.ActiveIdClickOffset - this.Position;
                            var newSizeWidth  = t.X + resizeRect.Width;
                            var newSizeHeight = t.Y + resizeRect.Height;
                            var resizeSize    = new Size(newSizeWidth, newSizeHeight);
                            this.ApplySize(resizeSize);
                        }
                    }

                    // Render resize grip
                    // (after the input handling so we don't have a frame of latency)
                    var borderBottom  = this.WindowContainer.RuleSet.BorderBottom;
                    var paddingBottom = this.WindowContainer.RuleSet.PaddingBottom;
                    var borderRight   = this.WindowContainer.RuleSet.BorderRight;
                    var paddingRight  = this.WindowContainer.RuleSet.PaddingRight;
                    using (var dc = this.ResizeGripNode.RenderOpen())
                    {
                        var path   = new PathGeometry();
                        var figure = new PathFigure();
                        var A      = br + new Vector(-10 - borderRight - paddingRight, 0);
                        var B      = br + new Vector(0, -10 - borderBottom - paddingBottom);
                        figure.StartPoint = A;
                        figure.IsFilled   = true;
                        figure.Segments.Add(new LineSegment(B, false));
                        figure.Segments.Add(new LineSegment(br, false));
                        figure.Segments.Add(new LineSegment(A, false));
                        path.Figures.Add(figure);
                        dc.DrawGeometry(new Brush(resizeGripColor), null, path);
                    }
                }

                this.ContentRect = Rect.Zero;
            }
        }
Exemple #29
0
 public override void Render(SpriteBatch spriteBatch, WindowContainer windowContainer)
 {
     base.Render(spriteBatch, windowContainer);
 }
 public void SplashScreenOwner_Test04() {
     var owner = new WindowContainer(new Border());
     DXSplashScreen.Show(CreateDefaultWindow, CreateDefaultContent, new object[] { owner.CreateOwnerContainer() }, null);
     var info = DXSplashScreen.SplashContainer.ActiveInfo;
     Assert.AreEqual(owner, info.Owner);
     Assert.IsNotNull(info.InternalThread);
     Assert.IsFalse(info.Owner.IsInitialized);
     CloseDXSplashScreen();
 }
 public abstract void Render(SpriteBatch spriteBatch, WindowContainer windowContainer);