示例#1
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (e.Parameter is GeneralPageViewModel viewModel)
     {
         ViewModel = viewModel;
     }
 }
 public SettingsViewModel(ISettingsService settingsService, IDefaultValueProvider defaultValueProvider, IDialogService dialogService, ITrayProcessCommunicationService trayProcessCommunicationService, IThemeParserFactory themeParserFactory)
 {
     KeyBindings = new KeyBindingsPageViewModel(settingsService, dialogService, defaultValueProvider, trayProcessCommunicationService);
     General     = new GeneralPageViewModel(settingsService, dialogService, defaultValueProvider);
     Shell       = new ProfilesPageViewModel(settingsService, dialogService, defaultValueProvider);
     Terminal    = new TerminalPageViewModel(settingsService, dialogService, defaultValueProvider);
     Themes      = new ThemesPageViewModel(settingsService, dialogService, defaultValueProvider, themeParserFactory);
 }
示例#3
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (e.Parameter is GeneralPageViewModel viewModel)
     {
         ViewModel = viewModel;
         // ReSharper disable once AssignmentIsFullyDiscarded
         _ = ViewModel.OnNavigatedToAsync();
     }
 }
示例#4
0
 public SettingsViewModel(ISettingsService settingsService, IDefaultValueProvider defaultValueProvider, IDialogService dialogService,
                          ITrayProcessCommunicationService trayProcessCommunicationService, IThemeParserFactory themeParserFactory, ISystemFontService systemFontService, IFileSystemService fileSystemService, IStartupTaskService startupTaskService)
 {
     KeyBindings = new KeyBindingsPageViewModel(settingsService, dialogService, defaultValueProvider, trayProcessCommunicationService);
     General     = new GeneralPageViewModel(settingsService, dialogService, defaultValueProvider, startupTaskService);
     Shell       = new ProfilesPageViewModel(settingsService, dialogService, defaultValueProvider, fileSystemService);
     Terminal    = new TerminalPageViewModel(settingsService, dialogService, defaultValueProvider, systemFontService);
     Themes      = new ThemesPageViewModel(settingsService, dialogService, defaultValueProvider, themeParserFactory, fileSystemService);
     Mouse       = new MousePageViewModel(settingsService, dialogService, defaultValueProvider);
 }
示例#5
0
        public async Task <IActionResult> InsertGeneralPageConfirm(GeneralPageViewModel model)
        {
            string nvm;

            if (ModelState.IsValid == false)
            {
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Wrong_Values, contentRootPath);
                return(RedirectToAction("ShowGeneralPage", new { notification = nvm }));
            }
            GeneralPage generalPage = new GeneralPage()
            {
                Title        = model.Title,
                Description  = model.Description,
                RegdDateTime = DateTime.Now,
                ContentHtml  = model.ContentHtml,
                ShowOrder    = model.ShowOrder,
                Status       = model.Status
            };

            try
            {
                //Save File in wwwroot
                string folderPath = "";
                string savePath   = "";
                folderPath = configuration.GetSection("DefaultPaths").GetSection("PagesFiles").Value;
                savePath   = await FileManager.ReadAndSaveFile(contentRootPath, folderPath, model.MainImage);

                generalPage.MainImagePath = savePath;
                if (model.MovieFile != null)
                {
                    folderPath = configuration.GetSection("DefaultPaths").GetSection("PagesFiles").Value;
                    savePath   = await FileManager.ReadAndSaveFile(contentRootPath, folderPath, model.MovieFile);

                    generalPage.MoviePath = savePath;
                }
                if (model.DocumentFile != null)
                {
                    folderPath = configuration.GetSection("DefaultPaths").GetSection("PagesFiles").Value;
                    savePath   = await FileManager.ReadAndSaveFile(contentRootPath, folderPath, model.DocumentFile);

                    generalPage.DocumentPath = savePath;
                }
                dbGeneralPage.Insert(generalPage);
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Success_Insert, contentRootPath);
                return(RedirectToAction("ShowGeneralPage", new { notification = nvm }));
            }
            catch (Exception)
            {
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Insert, contentRootPath);
                return(RedirectToAction("ShowGeneralPage", new { notification = nvm }));
            }
        }
 public SettingsViewModel(ISettingsService settingsService, IDefaultValueProvider defaultValueProvider, IDialogService dialogService,
                          ITrayProcessCommunicationService trayProcessCommunicationService, IThemeParserFactory themeParserFactory, ISystemFontService systemFontService,
                          IFileSystemService fileSystemService, IStartupTaskService startupTaskService, IUpdateService updateService, IApplicationView applicationView, IApplicationLanguageService applicationLanguageService)
 {
     About       = new AboutPageViewModel(settingsService, updateService, applicationView);
     KeyBindings = new KeyBindingsPageViewModel(settingsService, dialogService, defaultValueProvider, trayProcessCommunicationService);
     General     = new GeneralPageViewModel(settingsService, dialogService, defaultValueProvider, startupTaskService, applicationLanguageService);
     Profiles    = new ProfilesPageViewModel(settingsService, dialogService, defaultValueProvider, fileSystemService, applicationView);
     Terminal    = new TerminalPageViewModel(settingsService, dialogService, defaultValueProvider, systemFontService);
     Themes      = new ThemesPageViewModel(settingsService, dialogService, defaultValueProvider, themeParserFactory, fileSystemService);
     Mouse       = new MousePageViewModel(settingsService, dialogService, defaultValueProvider);
     SshProfiles = new SshProfilesPageViewModel(settingsService, dialogService, fileSystemService, applicationView, defaultValueProvider, trayProcessCommunicationService);
 }
 public SettingsViewModel(ISettingsService settingsService, IDefaultValueProvider defaultValueProvider, IDialogService dialogService,
                          ITrayProcessCommunicationService trayProcessCommunicationService, IThemeParserFactory themeParserFactory, ISystemFontService systemFontService,
                          IFileSystemService fileSystemService, IStartupTaskService startupTaskService, IApplicationView applicationView,
                          IApplicationLanguageService applicationLanguageService, ApplicationDataContainers containers,
                          IImageFileSystemService imageFileSystemService)
 {
     KeyBindings = new KeyBindingsPageViewModel(settingsService, dialogService, trayProcessCommunicationService);
     General     = new GeneralPageViewModel(settingsService, dialogService, defaultValueProvider, startupTaskService, applicationLanguageService, trayProcessCommunicationService, fileSystemService);
     Profiles    = new ProfilesPageViewModel(settingsService, dialogService, defaultValueProvider, fileSystemService, applicationView);
     Terminal    = new TerminalPageViewModel(settingsService, dialogService, defaultValueProvider, systemFontService);
     Themes      = new ThemesPageViewModel(settingsService, dialogService, defaultValueProvider, themeParserFactory, fileSystemService, imageFileSystemService);
     Mouse       = new MousePageViewModel(settingsService, dialogService, defaultValueProvider);
     SshProfiles = new SshProfilesPageViewModel(settingsService, dialogService, fileSystemService,
                                                applicationView, trayProcessCommunicationService, containers.HistoryContainer);
 }
