private static CGX_Mask GetOrCreateMask(string sLayerName) { CGX_Mask newMask = null; try { if (Masks != null) { newMask = Masks.FindLast( delegate(CGX_Mask bk) { return(bk.LayerName == sLayerName); }); } // Create a new Mask if not found if (newMask == null) { newMask = new CGX_Mask(); newMask.LayerName = sLayerName; Masks.Add(newMask); } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(newMask); }
public static void AddMask(string[] layersName, Tuple <string, string> parentName, Coordinate center, double dWidth, double dHeight, double angle, Tuple <double, double, double, double> margins) { try { if (Masks == null) { Masks = new List <CGX_Mask>(); } foreach (string slayer in layersName) { CGX_Mask mask = GetOrCreateMask(slayer); mask.OffsetTop = margins.Item1; mask.OffsetRight = margins.Item2; mask.OffsetLeft = margins.Item3; mask.OffsetBottom = margins.Item4; Tuple <string, string> sGet = mask.Parents.FindLast( delegate(Tuple <string, string> maskParent) { return((maskParent.Item1 == parentName.Item1) && (maskParent.Item2 == parentName.Item2)); }); if (sGet == null) { mask.Parents.Add(parentName); } mask.Masks.Add(new CGX_MaskBounds(center, angle, dWidth, dHeight)); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void ResetMask(string sLayerName, Tuple <string, string> sParent) { try { if (Masks != null) { CGX_Mask foundMask = Masks.FindLast( delegate(CGX_Mask bk) { return(bk.LayerName == sLayerName); }); if (foundMask != null) { Tuple <string, string> sGet = foundMask.Parents.FindLast( delegate(Tuple <string, string> maskParent) { return((maskParent.Item1 == sParent.Item1) && (maskParent.Item2 == sParent.Item2)); }); if (sGet != null) { foundMask.Masks.Clear(); } } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
//======================================================== #region Constructor /// <summary> /// /// </summary> /// <param name="newMask"></param> public static void AddMask(CGX_Mask newMask) { try { if (Masks == null) { Masks = new List <CGX_Mask>(); } Masks.Add(newMask); } catch (Exception ex) { Console.WriteLine(ex.Message); } }