<commit_before>/*
 	 Uiml.Net: a Uiml.Net renderer (http://lumumba.uhasselt.be/kris/research/uiml.net/)

	 Copyright (C) 2003  <NAME> (<EMAIL>)
	                     Expertise Centre for Digital Media (http://edm.uhasselt.be)
								Hasselt University

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public License
	as published by the Free Software Foundation; either version 2.1
	of	the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

	Author: 
		<NAME>
		<EMAIL>
*/


namespace Uiml.Rendering.CompactSWF
{
	using System;
	using System.Collections;
	using System.Reflection;
    
	using System.Windows.Forms;
	using System.Drawing;
	using Uiml;
	using Uiml.Rendering;
    using Uiml.Rendering.TypeDecoding;

	public class CompactSWFTypeDecoders
	{
        [TypeDecoderMethod]
        public static System.Drawing.Point DecodePoint(string val)
        {
            string[] coords = val.Split(new Char[] { ',' });
            return new System.Drawing.Point(Int32.Parse(coords[0]), Int32.Parse(coords[1]));
        }

        [TypeDecoderMethod]
        public static System.Drawing.Size DecodeSize(string val)
        {
            string[] coords = val.Split(new Char[] { ',' });
            return new System.Drawing.Size(Int32.Parse(coords[0]), Int32.Parse(coords[1]));
        }

        [TypeDecoderMethod]
        public static System.Drawing.Image DecodeImage(string file)
        {
            return new Bitmap((string) file);
        }

		///<summary>
		///Decodes a font from a given value
		///Original code from the MyXaml project, <NAME>
		///</summary>
		///<param name="value">Contains the font information that has to be decoded</param>
        [TypeDecoderMethod]
		public static Font DecodeFont(string value)
		{
			System.Drawing.Font c = new Font("MS Sans Serif", 10, FontStyle.Regular );
			string [] Fontparts;
			value = value.Replace(" ","");

			Fontparts = value.Split(",".ToCharArray());
			FontStyle fontstyle = FontStyle.Regular;
			int fontsize = 10;

			if (Fontparts.Length == 3) 
			{
				try 
				{
					Fontparts[1] = Fontparts[1].Replace("pt", "");
					fontsize = Convert.ToInt16(Fontparts[1]);
				}
				catch (Exception e) 
				{
				}
				try 
				{
					Fontparts[2] = Fontparts[2].Replace("style", "");
					Fontparts[2] = Fontparts[2].Replace("=", "");
				}
				catch (Exception e) 
				{
				}

				switch (Fontparts[2].ToLower()) 
				{	
					case "bold": fontstyle = FontStyle.Bold; break;
					case "italic": fontstyle = FontStyle.Italic; break;
					case "regular": fontstyle = FontStyle.Regular; break;
					case "strikeout": fontstyle = FontStyle.Strikeout; break;
					case "underline": fontstyle = FontStyle.Underline; break;
				}
				return new Font(Fontparts[0], fontsize, fontstyle);
			}
			else
			{
				return null;
			}
		}

		///<summary>
		///Decodes the border style from a given string. 
		///Original code from the MyXaml project, <NAME>
		///</summary>
		///<param name="value">The string containing a description for a font</param>
        [TypeDecoderMethod]
		public static FormBorderStyle DecodeFormBorderStyle(string value) 
		{
			switch (value.ToLower()) 
			{
				case "fixed3d": return System.Windows.Forms.FormBorderStyle.Fixed3D;
				case "fixeddialog": return System.Windows.Forms.FormBorderStyle.FixedDialog;
				case "fixedsingle": return System.Windows.Forms.FormBorderStyle.FixedSingle; 
				case "fixedTooltindow": return System.Windows.Forms.FormBorderStyle.FixedToolWindow; 
				case "none": return System.Windows.Forms.FormBorderStyle.None; 
				case "sizable": return System.Windows.Forms.FormBorderStyle.Sizable; 
				case "sizabletooltindow": return System.Windows.Forms.FormBorderStyle.SizableToolWindow; 
				default :
					return System.Windows.Forms.FormBorderStyle.Fixed3D; 

			}
		}

