private void Rename(LayoutSlot param) { var slot = GetCurrentSlot(); if (slot != null) { slot.IsInEditMode = true; } }
public ManageWindowLayoutsDialogViewModel(IEnumerable <Pair <string, Keys> > layouts) { Title = "Select a layout"; RenameCommand = new DelegateCommand <LayoutSlot>(Rename, CanRename, false); DeleteCommand = new DelegateCommand <LayoutSlot>(Delete, CanDelete, false); foreach (var layout in layouts) { var slot = new LayoutSlot(this, layout.First, layout.Second); slot.Renamed += SlotRenamed; Layouts.Add(slot); } LayoutView = CollectionViewSource.GetDefaultView(Layouts); }
public ManageWindowLayoutsDialogViewModel(IEnumerable<Pair<string, Keys>> layouts) { Title = "Select a layout"; RenameCommand = new DelegateCommand<LayoutSlot>(Rename, CanRename, false); DeleteCommand = new DelegateCommand<LayoutSlot>(Delete, CanDelete, false); foreach (var layout in layouts) { var slot = new LayoutSlot(this, layout.First, layout.Second); slot.Renamed += SlotRenamed; Layouts.Add(slot); } LayoutView = CollectionViewSource.GetDefaultView(Layouts); }
private void Delete(LayoutSlot param) { var selectedItem = GetCurrentSlot(); if (selectedItem != null) { var name = selectedItem.OldName; // Don't schedule a rename m_renamedLayouts.Remove(name); // Make sure to use the old name m_deletedLayouts.Add(name); Layouts.Remove(selectedItem); try { selectedItem.Image = null; if (m_screenshots.Contains(selectedItem)) { m_screenshots.Remove(selectedItem); } // Remove screenshot string path = Path.Combine( m_screenshotDirectory.FullName + Path.DirectorySeparatorChar, selectedItem.Name + WindowLayoutServiceCommandsBase.ScreenshotExtension); if (File.Exists(path)) { File.Delete(path); } } catch (Exception ex) { Outputs.WriteLine( OutputMessageType.Error, "Manage layouts: Exception " + "deleting screenshot: {0}", ex.Message); } } }
void SlotRenamed(object sender, EventArgs e) { var slot = sender as LayoutSlot; if (slot == null) { return; } // Back to original if not valid if (string.IsNullOrEmpty(slot.Name) || LayoutSlot.IsValidName(slot.Name) != null) { slot.Name = slot.OldName; } else { m_renamedLayouts[slot.OldName] = slot.Name; if (m_screenshots.Contains(slot)) { m_screenshots.Remove(slot); } // // Try and remove existing screenshot on disk // string sourceFile = Path.Combine( m_screenshotDirectory.FullName + Path.DirectorySeparatorChar, slot.OldName + WindowLayoutServiceCommandsBase.ScreenshotExtension); if (!File.Exists(sourceFile)) { return; } string destFile = Path.Combine( m_screenshotDirectory.FullName + Path.DirectorySeparatorChar, slot.Name + WindowLayoutServiceCommandsBase.ScreenshotExtension); if (!sourceFile.Equals(destFile)) { slot.Image = null; try { File.Copy(sourceFile, destFile); if (File.Exists(destFile)) { m_screenshots.Add(slot); } File.Delete(sourceFile); } catch (IOException) { } slot.Image = ImageUtil.CreateFromFile(destFile); } } }
private bool CanRename(LayoutSlot param) { var slot = GetCurrentSlot(); return(slot != null); }
private bool CanDelete(LayoutSlot param) { var slot = GetCurrentSlot(); return(slot != null && slot.Name != null); }
private void Rename(LayoutSlot param) { var slot = GetCurrentSlot(); if (slot != null) slot.IsInEditMode = true; }
private bool CanRename(LayoutSlot param) { var slot = GetCurrentSlot(); return slot != null; }
private void Delete(LayoutSlot param) { var selectedItem = GetCurrentSlot(); if (selectedItem != null) { var name = selectedItem.OldName; // Don't schedule a rename m_renamedLayouts.Remove(name); // Make sure to use the old name m_deletedLayouts.Add(name); Layouts.Remove(selectedItem); try { selectedItem.Image = null; if (m_screenshots.Contains(selectedItem)) m_screenshots.Remove(selectedItem); // Remove screenshot string path = Path.Combine( m_screenshotDirectory.FullName + Path.DirectorySeparatorChar, selectedItem.Name + WindowLayoutServiceCommandsBase.ScreenshotExtension); if (File.Exists(path)) File.Delete(path); } catch (Exception ex) { Outputs.WriteLine( OutputMessageType.Error, "Manage layouts: Exception " + "deleting screenshot: {0}", ex.Message); } } }
private bool CanDelete(LayoutSlot param) { var slot = GetCurrentSlot(); return slot != null && slot.Name != null; }