Esempio n. 1
0
		string SetWidth(string str, WidthDialog.Result result, int value)
		{
			if (str.Length == value)
				return str;

			if (str.Length > value)
			{
				switch (result.Location)
				{
					case WidthDialog.TextLocation.Start: return str.Substring(0, value);
					case WidthDialog.TextLocation.Middle: return str.Substring((str.Length - value + 1) / 2, value);
					case WidthDialog.TextLocation.End: return str.Substring(str.Length - value);
					default: throw new ArgumentException("Invalid");
				}
			}
			else
			{
				var len = value - str.Length;
				switch (result.Location)
				{
					case WidthDialog.TextLocation.Start: return str + new string(result.PadChar, len);
					case WidthDialog.TextLocation.Middle: return new string(result.PadChar, (len + 1) / 2) + str + new string(result.PadChar, len / 2);
					case WidthDialog.TextLocation.End: return new string(result.PadChar, len) + str;
					default: throw new ArgumentException("Invalid");
				}
			}
		}
Esempio n. 2
0
		public static Result Run(Window parent, bool numeric, bool isSelect, NEVariables variables)
		{
			var dialog = new WidthDialog(numeric, isSelect, variables) { Owner = parent };
			return dialog.ShowDialog() ? dialog.result : null;
		}
Esempio n. 3
0
		void Command_Text_Width(WidthDialog.Result result)
		{
			var results = GetFixedExpressionResults<int>(result.Expression);
			ReplaceSelections(Selections.AsParallel().AsOrdered().Select((range, index) => SetWidth(GetString(range), result, results[index])).ToList());
		}
Esempio n. 4
0
		void Command_Text_Select_ByWidth(WidthDialog.Result result)
		{
			var results = GetFixedExpressionResults<int>(result.Expression);
			Selections.Replace(Selections.AsParallel().AsOrdered().Where((range, index) => range.Length == results[index]).ToList());
		}