Ejemplo n.º 1
0
 private void RenderTags2(IList<ImageTag> tags)
 {
     foreach (ImageTag tag in tags) {
         TagUtility tu = new TagUtility (tag);
         PaintTaggedBox (tu.FetchAsRectangleF(), tag.TagString);
     }
 }
Ejemplo n.º 2
0
 private void RenderTags(IList<ImageTag> tags)
 {
     List<RectangleF> rects = new List<RectangleF> ();
     List<String> tagStrings = new List<string>();
     foreach(ImageTag tag in tags){
         Console.WriteLine("RenderTags():"+tag.ToString());
         TagUtility tu = new TagUtility (tag);
         rects.Add (tu.FetchAsRectangleF ());
         tagStrings.Add(tag.TagString);
     }
     PaintBoxes(rects);
     DrawTexts (tagStrings, rects);
 }
Ejemplo n.º 3
0
        void ShowDetails(ImageTag mytag)
        {
            this.tag = mytag;
            TagUtility tu = new TagUtility (tag);
            fetcher = tu.FetchAsRectangleF ();
            string tagText = MonoTouch.Foundation.NSBundle.MainBundle.LocalizedString ("Tag", "Tag");
            this.tagIdLabel.Text = tagText + ":"+mytag.ID;

            this.xTextField.Text = fetcher.X.ToString();
            this.yTextField.Text = fetcher.Y.ToString ();
            this.WidthLabel.Text = MonoTouch.Foundation.NSBundle.MainBundle.LocalizedString ("Width", "Width");
            this.Label_Height.Text = MonoTouch.Foundation.NSBundle.MainBundle.LocalizedString ("Height", "Height");
            this.TextField_height.Text = fetcher.Height.ToString ();
            this.WidthTextField.Text = fetcher.Width.ToString ();

            this.TextField_height.ValueChanged += (object sender, EventArgs e) => {
                try{
                    float height = float.Parse(this.TextField_height.Text.Replace(',', '.'), System.Globalization.CultureInfo.InvariantCulture);
                    fetcher.Height = height;
                    tu.StoreRectangleF(fetcher);
                    AppDelegate.dao.SaveTag(mytag);
                }catch(Exception ex){
                    Console.WriteLine("exception happend, defaulting value:"+ex.ToString());
                    this.Label_Height.Text = fetcher.Height.ToString();
                }
            };

            this.WidthTextField.ValueChanged += (object sender, EventArgs e) => {
                try{
                    float width = float.Parse(this.WidthTextField.Text.Replace(',', '.'), System.Globalization.CultureInfo.InvariantCulture);
                    fetcher.Width = width;
                    tu.StoreRectangleF(fetcher);
                    AppDelegate.dao.SaveTag(mytag);
                }catch(Exception ex){
                    Console.WriteLine("exception happend, defaulting value:"+ex.ToString());
                    this.WidthTextField.Text = fetcher.Width.ToString();
                }
            };

            this.xTextField.ValueChanged += (object sender, EventArgs e) => {
                try{
                    float x = float.Parse(this.xTextField.Text.Replace(',', '.'), System.Globalization.CultureInfo.InvariantCulture);
                    fetcher.X = x;
                    tu.StoreRectangleF(fetcher);
                    AppDelegate.dao.SaveTag(mytag);
                }catch(Exception ex){
                    Console.WriteLine("exception happend, defaulting value:"+ex.ToString());
                    this.xTextField.Text = fetcher.X.ToString();
                }
            };

            this.yTextField.ValueChanged += (object sender, EventArgs e) => {
                try{
                    float y = float.Parse(this.yTextField.Text.Replace(',', '.'), System.Globalization.CultureInfo.InvariantCulture);
                    fetcher.Y = y;
                    tu.StoreRectangleF(fetcher);
                    AppDelegate.dao.SaveTag(mytag);
                }catch(Exception ex){
                    Console.WriteLine("exception happend, defaulting value:"+ex.ToString());
                    this.yTextField.Text = fetcher.Y.ToString();
                }
            };

            this.xTextField.ShouldReturn += textField => {
                textField.ResignFirstResponder();
                return true;
            };
            this.yTextField.ShouldReturn += textField => {
                textField.ResignFirstResponder();
                return true;
            };

            this.TextField_height.ShouldReturn += textField => {
                textField.ResignFirstResponder();
                return true;
            };
            this.WidthTextField.ShouldReturn += textField => {
                textField.ResignFirstResponder();
                return true;
            };
        }
