Esempio n. 1
0
        public RoundViewModel(Round round)
            : base(round)
        {
            foreach (var theme in round.Themes)
            {
                Themes.Add(new ThemeViewModel(theme)
                {
                    OwnerRound = this
                });
            }

            Themes.CollectionChanged += Themes_CollectionChanged;

            Clone  = new SimpleCommand(CloneRound_Executed);
            Remove = new SimpleCommand(RemoveRound_Executed);
            Add    = AddTheme = new SimpleCommand(AddTheme_Executed);
        }
Esempio n. 2
0
        public ThemeViewModel(Theme theme)
            : base(theme)
        {
            foreach (var question in theme.Questions)
            {
                Questions.Add(new QuestionViewModel(question)
                {
                    OwnerTheme = this
                });
            }

            Questions.CollectionChanged += Questions_CollectionChanged;

            Clone         = new SimpleCommand(CloneTheme_Executed);
            Remove        = new SimpleCommand(RemoveTheme_Executed);
            Add           = AddQuestion = new SimpleCommand(AddQuestion_Executed);
            SortQuestions = new SimpleCommand(SortQuestions_Executed);
        }
Esempio n. 3
0
        public AnswersViewModel(QuestionViewModel owner, IEnumerable <string> collection, bool isRight)
            : base(collection)
        {
            Owner   = owner;
            IsRight = isRight;

            AnswerSpecial1 = new SimpleCommand(AnswerSpecial1_Executed);
            AnswerSpecial2 = new SimpleCommand(AnswerSpecial2_Executed);
            AnswerSpecial3 = new SimpleCommand(AnswerSpecial3_Executed);

            ToNewAnswer  = new SimpleCommand(ToNewAnswer_Executed);
            ToNewSource  = new SimpleCommand(ToNewSource_Executed);
            ToNewComment = new SimpleCommand(ToNewComment_Executed);

            SelectAtomObject = new SimpleCommand(SelectAtomObject_Executed);

            UpdateCommands();
            UpdateAnswersCommands();
        }
Esempio n. 4
0
        public SpardTemplateViewModel()
        {
            Aliases = new Dictionary <string, EditAlias>();

            Cut = new SimpleCommand(arg =>
            {
                if (_transform != null)
                {
                    Clipboard.SetData(DataFormats.UnicodeText, _transform);
                    Transform = "";
                }
            });

            Copy = new SimpleCommand(arg =>
            {
                if (_transform != null)
                {
                    Clipboard.SetData(DataFormats.UnicodeText, _transform);
                }
            });

            Paste = new SimpleCommand(arg =>
            {
                Transform = (string)Clipboard.GetData(DataFormats.UnicodeText);
            });

            InsertAlias = new SimpleCommand(arg =>
            {
                AliasInserted?.Invoke(arg.ToString());
            });

            InsertOptional = new SimpleCommand(arg =>
            {
                OptionalInserted?.Invoke();
            });

            ChangeTemplate = new SimpleCommand(template =>
            {
                Transform = template.ToString();
            });
        }
Esempio n. 5
0
        public QuestionViewModel(Question question)
            : base(question)
        {
            Type = new QuestionTypeViewModel(question.Type);

            Right    = new AnswersViewModel(this, question.Right, true);
            Wrong    = new AnswersViewModel(this, question.Wrong, false);
            Scenario = new ScenarioViewModel(this, question.Scenario);

            BindHelper.Bind(Right, question.Right);
            BindHelper.Bind(Wrong, question.Wrong);

            AddWrongAnswers = new SimpleCommand(AddWrongAnswers_Executed);

            Clone  = new SimpleCommand(CloneQuestion_Executed);
            Remove = new SimpleCommand(RemoveQuestion_Executed);

            SetQuestionType = new SimpleCommand(SetQuestionType_Executed);

            Wrong.CollectionChanged += Wrong_CollectionChanged;
        }
Esempio n. 6
0
        public MainViewModel(string[] args)
        {
            DocList = new ObservableCollection <WorkspaceViewModel>();
            DocList.CollectionChanged += DocList_CollectionChanged;
            CollectionViewSource.GetDefaultView(DocList).CurrentChanged += MainViewModel_CurrentChanged;

            Open       = new SimpleCommand(Open_Executed);
            OpenRecent = new SimpleCommand(OpenRecent_Executed);

            ImportTxt          = new SimpleCommand(ImportTxt_Executed);
            ImportClipboardTxt = new SimpleCommand(ImportClipboardTxt_Executed);
            ImportXml          = new SimpleCommand(ImportXml_Executed);
            ImportBase         = new SimpleCommand(ImportBase_Executed);
            ImportFromSIStore  = new SimpleCommand(ImportFromSIStore_Executed);

            SaveAll = new SimpleCommand(SaveAll_Executed)
            {
                CanBeExecuted = false
            };

            About    = new SimpleCommand(About_Executed);
            Feedback = new SimpleCommand(Feedback_Executed);
            Donate   = new SimpleCommand(Donate_Executed);

            SetSettings  = new SimpleCommand(SetSettings_Executed);
            SearchFolder = new SimpleCommand(SearchFolder_Executed);

            _storageContextViewModel = new StorageContextViewModel(new Services.SI.SIStorageService());
            _storageContextViewModel.Load();

            AddCommandBinding(ApplicationCommands.New, New_Executed);
            AddCommandBinding(ApplicationCommands.Open, (sender, e) => Open_Executed(e.Parameter));
            AddCommandBinding(ApplicationCommands.Help, Help_Executed);
            AddCommandBinding(ApplicationCommands.Close, Close_Executed);

            _args = args;

            UI.Initialize();
        }