        [TypeDecoderMethod]
		public static DateTime DecodeDateTime(string value)
		{
			string[] coords = value.Split(new Char[] {'/'});
			int month = int.Parse(coords[0]);
			int day = int.Parse(coords[1]);
			int year = int.Parse(coords[2]);
			return new DateTime(year, month, day);
		}

        [TypeDecoderMethod]
		public static ScrollBars DecodeScrollBars(string value)
		{
			if(value == "Both")
				return ScrollBars.Both;
			else if(value == "Horizontal")
				return ScrollBars.Horizontal;
			else if(value == "Vertical")
				return ScrollBars.Vertical;
			else
				return ScrollBars.None;
		}

        [TypeDecoderMethod]
		public static View DecodeView(string value)
		{
			if(value == "LargeIcon")
				return View.LargeIcon;
			else if(value == "SmallIcon")
				return View.SmallIcon;
			else if(value == "List")
				return View.List;
			else
				return View.Details;
		}

        [TypeDecoderMethod]
        public static PictureBoxSizeMode DecodePictureBoxSizeMode(string value)
        {
            switch (value)
            {
                case "StretchImage":
                    return PictureBoxSizeMode.StretchImage;
                case "AutoSize":
                    return PictureBoxSizeMode.AutoSize;
                case "CenterImage":
                    return PictureBoxSizeMode.CenterImage;
                case "Zoom":
                    return PictureBoxSizeMode.Zoom;
                case "Normal":
                default:
                    return PictureBoxSizeMode.Normal;
            }
        }

        public static string DecodePictureBoxSizeModeInverse(PictureBoxSizeMode m)
        {
            return m.ToString();
        }

        [TypeDecoderMethod]<commit_msg>Fixed bug in decoding of PictureBoxSizeMode class on Compact .NET.<commit_after>/*
 	 Uiml.Net: a Uiml.Net renderer (http://lumumba.uhasselt.be/kris/research/uiml.net/)

	 Copyright (C) 2003  <NAME> (<EMAIL>)
	                     Expertise Centre for Digital Media (http://edm.uhasselt.be)
								Hasselt University

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public License
	as published by the Free Software Foundation; either version 2.1
	of	the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

	Author: 
		<NAME>
		<EMAIL>
*/


namespace Uiml.Rendering.CompactSWF
{
	using System;
	using System.Collections;
	using System.Reflection;
    
	using System.Windows.Forms;
	using System.Drawing;
	using Uiml;
	using Uiml.Rendering;
    using Uiml.Rendering.TypeDecoding;

	public class CompactSWFTypeDecoders
	{
        [TypeDecoderMethod]
        public static System.Drawing.Point DecodePoint(string val)
        {
            string[] coords = val.Split(new Char[] { ',' });
            return new System.Drawing.Point(Int32.Parse(coords[0]), Int32.Parse(coords[1]));
        }

        [TypeDecoderMethod]
        public static System.Drawing.Size DecodeSize(string val)
        {
            string[] coords = val.Split(new Char[] { ',' });
            return new System.Drawing.Size(Int32.Parse(coords[0]), Int32.Parse(coords[1]));
        }

        [TypeDecoderMethod]
        public static System.Drawing.Image DecodeImage(string file)
        {
            return new Bitmap((string) file);
        }

