コード例 #1
0
        public MainViewModel()
        {
            m_OutPut                         = new StringBuilder();
            CreateProgramCommand             = new RelayCommand(CreateProgram);
            OpenProgramCommand               = new RelayCommand(OpenProgram);
            SaveProgramCommand               = new RelayCommand(SaveProgram, o => ActiveDocument != null && ActiveDocument.IsDirty);
            BuildProgramCommand              = new RelayCommand(BuildProgram, o => SelectedProgram != null);
            ApplicationCloseCommand          = new RelayCommand(ApplicationClose);
            HelpCommand                      = new RelayCommand(ShowHelp);
            AboutCommand                     = new RelayCommand(ShowAbout);
            OpenProgramFromRecentListCommand = new RelayCommand(OpenProgramFromRecentList);
            SettingsCommand                  = new RelayCommand(OpenSettings);
            FormatCodeCommand                = new RelayCommand(FormatCode);
            FindAndReplaceCommand            = new RelayCommand(Replace);
            ClearOutPutCommand               = new RelayCommand(o =>
            {
                m_OutPut.Clear();
                OnPropertyChanged(nameof(OutPut));
            }, o => m_OutPut.Length > 0);

            QuickSearchCommand = new RelayCommand(o =>
            {
                ActiveDocument?.QuickSearchCommand.Execute(o);
            });

            m_DocumentHandler = DocumentHandler.DeSerialize() ?? new DocumentHandler();
            m_DocumentHandler.DocumentOpened += DocumentOpened;
            SelectedTheme = Themes[m_DocumentHandler.TvcStudioSettings.SelectedTheme];
            TraceEngine.Subscribe(this);
        }
コード例 #2
0
        public static void Serialize(DocumentHandler settings)
        {
            try
            {
                if (!Directory.Exists(SettingsDirectory))
                {
                    Directory.CreateDirectory(SettingsDirectory);
                }

                FileStream    fs = new FileStream(SettingsPath, FileMode.Create);
                XmlSerializer xs = new XmlSerializer(typeof(DocumentHandler));
                xs.Serialize(fs, settings);
            }
            catch (Exception e)
            {
                TraceEngine.TraceError($"{SettingsPath} kimentése sikertelen:{e.Message}");
            }
        }