Esempio n. 1
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     try
     {
         destinationType.RequireNotNull();
         value.RequireNotNull();
         var strValue = ConvertToInvariantString(context, value);
         if (destinationType == typeof(string))
         {
             return(value.ToString());
         }
         if (destinationType == typeof(InstanceDescriptor))
         {
             var info = TargetType.GetField(strValue);
             if (info != null)
             {
                 return(new InstanceDescriptor(info, null));
             }
         }
         if (destinationType == TargetType)
         {
             return(FlexEnum.Parse(TargetType, strValue));
         }
         throw new Exception("convertto failed");
     }
     catch
     {
         throw new Exception("convertto failed unknown");
     }
 }
Esempio n. 2
0
 public ReportViewer()
 {
     InitializeComponent();
     EventManager.RegisterClassHandler(typeof(ReportViewer), FlexDocumentViewport.DocumentLoadErrorEvent,
                                       new RoutedDocumentLoadErrorEventHandler(OnDocumentLoadError));
     resetUI();
     Width        = AppSettings.Instance.WindowSize.Width;
     Height       = AppSettings.Instance.WindowSize.Height;
     SizeChanged += onSizeChanged;
     try
     {
         var theme = FlexEnum.FromName <RecommendedThemeSet>(AppSettings.Instance.Theme);
         ThemePrimitive.SetTheme(this, theme.Value);
     }
     catch
     {
         AppSettings.Instance.Theme = "Cyan";
     }
     foreach (var arg in from arg in Environment.GetCommandLineArgs()
              let fi = new FileInfo(arg)
                       where fi.Exists
                       where string.Equals(fi.Extension, ".FLEX",
                                           StringComparison.CurrentCultureIgnoreCase)
                       select arg)
     {
         Loaded += (Sender, Args) =>
         {
             OpenDocument(arg);
         };
     }
 }
Esempio n. 3
0
 public override bool IsValid(ITypeDescriptorContext context, object value)
 {
     try
     {
         return(FlexEnum.IsDefined(TargetType, value));
     }
     catch
     {
         throw new Exception("isvalid failed");
     }
 }
Esempio n. 4
0
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     try
     {
         return(FlexEnum.Parse(TargetType, value.RequireType <string>()));
     }
     catch
     {
         throw new Exception("convertfrom failed");
     }
 }