Beispiel #1
0
        /**
         * Return the last NORMAL state tag view in this group.
         *
         * @return the last NORMAL state tag view or null if not exists
         */
        protected TagView getLastNormalTagView()
        {
            int     lastNormalTagIndex = isAppendMode ? ChildCount - 2 : ChildCount - 1;
            TagView lastNormalTagView  = getTagAt(lastNormalTagIndex);

            return(lastNormalTagView);
        }
Beispiel #2
0
        public override Task <TagsView> PublishCollection(PublishTags command, ServerCallContext context)
        {
            var tagViews = new List <TagView>();

            foreach (var tag in command.Names)
            {
                var tagId  = Guid.NewGuid();
                var entity = new Tag
                {
                    Id          = tagId,
                    Name        = tag,
                    ArticleTags = new HashSet <ArticleTag>
                    {
                        new ArticleTag
                        {
                            TagId     = tagId,
                            ArticleId = Guid.Parse(command.ArticleId)
                        }
                    }
                };
                _repository.AddOrDefault(entity);
                var view = new TagView
                {
                    Id   = tagId.ToString(),
                    Name = tag
                };
                tagViews.Add(view);
            }
            var result = new TagsView
            {
                Tags = { tagViews }
            };

            return(Task.FromResult(result));
        }
Beispiel #3
0
        /**
         * Append tag to this group.
         *
         * @param tag the tag to append.
         */
        protected void appendTag(TagColor color, string tag)
        {
            TagView newTag = new TagView(this, Context, TagView.STATE_NORMAL, color, tag);

            newTag.Click += NewTag_Click;
            AddView(newTag);
        }
Beispiel #4
0
        public static TagView Create(string text, int count)
        {
            var response = new TagView();

            response.Tag = text;

            if (count > 10)
            {
                response.Class = "tag5";
            }
            else if (count > 5)
            {
                response.Class = "tag4";
            }
            else if (count > 3)
            {
                response.Class = "tag3";
            }
            else if (count > 1)
            {
                response.Class = "tag2";
            }
            else
            {
                response.Class = "tag1";
            }

            return(response);
        }
Beispiel #5
0
        public ActionResult Create(TagView tag, int postId)
        {
            try
            {
                var post = postService.GetById(postId);
                if (post == null)
                {
                    return(View("Error"));
                }

                var existingTag = tagService.GetAll()
                                  .FirstOrDefault(t => t.Name == tag.Name);

                if (existingTag == null)
                {
                    existingTag = tagService.Add(tag);
                }

                existingTag.Posts.Add(post);
                tagService.Update(existingTag);

                return(RedirectToAction("Edit", "Post", new { id = postId }));
            }
            catch
            {
                return(View("Error"));
            }
        }
Beispiel #6
0
        public override Task <TagsView> GetByArticle(ByArticleId query, ServerCallContext context)
        {
            var result = new List <TagView>();

            foreach (var tag in _repository.All)
            {
                var articleIds = tag.ArticleTags
                                 .Select(articleTag => articleTag.ArticleId.ToString());

                if (!articleIds.Contains(query.ArticleId))
                {
                    continue;
                }

                var view = new TagView
                {
                    Id   = tag.Id.ToString(),
                    Name = tag.Name
                };
                result.Add(view);
            }

            return(Task.FromResult(new TagsView
            {
                Tags = { result }
            }));
        }
        public ActionResult <TagView> Get()
        {
            TagView tagList = new TagView {
                Tags = db.Tags.Select(t => t.TagName)
            };

            return(tagList);
        }
        public static TagModel MergeModelWithView(TagModel model, TagView view)
        {
            model.Name        = view.Name;
            model.Slug        = ConvertTextToSlug(view.ShortName);
            model.Description = view.Description;

            return(model);
        }
Beispiel #9
0
 protected void deleteTag(TagView tagView)
 {
     RemoveView(tagView);
     if (mOnTagChangeListener != null)
     {
         mOnTagChangeListener.onDelete(this, tagView.Text);
     }
 }
