Beispiel #1
0
        /// <inheritdoc/>
        protected override void SetViewInternal(NavigationRequest request, UIElement view)
        {
            if (request.IsCloseRequest)
            {
                if (UILayers.Count > 1)
                {
                    if (CurrentElement is Window dialog)
                    {
                        dialog.Close();
                    }

                    UILayers.RemoveAt(UILayers.Count - 1);
                }
                else
                {
                    throw new InvalidOperationException("Cannot remove root content layer in close operation.");
                }
            }
            else
            {
                if (request.Properties.LayerMode == LayerBehavior.Modal)
                {
                    var dialog = new Window()
                    {
                        Content               = view,
                        WindowStyle           = WindowStyle.None,
                        ShowInTaskbar         = false,
                        MinHeight             = 200,
                        MinWidth              = 300,
                        SizeToContent         = SizeToContent.WidthAndHeight,
                        ResizeMode            = ResizeMode.NoResize,
                        WindowStartupLocation = WindowStartupLocation.CenterOwner
                    };

                    UILayers.Add(dialog);
                    dialog.Closing += DialogClosing;
                    dialog.ShowDialog();
                }
                else if (request.Properties.LayerMode == LayerBehavior.Default)
                {
                    CurrentElement.Content = view;
                }
                else if (request.Properties.LayerMode == LayerBehavior.Shell)
                {
                    if (view is ILayerContainer container)
                    {
                        CurrentElement.Content = container;
                        UILayers.Add(container.Container);
                    }
                    else
                    {
                        throw new ArgumentException("WPF apps require all new navigation layers be created in ILayerContainers.", nameof(view));
                    }
                }
                else
                {
                    throw new ArgumentException($"WPF apps currently do not have support for the given LayerMode {request.Properties.LayerMode}.", nameof(request));
                }
            }
        }
    public void OpenView(int viewName, object data = null, UILayers layer = UILayers.First)
    {
        ViewModuleData _viewModuleData = null;

        if (m_viewModuleDatas.TryGetValue(viewName, out _viewModuleData))
        {
            if (_viewModuleData.m_gameObject == null)
            {
                _viewModuleData.m_gameObject = _viewModuleData.m_viewModule.OnCreate();
            }

            GameObject _prefab = GetGameObjectByUILayers(layer);
            if (_prefab != null)
            {
                RectTransform trans = (RectTransform)_viewModuleData.m_gameObject.transform;
                trans.SetParent(_prefab.transform);
                trans.sizeDelta     = Vector3.zero;
                trans.localScale    = Vector3.one;
                trans.localPosition = Vector3.zero;
                trans.localRotation = Quaternion.identity;

                _viewModuleData.m_gameObject.SetActive(true);
                trans.SetAsLastSibling();

                _viewModuleData.m_uiLayers = layer;
                _viewModuleData.m_viewModule.OnOpen(data);
                _viewModuleData.m_viewModule.RegisterEvents(m_eventSystemManager);
                _viewModuleData.m_isOpened = true;
            }
            else
            {
                Debug.LogError("layer gameObject is null");
            }
        }
    }
Beispiel #3
0
        /// <inheritdoc/>
        public override void StartUI()
        {
            var myWindow = new Window();

            Application.Current.MainWindow = myWindow;
            UILayers.Add(myWindow);
            myWindow.Show();
        }
    public void CloseAllView(UILayers uiLayers)
    {
        var _item = m_viewModuleDatas.GetEnumerator();

        while (_item.MoveNext())
        {
            if (_item.Current.Value.m_isOpened)
            {
                if (_item.Current.Value.m_uiLayers == uiLayers)
                {
                    CloseView(_item.Current.Key);
                }
            }
        }
    }
    public GameObject GetGameObjectByUILayers(UILayers uilayer)
    {
        GameObject _object = null;

        if (Pool != null)
        {
            int _index = (int)uilayer;
            if (_index < m_layerObjects.Length)
            {
                _object = m_layerObjects[_index];
            }
        }

        return(_object);
    }
Beispiel #6
0
    Transform Layer(UILayers layer)
    {
        switch (layer)
        {
        case UILayers.Bottom: return(bottom);

        case UILayers.Mid: return(mid);

        case UILayers.Top: return(top);

        case UILayers.System: return(system);

        case UILayers.HUD: return(hud);

        default: return(null);
        }
    }
