Exemple #1
0
 public EscapeData(EscapeType EscapeType, string MetaData)
 {
     if (EscapeType == EscapeType.NotAnEscape)
     {
         throw new PeterPiperArgumentException(String.Format("EscapeMetaData's EscapeType argument can not be set to '{0}', maybe you should choose '{1}'", EscapeType.NotAnEscape.ToString(), EscapeType.Unknown.ToString()));
     }
     this._EscapeType         = EscapeType;
     this._EscapeTypeCharater = Escapes.ResolveEscapeChararter(_EscapeType);
     this._MetaData           = MetaData;
 }
Exemple #2
0
        /// <summary>Number of escapes in given code </summary>
        private static int N(Escapes escapes)
        {
            switch (escapes)
            {
            case Escapes.None: return(0);

            case Escapes.Both: return(2);

            default: return(1);
            }
        }
 public void ExportEscapesPDF()
 {
     if (Escapes != null && Escapes.Count() != 0)
     {
         DocumentManager.ExportDataPDF(EscapeInfo.ConvertToList(Escapes), "Export zvířata");
     }
     else
     {
         MessageBox.Show("Žádná data pro export.");
     }
 }
 public void Export()
 {
     if (Escapes != null && Escapes.Count() != 0)
     {
         DocumentManager.ExportDataPDF(EscapeInfo.ConvertToList(Escapes), "Export útěky: " + EscapeSince + " až " + EscapeTo);
     }
     else
     {
         MessageBox.Show("Žádná data pro export.");
     }
 }
Exemple #5
0
        //Extract the string content from lexeme, adjusts the escaped and double-end symbols
        protected override bool ConvertValue(CompoundTokenDetails details)
        {
            var value         = details.Body;
            var escapeEnabled = !details.IsSet((short)HereDocOptions.NoEscapes);

            //Fix all escapes
            if (escapeEnabled && value.IndexOf(EscapeChar) >= 0)
            {
                details.Flags |= (int)StringFlagsInternal.HasEscapes;
                var arr        = value.Split(EscapeChar);
                var ignoreNext = false;
                //we skip the 0 element as it is not preceeded by "\"
                for (var i = 1; i < arr.Length; i++)
                {
                    if (ignoreNext)
                    {
                        ignoreNext = false;
                        continue;
                    }
                    var s = arr[i];
                    if (string.IsNullOrEmpty(s))
                    {
                        //it is "\\" - escaped escape symbol.
                        arr[i]     = @"\";
                        ignoreNext = true;
                        continue;
                    }
                    //The char is being escaped is the first one; replace it with char in Escapes table
                    var first = s[0];
                    if (Escapes.TryGetValue(first, out char newFirst))
                    {
                        arr[i] = newFirst + s.Substring(1);
                    }
                    else
                    {
                        arr[i] = HandleSpecialEscape(arr[i], details);
                    }
                }
                value = string.Join(string.Empty, arr);
            }

            details.TypeCodes = new[] { TypeCode.String };
            details.Value     = value;

            return(true);
        }
