示例#1
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            ActiveCommandCollection ActiveCommands = ctrl.ActiveCommands;

            ActiveCommands.Clear();
            ActiveCommands.Add(CustomControls.ActiveCommand.Ok);
            ActiveCommands.Add(CustomControls.ActiveCommand.Cancel);

            TypeConverter CollectionConverter = TypeDescriptor.GetConverter(ActiveCommands);

            Debug.Assert(CollectionConverter.CanConvertFrom(typeof(string)));
            Debug.Assert(!CollectionConverter.CanConvertFrom(typeof(int)));

            bool IsConvertedFrom;
            bool IsConvertedTo;

            ConvertActiveCommandCollection(CollectionConverter, "Ok", out IsConvertedFrom, ActiveCommands, out IsConvertedTo);
            Debug.Assert(IsConvertedFrom);
            Debug.Assert(IsConvertedTo);

            ConvertActiveCommandCollection(CollectionConverter, 0, out IsConvertedFrom, ActiveCommands, out IsConvertedTo);
            Debug.Assert(!IsConvertedFrom);
            Debug.Assert(!IsConvertedTo);

            TypeConverter Converter = TypeDescriptor.GetConverter(ActiveCommands[0]);

            Debug.Assert(Converter.CanConvertFrom(typeof(string)));
            Debug.Assert(!Converter.CanConvertFrom(typeof(int)));

            ConvertActiveCommand(Converter, "Ok", out IsConvertedFrom, ActiveCommands[0], out IsConvertedTo);
            Debug.Assert(IsConvertedFrom);
            Debug.Assert(IsConvertedTo);

            ConvertActiveCommand(Converter, 0, out IsConvertedFrom, ActiveCommands[0], out IsConvertedTo);
            Debug.Assert(!IsConvertedFrom);
            Debug.Assert(!IsConvertedTo);

            string SystemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
            string User32Path = Path.Combine(SystemPath, "user32.dll");

            DialogValidation.LoadStringFromResourceFile("", 1);
            DialogValidation.LoadStringFromResourceFile(User32Path, 9999);
        }