Example #1
0
        public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource)
        {
            if (propertyValue == null)
            {
                return;
            }
            if (propertyValue.ParentProperty.IsReadOnly)
            {
                return;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.AllowMultiple = false;

            openFileDialog.Filters = new List <FileDialogFilter>
            {
                new FileDialogFilter()
                {
                    Name         = "Image Files (*.jpg, *.png, *.bmp)"
                    , Extensions = new List <string>()
                    {
                        "jpg", "png", "bmp"
                    }
                }
            };

            var mainWindow = ApplicationExtension.GetMainWindow();

            openFileDialog.ShowAsync(mainWindow).ContinueWith(x =>
            {
                if (x.IsFaulted == false)
                {
                    string result = x.Result.FirstOrDefault();

                    if (string.IsNullOrEmpty(result) == false)
                    {
                        propertyValue.StringValue = result;
                    }
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Example #2
0
        public FileBrowserDialogPropertyValueEditor()
        {
            //little ugly search for the resource
            var mainWindow = ApplicationExtension.GetMainWindow();

            if (mainWindow != null)
            {
                object res = null;
                foreach (var item in mainWindow.FindChildren <UserControl>(true))
                {
                    if (item.TryFindResource(LocalResources.FileBrowserEditorKey, out res))
                    {
                        break;
                    }
                }


                InlineTemplate = res;
            }
        }
Example #3
0
        public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource)
        {
            if (propertyValue == null)
            {
                return;
            }
            if (propertyValue.ParentProperty.IsReadOnly)
            {
                return;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.AllowMultiple = false;

            var property = propertyValue.ParentProperty;

            if (property != null)
            {
                var optionsAttribute = (OpenFileDialogOptionsAttribute)property.Attributes[typeof(OpenFileDialogOptionsAttribute)];
                if (optionsAttribute != null)
                {
                    optionsAttribute.ConfigureDialog(openFileDialog);
                }
            }

            var mainWindow = ApplicationExtension.GetMainWindow();

            openFileDialog.ShowAsync(mainWindow).ContinueWith(x =>
            {
                if (x.IsFaulted == false)
                {
                    string result = x.Result.FirstOrDefault();

                    if (string.IsNullOrEmpty(result) == false)
                    {
                        propertyValue.StringValue = result;
                    }
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }