public void Execute(object parameter)
        {
            CommonSaveFileDialog fd = new CommonSaveFileDialog("Select where to save the library set:");

            fd.Filters.Add(new CommonFileDialogFilter("WinLibrary Sets", "*.winLibraries"));
            if (fd.ShowDialog() == CommonFileDialogResult.OK)
            {
                // ensure file extension is included.
                string filePath = fd.FileName;
                if (!filePath.EndsWith(_fileExtension, StringComparison.CurrentCultureIgnoreCase))
                {
                    filePath = filePath + _fileExtension;
                }

                try
                {
                    _viewModel.Save(filePath);
                }
                catch (System.Exception ex)
                {
                    WpfDialog.WpfDialogOptions options = new WpfDialog.WpfDialogOptions();
                    options.DialogType = WpfDialog.DialogType.Error;
                    WpfDialog dialog = new WpfDialog("Win Library Tool",
                                                     String.Format("An error occurred trying to save libraries to:\n\n{0}\n\nError:{1}", filePath, ex.Message),
                                                     options);
                }
            }
        }
        public void Execute(object parameter)
        {
            LibraryPropertiesControl userControl = new LibraryPropertiesControl(_viewModel.CurrentLibrary);

            WpfDialog.WpfDialogOptions options = new WpfDialog.WpfDialogOptions();
            options.DialogType        = WpfDialog.DialogType.Information;
            options.PossibleResponses = new WpfDialog.UserResponses(new string[] { "Close" }, 0);
            options.CustomContent     = userControl;
            options.TitleBarIcon      = ((Window)parameter).Icon;

            WpfDialog dialog = new WpfDialog("Edit library", "You can add local and network folders to this library.", options);

            dialog.Owner = (Window)parameter;
            dialog.ShowDialog();
        }
