/// <summary> /// Handles the Click event of the btnName control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void btnName_Click(object sender, EventArgs e) { PromptBox pbox = new PromptBox(GuiResources.NewName); if (pbox.ShowDialog() == DialogResult.OK) { bool ok = true; if (String.IsNullOrEmpty(pbox.Value)) { ok = false; } else { foreach (char ch in pbox.Value) { char ch2 = Char.ToLower(ch); if (!((ch2 >= 'a' && ch2 <= 'z') || (ch2 >= '0' && ch2 <= '9') || (" ._".IndexOf(ch) >= 0))) { ok = false; break; } } } if (ok) { _treeView.AddLevel(pbox.Value); } else { MessageBox.Show("Invalid name. (Only [a-z]|[0-9]|[ ._])"); } } }
private void displacementToolStripMenuItem_Click(object sender, EventArgs e) { // Click on 'Displacement' menu item try { PromptBox pBox = new PromptBox("Engine displacement...", _MESSAGE_ENTER_DISPLACEMENT, engineDisplacementLabel.Text); DialogResult dr = pBox.ShowDialog(this); if (dr == DialogResult.OK && pBox.IsValueChanged) { Cursor = Cursors.WaitCursor; // Changing displacement string newValue = pBox.ReturnValue; DatabaseHelper.UpdateCellFromTopicWherePrimaryKey(_PhysicsTable, SharedConstants.DISPLACEMENT_PHYSICS_DB_COLUMN, _CurrentVehicle, newValue); // Reloading _InitializeDatasheetContents(); // Modification flag _IsDatabaseModified = true; StatusBarLogManager.ShowEvent(this, _STATUS_CHANGING_DISPLACEMENT_OK); Cursor = Cursors.Default; } } catch (Exception ex) { MessageBoxes.ShowError(this, ex); } }
/// <summary> /// Allows to change brake diameter /// </summary> /// <param name="isFrontBrakes"></param> private void _ChangeBrakesDiameter(bool isFrontBrakes) { string currentValue = (isFrontBrakes ? frontBrakesLabel.Text.Split('ø')[1] : rearBrakesLabel.Text.Split('ø')[1]); string message = (isFrontBrakes ? _MESSAGE_ENTER_FRONT_DIAMETER : _MESSAGE_ENTER_REAR_DIAMETER); PromptBox pBox = new PromptBox(_TITLE_BRAKES_DIAMETER, message, currentValue); DialogResult dr = pBox.ShowDialog(this); if (dr == DialogResult.OK && pBox.IsValueChanged) { Cursor = Cursors.WaitCursor; // Changing displacement string columnName = (isFrontBrakes ? SharedConstants.BRAKES_DIM_FRONT_PHYSICS_DB_COLUMN : SharedConstants.BRAKES_DIM_REAR_PHYSICS_DB_COLUMN); string newValue = pBox.ReturnValue; DatabaseHelper.UpdateCellFromTopicWherePrimaryKey(_PhysicsTable, columnName, _CurrentVehicle, newValue); // Reloading _InitializeDatasheetContents(); // Modification flag _IsDatabaseModified = true; StatusBarLogManager.ShowEvent(this, _STATUS_CHANGING_BRAKE_DIAMETER_OK); Cursor = Cursors.Default; } }
private void button1_Click(object sender, RibbonControlEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = true;//该值确定是否可以选择多个文件 dialog.Title = "请选择文件"; dialog.Filter = "所有文件(*.*)|*.*"; string fileName = ""; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fileName = dialog.FileName; string url = "{0}/ppttools/pptdata/save?token={1}"; url = String.Format(url, Rigel.ServerUrl, Rigel.UserToken); ProgressWidget pro = new ProgressWidget(); pro.Show(); pro.SetInfoText("正在上传,请稍后···"); pro.Show(); string resultStr = Request.UploadFilesToRemoteUrl(url, fileName); pro.Hide(); JObject jObject = JObject.Parse(resultStr); if (jObject.Value <String>("code").Equals("200")) { PromptBox.Prompt("数据上传成功!"); } else { PromptBox.Error("上传失败:" + jObject.Value <String>("msg")); } } }
private void setNameButton_Click(object sender, EventArgs e) { // Click on 'Set name...' button try { if (creditsListView.SelectedItems.Count == 1) { ListViewItem selectedRole = creditsListView.SelectedItems[0]; int roleIndex = selectedRole.Index; string currentName = selectedRole.SubItems[1].Text; PromptBox pBox = new PromptBox(_TITLE_PATCH_EDITOR, _MESSAGE_SET_NAME_CUSTOM, currentName); if (pBox.ShowDialog(this) == DialogResult.OK && !pBox.ReturnValue.Equals(currentName)) { Cursor = Cursors.WaitCursor; _CurrentPatch.SetRoleAuthorName(roleIndex, pBox.ReturnValue); // Refresh _UpdateRoleInformationTable(); } } } catch (Exception ex) { MessageBoxes.ShowError(this, ex); } finally { Cursor = Cursors.Default; } }
public void PromptAlertBox() { PromptBox.Click(); IAlert alert = _driver.SwitchTo().Alert(); alert.SendKeys("Some text"); alert.Accept(); }
public override void Play() { string[] dialogContent = { "Hey Toi !", "Je ne t'ai jamais vu ici. . .", "Tu es un aventurier ??", "Dis moi, quel-est ton nom ?" }; Point dialogPoint = new Point((int)(Console.WindowWidth * 0.4), (int)(Console.WindowHeight * 0.5)); Point dialogPoint2 = new Point((int)(Console.WindowWidth * 0.6), (int)(Console.WindowHeight * 0.7)); Dialog dialog = new Dialog(dialogPoint, dialogPoint2); dialog.AddSentences(dialogContent); dialog.Display(); // Here prompting the player name Point promptPoint = new Point((int)(Console.WindowWidth * 0.6), (int)(Console.WindowHeight * 0.5)); PromptBox namePrompt = new PromptBox(12, promptPoint, ':'); string playerName; bool sure = false; do { playerName = namePrompt.Prompt(); namePrompt.Clear(); dialog = new Dialog(dialogPoint, dialogPoint2); dialog.AddSentence(playerName + ", c'est vraiment ton nom ?"); dialog.Display(); TwoChoicesPromptBox nameChoiceSure = new TwoChoicesPromptBox(promptPoint); sure = nameChoiceSure.Prompt(); } while (!sure); // Here the player name is definitely chosen Stats.Player.Name = playerName; dialog = new Dialog(dialogPoint, dialogPoint2); dialog.AddSentence("Eh bien " + playerName + " ravi de te rencontrer !"); string secondSentence = (playerName.ToLower() == "tyrex") ? "Figure-toi que c'est mon nom aussi :)" : "Moi c'est Tyrex, mais je n'aime pas spécialement parler . . ."; dialog.AddSentence(secondSentence); dialog.AddSentence("Mais laisse-moi te montrer un endroit génial !"); dialog.Display(); Stats.Player.ProgressLevel++; }
public void ShowTest() { const string v = "V"; IWin32Window owner = null; PromptBox target = new PromptBox("TITLE", "MESSAGE", v); const DialogResult expected = DialogResult.OK; DialogResult actual = target.Show(owner); Assert.AreEqual(expected, actual); _Logger.Info("Returned value: " + target.ReturnValue); Assert.AreEqual(v, target.ReturnValue); }
/// <summary> /// Ajoute une configuration de lancement /// </summary> private void _AddLaunchConfiguration() { // Nom de la configuration PromptBox pBox = new PromptBox(Application.ProductName, _CONFIG_NAME_MESSAGE, null); pBox.ShowDialog(this); if (pBox.DialogResult == DialogResult.OK) { // Nouvelle config LaunchConfiguration newConf = new LaunchConfiguration(); // Nettoyage du nom pour éviter les conflits avec le sérialiseur string name = pBox.ReturnValue; if (!string.IsNullOrEmpty(name)) { name = name.Trim(); } // Une chaîne vide n'est pas autorisée if (string.IsNullOrEmpty(name)) { throw new Exception(_ERROR_INVALID_CONFIG_NAME); } name = name.Replace('|', '!'); name = name.Replace('¤', '*'); // Vérification de l'existence d'une config de même nom foreach (LaunchConfiguration anotherConf in _TemporaryConfigList) { if (anotherConf.Name.Equals(name)) { throw new Exception(_ERROR_CONFIG_NAME_EXISTS); } } newConf.Name = name; _UpdateConfiguration(ref newConf); // Ajout à la liste IHM configComboBox.Items.Add(newConf.Name); // Ajout à la config _TemporaryConfigList.Add(newConf); // Sélection de la config ajoutée configComboBox.SelectedIndex = configComboBox.Items.Count - 1; } }
private void button_option_Click(object sender, RibbonControlEventArgs e) { try { UpdateWidget updateWidget = new UpdateWidget(); updateWidget.setVersion(Rigel.PluginVersion, VSTOUpdater.ServerVersion); VSTOUpdater.UpdateLog.TryGetValue("slogan", out string slogan); VSTOUpdater.UpdateLog.TryGetValue("content", out string content); VSTOUpdater.UpdateLog.TryGetValue("sjhs", out string sjhs); List <string> lists = new List <string>(); if (sjhs != null) { lists = sjhs.Split(',').ToList <string>(); } updateWidget.setInfo(slogan, content); Int32.TryParse(Rigel.PluginVersion.Replace(".", ""), out int local); Int32.TryParse(VSTOUpdater.ServerVersion.Replace(".", ""), out int server); if ((lists.Contains(Rigel.UserID) || lists.Contains("all")) && local < server) { VSTOUpdater.NeedUpdate = true; } else { updateWidget.setVersion(Rigel.PluginVersion, Rigel.PluginVersion); VSTOUpdater.NeedUpdate = false; } updateWidget.setNeedUpdate(VSTOUpdater.NeedUpdate); if (VSTOUpdater.NeedUpdate) { Logger.LogInfo("需要更新版本:" + VSTOUpdater.ServerVersion); } Logger.LogInfo("开始更新从:" + Rigel.PluginVersion + "升级到:" + VSTOUpdater.ServerVersion); DialogResult result = ThisAddIn.FormShower.ShowDialog(updateWidget); if (result == DialogResult.OK && VSTOUpdater.Update()) { PromptBox.Prompt("更新完成,需要重新启动软件。"); return; } } catch (Exception ex) { PromptBox.Prompt("非常抱歉更新失败,请联系工作人员!"); Logger.LogError(ex.ToString()); } }
private void img2pdf(List <string> ImageName) { string[] files = ImageName.ToArray(); iTextSharp.text.Document document = new iTextSharp.text.Document(new iTextSharp.text.Rectangle(100f, 100f, 800f, 500f, 0)); try { iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(FileName, FileMode.Create, FileAccess.ReadWrite)); document.Open(); iTextSharp.text.Image image; for (int i = 0; i < files.Length; i++) { if (String.IsNullOrEmpty(files[i])) { break; } image = iTextSharp.text.Image.GetInstance(files[i]); if (image.Height > iTextSharp.text.PageSize.A4.Height - 25) { image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25); } else if (image.Width > iTextSharp.text.PageSize.A4.Width - 25) { image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25); } image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE; document.NewPage(); document.Add(image); //iTextSharp.text.Chunk c1 = new iTextSharp.text.Chunk("Hello World"); //iTextSharp.text.Phrase p1 = new iTextSharp.text.Phrase(); //p1.Leading = 150; //行间距 //document.Add(p1); } Console.WriteLine("转换成功!"); } catch (Exception ex) { Console.WriteLine("转换失败,原因:" + ex.Message); } document.Close(); PromptBox.Prompt("导出完成!"); Console.ReadKey(); }
private void InsertUsingEncoding(Encoding encoding, HexBox _hexbox, bool Multiline) { PromptBox prompt = new PromptBox(Multiline); if (prompt.ShowDialog() == DialogResult.OK) { byte[] bytes = new byte[prompt.Value.Length * encoding.GetByteCount("A")]; encoding.GetBytes(prompt.Value, 0, prompt.Value.Length, bytes, 0); _hexbox.ByteProvider.DeleteBytes(_hexbox.SelectionStart, _hexbox.SelectionLength); _hexbox.ByteProvider.InsertBytes(_hexbox.SelectionStart, bytes); _hexbox.Select(_hexbox.SelectionStart, bytes.Length); } }
private async void button_identCode_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(lineEdit_account.Text)) { try { if (!IsHandset(lineEdit_account.Text)) { errorProvider.ErrorAlignment = ErrorAlignment.Top; errorProvider.SetError(account_Layout, "手机号格式错误"); return; } int userFlag = await RequestHandle.SendIdentCode(lineEdit_account.Text); button_identCode.Enabled = false; m_TotalTime = 0; m_timer.Start(); button_identCode.BackgroundImage = Properties.Resources.nor_btn; if (userFlag == 0)//未注册 { invite_Layout.Visible = true; } else if (userFlag == 1) { //none } else//2 出错 { errorProvider.ErrorAlignment = ErrorAlignment.Top; errorProvider.SetError(account_Layout, "手机号输入错误"); return; } } catch (Exception ex) { PromptBox.Error(ex.Message); } } else { errorProvider.ErrorAlignment = ErrorAlignment.Top; errorProvider.SetError(account_Layout, "请输入手机号"); } }
private async void button_login_Click(object sender, RibbonControlEventArgs e) { DialogResult result = DialogResult.None; if (String.IsNullOrEmpty(Rigel.UserID)) { LoginWidget loginWidget = new LoginWidget(); result = loginWidget.ShowDialog(); if (result == DialogResult.OK) { if (String.IsNullOrEmpty(Rigel.UserID)) { PromptBox.Error("登录失败!"); return; } else { Regditer.WriteReg(Regditer.RootKey.CurrentUser, Rigel.UserRegKey, StrUserName, Rigel.UserName); Regditer.WriteReg(Regditer.RootKey.CurrentUser, Rigel.UserRegKey, StrUserToken, Rigel.UserToken); button_login.Label = Rigel.UserName; button_login.Image = Properties.Resources.Login; ResetButtonEnable(true); } } } else { result = PromptBox.Prompt("确认退出登录?"); if (result == DialogResult.OK) { await RequestHandle.Logout(Rigel.UserName); Rigel.UserID = ""; Rigel.UserToken = ""; Regditer.WriteReg(Regditer.RootKey.CurrentUser, Rigel.UserRegKey, StrUserToken, String.Empty); button_login.Label = "登录\r\n"; button_login.Image = Properties.Resources.Logout; Globals.ThisAddIn.TaskWidget.Visible = false; ResetButtonEnable(false); } } }
private void InsertNumber(HexBox _hexbox, int byteCount, bool BigEndian) { PromptBox prompt = new PromptBox(); if (prompt.ShowDialog() == DialogResult.OK) { byte[] bytes = new byte[byteCount]; long number = (long)BaseConverter.ToNumberParse(prompt.Value); for (int i = 0; i < bytes.Length; i++) { bytes[BigEndian ? (bytes.Length - i - 1) : i] = (byte)((number >> (i * 8)) & 0xff); } _hexbox.ByteProvider.DeleteBytes(_hexbox.SelectionStart, _hexbox.SelectionLength); _hexbox.ByteProvider.InsertBytes(_hexbox.SelectionStart, bytes); _hexbox.Select(_hexbox.SelectionStart, bytes.Length); } }
public static bool Update() { UninstallPlugin(); String strinstall = Rigel.PluginDir + "Plugins/InstallVSTO.bat"; try { if (File.Exists(strinstall)) { ProcessStartInfo startInfo = new ProcessStartInfo(strinstall); //设置不在新窗口中启动新的进程 startInfo.CreateNoWindow = true; //不使用操作系统使用的shell启动进程 startInfo.UseShellExecute = false; //将输出信息重定向 startInfo.RedirectStandardOutput = true; Process process = Process.Start(startInfo); if (process != null) { process.WaitForExit(); return true; } } else { bool flag = execCmd("i"); if (!flag) { PromptBox.Prompt("升级失败"); } return flag; } } catch (Exception ex) { Logger.LogError(ex.ToString()); PromptBox.Prompt("非常抱歉更新失败,请联系工作人员!"); } return false; }
/// <summary> /// Execute the command /// </summary> public void Exec() { if (_layer == null) { return; } XmiImporter importer = new XmiImporter(_layer); PromptBox prompt = new PromptBox("Xmi file name", "xmi files|*.xmi"); if (prompt.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { importer.Import(prompt.Value); } catch (Exception ex) { ServiceLocator.Instance.IDEHelper.ShowError("Import error : " + ex.Message); } } }
/// <summary> /// Méthode appelée quand la clr n'arrive pas à résoudre l'assembly /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="args">The <see cref="System.ResolveEventArgs"/> instance containing the event data.</param> /// <returns></returns> Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { string name = args.Name; int pos = name.IndexOf(','); if (pos > 0) { name = name.Substring(0, pos).Trim(); } name += ".dll"; Assembly assembly = null; try { assembly = Assembly.ReflectionOnlyLoad(args.Name); } catch { try { assembly = Assembly.ReflectionOnlyLoadFrom(Path.Combine(_initialAssemblyPath, name)); } catch { // On demande à l'utilisateur PromptBox prompt = new PromptBox("Veuillez indiquer l'emplacement de l'assembly : " + name, "Assemblies|*.dll"); if (prompt.ShowDialog() == System.Windows.Forms.DialogResult.OK) { assembly = Assembly.ReflectionOnlyLoadFrom(Path.Combine(prompt.Value, name)); } } } if (assembly != null) { _referencedAssemblies.Add(assembly); } return(assembly); }
private async void button_login_Click(object sender, EventArgs e) { String strAccount = ""; String identCode = ""; String inviteCode = ""; if (string.IsNullOrEmpty(lineEdit_account.Text)) { errorProvider.ErrorAlignment = ErrorAlignment.Top; errorProvider.SetError(account_Layout, "手机号为空"); return; } if (string.IsNullOrEmpty(lineEdit_identCode.Text)) { errorProvider.ErrorAlignment = ErrorAlignment.Top; errorProvider.SetError(ident_Layout, "验证码为空"); return; } strAccount = lineEdit_account.Text; identCode = lineEdit_identCode.Text; inviteCode = lineEdit_inviteCode.Text; try { bool isLogin = await RequestHandle.Login(strAccount, identCode, inviteCode); if (isLogin) { DialogResult = DialogResult.OK; this.Close(); } } catch (Exception ex) { PromptBox.Error(ex.Message); } }
private void readWriteAddressMemoryMenuItem_Click(object sender, EventArgs e) { PromptBox prompt = new PromptBox(); if (prompt.ShowDialog() == DialogResult.OK) { IntPtr address = new IntPtr(-1); IntPtr regionAddress = IntPtr.Zero; long regionSize = 0; bool found = false; try { address = ((long)BaseConverter.ToNumberParse(prompt.Value)).ToIntPtr(); } catch { PhUtils.ShowError("You have entered an invalid address."); return; } List<MemoryItem> items = new List<MemoryItem>(); foreach (MemoryItem item in _provider.Dictionary.Values) items.Add(item); items.Sort((i1, i2) => i1.Address.CompareTo(i2.Address)); int i = 0; foreach (MemoryItem item in items) { if (item.Address.CompareTo(address) > 0) { MemoryItem regionItem = items[i - 1]; listMemory.Items[regionItem.Address.ToString()].Selected = true; listMemory.Items[regionItem.Address.ToString()].EnsureVisible(); regionAddress = regionItem.Address; regionSize = regionItem.Size; found = true; break; } i++; } if (!found) { PhUtils.ShowError("Unable to find the memory address."); return; } MemoryEditor m_e = MemoryEditor.ReadWriteMemory(_pid, regionAddress, (int)regionSize, false, new Program.MemoryEditorInvokeAction(delegate(MemoryEditor f) { f.Select(address.Decrement(regionAddress).ToInt64(), 1); })); } }
private void readWriteAddressMemoryMenuItem_Click(object sender, EventArgs e) { PromptBox prompt = new PromptBox(); if (prompt.ShowDialog() == DialogResult.OK) { IntPtr address = new IntPtr(-1); IntPtr regionAddress = IntPtr.Zero; long regionSize = 0; bool found = false; try { address = ((long)BaseConverter.ToNumberParse(prompt.Value)).ToIntPtr(); } catch { PhUtils.ShowError("You have entered an invalid address."); return; } List <MemoryItem> items = new List <MemoryItem>(); foreach (MemoryItem item in _provider.Dictionary.Values) { items.Add(item); } items.Sort((i1, i2) => i1.Address.CompareTo(i2.Address)); int i = 0; foreach (MemoryItem item in items) { MemoryItem regionItem = null; if (item.Address.CompareTo(address) > 0) { if (i > 0) { regionItem = items[i - 1]; } } else if (item.Address.CompareTo(address) == 0) { regionItem = items[i]; } if (regionItem != null && address.CompareTo(regionItem.Address) >= 0) { listMemory.Items[regionItem.Address.ToString()].Selected = true; listMemory.Items[regionItem.Address.ToString()].EnsureVisible(); regionAddress = regionItem.Address; regionSize = regionItem.Size; found = true; break; } i++; } if (!found) { PhUtils.ShowError("Unable to find the memory address."); return; } MemoryEditor m_e = MemoryEditor.ReadWriteMemory(_pid, regionAddress, (int)regionSize, false, new Program.MemoryEditorInvokeAction(delegate(MemoryEditor f) { f.Select(address.Decrement(regionAddress).ToInt64(), 1); })); } }
private void Button4_Click(object sender, EventArgs e) { PromptBox box = new PromptBox(); box.ShowDialog(); }
private void exportToolStripButton_Click(object sender, EventArgs e) { // Click on Export button... Collection <ListViewItem> checkedItems = ListView2.GetCheckedItems(customTracksListView); Cursor = Cursors.WaitCursor; try { if (checkedItems.Count == 0) { MessageBoxes.ShowWarning(this, _WARNING_CHECK_EXPORT); } else { // All tracks must have replacing information foreach (ListViewItem anotherItem in checkedItems) { DFE currentTrack = anotherItem.Tag as DFE; if (currentTrack != null) { FileInfo fi = new FileInfo(currentTrack.FileName); DFE replacedChallenge = _GetReplacedChallenge(fi.Name); if (replacedChallenge == null) { throw new Exception(_ERROR_REPLACE_EXPORT); } } } // Asks for track name PromptBox pBox = new PromptBox(_TITLE_EXPORT, _MSG_EXPORT, _NAME_EXPORT); DialogResult dr = pBox.ShowDialog(this); if (dr == DialogResult.OK) { // Displays export target folder folderBrowserDialog.Description = _MSG_PATH_EXPORT; dr = folderBrowserDialog.ShowDialog(this); if (dr == DialogResult.OK) { _ExportTracks(checkedItems, pBox.ReturnValue, folderBrowserDialog.SelectedPath); string msg = string.Format(_FORMAT_EXPORT_OK, checkedItems.Count); StatusBarLogManager.ShowEvent(this, msg); } } } } catch (Exception ex) { MessageBoxes.ShowError(this, ex); } finally { Cursor = Cursors.Default; } }
/// <summary> /// Sélection d'un modèle /// </summary> /// <param name="component">The component.</param> /// <param name="metaData">The meta data.</param> /// <returns></returns> bool IModelsMetadata.SelectModel(ExternalComponent component, out ComponentModelMetadata metaData) { metaData = null; // Ici on veut saisir le fichier décrivant le système ComponentType?ct = null; if (component.MetaData != null) { ct = component.MetaData.ComponentType; } RepositoryTreeForm wizard = new RepositoryTreeForm(true, ct); if (wizard.ShowDialog() == System.Windows.Forms.DialogResult.OK) { // On doit le créer if (wizard.SelectedItem == null) { // // Création d'un composant externe // if (component.Name == String.Empty) { PromptBox pb = new PromptBox("Name of the new component"); if (pb.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(false); } // Vérification des doublons. if (_metadatas.NameExists(pb.Value)) { IIDEHelper ide = ServiceLocator.Instance.IDEHelper; if (ide != null) { ide.ShowMessage("This model already exists in this model."); } return(false); } component.Name = pb.Value; } // Création d'un modèle vide dans un répertoire temporaire string relativeModelFileName = component.Name + ModelConstants.FileNameExtension; string fn = Utils.GetTemporaryFileName(relativeModelFileName); Directory.CreateDirectory(System.IO.Path.GetDirectoryName(fn)); // Persistence du modèle CandleModel model = ModelLoader.CreateModel(component.Name, component.Version); component.ModelMoniker = model.Id; SerializationResult result = new SerializationResult(); CandleSerializationHelper.Instance.SaveModel(result, model, fn); // Et ouverture du modèle ServiceLocator.Instance.ShellHelper.Solution.DTE.ItemOperations.OpenFile(fn, EnvDTE.Constants.vsViewKindDesigner); } else // Sinon affectation { metaData = wizard.SelectedItem; ExternalComponent externalComponent = component.Model.FindExternalComponent(metaData.Id); if (externalComponent != null) { IIDEHelper ide = ServiceLocator.Instance.IDEHelper; if (ide != null) { ide.ShowMessage("This model already exists in this model."); } return(false); } metaData.UpdateComponent(component); } return(true); // On ne passe pas dans le rollback } return(false); }