private void OnRegistImgCommand(ShortcutModel model) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "img file (*.jpg, *.png)|*.jpg;*.png|icon file (*.ico)|*.ico"; ofd.Title = "아이콘에 등록할 이미지를 선택해주세요."; var result = ofd.ShowDialog(); if (result != DialogResult.OK) { return; } string base64Str = string.Empty; using (MemoryStream ms = new MemoryStream()) { using (var bitmap = new Bitmap(ofd.FileName)) { bitmap.Save(ms, ImageFormat.Jpeg); base64Str = Convert.ToBase64String(ms.GetBuffer()); } } model.IconBase64 = base64Str; }
public static void ShowInteractiveToast(ToastModel toastModel, string appId) { var toastXml = new ToastXml(toastModel); // Register shortcut var shortcut = new ShortcutModel { ShortcutFileName = appId + ".lnk", ShortcutTargetFilePath = Assembly.GetExecutingAssembly().Location, AppId = appId, ActivatorId = typeof(NotificationActivator).GUID }; ShortcutService.CheckInstallShortcut(shortcut); // Create Xml document var document = new XmlDocument(); document.LoadXml(toastXml.GetInteractiveToastXml()); // Send toast var toast = new ToastNotification(document); ToastNotificationManager.CreateToastNotifier(appId).Show(toast); }
private void OnOpen(ShortcutModel model) { try { switch (model.ExecuteType) { case ExecuteTypes.Chrome: Process.Start("chrome", model.FilePath); break; case ExecuteTypes.IE: Process.Start("iexplore", model.FilePath); break; case ExecuteTypes.EXE: Process.Start(model.FilePath); break; case ExecuteTypes.Edge: Process.Start("msedge", model.FilePath); break; } } catch (Exception e) { MessageBox.Show(e.Message, "오류", MessageBoxButton.OK); } }
public async Task <IActionResult> Update(ShortcutModel model) { var shortcut = new ShortcutModifyRequest { Description = model.Description, Name = model.Name, Icon = model.Icon, TypeId = (int)model.TypeId, Url = model.Url, Id = model.Id, Order = model.Order, UpdatedById = LoggedUserId }; if (shortcut.Id <= 0) { return(RedirectToErrorPage()); } var exist = await _shortcutService.FindAsync(new IdRequestFilter <int> { Id = model.Id, CanGetInactived = true }); if (exist == null) { return(RedirectToErrorPage()); } await _shortcutService.UpdateAsync(shortcut); return(RedirectToAction(nameof(Detail), new { id = shortcut.Id })); }
private void OnRegistFilePathCommand(ShortcutModel model) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "all files (*.*)|*.*"; ofd.Title = "등록할 파일을 선택해주세요."; var result = ofd.ShowDialog(); if (result != DialogResult.OK) { return; } model.FilePath = ofd.FileName; }
public async Task <IActionResult> Update(int id) { var shortcut = await _shortcutService.FindAsync(new IdRequestFilter <int> { Id = id, CanGetInactived = true }); var model = new ShortcutModel { Description = shortcut.Description, Name = shortcut.Name, Icon = shortcut.Icon, TypeId = (ShortcutType)shortcut.TypeId, Url = shortcut.Url, Id = shortcut.Id, Order = shortcut.Order, StatusId = (ShortcutStatus)shortcut.StatusId }; return(View(model)); }
public async Task <IActionResult> Detail(int id) { if (id <= 0) { return(RedirectToNotFoundPage()); } try { var shortcut = await _shortcutService.FindAsync(new IdRequestFilter <int> { Id = id, CanGetInactived = true }); if (shortcut == null) { return(RedirectToNotFoundPage()); } var model = new ShortcutModel { Description = shortcut.Description, Name = shortcut.Name, Icon = shortcut.Icon, TypeId = (ShortcutType)shortcut.TypeId, Url = shortcut.Url, Id = shortcut.Id, Order = shortcut.Order, StatusId = (ShortcutStatus)shortcut.StatusId }; return(View(model)); } catch (Exception) { return(RedirectToErrorPage()); } }
/// <summary> /// Checks and installs a shortcut file in Start menu. /// </summary> /// <param name="shortcutModel">Toast shortcutModel</param> public static void CheckInstallShortcut(ShortcutModel shortcutModel) { var shortcutFilePath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), // Not CommonStartMenu "Programs", shortcutModel.ShortcutFileName); var shortcut = new Shortcut(); if (!shortcut.CheckShortcut( shortcutPath: shortcutFilePath, targetPath: shortcutModel.ShortcutTargetFilePath, arguments: shortcutModel.ShortcutArguments, comment: shortcutModel.ShortcutComment, workingFolder: shortcutModel.ShortcutWorkingFolder, windowState: shortcutModel.ShortcutWindowState, iconPath: shortcutModel.ShortcutIconFilePath, appId: shortcutModel.AppId, activatorId: shortcutModel.ActivatorId)) { shortcut.InstallShortcut( shortcutPath: shortcutFilePath, targetPath: shortcutModel.ShortcutTargetFilePath, arguments: shortcutModel.ShortcutArguments, comment: shortcutModel.ShortcutComment, workingFolder: shortcutModel.ShortcutWorkingFolder, windowState: shortcutModel.ShortcutWindowState, iconPath: shortcutModel.ShortcutIconFilePath, appId: shortcutModel.AppId, activatorId: shortcutModel.ActivatorId); System.Threading.Thread.Sleep(_waitingDuration); //await Task.Delay(_waitingDuration); } }
public async Task <IActionResult> Create(ShortcutModel model) { var shortcut = new ShortcutModifyRequest { Description = model.Description, Name = model.Name, Icon = model.Icon, TypeId = (int)model.TypeId, Url = model.Url, Order = model.Order, UpdatedById = LoggedUserId, CreatedById = LoggedUserId }; var exist = await _shortcutService.FindByNameAsync(model.Name); if (exist != null) { return(RedirectToErrorPage()); } var id = await _shortcutService.CreateAsync(shortcut); return(RedirectToAction(nameof(Detail), new { id })); }
public IActionResult Create() { var model = new ShortcutModel(); return(View(model)); }
private void OnDelteShortcutCommand(ShortcutModel obj) { Shortcuts.Remove(obj); IsModified = true; }