private void FooterDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            _generatedButtons.ForEach(button => ButtonsPanel.Children.Remove(button));
            _generatedButtons.Clear();

            if (DataContext is null)
            {
                return;
            }

            DataContext
            .GetType()
            .GetMethods()
            .Select(methodInfo => new { Attribute = methodInfo.GetCustomAttribute <GenerateButtonAttribute>(), MethodInfo = methodInfo })
            .Where(x => x.Attribute != null)
            .OrderBy(x => x.Attribute.Order)
            .ToList()
            .ForEach(x =>
            {
                var button = new LabeledButton();
                button.SetBinding(ButtonBase.CommandProperty, new Binding(string.IsNullOrWhiteSpace(x.Attribute.BindCommandTo) ? $"{x.MethodInfo.Name}Command" : x.Attribute.BindCommandTo));
                button.SetBinding(LabeledButton.LabelProperty, new Binding(string.IsNullOrWhiteSpace(x.Attribute.BindTextTo) ? $"{x.MethodInfo.Name}Label" : x.Attribute.BindTextTo));
                ButtonsPanel.Children.Add(button);
                _generatedButtons.Add(button);
            });
        }
コード例 #2
0
ファイル: TransformManager.cs プロジェクト: ryo0ka/Sightsync
        void InitiateSelectorOf(Transform target)
        {
            LabeledButton controller = Instantiate(selectButtonPrototype);

            controller.transform.parent = selectorBox;
            controller.onClick.AddListener(() => Select(target));
            controller.text = target.name;
            controller.gameObject.SetActive(true);

            // Vectical Layer Group has a scalling bug
            // that can be worked around by force-resetting the scale.
            controller.transform.localScale = Vector3.one;
        }