Example #1
0
        /// <summary>
        /// Event when the add button is clicked.
        /// </summary>
        /// <param name="sender">Sender argument.</param>
        /// <param name="e">Event arguments.</param>
        private void AddButton_Click(object sender, EventArgs e)
        {
            LocalizedLabel[] localLabels       = new LocalizedLabel[this.installedLanguages.Count];
            LocalizedLabel[] localDescriptions = new LocalizedLabel[this.installedLanguages.Count];
            for (int i = 0; i < this.installedLanguages.Count; i++)
            {
                localLabels[i]       = new LocalizedLabel(string.Empty, this.installedLanguages.Keys.Skip(i).First());
                localDescriptions[i] = new LocalizedLabel(string.Empty, this.installedLanguages.Keys.Skip(i).First());
            }

            Microsoft.Xrm.Sdk.Label label       = new Microsoft.Xrm.Sdk.Label(new LocalizedLabel(string.Empty, this.DefaultLanguage), localLabels);
            Microsoft.Xrm.Sdk.Label description = new Microsoft.Xrm.Sdk.Label(new LocalizedLabel(string.Empty, this.DefaultLanguage), localDescriptions);

            int currentValue = 0;
            var currentItem  = (EntityItem)AttributesList.SelectedItem;

            for (int i = this.OptionSetPrefix * 10000; i < (this.OptionSetPrefix * 10000) + 9999; i++)
            {
                if (!currentItem.Children.Exists(c => c.Value == i))
                {
                    currentValue = i;
                    break;
                }
            }

            EntityItem item = new EntityItem(currentValue, label, description, currentItem);

            currentItem.Children.Add(item);
            OptionsList.DataSource   = new BindingList <EntityItem>(((EntityItem)AttributesList.SelectedItem).Children);
            OptionsList.SelectedItem = item;
            AddButton.Enabled        = AttributesList.SelectedIndex > -1 && OptionsList.Items.Count < 300;
            item.Changed             = true;
            item.Parent.Changed      = true;
            PublishMenu.Enabled      = true;
        }
        private void ComponentTypeSelector_Load(object sender, EventArgs e)
        {
            if (_omc.All(o => o.Value != 80))
            {
                var lb = new Label {
                    UserLocalizedLabel = new LocalizedLabel("Model driven app", -1)
                };
                _omc.Add(new OptionMetadata(lb, 80));
            }

            foreach (var omd in _omc)
            {
                lvTypes.Items.Add(new ListViewItem(omd.Label?.UserLocalizedLabel?.Label)
                {
                    Tag = omd.Value, Checked = true
                });
            }
        }
            public StatusCodeViewItem(
                int stateCode
                , string stateCodeName
                , int statusCode
                , string statusCodeName
                , Microsoft.Xrm.Sdk.Label stateCodeLabel
                , Microsoft.Xrm.Sdk.Label statusCodeLabel
                , StatusOptionMetadata statusOptionMetadata
                )
            {
                this.StateCode     = stateCode;
                this.StateCodeName = stateCodeName;

                this.StatusCode     = statusCode;
                this.StatusCodeName = statusCodeName;

                this.StateCodeLabel  = stateCodeLabel;
                this.StatusCodeLabel = statusCodeLabel;

                this.StatusOptionMetadata = statusOptionMetadata;
            }
Example #4
0
        /// <summary>
        /// Loads the labels in to the group boxes.
        /// </summary>
        /// <param name="group">The group box to load into.</param>
        /// <param name="optionLabel">The CRM label to put in the box.</param>
        private void LoadLabels(GroupBox group, Microsoft.Xrm.Sdk.Label optionLabel)
        {
            group.Controls.Clear();
            if (this.installedLanguages.ContainsKey(this.DefaultLanguage))
            {
                int left = 20;
                int top  = 20;
                System.Windows.Forms.Label label = new System.Windows.Forms.Label();
                label.Text     = this.installedLanguages[this.DefaultLanguage];
                label.Left     = left;
                label.AutoSize = true;
                label.Top      = top;

                group.Controls.Add(label);

                TextBox text        = new System.Windows.Forms.TextBox();
                var     localOption = optionLabel.LocalizedLabels.Where(l => l.LanguageCode == this.DefaultLanguage).FirstOrDefault();
                localOption    = localOption == null ? optionLabel.UserLocalizedLabel : localOption;
                text.Text      = localOption == null ? string.Empty : localOption.Label;
                text.Top       = top + 15;
                text.Left      = left;
                text.Width     = 150;
                text.MaxLength = 255;
                text.Tag       = optionLabel;
                ToolTip toolTip = new ToolTip();
                toolTip.SetToolTip(text, $"{label.Text} translation for the option.");
                text.Name         = "L" + this.DefaultLanguage.ToString();
                text.TextChanged += this.LabelChanged;
                if (this.DefaultLanguage != 0 && !group.Name.ToLower().Contains("description"))
                {
                    text.Leave += this.Label_Leave;
                }

                group.Controls.Add(text);

                top += 48;

                foreach (var item in this.installedLanguages)
                {
                    if (item.Key != this.DefaultLanguage)
                    {
                        label          = new System.Windows.Forms.Label();
                        label.Text     = item.Value;
                        label.Left     = left;
                        label.Top      = top;
                        label.AutoSize = true;
                        group.Controls.Add(label);

                        text = new System.Windows.Forms.TextBox();
                        var localLabel = optionLabel.LocalizedLabels.Where(l => l.LanguageCode == item.Key).FirstOrDefault();
                        text.Text         = localLabel == null ? string.Empty : localLabel.Label;
                        text.Top          = top + 15;
                        text.Left         = left;
                        text.Width        = 150;
                        text.MaxLength    = 255;
                        text.Tag          = optionLabel;
                        text.Name         = " " + item.Key.ToString();
                        text.TextChanged += this.LabelChanged;
                        toolTip           = new ToolTip();
                        toolTip.SetToolTip(text, $"{label.Text} translation for the option.");
                        group.Controls.Add(text);
                        top += 48;
                    }
                }

                group.Height = top;
            }

            this.ShowLabels(true);
        }