Exemplo n.º 1
0
        private void ClanMembers_OnAdd(FaceBox instance)
        {
            Debug.Log("instance " + instance.Name + " add");

            Transform prefab = (clanMembersRectTransform.childCount > 0 ? clanMembersRectTransform.GetChild(0) : null);

            if (prefab == null)
            {
                throw new System.Exception(clanMembersRectTransform.childCount.ToString());
            }

            var newGameObject = GameObject.Instantiate(prefab.gameObject);

            newGameObject.name = instance.Name;

            //获取子View
            var subView = newGameObject.GetComponent <FaceBoxView>();

            subView.BindingContext = new FaceBoxViewModel()
            {
                ParentViewModel = BindingContext
            };
            subView.BindingContext.InitializationFromData(instance);
            subView.Reveal();

            newGameObject.transform.SetParent(clanMembersRectTransform, false);
            newGameObject.transform.localScale = Vector3.one;
        }
Exemplo n.º 2
0
 public void InitializationFromData(FaceBox member)
 {
     Name.Value  = member.Name;
     Level.Value = member.Level;
     Face.Value  = member.Face;
     Badge.Value = new Badge()
     {
         Icon = member.Badge.Icon, ElementColor = member.Badge.ElementColor
     };
 }
Exemplo n.º 3
0
        private static void EnlargeFaceBoxSize(FaceBox face, int imageWidth, int imageHeight, out int width, out int height,
                                               out int xStartPosition,
                                               out int yStartPosition)
        {
            width  = (int)face.Width;
            height = (int)face.Height;
            int paddingWidth  = (int)(face.Width * FaceImageBoxPaddingPercentage / 100);
            int paddingHeight = (int)(face.Height * FaceImageBoxPaddingPercentage / 100);

            xStartPosition = (int)face.X;
            yStartPosition = (int)face.Y;
            if (xStartPosition >= paddingWidth)
            {
                xStartPosition = xStartPosition - paddingWidth;
                width          = width + paddingWidth;
            }
            else
            {
                width          = width + xStartPosition;
                xStartPosition = 0;
            }
            if (yStartPosition >= paddingHeight)
            {
                yStartPosition = yStartPosition - paddingHeight;
                height         = height + paddingHeight;
            }
            else
            {
                height         = height + paddingHeight;
                yStartPosition = 0;
            }
            if (imageWidth >= xStartPosition + width + paddingWidth)
            {
                width = width + paddingWidth;
            }
            else
            {
                width = imageWidth - xStartPosition;
            }
            if (imageHeight >= yStartPosition + height + paddingHeight)
            {
                height = height + paddingHeight;
            }
            else
            {
                height = imageHeight - yStartPosition;
            }
        }
Exemplo n.º 4
0
        private async void Fsw_Created(object sender, FileSystemEventArgs e)
        {
            if ((Path.GetExtension(e.FullPath).ToLower() != ".jpeg") && (Path.GetExtension(e.FullPath).ToLower() != ".jpg") && (Path.GetExtension(e.FullPath).ToLower() != ".png"))// || (Path.GetExtension(e.FullPath).ToLower() != ".jpg"))
            {
                return;
            }
            try
            {
                while (FileHelper.IsFileInUse(new FileInfo(e.FullPath)))
                {
                    Thread.Sleep(100);
                }
                var fii = await new facehelper(apikey).ProcessFile(e.FullPath);

                UpdateLabel(lbl_age, fii.GetFace().FaceAttributes.Age.ToString());
                UpdateLabel(lbl_gender, fii.GetFace().FaceAttributes.Gender);
                UpdateLabel(lbl_smile, String.Format("{0}%", fii.GetFace().FaceAttributes.Smile * 100));
                UpdateLabel(lbl_moustache, String.Format("{0}%", fii.GetFace().FaceAttributes.FacialHair.Moustache * 100));
                try
                {
                    UpdateLabel(lbl_haircolor, (fii.GetFace().FaceAttributes.Hair.HairColor.MaxBy(x => x.Confidence)).Color.ToString());
                }
                catch
                {
                    string message = "Person is wearing a hat.";
                }
                UpdateLabel(lbl_glasses, fii.GetFace().FaceAttributes.Glasses.ToString());
                UpdateLabel(lbl_faceid, fii.GetFace().FaceId.ToString());

                FaceBox.Invoke((MethodInvoker) delegate
                {
                    FaceBox.InitialImage = null;
                    FaceBox.Image        = fii.GetImage();
                });
            }
            catch (Exception ex)
            {
                var exmessage = ex.StackTrace;
            }
        }
