Repository navigation
Expand file tree
/
Copy pathGraphicsPathExtensions.cs
More file actions
98 lines (83 loc) · 3.23 KB
/
Copy pathGraphicsPathExtensions.cs
File metadata and controls
98 lines (83 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BASeTris
{
public static class GraphicsPathExtensions
{
public static void AddString(this GraphicsPath gp, String addme, Font usefont, PointF origin, StringFormat sformat)
{
gp.AddString(addme, usefont.FontFamily, (int) usefont.Style, usefont.Size, origin, sformat);
}
public static void AddString(this GraphicsPath gp, String addme, Font usefont, Point origin, StringFormat sformat)
{
gp.AddString(addme, usefont.FontFamily, (int) usefont.Style, usefont.Size, origin, sformat);
}
}
public static class RandomExtensions
{
public static double NextDouble(this Random r, double Minimum, double Maximum)
{
return (r.NextDouble() * (Maximum - Minimum)) + Minimum;
}
}
public static class ListExtensions
{
public static Queue<T> Clone<T>(this Queue<T> QueueToClone) where T : ICloneable
{
return new Queue<T>(QueueToClone.Select(item => (T) item.Clone()));
}
public static List<T> Clone<T>(this IEnumerable<T> listToClone) where T : ICloneable
{
return listToClone.Select(item => (T) item.Clone()).ToList();
}
public static List<T> ShallowClone<T>(this IEnumerable<T> listtoclone)
{
lock (listtoclone)
{
return new List<T>(listtoclone);
}
}
public static LinkedList<T> Clone<T>(this LinkedList<T> listtoClone) where T : ICloneable
{
return new LinkedList<T>(listtoClone.Select(item => (T) item.Clone()));
}
public static LinkedList<T> ShallowClone<T>(this LinkedList<T> listtoClone)
{
return new LinkedList<T>(listtoClone);
}
}
public static class ImageExtensions
{
public static Image ClipImage(this Image ourimage, Point TopLeft, Size ClipSize)
{
Bitmap newimage = new Bitmap(ClipSize.Width, ClipSize.Height);
using (Graphics drawcanvas = Graphics.FromImage(newimage))
{
drawcanvas.DrawImage(ourimage, 0, 0, new Rectangle(TopLeft, ClipSize), GraphicsUnit.Pixel);
}
return newimage;
}
}
public static class EnumExtensions
{
public static T Successor<T>(this T value) where T : struct, IConvertible
{
if (!typeof(T).IsEnum) throw new ArgumentException("T must be an Enum");
T[] ValueArray = (T[])Enum.GetValues(typeof(T));
if ((value.Equals(ValueArray[ValueArray.Length - 1]))) return ValueArray[0];
return ValueArray[Convert.ToInt32(value) + 1];
}
public static T Predecessor<T>(this T value) where T : struct, IConvertible
{
if (!typeof(T).IsEnum) throw new ArgumentException("T must be an Enum");
T[] ValueArray = (T[])Enum.GetValues(typeof(T));
if ((value.Equals(ValueArray[0]))) return ValueArray[ValueArray.Length - 1];
return ValueArray[Convert.ToInt32(value) - 1];
}
}
}