Ejemplo n.º 4
0
        string[] ExtractTagImages(ImageTag tag)
        {
            GalleryObject go = AppDelegate.dao.GetGalleryObjectByID (tag.GalleryObjectID);

            var documentsDirectory = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            var gallerydirectory = Path.Combine (documentsDirectory, "gallery");
            string imagefilename = go.imageFileName;
            string path = Path.Combine (gallerydirectory, imagefilename);
            UIImage MasterImage = UIImage.FromFile (path);

            CGImage cg = MasterImage.CGImage;
            TagUtility tu = new TagUtility (tag);
            CGImage neo = cg.WithImageInRect (tu.FetchAsRectangleF());

            UIImage cutout = UIImage.FromImage (neo);
            //UIImage thumbnail = cutout.Scale (new SizeF(50, 50));
            return SaveCutout (RandomGeneratedName (), cutout);
        }
Ejemplo n.º 5
0
        void EditTagFrame(UIGestureRecognizer gestureRecognizer)
        {
            Console.WriteLine ("edittagframe triggered");
            if (mylock == false) {
                Console.WriteLine ("mutex aquired");
                mylock = true;
                point = gestureRecognizer.LocationInView (this.blend);
            //			Console.WriteLine ("presspoint:" + point);
            //			PointF center = scrollView.Center;
            //			Console.WriteLine("center:"+scrollView.Center);
            //			float scale = scrollView.ZoomScale;
            //			PointF con = new PointF (scrollView.ContentOffset.X / scale, scrollView.ContentOffset.Y / scale);
            //			PointF con = new PointF (scrollView.ContentOffset.X, scrollView.ContentOffset.Y);
            //			Console.WriteLine ("con:" + con);
            //			PointF guess = new PointF (con.X + point.X, con.Y + point.Y);
            //			Console.WriteLine ("guess:" + guess);

                Rects = new List<RectangleF> ();
                Tags = AppDelegate.dao.GetTagsByGalleryObjectID (go.ID);
                for (int i = 0; i < Tags.Count; i++) {
                    TagUtility tu = new TagUtility (Tags [i]);
                    Rects.Add (tu.FetchAsRectangleF ());
                }
                for (int j = 0; j < Rects.Count; j++) {
                    if (Rects [j].Contains (point)) {
            //						if (finds.Exists (x => x.ID == Tags [j].ID)) {
            //							Console.WriteLine ("pushing:" + Tags [j]);
            //							finds.Remove (Tags [j]);
                        tds = new TagDetailScreen (Tags [j],this);

                        found = true;
            //						tds.backpush += (object sender, BackClickedEventArgs e) => {
            //							Console.WriteLine("mutex released");
            //							mylock = false;
            //						};
                        this.NavigationController.PushViewController(tds, true);
                        //this.NavigationController.PushViewController (tds, false);
                        break;
            //						} else {
            //							Console.WriteLine ("adder:" + Tags [j]);
            //							Console.WriteLine ("finds:" + finds.Count);
            //							finds.Add (Tags [j]);
            //							break;
            //						}
                    }
                }
                if (!found) {
                    Console.WriteLine ("releasing mutex");
                    mylock = false;
                }
            }
        }
Ejemplo n.º 6
0
        void AddTagInner()
        {
            ImageTag tag = new ImageTag ();
            tag.GalleryObjectID = go.ID;
            var cr8 = MonoTouch.Foundation.NSBundle.MainBundle.LocalizedString ("Create", "Create");
            var input = MonoTouch.Foundation.NSBundle.MainBundle.LocalizedString ("input tags, comma seperated", "input tags, comma seperated");
            var abort = MonoTouch.Foundation.NSBundle.MainBundle.LocalizedString ("Cancel", "Cancel");
            UIAlertView av = new UIAlertView (input, "\n", null, abort, new string[] {
                cr8
            });
            av.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
            int Create = av.FirstOtherButtonIndex;
            av.Clicked += (object sender, UIButtonEventArgs e) =>  {
                if (e.ButtonIndex == Create) {
                    String tagText = av.GetTextField (0).Text;
                    tag.TagString = tagText;
                    var scale = scrollView.ZoomScale;
                    const float heightmod = 0.70f;
                    //float widthmod = 1f;
                    RectangleF contentFrame = new RectangleF (scrollView.ContentOffset.X / scale, scrollView.ContentOffset.Y / scale, scrollView.Frame.Size.Width / scale, scrollView.Frame.Size.Height / scale * heightmod);
                    //RectangleF MyContentFrame = new RectangleF(contentFrame.X, contentFrame.Y - navbar,contentFrame.Width, contentFrame.Height + navbar);
                    //contentFrame.Y = contentFrame.Y + this.NavigationController.View.Bounds.Y;
                    //contentFrame.X = contentFrame.X + this.NavigationController.View.Bounds.Bottom;
                    contentFrame.Y = contentFrame.Y + 90;
                    TagUtility tu = new TagUtility(tag);
                    tu.StoreRectangleF (contentFrame);
                    AppDelegate.dao.SaveTag (tag);
            //					Console.WriteLine ("tagtext:" + tag.TagString);
            //					Console.WriteLine ("spot:" + tag.FetchAsRectangleF ());
                    tgv.SetNeedsDisplay ();

                }
            };
            av.Show ();
        }