Esempio n. 1
0
        public Window CreateWindow(WindowEnum winEnum)
        {
            object vm;

            switch (winEnum)
            {
            case WindowEnum.StartWindow:
                vm = viewModels.FirstOrDefault <object>(x => x.GetType() == typeof(StartWindow_ViewModel));
                if (vm == null)
                {
                    vm = new StartWindow_ViewModel(core);
                    viewModels.Add(vm);
                }
                return(new StartWindow(vm as StartWindow_ViewModel));

            case WindowEnum.ProjectView:
                vm = viewModels.FirstOrDefault <object>(x => x.GetType() == typeof(ProjectViewer_ViewModel));
                if (vm == null)
                {
                    vm = new ProjectViewer_ViewModel(core);
                    viewModels.Add(vm);
                }
                return(new ProjectViewer(vm as ProjectViewer_ViewModel));

            case WindowEnum.NewFile:
                vm = viewModels.FirstOrDefault <object>(x => x.GetType() == typeof(NewFile_ViewModel));
                if (vm == null)
                {
                    vm = new NewFile_ViewModel(core);
                    viewModels.Add(vm);
                }
                return(new NewFile(vm as NewFile_ViewModel));

            case WindowEnum.Editor:
                vm = viewModels.FirstOrDefault <object>(x => x.GetType() == typeof(Editor_ViewModel));
                if (vm == null)
                {
                    vm = new Editor_ViewModel(core);
                    viewModels.Add(vm);
                }
                return(new Editor(vm as Editor_ViewModel));

            default:
                return(null);
            }
        }
Esempio n. 2
0
        public void StartUp(object sender, StartupEventArgs e)
        {
            const string CONFIG_PATH_NAME = "\\CMK WSDS Configs\\";
            const string CONFIG_FILE_NAME = "config.xml";

            var tempPath       = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + CONFIG_PATH_NAME;
            var DEFAULT_CONFIG = $"<Config><Language>EN</Language><ProjectPath>{tempPath}\\CMK WSDS Projects\\</ProjectPath></Config>";

            try
            {
                if (!Directory.Exists(tempPath))
                {
                    Directory.CreateDirectory(tempPath);
                }
                XmlSerializer serializer     = new XmlSerializer(typeof(Config));
                var           configFilePath = tempPath + CONFIG_FILE_NAME;
                if (!File.Exists(configFilePath))
                {
                    File.WriteAllText(configFilePath, DEFAULT_CONFIG);
                }
                Config config;
                using (var stream = File.Open(configFilePath, FileMode.Open))
                {
                    config = serializer.Deserialize(stream) as Config;
                }
                var translationService = new TranslationService();
                translationService.Initialize(config.Language);
                var projectLoader  = new ProjectLoader(config);
                var templateFunnel = new TemplateFunnel();
                var core           = new Core(config, projectLoader, translationService, templateFunnel);

                var startWindow_vm = new StartWindow_ViewModel(core);
                var mainWindow     = new StartWindow(startWindow_vm);
                mainWindow.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR: " + ex);
            }
        }
Esempio n. 3
0
 public StartWindow(StartWindow_ViewModel vm)
 {
     InitializeComponent();
     this.DataContext = vm;
 }