Exemplo n.º 5
0
        void createBoxes()
        {
            int count  = 134;
            int column = 11;

            for (int i = 0; i < count; i++)
            {
                FaceBox box = new FaceBox(i);
                box.Location = new Point(i % column * 30, i / column * 30);
                this.Controls.Add(box);

                box.Selected += delegate(int faceID)
                {
                    if (this.AddFace != null)
                    {
                        this.AddFace("Face_" + faceID);
                    }

                    this.Hide();
                };
            }
            this.Width  = 30 * column + 6;                                                //6为两边框宽
            this.Height = (count / column + (count % column == 0 ? 0 : 1)) * 30 + 3 + 29; //29为标题栏高和上下两边框高
        }
Exemplo n.º 6
0
 private void ClanMembers_OnRemove(FaceBox instance)
 {
     Debug.Log("instance " + instance.Name + " delete");
     Destroy(GameObject.Find(instance.Name));
 }
Exemplo n.º 7
0
	public PhotoView (IBrowsableCollection query)
		: base ()
	{
		this.query = query;

		description_delay = new FSpot.Delay (1000, new GLib.IdleHandler (CommitPendingChanges));
		this.Destroyed += HandleDestroy;

		Name = "ImageContainer";
		Box vbox = new VBox (false, 6);
		Add (vbox);

	        background = new EventBox ();
		Frame frame = new Frame ();
		background.Add (frame);

		frame.ShadowType = ShadowType.In;
		vbox.PackStart (background, true, true, 0);
		
		Box inner_vbox = new VBox (false , 2);

		frame.Add (inner_vbox);
		
		photo_view = new FSpot.PhotoImageView (query);
		photo_view.PhotoChanged += HandlePhotoChanged; 
		photo_view.SelectionChanged += HandleSelectionChanged;

		photo_view_scrolled = new ScrolledWindow (null, null);

		photo_view_scrolled.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);
		photo_view_scrolled.ShadowType = ShadowType.None;
		photo_view_scrolled.Add (photo_view);
		photo_view_scrolled.ButtonPressEvent += HandleButtonPressEvent;
		photo_view.AddEvents ((int) EventMask.KeyPressMask);
		inner_vbox.PackStart (photo_view_scrolled, true, true, 0);
		
		HBox inner_hbox = new HBox (false, 2);
		//inner_hbox.BorderWidth = 6;

		tag_view = new TagView ();
		inner_hbox.PackStart (tag_view, false, true, 0);
		SetColors ();

		Label comment = new Label (Catalog.GetString ("Comment:"));
		inner_hbox.PackStart (comment, false, false, 0);
		description_entry = new Entry ();
		inner_hbox.PackStart (description_entry, true, true, 0);
		description_entry.Changed += HandleDescriptionChanged;
		
		inner_vbox.PackStart (inner_hbox, false, true, 0);

		Box toolbar_hbox = new HBox (false, 6);
		vbox.PackStart (toolbar_hbox, false, true, 0);

		toolbar_hbox.PackStart (CreateConstraintsOptionMenu (), false, false, 0);

		crop_button = new ToolbarButton ();
		crop_button.Add (new Gtk.Image ("f-spot-crop", IconSize.Button));
		toolbar_hbox.PackStart (crop_button, false, true, 0);
	
		crop_button.Clicked += new EventHandler (HandleCropButtonClicked);

		redeye_button = new ToolbarButton ();
		redeye_button.Add (new Gtk.Image ("f-spot-red-eye", IconSize.Button));
		toolbar_hbox.PackStart (redeye_button, false, true, 0);
	
		redeye_button.Clicked += new EventHandler (HandleRedEyeButtonClicked);

		color_button = new ToolbarButton ();
		color_button.Add (new Gtk.Image ("f-spot-adjust-colors", IconSize.Button));
		toolbar_hbox.PackStart (color_button, false, true, 0);
	
		color_button.Clicked += new EventHandler (HandleColorButtonClicked);

		desaturate_button = new ToolbarButton ();
		desaturate_button.Add (new Gtk.Image ("f-spot-desaturate", IconSize.Button));
		toolbar_hbox.PackStart (desaturate_button, false, true, 0);
		desaturate_button.Clicked += HandleDesaturateButtonClicked;

		sepia_button = new ToolbarButton ();
		sepia_button.Add (new Gtk.Image ("f-spot-sepia", IconSize.Button));
		toolbar_hbox.PackStart (sepia_button, false, true, 0);
		sepia_button.Clicked += HandleSepiaButtonClicked;

		ItemAction straighten = new TiltEditorAction (photo_view);
		toolbar_hbox.PackStart (straighten.GetToolButton (false), false, true, 0);
		
		ItemAction softfocus = new SoftFocusEditorAction (photo_view);
		toolbar_hbox.PackStart (softfocus.GetToolButton (false), false, true, 0);

		ItemAction autocolor = new AutoColor (photo_view.Item);
		toolbar_hbox.PackStart (autocolor.GetToolButton (false), false, true, 0);
		
		/* Face detection ! */
		
		face_widget = new FaceBox (toolbar_hbox, photo_view);
		
		vbox.PackStart ( face_widget, false, true, 0);
		/* Spacer Label */
		toolbar_hbox.PackStart (new Label (String.Empty), true, true, 0);

		count_label = new Label (String.Empty);
		toolbar_hbox.PackStart (count_label, false, true, 0);

		display_previous_button = new ToolbarButton ();
		Gtk.Image display_previous_image = new Gtk.Image (Stock.GoBack, IconSize.Button);
		display_previous_button.Add (display_previous_image);
		display_previous_button.Clicked += new EventHandler (HandleDisplayPreviousButtonClicked);
		toolbar_hbox.PackStart (display_previous_button, false, true, 0);

		display_next_button = new ToolbarButton ();
		Gtk.Image display_next_image = new Gtk.Image (Stock.GoForward, IconSize.Button);
		display_next_button.Add (display_next_image);
		display_next_button.Clicked += new EventHandler (HandleDisplayNextButtonClicked);
		toolbar_hbox.PackStart (display_next_button, false, true, 0);

		tips.Enable ();


		UpdateButtonSensitivity ();

		vbox.ShowAll ();
		tips.SetTip (color_button, Catalog.GetString ("Adjust the photo colors"), String.Empty);
		tips.SetTip (constraints_option_menu, Catalog.GetString ("Constrain the aspect ratio of the selection"), String.Empty);
		tips.SetTip (display_next_button, Catalog.GetString ("Next photo"), String.Empty);
		tips.SetTip (display_previous_button, Catalog.GetString ("Previous photo"), String.Empty);
		tips.SetTip (desaturate_button, Catalog.GetString ("Convert the photo to black and white"), String.Empty);
		tips.SetTip (sepia_button, Catalog.GetString ("Convert the photo to sepia tones"), String.Empty);

		Realized += delegate (object o, EventArgs e) {SetColors ();};
	}
