Exemple #1
0
        public bool Copy(bool run = true)
        {
            if (_selectedShapes.Count == 0)
            {
                return(false);
            }
            if (run)
            {
                var buf  = SerializeSelected();
                var data = new DataObject();

                data.SetData("DiagramDocument", buf.ToArray());

                var sortedShapes = _selectedShapes.OrderBy(s =>
                {
                    var c = s.BBox.Center();
                    return(c.Y + c.X / 10);
                });
                var text = StringExt.Join("\n\n", sortedShapes
                                          .Select(s => s.PlainText()).Where(t => !string.IsNullOrEmpty(t)));
                if (!string.IsNullOrEmpty(text))
                {
                    data.SetText(text);
                }

                // Crazy Clipboard deletes data by default on app exit!
                // need 'true' parameter to prevent loss of data on exit
                Clipboard.SetDataObject(data, true);
            }
            return(true);
        }
Exemple #2
0
            public Pred PrevPosition;             // null if there were multiple starting positions

            public override string ToString()     // for debugging
            {
                if (AndPreds.Count > 0)
                {
                    return(string.Format("{2} {0} => {1}", Set, Position, StringExt.Join("", AndPreds)));
                }
                else
                {
                    return(string.Format("{0} => {1}", Set, Position));
                }
            }
Exemple #3
0
		protected virtual string ToString(bool inverted, IEnumerable<Int32> expected)
		{
			int plural = expected.Take(2).Count();
			if (plural == 0)
				return Localize.From(inverted ? "anything" : "nothing");
			else if (inverted)
				return Localize.From("anything except {0}", ToString(false, expected));
			else if (plural == 1)
				return ToString(expected.First());
			else
				return StringExt.Join("|", expected.Select(e => ToString(e)));
		}
Exemple #4
0
            public override string ToString()             // for debugging
            {
                string andPreds = "";

                if (AndPreds != null)
                {
                    andPreds = StringExt.Join(" || ", AndPreds.Select(set_ => StringExt.Join("", set_)));
                }
                string set = Set == null ? "" : Set.ToString();

                if (andPreds == "" && (set == "" || set == "[^]"))
                {
                    return(string.Format("otherwise, {0}", Sub.ToString()));
                }
                else
                {
                    return(string.Format("when {0} {1}, {2}", andPreds, set, Sub.ToString()));
                }
            }
Exemple #5
0
        protected virtual string ToString(bool inverted, IEnumerable <MatchType> expected)
        {
            int plural = expected.Take(2).Count();

            if (plural == 0)
            {
                return(Localize.Localized(inverted ? "anything" : "nothing"));
            }
            else if (inverted)
            {
                return(Localize.Localized("anything except {0}", ToString(false, expected)));
            }
            else if (plural == 1)
            {
                return(ToString(expected.First()));
            }
            else
            {
                return(StringExt.Join("|", expected.Select(e => ToString(e))));
            }
        }
Exemple #6
0
 public override string ToString()
 {
     return(StringExt.Join(" ", List.Where(child => !(child is ActionPred))));
 }
Exemple #7
0
 public override string ToString()
 {
     return(StringExt.Join(" ", List));
 }
Exemple #8
0
 public static string Join(this System.Collections.IEnumerable list, string separator)
 {
     return(StringExt.Join(separator, list.GetEnumerator()));
 }