コード例 #1
0
        /// <summary>
        /// Creates XML Document So A user can see what the document should/can look like
        /// </summary>
        public void CreateXAML()
        {
            List<Catagory> saveList = new List<Catagory>();
            Catagory first = new Catagory();
            Catagory second = new Catagory();
            first.BackGroundColor = Colors.AntiqueWhite;
            first.TextColor = Colors.Black;
            first.Ratio = 0.45;
            first.Title = "firstTitle";

            first.Video = @"C:\Users\Public\Videos\Sample Videos\Wildlife.wmv";
            first.Image = "X.jpg";
            first.Explanation = "long string with\n to make sence i should say newline\nLol\n";
            first.SubCatagoryFile = "Top";
            first.BackGroundImage = @"bond.jpg";

            first.ImageSetup = new ImageInformation();
            second.BackGroundColor = Colors.AntiqueWhite;
            second.TextColor = Colors.Black;
            second.Ratio = 0.55;
            second.Title = "SecondTitle";

            saveList.Add(first);
            saveList.Add(second);

            Catagory.WriteFile(saveList, "Resources/Information/Example.xml");
        }
コード例 #2
0
ファイル: Catagory.cs プロジェクト: RiedigerD2/OpenHouse
        public static SquareList ReadFile(string file)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(List<Catagory>));

            List<Catagory> simpleList=null;
            try
            {
                StreamReader reader = new StreamReader(file);
                simpleList = (List<Catagory>)serializer.Deserialize(reader);
                reader.Close();
            }catch(Exception e){
                Catagory error = new Catagory();
                error.BackGroundColor = Colors.Yellow;
                error.TextColor = Colors.Black;

                error.Ratio = 1;
                if(e is FileNotFoundException){
                        error.Title = "File Not Found";
                }
                else if (e is DirectoryNotFoundException)
                {
                    error.Title = "Invalid Path to File";
                }
                else if (e is PathTooLongException)
                {
                    error.Title = "Wow Thats along path to follow";
                }
                else if (e is IOException)
                {
                    if (e.InnerException != null)
                    {

                        error.Title = e.InnerException.Message;
                    }else
                    error.Title += e.Message;
                }
                else
                {
                    error.Title = e.Message;
                }

                simpleList = new List<Catagory>();
                simpleList.Add(error);
            }

            return createSquareList(simpleList);
        }