Esempio n. 1
0
        /// <summary>
        /// Добавить новый шаблон в список шаблонов
        /// </summary>
        /// <param name="richTextBox">Редактор с новым шаблоном</param>
        /// <param name="list">Список шаблонов</param>
        private static void AddTemplate(SpardTemplateViewModel template)
        {
            var text = template.Transform;

            if (!template.Enabled || template.Variants.Contains(text))
            {
                return;
            }

            template.Variants.Add(text);
        }
Esempio n. 2
0
        public ImportTextViewModel(object arg, StorageContextViewModel storageContextViewModel)
        {
            _arg = arg;
            _storageContextViewModel = storageContextViewModel;
            _scheduler = TaskScheduler.FromCurrentSynchronizationContext();

            #region Aliases
            Templates = new ObservableCollection <SpardTemplateViewModel>();

            var trashAlias = new EditAlias("Мусор", Colors.LightGray);

            _packageTemplate = new SpardTemplateViewModel {
                Name = "Пакет"
            };
            _packageTemplate.Aliases["PName"] = new EditAlias("Пакет", Colors.Orchid);
            _packageTemplate.Aliases["Some"]  = trashAlias;
            Templates.Add(_packageTemplate);

            _roundTemplate = new SpardTemplateViewModel {
                Name = "Раунд"
            };
            _roundTemplate.Aliases["RName"] = new EditAlias("Раунд", Colors.Olive);
            _roundTemplate.Aliases["Some"]  = trashAlias;
            Templates.Add(_roundTemplate);

            _themeTemplate = new SpardTemplateViewModel {
                Name = "Тема"
            };
            _themeTemplate.Aliases["TName"]    = new EditAlias("Тема", Colors.BlueViolet);
            _themeTemplate.Aliases["TAuthor"]  = new EditAlias("Автор", Colors.Maroon);
            _themeTemplate.Aliases["TComment"] = new EditAlias("Комментарий", Colors.Navy);
            _themeTemplate.Aliases["Some"]     = trashAlias;
            Templates.Add(_themeTemplate);

            _questTemplate = new SpardTemplateViewModel {
                Name = "Вопрос"
            };
            _questTemplate.Aliases["Number"]   = new EditAlias("Номер", Colors.SkyBlue);
            _questTemplate.Aliases["QText"]    = new EditAlias("Вопрос", Colors.SeaGreen);
            _questTemplate.Aliases["Answer"]   = new EditAlias("Ответ", Colors.Yellow);
            _questTemplate.Aliases["QAuthor"]  = new EditAlias("Автор", Colors.Goldenrod);
            _questTemplate.Aliases["QComment"] = new EditAlias("Комментарий", Colors.Cyan);
            _questTemplate.Aliases["QSource"]  = new EditAlias("Источник", Colors.Chocolate);
            _questTemplate.Aliases["Some"]     = trashAlias;
            Templates.Add(_questTemplate);

            _separatorTemplate = new SpardTemplateViewModel {
                Name = "Разделитель", NonStandartOnly = true
            };
            _separatorTemplate.Aliases["Some"] = trashAlias;

            _answerTemplate = new SpardTemplateViewModel {
                Name = "Ответ", NonStandartOnly = true
            };

            foreach (var item in _questTemplate.Aliases)
            {
                _answerTemplate.Aliases[item.Key] = item.Value;
            }

            foreach (var item in Templates)
            {
                item.PropertyChanged += Item_PropertyChanged;
                foreach (var alias in item.Aliases)
                {
                    if (!Aliases.ContainsKey(alias.Key))
                    {
                        Aliases[alias.Key] = alias.Value;
                    }
                }
            }

            #endregion

            _sns = new SimpleCommand(Sns_Executed)
            {
                CanBeExecuted = false
            };
            _auto = new SimpleCommand(Auto_Executed)
            {
                CanBeExecuted = false
            };
            _go   = new SimpleCommand(Go_Executed);
            _skip = new SimpleCommand(Skip_Executed);
        }