Exemplo n.º 8
0
        public PhotoView(IBrowsableCollection query)
            : base()
        {
            this.query = query;

            description_delay = new FSpot.Delay(1000, new GLib.IdleHandler(CommitPendingChanges));
            this.Destroyed   += HandleDestroy;

            Name = "ImageContainer";
            Box vbox = new VBox(false, 6);

            Add(vbox);

            background = new EventBox();
            Frame frame = new Frame();

            background.Add(frame);

            frame.ShadowType = ShadowType.In;
            vbox.PackStart(background, true, true, 0);

            Box inner_vbox = new VBox(false, 2);

            frame.Add(inner_vbox);

            photo_view = new FSpot.PhotoImageView(query);
            photo_view.PhotoChanged     += HandlePhotoChanged;
            photo_view.SelectionChanged += HandleSelectionChanged;

            photo_view_scrolled = new ScrolledWindow(null, null);

            photo_view_scrolled.SetPolicy(PolicyType.Automatic, PolicyType.Automatic);
            photo_view_scrolled.ShadowType = ShadowType.None;
            photo_view_scrolled.Add(photo_view);
            photo_view_scrolled.ButtonPressEvent += HandleButtonPressEvent;
            photo_view.AddEvents((int)EventMask.KeyPressMask);
            inner_vbox.PackStart(photo_view_scrolled, true, true, 0);

            HBox inner_hbox = new HBox(false, 2);

            //inner_hbox.BorderWidth = 6;

            tag_view = new TagView();
            inner_hbox.PackStart(tag_view, false, true, 0);
            SetColors();

            Label comment = new Label(Catalog.GetString("Comment:"));

            inner_hbox.PackStart(comment, false, false, 0);
            description_entry = new Entry();
            inner_hbox.PackStart(description_entry, true, true, 0);
            description_entry.Changed += HandleDescriptionChanged;

            inner_vbox.PackStart(inner_hbox, false, true, 0);

            Box toolbar_hbox = new HBox(false, 6);

            vbox.PackStart(toolbar_hbox, false, true, 0);

            toolbar_hbox.PackStart(CreateConstraintsOptionMenu(), false, false, 0);

            crop_button = new ToolbarButton();
            crop_button.Add(new Gtk.Image("f-spot-crop", IconSize.Button));
            toolbar_hbox.PackStart(crop_button, false, true, 0);

            crop_button.Clicked += new EventHandler(HandleCropButtonClicked);

            redeye_button = new ToolbarButton();
            redeye_button.Add(new Gtk.Image("f-spot-red-eye", IconSize.Button));
            toolbar_hbox.PackStart(redeye_button, false, true, 0);

            redeye_button.Clicked += new EventHandler(HandleRedEyeButtonClicked);

            color_button = new ToolbarButton();
            color_button.Add(new Gtk.Image("f-spot-adjust-colors", IconSize.Button));
            toolbar_hbox.PackStart(color_button, false, true, 0);

            color_button.Clicked += new EventHandler(HandleColorButtonClicked);

            desaturate_button = new ToolbarButton();
            desaturate_button.Add(new Gtk.Image("f-spot-desaturate", IconSize.Button));
            toolbar_hbox.PackStart(desaturate_button, false, true, 0);
            desaturate_button.Clicked += HandleDesaturateButtonClicked;

            sepia_button = new ToolbarButton();
            sepia_button.Add(new Gtk.Image("f-spot-sepia", IconSize.Button));
            toolbar_hbox.PackStart(sepia_button, false, true, 0);
            sepia_button.Clicked += HandleSepiaButtonClicked;

            ItemAction straighten = new TiltEditorAction(photo_view);

            toolbar_hbox.PackStart(straighten.GetToolButton(false), false, true, 0);

            ItemAction softfocus = new SoftFocusEditorAction(photo_view);

            toolbar_hbox.PackStart(softfocus.GetToolButton(false), false, true, 0);

            ItemAction autocolor = new AutoColor(photo_view.Item);

            toolbar_hbox.PackStart(autocolor.GetToolButton(false), false, true, 0);

            /* Face detection ! */

            face_widget = new FaceBox(toolbar_hbox, photo_view);

            vbox.PackStart(face_widget, false, true, 0);
            /* Spacer Label */
            toolbar_hbox.PackStart(new Label(String.Empty), true, true, 0);

            count_label = new Label(String.Empty);
            toolbar_hbox.PackStart(count_label, false, true, 0);

            display_previous_button = new ToolbarButton();
            Gtk.Image display_previous_image = new Gtk.Image(Stock.GoBack, IconSize.Button);
            display_previous_button.Add(display_previous_image);
            display_previous_button.Clicked += new EventHandler(HandleDisplayPreviousButtonClicked);
            toolbar_hbox.PackStart(display_previous_button, false, true, 0);

            display_next_button = new ToolbarButton();
            Gtk.Image display_next_image = new Gtk.Image(Stock.GoForward, IconSize.Button);
            display_next_button.Add(display_next_image);
            display_next_button.Clicked += new EventHandler(HandleDisplayNextButtonClicked);
            toolbar_hbox.PackStart(display_next_button, false, true, 0);

            tips.Enable();


            UpdateButtonSensitivity();

            vbox.ShowAll();
            tips.SetTip(color_button, Catalog.GetString("Adjust the photo colors"), String.Empty);
            tips.SetTip(constraints_option_menu, Catalog.GetString("Constrain the aspect ratio of the selection"), String.Empty);
            tips.SetTip(display_next_button, Catalog.GetString("Next photo"), String.Empty);
            tips.SetTip(display_previous_button, Catalog.GetString("Previous photo"), String.Empty);
            tips.SetTip(desaturate_button, Catalog.GetString("Convert the photo to black and white"), String.Empty);
            tips.SetTip(sepia_button, Catalog.GetString("Convert the photo to sepia tones"), String.Empty);

            Realized += delegate(object o, EventArgs e) { SetColors(); };
        }