Beispiel #10
0
        public async Task <TagViewResponseModel> View(TagViewModel model)
        {
            Guid?userId = null;

            if (model.SessionId != null)
            {
                userId = await context.Sessions.Where(x => x.Id == model.SessionId).Select(x => x.UserId).SingleOrDefaultAsync();

                if (Guid.Empty == userId)
                {
                    userId = null;
                }
            }
            Guid tagGuid;

            if (!Guid.TryParse(model.TagId, out tagGuid))
            {
                tagGuid = await context.Tags.Where(x => x.IsDefault && x.User.Username == model.TagId).Select(x => x.Id).SingleOrDefaultAsync();
            }
            var tagOwner = await context.Tags.Where(x => x.Id == tagGuid).Select(x => x.UserId).SingleOrDefaultAsync();

            var tagView = await context.TagViews.Where(x => x.Id == model.ViewId).SingleOrDefaultAsync();

            if (tagView == null)
            {
                tagView = new TagView();
                context.TagViews.Add(tagView);
            }

            tagView.Id        = model.ViewId;
            tagView.TagId     = tagGuid;
            tagView.Page      = model.Page;
            tagView.Referrer  = model.Referrer;
            tagView.PageId    = model.PageId;
            tagView.UserId    = userId;
            tagView.Timestamp = DateTime.UtcNow;

            await context.SaveChangesAsync();

            var response = new TagViewResponseModel();

            if (userId == null)
            {
                response.HasUser = false;
                return(response);
            }
            response.HasUser = true;

            response.TotalNanrCount = await context.Clicks.Where(x => x.UserId == userId && x.Tag.UserId == tagOwner).CountAsync();


            if (!string.IsNullOrWhiteSpace(model.PageId))
            {
                response.PageNanrCount = await context.Clicks.Where(x => x.UserId == userId && x.PageId == model.PageId && x.Tag.UserId == tagOwner).CountAsync();
            }
            return(response);
        }
Beispiel #11
0
        public SIREView()
        {
            InitializeComponent();
            edenIF = new EdenIF("admin", "98321abc");

            // init child views
            ScreeningView.Init(edenIF);
            MagicFormulaView.Init(edenIF);
            TagView.Init(edenIF);
        }
Beispiel #12
0
        /**
         * Returns the INPUT state tag in this group.
         *
         * @return the INPUT state tag view or null if not exists
         */
        public string getInputTagText()
        {
            TagView inputTagView = getInputTag();

            if (inputTagView != null)
            {
                return(inputTagView.Text);
            }
            return(null);
        }
        public static TagView ConvertToView(TagModel model)
        {
            var tagView = new TagView
            {
                Id          = model.Id,
                Name        = model.Name,
                ShortName   = model.Slug,
                Description = model.Description
            };

            return(tagView);
        }
        public static TagModel ConvertToModel(TagView view)
        {
            var categoryModel = new TagModel
            {
                Name        = view.Name,
                Slug        = ConvertTextToSlug(view.ShortName),
                Description = view.Description,
                Count       = 0
            };

            return(categoryModel);
        }
Beispiel #15
0
        public static TagModel ConvertToModel(TagView result)
        {
            var categoryModel = new TagModel
            {
                Name        = result.Name,
                Slug        = ConvertTextToSlug(result.ShortName),
                Description = result.Description,
                Count       = 0
            };

            return(categoryModel);
        }
Beispiel #16
0
        public static TagView ConvertToView(TagModel result)
        {
            var tagView = new TagView
            {
                Id          = result.Id,
                Name        = result.Name,
                ShortName   = result.Slug,
                Description = result.Description
            };

            return(tagView);
        }
Beispiel #17
0
        /**
         * Return the checked tag index.
         *
         * @return the checked tag index, or -1 if not exists.
         */
        protected int getCheckedTagIndex()
        {
            int count = ChildCount;

            for (int i = 0; i < count; i++)
            {
                TagView tag = getTagAt(i);
                if (tag.isChecked)
                {
                    return(i);
                }
            }
            return(-1);
        }
Beispiel #18
0
        protected void appendInputTag(TagColor color, string tag)
        {
            TagView previousInputTag = getInputTag();

            if (previousInputTag != null)
            {
                throw new IllegalStateException("Already has a INPUT tag in group.");
            }

            TagView newInputTag = new TagView(this, Context, TagView.STATE_INPUT, color, tag);

            newInputTag.Click += NewTag_Click;

            AddView(newInputTag);
        }
