Exemple #1
0
        public PTPEditorVM(PTP ptp)
        {
            FromCommand             = new RelayCommand(Replace);
            BackgroundWorker.Status = "Загрузка...";

            int sourceInd = Static.EncodingManager.GetPersonaEncodingIndex(ApplicationSettings.AppSetting.Default.PTPOldDefault);

            if (sourceInd >= 0)
            {
                OldEncoding = sourceInd;
            }
            else
            {
                OldEncoding = 0;
            }

            sourceInd = Static.EncodingManager.GetPersonaEncodingIndex(ApplicationSettings.AppSetting.Default.PTPNewDefault);
            if (sourceInd >= 0)
            {
                NewEncoding = sourceInd;
            }
            else
            {
                NewEncoding = 0;
            }

            sourceInd = Static.BackManager.GetBackgroundIndex(ApplicationSettings.AppSetting.Default.PTPBackgroundDefault);
            if (sourceInd >= 0)
            {
                SelectedBackgroundIndex = sourceInd;
            }
            else
            {
                SelectedBackgroundIndex = 0;
            }

            View = ApplicationSettings.AppSetting.Default.PTPImageView;
            EncodingManagerEW = new EventWrapperINPC(Static.EncodingManager, this);

            foreach (var a in ptp.Names)
            {
                Names.Add(new PTPNameEditVM(a, OldEncoding, NewEncoding, SelectedBackgroundIndex));
            }


            foreach (var a in ptp.Msg)
            {
                var name = Names.FirstOrDefault(x => x.Index == a.CharacterIndex);
                Tuple <ImageDrawing, ImageDrawing, ImageDrawing, RectangleGeometry> tuple;
                if (name == null)
                {
                    tuple = new Tuple <ImageDrawing, ImageDrawing, ImageDrawing, RectangleGeometry>(null, null, BackgroundDrawing, ClipGeometry);
                }
                else
                {
                    tuple = new Tuple <ImageDrawing, ImageDrawing, ImageDrawing, RectangleGeometry>(name.OldNameVisual.TextDrawing, name.NewNameVisual.TextDrawing, BackgroundDrawing, ClipGeometry);
                }

                MSG.Add(new PTPMsgVM(a, tuple, ApplicationSettings.AppSetting.Default.PTPOldDefault, ApplicationSettings.AppSetting.Default.PTPNewDefault, SelectedBackgroundIndex));
            }


            BackgroundWorker.Status = "Готово...";
        }