A Mingle property_definition
示例#1
0
        private ComboBox MakeComboBox(CardProperty cardProperty)
        {
            var cb = new ComboBox
            {
                IsEnabled       = !cardProperty.IsTransitionOnly,
                MinWidth        = 50,
                Name            = cardProperty.ColumnName,
                DataContext     = cardProperty,
                Background      = _buttonBackground,
                BorderThickness = _buttonBorderThickness,
                FontWeight      = _normalFontWeight
            };

            if (cardProperty.IsTeamValued)
            {
                cb.ItemsSource       = TeamMemberDictionaryAsManagedList.Values;
                cb.DisplayMemberPath = "Name";
                cb.SelectedValuePath = "Login";
            }
            else
            {
                cb.ItemsSource = cardProperty.PropertyValueDetails;
            }

            cb.SelectedValue = cardProperty.IsSetValued && !string.IsNullOrEmpty(cardProperty.Value as string) ||
                               (!cardProperty.IsManagedListOfScalars && !cardProperty.IsTeamValued)
                                   ? cardProperty.Value
                                   : Resources.ItemNotSet;

            cb.Tag = cardProperty;

            cb.IsEnabled = PropertyIsEditable(cardProperty);

            return(cb);
        }
示例#2
0
        private TextBox MakeTextBox(CardProperty cardProperty, Card thisCard)
        {
            var tb = new TextBox
            {
                MinWidth    = 50,
                Name        = cardProperty.ColumnName,
                DataContext = cardProperty,
                FontWeight  = _normalFontWeight
            };

            var cardinfo = cardProperty.Value as string;

            if (!string.IsNullOrEmpty(cardProperty.Value as string) && cardProperty.IsCardValued)
            {
                string name = thisCard.Model.GetOneCard(Convert.ToInt32(cardProperty.Value, CultureInfo.InvariantCulture)).Name;
                cardinfo = string.Format(CultureInfo.InvariantCulture, "{0} - {1}", cardProperty.Value as string, name);
            }
            tb.Text = cardinfo;
            tb.Tag  = cardProperty;

            if (cardProperty.IsTransitionOnly || cardProperty.IsFormula)
            {
                tb.Background = _darkThemeBackground;
            }

            return(tb);
        }
示例#3
0
        private Button MakeChooseCardButton(CardProperty cardProperty)
        {
            var a = new Button
            {
                Content         = "...",
                ToolTip         = "Click to choose a card",
                Tag             = cardProperty,
                Width           = 30,
                Background      = _buttonBackground,
                BorderThickness = _buttonBorderThickness,
                Style           = Application.Current.Resources["PlainButtonStyle"] as Style
            };

            return(a);
        }