Beispiel #19
0
        public PagedResults <TagView> GetTags(PagedRequest request = null)
        {
            request = request ?? new PagedRequest();
            request.Cleanup();

            var query = GetCurrentPagesQuery()
                        .Select(x => new { x.Title, x.Tags })
                        .ToList()
                        .SelectMany(x => x.Tags.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                        .GroupBy(x => x)
                        .AsQueryable();

            query = query.OrderBy(string.IsNullOrWhiteSpace(request.Order) ? "Key" : request.Order);
            return(GetPagedResults(query, request, x => TagView.Create(x.Key, x.Count())));
        }
Beispiel #20
0
        /**
         * Call this to submit the INPUT tag.
         */
        public void submitTag()
        {
            TagView inputTag = getInputTag();

            if (inputTag != null && inputTag.isInputAvailable())
            {
                inputTag.endInput();

                if (mOnTagChangeListener != null)
                {
                    mOnTagChangeListener.onAppend(this, inputTag.Text);
                }
                appendInputTag();
            }
        }
Beispiel #21
0
        /**
         * Returns the tag array in group, except the INPUT tag.
         *
         * @return the tag array.
         */
        public string[] getTags()
        {
            int           count   = ChildCount;
            List <string> tagList = new List <string>();

            for (int i = 0; i < count; i++)
            {
                TagView tagView = getTagAt(i);
                if (tagView.mState == TagView.STATE_NORMAL)
                {
                    tagList.Add(tagView.Text);
                }
            }

            return(tagList.ToArray());
        }
Beispiel #22
0
        public async Task <IActionResult> Add(TagView result)
        {
            if (await _tagService.CheckIfTagExist(result.Name))
            {
                ModelState.AddModelError("", "Tag o tej nazwie już istnieje");
            }

            if (!ModelState.IsValid)
            {
                return(View(result));
            }

            await _tagService.Create(TagHelpers.ConvertToModel(result));

            return(RedirectToAction("List"));
        }
Beispiel #23
0
        private void NewTag_Click(object sender, EventArgs e)
        {
            TagView tag = (TagView)sender;

            if (isAppendMode)
            {
                if (tag.mState == TagView.STATE_INPUT)
                {
                    // If the clicked tag is in INPUT state, uncheck the previous checked tag if exists.
                    TagView checkedTag = getCheckedTag();
                    if (checkedTag != null)
                    {
                        checkedTag.setChecked(false);
                    }
                }
                else
                {
                    // If the clicked tag is currently checked, delete the tag.
                    if (tag.isChecked)
                    {
                        deleteTag(tag);
                    }
                    else
                    {
                        // If the clicked tag is unchecked, uncheck the previous checked tag if exists,
                        // then check the clicked tag.
                        TagView checkedTag = getCheckedTag();
                        if (checkedTag != null)
                        {
                            checkedTag.setChecked(false);
                        }
                        tag.setChecked(true);
                    }
                }
            }
            else
            {
                if (mOnTagClickListener != null)
                {
                    mOnTagClickListener.onTagClick(tag.Text);
                }
            }
        }
Beispiel #24
0
 protected void AddTag_Click(object sender, EventArgs e)
 {
     /*
      * Type cstype = this.GetType();
      *
      * // Get a ClientScriptManager reference from the Page class.
      * ClientScriptManager cs = Page.ClientScript;
      *
      * // Check to see if the startup script is already registered.
      * if (!cs.IsStartupScriptRegistered(cstype, "PopupScript"))
      * {
      *  String cstext = "alert('" + sender.ToString() + "');";
      *  cs.RegisterStartupScript(cstype, "PopupScript", cstext, true);
      * }*/
     DbConn.NewConnection(Config.getConnectionString());
     DbConn.Update("INSERT INTO TAGS (TAG_NAME, TAG_DESCR) VALUES ('-', '-')");
     DbConn.Terminate();
     TagView.DataBind();
 }
Beispiel #25
0
 /**
  * Returns the INPUT tag view in this group.
  *
  * @return the INPUT state tag view or null if not exists
  */
 protected TagView getInputTag()
 {
     if (isAppendMode)
     {
         int     inputTagIndex = ChildCount - 1;
         TagView inputTag      = getTagAt(inputTagIndex);
         if (inputTag != null && inputTag.mState == TagView.STATE_INPUT)
         {
             return(inputTag);
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(null);
     }
 }
Beispiel #26
0
        public async Task <IActionResult> Edit(TagView result)
        {
            var tag = await _tagService.Get(result.Id);

            if (tag.Name != result.Name)
            {
                if (await _tagService.CheckIfTagExist(result.Name))
                {
                    ModelState.AddModelError("", "Tag o tej nazwie już istnieje");
                }
            }

            if (!ModelState.IsValid)
            {
                return(View(result));
            }


            await _tagService.Update(TagHelpers.MergeViewWithModel(tag, result));

            return(RedirectToAction("List"));
        }
Beispiel #27
0
        protected override void OnRestoreInstanceState(IParcelable state)
        {
            if (!(state is SavedState))
            {
                base.OnRestoreInstanceState(state);
                return;
            }

            SavedState ss = (SavedState)state;

            base.OnRestoreInstanceState(ss.SuperState);

            setTags(ss.tags);
            TagView checkedTagView = getTagAt(ss.checkedPosition);

            if (checkedTagView != null)
            {
                checkedTagView.setChecked(true);
            }
            if (getInputTag() != null)
            {
                getInputTag().Text = (ss.input);
            }
        }
Beispiel #28
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
                return;
            disposed = true;

            if (disposing) {
                Preferences.SettingChanged -= OnPreferencesChanged;
                // free managed resources
                if (rating != null){
                    rating.Dispose ();
                    rating = null;
                }
                if (description_entry != null){
                    description_entry.Dispose ();
                    description_entry = null;
                }
                if (tag_view != null) {
                    tag_view.Dispose ();
                    tag_view = null;
                }
                if (photo_view_scrolled != null) {
                    photo_view_scrolled.Dispose ();
                    photo_view_scrolled = null;
                }
                if (filmstrip != null) {
                    filmstrip.Dispose ();
                    filmstrip = null;
                }
                if (inner_vbox != null) {
                    inner_vbox.Dispose ();
                    inner_vbox = null;
                }
                if (inner_hbox != null) {
                    inner_hbox.Dispose ();
                    inner_hbox = null;
                }
            }
            // free unmanaged resources
        }
		public FullScreenView (IBrowsableCollection collection) : base ("Full Screen Mode")
		{
			Name = "FullscreenContainer";
			try {
				//scroll = new Gtk.ScrolledWindow (null, null);
				actions = new ActionGroup ("joe");
				
				actions.Add (new ActionEntry [] {
					new ActionEntry (HideToolbar, Stock.Close, 
							 Catalog.GetString ("Hide"), 
							 null, 
							 Catalog.GetString ("Hide Toolbar"), 
							 HideToolbarAction),
					new ActionEntry (ExitFullScreen, 
							 "f-spot-view-restore", 
							 Catalog.GetString ("Exit fullscreen"), 
							 null, 
							 null, 
							 ExitAction),
					new ActionEntry (SlideShow,
							 "f-spot-slideshow",
							 Catalog.GetString ("Slideshow"),
							 null,
							 Catalog.GetString ("Start slideshow"),
							 SlideShowAction),
						});

				actions.Add (new ToggleActionEntry [] {
					new ToggleActionEntry (Info,
							       Stock.Info,
							       Catalog.GetString ("Info"),
							       null,
							       Catalog.GetString ("Image Information"),
							       InfoAction,
							       false)
						});
				
				new Fader (this, 1.0, 3);
				notebook = new Notebook ();
				notebook.ShowBorder = false;
				notebook.ShowTabs = false;
				notebook.Show ();

				scroll = new ScrolledView ();
				view = new PhotoImageView (collection);
				// FIXME this should be handled by the new style setting code
				view.ModifyBg (Gtk.StateType.Normal, this.Style.Black);
				view.PointerMode = ImageView.PointerModeType.Scroll;
				this.Add (notebook);
				view.Show ();
				view.MotionNotifyEvent += HandleViewMotion;
				
				Action rotate_left = new RotateLeftAction (view.Item);
				actions.Add (rotate_left);
				
				Action rotate_right = new RotateRightAction (view.Item);
				actions.Add (rotate_right);

				scroll.ScrolledWindow.Add (view);
				HBox hhbox = new HBox ();
				hhbox.PackEnd (GetButton (HideToolbar), false, true, 0);
				hhbox.PackEnd (GetButton (Info), false, true, 0);
				hhbox.PackStart (GetButton (ExitFullScreen, true), false, false, 0);
				hhbox.PackStart (Add (new PreviousPictureAction (view.Item)), false, false, 0);
				hhbox.PackStart (GetButton (SlideShow), false, true, 0);
				hhbox.PackStart (Add (new NextPictureAction (view.Item)), false, false, 0);
				//hhbox.PackStart (Add (new AutoColor (view.Item)), false, false, 0);

				display = new TextureDisplay (view.Item);
				display.AddEvents ((int) (Gdk.EventMask.PointerMotionMask));
				display.ModifyBg (Gtk.StateType.Normal, this.Style.Black);
				display.MotionNotifyEvent += HandleViewMotion;
				Label effect = new Label (Catalog.GetString ("Slide transition: "));
				hhbox.PackStart (effect, false, false, 5);
				hhbox.PackStart (display.GetCombo (), false, false, 0);
				display.Show ();

				hhbox.PackStart (Add (new RotateLeftAction (view.Item)), false, false, 0);
				hhbox.PackStart (Add (new RotateRightAction (view.Item)), false, false, 0);
				hhbox.BorderWidth = 15;

				tag_view = new TagView ();
				hhbox.PackStart (tag_view, false, false, 0);

				//display = new ImageDisplay (view.Item);

				notebook.AppendPage (scroll, null);
				notebook.AppendPage (display, null);

				hhbox.ShowAll ();
				//scroll.ShowControls ();
				
				scroll.Show ();
				this.Decorated = false;
				this.Fullscreen ();
				this.ButtonPressEvent += HandleButtonPressEvent;
				
				view.Item.Changed += HandleItemChanged;
				view.GrabFocus ();
				
				controls = new ControlOverlay (this);
				controls.Add (hhbox);
				controls.Dismiss ();

				notebook.CurrentPage = 0;
			} catch (System.Exception e) {
				System.Console.WriteLine (e);
			}	

		}
Beispiel #30
0
        private void SetupWidgets()
        {
            histogram_expander = new Expander (Catalog.GetString ("Histogram"));
            histogram_expander.Activated += delegate (object sender, EventArgs e) {
                ContextSwitchStrategy.SetHistogramVisible (Context, histogram_expander.Expanded);
                UpdateHistogram ();
            };
            histogram_expander.StyleSet += delegate (object sender, StyleSetArgs args) {
                Gdk.Color c = this.Toplevel.Style.Backgrounds [(int)Gtk.StateType.Active];
                histogram.RedColorHint = (byte) (c.Red / 0xff);
                histogram.GreenColorHint = (byte) (c.Green / 0xff);
                histogram.BlueColorHint = (byte) (c.Blue / 0xff);
                histogram.BackgroundColorHint = 0xff;
                UpdateHistogram ();
            };
            histogram_image = new Gtk.Image ();
            histogram = new Histogram ();
            histogram_expander.Add (histogram_image);

            Add (histogram_expander);

            info_expander = new Expander (Catalog.GetString ("Image Information"));
            info_expander.Activated += delegate (object sender, EventArgs e) {
                ContextSwitchStrategy.SetInfoBoxVisible (Context, info_expander.Expanded);
            };

            Table info_table = new Table (10, 2, false);
            info_table.BorderWidth = 0;

            string name_pre = "<b>";
            string name_post = "</b>";

            name_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Name") + name_post);
            info_table.Attach (name_label, 0, 1, 0, 1, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

            version_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Version") + name_post);
            info_table.Attach (version_label, 0, 1, 1, 2, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

            date_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Date") + name_post + Environment.NewLine);
            info_table.Attach (date_label, 0, 1, 2, 3, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

            size_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Size") + name_post);
            info_table.Attach (size_label, 0, 1, 3, 4, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

            default_exposure_string = name_pre + Catalog.GetString ("Exposure") + name_post;
            exposure_label = CreateRightAlignedLabel (default_exposure_string);
            info_table.Attach (exposure_label, 0, 1, 4, 5, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

            focal_length_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Focal Length") + name_post);
            info_table.Attach (focal_length_label, 0, 1, 5, 6, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

            camera_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Camera") + name_post);
            info_table.Attach (camera_label, 0, 1, 6, 7, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

            file_size_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("File Size") + name_post);
            info_table.Attach (file_size_label, 0, 1, 7, 8, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

            rating_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Rating") + name_post);
            info_table.Attach (rating_label, 0, 1, 8, 9, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
            rating_label.Visible = false;

            name_value_label = new Label ();
            name_value_label.Ellipsize = Pango.EllipsizeMode.Middle;
            name_value_label.Justify = Gtk.Justification.Left;
            name_value_label.Selectable = true;
            name_value_label.Xalign = 0;
            name_value_label.PopulatePopup += HandlePopulatePopup;

            info_table.Attach (name_value_label, 1, 2, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 3, 0);

            date_value_label = AttachLabel (info_table, 2, name_value_label);
            size_value_label = AttachLabel (info_table, 3, name_value_label);
            exposure_value_label = AttachLabel (info_table, 4, name_value_label);

            version_list = new ListStore (typeof (uint), typeof (string), typeof (bool));
            version_combo = new ComboBox ();
            CellRendererText version_name_cell = new CellRendererText ();
            version_name_cell.Ellipsize = Pango.EllipsizeMode.End;
            version_combo.PackStart (version_name_cell, true);
            version_combo.SetCellDataFunc (version_name_cell, new CellLayoutDataFunc (VersionNameCellFunc));
            version_combo.Model = version_list;
            version_combo.Changed += OnVersionComboChanged;
            info_table.Attach (version_combo, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

            date_value_label.Text = Environment.NewLine;
            exposure_value_label.Text = Environment.NewLine;
            focal_length_value_label = AttachLabel (info_table, 5, name_value_label);
            camera_value_label = AttachLabel (info_table, 6, name_value_label);
            file_size_value_label = AttachLabel (info_table, 7, name_value_label);

            Gtk.Alignment rating_align = new Gtk.Alignment( 0, 0, 0, 0);
            info_table.Attach (rating_align, 1, 2, 8, 9, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

            rating_view = new RatingSmall ();
            rating_view.Visible = false;
            rating_view.Changed += HandleRatingChanged;
            rating_align.Add (rating_view);

            tag_view = new TagView (MainWindow.ToolTips);
            info_table.Attach (tag_view, 0, 2, 9, 10, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

            info_table.ShowAll ();

            EventBox eb = new EventBox ();
            eb.Add (info_table);
            info_expander.Add (eb);
            eb.ButtonPressEvent += HandleButtonPressEvent;

            Add (info_expander);
            rating_label.Visible = show_rating;
            rating_view.Visible = show_rating;
        }
Beispiel #31
0
        /// <summary>
        /// Convert a <see cref="Tag"/> to a <see cref="TagView"/> for UI.
        /// </summary>
        /// <param name="t">The tag to convert</param>
        /// <returns>return the <see cref="TagView"/> representing the Tag.</returns>
        private TagView ConvertToTagView(Tag t)
        {
            //Find and clean all the deleted folder that are still tag.
            FindAndCleanDeletedPaths();
            //Create the Tag View

            //Convert the path.
            List<string>[] pathList = ProfilingLayer.Instance.ConvertAndFilter(t.FilteredPathListString);
            //a list of available path
            PathGroupView availGrpView = new PathGroupView("Available");
            List<PathView> pathViewList = new List<PathView>();
            foreach (string path in pathList[0])
            {
                PathView p = new PathView(path);
                if (!Directory.Exists(path))
                {
                    p.IsMissing = false;
                }
                pathViewList.Add(p);
            }
            availGrpView.PathList = pathViewList;
            TagView view = new TagView(t.TagName, t.LastUpdatedDate);
            view.GroupList.Add(availGrpView);

            view.Created = t.CreatedDate;
            view.IsQueued = CompareAndSyncController.Instance.IsQueued(t.TagName);
            view.IsSyncing = CompareAndSyncController.Instance.IsSyncing(t.TagName);

            view.TagState = GetTagState(view.TagName);
            return view;
        }
	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 ();};
	}
Beispiel #33
0
        public PhotoView(IBrowsableCollection query)
        {
            Query = query;

            commit_delay = new DelayedOperation (1000, new GLib.IdleHandler (CommitPendingChanges));
            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);

            inner_vbox = new VBox (false , 2);
            inner_hbox = new HBox (false , 2);

            frame.Add (inner_hbox);

            BrowsablePointer bp = new BrowsablePointer (query, -1);
            View = new PhotoImageView (bp);

            filmstrip = new Filmstrip (bp);
            filmstrip.ThumbOffset = 1;
            filmstrip.Spacing = 4;
            filmstrip.ThumbSize = 75;
            PlaceFilmstrip ((Orientation) Preferences.Get <int> (Preferences.FILMSTRIP_ORIENTATION), true);

            View.PhotoChanged += HandlePhotoChanged;

            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 (View);
            photo_view_scrolled.Child.ButtonPressEvent += HandleButtonPressEvent;
            View.AddEvents ((int) EventMask.KeyPressMask);
            inner_vbox.PackStart (photo_view_scrolled, true, true, 0);
            inner_hbox.PackStart (inner_vbox, true, true, 0);

            HBox lower_hbox = new HBox (false, 2);
            //inner_hbox.BorderWidth = 6;

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

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

            rating = new RatingEntry {
                HasFrame = false,
                AlwaysShowEmptyStars = true
            };
            lower_hbox.PackStart (rating, false, false, 0);
            rating.Changed += HandleRatingChanged;

            SetColors ();

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

            vbox.ShowAll ();

            Realized += (o, e) => SetColors();
            Preferences.SettingChanged += OnPreferencesChanged;
        }
		private void SetupWidgets ()
		{

			histogram_expander = new Expander (Catalog.GetString ("Histogram"));
			histogram_expander.Activated += delegate (object sender, EventArgs e) { 
				ContextSwitchStrategy.SetHistogramVisible (Context, histogram_expander.Expanded);
				UpdateHistogram ();
			};
			histogram_image = new Gtk.Image ();
			histogram = new Histogram ();
			histogram_expander.Add (histogram_image);

			Window window = MainWindow.Toplevel.Window;
			Gdk.Color c = window.Style.Backgrounds [(int)Gtk.StateType.Active];
			histogram.RedColorHint = (byte) (c.Red / 0xff);
			histogram.GreenColorHint = (byte) (c.Green / 0xff);
			histogram.BlueColorHint = (byte) (c.Blue / 0xff);
			histogram.BackgroundColorHint = 0xff;

			Add (histogram_expander);

			info_expander = new Expander (Catalog.GetString ("Image Information"));
			info_expander.Activated += delegate (object sender, EventArgs e) {
				ContextSwitchStrategy.SetInfoBoxVisible (Context, info_expander.Expanded);
			};

			Table info_table = new Table (7, 2, false);
			info_table.BorderWidth = 0;
	
			string name_pre = "<b>";
			string name_post = "</b>";

			name_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Name") + name_post);
			info_table.Attach (name_label, 0, 1, 0, 1, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

			version_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Version") + name_post); 
			info_table.Attach (version_label, 0, 1, 1, 2, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

			date_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Date") + name_post + Environment.NewLine);
			info_table.Attach (date_label, 0, 1, 2, 3, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

			size_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Size") + name_post);
			info_table.Attach (size_label, 0, 1, 3, 4, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);

			default_exposure_string = name_pre + Catalog.GetString ("Exposure") + name_post;
			exposure_label = CreateRightAlignedLabel (default_exposure_string);
			info_table.Attach (exposure_label, 0, 1, 4, 5, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
			
			rating_label = CreateRightAlignedLabel (name_pre + Catalog.GetString ("Rating") + name_post);
			info_table.Attach (rating_label, 0, 1, 5, 6, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
			rating_label.Visible = false;

			name_value_label = new Label ();
			name_value_label.Ellipsize = Pango.EllipsizeMode.Middle;
			name_value_label.Justify = Gtk.Justification.Left;
			name_value_label.Selectable = true;
			name_value_label.Xalign = 0;
			info_table.Attach (name_value_label, 1, 2, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 3, 0);
			
			date_value_label = AttachLabel (info_table, 2, name_value_label);
			size_value_label = AttachLabel (info_table, 3, name_value_label);
			exposure_value_label = AttachLabel (info_table, 4, name_value_label);
	
			version_option_menu = new OptionMenu ();
			info_table.Attach (version_option_menu, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
	
			date_value_label.Text = Environment.NewLine;
			exposure_value_label.Text = Environment.NewLine;

			Gtk.Alignment rating_align = new Gtk.Alignment( 0, 0, 0, 0);
			info_table.Attach (rating_align, 1, 2, 5, 6, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
			
			rating_view = new RatingSmall ();
			rating_view.Visible = false;
			rating_view.Changed += HandleRatingChanged;
			rating_align.Add (rating_view);

			tag_view = new TagView (MainWindow.ToolTips);
			info_table.Attach (tag_view, 0, 2, 6, 7, AttachOptions.Fill, AttachOptions.Fill, TABLE_XPADDING, TABLE_YPADDING);
			tag_view.Show ();

			info_table.ShowAll ();
	
			info_expander.Add (info_table);
			Add (info_expander);
			rating_label.Visible = show_rating;
			rating_view.Visible = show_rating;
		}