public string GetRelativeProjectPath(string name) { if (!NameToPath.ContainsKey(name)) { if (MessageService.AskQuestion("Project reference to " + name + " could not be resolved.\n" + "Do you want to specify it manually?")) { using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Title = "Find " + name; dlg.InitialDirectory = basePath; dlg.Filter = "SharpDevelop 1.x project|*.prjx"; if (dlg.ShowDialog() == DialogResult.OK) { NameToPath[name] = dlg.FileName; NameToGuid[name] = Guid.NewGuid(); return(FileUtility.GetRelativePath(basePath, NameToPath[name])); } } } return("NotFound." + name + ".proj"); } return(FileUtility.GetRelativePath(basePath, NameToPath[name])); }
/// <summary> /// Tool Bar Delete Click /// </summary> private void toolbarDelete_Click(object sender, EventArgs e) { if (MessageService.AskQuestion("${res:Global.DeleteNoteMessage}", "${res:Global.SystemInfo}")) { if (_enterprise.Delete()) { foreach (IViewContent viewContent in WorkbenchSingleton.Workbench.ViewContentCollection) { if (viewContent.TitleName == StringParser.Parse("${res:FanHai.Hemera.Addins.FMM.EnterpriseViewContent.TitleName}")) { WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.CloseWindow(true); viewContent.WorkbenchWindow.SelectWindow(); return; } } WorkbenchSingleton.Workbench.ActiveViewContent.TitleName = StringParser.Parse("${res:FanHai.Hemera.Addins.FMM.EnterpriseViewContent.TitleName}"); CtrlState = ControlState.New; } } }
void ConfigurationChanged(object sender, EventArgs e) { if (resettingIndex) { return; } if (helper.IsDirty) { if (!MessageService.AskQuestion("${res:Dialog.ProjectOptions.ContinueSwitchConfiguration}")) { ResetIndex(); return; } if (!helper.Save()) { ResetIndex(); return; } } helper.Configuration = (string)configurationComboBox.SelectedItem; helper.Platform = (string)platformComboBox.SelectedItem; helper.Load(); }
void OnSteticFileChanged(object s, FileSystemEventArgs args) { Runtime.RunInMainThread(() => { lock (fileSaveLock) { if (lastSaveTime == System.IO.File.GetLastWriteTime(fileName)) { return; } } if (GuiBuilderService.HasOpenDesigners(project, true)) { if (MessageService.AskQuestion(GettextCatalog.GetString("The project '{0}' has been modified by an external application. Do you want to reload it?", project.Name), GettextCatalog.GetString("Unsaved changes in the open GTK designers will be lost."), AlertButton.Cancel, AlertButton.Reload) != AlertButton.Reload) { return; } } if (!disposed) { Reload(); } }); }
/// <summary> /// Tool Bar Save Click /// </summary> private void toolbarSave_Click(object sender, EventArgs e) { if (MessageService.AskQuestion("${res:Global.EnsureSaveCurrentData}", "${res:Global.SystemInfo}")) { MapControlsToParam(); if (_param.ParamName == string.Empty) { MessageService.ShowMessage("${res:Global.NameNotNullMessage}", "${res:Global.SystemInfo}"); return; } if (CtrlState == ControlState.New && !_param.ParamNameValidate()) { MessageService.ShowMessage("${res:Global.NameIsExistMessage}", "${res:Global.SystemInfo}"); return; } if (CtrlState == ControlState.New) { if (_param.Insert()) { WorkbenchSingleton.Workbench.ActiveViewContent.TitleName = StringParser.Parse("${res:FanHai.Hemera.Addins.EDC.ParamViewContent}") + "_" + _param.ParamName; CtrlState = ControlState.Edit; } } else { _param.Editor = PropertyService.Get(PROPERTY_FIELDS.USER_NAME); if (_param.Update()) { CtrlState = ControlState.Edit; } } } }
public bool DropSelectedIndexes(bool confirm) { if (grd.SelectedRows.Count == 0) { return(false); } if (confirm && !MessageService.AskQuestion("Are you sure you want to drop selected indexes?")) { return(false); } IndexWrapper idx = null; foreach (DataGridViewRow row in grd.SelectedRows) { if (!Utils.IsDbValueValid(row.Cells[0]) || !Utils.IsDbValueValid(row.Cells[1]) || !Utils.IsDbValueValid(row.Cells[2]) || !Utils.IsDbValueValid(row.Cells[3]) || !Utils.IsDbValueValid(row.Cells[4])) { continue; } idx = new IndexWrapper(_cp); idx.ID = (short)row.Cells[1].Value; idx.OwnerObjectId = (int)row.Cells[0].Value; idx.OwnerObjectName = (string)row.Cells[3].Value; idx.Owner = (string)row.Cells[2].Value; idx.Name = (string)row.Cells[4].Value; idx.Drop(); } RefreshIndexes(); return(true); }
private void btnDel_Click(object sender, EventArgs e) { //系统提示确定要删除吗? if (MessageService.AskQuestion(StringParser.Parse("${res:FanHai.Hemera.Addins.Msg.DeleteRemind}"), StringParser.Parse("${res:Global.SystemInfo}"))) { int rowHandle = 0; //焦点没有获取到 if (ShiftView.FocusedRowHandle < 0) { //系统提示没有选中行 MessageService.ShowMessage("${res:FanHai.Hemera.Addin.SelectRemaind}", "${res:Global.SystemInfo}"); return; } else { rowHandle = ShiftView.FocusedRowHandle; Shift shift = new Shift(); shift.ScheduleKey = _schedule.ScheduleKey; shift.ShiftKey = this.ShiftView.GetRowCellValue(rowHandle, shift_key).ToString(); if (shift.ShiftKey != string.Empty && shift.ScheduleKey != string.Empty) { shift.DeleteShift(); if (shift.ErrorMsg == string.Empty) { //delete row from gridView 删除成功 MessageService.ShowMessage("${res:FanHai.Hemera.Addins.Msg.DeleteSucceed}", "${res:Global.SystemInfo}"); ShiftView.DeleteSelectedRows(); } else { MessageService.ShowError("${res:FanHai.Hemera.Addins.Msg.DeleteFailed}" + shift.ErrorMsg); } } } } }
void LoadVSSettings(XDocument document) { XElement[] items; if (!CheckVersionAndFindCategory(document, out items) || items == null) { Core.MessageService.ShowError("${res:Dialog.HighlightingEditor.NotSupportedMessage}"); return; } if (!MessageService.AskQuestion("${res:Dialog.HighlightingEditor.OverwriteCustomizationsMessage}")) { return; } ResetAllButtonClick(null, null); foreach (var item in items) { string key = item.Attribute("Name").Value; var entry = ParseEntry(item); foreach (var sdKey in mapping[key]) { IHighlightingItem color; if (FindSDColor(sdKey, out color)) { color.Bold = entry.Item3; color.UseDefaultForeground = !entry.Item1.HasValue; if (entry.Item1 != null) { color.Foreground = entry.Item1.Value; } color.UseDefaultBackground = !entry.Item2.HasValue; if (entry.Item2 != null) { color.Background = entry.Item2.Value; } } } } }
public override void DeleteMultipleItems() { QuestionMessage msg = new QuestionMessage(); msg.SecondaryText = GettextCatalog.GetString("The Delete option permanently removes the file from your hard disk. Click Remove from Solution if you only want to remove it from your current solution."); AlertButton removeFromSolution = new AlertButton(GettextCatalog.GetString("_Remove from Solution"), Gtk.Stock.Remove); msg.Buttons.Add(AlertButton.Delete); msg.Buttons.Add(AlertButton.Cancel); msg.Buttons.Add(removeFromSolution); msg.AllowApplyToAll = true; foreach (ITreeNavigator nav in CurrentNodes) { SolutionFolderFileNode file = (SolutionFolderFileNode)nav.DataItem; if (file.Parent.IsRoot) { msg.Text = GettextCatalog.GetString("Are you sure you want to remove the file {0} from the solution folder {1}?", file.FileName.FileName, file.Parent.Name); } else { msg.Text = GettextCatalog.GetString("Are you sure you want to remove the file {0} from the solution {1}?", file.FileName.FileName, file.Parent.ParentSolution.Name); } AlertButton result = MessageService.AskQuestion(msg); if (result == AlertButton.Cancel) { return; } file.Parent.Files.Remove(file.FileName); if (result == AlertButton.Delete) { FileService.DeleteFile(file.FileName); } } }
private void tsbDelete_Click(object sender, EventArgs e) { if (gvFactoryShift.FocusedRowHandle < 0 || gvFactoryShift.RowCount < 1) { MessageService.ShowMessage("请选择要删除的数据!", "提示"); return; } if (MessageService.AskQuestion("确认要删除数据么?", "提示")) { sFactoryShiftSetKey = gvFactoryShift.GetRowCellValue(gvFactoryShift.FocusedRowHandle, "FACTORYSHIFTSET_KEY").ToString(); if (!string.IsNullOrEmpty(sFactoryShiftSetKey) && !string.IsNullOrEmpty(sFactoryShiftSetKey)) { string sql = "DELETE FROM BASE_FACTORYSHIFT_SET WHERE FACTORYSHIFTSET_KEY='" + sFactoryShiftSetKey + "'"; DataSet dsDelFSS = optEntity.UpdateData(sql, "DelFactoryShiftSet"); int nDelRows = int.Parse(dsDelFSS.ExtendedProperties["rows"].ToString()); if (nDelRows < 1) { MessageService.ShowMessage("无数据删除!", "提示"); return; } if (!string.IsNullOrEmpty(optEntity.ErrorMsg)) { MessageService.ShowError(optEntity.ErrorMsg); return; } MessageService.ShowMessage("数据删除成功!", "提示"); } else { MessageService.ShowMessage("数据删除失败,请重试!", "提示"); return; } } sFlag = "D"; ButtonState(); btnQuery_Click(sender, e); }
private void btnDelete_Click(object sender, EventArgs e) { if (gvTestRule.FocusedRowHandle < 0 || gvTestRule.RowCount < 1) { //MessageService.ShowMessage("请选择删除的数据!", "提示"); MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.BasicTestRule.msg.0001}"), StringParser.Parse("${res:Global.SystemInfo}")); return; } //if (MessageService.AskQuestion("确认删除数据么?", "提示")) if (MessageService.AskQuestion(StringParser.Parse("${res:FanHai.Hemera.Addins.BasicTestRule.msg.0002}"), StringParser.Parse("${res:Global.SystemInfo}"))) { //删除处理 DataSet dsTestRule = new DataSet(); DataTable dtTestRule = ((DataView)gvTestRule.DataSource).Table; string pk = gvTestRule.GetRowCellValue(gvTestRule.FocusedRowHandle, BASE_TESTRULE.FIELDS_TESTRULE_KEY).ToString(); DataRow[] drTestRules = dtTestRule.Select(string.Format(BASE_TESTRULE.FIELDS_TESTRULE_KEY + "='{0}'", pk)); DataTable dtDel = dtTestRule.Clone(); DataRow drDel = drTestRules[0]; drDel[BASE_TESTRULE.FIELDS_ISFLAG] = 0; dtDel.ImportRow(drDel); dtDel.TableName = BASE_TESTRULE.DATABASE_TABLE_FORUPDATE; dsTestRule.Merge(dtDel, true, MissingSchemaAction.Add); bool bl_bak = _baseTestRuleEntity.SavePowerSetData(dsTestRule); if (!bl_bak) { //MessageService.ShowMessage("删除失败!"); MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.BasicTestRule.msg.0003}"), StringParser.Parse("${res:Global.SystemInfo}")); } else { //MessageService.ShowMessage("删除成功!"); MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.BasicTestRule.msg.0004}"), StringParser.Parse("${res:Global.SystemInfo}")); InitDataBind(); } } }
public override void Run() { if (CanRunBuild) { if (DebuggerService.IsDebuggerLoaded && DebuggerService.CurrentDebugger.IsDebugging) { if (MessageService.AskQuestion("${res:XML.MainMenu.RunMenu.Compile.StopDebuggingQuestion}", "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingTitle}")) { DebuggerService.CurrentDebugger.Stop(); } else { return; } } BeforeBuild(); StartBuild(); } else { AddNoSingleFileCompilationError(); } }
public static ReplaceExistingFile ShowReplaceExistingFileDialog(string caption, string fileName, bool replacingMultiple) { if (caption == null) { caption = "${res:ProjectComponent.ContextMenu.AddExistingFiles.ReplaceExistingFile.Title}"; } string text = StringParser.Parse("${res:ProjectComponent.ContextMenu.AddExistingFiles.ReplaceExistingFile}", new StringTagPair("FileName", fileName)); if (replacingMultiple) { return((ReplaceExistingFile) MessageService.ShowCustomDialog(caption, text, 0, 3, "${res:Global.Yes}", "${res:Global.YesToAll}", "${res:Global.No}", "${res:Global.CancelButtonText}")); } else { return(MessageService.AskQuestion(text, caption) ? ReplaceExistingFile.Yes : ReplaceExistingFile.No); } }
public MigrationType ShouldMigrateProject() { if (Migration.HasValue) { return(Migration.Value); } var buttonBackupAndMigrate = new AlertButton(GettextCatalog.GetString("Back up and migrate")); var buttonMigrate = new AlertButton(GettextCatalog.GetString("Migrate")); var buttonIgnore = new AlertButton(GettextCatalog.GetString("Ignore")); var response = MessageService.AskQuestion( GettextCatalog.GetString("Migrate Project?"), GettextCatalog.GetString( "One or more projects must be migrated to a new format. " + "After migration, it will not be able to be opened in " + "older versions of MonoDevelop.\n\n" + "If you choose to back up the project before migration, a copy of the project " + "file will be saved in a 'backup' directory in the project directory."), buttonIgnore, buttonMigrate, buttonBackupAndMigrate); // If we get an unexpected response, the default should be to *not* migrate if (response == buttonBackupAndMigrate) { Migration = MigrationType.BackupAndMigrate; } else if (response == buttonMigrate) { Migration = MigrationType.Migrate; } else { Migration = MigrationType.Ignore; } return(Migration.Value); }
public override void Run() { TreeNode schemaNode = Workbench.Instance.ObjectExplorer.GetSelectedNode(); if (schemaNode.Level == 2 && MessageService.AskQuestion("Are you sure you want to delete this schema?")) { FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>(); FdoConnection conn = mgr.GetConnection(schemaNode.Parent.Name); using (FdoFeatureService service = conn.CreateFeatureService()) { try { service.DestroySchema(schemaNode.Name); Msg.ShowMessage(Res.GetString("MSG_SCHEMA_DELETED"), Res.GetString("TITLE_DELETE_SCHEMA")); Log.InfoFormatted(Res.GetString("LOG_SCHEMA_DELETED"), schemaNode.Name, schemaNode.Parent.Name); mgr.RefreshConnection(schemaNode.Parent.Name); } catch (OSGeo.FDO.Common.Exception ex) { Msg.ShowError(ex); } } } }
void OnBeforeRemoveConnection(object sender, ConnectionBeforeRemoveEventArgs e) { FdoConnection conn = connMgr.GetConnection(e.ConnectionName); //Get all views that depend on connection List <IConnectionDependentView> matches = _tabs.FindAll(delegate(IConnectionDependentView c) { return(c.DependsOnConnection(conn)); }); if (matches.Count > 0) { //Don't close then cancel if (!MessageService.AskQuestion(ResourceService.GetStringFormatted("QUESTION_CLOSE_TABS", e.ConnectionName))) { e.Cancel = true; return; } else //Otherwise remove from watch list and close the view { foreach (IConnectionDependentView view in matches) { _tabs.Remove(view); view.Close(); } } } }
private void StartBulkCopy() { if (_cpDest == null) { MessageService.ShowError("Destination connection not specified!"); return; } string confirmMsg = String.Format(Properties.Resources.CopyDataConfirmation, _cp.InfoDbServer, _cpDest.InfoDbServer); SqlBulkCopyOptions ops = EvalSqlBulkCopyOptions(); if ((ops & SqlBulkCopyOptions.TableLock) == SqlBulkCopyOptions.TableLock) { int majorServerVersion = SmoHelpers.GetServerMajorVersion(_cpDest); if (majorServerVersion == 9 && !MessageService.AskQuestion(Properties.Resources.TableLock_Notification + confirmMsg)) return; } else if (!MessageService.AskQuestion(confirmMsg)) return; BulkCopyArgs args = new BulkCopyArgs(); args.Objects = objList.SelectedObjects; args.StopOnError = chkStopOnError.Checked; args.CopyOptions = EvalSqlBulkCopyOptions(); _copying = true; _cancelled = false; wizardControl1.NextButtonEnabled = false; wizardControl1.BackButtonEnabled = false; _totalCopied = 0; lblTotal.Text = String.Empty; StartTimer(); bw.RunWorkerAsync(args); }
public static void AddController(AspMvcProject project, string path, string name) { var provider = project.LanguageBinding.GetCodeDomProvider(); if (provider == null) { throw new InvalidOperationException("Project language has null CodeDOM provider"); } string outputFile = null; MvcTextTemplateHost host = null; AddControllerDialog dialog = null; try { dialog = new AddControllerDialog(project); if (!String.IsNullOrEmpty(name)) { dialog.ControllerName = name; } bool fileGood = false; while (!fileGood) { var resp = (Gtk.ResponseType)MessageService.RunCustomDialog(dialog); dialog.Hide(); if (resp != Gtk.ResponseType.Ok || !dialog.IsValid()) { return; } outputFile = System.IO.Path.Combine(path, dialog.ControllerName) + ".cs"; if (System.IO.File.Exists(outputFile)) { fileGood = MessageService.AskQuestion("Overwrite file?", String.Format("The file '{0}' already exists.\n", dialog.ControllerName) + "Would you like to overwrite it?", AlertButton.OverwriteFile, AlertButton.Cancel) != AlertButton.Cancel; } else { break; } } host = new MvcTextTemplateHost { LanguageExtension = provider.FileExtension, ItemName = dialog.ControllerName, NameSpace = project.DefaultNamespace + ".Controllers" }; host.ProcessTemplate(dialog.TemplateFile, outputFile); MonoDevelop.TextTemplating.TextTemplatingService.ShowTemplateHostErrors(host.Errors); } finally { if (host != null) { host.Dispose(); } if (dialog != null) { dialog.Destroy(); } } if (System.IO.File.Exists(outputFile)) { project.AddFile(outputFile); IdeApp.ProjectOperations.Save(project); } }
public override void DeleteMultipleItems() { var projects = new Set <SolutionEntityItem> (); var folders = new List <ProjectFolder> (); foreach (ITreeNavigator node in CurrentNodes) { folders.Add((ProjectFolder)node.DataItem); } var removeButton = new AlertButton(GettextCatalog.GetString("_Remove from Project"), Gtk.Stock.Remove); var question = new QuestionMessage() { AllowApplyToAll = folders.Count > 1, SecondaryText = GettextCatalog.GetString( "The Delete option permanently removes the directory and any files it contains from your hard disk. " + "Click Remove from Project if you only want to remove it from your current solution.") }; question.Buttons.Add(AlertButton.Cancel); question.Buttons.Add(AlertButton.Delete); question.Buttons.Add(removeButton); var deleteOnlyQuestion = new QuestionMessage() { AllowApplyToAll = folders.Count > 1, SecondaryText = GettextCatalog.GetString("The directory and any files it contains will be permanintly removed from your hard disk. ") }; deleteOnlyQuestion.Buttons.Add(AlertButton.Cancel); deleteOnlyQuestion.Buttons.Add(AlertButton.Delete); foreach (var folder in folders) { var project = folder.Project; var folderRelativePath = folder.Path.ToRelative(project.BaseDirectory); var files = project.Files.GetFilesInVirtualPath(folderRelativePath).ToList(); var folderPf = project.Files.GetFileWithVirtualPath(folderRelativePath); bool isProjectFolder = files.Count == 0 && folderPf == null; AlertButton result; //if the parent directory has already been removed, there may be nothing to do if (isProjectFolder) { deleteOnlyQuestion.Text = GettextCatalog.GetString("Are you sure you want to remove directory {0}?", folder.Name); result = MessageService.AskQuestion(deleteOnlyQuestion); if (result != AlertButton.Delete) { break; } } else { question.Text = GettextCatalog.GetString("Are you sure you want to remove directory {0} from project {1}?", folder.Name, project.Name); result = MessageService.AskQuestion(question); if (result != removeButton && result != AlertButton.Delete) { break; } projects.Add(project); //remove the files and link files in the directory foreach (var f in files) { project.Files.Remove(f); } // also remove the folder's own ProjectFile, if it exists // FIXME: it probably was already in the files list if (folderPf != null) { project.Files.Remove(folderPf); } } if (result == AlertButton.Delete) { try { if (Directory.Exists(folder.Path)) { // FileService events should remove remaining files from the project FileService.DeleteDirectory(folder.Path); } } catch (Exception ex) { MessageService.ShowError(GettextCatalog.GetString( "The folder {0} could not be deleted from disk: {1}", folder.Path, ex.Message)); } } else { //explictly remove the node from the tree, since it currently only tracks real folder deletions folder.Remove(); } if (isProjectFolder && folder.Path.ParentDirectory != project.BaseDirectory) { // If it's the last item in the parent folder, make sure we keep a reference to the parent // folder, so it is not deleted from the tree. var inParentFolder = project.Files.GetFilesInVirtualPath(folderRelativePath.ParentDirectory); if (!inParentFolder.Skip(1).Any()) { project.Files.Add(new ProjectFile(folder.Path.ParentDirectory) { Subtype = Subtype.Directory, }); } } } IdeApp.ProjectOperations.Save(projects); }
void FileRemoving(object sender, FileCancelEventArgs e) { if (e.Cancel) { return; } string fullName = Path.GetFullPath(e.FileName); if (!CanBeVersionControlledFile(fullName)) { return; } if (e.IsDirectory) { // show "cannot delete directories" message even if // AutomaticallyDeleteFiles (see below) is off! using (SvnClientWrapper client = new SvnClientWrapper()) { SvnMessageView.HandleNotifications(client); try { Status status = client.SingleStatus(fullName); switch (status.TextStatus) { case StatusKind.None: case StatusKind.Unversioned: case StatusKind.Ignored: break; default: // must be done using the subversion client, even if // AutomaticallyDeleteFiles is off, because we don't want to corrupt the // working copy e.OperationAlreadyDone = true; try { client.Delete(new string[] { fullName }, false); } catch (SvnClientException ex) { LoggingService.Warn("SVN Error" + ex); LoggingService.Warn(ex); if (ex.IsKnownError(KnownError.CannotDeleteFileWithLocalModifications) || ex.IsKnownError(KnownError.CannotDeleteFileNotUnderVersionControl)) { if (MessageService.ShowCustomDialog("${res:AddIns.Subversion.DeleteDirectory}", StringParser.Parse("${res:AddIns.Subversion.ErrorDelete}:\n", new StringTagPair("File", fullName)) + ex.Message, 0, 1, "${res:AddIns.Subversion.ForceDelete}", "${res:Global.CancelButtonText}") == 0) { try { client.Delete(new string[] { fullName }, true); } catch (SvnClientException ex2) { e.Cancel = true; MessageService.ShowError(ex2.Message); } } else { e.Cancel = true; } } else { e.Cancel = true; MessageService.ShowError(ex.Message); } } break; } } catch (SvnClientException ex3) { e.Cancel = true; MessageService.ShowError(ex3.Message); } } return; } // not a directory, but a file: if (!AddInOptions.AutomaticallyDeleteFiles) { return; } try { using (SvnClientWrapper client = new SvnClientWrapper()) { SvnMessageView.HandleNotifications(client); Status status = client.SingleStatus(fullName); switch (status.TextStatus) { case StatusKind.None: case StatusKind.Unversioned: case StatusKind.Ignored: case StatusKind.Deleted: return; // nothing to do case StatusKind.Normal: // remove without problem break; case StatusKind.Modified: case StatusKind.Replaced: if (MessageService.AskQuestion("${res:AddIns.Subversion.RevertLocalModifications}")) { // modified files cannot be deleted, so we need to revert the changes first client.Revert(new string[] { fullName }, e.IsDirectory ? Recurse.Full : Recurse.None); } else { e.Cancel = true; return; } break; case StatusKind.Added: if (status.Copied) { if (!MessageService.AskQuestion("${res:AddIns.Subversion.RemoveMovedFile}")) { e.Cancel = true; return; } } client.Revert(new string[] { fullName }, e.IsDirectory ? Recurse.Full : Recurse.None); return; default: MessageService.ShowErrorFormatted("${res:AddIns.Subversion.CannotRemoveError}", status.TextStatus.ToString()); e.Cancel = true; return; } e.OperationAlreadyDone = true; client.Delete(new string [] { fullName }, true); } } catch (Exception ex) { MessageService.ShowError("File removed exception: " + ex); } }
/// <summary> /// 新增批次操作记录。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { try { string lotNumber = this.teLotNumber.Text; string roomKey = Convert.ToString(this.lueFactoryRoom.EditValue); //车间没有选择,给出提示。 if (string.IsNullOrEmpty(roomKey)) { MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.WIP.LotDispatch.Msg004}"), MESSAGEBOX_CAPTION);//车间名称不能为空 //MessageService.ShowMessage("车间名称不能为空", "提示"); this.lueFactoryRoom.Select(); return; } //批号没有输入,给出提示。 if (string.IsNullOrEmpty(lotNumber)) { MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.WIP.LotUndoCtrl.Msg001}"), MESSAGEBOX_CAPTION);//请输入序列号 //MessageService.ShowMessage("请输入序列号。", "提示"); return; } DataSet dsReturn = this._entity.GetLotLastestActivity(lotNumber); if (!string.IsNullOrEmpty(this._entity.ErrorMsg)) { MessageService.ShowError(this._entity.ErrorMsg); return; } if (dsReturn == null || dsReturn.Tables.Count <= 0 || dsReturn.Tables[0].Rows.Count <= 0) { MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.WIP.LotUndoCtrl.Msg002}"), MESSAGEBOX_CAPTION);//输入的序列号没有操作可被撤销 //MessageService.ShowMessage("输入的序列号没有操作可被撤销。", "提示"); return; } DataTable dtReturn = dsReturn.Tables[0]; DataRow drReturn = dtReturn.Rows[0]; //判断批次号在指定车间中是否存在。 string curRoomKey = Convert.ToString(drReturn[POR_LOT_FIELDS.FIELD_FACTORYROOM_KEY]); if (roomKey != curRoomKey) { MessageService.ShowMessage(string.Format("【{0}】在当前车间中不存在,请确认。", lotNumber), "提示"); return; } string curOperationName = Convert.ToString(drReturn[WIP_TRANSACTION_FIELDS.FIELD_STEP_NAME]); string createOperationName = Convert.ToString(drReturn[POR_LOT_FIELDS.FIELD_CREATE_OPERTION_NAME]); string palletNo = Convert.ToString(drReturn[POR_LOT_FIELDS.FIELD_PALLET_NO]); if (!string.IsNullOrEmpty(palletNo) && MessageService.AskQuestion(string.Format("组件已包装,若撤销会影响托盘({0})数据及其中的所有组件数据,是否确认?", palletNo), "询问") == false) { return; } string activity = Convert.ToString(drReturn[WIP_TRANSACTION_FIELDS.FIELD_ACTIVITY]); //操作是否允许撤销。 //if (!AllowUndoActivityList.ContainsKey(activity)) //{ // MessageService.ShowMessage(string.Format("对不起,操作({0})不能被撤销。",activity), "提示"); // return; //} string operations = PropertyService.Get(PROPERTY_FIELDS.OPERATIONS);//获取有权限的所有工序 //除批次进站 批次出站或创建批次外,不卡控工序权限。 if (activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_TRACKIN || activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_TRACKOUT || activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_CREATELOT || activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_CELLSCRAP || activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_PATCHED || activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_PATCH) { //非创建批次操作,检查登录用户对批次操作时的工序是否拥有权限。 if ((activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_TRACKIN || activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_TRACKOUT) && (operations + ",").IndexOf(curOperationName + ",") == -1) { MessageService.ShowMessage(string.Format("您没有权限撤销工序[{0}]的[{1}]操作。", curOperationName, activity), "提示"); return; } //创建批次操作,判断用户对创建批次工序是否拥有权限。 if ((activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_CREATELOT || activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_CELLSCRAP || activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_PATCHED || activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_PATCH) && (operations + ",").IndexOf(createOperationName + ",") == -1) { MessageService.ShowMessage(string.Format("您没有权限撤销工序[{0}]的[{1}]操作。", createOperationName, activity), "提示"); return; } } //只有包装人员才允许撤销 返工单作业 if ((activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_CHANGE_PROID) && (operations + ",").IndexOf("包装,") == -1) { MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.WIP.LotUndoCtrl.Msg003}"), MESSAGEBOX_CAPTION);//只有包装人员才允许撤销返工单作业 //MessageService.ShowMessage(string.Format("只有包装人员才允许撤销返工单作业。"), "提示"); return; } //只有入库人员才允许撤销 入库作业 if ((activity == ACTIVITY_FIELD_VALUES.FIELD_ACTIVITY_TO_WAREHOUSE) && (operations + ",").IndexOf("入库,") == -1) { MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.WIP.LotUndoCtrl.Msg004}"), MESSAGEBOX_CAPTION);//只有入库人员才允许撤销入库作业 //MessageService.ShowMessage(string.Format("只有入库人员才允许撤销入库作业。"), "提示"); return; } DataTable dtList = this.gcUndo.DataSource as DataTable; if (dtList == null) { this.gcUndo.DataSource = dtReturn; } else { if (dtList.Rows.Count >= 100) { MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.WIP.LotUndoCtrl.Msg005}"), MESSAGEBOX_CAPTION);//一次撤销记录数不能超过100条 //MessageService.ShowMessage("一次撤销记录数不能超过100条。", "提示"); return; } //判断记录是否在列表中存在。 string transactionKey = Convert.ToString(drReturn[WIP_TRANSACTION_FIELDS.FIELD_TRANSACTION_KEY]); DataRow[] drs = dtList.Select(string.Format("{0}='{1}'", WIP_TRANSACTION_FIELDS.FIELD_TRANSACTION_KEY, transactionKey)); if (drs.Length > 0) { MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.WIP.LotUndoCtrl.Msg006}"), MESSAGEBOX_CAPTION);//记录已存在,请确认 //MessageService.ShowMessage("记录已存在,请确认。", "提示"); this.gvUndo.FocusedRowHandle = dtList.Rows.IndexOf(drs[0]); return; } dtList.Merge(dtReturn); } } finally { this.teLotNumber.Select(); this.teLotNumber.SelectAll(); } }
public override void DeleteMultipleItems() { bool hasChildren = false; List <ProjectFile> files = new List <ProjectFile> (); Set <SolutionEntityItem> projects = new Set <SolutionEntityItem> (); foreach (ITreeNavigator node in CurrentNodes) { ProjectFile pf = (ProjectFile)node.DataItem; projects.Add(pf.Project); if (pf.HasChildren) { hasChildren = true; } files.Add(pf); } AlertButton removeFromProject = new AlertButton(GettextCatalog.GetString("_Remove from Project"), Gtk.Stock.Remove); string question, secondaryText; secondaryText = GettextCatalog.GetString("The Delete option permanently removes the file from your hard disk. " + "Click Remove from Project if you only want to remove it from your current solution."); if (hasChildren) { if (files.Count == 1) { question = GettextCatalog.GetString("Are you sure you want to remove the file {0} and " + "its code-behind children from project {1}?", Path.GetFileName(files[0].Name), files[0].Project.Name); } else { question = GettextCatalog.GetString("Are you sure you want to remove the selected files and " + "their code-behind children from the project?"); } } else { if (files.Count == 1) { question = GettextCatalog.GetString("Are you sure you want to remove file {0} from project {1}?", Path.GetFileName(files[0].Name), files[0].Project.Name); } else { question = GettextCatalog.GetString("Are you sure you want to remove the selected files from the project?"); } } AlertButton result = MessageService.AskQuestion(question, secondaryText, AlertButton.Delete, AlertButton.Cancel, removeFromProject); if (result != removeFromProject && result != AlertButton.Delete) { return; } foreach (ProjectFile file in files) { Project project = file.Project; var inFolder = project.Files.GetFilesInVirtualPath(file.ProjectVirtualPath.ParentDirectory).ToList(); if (inFolder.Count == 1 && inFolder [0] == file) { // This is the last project file in the folder. Make sure we keep // a reference to the folder, so it is not deleted from the tree. ProjectFile folderFile = new ProjectFile(project.BaseDirectory.Combine(file.ProjectVirtualPath.ParentDirectory)); folderFile.Subtype = Subtype.Directory; project.Files.Add(folderFile); } if (file.HasChildren) { foreach (ProjectFile f in file.DependentChildren) { project.Files.Remove(f); if (result == AlertButton.Delete) { FileService.DeleteFile(f.Name); } } } project.Files.Remove(file); if (result == AlertButton.Delete && !file.IsLink) { FileService.DeleteFile(file.Name); } } IdeApp.ProjectOperations.Save(projects); }
private void btnSave_Click(object sender, EventArgs e) { var schema = _schema; //Remove elements that have been unchecked. foreach (TreeNode clsNode in treeSchema.Nodes) { string className = clsNode.Name; int index = schema.Classes.IndexOf(className); if (!clsNode.Checked) { if (index >= 0) { schema.Classes.RemoveAt(index); } } else { if (index >= 0) { ClassDefinition clsDef = schema.Classes[index]; foreach (TreeNode propNode in clsNode.Nodes) { if (!propNode.Checked) { string propName = propNode.Text; int pidx = clsDef.Properties.IndexOf(propName); if (pidx >= 0) { clsDef.Properties.RemoveAt(pidx); if (clsDef.IdentityProperties.Contains(propName)) { int idpdx = clsDef.IdentityProperties.IndexOf(propName); clsDef.IdentityProperties.RemoveAt(idpdx); } if (clsDef.ClassType == ClassType.ClassType_FeatureClass) { FeatureClass fc = (FeatureClass)clsDef; if (fc.GeometryProperty.Name == propName) { fc.GeometryProperty = null; } } } } } } } } if (rdXml.Checked) { using (var ios = new IoFileStream(txtXml.Text, "w")) { using (var writer = new XmlWriter(ios, false, XmlWriter.LineFormat.LineFormat_Indent)) { schema.WriteXml(writer); writer.Close(); } ios.Close(); } MessageService.ShowMessage("Schema saved to: " + txtXml.Text); this.DialogResult = DialogResult.OK; } else if (rdFile.Checked) { string fileName = txtFile.Text; if (ExpressUtility.CreateFlatFileDataSource(fileName)) { FdoConnection conn = ExpressUtility.CreateFlatFileConnection(fileName); bool disposeConn = true; using (FdoFeatureService svc = conn.CreateFeatureService()) { svc.ApplySchema(schema); if (MessageService.AskQuestion("Schema saved to: " + txtFile.Text + " connect to it?", "Saved")) { FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>(); string name = MessageService.ShowInputBox(ResourceService.GetString("TITLE_CONNECTION_NAME"), ResourceService.GetString("PROMPT_ENTER_CONNECTION"), ""); if (name == null) { return; } while (name == string.Empty || mgr.NameExists(name)) { MessageService.ShowError(ResourceService.GetString("ERR_CONNECTION_NAME_EMPTY_OR_EXISTS")); name = MessageService.ShowInputBox(ResourceService.GetString("TITLE_CONNECTION_NAME"), ResourceService.GetString("PROMPT_ENTER_CONNECTION"), name); if (name == null) { return; } } disposeConn = false; mgr.AddConnection(name, conn); } } if (disposeConn) { conn.Close(); conn.Dispose(); } this.DialogResult = DialogResult.OK; } } }
public static bool Publish(IWorkspaceObject entry, FilePath localPath, bool test) { if (test) { return(VersionControlService.CheckVersionControlInstalled() && VersionControlService.GetRepository(entry) == null); } List <FilePath> files = new List <FilePath> (); // Build the list of files to be checked in string moduleName = entry.Name; if (localPath == entry.BaseDirectory) { GetFiles(files, entry); } else if (entry is Project) { foreach (ProjectFile file in ((Project)entry).Files.GetFilesInPath(localPath)) { if (file.Subtype != Subtype.Directory) { files.Add(file.FilePath); } } } else { return(false); } if (files.Count == 0) { return(false); } SelectRepositoryDialog dlg = new SelectRepositoryDialog(SelectRepositoryMode.Publish); try { dlg.ModuleName = moduleName; dlg.Message = GettextCatalog.GetString("Initial check-in of module {0}", moduleName); do { if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok && dlg.Repository != null) { AlertButton publishButton = new AlertButton("_Publish"); if (MessageService.AskQuestion(GettextCatalog.GetString("Are you sure you want to publish the project?"), GettextCatalog.GetString("The project will be published to the repository '{0}', module '{1}'.", dlg.Repository.Name, dlg.ModuleName), AlertButton.Cancel, publishButton) == publishButton) { PublishWorker w = new PublishWorker(dlg.Repository, dlg.ModuleName, localPath, files.ToArray(), dlg.Message); w.Start(); break; } } else { break; } } while (true); } finally { dlg.Destroy(); } return(true); }
async Task <bool> CreateProject() { if (!projectConfiguration.IsValid()) { MessageService.ShowError(projectConfiguration.GetErrorMessage()); return(false); } if (ParentFolder != null && ParentFolder.ParentSolution.FindProjectByName(projectConfiguration.ProjectName) != null) { MessageService.ShowError(GettextCatalog.GetString("A Project with that name is already in your Project Space")); return(false); } if (ParentWorkspace != null && SolutionAlreadyExistsInParentWorkspace()) { MessageService.ShowError(GettextCatalog.GetString("A solution with that filename is already in your workspace")); return(false); } SolutionTemplate template = GetTemplateForProcessing(); if (ProjectNameIsLanguageKeyword(template.Language, projectConfiguration.ProjectName)) { MessageService.ShowError(GettextCatalog.GetString("Illegal project name.\nName cannot contain a language keyword.")); return(false); } ProcessedTemplateResult result = null; try { if (Directory.Exists(projectConfiguration.ProjectLocation)) { var question = GettextCatalog.GetString("Directory {0} already exists.\nDo you want to continue creating the project?", projectConfiguration.ProjectLocation); var btn = MessageService.AskQuestion(question, AlertButton.No, AlertButton.Yes); if (btn != AlertButton.Yes) { return(false); } } Directory.CreateDirectory(projectConfiguration.ProjectLocation); } catch (IOException) { MessageService.ShowError(GettextCatalog.GetString("Could not create directory {0}. File already exists.", projectConfiguration.ProjectLocation)); return(false); } catch (UnauthorizedAccessException) { MessageService.ShowError(GettextCatalog.GetString("You do not have permission to create to {0}", projectConfiguration.ProjectLocation)); return(false); } DisposeExistingNewItems(); try { result = await TemplatingService.ProcessTemplate(template, projectConfiguration, ParentFolder); SetFirstBuildProperty(result.WorkspaceItems); if (!result.WorkspaceItems.Any()) { return(false); } } catch (UserException ex) { MessageService.ShowError(ex.Message, ex.Details); return(false); } catch (Exception ex) { MessageService.ShowError(GettextCatalog.GetString("The project could not be created"), ex); return(false); } processedTemplate = result; return(true); }
//Show prompt, create files from template, create project, execute command, save project public IProject CreateProject(ProjectCreateInformation projectCreateInformation, string defaultLanguage) { // remember old outerProjectBasePath string outerProjectBasePath = projectCreateInformation.ProjectBasePath; string outerProjectName = projectCreateInformation.ProjectName; try { projectCreateInformation.ProjectBasePath = Path.Combine(projectCreateInformation.ProjectBasePath, this.relativePath); if (!Directory.Exists(projectCreateInformation.ProjectBasePath)) { Directory.CreateDirectory(projectCreateInformation.ProjectBasePath); } string language = string.IsNullOrEmpty(languageName) ? defaultLanguage : languageName; ProjectBindingDescriptor descriptor = ProjectBindingService.GetCodonPerLanguageName(language); IProjectBinding languageinfo = (descriptor != null) ? descriptor.Binding : null; if (languageinfo == null) { MessageService.ShowError( StringParser.Parse("${res:ICSharpCode.SharpDevelop.Internal.Templates.ProjectDescriptor.CantCreateProjectWithTypeError}", new StringTagPair("type", language))); return(null); } string newProjectName = StringParser.Parse(name, new StringTagPair("ProjectName", projectCreateInformation.ProjectName)); string projectLocation = Path.GetFullPath(Path.Combine(projectCreateInformation.ProjectBasePath, newProjectName + ProjectBindingService.GetProjectFileExtension(language))); StringBuilder standardNamespace = new StringBuilder(); // filter 'illegal' chars from standard namespace if (newProjectName != null && newProjectName.Length > 0) { char ch = '.'; for (int i = 0; i < newProjectName.Length; ++i) { if (ch == '.') { // at beginning or after '.', only a letter or '_' is allowed ch = newProjectName[i]; if (!Char.IsLetter(ch)) { standardNamespace.Append('_'); } else { standardNamespace.Append(ch); } } else { ch = newProjectName[i]; // can only contain letters, digits or '_' if (!Char.IsLetterOrDigit(ch) && ch != '.') { standardNamespace.Append('_'); } else { standardNamespace.Append(ch); } } } } projectCreateInformation.OutputProjectFileName = projectLocation; projectCreateInformation.RootNamespace = standardNamespace.ToString(); projectCreateInformation.ProjectName = newProjectName; StringParserPropertyContainer.FileCreation["StandardNamespace"] = projectCreateInformation.RootNamespace; if (File.Exists(projectLocation)) { if (!MessageService.AskQuestion( StringParser.Parse("${res:ICSharpCode.SharpDevelop.Internal.Templates.ProjectDescriptor.OverwriteProjectQuestion}", new StringTagPair("projectLocation", projectLocation)), "${res:ICSharpCode.SharpDevelop.Internal.Templates.ProjectDescriptor.OverwriteQuestion.InfoName}")) { return(null); //The user doesnt want to overwrite the project... } } //Show prompt if any of the files exist StringBuilder existingFileNames = new StringBuilder(); foreach (FileDescriptionTemplate file in files) { string fileName = Path.Combine(projectCreateInformation.ProjectBasePath, StringParser.Parse(file.Name, new string[, ] { { "ProjectName", projectCreateInformation.ProjectName } })); if (File.Exists(fileName)) { if (existingFileNames.Length > 0) { existingFileNames.Append(", "); } existingFileNames.Append(Path.GetFileName(fileName)); } } bool overwriteFiles = true; if (existingFileNames.Length > 0) { if (!MessageService.AskQuestion( StringParser.Parse("${res:ICSharpCode.SharpDevelop.Internal.Templates.ProjectDescriptor.OverwriteQuestion}", new StringTagPair("fileNames", existingFileNames.ToString())), "${res:ICSharpCode.SharpDevelop.Internal.Templates.ProjectDescriptor.OverwriteQuestion.InfoName}")) { overwriteFiles = false; } } #region Copy files to target directory foreach (FileDescriptionTemplate file in files) { string fileName = Path.Combine(projectCreateInformation.ProjectBasePath, StringParser.Parse(file.Name, new string[, ] { { "ProjectName", projectCreateInformation.ProjectName } })); if (File.Exists(fileName) && !overwriteFiles) { continue; } try { if (!Directory.Exists(Path.GetDirectoryName(fileName))) { Directory.CreateDirectory(Path.GetDirectoryName(fileName)); } if (!String.IsNullOrEmpty(file.BinaryFileName)) { // Binary content File.Copy(file.BinaryFileName, fileName); } else { // Textual content StreamWriter sr = new StreamWriter(File.Create(fileName), ParserService.DefaultFileEncoding); string fileContent = StringParser.Parse(file.Content, new string[, ] { { "ProjectName", projectCreateInformation.ProjectName }, { "FileName", fileName } }); fileContent = StringParser.Parse(fileContent); if (EditorControlService.GlobalOptions.IndentationString != "\t") { fileContent = fileContent.Replace("\t", EditorControlService.GlobalOptions.IndentationString); } sr.Write(fileContent); sr.Close(); } } catch (Exception ex) { MessageService.ShowException(ex, "Exception writing " + fileName); } } #endregion #region Create Project IProject project; try { project = languageinfo.CreateProject(projectCreateInformation); } catch (ProjectLoadException ex) { MessageService.ShowError(ex.Message); return(null); } #endregion #region Create Project Items, Imports and Files // Add Project items if (project is IProjectItemListProvider) { foreach (ProjectItem projectItem in projectItems) { ProjectItem newProjectItem = new UnknownProjectItem( project, StringParser.Parse(projectItem.ItemType.ItemName), StringParser.Parse(projectItem.Include) ); foreach (string metadataName in projectItem.MetadataNames) { string metadataValue = projectItem.GetMetadata(metadataName); // if the input contains any special MSBuild sequences, don't escape the value // we want to escape only when the special characters are introduced by the StringParser.Parse replacement if (metadataValue.Contains("$(") || metadataValue.Contains("%")) { newProjectItem.SetMetadata(StringParser.Parse(metadataName), StringParser.Parse(metadataValue)); } else { newProjectItem.SetEvaluatedMetadata(StringParser.Parse(metadataName), StringParser.Parse(metadataValue)); } } ((IProjectItemListProvider)project).AddProjectItem(newProjectItem); } } // Add Imports if (clearExistingImports || projectImports.Count > 0) { MSBuildBasedProject msbuildProject = project as MSBuildBasedProject; if (msbuildProject == null) { throw new Exception("<Imports> may be only used in project templates for MSBuildBasedProjects"); } try { msbuildProject.PerformUpdateOnProjectFile( delegate { var projectFile = msbuildProject.MSBuildProjectFile; if (clearExistingImports) { foreach (var import in projectFile.Imports.ToArray()) { projectFile.RemoveChild(import); } } foreach (Import projectImport in projectImports) { projectFile.AddImport(projectImport.Key).Condition = projectImport.Value; } }); } catch (InvalidProjectFileException ex) { if (string.IsNullOrEmpty(importsFailureMessage)) { MessageService.ShowError("Error creating project:\n" + ex.Message); } else { MessageService.ShowError(importsFailureMessage + "\n\n" + ex.Message); } return(null); } } if (projectProperties.Count > 0) { if (!(project is MSBuildBasedProject)) { throw new Exception("<PropertyGroup> may be only used in project templates for MSBuildBasedProjects"); } foreach (ProjectProperty p in projectProperties) { ((MSBuildBasedProject)project).SetProperty( StringParser.Parse(p.Configuration), StringParser.Parse(p.Platform), StringParser.Parse(p.Name), StringParser.Parse(p.Value), p.Location, p.ValueIsLiteral ); } } // Add Files if (project is IProjectItemListProvider) { foreach (FileDescriptionTemplate file in files) { string fileName = Path.Combine(projectCreateInformation.ProjectBasePath, StringParser.Parse(file.Name, new string[, ] { { "ProjectName", projectCreateInformation.ProjectName } })); FileProjectItem projectFile = new FileProjectItem(project, project.GetDefaultItemType(fileName)); projectFile.Include = FileUtility.GetRelativePath(project.Directory, fileName); file.SetProjectItemProperties(projectFile); ((IProjectItemListProvider)project).AddProjectItem(projectFile); } } #endregion RunCreateActions(project); project.ProjectCreationComplete(); // Save project project.Save(); projectCreateInformation.createdProjects.Add(project); ProjectService.OnProjectCreated(new ProjectEventArgs(project)); return(project); } finally { // set back outerProjectBasePath projectCreateInformation.ProjectBasePath = outerProjectBasePath; projectCreateInformation.ProjectName = outerProjectName; } }
public static void AddView(DotNetProject project, string path, string name) { var provider = project.LanguageBinding.GetCodeDomProvider(); if (provider == null) { throw new InvalidOperationException("Project language has null CodeDOM provider"); } string outputFile = null; MvcTextTemplateHost host = null; AddViewDialog dialog = null; try { dialog = new AddViewDialog(project); dialog.ViewName = name; bool fileGood = false; while (!fileGood) { var resp = (Gtk.ResponseType)MessageService.RunCustomDialog(dialog); dialog.Hide(); if (resp != Gtk.ResponseType.Ok || !dialog.IsValid()) { return; } string ext = ".cshtml"; if (dialog.ActiveViewEngine == "Aspx") { ext = dialog.IsPartialView ? ".ascx" : ".aspx"; } if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } outputFile = System.IO.Path.Combine(path, dialog.ViewName) + ext; if (System.IO.File.Exists(outputFile)) { fileGood = MessageService.AskQuestion(GettextCatalog.GetString("Overwrite file?"), GettextCatalog.GetString("The file '{0}' already exists.\n", dialog.ViewName) + GettextCatalog.GetString("Would you like to overwrite it?"), AlertButton.OverwriteFile, AlertButton.Cancel) != AlertButton.Cancel; } else { break; } } host = new MvcTextTemplateHost { LanguageExtension = provider.FileExtension, ItemName = dialog.ViewName, ViewDataTypeString = "" }; if (dialog.HasMaster) { host.IsViewContentPage = true; host.ContentPlaceholder = dialog.PrimaryPlaceHolder; host.MasterPage = dialog.MasterFile; host.ContentPlaceHolders = dialog.ContentPlaceHolders; } else if (dialog.IsPartialView) { host.IsViewUserControl = true; } else { host.IsViewPage = true; } if (dialog.IsStronglyTyped) { host.ViewDataTypeString = dialog.ViewDataTypeString; } host.ProcessTemplate(dialog.TemplateFile, outputFile); MonoDevelop.TextTemplating.TextTemplatingService.ShowTemplateHostErrors(host.Errors); } finally { if (host != null) { host.Dispose(); } if (dialog != null) { dialog.Destroy(); dialog.Dispose(); } } if (System.IO.File.Exists(outputFile)) { project.AddFile(outputFile); IdeApp.ProjectOperations.SaveAsync(project); } }
private void tsbSave_Click(object sender, EventArgs e) { //if (MessageService.AskQuestion("你确定要保存当前界面的数据吗?", "保存")) if (MessageService.AskQuestion(StringParser.Parse("${res:FanHai.Hemera.Addins.BomMaterialBandCtrl.msg.0002}"), StringParser.Parse("${res:Global.SystemInfo}"))) { bool IsTrue = false; MapControlsToBomMateil(); if (_bomMaterialBandEntity.Code == string.Empty) { //MessageService.ShowMessage("物料不为空", "保存"); //名称不能为空! MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.BomMaterialBandCtrl.msg.0003}"), StringParser.Parse("${res:Global.SystemInfo}")); return; } if (_bomMaterialBandEntity.Name == string.Empty) { //MessageService.ShowMessage("物料名称不为空", "保存"); //名称不能为空! MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.BomMaterialBandCtrl.msg.0004}"), StringParser.Parse("${res:Global.SystemInfo}")); return; } if (_bomMaterialBandEntity.BarCode == string.Empty) { //MessageService.ShowMessage("物料代码不能为空", "保存"); //名称不能为空! MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.BomMaterialBandCtrl.msg.0005}"), StringParser.Parse("${res:Global.SystemInfo}")); return; } if (_bomMaterialBandEntity.Desc == string.Empty) { //MessageService.ShowMessage("物料描述", "保存"); //名称不能为空! MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.BomMaterialBandCtrl.msg.0006}"), StringParser.Parse("${res:Global.SystemInfo}")); return; } if (CtrlState == ControlState.New && _bomMaterialBandEntity.GetMaterialDateByCodeAndBarcode(_bomMaterialBandEntity.Code, "").Tables[0].Rows.Count > 0) { //MessageService.ShowMessage("当前物料料号已经存在,请重新设置", "保存"); //当前名称已存在! MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.BomMaterialBandCtrl.msg.0007}"), StringParser.Parse("${res:Global.SystemInfo}")); return; } if (CtrlState == ControlState.New) { //状态为new if (_bomMaterialBandEntity.Insert()) { //新增成功 IsTrue = true; } } else { //状态不为new if (_bomMaterialBandEntity.Update()) { //修改成功 IsTrue = true; } else { //MessageService.ShowMessage("请选择要修改的信息", "保存"); //当前名称已存在! MessageService.ShowMessage(StringParser.Parse("${res:FanHai.Hemera.Addins.BomMaterialBandCtrl.msg.0008}"), StringParser.Parse("${res:Global.SystemInfo}")); } } if (IsTrue) { //值为true BandView(); CtrlState = ControlState.ReadOnly; //状态为readonly } } }
private void treeSchema_BeforeCheck(object sender, TreeViewCancelEventArgs e) { if (e.Node.Checked) { if (e.Node.Level == 0) //Class { //Check for associations string className = e.Node.Name; var affectedProperties = GetAffectedAssociationProperties(className); var affectedClasses = GetAffectedClasses(className); if (affectedProperties.Length > 0 || affectedClasses.Length > 0) { string msg = "You are un-checking a class that {0} association properties and {1} class definitions depend on. Un-checking this class will remove these association properties and make the affected class definition not derived from this class (re-checking will not restore these changes). Do you want to continue?"; if (!MessageService.AskQuestion(MSG_ORPHANED_ASSOCIATIONS)) { e.Cancel = true; return; } else { int removedProperties = 0; int alteredClasses = 0; if (affectedProperties.Length > 0) { removedProperties = PurgeAffectedAssocationProperties(affectedProperties); } if (affectedClasses.Length > 0) { alteredClasses = DetachAffectedClasses(affectedClasses); } MessageService.ShowMessage(removedProperties + " affected association properties removed and " + alteredClasses + " class definitions altered"); } } } else if (e.Node.Level == 1) //Property { string propName = e.Node.Name; string className = e.Node.Parent.Name; var affectedProperties = GetAffectedAssociationProperties(className); var affectedConstraints = GetAffectedConstraints(className, propName); if (affectedProperties.Length > 0 || affectedConstraints.Length > 0) { string msg = "You are un-checking a property that {0} association properties and {1} unique constraints depend on. By un-checking this property, these affected elements will be removed or modified (re-checking will not restore these changes. Do you want to continue?"; msg = string.Format(msg, affectedProperties.Length, affectedConstraints.Length); if (!MessageService.AskQuestion(msg)) { e.Cancel = true; return; } else { int removedProperties = 0; int removedConstraints = 0; if (affectedProperties.Length > 0) { removedProperties = PurgeAffectedAssocationProperties(affectedProperties); } if (affectedConstraints.Length > 0) { removedConstraints = PurgeAffectedConstraints(className, affectedConstraints); } MessageService.ShowMessage(removedProperties + " association properties and " + removedConstraints + " unique constraints removed"); } } } } }
bool CreateProject() { if (templateView.CurrentlySelected != null) { PropertyService.Set("Dialogs.NewProjectDialog.LastSelectedCategory", ((ProjectTemplate)templateView.CurrentlySelected).Category); recentIds.Remove(templateView.CurrentlySelected.Id); recentIds.Insert(0, templateView.CurrentlySelected.Id); if (recentIds.Count > 15) { recentIds.RemoveAt(recentIds.Count - 1); } string strRecent = string.Join(",", recentIds.ToArray()); PropertyService.Set("Dialogs.NewProjectDialog.RecentTemplates", strRecent); PropertyService.SaveProperties(); //PropertyService.Set("Dialogs.NewProjectDialog.LargeImages", ((RadioButton)ControlDictionary["largeIconsRadioButton"]).Checked); } string solution = txt_subdirectory.Text; string name = txt_name.Text; string location = ProjectLocation; if (solution.Equals("")) { solution = name; //This was empty when adding after first combine } if ( !FileService.IsValidPath(solution) || !FileService.IsValidFileName(name) || name.IndexOf(' ') >= 0 || !FileService.IsValidPath(location)) { MessageService.ShowError(GettextCatalog.GetString("Illegal project name.\nOnly use letters, digits, '.' or '_'.")); return(false); } if (parentFolder != null && parentFolder.ParentSolution.FindProjectByName(name) != null) { MessageService.ShowError(GettextCatalog.GetString("A Project with that name is already in your Project Space")); return(false); } PropertyService.Set( "MonoDevelop.Core.Gui.Dialogs.NewProjectDialog.AutoCreateProjectSubdir", CreateSolutionDirectory); if (templateView.CurrentlySelected == null || name.Length == 0) { return(false); } ProjectTemplate item = (ProjectTemplate)templateView.CurrentlySelected; try { if (Directory.Exists(ProjectLocation)) { var btn = MessageService.AskQuestion(GettextCatalog.GetString("Directory {0} already exists.\nDo you want to coninue the Project creation?", ProjectLocation), AlertButton.No, AlertButton.Yes); if (btn != AlertButton.Yes) { return(false); } } System.IO.Directory.CreateDirectory(location); } catch (IOException) { MessageService.ShowError(GettextCatalog.GetString("Could not create directory {0}. File already exists.", location)); return(false); } catch (UnauthorizedAccessException) { MessageService.ShowError(GettextCatalog.GetString("You do not have permission to create to {0}", location)); return(false); } try { ProjectCreateInformation cinfo = CreateProjectCreateInformation(); if (newSolution) { newItem = item.CreateWorkspaceItem(cinfo); } else { newItem = item.CreateProject(parentFolder, cinfo); } } catch (UserException ex) { MessageService.ShowError(ex.Message, ex.Details); return(false); } catch (Exception ex) { MessageService.ShowException(ex, GettextCatalog.GetString("The project could not be created")); return(false); } selectedItem = item; return(true); }