示例#4
0
        private static Button ValueNotSetButton(CardProperty cardProperty, FrameworkElement control)
        {
            var b = new Button
            {
                Content    = "X",
                ToolTip    = "Click to leave the value not set",
                Tag        = cardProperty,
                Width      = 30,
                FontWeight = FontWeights.Normal,
                Background = Brushes.Gainsboro,
                Style      = Application.Current.Resources["PlainButtonStyle"] as Style
            };

            b.Tag = control.Tag;
            return(b);
        }
 /// <summary>
 /// Binds CardData.PropertyDefinitions list onto the Properties tab
 /// </summary>
 /// <remarks>
 /// Adds elements to the Properties tab dynamically for each property
 /// in the Properties list. Menus and lists of data values are dynamically 
 /// created based on the "type_description" of easch Property.
 /// 
 /// Each Property becomes a horizontal StackPanel member of the propertiesPanel
 /// in the form. Each StackPanel has a Label/[some element] member pair. 
 /// The type of [some element] is determined by the type_description from 
 /// the card itself.
 /// 
 /// The propertiesPanel is a horizontal WrapPanel element so that the 
 /// StackPanel members wrap automatically flowing from left to right.
 /// </remarks>
 internal StackPanel InnerPanel(CardProperty cardProperty)
 {
     return _thisCard.Model.InnerPanel(cardProperty, _thisCard, OnButtonChooseCardClick, OnPropertyTextBoxLostFocus,
         OnPropertyComboBoxSelectionChanged, OnButtonNotSetClick);
 }
 private bool PropertyIsEditable(CardProperty property)
 {
     return UserIsProjectAdmin() ||
            !property.IsFormula && !property.IsTransitionOnly &&
            !property.PropertyValuesDescription.Equals("Aggregate");
 }
        private TextBox MakeTextBox(CardProperty cardProperty, Card thisCard)
        {
            var tb = new TextBox
            {
                MinWidth = 50,
                Name = cardProperty.ColumnName,
                DataContext = cardProperty,
                FontWeight = _normalFontWeight
            };

            var cardinfo = cardProperty.Value as string;
            if (!string.IsNullOrEmpty(cardProperty.Value as string) && cardProperty.IsCardValued)
            {
                string name = thisCard.Model.GetOneCard(Convert.ToInt32(cardProperty.Value, CultureInfo.InvariantCulture)).Name;
                cardinfo = string.Format(CultureInfo.InvariantCulture, "{0} - {1}", cardProperty.Value as string, name);
            }
            tb.Text = cardinfo;
            tb.Tag = cardProperty;

            if (cardProperty.IsTransitionOnly || cardProperty.IsFormula)
                tb.Background = _darkThemeBackground;

            return tb;
        }
        private ComboBox MakeComboBox(CardProperty cardProperty)
        {
            var cb = new ComboBox
            {
                IsEnabled = !cardProperty.IsTransitionOnly,
                MinWidth = 50,
                Name = cardProperty.ColumnName,
                DataContext = cardProperty,
                Background = _buttonBackground,
                BorderThickness = _buttonBorderThickness,
                FontWeight = _normalFontWeight
            };

            if (cardProperty.IsTeamValued)
            {
                cb.ItemsSource = TeamMemberDictionaryAsManagedList.Values;
                cb.DisplayMemberPath = "Name";
                cb.SelectedValuePath = "Login";
            }
            else
            {
                cb.ItemsSource = cardProperty.PropertyValueDetails;
            }

            cb.SelectedValue = cardProperty.IsSetValued && !string.IsNullOrEmpty(cardProperty.Value as string) ||
                               (!cardProperty.IsManagedListOfScalars && !cardProperty.IsTeamValued)
                                   ? cardProperty.Value
                                   : Resources.ItemNotSet;

            cb.Tag = cardProperty;

            cb.IsEnabled = PropertyIsEditable(cardProperty);

            return cb;
        }
 private Button MakeChooseCardButton(CardProperty cardProperty)
 {
     var a = new Button
     {
         Content = "...",
         ToolTip = "Click to choose a card",
         Tag = cardProperty,
         Width = 30,
         Background = _buttonBackground,
         BorderThickness = _buttonBorderThickness,
         Style = Application.Current.Resources["PlainButtonStyle"] as Style
     };
     return a;
 }
        private static Button ValueNotSetButton(CardProperty cardProperty, FrameworkElement control)
        {
            var b = new Button
            {
                Content = "X",
                ToolTip = "Click to leave the value not set",
                Tag = cardProperty,
                Width = 30,
                FontWeight = FontWeights.Normal,
                Background = Brushes.Gainsboro,
                Style = Application.Current.Resources["PlainButtonStyle"] as Style
            };

            b.Tag = control.Tag;
            return b;
        }
        internal StackPanel InnerPanel(CardProperty cardProperty, Card thisCard, 
            RoutedEventHandler onButtonChooseCardClick, RoutedEventHandler onPropertyTextBoxLostFocus,
            SelectionChangedEventHandler onPropertyComboBoxSelectionChanged, RoutedEventHandler onButtonNotSetClick)
        {
            // A StackPanel to hold the label and data controls for a single property. Each property gets one.
            // The enclosing WrapPanel (see XAML source) handles automatic layout on resize events.
            var panel = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Margin = new Thickness(6, 6, 0, 0),
                Tag = cardProperty
            };

            var label = new Label
            {
                Content = cardProperty.Name,
                Background = _darkThemeBackground,
                FontWeight = FontWeights.ExtraBlack
            };

            // Make labels for hidden properties italic.
            if (cardProperty.Hidden) label.FontStyle = FontStyles.Italic;
            panel.Children.Add(label);

            FrameworkElement uiElement;

            switch (cardProperty.IsManagedListOfScalars)
            {
                case false:
                    {
                        if (cardProperty.IsTeamValued)
                        {
                            uiElement = MakeComboBox(cardProperty);
                            if (!cardProperty.IsTransitionOnly && !cardProperty.IsFormula)
                                (uiElement as ComboBox).SelectionChanged += onPropertyComboBoxSelectionChanged;

                            panel.Children.Add(uiElement);
                            break;
                        }

                        uiElement = MakeTextBox(cardProperty, thisCard);
                        if (!cardProperty.IsTransitionOnly && !cardProperty.IsFormula)
                        {
                            uiElement.LostFocus += onPropertyTextBoxLostFocus;
                        }

                        panel.Children.Add(uiElement);

                        if (PropertyIsEditable(cardProperty) && cardProperty.IsCardValued)
                        {
                            // Add a 'click to choose' button
                            Button a = MakeChooseCardButton(cardProperty);
                            a.Click += onButtonChooseCardClick;
                            a.Tag = uiElement;
                            panel.Children.Add(a);
                            var b = ValueNotSetButton(cardProperty, panel);
                            b.Click += onButtonNotSetClick;
                            panel.Children.Add(b);
                        }

                        break;
                    }
                case true:
                    {
                        uiElement = MakeComboBox(cardProperty);
                        (uiElement as ComboBox).SelectionChanged += onPropertyComboBoxSelectionChanged;
                        panel.Children.Add(uiElement);
                        break;
                    }
            }

            return panel;
        }
