public static Parameter createParameter(Module scope) { var param = new ILANET.Parameter { ImportedVariable = new Variable { Name = "nouveau_parametre", Type = GenericType.Int }, Mode = ILANET.Parameter.Flags.INPUT }; var uiParam = new Parameter(param, scope); return(new ParameterEdition(uiParam, scope).ShowDialog() == true ? uiParam : null); }
public Parameter(ILANET.Parameter param, Module scope) { InitializeComponent(); (removeParam.Content as Image).Source = App.MakeDarkTheme((removeParam.Content as Image).Source as BitmapSource); (editParam.Content as Image).Source = App.MakeDarkTheme((editParam.Content as Image).Source as BitmapSource); this.scope = scope; Link = param; paramName.Text = param.ImportedVariable.Name; if (param.Mode == ILANET.Parameter.Flags.OUTPUT) { prefixName.Text = "s"; } else if (param.Mode == ILANET.Parameter.Flags.IO) { prefixName.Text = "es"; } else if (param.Mode == ILANET.Parameter.Flags.INPUT) { dbPoints.Visibility = Visibility.Collapsed; } if (param.ImportedVariable.Type == GenericType.Int) { iconType.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources.int_var))); paramType.Text = "entier"; } else if (param.ImportedVariable.Type == GenericType.Float) { iconType.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources.float_var))); paramType.Text = "reel"; } else if (param.ImportedVariable.Type == GenericType.Char) { iconType.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources._char))); paramType.Text = "caractere"; } else if (param.ImportedVariable.Type == GenericType.Bool) { iconType.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources._bool))); paramType.Text = "booleen"; } else if (param.ImportedVariable.Type == GenericType.String) { iconType.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources._string))); paramType.Text = "chaine"; } else if (param.ImportedVariable.Type is StructType st) { iconType.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources._struct))); paramType.Text = st.Name; } else if (param.ImportedVariable.Type is EnumType et) { iconType.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources._enum))); paramType.Text = et.Name; } else if (param.ImportedVariable.Type is TableType tt) { iconType.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources.table))); paramType.Text = tt.Name; } else { iconType.Source = App.MakeDarkTheme(App.GetBitmapImage(new MemoryStream(Properties.Resources.custom_var))); paramType.Text = param.ImportedVariable.Type.Name; } }
public static void editModule(Module m) { Module copy; Function func; string choosenName = m.Name; if (m is Function f) { copy = new Function(); ((Function)copy).ReturnType = f.ReturnType; } else { copy = new Module(); } copy.Name = m.Name.Clone() as string; copy.AboveComment = m.AboveComment == null ? null : new Comment { MultiLine = m.AboveComment.MultiLine, Message = m.AboveComment.Message.Clone() as string }; copy.InlineComment = m.InlineComment.Clone() as string; foreach (var item in m.Parameters) { var param = new ILANET.Parameter(); var variable = new Variable(); param.ImportedVariable = variable; param.Mode = item.Mode; variable.Name = item.ImportedVariable.Name; variable.Type = item.ImportedVariable.Type; copy.Parameters.Add(param); } m.Name = ""; if (copy is Function fcopy) { func = m as Function; do { var dialog = new createModule(fcopy, true); dialog.Owner = MainDialog; if (dialog.ShowDialog() == true) { fcopy.Name = dialog.modName.Text; if (!isNameConventionnal(dialog.modName.Text)) { MessageBox.Show(dialog, "nom non conventionnel !", "erreur", MessageBoxButton.OK, MessageBoxImage.Error); } else if (!isNameAvailable(dialog.modName.Text, CurrentILAcode)) { MessageBox.Show(dialog, "nom déjà utilisé !", "erreur", MessageBoxButton.OK, MessageBoxImage.Error); } else { choosenName = dialog.modName.Text; func.ReturnType = ((ToStringOverrider)dialog.returnType.SelectedItem).Content as VarType; var comm = new Comment(); comm.MultiLine = dialog.comments.Text.Contains('\n'); comm.Message = dialog.comments.Text; func.AboveComment = comm; func.InlineComment = dialog.inlineComm.Text; func.Parameters.Clear(); foreach (var item in dialog.paramList.Children) { if (item is Parameter p) { func.Parameters.Add(p.Link as ILANET.Parameter); } } } } else { break; } } while (!(isNameAvailable(fcopy.Name, CurrentILAcode) && isNameConventionnal(fcopy.Name))); } else { do { var dialog = new createModule(copy, true); dialog.Owner = MainDialog; if (dialog.ShowDialog() == true) { copy.Name = dialog.modName.Text; if (!isNameConventionnal(dialog.modName.Text)) { MessageBox.Show(dialog, "nom non conventionnel !", "erreur", MessageBoxButton.OK, MessageBoxImage.Error); } else if (!isNameAvailable(dialog.modName.Text, CurrentILAcode)) { MessageBox.Show(dialog, "nom déjà utilisé !", "erreur", MessageBoxButton.OK, MessageBoxImage.Error); } else { choosenName = dialog.modName.Text; var comm = new Comment(); comm.MultiLine = dialog.comments.Text.Contains('\n'); comm.Message = dialog.comments.Text; m.AboveComment = comm; m.InlineComment = dialog.inlineComm.Text; m.Parameters.Clear(); foreach (var item in dialog.paramList.Children) { if (item is Parameter p) { m.Parameters.Add(p.Link as ILANET.Parameter); } } } } else { break; } } while (!(isNameAvailable(copy.Name, CurrentILAcode) && isNameConventionnal(copy.Name))); } m.Name = choosenName; UpdateTree(); UpdateEditor(); }