Esempio n. 1
0
        private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            ValueCommentAlias comment = e.Row.DataContext as ValueCommentAlias;
            TextBox           textBox = e.EditingElement as TextBox;

            if (e.Column == elementComment)
            {
                if (comment != null && textBox != null)
                {
                    ValueCommentManager.UpdateComment(comment.Name, textBox.Text);
                }
            }
            else if (e.Column == elementAlias)
            {
                if (comment != null && textBox != null)
                {
                    if (textBox.Text != string.Empty && !ValueAliasManager.CheckAlias(comment.Name, textBox.Text))
                    {
                        LocalizedMessageBox.Show(Properties.Resources.Message_Alias_Exist, LocalizedMessageIcon.Warning);
                        e.Cancel = true;
                    }
                    else
                    {
                        ValueAliasManager.UpdateAlias(comment.Name, textBox.Text);
                    }
                }
            }
        }
Esempio n. 2
0
        private static void RefreshMappedModelsByItem(ValueCommentAlias item)
        {
            List <TextBlock>            mappedModels = new List <TextBlock>();
            IEnumerable <BaseViewModel> models       = InstructionCommentManager.ValueRelatedModel[item.Name].Where(x => { return(x.NetWorkNum != -1); });

            if (models.Count() > 0)
            {
                TextBlock textblock = new TextBlock();
                textblock.Text = (new HorizontalLineViewModel()).ToString();
                mappedModels.Add(textblock);
                foreach (var model in models)
                {
                    textblock      = new TextBlock();
                    textblock.Text = model.ToString();
                    mappedModels.Add(textblock);
                }
            }
            item.MappedModels = mappedModels;
        }
Esempio n. 3
0
        public static void InstructionCommentManager_MappedMessageChanged(MappedMessageChangedEventArgs e)
        {
            IEnumerable <ValueCommentAlias> fit = _elementCollection.Where(x => { return(x.Name == e.ValueString); });

            if (fit.Count() == 0 && e.MappedValueModel != null && e.Type != MappedMessageChangedType.Refresh)
            {
                return;
            }
            ValueCommentAlias valueCommentAlias;

            if (e.Type != MappedMessageChangedType.Clear && e.Type != MappedMessageChangedType.Refresh)
            {
                valueCommentAlias = fit.First();
            }
            else
            {
                valueCommentAlias = new ValueCommentAlias(string.Empty, 0, string.Empty, string.Empty);
            }
            List <TextBlock> mappedModels;

            switch (e.Type)
            {
            case MappedMessageChangedType.Refresh:
                ClearMappedModels();
                RefreshMappedModels();
                break;

            case MappedMessageChangedType.Add:
                if (!valueCommentAlias.MappedModels.Exists(x => { return(x.Text == e.MappedValueModel.ToString()); }))
                {
                    mappedModels = new List <TextBlock>(valueCommentAlias.MappedModels);
                    TextBlock textblock = new TextBlock();
                    textblock.Text = e.MappedValueModel.ToString();
                    mappedModels.Add(textblock);
                    valueCommentAlias.MappedModels = mappedModels;
                }
                break;

            case MappedMessageChangedType.AddFirst:
                valueCommentAlias.MappedModels.Clear();
                mappedModels = new List <TextBlock>(valueCommentAlias.MappedModels);
                TextBlock textblock1 = new TextBlock();
                textblock1.Text = (new HorizontalLineViewModel()).ToString();
                mappedModels.Add(textblock1);
                TextBlock textblock2 = new TextBlock();
                textblock2.Text = e.MappedValueModel.ToString();
                mappedModels.Add(textblock2);
                valueCommentAlias.MappedModels = mappedModels;
                break;

            case MappedMessageChangedType.Remove:
                mappedModels = new List <TextBlock>(valueCommentAlias.MappedModels);
                foreach (var model in mappedModels)
                {
                    var index = e.MappedValueModel.ToString().LastIndexOf("(I=");
                    if (model.Text.Contains(e.MappedValueModel.ToString().Substring(0, index)))
                    {
                        mappedModels.Remove(model);
                        break;
                    }
                }
                valueCommentAlias.MappedModels = mappedModels;
                break;

            case MappedMessageChangedType.RemoveLast:
                valueCommentAlias.MappedModels.Clear();
                valueCommentAlias.MappedModels = new List <TextBlock>();
                break;

            case MappedMessageChangedType.Clear:
                ClearMappedModels();
                break;

            default:
                break;
            }
        }