Exemple #6
0
 public void CreateEscape()
 {
     try
     {
         using (ShelterDatabaseLINQDataContext db = new ShelterDatabaseLINQDataContext())
         {
             Escapes escape = new Escapes
             {
                 AnimalID    = AnimalID,
                 Date        = Date,
                 Description = Description,
             };
             db.Escapes.InsertOnSubmit(escape);
             db.SubmitChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #7
0
        public EscapeData(string ContentEscapeString)
        {
            if (ContentEscapeString == String.Empty)
            {
                throw new PeterPiperArgumentException("EscapeMetaData supplied string was empty, this is not allowed.");
            }

            this._EscapeType = Escapes.ResolveEscapeType(ContentEscapeString);
            if (_EscapeType != EscapeType.Unknown)
            {
                this._EscapeTypeCharater = Escapes.ResolveEscapeChararter(_EscapeType);
            }
            else
            {
                this._EscapeTypeCharater = ContentEscapeString.ToCharArray()[0].ToString();
            }

            if (ContentEscapeString.Length > 1)
            {
                if (ContentEscapeString.StartsWith("."))
                {
                    if (ContentEscapeString.Length > 3)
                    {
                        this._MetaData = ContentEscapeString.Substring(3, ContentEscapeString.Length - 3);
                    }
                    else
                    {
                        this._MetaData = String.Empty;
                    }
                }
                else
                {
                    this._MetaData = ContentEscapeString.Substring(1, ContentEscapeString.Length - 1);
                }
            }
            else
            {
                this._MetaData = String.Empty;
            }
        }
        }     //method

        //Extract the string content from lexeme, adjusts the escaped and double-end symbols
        protected override bool ConvertValue(CompoundTokenDetails details)
        {
            string value         = details.Body;
            bool   escapeEnabled = !details.IsSet((short)StringOptions.NoEscapes);

            //Fix all escapes
            if (escapeEnabled && value.IndexOf(EscapeChar) >= 0)
            {
                details.Flags |= (int)StringFlagsInternal.HasEscapes;
                string[] arr        = value.Split(EscapeChar);
                bool     ignoreNext = false;
                //we skip the 0 element as it is not preceeded by "\"
                for (int i = 1; i < arr.Length; i++)
                {
                    if (ignoreNext)
                    {
                        ignoreNext = false;
                        continue;
                    }
                    string s = arr[i];
                    if (string.IsNullOrEmpty(s))
                    {
                        //it is "\\" - escaped escape symbol.
                        arr[i]     = @"\";
                        ignoreNext = true;
                        continue;
                    }
                    //The char is being escaped is the first one; replace it with char in Escapes table
                    char first = s[0];
                    char newFirst;
                    if (Escapes.TryGetValue(first, out newFirst))
                    {
                        arr[i] = newFirst + s.Substring(1);
                    }
                    else
                    {
                        arr[i] = HandleSpecialEscape(arr[i], details);
                    } //else
                }     //for i
                value = string.Join(string.Empty, arr);
            }         // if EscapeEnabled

            //Check for doubled end symbol
            string endSymbol = details.EndSymbol;

            if (details.IsSet((short)StringOptions.AllowsDoubledQuote) && value.IndexOf(endSymbol) >= 0)
            {
                value = value.Replace(endSymbol + endSymbol, endSymbol);
            }

            if (details.IsSet((short)StringOptions.IsChar))
            {
                if (value.Length != 1)
                {
                    details.Error = Resources.ErrBadChar; //"Invalid length of char literal - should be a single character.";
                    return(false);
                }
                details.Value = value[0];
            }
            else
            {
                details.TypeCodes = new TypeCode[] { TypeCode.String };
                details.Value     = value;
            }
            return(true);
        }
Exemple #9
0
        private static List <GridLayout> CalculateSimpleGrid(RectangleF bounds, int rows, int columns, int spacing, Escapes escapeRows, Escapes escapeColumns, float escapeRatio, Item.ItemTypes type)
        {         // do simple spacing within 1 bounds.  May be used with rows=1 or cols=1 to work within a row/col or to generate rows/cols
                  // returns list of items in grid
            SizeF available = new SizeF(Math.Max(3, bounds.Width - (columns + N(escapeColumns) + 1) * spacing),
                                        Math.Max(3, bounds.Height - (rows + N(escapeRows) + 1) * spacing));
            SizeF             cellSize = new SizeF(available.Width / (columns + N(escapeColumns) * escapeRatio), available.Height / (rows + N(escapeRows) * escapeRatio)); // size of standard cell
            PointF            location = new PointF(spacing + bounds.X, spacing + bounds.Y);
            List <GridLayout> list     = new List <GridLayout>();

            for (int Y = 0; Y < rows + N(escapeRows); Y++)
            {
                location.X = spacing + bounds.X;
                bool  isEscapeRow = Y == 0 && (escapeRows & Escapes.Start) > 0 || Y == rows + N(escapeRows) - 1 && (escapeRows & Escapes.End) > 0;
                SizeF thisSize    = cellSize;
                thisSize.Height = isEscapeRow ? cellSize.Height * escapeRatio : cellSize.Height;
                for (int X = 0; X < columns + N(escapeColumns); X++)
                {
                    bool isEscapeColumn = X == 0 && (escapeColumns & Escapes.Start) > 0 || X == columns + N(escapeColumns) - 1 && (escapeColumns & Escapes.End) > 0;
                    thisSize.Width = isEscapeColumn ? cellSize.Width * escapeRatio : cellSize.Width;
                    list.Add(new GridLayout()
                    {
                        Bounds = new RectangleF(location, thisSize), Type = isEscapeColumn || isEscapeRow ? Item.ItemTypes.IT_Escape : type
                    });
                    location.X += spacing + thisSize.Width;
                }
                location.Y += spacing + thisSize.Height;
            }
            return(list);
        }
Exemple #10
0
        public static GridLayout CalculateAreas(RectangleF bounds, int rows, int columns, int spacing, Orders order, Escapes escapes, float escapeRatio)
        {
            GridLayout top = new GridLayout()
            {
                Bounds = bounds, Type = Item.ItemTypes.IT_TopItem
            };

            switch (order)
            {
            case Orders.Individual:
                top.Contents = CalculateSimpleGrid(bounds, rows, columns, spacing, 0, 0, 0, Item.ItemTypes.IT_Item);
                break;

            case Orders.Rows:
                var rowContainers = CalculateSimpleGrid(bounds, rows, 1, spacing, 0, 0, 0, Item.ItemTypes.IT_Group);
                foreach (var row in rowContainers)
                {
                    row.Contents = CalculateSimpleGrid(row.Bounds, 1, columns, spacing, 0, escapes, escapeRatio, Item.ItemTypes.IT_Item);
                }
                top.Contents = rowContainers;
                break;

            case Orders.Columns:
                var columnContainers = CalculateSimpleGrid(bounds, 1, columns, spacing, 0, 0, 0, Item.ItemTypes.IT_Group);
                foreach (var row in columnContainers)
                {
                    row.Contents = CalculateSimpleGrid(row.Bounds, rows, 1, spacing, escapes, 0, escapeRatio, Item.ItemTypes.IT_Item);
                }
                top.Contents = columnContainers;
                break;
            }
            return(top);
        }
        }     //method

        //Extract the string content from lexeme, adjusts the escaped and double-end symbols
        protected override bool ConvertValue(ScanDetails details)
        {
            string value         = details.Body;
            bool   escapeEnabled = !details.IsSet(ScanFlags.DisableEscapes);

            //Fix all escapes
            if (escapeEnabled && value.IndexOf(EscapeChar) >= 0)
            {
                details.Flags |= ScanFlags.HasEscapes;
                string[] arr        = value.Split(EscapeChar);
                bool     ignoreNext = false;
                //we skip the 0 element as it is not preceeded by "\"
                for (int i = 1; i < arr.Length; i++)
                {
                    if (ignoreNext)
                    {
                        ignoreNext = false;
                        continue;
                    }
                    string s = arr[i];
                    if (string.IsNullOrEmpty(s))
                    {
                        //it is "\\" - escaped escape symbol.
                        arr[i]     = @"\";
                        ignoreNext = true;
                        continue;
                    }
                    //The char is being escaped is the first one; replace it with char in Escapes table
                    char first = s[0];
                    char newFirst;
                    if (Escapes.TryGetValue(first, out newFirst))
                    {
                        arr[i] = newFirst + s.Substring(1);
                    }
                    else
                    {
                        arr[i] = HandleSpecialEscape(arr[i], details);
                    } //else
                }     //for i
                value = string.Join(string.Empty, arr);
            }         // if EscapeEnabled

            //Check for doubled end symbol
            string startS = details.ControlSymbol;

            if (details.IsSet(ScanFlags.AllowDoubledQuote) && value.IndexOf(startS) >= 0)
            {
                value = value.Replace(startS + startS, startS);
            }

            if (details.IsSet(ScanFlags.IsChar))
            {
                details.TypeCodes = new TypeCode[] { TypeCode.Char }
            }
            ;
            //Check char length - must be exactly 1
            if (details.TypeCodes[0] == TypeCode.Char && value.Length != 1)
            {
                details.Error = "Invalid length of char literal - should be 1.";
                return(false);
            }

            details.Value = (details.TypeCodes[0] == TypeCode.Char ? (object)value[0] : value);
            return(true);

            //TODO: Investigate unescaped linebreak, with  Flags == BnfFlags.StringAllowLineBreak | BnfFlags.StringLineBreakEscaped
            //      also investigate what happens in this case in Windows where default linebreak is "\r\n", not "\n"
        }