Beispiel #1
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (provider != null)
     {
         try
         {
             using (XsdElementPickerForm form = new XsdElementPickerForm(provider))
             {
                 IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                 if (editorService != null)
                 {
                     VSShellHelper.SetWaitCursor(provider);
                     if (editorService.ShowDialog(form) == DialogResult.OK)
                     {
                         value = form.XsdElementUri;
                     }
                 }
             }
         }
         catch (Exception e)
         {
             VSShellHelper.ShowErrorDialog(provider, LogEntry.ErrorMessageToString(e));
         }
     }
     return(value);
 }
Beispiel #2
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider == null)
            {
                return(string.Empty);
            }

            IVsSolution   vsSolution   = (IVsSolution)ServiceHelper.GetService(provider, typeof(IVsSolution), this);
            HierarchyNode root         = new HierarchyNode(vsSolution);
            HierarchyNode currentValue = null;

            if (value == null)
            {
                value = Guid.Empty;
            }

            try
            {
                VSShellHelper.SetWaitCursor(provider);
                if (!string.IsNullOrWhiteSpace(value.ToString()))
                {
                    currentValue = new HierarchyNode(vsSolution, value.ToString());
                }

                using (HierarchyNode newValue = EditValue(provider, root, currentValue))
                {
                    if (newValue != null)
                    {
                        return(newValue.UniqueName);
                    }
                }
            }
            //Thrown if Project doesn't exist on solution
            catch (InvalidOperationException) { }
            //Thrown if Project doesn't exist on solution
            catch (COMException) { }
            catch (ServiceMissingException) { throw; }
            catch (Exception e)
            {
                VSShellHelper.ShowErrorDialog(provider, e.Message);
            }
            finally
            {
                if (root != null)
                {
                    root.Dispose();
                }
                if (currentValue != null)
                {
                    currentValue.Dispose();
                }
            }

            return(string.Empty);
        }