Esempio n. 1
0
        private static IDataObject LoadResources(object state1)
        {
            var st   = (TaskState <RootNode1>)state1;
            var node = st.Node;

            try
            {
                var dta = new List <SubnodeData>();
                using (var stream = node.Assembly.GetManifestResourceStream(node.Name.ToString()))
                {
                    if (stream != null && node.Name.ToString().EndsWith(".resources"))
                    {
                        using (var reader = new ResourceReader(stream))
                        {
                            foreach (var dictionaryEntry in reader.Cast <DictionaryEntry>())
                            {
                                var value = dictionaryEntry.Value;
                                if (((string)dictionaryEntry.Key).EndsWith(".png"))
                                {
                                    Debug.WriteLine(dictionaryEntry.Value.ToString());
                                }
                                try
                                {
                                    var data = new SubnodeData
                                    {
                                        Name         = dictionaryEntry.Key as string,
                                        Value        = value,
                                        ResourceName = node.Name,
                                        Assembly     = node.Assembly
                                    };
                                    dta.Add(data);
                                }
                                catch (Exception ex)
                                {
                                    // DebugUtils.WriteLine(ex.ToString());
                                }
                            }
                        }
                    }
                }

                return(new DataObject(typeof(IEnumerable), dta));
            }
            catch (Exception ex)
            {
                // DebugUtils.WriteLine(ex.ToString());
                throw;
            }
        }
Esempio n. 2
0
        private async Task <IDataObject> MakeBitmapValue()
        {
            var object3 = await Dispatcher.InvokeAsync(() =>
            {
                Debug.WriteLine(".png");

                var png = new PngBitmapDecoder(MemoryStream, BitmapCreateOptions.None,
                                               BitmapCacheOption.Default);
                BitmapSource src = png.Frames[0];
                var s            = new SubnodeData();
                s.Value          = src;
                s.Name           = "Image";
                return(new DataObject(typeof(BitmapSource), src));
            },
                                                       DispatcherPriority.Send);

            return(object3);
        }