Esempio n. 7
0
        protected TextsStorageViewModel(string title, IList <T> sourceList)
        {
            _title      = title;
            _sourceList = sourceList;

            Collection = new ObservableCollection <T>(_sourceList);
            Collection.CollectionChanged += Collection_CollectionChanged;

            BindHelper.Bind(Collection, _sourceList);

            foreach (var item in Collection)
            {
                item.PropertyChanged += Item_PropertyChanged;
            }

            MoveUp   = new SimpleCommand(MoveUp_Executed);
            MoveDown = new SimpleCommand(MoveDown_Executed);
            Add      = new SimpleCommand(Add_Executed);
            Remove   = new SimpleCommand(Remove_Executed);

            CheckCommands();
        }
Esempio n. 8
0
        protected ItemViewModel(T model)
        {
            Model = model;
            Info  = new InfoViewModel(Model.Info, this);

            AddAuthors = new SimpleCommand(AddAuthors_Executed)
            {
                CanBeExecuted = Info.Authors.Count == 0
            };
            AddSources = new SimpleCommand(AddSources_Executed)
            {
                CanBeExecuted = Info.Sources.Count == 0
            };
            AddComments = new SimpleCommand(AddComments_Executed)
            {
                CanBeExecuted = Info.Comments.Text.Length == 0
            };

            SetCosts = new SimpleCommand(SetCosts_Executed);

            Info.Authors.CollectionChanged += Authors_CollectionChanged;
            Info.Sources.CollectionChanged += Sources_CollectionChanged;
            Info.Comments.PropertyChanged  += Comments_PropertyChanged;
        }
Esempio n. 9
0
        public QuestionTypeViewModel(QuestionType model)
        {
            Model  = model;
            Params = new ObservableCollection <QuestionTypeParamViewModel>();

            Model.PropertyChanged += Model_PropertyChanged;

            AddQuestionTypeParam = new SimpleCommand(AddQuestionTypeParam_Executed)
            {
                CanBeExecuted = AddQuestionTypeParam_CanExecute()
            };

            foreach (var item in Model.Params)
            {
                var viewModel = new QuestionTypeParamViewModel(item)
                {
                    Owner = this
                };
                viewModel.RemoveQuestionTypeParam.CanBeExecuted = AddQuestionTypeParam.CanBeExecuted;
                Params.Add(viewModel);
            }

            Params.CollectionChanged += Params_CollectionChanged;
        }
Esempio n. 10
0
        public ScenarioViewModel(QuestionViewModel owner, Scenario scenario)
        {
            Model = scenario;
            Owner = owner;

            foreach (var atom in scenario)
            {
                Add(new AtomViewModel(atom)
                {
                    OwnerScenario = this
                });

                if (atom.Type == AtomTypes.Marker)
                {
                    IsComplex = true;
                }
            }

            CollectionChanged += ScenarioViewModel_CollectionChanged;

            AddText   = new SimpleCommand(AddText_Executed);
            AddVoice  = new SimpleCommand(AddVoice_Executed);
            AddMarker = new SimpleCommand(AddMarker_Executed);

            ChangeType = new SimpleCommand(ChangeType_Executed);

            SetTime = new SimpleCommand(SetTime_Executed);

            CollapseMedia = new SimpleCommand(CollapseMedia_Executed);
            ExpandMedia   = new SimpleCommand(ExpandMedia_Executed);
            ExportMedia   = new SimpleCommand(ExportMedia_Executed);

            SelectAtomObject = new SimpleCommand(SelectAtomObject_Executed);

            UpdateCommands();
        }
Esempio n. 11
0
 public SettingsViewModel()
 {
     Reset = new SimpleCommand(Reset_Executed);
 }
Esempio n. 12
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);
        }
Esempio n. 13
0
        public NewViewModel(StorageContextViewModel storageContextViewModel)
        {
            _storageContextViewModel = storageContextViewModel;

            Create = new SimpleCommand(Create_Executed);
        }
 public ExportHtmlViewModel(QDocument document)
 {
     _document = document;
     Export    = new SimpleCommand(Export_Executed);
 }
Esempio n. 15
0
 public AboutViewModel()
 {
     OpenSite   = new SimpleCommand(arg => GoToUrl("http://vladimirkhil.com/si/siquester"));
     OpenIcons  = new SimpleCommand(arg => GoToUrl("http://www.famfamfam.com/lab/icons/silk"));
     OpenIcons2 = new SimpleCommand(arg => GoToUrl("http://modernuiicons.com"));
 }
Esempio n. 16
0
 private void Init()
 {
     RemoveQuestionTypeParam = new SimpleCommand(RemoveQuestionTypeParam_Executed);
 }