private static SignViewModel ConvertSigntoSignViewModel(Sign signModel)
 {
     //var size = GetSize(signModel.MinBounding.X, signModel.MinBounding.Y, signModel.MaxBounding.X,
     //                   signModel.MaxBounding.Y, 10);
     var size = GetSize(signModel);
     //var leftPadding = GetLeftPadding(signModel);
     //var margin = new Thickness(leftPadding, 0, 0, 0);
     //_top += size.Height;
     //var top = _top;
     var svm = new SignViewModel
     {
         Sign = signModel,
         Symbols = GetSymbols(signModel),
         Height = size.Height,
         Width = size.Width,
         //Margin = margin,
         //LefttoEdge = leftPadding,
         //Top = top
     };
     return svm;
 }
        public static Sign FswtoSwSign(string fsw, int idSignLanguage = 0, int idCulture = 0)
        {
            var sign = new Sign { BkColor = BasicColor.GetBasicColor(Colors.White) };
            //swSign.LanguageIso((long)idCulture);
            //swSign.SignLanguageIso((long)idSignLanguage);

            //swSign.SignWriterGuid = (Guid?)Guid.NewGuid();
            var sequenceBuildStr = fsw.GetSequenceBuildStr();
            var symbolsBuildStr = fsw.GetSymbolsBuildStr();

            var boundingStr = GetBoundingStr(symbolsBuildStr);

            if (boundingStr != null)
            {
                sign.Lane = boundingStr.FirstOrDefault();
                sign.MaxBounding = GetCoordinate(boundingStr.Substring(1, boundingStr.Length - 1));
            }

            foreach (var symbol in SpmlSymbolsToSwSymbols(symbolsBuildStr))
            {
                symbol.PrimaryColor = BasicColor.GetBasicColor(Colors.Black);
                symbol.SecondaryColor = BasicColor.GetBasicColor(Colors.White);
                sign.Frames[0].Symbols.Add(symbol);
            }
            sign.MinBounding = GetMinBounding(sign.Frames[0].Symbols);
            var rank = 0;
            foreach (var seq in SpmlSequence(sequenceBuildStr))
            {
                rank++;

                if (SymbolExists(seq))
                    sign.Frames[0].Sequences.Add(new Sequence(seq, rank));
            }
            //sign.Frames[0].CenterSymbols();
            return sign;
        }
        private static ObservableCollection<SymbolViewModel> GetSymbols(Sign sign)
        {
            var oc = new ObservableCollection<SymbolViewModel>();

            var firstOrDefault = sign.Frames.FirstOrDefault();

            var xOffset = (sign.MaxBounding.X - 500);
            var yOffset = (sign.MaxBounding.Y - 500);

            if (firstOrDefault != null)
            {
                var offsetToNormal = GetOffsetToNormal(firstOrDefault.Symbols);

                foreach (var symbol in firstOrDefault.Symbols)
                {
                    var x = (symbol.X - 500) - offsetToNormal.X;
                    var y = (symbol.Y - 500) - offsetToNormal.Y;
                    oc.Add(new SymbolViewModel
                        {
                            Definition = Dal.GetDefinition(symbol.Code),
                            X = x,
                            Y = y,
                            PrimaryBrush = new SolidColorBrush(BasicColor.GetMediaColor(symbol.PrimaryColor)),
                            SecondaryBrush = new SolidColorBrush(BasicColor.GetMediaColor(symbol.SecondaryColor))
                        });
                }
            }
            return oc;
        }
 public static SignViewModel GetSignViewModel(Sign signModel)
 {
     return ConvertSigntoSignViewModel(signModel);
 }
        private static Size GetSize(Sign signModel)
        {
            int signxMin = int.MaxValue, signyMin = int.MaxValue, signxMax = int.MinValue, signyMax = int.MinValue;
            var firstOrDefault = signModel.Frames.FirstOrDefault();
            if (firstOrDefault != null)
                foreach (var symbol in firstOrDefault.Symbols)
                {
                    int symxMin = symbol.X;
                    int symyMin = symbol.Y;
                    int symxMax = symbol.X + GetSymbolWidth(symbol.Code);
                    int symyMax = symbol.Y + GetSymbolHeight(symbol.Code);

                    if (symxMin < signxMin) signxMin = symxMin;
                    if (symyMin < signyMin) signyMin = symyMin;
                    if (symxMax > signxMax) signxMax = symxMax;
                    if (symyMax > signyMax) signyMax = symyMax;

                }

            return new Size(signxMax - signxMin, signyMax - signyMin);
        }