예제 #1
0
        public override void Execute(object parameter)
        {
            var context = parameter as ContentEditorFieldContext;

            if (context == null)
            {
                return;
            }

            var fieldUri = context.Field.FieldUris.FirstOrDefault();

            if (fieldUri == null)
            {
                return;
            }

            var dialog = new SelectFileDialog
            {
                Site = fieldUri.DatabaseUri.Site
            };

            if (!dialog.ShowDialog())
            {
                return;
            }

            var control = context.Field.Control;

            if (control != null)
            {
                control.SetValue(dialog.SelectedFilePath.Replace("\\", "/"));
            }
        }
예제 #2
0
        public override object EditValue(ITypeDescriptorContext context, [CanBeNull] IServiceProvider provider, object value)
        {
            Assert.ArgumentNotNull(context, nameof(context));

            var renderingItem = context.Instance as IItem;

            if (renderingItem == null)
            {
                // ReSharper disable once AssignNullToNotNullAttribute
                return(value);
            }

            var dialog = new SelectFileDialog
            {
                Site = renderingItem.ItemUri.Site
            };

            if (!dialog.ShowDialog())
            {
                // ReSharper disable once AssignNullToNotNullAttribute
                return(value);
            }

            return(dialog.SelectedFilePath.Replace("\\", "/"));
        }
예제 #3
0
        /// <summary> Opens the template selection window. </summary>
        /// <returns></returns>
        protected override IQOpResult <string> OpenEditor(string defaultValue, IQVarElementTarget target)
        {
            // other_files_folder\eSCRIBE
            string otherFilesEscribe = EscribeOperations.EscribeRoot;

            // other_files_folder\eSCRIBE\<TemplatesRoot>
            // default TemplatesRoot to the eScribe templates, i.e. 'WKGroup'
            string templatesRoot = !String.IsNullOrEmpty(TemplatesRoot)
                                        ? TemplatesRoot
                                        : EscribeConstants.EscribeTemplatesRoot;

            string otherFilesEscribeTemplatesRoot = Path.Combine(otherFilesEscribe, templatesRoot);

            string selectedTemplate = SelectFileDialog.IsValidTemplate(defaultValue)
                                                ? Path.Combine(otherFilesEscribe, defaultValue)
                                                : defaultValue;

            var editor = new SelectFileDialog(otherFilesEscribeTemplatesRoot, String.Empty, selectedTemplate);

            if (editor.ShowDialog() != DialogResult.OK)
            {
                return new IQOpResult <string> {
                           Result = OpResultEnum.Cancelled
                }
            }
            ;

            // trim the 'other_files_folder\eSCRIBE\' part
            selectedTemplate = SelectFileDialog.TrimTemplateRoot(otherFilesEscribe, editor.SelectedFile);
            return(new IQOpResult <string> {
                Result = OpResultEnum.Completed, Value = selectedTemplate
            });
        }
    }
예제 #4
0
 private void Button_Click(object sender, EventArgs e)
 {
     if (SelectFileDialog.ShowDialog() == DialogResult.OK)
     {
         FilePath         = SelectFileDialog.FileName;
         txtFilePath.Text = FilePath;
         RunCallBack();
     }
 }
예제 #5
0
        public void AddFileProperty([NotNull] string text, [NotNull] string propertyName)
        {
            Assert.ArgumentNotNull(text, nameof(text));
            Assert.ArgumentNotNull(propertyName, nameof(propertyName));

            AddLabel(text);

            var property = GetProperty(propertyName);
            var binding  = new Binding(property.Name);

            var grid = new Grid();

            grid.RowDefinitions.Add(new RowDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition
            {
                Width = GridLength.Auto
            });

            var textBox = new TextBox();

            textBox.SetBinding(TextBox.TextProperty, binding);
            textBox.VerticalAlignment = VerticalAlignment.Center;
            grid.Children.Add(textBox);
            textBox.SetValue(Grid.ColumnProperty, 0);

            var button = new Button
            {
                Content = "Browse",
                Width   = 75,
                Height  = 23,
                Margin  = new Thickness(2, 0, 0, 0)
            };

            button.Click += delegate
            {
                var dialog = new SelectFileDialog
                {
                    Site = RenderingItem.ItemUri.Site
                };

                if (dialog.ShowDialog())
                {
                    textBox.Text = dialog.SelectedFilePath.Replace("\\", "/");
                }
            };

            grid.Children.Add(button);
            button.SetValue(Grid.ColumnProperty, 1);

            Grid.Children.Add(grid);

            bindings.Add(BindingOperations.GetBindingExpressionBase(textBox, TextBox.TextProperty));
        }