Beispiel #7
0
        /// <inheritdoc/>
        public override void StartUI()
        {
            Frame rootFrame = Window.Current.Content as Frame;

            //// Do not repeat app initialization when the Window already has content,
            //// just ensure that the window is active
            if (rootFrame == null)
            {
                //// Create a Frame to act as the navigation context.
                rootFrame = new Frame();
                Window.Current.Content = rootFrame;
            }

            UILayers.Add(rootFrame);

            //// Ensure the current window is active before setting up back navigation.
            Window.Current.Activate();
        }
        private void ShowUILayers(
            UILayers uiLayers,
            int level,
            List <Layer> layers
            )
        {
            string indentation = GetIndentation(level);

            foreach (IUILayerNode layerNode in uiLayers)
            {
                ShowLayer(layerNode, layers.Count, indentation);

                if (layerNode is Layer)
                {
                    layers.Add((Layer)layerNode);
                }

                ShowUILayers(layerNode.Children, level + 1, layers);
            }
        }
Beispiel #9
0
        /**
         * <summary>Populates a PDF file with contents.</summary>
         */
        private void Populate(Document document)
        {
            // Initialize a new page!
            Page page = new Page(document);

            document.Pages.Add(page);

            // Initialize the primitive composer (within the new page context)!
            PrimitiveComposer composer = new PrimitiveComposer(page);

            composer.SetFont(PdfType1Font.Load(document, PdfType1Font.FamilyEnum.Helvetica, true, false), 12);

            // Initialize the block composer (wrapping the primitive one)!
            BlockComposer blockComposer = new BlockComposer(composer);

            // Initialize the document layer configuration!
            LayerDefinition layerDefinition = document.Layer;

            document.ViewerPreferences.PageMode = ViewerPreferences.PageModeEnum.Layers; // Shows the layers tab on document opening.

            // Get the root collection of the layers displayed to the user!
            UILayers uiLayers = layerDefinition.UILayers;

            // Nested layers.
            Layer parentLayer;
            {
                parentLayer = new Layer(document, "Parent layer");
                uiLayers.Add(parentLayer);
                var childLayers = parentLayer.Children;

                var childLayer1 = new Layer(document, "Child layer 1");
                childLayers.Add(childLayer1);

                var childLayer2 = new Layer(document, "Child layer 2");
                childLayers.Add(childLayer2);
                childLayer2.Locked = true;

                /*
                 * NOTE: Graphical content can be controlled through layers in two ways:
                 * 1) marking content within content streams (that is content within the page body);
                 * 2) associating annotations and external objects (XObject) to the layers.
                 */

                XObject imageXObject = entities::Image.Get(GetResourcePath("images" + Path.DirectorySeparatorChar + "gnu.jpg")).ToXObject(document);
                imageXObject.Layer = childLayer1; // Associates the image to the layer.

                composer.ShowXObject(imageXObject, new SKPoint(200, 75));

                composer.BeginLayer(parentLayer); // Opens a marked block associating its contents with the specified layer.
                composer.ShowText(parentLayer.Title, new SKPoint(50, 50));
                composer.End();                   // Closes the marked block.

                composer.BeginLayer(childLayer1);
                composer.ShowText(childLayer1.Title, new SKPoint(50, 75));
                composer.End();

                composer.BeginLayer(childLayer2);
                composer.ShowText(childLayer2.Title, new SKPoint(50, 100));
                composer.End();
            }

            // Simple layer collection (labeled collection of inclusive-state layers).
            Layer simpleLayer1;
            {
                var simpleLayerCollection = new LayerCollection(document, "Simple layer collection");
                uiLayers.Add(simpleLayerCollection);

                simpleLayer1 = new Layer(document, "Simple layer 1");
                simpleLayerCollection.Add(simpleLayer1);

                var simpleLayer2 = new Layer(document, "Simple layer 2 (Design)");

                /*
                 * NOTE: Intent limits layer use in determining visibility to specific use contexts. In this
                 * case, we want to mark content as intended to represent a document designer's structural
                 * organization of artwork, hence it's outside the interactive use by document consumers.
                 */
                simpleLayer2.Intents = new HashSet <PdfName> {
                    IntentEnum.Design.Name()
                };
                simpleLayerCollection.Add(simpleLayer2);

                var simpleLayer3 = new Layer(document, "Simple layer 3");
                simpleLayerCollection.Add(simpleLayer3);

                blockComposer.Begin(SKRect.Create(50, 125, 200, 75), XAlignmentEnum.Left, YAlignmentEnum.Middle);

                composer.BeginLayer(simpleLayer1);
                blockComposer.ShowText(simpleLayer1.Title);
                composer.End();

                blockComposer.ShowBreak(new SKSize(0, 10));

                composer.BeginLayer(simpleLayer2);
                blockComposer.ShowText(simpleLayer2.Title);
                composer.End();

                blockComposer.ShowBreak(new SKSize(0, 10));

                composer.BeginLayer(simpleLayer3);
                blockComposer.ShowText(simpleLayer3.Title);
                composer.End();

                blockComposer.End();
            }

            // Radio layer collection (labeled collection of exclusive-state layers).
            Layer radioLayer2;

            {
                var radioLayerCollection = new LayerCollection(document, "Radio layer collection");
                uiLayers.Add(radioLayerCollection);

                var radioLayer1 = new Layer(document, "Radio layer 1")
                {
                    Visible = true
                };
                radioLayerCollection.Add(radioLayer1);

                radioLayer2 = new Layer(document, "Radio layer 2")
                {
                    Visible = false
                };
                radioLayerCollection.Add(radioLayer2);

                var radioLayer3 = new Layer(document, "Radio layer 3")
                {
                    Visible = false
                };
                radioLayerCollection.Add(radioLayer3);

                // Register this option group in the layer configuration!
                var optionGroup = new OptionGroup(document)
                {
                    radioLayer1, radioLayer2, radioLayer3
                };
                layerDefinition.OptionGroups.Add(optionGroup);

                blockComposer.Begin(SKRect.Create(50, 200, 200, 75), XAlignmentEnum.Left, YAlignmentEnum.Middle);

                composer.BeginLayer(radioLayer1);
                blockComposer.ShowText(radioLayer1.Title);
                composer.End();

                blockComposer.ShowBreak(new SKSize(0, 10));

                composer.BeginLayer(radioLayer2);
                blockComposer.ShowText(radioLayer2.Title);
                composer.End();

                blockComposer.ShowBreak(new SKSize(0, 10));

                composer.BeginLayer(radioLayer3);
                blockComposer.ShowText(radioLayer3.Title);
                composer.End();

                blockComposer.End();
            }

            // Layer state action.
            {
                var actionLayer = new Layer(document, "Action layer")
                {
                    Printable = false
                };

                composer.BeginLayer(actionLayer);
                composer.BeginLocalState();
                composer.SetFillColor(colors::DeviceRGBColor.Get(SKColors.Blue));
                composer.ShowText(
                    "Layer state action:\n * deselect \"" + simpleLayer1.Title + "\"\n   and \"" + radioLayer2.Title + "\"\n * toggle \"" + parentLayer.Title + "\"",
                    new SKPoint(400, 200),
                    XAlignmentEnum.Left,
                    YAlignmentEnum.Middle,
                    0,
                    new SetLayerState(
                        document,
                        new SetLayerState.LayerState(SetLayerState.StateModeEnum.Off, simpleLayer1, radioLayer2),
                        new SetLayerState.LayerState(SetLayerState.StateModeEnum.Toggle, parentLayer)
                        )
                    );
                composer.End();
                composer.End();
            }

            // Zoom-restricted layer.
            {
                var zoomRestrictedLayer = new Layer(document, "Zoom-restricted layer")
                {
                    ZoomRange = new Interval <double>(.75, 1.251)
                };                                                // NOTE: Change this interval to test other magnification ranges.

                composer.BeginLayer(zoomRestrictedLayer);
                new TextMarkup(
                    page,
                    composer.ShowText(zoomRestrictedLayer.Title + ": this text is only visible if zoom between 75% and 125%", new SKPoint(50, 290)),
                    "This is a highlight annotation visible only if zoom is between 75% and 125%",
                    TextMarkupType.Highlight
                    )
                {
                    Layer = zoomRestrictedLayer /* Associates the annotation to the layer. */
                };
                composer.End();
            }

            // Print-only layer.
            {
                var printOnlyLayer = new Layer(document, "Print-only layer")
                {
                    Visible   = false,
                    Printable = true
                };

                composer.BeginLayer(printOnlyLayer);
                composer.BeginLocalState();
                composer.SetFillColor(colors::DeviceRGBColor.Get(SKColors.Red));
                composer.ShowText(printOnlyLayer.Title, new SKPoint(25, 300), XAlignmentEnum.Left, YAlignmentEnum.Top, 90);
                composer.End();
                composer.End();
            }

            // Language-specific layer.
            {
                var languageLayer = new Layer(document, "Language-specific layer")
                {
                    Language          = new LanguageIdentifier("en-GB"), // NOTE: Change this to test other languages and locales.
                    LanguagePreferred = true,                            // Matches any system locale (e.g. en-US, en-AU...) if layer language (en-GB) doesn't match exactly the system language.
                    Printable         = false
                };

                blockComposer.Begin(SKRect.Create(50, 320, 500, 75), XAlignmentEnum.Left, YAlignmentEnum.Top);

                composer.BeginLayer(languageLayer);
                blockComposer.ShowText(languageLayer.Title + ": this text is visible only if current system language is english (\"en\", any locale (\"en-US\", \"en-GB\", \"en-NZ\", etc.)) and is hidden on print.");
                composer.End();

                blockComposer.End();
            }

            // User-specific layer.
            {
                var userLayer = new Layer(document, "User-specific layer")
                {
                    Users = new List <string> {
                        "Lizbeth", "Alice", "Stefano", "Johann"
                    },                                                                    // NOTE: Change these entries to test other user names.
                    UserType = Layer.UserTypeEnum.Individual
                };

                blockComposer.Begin(SKRect.Create(blockComposer.BoundBox.Left, blockComposer.BoundBox.Bottom + 15, blockComposer.BoundBox.Width, 75), XAlignmentEnum.Left, YAlignmentEnum.Top);

                composer.BeginLayer(userLayer);
                blockComposer.ShowText(userLayer.Title + ": this text is visible only to " + String.Join(", ", userLayer.Users) + " (exact match).");
                composer.End();

                blockComposer.End();
            }

            // Layer membership (composite layer visibility).
            {
                var layerMembership = new LayerMembership(document)
                {
                    /*
                     * NOTE: VisibilityExpression is a more flexible alternative to the combination of
                     * VisibilityPolicy and VisibilityMembers. However, for compatibility purposes is preferable
                     * to provide both of them (the latter combination will work as a fallback in case of older
                     * viewer application).
                     */
                    VisibilityExpression = new VisibilityExpression(
                        document,
                        VisibilityExpression.OperatorEnum.And,
                        new VisibilityExpression(
                            document,
                            VisibilityExpression.OperatorEnum.Not,
                            new VisibilityExpression(
                                document,
                                VisibilityExpression.OperatorEnum.Or,
                                simpleLayer1,
                                radioLayer2
                                )
                            ),
                        parentLayer
                        ),
                    VisibilityPolicy  = LayerMembership.VisibilityPolicyEnum.AnyOff,
                    VisibilityMembers = new List <Layer> {
                        simpleLayer1, radioLayer2, parentLayer
                    }
                };

                blockComposer.Begin(SKRect.Create(blockComposer.BoundBox.Left, blockComposer.BoundBox.Bottom + 15, blockComposer.BoundBox.Width, 75), XAlignmentEnum.Left, YAlignmentEnum.Top);

                composer.BeginLayer(layerMembership);
                blockComposer.ShowText(String.Format("Layer membership: the visibility of this text is computed combining multiple layer states into an expression (\"{0}\" and \"{1}\" must be OFF while \"{2}\" must be ON).", simpleLayer1.Title, radioLayer2.Title, parentLayer.Title));
                composer.End();

                blockComposer.End();
            }

            composer.Flush();
        }
