Ejemplo n.º 1
0
        public static IMTag FromJObject(JObject obj, string key)
        {
            var res = new IMTag()
            {
                Key         = key,
                Synonyms    = (from o in obj[key]["synonyms"].Values() select o.ToString()).ToList(),
                Description = obj[key]["description"].ToString()
            };

            return(res);
        }
Ejemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     result = new IMTag()
     {
         Key         = textBoxKey.Text,
         Synonyms    = (textBoxAliases.Text != "") ? textBoxAliases.Lines.ToList() : new List <string>(),
         Description = textBoxDescription.Text,
     };
     dialogResult = DialogResult.OK;
     this.Close();
 }
Ejemplo n.º 3
0
        private void LoadProject()
        {
            var JImages                = Project["Images"] as JArray;
            var JTags                  = (Project["Tags"]).Children();
            var JCharacters            = (Project["Characters"]).Children();
            var max                    = JImages.Count();
            var LVImagesCollection     = new List <ListViewItem>();
            var LVTagsCollection       = new List <ListViewItem>();
            var LVCharactersCollection = new List <ListViewItem>();
            var LVSmallImageList       = new ImageList()
            {
                ImageSize = new Size(32, 32),
            };
            var LVLargeImageList = new ImageList()
            {
                ImageSize = new Size(80, 80)
            };

            if (InvokeRequired)
            {
                Invoke(new MethodInvoker(delegate
                {
                    statusLabel.Text          = "Loading Images: (0/" + max + ")";
                    statusProgressBar.Maximum = max;
                    statusProgressBar.Minimum = 1;
                }));
            }
            var somecounter = 1;

            foreach (var v in JImages)
            {
                var newImg = IMImage.FromJObject(v as JObject, ProjectDataPath);
                Images.Add(newImg.Path.Split('\\').Last(), newImg);
                LVImagesCollection.Add(Images.Last().Value.ToListViewItem());
                var   p         = Images.Last().Value.Path.Split('\\').Last();
                var   thumbpath = ProjectDataPath + "\\thumb\\" + Helper.StrArrayToStr((from x in p.Split('.').ToList() where x != p.Split('.').Last() select x).ToList(), ".") + ".png";
                Image img;
                if (!File.Exists(thumbpath))
                {
                    img = Image.FromFile(Images.Last().Value.Path);
                    double factor = (double)img.Width / (double)img.Height;
                    img = img.GetThumbnailImage((int)Math.Truncate(Convert.ToDecimal(100 * factor)), 100, () => false, IntPtr.Zero);
                    img.Save(thumbpath);
                }
                else
                {
                    img = Image.FromFile(thumbpath);
                }
                LVSmallImageList.Images.Add(p, img);
                LVLargeImageList.Images.Add(p, img);
                if (InvokeRequired)
                {
                    Invoke(new MethodInvoker(delegate
                    {
                        statusLabel.Text        = "Loading Images: (" + somecounter + "/" + max + ")";
                        statusProgressBar.Value = somecounter;
                    }));
                }

                somecounter++;
            }
            if (JTags.Count() > 0)
            {
                max = JTags.Count();
                if (InvokeRequired)
                {
                    Invoke(new MethodInvoker(delegate()
                    {
                        statusProgressBar.Maximum = max;
                    }));
                }
                var counter = 1;
                foreach (var v in JTags)
                {
                    var x       = JObject.Parse("{" + v.ToString() + "}");
                    var current = counter;
                    if (InvokeRequired)
                    {
                        Invoke(new MethodInvoker(delegate
                        {
                            statusLabel.Text        = "Loading Tags: (" + current + "/" + max + ")";
                            statusProgressBar.Value = current;
                        }));
                    }
                    counter++;
                    Tags.Add((v as JProperty).Name, IMTag.FromJObject(x, (v as JProperty).Name));
                    LVTagsCollection.Add(Tags.Last().Value.ToListViewItem());
                }
            }
            if (JCharacters.Count() > 0)
            {
                var counter = 1;
                max = JCharacters.Count();
                if (InvokeRequired)
                {
                    Invoke(new MethodInvoker(delegate()
                    {
                        statusProgressBar.Maximum = max;
                    }));
                }
                foreach (var v in JCharacters)
                {
                    var x       = JObject.Parse("{" + v.ToString() + "}");
                    var current = counter;
                    if (InvokeRequired)
                    {
                        Invoke(new MethodInvoker(delegate
                        {
                            statusLabel.Text        = "Loading Characters: (" + current + "/" + max + ")";
                            statusProgressBar.Value = current;
                        }));
                    }
                    counter++;
                    Characters.Add((v as JProperty).Name, IMCharacter.FromJObject(x, (v as JProperty).Name));
                    LVCharactersCollection.Add(Characters.Last().Value.ToListViewItem());
                }
            }
            if (InvokeRequired)
            {
                Invoke(new MethodInvoker(delegate
                {
                    statusLabel.Text = "Building Lists ...";

                    LVImages.SmallImageList = LVSmallImageList;
                    LVImages.LargeImageList = LVLargeImageList;
                    var counter             = 1;
                    var buildmax            = LVImagesCollection.Count();
                    foreach (var v in LVImagesCollection)
                    {
                        LVImages.Items.Add(v);
                        statusLabel.Text = "Building Images List (" + counter + " / " + buildmax + ")";
                        counter++;
                    }
                    counter  = 1;
                    buildmax = LVTagsCollection.Count();
                    foreach (var v in LVTagsCollection)
                    {
                        LVTags.Items.Add(v);
                        statusLabel.Text = "Building Tags List (" + counter + " / " + buildmax + ")";
                        counter++;
                    }
                    counter  = 1;
                    buildmax = LVCharactersCollection.Count();
                    foreach (var v in LVCharactersCollection)
                    {
                        LVCharacters.Items.Add(v);
                        statusLabel.Text = "Building Characters List (" + counter + " / " + buildmax + ")";
                        counter++;
                    }
                    UpdateEditLists();
                    statusLabel.Text = "Done Loading";
                }));
            }
        }