示例#12
0
 private bool PropertyIsEditable(CardProperty property)
 {
     return(UserIsProjectAdmin() ||
            !property.IsFormula && !property.IsTransitionOnly &&
            !property.PropertyValuesDescription.Equals("Aggregate"));
 }
示例#13
0
        internal StackPanel InnerPanel(CardProperty cardProperty, Card thisCard,
                                       RoutedEventHandler onButtonChooseCardClick, RoutedEventHandler onPropertyTextBoxLostFocus,
                                       SelectionChangedEventHandler onPropertyComboBoxSelectionChanged, RoutedEventHandler onButtonNotSetClick)
        {
            // A StackPanel to hold the label and data controls for a single property. Each property gets one.
            // The enclosing WrapPanel (see XAML source) handles automatic layout on resize events.
            var panel = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Margin      = new Thickness(6, 6, 0, 0),
                Tag         = cardProperty
            };

            var label = new Label
            {
                Content    = cardProperty.Name,
                Background = _darkThemeBackground,
                FontWeight = FontWeights.ExtraBlack
            };

            // Make labels for hidden properties italic.
            if (cardProperty.Hidden)
            {
                label.FontStyle = FontStyles.Italic;
            }
            panel.Children.Add(label);

            FrameworkElement uiElement;

            switch (cardProperty.IsManagedListOfScalars)
            {
            case false:
            {
                if (cardProperty.IsTeamValued)
                {
                    uiElement = MakeComboBox(cardProperty);
                    if (!cardProperty.IsTransitionOnly && !cardProperty.IsFormula)
                    {
                        (uiElement as ComboBox).SelectionChanged += onPropertyComboBoxSelectionChanged;
                    }

                    panel.Children.Add(uiElement);
                    break;
                }

                uiElement = MakeTextBox(cardProperty, thisCard);
                if (!cardProperty.IsTransitionOnly && !cardProperty.IsFormula)
                {
                    uiElement.LostFocus += onPropertyTextBoxLostFocus;
                }

                panel.Children.Add(uiElement);

                if (PropertyIsEditable(cardProperty) && cardProperty.IsCardValued)
                {
                    // Add a 'click to choose' button
                    Button a = MakeChooseCardButton(cardProperty);
                    a.Click += onButtonChooseCardClick;
                    a.Tag    = uiElement;
                    panel.Children.Add(a);
                    var b = ValueNotSetButton(cardProperty, panel);
                    b.Click += onButtonNotSetClick;
                    panel.Children.Add(b);
                }

                break;
            }

            case true:
            {
                uiElement = MakeComboBox(cardProperty);
                (uiElement as ComboBox).SelectionChanged += onPropertyComboBoxSelectionChanged;
                panel.Children.Add(uiElement);
                break;
            }
            }



            return(panel);
        }
示例#14
0
 /// <summary>
 /// Binds CardData.PropertyDefinitions list onto the Properties tab
 /// </summary>
 /// <remarks>
 /// Adds elements to the Properties tab dynamically for each property
 /// in the Properties list. Menus and lists of data values are dynamically
 /// created based on the "type_description" of easch Property.
 ///
 /// Each Property becomes a horizontal StackPanel member of the propertiesPanel
 /// in the form. Each StackPanel has a Label/[some element] member pair.
 /// The type of [some element] is determined by the type_description from
 /// the card itself.
 ///
 /// The propertiesPanel is a horizontal WrapPanel element so that the
 /// StackPanel members wrap automatically flowing from left to right.
 /// </remarks>
 internal StackPanel InnerPanel(CardProperty cardProperty)
 {
     return(_thisCard.Model.InnerPanel(cardProperty, _thisCard, OnButtonChooseCardClick, OnPropertyTextBoxLostFocus,
                                       OnPropertyComboBoxSelectionChanged, OnButtonNotSetClick));
 }