		///<summary>
		///Decodes a font from a given value
		///Original code from the MyXaml project, <NAME>
		///</summary>
		///<param name="value">Contains the font information that has to be decoded</param>
        [TypeDecoderMethod]
		public static Font DecodeFont(string value)
		{
			System.Drawing.Font c = new Font("MS Sans Serif", 10, FontStyle.Regular );
			string [] Fontparts;
			value = value.Replace(" ","");

			Fontparts = value.Split(",".ToCharArray());
			FontStyle fontstyle = FontStyle.Regular;
			int fontsize = 10;

			if (Fontparts.Length == 3) 
			{
				try 
				{
					Fontparts[1] = Fontparts[1].Replace("pt", "");
					fontsize = Convert.ToInt16(Fontparts[1]);
				}
				catch (Exception e) 
				{
				}
				try 
				{
					Fontparts[2] = Fontparts[2].Replace("style", "");
					Fontparts[2] = Fontparts[2].Replace("=", "");
				}
				catch (Exception e) 
				{
				}

				switch (Fontparts[2].ToLower()) 
				{	
					case "bold": fontstyle = FontStyle.Bold; break;
					case "italic": fontstyle = FontStyle.Italic; break;
					case "regular": fontstyle = FontStyle.Regular; break;
					case "strikeout": fontstyle = FontStyle.Strikeout; break;
					case "underline": fontstyle = FontStyle.Underline; break;
				}
				return new Font(Fontparts[0], fontsize, fontstyle);
			}
			else
			{
				return null;
			}
		}

		///<summary>
		///Decodes the border style from a given string. 
		///Original code from the MyXaml project, <NAME>
		///</summary>
		///<param name="value">The string containing a description for a font</param>
        [TypeDecoderMethod]
		public static FormBorderStyle DecodeFormBorderStyle(string value) 
		{
			switch (value.ToLower()) 
			{
				case "fixed3d": return System.Windows.Forms.FormBorderStyle.Fixed3D;
				case "fixeddialog": return System.Windows.Forms.FormBorderStyle.FixedDialog;
				case "fixedsingle": return System.Windows.Forms.FormBorderStyle.FixedSingle; 
				case "fixedTooltindow": return System.Windows.Forms.FormBorderStyle.FixedToolWindow; 
				case "none": return System.Windows.Forms.FormBorderStyle.None; 
				case "sizable": return System.Windows.Forms.FormBorderStyle.Sizable; 
				case "sizabletooltindow": return System.Windows.Forms.FormBorderStyle.SizableToolWindow; 
				default :
					return System.Windows.Forms.FormBorderStyle.Fixed3D; 

			}
		}

        [TypeDecoderMethod]
		public static DateTime DecodeDateTime(string value)
		{
			string[] coords = value.Split(new Char[] {'/'});
			int month = int.Parse(coords[0]);
			int day = int.Parse(coords[1]);
			int year = int.Parse(coords[2]);
			return new DateTime(year, month, day);
		}

        [TypeDecoderMethod]
		public static ScrollBars DecodeScrollBars(string value)
		{
			if(value == "Both")
				return ScrollBars.Both;
			else if(value == "Horizontal")
				return ScrollBars.Horizontal;
			else if(value == "Vertical")
				return ScrollBars.Vertical;
			else
				return ScrollBars.None;
		}

        [TypeDecoderMethod]
		public static View DecodeView(string value)
		{
			if(value == "LargeIcon")
				return View.LargeIcon;
			else if(value == "SmallIcon")
				return View.SmallIcon;
			else if(value == "List")
				return View.List;
			else
				return View.Details;
		}

        [TypeDecoderMethod]
        public static PictureBoxSizeMode DecodePictureBoxSizeMode(string value)
        {
            switch (value)
            {
                case "StretchImage":
                    return PictureBoxSizeMode.StretchImage;
                case "CenterImage":
                    return PictureBoxSizeMode.CenterImage;
                case "Normal":
                default:
                    return PictureBoxSizeMode.Normal;
            }
        }

        public static string DecodePictureBoxSizeModeInverse(PictureBoxSizeMode m)
        {
            return m.ToString();
        }

        [TypeDecoderMethod]
{'fraction_non_alphanumeric': 0.10591483309629382, 'fraction_numerical': 0.009035388605371036, 'mean_word_length': 2.712422360248447, 'pattern_counts': {'":': 32, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6954778', 'n_tokens_mistral': 4099, 'n_tokens_neox': 3483, 'n_words': 950}