Ejemplo n.º 1
0
        void DataRead(GLib.Object obj, GLib.AsyncResult res)
        {
            File file = FileAdapter.GetObject(obj);

            Regex keyValueRegex = new Regex(
                @"(^(\s)*(?<Key>([^\=^\n]+))[\s^\n]*\=(\s)*(?<Value>([^\n]+(\n){0,1})))",
                RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled |
                RegexOptions.CultureInvariant
                );

            using (DataInputStream stream = new DataInputStream(file.ReadFinish(res))) {
                ulong  len;
                string line;
                while ((line = stream.ReadLine(out len, null)) != null)
                {
                    line = line.Trim();

                    Match match = keyValueRegex.Match(line);
                    if (match.Success)
                    {
                        string key = match.Groups["Key"].Value;
                        string val = match.Groups["Value"].Value;

                        if (key.Equals(NameTag))
                        {
                            Name = val;
                        }
                        else if (key.Equals(DescTag))
                        {
                            Description = val;
                        }
                        else if (key.Equals(AppUriTag))
                        {
                            AppUri = val;
                        }
                        else if (key.Equals(IconTag))
                        {
                            if (val.StartsWith("./") && val.Length > 2)
                            {
                                IconFile = file.Parent.GetChild(val.Substring(2));
                                if (IconFile.Exists)
                                {
                                    Icon = DockServices.Drawing.LoadIcon(IconFile.Path + ";;extension");
                                }
                            }
                            else
                            {
                                Icon = DockServices.Drawing.LoadIcon(val + ";;extension", 128);
                            }
                        }
                    }
                }
            }
            OnDataReady();
        }
Ejemplo n.º 2
0
 static void HandleMountFinished(GLib.Object sender, GLib.AsyncResult result)
 {
     System.Console.WriteLine("handle mount finished");
     if (file.MountEnclosingVolumeFinish(result))
     {
         System.Console.WriteLine("successfull");
     }
     else
     {
         System.Console.WriteLine("Failed");
     }
 }
Ejemplo n.º 3
0
            void InfoLoaded(GLib.Object o, GLib.AsyncResult res)
            {
                List <FilePhoto> items = new List <FilePhoto> ();

                foreach (GLib.FileInfo info in file.EnumerateChildrenFinish(res))
                {
                    SafeUri i = new SafeUri(file.GetChild(info.Name).Uri);
                    Hyena.Log.DebugFormat("testing uri = {0}", i);
                    if (ImageFile.HasLoader(i))
                    {
                        items.Add(new FilePhoto(i));
                    }
                }
                ThreadAssist.ProxyToMain(() => collection.Add(items.ToArray()));
            }