Пример #1
0
        private void Rename(LayoutSlot param)
        {
            var slot = GetCurrentSlot();

            if (slot != null)
            {
                slot.IsInEditMode = true;
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
                }
            }
        }
Пример #5
0
        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);
                }
            }
        }
Пример #6
0
        private bool CanRename(LayoutSlot param)
        {
            var slot = GetCurrentSlot();

            return(slot != null);
        }
Пример #7
0
        private bool CanDelete(LayoutSlot param)
        {
            var slot = GetCurrentSlot();

            return(slot != null && slot.Name != null);
        }
Пример #8
0
 private void Rename(LayoutSlot param)
 {
     var slot = GetCurrentSlot();
     if (slot != null)
         slot.IsInEditMode = true;
 }
Пример #9
0
 private bool CanRename(LayoutSlot param)
 {
     var slot = GetCurrentSlot();
     return slot != null;
 }
Пример #10
0
        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);
                }
            }
        }
Пример #11
0
 private bool CanDelete(LayoutSlot param)
 {
     var slot = GetCurrentSlot();
     return slot != null && slot.Name != null;
 }