public void OnUpdate(CommandUpdateEventArgs e) { if (EnumTools.GetSingle(e.Selection.GetSelection <ISvnLogItem>()) == null) { e.Enabled = false; } }
public override void OnUpdate(CommandUpdateEventArgs e) { ISvnRepositoryItem reposItem = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>()); if (reposItem != null) { if (reposItem.Origin != null && reposItem.NodeKind != SharpSvn.SvnNodeKind.Directory && reposItem.Revision.RevisionType == SharpSvn.SvnRevisionType.Number) { if (e.Command == AnkhCommand.RepositoryCompareWithWc) { if (!(reposItem.Origin.Target is SvnPathTarget)) { e.Enabled = false; return; } } return; } else if (e.Command == AnkhCommand.RepositoryCompareWithWc && reposItem.Revision == SvnRevision.Working) { return; } } e.Enabled = false; }
public override void OnExecute(CommandEventArgs e) { using (ExportDialog dlg = new ExportDialog(e.Context)) { dlg.OriginPath = EnumTools.GetSingle(e.Selection.GetSelectedSvnItems(false)).FullPath; if (dlg.ShowDialog(e.Context) != DialogResult.OK) { return; } SvnDepth depth = dlg.NonRecursive ? SvnDepth.Empty : SvnDepth.Infinity; e.GetService <IProgressRunner>().RunModal(CommandStrings.Exporting, delegate(object sender, ProgressWorkerArgs wa) { SvnExportArgs args = new SvnExportArgs(); args.Depth = depth; args.Revision = dlg.Revision; args.Overwrite = true; wa.Client.Export(dlg.ExportSource, dlg.LocalPath, args); }); } }
private static Keys MapModifier(ModifierKey modifier) { var result = Keys.None; foreach (var flag in EnumTools.GetFlags(modifier)) { switch (flag) { case ModifierKey.None: continue; case ModifierKey.Shift: result |= Keys.Shift; break; case ModifierKey.Control: case ModifierKey.Primary: result |= Keys.Control; break; case ModifierKey.Alt: result |= Keys.Alt; break; case ModifierKey.Super: result |= Keys.LWin; break; default: throw new NotSupportedException($"Unsupported modifier key: \"{flag}\""); } } return(result); }
public static NSEventModifierFlags GetModifier(ModifierKey key) { NSEventModifierFlags result = NSEventModifierFlags.None; foreach (var flag in EnumTools.GetFlags(key)) { switch (flag) { case ModifierKey.None: continue; case ModifierKey.Shift: result |= NSEventModifierFlags.Shift; break; case ModifierKey.Control: result |= NSEventModifierFlags.Control; break; case ModifierKey.Alt: result |= NSEventModifierFlags.Option; break; case ModifierKey.Super: case ModifierKey.Primary: result |= NSEventModifierFlags.Command; break; default: throw new NotSupportedException($"Unsupported modifier key: \"{flag}\""); } } return(result); }
void ExecuteDiff(CommandEventArgs e, ICollection <SvnOrigin> targets, SvnRevisionRange range) { if (targets.Count != 1) { return; } SvnTarget diffTarget = EnumTools.GetSingle(targets).Target; IAnkhDiffHandler diff = e.GetService <IAnkhDiffHandler>(); AnkhDiffArgs da = new AnkhDiffArgs(); string[] files = diff.GetTempFiles(diffTarget, range.StartRevision, range.EndRevision, true); if (files == null) { return; } da.BaseFile = files[0]; da.MineFile = files[1]; da.BaseTitle = diff.GetTitle(diffTarget, range.StartRevision); da.MineTitle = diff.GetTitle(diffTarget, range.EndRevision); da.ReadOnly = true; diff.RunDiff(da); }
bool UpdateForChangedFiles(CommandUpdateEventArgs e) { ISvnLogChangedPathItem change = EnumTools.GetSingle(e.Selection.GetSelection <ISvnLogChangedPathItem>()); if (change == null) { return(false); } // Skip all the files we cannot diff switch (change.Action) { case SvnChangeAction.Add: if (change.CopyFromRevision >= 0) { break; // We can retrieve this file using CopyFromPath } e.Enabled = false; break; case SvnChangeAction.Delete: e.Enabled = false; break; } if (change.NodeKind == SvnNodeKind.Directory) { e.Enabled = false; } return(true); }
public override void OnUpdate(CommandUpdateEventArgs e) { if (null == EnumTools.GetFirst(e.Selection.GetSelectedFiles(true))) { e.Enabled = false; } }
static void Main(string[] args) { //TestLogger(); var numbers = Enumerable.Range(1, 100).Select(m => m.ToString()); Devmasters.Batch.ThreadManager.DoActionForAll <string>(numbers, n => { Console.WriteLine(n); System.Threading.Thread.Sleep(1000); return(new Devmasters.Batch.ActionOutputData()); }, true, 10); //TestCache_multithread(); return; return; TestAutoUpdatableCacheMem(); return; TestAutoUpdatableCacheFile(); return; var grps = EnumTools.Groups(typeof(Tester)); var grpsLiche = EnumTools.InGroup(typeof(Tester), "liche"); var grpsLiche2 = EnumTools.InGroup <Tester>("liche"); var grpsLiche2x = EnumTools.InGroup <Tester>("xliche"); }
public void OnUpdate(CommandUpdateEventArgs e) { if (EnumTools.IsEmpty(e.Selection.GetSelection <ISvnLogItem>())) { e.Enabled = false; } }
public static void StartBuildBundle() { LogTools.Info("---------------------------------start-------------------------------------"); LogTools.Info("设置打包平台"); //设置打包平台 if (ProjectConfig.Instance.m_AssetBundleBuildTarget != EnumTools.GetException <BuildTarget>()) { buildTarget = ProjectConfig.Instance.m_AssetBundleBuildTarget; } LogTools.Info("清理资源:"); AssetsSetting.ClearResourcesDir(); //清空Resources目录 LogTools.Info("拷贝并导入资源"); srcPath = AssetsSetting.ImportAsset(srcPath); //将srcPath上的文件复制到Resources目录下,并且导入资源 LogTools.Info("设置资源"); AssetsSetting.ImporterSet(configJson, srcPath); //对资源进行各种参数修改和设置再次导入 LogTools.Info("清空AssetBundlesName"); ClearAssetBundlesName(); //清空AssetBundlesName LogTools.Info("设置AssetBundlesName"); PerpareToBuild(srcPath); //设置打包资源的assetBundleName LogTools.Info("开始打包"); StartToBuild(); //开始打包 LogTools.Info("导出资源"); string assetBundlePath = GlobalConstants.TempPath + "/" + FileTools.GetFileName(srcPath).ToLower() + ".ab"; AssetsSetting.MoveOutAsset(assetBundlePath, outPath); //将打包好的文件移动到输出目录 LogTools.Info("清空资源文件"); AssetsSetting.ClearResourcesDir(); //清空Resources目录 LogTools.Info("结束"); LogTools.Info("---------------------------------end-------------------------------------"); }
public void EnumToolsParse() { Assert.AreEqual(Robot.One, EnumTools.Parse <Robot>("1")); Assert.AreEqual(Robot.One, EnumTools.Parse <Robot>("One")); Assert.AreEqual(Robot.One, EnumTools.Parse <Robot>(Robot.One)); Assert.AreEqual(Robot.One, EnumTools.Parse <Robot>(1)); Assert.AreEqual(null, EnumTools.Parse <Robot>(4)); }
public ActionResult DictionaryEdit(long id) { EditDictionary editDictionary = new EditDictionary(); editDictionary.BaseDictionary = BaseService.GetDictionaryById(id); editDictionary.ValueTypes = EnumTools.GetEnumDescriptions <ValueTypeEnum>(); return(View(editDictionary)); }
/// <summary> /// Shows the log viewer and sets the revision cell value to the selected revision /// </summary> /// <param name="row"></param> private void SelectRevision(DataGridViewRow row) { IAnkhServiceProvider context = Context; if (context != null) { string selectedUriString = row.Cells[0].Value as string; Uri selectedUri; if (!string.IsNullOrEmpty(selectedUriString) && Uri.TryCreate(selectedUriString, UriKind.Absolute, out selectedUri) ) { Uri repoRoot = string.Equals(_lastUsedUriString, selectedUriString) ? _lastRepositoryRoot : null; if (repoRoot == null) { if (context.GetService <IProgressRunner>().RunModal( PropertyEditStrings.RetrievingRepositoryRoot, delegate(object sender, ProgressWorkerArgs a) { repoRoot = a.Client.GetRepositoryRoot(selectedUri); }).Succeeded) { //cache the last used repo uri string and the fetched repository root uri _lastRepositoryRoot = repoRoot; _lastUsedUriString = selectedUriString; } } if (repoRoot != null) { try { // set the current revision value as the initial selection string rev = row.Cells[2].Value as string; SvnRevision rr = string.IsNullOrEmpty(rev) ? SvnRevision.None : long.Parse(rev); SvnUriTarget svnTarget = new SvnUriTarget(selectedUri, rr); Ankh.Scc.SvnOrigin origin = new Ankh.Scc.SvnOrigin(svnTarget, repoRoot); using (Ankh.UI.SvnLog.LogViewerDialog dlg = new Ankh.UI.SvnLog.LogViewerDialog(origin)) { if (dlg.ShowDialog(Context) == DialogResult.OK) { Ankh.Scc.ISvnLogItem li = EnumTools.GetSingle(dlg.SelectedItems); rev = li == null ? null : li.Revision.ToString(); //set the revision cell value to the selection revision row.Cells[2].Value = rev ?? string.Empty; } } } catch { // clear cache in case of error _lastUsedUriString = null; _lastRepositoryRoot = null; } } } } }
public override void OnUpdate(CommandUpdateEventArgs e) { SvnItem i = EnumTools.GetSingle(e.Selection.GetSelectedSvnItems(false)); if (i == null || !i.IsVersioned) { e.Enabled = false; } }
void OnUpdateOpen(object sender, CommandUpdateEventArgs e) { SvnItem item = EnumTools.GetSingle(e.Selection.GetSelectedSvnItems(false)); if (item == null) { e.Enabled = false; } }
public override void OnExecute(CommandEventArgs e) { IAnkhDiffHandler diff = e.GetService <IAnkhDiffHandler>(); ISvnRepositoryItem reposItem = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>()); if (reposItem == null) { return; } SvnRevision from; SvnRevision to; if (reposItem.Revision == SvnRevision.Working) { from = SvnRevision.Base; to = SvnRevision.Working; } else if (e.Command == AnkhCommand.RepositoryCompareWithWc) { from = reposItem.Revision; to = SvnRevision.Working; } else { from = reposItem.Revision.Revision - 1; to = reposItem.Revision; } AnkhDiffArgs da = new AnkhDiffArgs(); if (to == SvnRevision.Working) { da.BaseFile = diff.GetTempFile(reposItem.Origin.Target, from, true); if (da.BaseFile == null) { return; // User canceled } da.MineFile = ((SvnPathTarget)reposItem.Origin.Target).FullPath; } else { string[] files = diff.GetTempFiles(reposItem.Origin.Target, from, to, true); if (files == null) { return; // User canceled } da.BaseFile = files[0]; da.MineFile = files[1]; System.IO.File.SetAttributes(da.MineFile, System.IO.FileAttributes.ReadOnly | System.IO.FileAttributes.Normal); } da.BaseTitle = diff.GetTitle(reposItem.Origin.Target, from); da.MineTitle = diff.GetTitle(reposItem.Origin.Target, to); diff.RunDiff(da); }
private void OnUpdateOpenFolder(object sender, CommandUpdateEventArgs e) { SvnItem one = EnumTools.GetSingle(e.Selection.GetSelectedSvnItems(false)); if (one == null || !one.Exists) { e.Enabled = false; } }
void OnUpdateOpen(object sender, CommandUpdateEventArgs e) { RepositoryExplorerItem item = EnumTools.GetSingle(e.Selection.GetSelection <RepositoryExplorerItem>()); if (item == null || item.Uri == null) { e.Enabled = false; } }
public override void OnUpdate(CommandUpdateEventArgs e) { ISvnRepositoryItem single = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>()); if (single == null || single.NodeKind == SvnNodeKind.File || single.Origin == null) { e.Enabled = false; } }
public void OnUpdate(CommandUpdateEventArgs e) { ISvnLogItem item = EnumTools.GetSingle(e.Selection.GetSelection <ISvnLogItem>()); if (item == null || EnumTools.IsEmpty(item.Issues)) { e.Enabled = false; } }
public override void OnUpdate(CommandUpdateEventArgs e) { if (!e.State.SolutionExists || e.State.SolutionBuilding || e.State.Debugging || e.State.SolutionOpening) { e.Enabled = false; return; } e.Enabled = !EnumTools.IsEmpty(GetChanges(e)); }
public void GetActiveValuesTests() { var value = FlagsEnum.P1 | FlagsEnum.P2; var subject = EnumTools.GetActiveValues(value); Assert.Contains(FlagsEnum.P1, subject); Assert.Contains(FlagsEnum.P2, subject); Assert.DoesNotContain(FlagsEnum.P3, subject); Assert.DoesNotContain(FlagsEnum.P4, subject); }
public override void OnUpdate(CommandUpdateEventArgs e) { if (!e.State.SolutionExists || e.State.SolutionBuilding || e.State.Debugging || e.State.SolutionOpening) { e.Enabled = false; return; } switch (e.Command) { case AnkhCommand.SolutionSwitchDialog: IAnkhSolutionSettings solutionSettings = e.GetService <IAnkhSolutionSettings>(); SvnItem solutionItem = solutionSettings.ProjectRootSvnItem; if (solutionItem == null || !solutionItem.IsVersioned || solutionItem.IsNewAddition) { e.Enabled = false; return; } break; case AnkhCommand.SwitchProject: SccProject oneProject = EnumTools.GetSingle(e.Selection.GetSelectedProjects(false)); if (oneProject == null) { e.Enabled = false; return; } IProjectFileMapper pfm = e.GetService <IProjectFileMapper>(); ISccProjectInfo pi = pfm.GetProjectInfo(oneProject); if (pi == null || pi.ProjectDirectory == null) { e.Enabled = false; return; } SvnItem projectItem = e.GetService <ISvnStatusCache>()[pi.ProjectDirectory]; if (projectItem == null || !projectItem.IsVersioned || projectItem.IsNewAddition) { e.Enabled = false; } break; case AnkhCommand.SwitchItem: SvnItem oneItem = EnumTools.GetSingle(e.Selection.GetSelectedSvnItems(false)); if (oneItem == null || !oneItem.IsVersioned || oneItem.IsNewAddition) { e.Enabled = false; } break; } }
public override void OnUpdate(CommandUpdateEventArgs e) { ISvnRepositoryItem item = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>()); if (item != null && item.Origin != null && !item.Origin.IsRepositoryRoot) { return; } e.Enabled = false; }
public static EnumerationMember[] GetEnumerationMembers(Type enumType) { Array enumValues = Enum.GetValues(enumType); return((from object enumValue in enumValues select new EnumerationMember { Value = enumValue, Description = EnumTools.GetEnumDescription(enumValue, enumType) }).ToArray()); }
void OnOpen(object sender, CommandEventArgs e) { RepositoryExplorerItem item = EnumTools.GetSingle(e.Selection.GetSelection <RepositoryExplorerItem>()); if (item.Entry == null || item.Entry.NodeKind == SvnNodeKind.Directory || item.Origin == null) { treeView.BrowseTo(item.Uri); return; } AutoOpenCommand(e, item.Origin); }
/// <summary> /// Gives the specified upgrades to a FirstPersonMover /// </summary> /// <param name="Target"></param> /// <param name="Upgrades"></param> /// <param name="Levels"></param> public static void Give(FirstPersonMover Target, Dictionary <UpgradeType, int> upgrades) { List <UpgradeType> upgradeTypes = EnumTools.GetValues <UpgradeType>(); for (int i = 0; i < upgradeTypes.Count; i++) { if (upgrades.TryGetValue(upgradeTypes[i], out int level)) { Give(Target, GetUpgradeDescriptionFromTypeAndLevel(upgradeTypes[i], level)); } } }
/// <summary> /// Verifies if the log message is valid for the current policy /// </summary> /// <param name="state">The state.</param> /// <returns></returns> private bool PreCommit_VerifyLogMessage(PendingCommitState state) { if (state.LogMessage == null) { return(true); // Skip checks } // And after checking whether the message is valid: Normalize the message the way the CLI would // * No whitespace at the end of lines // * Always a newline at the end StringBuilder sb = new StringBuilder(); foreach (string line in state.LogMessage.Replace("\r", "").Split('\n')) { sb.AppendLine(line.TrimEnd()); } string msg = sb.ToString(); // no need to check for issue id if issue tracker integration already did it. if (CommitSettings.WarnIfNoIssue && !state.SkipIssueVerify) { bool haveIssue = false; // Use the project commit settings class to add an issue number (if available) if (CommitSettings.ShowIssueBox && !string.IsNullOrEmpty(state.IssueText)) { haveIssue = true; } IEnumerable <TextMarker> markers; if (!haveIssue && !string.IsNullOrEmpty(state.LogMessage) && IssueService.TryGetIssues(state.LogMessage, out markers) && !EnumTools.IsEmpty(markers)) { haveIssue = true; } if (!haveIssue && state.MessageBox.Show(PccStrings.NoIssueNumber, "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return(false); } } msg = CommitSettings.BuildLogMessage(msg, state.IssueText); // And make sure the log message ends with a single newline state.LogMessage = msg.TrimEnd() + Environment.NewLine; return(true); // Logmessage always ok for now }
public override void OnUpdate(CommandUpdateEventArgs e) { ISvnRepositoryItem item = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>()); if (item == null || item.Origin == null || item.Origin.Target.Revision != SvnRevision.Head || item.NodeKind == SvnNodeKind.File) { e.Enabled = false; } }