Beispiel #10
0
        private void Property()
        {
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("创建者:", GUILayout.Width(50));
                creaters = (Developer)EditorGUILayout.EnumPopup(creaters, GUILayout.Width(150));
                GUILayout.Space(50);

                EditorGUILayout.LabelField("是游戏模块", GUILayout.Width(80));
                isGameModule = EditorGUILayout.Toggle(isGameModule, GUILayout.Width(50));
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            if (!isGameModule)
            {
                EditorGUILayout.BeginHorizontal();
                {
                    useMVC = EditorGUILayout.Toggle(useMVC, GUILayout.Width(12));
                    EditorGUILayout.LabelField("使用MVC", GUILayout.Width(100));
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.Space();

                if (useMVC)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.BeginVertical();
                        {
                            EditorGUILayout.BeginHorizontal();
                            {
                                EditorGUILayout.LabelField("开启View", GUILayout.Width(100));
                                useView = EditorGUILayout.Toggle(useView, GUILayout.Width(150));
                            }
                            EditorGUILayout.EndHorizontal();
                            if (useView)
                            {
                                EditorGUILayout.BeginHorizontal();
                                {
                                    EditorGUILayout.LabelField("UI层级:", GUILayout.Width(100));
                                    layer = (UILayers)EditorGUILayout.EnumPopup(layer, GUILayout.Width(150));
                                }
                                EditorGUILayout.EndHorizontal();
                                EditorGUILayout.BeginHorizontal();
                                {
                                    EditorGUILayout.LabelField("生成Prefab模板", GUILayout.Width(100));
                                    useView_Prefab = EditorGUILayout.Toggle(useView_Prefab, GUILayout.Width(150));
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                        EditorGUILayout.EndVertical();

                        EditorGUILayout.BeginVertical();
                        {
                            useData = EditorGUILayout.Toggle("开启Data", useData, GUILayout.Width(200));
                        }
                        EditorGUILayout.EndVertical();
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                EditorGUILayout.LabelField("UI层级:");
                layer = (UILayers)EditorGUILayout.EnumPopup(layer, GUILayout.Width(200));
                EditorGUILayout.Space();
                isUseNode = EditorGUILayout.Toggle("使用节点:", isUseNode);
                if (isUseNode)
                {
                    for (int i = 0; i < useNodes.Count; i++)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.LabelField("节点名称:", GUILayout.Width(80));
                            useNodes[i] = EditorGUILayout.TextField(useNodes[i], GUILayout.Width(300));
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    EditorGUILayout.BeginHorizontal();
                    {
                        if (GUILayout.Button("添加", GUILayout.Width(100)))
                        {
                            useNodes.Add(string.Empty);
                        }
                        if (GUILayout.Button("移除", GUILayout.Width(100)))
                        {
                            if (useNodes.Count > 0)
                            {
                                useNodes.RemoveAt(useNodes.Count - 1);
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Space();
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("模块名称:", GUILayout.Width(100));
                createModuleName = EditorGUILayout.TextField(createModuleName);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("内容简介:");
            contents = EditorGUILayout.TextArea(contents, GUILayout.MinHeight(150));

            GUILayout.Space(20);
        }
Beispiel #11
0
        /// <inheritdoc/>
        protected override void SetViewInternal(NavigationRequest request, UIElement view)
        {
            if (request.IsCloseRequest)
            {
                if (UILayers.Count > 1)
                {
                    if (CurrentElement is ContentDialog dialog)
                    {
                        SynchronousTask hideTask = new SynchronousTask(
                            () => Dispatchers.RunOnUIThreadAsync(
                                () => dialog.Hide()));
                        hideTask.RunTask();
                    }

                    UILayers.RemoveAt(UILayers.Count - 1);
                }
                else
                {
                    throw new InvalidOperationException("Cannot remove root content layer in close operation.");
                }
            }
            else
            {
                if (request.Properties.LayerMode == LayerBehavior.Modal)
                {
                    ContentDialog dialog = new ContentDialog()
                    {
                        Title   = null,
                        Content = view,
                        Padding = new Thickness(0),
                        Margin  = new Thickness(0)
                    };
                    UILayers.Add(dialog);
                    dialog.CloseButtonClick += DialogClosed;

                    SynchronousTask showTask = new SynchronousTask(
                        () => Dispatchers.RunOnUIThreadAsync(
                            () => ShowDialogTask(dialog)));
                    showTask.RunTask();
                }
                else if (request.Properties.LayerMode == LayerBehavior.Default)
                {
                    CurrentElement.Content = view;
                }
                else if (request.Properties.LayerMode == LayerBehavior.Shell)
                {
                    if (view is ILayerContainer container)
                    {
                        CurrentElement.Content = container;
                        UILayers.Add(container.Container);
                    }
                    else
                    {
                        throw new ArgumentException("UWP apps require all new navigation layers be created in ILayerContainers.", nameof(view));
                    }
                }
                else
                {
                    throw new ArgumentException($"UWP apps currently do not have support for the given LayerMode {request.Properties.LayerMode}.", nameof(request));
                }
            }
        }
Beispiel #12
0
 public static void OpenView(this ViewModuleManager manager, ViewName name, object data = null, UILayers layer = UILayers.First)
 {
     manager.OpenView((int)name, data, layer);
 }