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();
        }
Exemplo n.º 2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                var viewModel = new CreateJournalViewModel();
                var view      = new CreateJournalView();

                viewModel.SetDocumentationViewModel(view.DocumentationViewModel);
                view.DataContext = viewModel;

                var dialog = new WpfDialog(view);
                dialog.ShowDialog();

                if (dialog.DialogResult == true)
                {
                    var application = commandData.Application.Application;
                    var manager     = new FileCreationManager();
                    var settings    = viewModel.Setting;
                    settings.SetRevitDirectory(application);
                    var journalFiles = new List <string>();
                    var count        = 0;
                    foreach (var file in settings.DocumentationFiles)
                    {
                        settings.CurrentFile = file;
                        settings.FileCount   = ++count;
                        manager.CreateJournal(settings);
                    }

                    manager.CreateBatch(settings);
                    manager.CreateAddinFile(settings);
                    return(Result.Succeeded);
                }
                else
                {
                    return(Result.Cancelled);
                }
            }
            catch (Exception ex)
            {
                message = $"Error: {ex.Message}\nStack: {ex.StackTrace}";
                return(Result.Failed);
            }
        }
Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 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);
            }
        }
        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);
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
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");
                    }
                }
            }
        }
Exemplo n.º 9
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            var app = commandData.Application;

            if (app is null)
            {
                message = "No application object";
                return(Result.Failed);
            }

            var uiDoc = app.ActiveUIDocument;

            if (uiDoc is null)
            {
                message = "No opent UIDocument";
                return(Result.Failed);
            }

            var doc = uiDoc.Document;

            if (doc is null)
            {
                message = "No open Document";
                return(Result.Failed);
            }

            if (doc.IsFamilyDocument == false)
            {
                message = "No family Document";
                return(Result.Failed);
            }

            try
            {
                var viewModel = new DocumentationViewModel();
                var view      = new DocumentationView {
                    DataContext = viewModel
                };
                var dialog = new WpfDialog(view);

                var manager = new CreateJournalManager(commandData);
                if (manager.CanReadData == false)
                {
                    dialog.ShowDialog();
                }
                if (manager.CanReadData || dialog.DialogResult == true)
                {
                    var setting = viewModel.Settings;
                    var tran    = new Transaction(doc, "Family Documentation");
                    try
                    {
                        tran.Start();
                        manager.CreateDocumentation(doc, setting);
                        tran.Commit();
                        return(Result.Succeeded);
                    }
                    catch (Exception ex)
                    {
                        tran.RollBack();
                        throw ex;
                    }
                }
                else
                {
                    return(Result.Cancelled);
                }
            }
            catch (Exception ex)
            {
                message = $"Error: {ex.Message}\nStack: {ex.StackTrace}";
                return(Result.Failed);
            }
        }
Exemplo n.º 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;
            }
        }