예제 #1
0
파일: App.xaml.cs 프로젝트: oxypomme/ILA
        public static void editType(TypeDeclaration type)
        {
            var copy = new TypeDeclaration();

            copy.AboveComment = new Comment
            {
                Message   = type.AboveComment?.Message,
                MultiLine = type.AboveComment != null ? type.AboveComment.MultiLine : false
            };
            copy.InlineComment = type.InlineComment;

            if (type.CreatedType is StructType st)
            {
                var structCopy = new StructType
                {
                    Name    = st.Name,
                    Members = new SortedDictionary <string, VarType>()
                };
                foreach (var item in st.Members)
                {
                    structCopy.Members.Add(item.Key, item.Value);
                }
                copy.CreatedType = structCopy;
                var dialog = new createStruct(copy);
                dialog.Owner = MainDialog;
                if (dialog.ShowDialog() == true)
                {
                    var comm = new Comment();
                    comm.MultiLine     = dialog.comments.Text.Contains('\n');
                    comm.Message       = dialog.comments.Text;
                    type.AboveComment  = comm;
                    type.InlineComment = dialog.inlineComm.Text;
                    (type.CreatedType as StructType).Members = structCopy.Members;
                    type.CreatedType.Name = dialog.typeName.Text;
                }
            }
            else if (type.CreatedType is TableType tt)
            {
                var dialog = new createTable(type, true);
                dialog.Owner = MainDialog;
                if (dialog.ShowDialog() == true)
                {
                    var comm = new Comment();
                    comm.MultiLine     = dialog.comments.Text.Contains('\n');
                    comm.Message       = dialog.comments.Text;
                    type.AboveComment  = comm;
                    type.InlineComment = dialog.inlineComm.Text;
                    tt.Name            = dialog.typeName.Text;
                    tt.DimensionsSize.Clear();
                    foreach (dimension item in dialog.dimList.Children)
                    {
                        tt.DimensionsSize.Add(new ILANET.Range(
                                                  ILANET.Parser.Parser.ParseValue(item.minValue.Text, CurrentILAcode, CurrentILAcode, true),
                                                  ILANET.Parser.Parser.ParseValue(item.maxValue.Text, CurrentILAcode, CurrentILAcode, true)
                                                  ));
                    }
                }
            }
            else if (type.CreatedType is EnumType et)
            {
                var dialog = new createEnum(type, true);
                dialog.Owner = MainDialog;
                if (dialog.ShowDialog() == true)
                {
                    var comm = new Comment();
                    comm.MultiLine     = dialog.comments.Text.Contains('\n');
                    comm.Message       = dialog.comments.Text;
                    type.AboveComment  = comm;
                    type.InlineComment = dialog.inlineComm.Text;
                    et.Name            = dialog.typeName.Text;
                    et.Values.Clear();
                    foreach (enumValue item in dialog.valList.Children)
                    {
                        et.Values.Add(item.valueName.Text);
                    }
                }
            }
        }
예제 #2
0
파일: App.xaml.cs 프로젝트: oxypomme/ILA
 public static TypeDeclaration createType(int type) //0 = struct, 1 = table, 2 = enum
 {
     if (type == 0)
     {
         var tmp = new StructType();
         tmp.Name = "nouvelle_structure";
         var dialog = new createStruct(new TypeDeclaration()
         {
             CreatedType = tmp
         });
         dialog.Owner = MainDialog;
         if (dialog.ShowDialog() == true)
         {
             var decl = new TypeDeclaration();
             var comm = new Comment();
             comm.MultiLine     = dialog.comments.Text.Contains('\n');
             comm.Message       = dialog.comments.Text;
             decl.AboveComment  = comm;
             decl.InlineComment = dialog.inlineComm.Text;
             decl.CreatedType   = tmp;
             tmp.Name           = dialog.typeName.Text;
             return(decl);
         }
     }
     else if (type == 1)
     {
         var tmp = new TableType();
         tmp.Name = "nouveau_tableau";
         tmp.DimensionsSize.Add(new ILANET.Range(new ConstantInt()
         {
             Value = 1
         }, new ConstantInt()
         {
             Value = 10
         }));
         var dialog = new createTable(new TypeDeclaration()
         {
             CreatedType = tmp
         }, false);
         dialog.Owner = MainDialog;
         if (dialog.ShowDialog() == true)
         {
             var decl = new TypeDeclaration();
             var comm = new Comment();
             comm.MultiLine     = dialog.comments.Text.Contains('\n');
             comm.Message       = dialog.comments.Text;
             decl.AboveComment  = comm;
             decl.InlineComment = dialog.inlineComm.Text;
             decl.CreatedType   = tmp;
             tmp.Name           = dialog.typeName.Text;
             tmp.DimensionsSize.Clear();
             foreach (dimension item in dialog.dimList.Children)
             {
                 tmp.DimensionsSize.Add(new ILANET.Range(
                                            ILANET.Parser.Parser.ParseValue(item.minValue.Text, CurrentILAcode, CurrentILAcode, true),
                                            ILANET.Parser.Parser.ParseValue(item.maxValue.Text, CurrentILAcode, CurrentILAcode, true)
                                            ));
             }
             return(decl);
         }
     }
     else if (type == 2)
     {
         var tmp = new EnumType();
         tmp.Name = "nouvelle_enumeration";
         tmp.Values.Add("VALEUR1");
         var dialog = new createEnum(new TypeDeclaration()
         {
             CreatedType = tmp
         }, false);
         dialog.Owner = MainDialog;
         if (dialog.ShowDialog() == true)
         {
             var decl = new TypeDeclaration();
             var comm = new Comment();
             comm.MultiLine     = dialog.comments.Text.Contains('\n');
             comm.Message       = dialog.comments.Text;
             decl.AboveComment  = comm;
             decl.InlineComment = dialog.inlineComm.Text;
             decl.CreatedType   = tmp;
             tmp.Name           = dialog.typeName.Text;
             tmp.Values.Clear();
             foreach (enumValue item in dialog.valList.Children)
             {
                 tmp.Values.Add(item.valueName.Text);
             }
             return(decl);
         }
     }
     return(null);
 }