Esempio n. 1
0
        public (string FileName, FileInfo Info) SaveMsgTuple(ATextField _txt, string _fileName)
        {
            //FileInfo
            var info = new FileInfo(_fileName);


            //Breakdown TextField Properties
            var background   = (SolidColorBrush)_txt.Background;
            var foreground   = (SolidColorBrush)_txt.Foreground;
            var border       = (SolidColorBrush)_txt.BorderBrush;
            var thickness    = _txt.BorderThickness.Top;
            var cornerradius = _txt.CornerRadius.TopLeft;
            var fontfamily   = _txt.FontFamily;
            var fontsize     = _txt.FontSize;
            var text         = _txt.Text;

            // Convet to the format
            var format = new MsgFormat
            {
                Background   = background.Color.ToString(),
                Foreground   = foreground.Color.ToString(),
                Border       = border.Color.ToString(),
                Thickness    = thickness,
                CornerRadius = cornerradius,
                FontSize     = fontsize,
                FontFamily   = fontfamily.Source
            };

            //Sererlize to Json
            var json = Serialize(format);

            //Save the Json to file
            File.WriteAllText(_fileName, json);



            return(_fileName, info);
        }
Esempio n. 2
0
        public (string FileName, FileInfo Info) LoadMsgTuple(string _fileName, ATextField _txt)
        {
            //FileINfo
            var info = new FileInfo(_fileName);

            // Grab the Json
            var json = File.ReadAllText(_fileName);
            //Convet json to MsgFormat
            var format = Deserialize <MsgFormat>(json);


            //Convert format to the ATextField
            _txt.Background      = HexBrush(format.Background);
            _txt.Foreground      = HexBrush(format.Foreground);
            _txt.BorderBrush     = HexBrush(format.Border);
            _txt.BorderThickness = new Thickness(format.Thickness);
            _txt.FontFamily      = new FontFamily(format.FontFamily);
            _txt.FontSize        = format.FontSize;
            _txt.Text            = format.Text;

            //Return FIle and FileInfo
            return(_fileName, info);
        }