private bool ResolveEnvVars(string inputText, ref string outputText, ref string errorsStr) { outputText = ""; List <string> errors = VsUtility.ResolveEnvironmentVariables(inputText, ref outputText); if (errors.Count > 0) { foreach (string error in errors) { VsUtility.AddNewLineIfNeeded(ref errorsStr); errorsStr += error; } return(false); } return(true); }
private void UpdatePathTextBoxState(TextBox tb, Image errImg, bool allowUserVars, bool isDir, bool isMultiGame, bool hasConfig) { string strToolTip = ""; bool hasErrors = false; string errorsStr = ""; List <KeyValuePair <string, string> > toolTips = new List <KeyValuePair <string, string> > { }; string inputText = tb.Text; if (String.IsNullOrEmpty(tb.Text)) { inputText = tb.Tag.ToString(); } if (!String.IsNullOrEmpty(inputText)) { if (String.IsNullOrEmpty(tb.Text)) { strToolTip = String.Format(Properties.Resources.strEmptyPathNote, tb.Tag.ToString()); } if (allowUserVars && isMultiGame) { if (IsSaSelected()) { string text = VsUtility.FormatName(inputText, "", safeProjectName, isDir ? "$(ProjectDir)" : "", isDir ? "$(SolutionDir)" : "", "SA", isDir ? VsUtility.GetName(tbSaDir.Text, tbSaDir.Tag.ToString()) : "", isDir ? GetOutputDirName() : "", hasConfig ? "Release" : ""); if (!ResolveEnvVars(text, ref text, ref errorsStr)) { hasErrors = true; } toolTips.Add(new KeyValuePair <string, string>("GTA SA", text)); } if (IsVcSelected()) { string text = VsUtility.FormatName(inputText, "", safeProjectName, isDir ? "$(ProjectDir)" : "", isDir ? "$(SolutionDir)" : "", "VC", isDir ? VsUtility.GetName(tbVcDir.Text, tbVcDir.Tag.ToString()) : "", isDir ? GetOutputDirName() : "", hasConfig ? "Release" : ""); if (!ResolveEnvVars(text, ref text, ref errorsStr)) { hasErrors = true; } toolTips.Add(new KeyValuePair <string, string>("GTA VC", text)); } if (IsIIISelected()) { string text = VsUtility.FormatName(inputText, "", safeProjectName, isDir ? "$(ProjectDir)" : "", isDir ? "$(SolutionDir)" : "", "III", isDir ? VsUtility.GetName(tbIIIDir.Text, tbIIIDir.Tag.ToString()) : "", isDir ? GetOutputDirName() : "", hasConfig ? "Release" : ""); if (!ResolveEnvVars(text, ref text, ref errorsStr)) { hasErrors = true; } toolTips.Add(new KeyValuePair <string, string>("GTA 3", text)); } } else { string text = inputText; if (allowUserVars) { text = VsUtility.FormatName(inputText, "", safeProjectName, isDir ? "$(ProjectDir)" : "", isDir ? "$(SolutionDir)" : "", "", "", "", hasConfig ? "Release" : ""); } if (!ResolveEnvVars(text, ref text, ref errorsStr)) { hasErrors = true; } toolTips.Add(new KeyValuePair <string, string>("", text)); } foreach (var item in toolTips) { if (!String.IsNullOrEmpty(item.Key) && GetNumGamesSelected() > 1) { VsUtility.AddNewLineIfNeeded(ref strToolTip); strToolTip += item.Key; } VsUtility.AddNewLineIfNeeded(ref strToolTip); strToolTip += item.Value; } } tb.ToolTip = strToolTip; errImg.IsEnabled = hasErrors; if (hasErrors) { errImg.ToolTip = errorsStr; } }