예제 #6
0
        private void CDImageSelect_Click(object sender, EventArgs e)
        {
            SelectFileDialog.Title           = "Extract From CD Image";
            SelectFileDialog.DefaultExt      = ".bin";
            SelectFileDialog.CheckFileExists = true;
            SelectFileDialog.Filter          = "CD Images (*.bin)|*.bin|All Files (*.*)|*.*";
            SelectFileDialog.FileName        = CDImageTextBox.Text;

            if (SelectFileDialog.ShowDialog() == DialogResult.OK)
            {
                CDImageTextBox.Text = SelectFileDialog.FileName;
            }
        }
예제 #7
0
        private void BinaryFileSelect_Click(object sender, EventArgs e)
        {
            SelectFileDialog.Title            = "Export Binary File";
            SelectFileDialog.DefaultExt       = ".dat";
            SelectFileDialog.CheckFileExists  = false;
            SelectFileDialog.OverwritePrompt  = true;
            SelectFileDialog.Filter           = "Binary Courses (*.dat)|*.dat|All Files (*.*)|*.*";
            SelectFileDialog.InitialDirectory = mMainForm.LocalSettings.LastPublishedBinaryFilePath;
            SelectFileDialog.FileName         = BinaryFileTextBox.Text;

            if (SelectFileDialog.ShowDialog() == DialogResult.OK)
            {
                BinaryFileTextBox.Text = SelectFileDialog.FileName;
            }
        }
        private void PresentViewViewModelOptions(List <ProjectItemAndType> docs)
        {
            var window = new SelectFileDialog();
            var vm     = new SelectFileDialogViewModel(docs, Container);

            window.DataContext = vm;

            var result = window.ShowDialog();

            if (result.GetValueOrDefault())
            {
                // Go to the selected project item.
                var win = vm.SelectedDocument.ProjectItem.Open();
                win.Visible = true;
                win.Activate();
            }
        }
        private void BrowseDestinationFolder([NotNull] object sender, [NotNull] RoutedEventArgs e)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(e, nameof(e));

            var dialog = new SelectFileDialog
            {
                Site = Site
            };

            if (!dialog.ShowDialog())
            {
                return;
            }

            DestinationTextBox.Text = dialog.SelectedFilePath.TrimStart('\\') + "\\";
        }
예제 #10
0
        private void Browse([NotNull] object sender, [NotNull] RoutedEventArgs e)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(e, nameof(e));

            var dialog = new SelectFileDialog
            {
                Site = Rendering.ItemUri.Site
            };

            if (!dialog.ShowDialog())
            {
                return;
            }

            var fileName = dialog.SelectedFilePath.Replace("\\", "/");

            Rendering.SetParameterValue("PageCodeScriptFileName", fileName);
            PageCodeTextBox.Text = fileName;
        }
예제 #11
0
        public override void Execute(object parameter)
        {
            var selectedItems = GetSelectedItems();
            var items = GetProjectItems(selectedItems);

            var item = items.FirstOrDefault();
            if (item == null)
            {
                return;
            }

            var project = ProjectManager.GetProject(item);
            if (project == null)
            {
                return;
            }

            var site = project.Site;
            if (site == null)
            {
                return;
            }

            var dialog = new SelectFileDialog
            {
                Site = site
            };

            if (!dialog.ShowDialog())
            {
                return;
            }

            var options = new TaskDialogOptions
            {
                Title = "Folder Synchronization",
                CommonButtons = TaskDialogCommonButtons.None,
                Content = "Select the synchronization mode.",
                MainIcon = VistaTaskDialogIcon.Information,
                DefaultButtonIndex = 0,
                CommandButtons = new[]
                {
                    "Mirror - every change is applied",
                    "Copy - only create and edit changes are applied"
                },
                AllowDialogCancellation = true
            };

            var r = TaskDialog.Show(options).CommandButtonResult;
            if (r == null)
            {
                return;
            }

            var mode = r == 0 ? FolderSynchronizationMode.Mirror : FolderSynchronizationMode.Copy;

            var fileName = dialog.SelectedFilePath.TrimStart('\\');

            var absoluteFileName = Path.Combine(site.WebRootPath, fileName);
            if (File.Exists(absoluteFileName))
            {
                fileName = Path.GetDirectoryName(fileName) ?? string.Empty;
            }

            var folderSynchronizationManager = AppHost.Container.Get<FolderSynchronizationManager>();

            var sourceFolder = folderSynchronizationManager.GetFolderFileName(project, item);
            var destinationFolder = fileName + "\\";

            folderSynchronizationManager.Add(project, sourceFolder, destinationFolder, mode, "*.*");
        }