示例#8
0
        public IActionResult InsertAboutConfirm(GeneralPageViewModel model)
        {
            string nvm;

            if (ModelState.IsValid == false)
            {
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Wrong_Values, contentRootPath);
                return(RedirectToAction("InsertPost", new { notification = nvm }));
            }

            byte[] b      = null;
            var    entity = dbGeneralPage.GetAll().Where(e => e.Title == "AboutUs").FirstOrDefault();

            if (entity != null)
            {
                entity.ContentHtml = model.ContentHtml;
                entity.Summary     = model.Summary;
                entity.Status      = model.Status;
            }
            if (model.MainImage != null)
            {
                b = new byte[model.MainImage.Length];
                model.MainImage.OpenReadStream().Read(b, 0, (int)model.MainImage.Length);
                entity.MainImage = b;
            }
            try
            {
                dbGeneralPage.Update(entity);
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Success_Update, contentRootPath);
                return(RedirectToAction("Index", new { notification = nvm }));
            }
            catch (Exception)
            {
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Operation, contentRootPath);
                return(RedirectToAction("Index", new { notification = nvm }));
            }
        }
示例#9
0
        public async Task <IActionResult> EditGeneralPageConfirm(GeneralPageViewModel model)
        {
            string nvm;

            if (ModelState.IsValid == false)
            {
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Wrong_Values, contentRootPath);
                return(RedirectToAction("ShowGeneralPage", new { notification = nvm }));
            }
            var entity = dbGeneralPage.FindById(model.Id);

            if (entity != null)
            {
                entity.Title        = model.Title;
                entity.Description  = model.Description;
                entity.RegdDateTime = DateTime.Now;
                entity.ContentHtml  = model.ContentHtml;
                entity.ShowOrder    = model.ShowOrder;
                entity.Status       = model.Status;
            }
            //Delete Old Image then Insert New Image
            string folderPath;
            string savePath;

            if (model.MainImage != null)
            {
                if (entity.MainImagePath != null)
                {
                    bool imgDel = FileManager.DeleteFile(contentRootPath, entity.MainImagePath);
                }
                folderPath = configuration.GetSection("DefaultPaths").GetSection("PagesFiles").Value;
                savePath   = await FileManager.ReadAndSaveFile(contentRootPath, folderPath, model.MainImage);

                entity.MainImagePath = savePath;
            }
            if (model.MovieFile != null)
            {
                if (entity.MoviePath != null)
                {
                    bool FileDel = FileManager.DeleteFile(contentRootPath, entity.MoviePath);
                }
                folderPath = configuration.GetSection("DefaultPaths").GetSection("PagesFiles").Value;
                savePath   = await FileManager.ReadAndSaveFile(contentRootPath, folderPath, model.MovieFile);

                entity.MoviePath = savePath;
            }
            if (model.DocumentFile != null)
            {
                if (entity.DocumentPath != null)
                {
                    bool FileDel = FileManager.DeleteFile(contentRootPath, entity.DocumentPath);
                }
                folderPath = configuration.GetSection("DefaultPaths").GetSection("PagesFiles").Value;
                savePath   = await FileManager.ReadAndSaveFile(contentRootPath, folderPath, model.DocumentFile);

                entity.DocumentPath = savePath;
            }
            try
            {
                dbGeneralPage.Update(entity);
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Success_Update, contentRootPath);
                return(RedirectToAction("ShowGeneralPage", new { notification = nvm }));
            }
            catch (Exception)
            {
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Update, contentRootPath);
                return(RedirectToAction("ShowGeneralPage", new { notification = nvm }));
            }
        }