示例#3
0
        public void Execute(object parameter)
        {
            bool created   = false;
            bool cancelled = false;

            while (!cancelled && !created)
            {
                UserInputControl           userControl = new UserInputControl("Library name:", "");
                WpfDialog.WpfDialogOptions options     = new WpfDialog.WpfDialogOptions();
                options.DialogType        = WpfDialog.DialogType.Question;
                options.PossibleResponses = new WpfDialog.UserResponses(new string[] { "Create", "Cancel" }, 0);
                options.CustomContent     = userControl;
                options.TitleBarIcon      = ((Window)parameter).Icon;

                WpfDialog dialog = new WpfDialog(Helpers.AssemblyProperties.AssemblyTitle, "Enter the name of the new library.", options);
                dialog.Owner = (Window)parameter;
                dialog.ShowDialog();

                if (dialog.UserResponse.Equals("Create", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (userControl.InputText.Length > 0)
                    {
                        _viewModel.CreateLibrary(userControl.InputText);
                        created = true;
                    }
                    else
                    {
                        WpfDialog.WpfDialogOptions errorOptions = new WpfDialog.WpfDialogOptions();
                        errorOptions.DialogType   = WpfDialog.DialogType.Error;
                        errorOptions.TitleBarIcon = ((Window)parameter).Icon;

                        WpfDialog errorDialog = new WpfDialog(Helpers.AssemblyProperties.AssemblyTitle, "You must enter a name for the new library.", errorOptions);
                        errorDialog.Owner = (Window)parameter;
                        errorDialog.ShowDialog();
                    }
                }
                else
                {
                    cancelled = true;
                }
            }
        }
示例#4
0
        public void Execute(object parameter)
        {
            WpfDialog.WpfDialogOptions options = new WpfDialog.WpfDialogOptions();
            options.DialogType        = WpfDialog.DialogType.Information;
            options.PossibleResponses = new WpfDialog.UserResponses(new string[] { "OK", "Cancel" }, 1);
            options.TitleBarIcon      = ((Window)parameter).Icon;
            LibraryIconSelectorControl selectorControl = new LibraryIconSelectorControl(_viewModel, (Window)parameter);

            options.CustomContent = selectorControl;

            WpfDialog dialog = new WpfDialog(Helpers.AssemblyProperties.AssemblyTitle, "Choose an icon for this library.", options);

            dialog.Owner = (Window)parameter;
            dialog.ShowDialog();

            if (dialog.UserResponse.Equals("OK", StringComparison.CurrentCultureIgnoreCase))
            {
                _viewModel.SetIcon(selectorControl.CurrentIconReference);
            }
        }
        public void Execute(object parameter)
        {
            CommonOpenFileDialog fd = new CommonOpenFileDialog("Select library set to load:");

            fd.Filters.Add(new CommonFileDialogFilter("WinLibrary Sets", "*.winLibraries;*.win7Libraries"));
            if (fd.ShowDialog() == CommonFileDialogResult.OK)
            {
                try
                {
                    _viewModel.Load(fd.FileName);
                }
                catch (System.Exception ex)
                {
                    WpfDialog.WpfDialogOptions options = new WpfDialog.WpfDialogOptions();
                    options.DialogType = WpfDialog.DialogType.Error;
                    WpfDialog dialog = new WpfDialog("Win Library Tool",
                                                     String.Format("An error occurred trying to load libraries from:\n\n{0}\n\nError:{1}", fd.FileName, ex.Message),
                                                     options);
                }
            }
        }
        private void AddLibraries()
        {
            foreach (WinLibrary library in WinLibrarySetStorage.Libraries)
            {
                string iconPath = library.IconReference.ModuleName;
                if (Path.IsPathRooted(iconPath))
                {
                    if (!File.Exists(iconPath))
                    {
                        var options = new WpfDialog.WpfDialogOptions();
                        options.DialogType = WpfDialog.DialogType.Error;
                        var dialog = new WpfDialog("Windows Library Tool", String.Format("The icon for library '{0}' cannot be found, reverting to default icon.  Path:\n\n{1}", library.Name, iconPath), options);
                        dialog.ShowDialog();
                        library.IconReference = new IconReference(WinLibrary.DefaultIconReference);
                    }
                }

                LibraryViewModel viewModel = new LibraryViewModel(library, _userInterface);
                viewModel.IsExpanded = true;
                _libraries.Add(viewModel);
            }
        }
        public void Execute(object parameter)
        {
            CommonOpenFileDialog fd = new CommonOpenFileDialog("Select folder(s) to include:");

            fd.IsFolderPicker = true;
            fd.Multiselect    = true;

            bool cancelled = false;
            bool succeeded = false;

            do
            {
                if (fd.ShowDialog() == CommonFileDialogResult.OK)
                {
                    foreach (var folderPath in fd.FileNames)
                    {
                        if (!_viewModel.IncludeFolder(folderPath))
                        {
                            WpfDialog.WpfDialogOptions options = new WpfDialog.WpfDialogOptions();
                            options.DialogType   = WpfDialog.DialogType.Error;
                            options.TitleBarIcon = ((Window)parameter).Icon;

                            WpfDialog dialog = new WpfDialog(Helpers.AssemblyProperties.AssemblyTitle, String.Format("The folder '{0}' already exists in this library.\n\nPlease choose another.", folderPath), options);
                            dialog.Owner = (Window)parameter;
                            dialog.ShowDialog();
                            return;
                        }
                    }

                    succeeded = true;
                }
                else
                {
                    cancelled = true;
                }
            } while (!cancelled && !succeeded);
        }
        public void Execute(object parameter)
        {
            TextBlock infoText = new TextBlock();

            infoText.Inlines.Add("This tool provides the following features not available in Windows:\n\n" +
                                 "      - Add network (UNC or mapped drive) and any other un-indexed folders to libraries.\n" +
                                 "      - Backup library configuration, such that a saved set of libraries can be instantly\n" +
                                 "        restored at any point.\n" +
                                 "      - Create a mirror of all libraries (using symbolic links) in [SystemDrive]:\\libraries.\n" +
                                 "      - Change a library's icon.\n\n");

            Run       webAddress = new Run("http://zornsoftware.codenature.info");
            Hyperlink link       = new Hyperlink(webAddress);

            link.NavigateUri = new Uri(webAddress.Text);
            link.Click      += new RoutedEventHandler(link_Click);
            infoText.Inlines.Add(link);

            WpfDialog.WpfDialogOptions options = new WpfDialog.WpfDialogOptions();
            options.DialogType        = WpfDialog.DialogType.Information;
            options.DialogIcon        = ((Window)parameter).Icon;
            options.PossibleResponses = new WpfDialog.UserResponses(new string[] { "OK" });
            options.TitleBarIcon      = ((Window)parameter).Icon;
            options.CustomContent     = infoText;

            WpfDialog dialog = new WpfDialog(
                Helpers.AssemblyProperties.AssemblyTitle,
                String.Format("{0} v{1}\n{2}\n{3}",
                              Helpers.AssemblyProperties.AssemblyTitle,
                              Helpers.AssemblyProperties.AssemblyVersion,
                              Helpers.AssemblyProperties.AssemblyDescription,
                              Helpers.AssemblyProperties.AssemblyCopyright),
                options);

            dialog.Owner = (Window)parameter;
            dialog.ShowDialog();
        }
示例#9
0
        public void Execute(object parameter)
        {
            CheckBox mirrorCheckBox = new CheckBox();
            string   mirrorRoot     = String.Format("{0}libraries", Environment.SystemDirectory.Substring(0, 3));

            mirrorCheckBox.Content = String.Format("Create a mirror of all libraries (using symbolic links) in {0}", mirrorRoot);
            if (System.IO.Directory.Exists(mirrorRoot))
            {
                mirrorCheckBox.Content += "\n(Existing directory will be erased.)";
            }
            mirrorCheckBox.IsChecked = false;

            WpfDialog.WpfDialogOptions options = new WpfDialog.WpfDialogOptions();
            options.DialogType        = WpfDialog.DialogType.Warning;
            options.CustomContent     = mirrorCheckBox;
            options.PossibleResponses = new WpfDialog.UserResponses(new string[] { "Proceed", "Cancel" }, 1);
            options.TitleBarIcon      = ((Window)parameter).Icon;

            WpfDialog dialog = new WpfDialog(Helpers.AssemblyProperties.AssemblyTitle, "Your existing library structure will now be backed-up, and the\nones defined in this tool will be created.\n\nIf any problem occurs during creation of the new libraries,\nthe backed-up copies will be restored.\n", options);

            dialog.Owner = (Window)parameter;
            dialog.ShowDialog();

            if (dialog.UserResponse.Equals("Proceed", StringComparison.CurrentCultureIgnoreCase))
            {
                bool appliedOK = false;

                try
                {
                    Mouse.OverrideCursor = Cursors.Wait;
                    _viewModel.ApplyChanges(mirrorCheckBox.IsChecked.Value);
                    Mouse.OverrideCursor = Cursors.Arrow;
                    appliedOK            = true;
                }
                catch (System.Exception ex)
                {
                    Mouse.OverrideCursor = Cursors.Arrow;                       // revert cursor

                    WpfDialog.WpfDialogOptions errorOptions = new WpfDialog.WpfDialogOptions();
                    errorOptions.DialogType        = WpfDialog.DialogType.Error;
                    errorOptions.PossibleResponses = new WpfDialog.UserResponses(new string[] { "Bugger" });
                    errorOptions.TitleBarIcon      = ((Window)parameter).Icon;

                    WpfDialog resultDialog = new WpfDialog(Helpers.AssemblyProperties.AssemblyTitle, "An error occurred whilst configuring the libraries.\n\n" + ex.Message, errorOptions);
                    resultDialog.Owner = (Window)parameter;
                    resultDialog.ShowDialog();
                }

                if (appliedOK)
                {
                    CheckBox openCheckBox = new CheckBox();
                    openCheckBox.Content   = "Show me in Windows Explorer";
                    openCheckBox.IsChecked = true;

                    WpfDialog.WpfDialogOptions successOptions = new WpfDialog.WpfDialogOptions();
                    successOptions.DialogType        = WpfDialog.DialogType.Information;
                    successOptions.PossibleResponses = new WpfDialog.UserResponses(new string[] { "Great" });
                    successOptions.CustomContent     = openCheckBox;
                    successOptions.TitleBarIcon      = ((Window)parameter).Icon;

                    WpfDialog resultDialog = new WpfDialog(Helpers.AssemblyProperties.AssemblyTitle, "Your new libraries have been created successfully.\n", successOptions);
                    resultDialog.Owner = (Window)parameter;
                    resultDialog.ShowDialog();

                    if (openCheckBox.IsChecked.Value)
                    {
                        Process.Start("explorer");
                    }
                }
            }
        }
示例#10
0
        public void AddIcons(string filePath)
        {
            int iconCount = IconHelper.GetIconCount(filePath);

            if (iconCount == 0)
            {
                WpfDialog.WpfDialogOptions errorOptions = new WpfDialog.WpfDialogOptions();
                errorOptions.DialogType   = WpfDialog.DialogType.Error;
                errorOptions.TitleBarIcon = _userInterface.Icon;

                WpfDialog errorDialog = new WpfDialog(
                    Helpers.AssemblyProperties.AssemblyTitle,
                    String.Format("No icons were found in '{0}'.", System.IO.Path.GetFileName(filePath)),
                    errorOptions);

                errorDialog.Owner = _userInterface;
                errorDialog.ShowDialog();
            }
            else
            {
                Mouse.OverrideCursor = Cursors.Wait;
                int errorCount = 0;

                for (int index = 0; index < iconCount; index++)
                {
                    IconReference iconRef = new IconReference(filePath, index);
                    AvailableIcon icon    = null;

                    try
                    {
                        icon = new AvailableIcon(iconRef);
                    }
                    catch (Exception)
                    {
                        errorCount++;
                    }

                    if (icon != null)
                    {
                        _availableIcons.Add(icon);
                    }
                }

                if (errorCount > 0)
                {
                    WpfDialog.WpfDialogOptions errorOptions = new WpfDialog.WpfDialogOptions();
                    errorOptions.DialogType   = WpfDialog.DialogType.Error;
                    errorOptions.TitleBarIcon = _userInterface.Icon;

                    WpfDialog errorDialog = new WpfDialog(
                        Helpers.AssemblyProperties.AssemblyTitle,
                        String.Format("{0} icon(s) were not added from '{1}', possibly because no 32x32 size was found.", errorCount, System.IO.Path.GetFileName(filePath)),
                        errorOptions);

                    errorDialog.Owner = _userInterface;
                    errorDialog.ShowDialog();
                }

                Mouse.OverrideCursor = Cursors.Arrow;
            }
        }