Beispiel #1
0
        YogaNode CreateYogaNode(Box ui, YogaConfig config, bool updateMode)
        {
            LayoutInstance instance = ui.LayoutInstance;

            if (instance is YogaLayoutInstance inst)
            {
                if (inst.YogaNode == null)
                {
                    //create yoga node
                    YogaNode node = new YogaNode(config);
                    inst.SetNode(node);
                }

                //already has node
                foreach (UIElement childUI in ui.GetChildIter())
                {
                    if (childUI is Box childBox)
                    {
                        inst.YogaNode.Append(CreateYogaNode(childBox, config, updateMode));
                    }
                }
                return(inst.YogaNode);
            }
            return(null);
        }
 public SlotContent(LayoutInstance layoutInstance, string slotName)
 {
     this.ParentSite = layoutInstance;
     this.SlotName = slotName;
     this.layoutControl = layoutInstance.LayoutControl;
 }
        void IActivationSite.NotifyActivation(object child)
        {
            var layoutInstance = child as LayoutInstance;

            if (layoutInstance != null)
            {
                this.lastActiveLayout = layoutInstance;
            }
        }
        void IActivationSite.BubbleActivation(object child)
        {
            var layoutInstance = child as LayoutInstance;

            if (layoutInstance != null && this.Items.Contains(layoutInstance))
            {
                this.lastActiveLayout = layoutInstance;
                this.SelectedIndex = this.Items.IndexOf(layoutInstance);
            }
        }
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            var tabItem = element as TabItem;
            var data = item as LayoutInstance;

            if (tabItem == null)
            {
                base.PrepareContainerForItemOverride(element, item);
                return;
            }

            if (data != null)
            {
                var headerBinding = new Binding { Source = data.LayoutDefinition, Path = new PropertyPath(LayoutDefinition.HeaderProperty), Mode = BindingMode.TwoWay };
                tabItem.SetBinding(TabItem.HeaderProperty, headerBinding);
                tabItem.SetBinding(System.Windows.Automation.AutomationProperties.AutomationIdProperty, headerBinding);
                tabItem.Content = data.LayoutControl;
            }
            else if (item is LayoutDefinition)
            {
                var tabData = item as LayoutDefinition;
                var headerBinding = new Binding { Source = tabData, Path = new PropertyPath(LayoutDefinition.HeaderProperty), Mode = BindingMode.TwoWay };

                tabItem.SetBinding(TabItem.HeaderProperty, headerBinding);
                tabItem.SetBinding(System.Windows.Automation.AutomationProperties.AutomationIdProperty, headerBinding);

                // WPF's bindings are strange, so if our ServiceProvider is bound, it shows as null here
                var sp = this.ServiceProvider ?? this.FindParent<ToolsUIWindow>().ServiceProvider;
                var layoutInstance = new LayoutInstance(sp, this, tabData, true);

                tabItem.Content = layoutInstance.LayoutControl;
            }
        }
 public LayoutControl(LayoutInstance layoutInstance)
 {
     this.LayoutInstance = layoutInstance;
     this.CommandBindings.Add(new CommandBinding(ViewShortcutCommand, OnViewShortcutExecuted));
 }
        public IEnumerable <MetadataView> GetMetadataViews(Window window)
        {
            DebugHelper.AssertUIThread();

            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            while (window.Owner != null)
            {
                window = window.Owner;
            }

            IEnumerable <MetadataView> value = null;

            ToolsUIWindow toolsWindow = window as ToolsUIWindow;

            if (toolsWindow != null)
            {
                LayoutTabControl tabControl = toolsWindow.LayoutTabControl;

                if (tabControl != null)
                {
                    int layoutIndex = tabControl.SelectedIndex;

                    List <MetadataView> activeTab = new List <MetadataView>();
                    List <MetadataView> otherTabs = new List <MetadataView>();
                    List <MetadataView> temp      = new List <MetadataView>();

                    for (int i = 0; i < tabControl.Items.Count; ++i)
                    {
                        List <MetadataView> list = (i == layoutIndex) ? activeTab : temp;

                        LayoutInstance layout = tabControl.Items[i] as LayoutInstance;
                        if (layout != null)
                        {
                            foreach (View v in layout.FindViews("MetadataView"))
                            {
                                MetadataView mv = v as MetadataView;

                                if (mv != null)
                                {
                                    list.Add(mv);
                                }
                            }
                        }

                        if ((i != layoutIndex) && (list.Count > 0))
                        {
                            if (otherTabs.Count > 0)
                            {
                                otherTabs.Add(null);
                            }

                            otherTabs.AddRange(list.OrderBy(mv => mv.Title));

                            list.Clear();
                        }
                    }

                    List <MetadataView> metadataViews = new List <MetadataView>();

                    if (activeTab.Count > 0)
                    {
                        metadataViews.AddRange(activeTab.OrderBy(mv => mv.Title));

                        if (otherTabs.Count > 0)
                        {
                            metadataViews.Add(null);
                        }
                    }

                    metadataViews.AddRange(otherTabs);
                    value = metadataViews;
                }
            }

            return(value);
        }
Beispiel #8
0
        private void LayoutAccepted(Widget src, LayoutInstance instance)
        {
            var widget = (PuzzleBoardWidget) src;
            Player who = widget.Board.Player;

            // spawn a new unit
            BattleUnit unit = _simulation.Spawn(instance.Layout.Name);
            unit.Simulation = _simulation;
            unit.Player = who;
            unit.Avatar.Position = who.InitialPosition;
            _simulation.Add(unit);
        }