Beispiel #1
0
        private StackPanel CreateRightStackPanelForInput(Language lang)
        {
            // Checks if the category already contains a localized category for said language.
            LocalizedCategory locCat = CategoryModel.LocalizedCategories.FirstOrDefault(x => x.LanguageID == lang.ID);

            // If the category does not contain one yet,
            if (locCat == null)
            {
                // Create a new one and add it to the model
                locCat = new LocalizedCategory
                {
                    LanguageID = lang.ID
                };
                CategoryModel.LocalizedCategories.Add(locCat);
            }

            // Creates a stackpanel
            StackPanel stackRight = new StackPanel();

            // Creates a new textbox for the Name property
            ClickSelectTextBox txtName = new ClickSelectTextBox
            {
                Height = _defaultHeight,
                Width  = _defaultWidth,
                Margin = _defaultMargin,
                VerticalContentAlignment = VerticalAlignment.Center
            };
            // Creates a binding with source the localized category and binds it to the Name property
            Binding nameBinding = new Binding("Name")
            {
                Source = locCat
            };

            // Adds the binding to the textbox
            txtName.SetBinding(TextBox.TextProperty, nameBinding);

            // Idem for the plural name textbox
            ClickSelectTextBox txtPluralName = new ClickSelectTextBox
            {
                Height = _defaultHeight,
                Width  = _defaultWidth,
                Margin = _defaultMargin,
                VerticalContentAlignment = VerticalAlignment.Center
            };
            Binding pluralNameBinding = new Binding("PluralName")
            {
                Source = locCat
            };

            txtPluralName.SetBinding(TextBox.TextProperty, pluralNameBinding);

            // Adds both textboxes to the stackpanels
            stackRight.Children.Add(txtName);
            stackRight.Children.Add(txtPluralName);

            return(stackRight);
        }
Beispiel #2
0
        private StackPanel CreateRightStackPanelForInput(Language lang)
        {
            // Checks if the specification already has a localized specification belonging to the language
            LocalizedSpecification locSpec = SpecModel.LocalizedSpecifications.FirstOrDefault(x => x.LanguageID == lang.ID);

            // If there is no localized specification yet...
            if (locSpec == null)
            {
                // ... create a new localized specification and add it to the Model
                locSpec = new LocalizedSpecification
                {
                    LanguageID      = lang.ID,
                    SpecificationID = SpecModel.ID
                };

                SpecModel.LocalizedSpecifications.Add(locSpec);
            }

            // Creates a stackpanel
            StackPanel stackRight = new StackPanel
            {
                HorizontalAlignment = HorizontalAlignment.Left
            };

            // Creates a textbox for the name property
            ClickSelectTextBox txtName = new ClickSelectTextBox
            {
                Height = _defaultHeight,
                Width  = _defaultWidth,
                Margin = _defaultMargin,
                VerticalContentAlignment = VerticalAlignment.Center
            };
            // Creates a binding to the LookupName property of the localized specification, and adds the binding to the textbox
            Binding nameBinding = new Binding("LookupName")
            {
                Source = locSpec
            };

            txtName.SetBinding(TextBox.TextProperty, nameBinding);

            // Ditto for the AdviceDescription
            ClickSelectTextBox txtAdviceDescription = new ClickSelectTextBox
            {
                Height        = 300,
                Width         = _defaultWidth,
                TextWrapping  = TextWrapping.Wrap,
                AcceptsReturn = true,
                Margin        = _defaultMargin
            };
            Binding descriptionBinding = new Binding("AdviceDescription")
            {
                Source = locSpec
            };

            txtAdviceDescription.SetBinding(TextBox.TextProperty, descriptionBinding);

            // Adds the textboxes to the stackpanel
            stackRight.Children.Add(txtName);
            stackRight.Children.Add(txtAdviceDescription);

            return(stackRight);
        }