private static void CreateImageButton(ImageButtons type, int width, int height)
 {
     ImageButton button = ImageButtonFactory.Create(type);
     if (!Script.IsNullOrUndefined(width))
     {
         button.SetSize(width, height);
     }
     AddButton(button);
 }
        public static void InsertButton(ImageButtons type, string replaceSeletor, int size, EventHandler onClick)
        {
            // Create the buttons.
            ImageButton button = ImageButtonFactory.Create(type);
            button.BackgroundHighlighting = true;
            button.SetSize(size, size);

            // Setup CSS.
            ButtonView view = button.CreateView() as ButtonView;

            // Wire up events.
            button.Click += onClick;

            // Insert the button.
            view.Insert(replaceSeletor, InsertMode.Replace);
            view.UpdateLayout();
        }
Ejemplo n.º 3
0
        private void DeleteTag(object obj)
        {
            var ibvm = obj as TagButtonViewModel;

            if (ibvm == null)
            {
                return;
            }

            OmniTags.Remove(ibvm.CurrentTag);
            ImageButtons.Remove(ibvm);
            if (!AddedTags.Remove(ibvm.CurrentTag))
            {
                DeletedTags.Add(ibvm.CurrentTag);
            }
            ChangesMade = true;
        }
Ejemplo n.º 4
0
        private void AddTag()
        {
            if (TagSearchText.IsEmpty())
            {
                return;
            }
            if (TagSearchText.Length > 20)
            {
                MessageBox.Show("Tag name cannot be longer than 20 characters (including space).",
                                "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                return;
            }
            if (OmniTags.Any(t => t.Name.Equals(TagSearchText, StringComparison.CurrentCultureIgnoreCase)))
            {
                MessageBox.Show($"This Omni is already associated with the \"{TagSearchText}\" tag.",
                                "Warning", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                return;
            }
            var tag = Context.Tags.SingleOrDefault(t => t.Name == TagSearchText);

            if (tag == null)
            {
                tag = new Tag
                {
                    Name             = TagSearchText,
                    Description      = null,
                    IsVerified       = false,
                    DateCreated      = DateTime.Now,
                    LastModifiedDate = DateTime.Now
                };
                AddedTags.Add(tag);
            }
            tag.DateDeleted = null; // undelete the tag (if it was in the DB but deleted)
            var buttonVm = new TagButtonViewModel(tag);

            OmniTags.Add(tag);
            ImageButtons.Add(buttonVm);
            TagSearchText = "";
            ChangesMade   = true;
        }
        /// <summary>Factory method for creating an pre-canned image button.</summary>
        /// <param name="type">Flag indicating the type of button to create.</param>
        public static ImageButton Create(ImageButtons type)
        {
            // Setup initial conditions.
            ImageButton button = new ImageButton();
            button.CanFocus = false;

            // Configure image URL's.
            switch (type)
            {
                case ImageButtons.PlusDark: InitFlatDark(button, "Plus"); break;
                case ImageButtons.PlayDark: InitFlatDark(button, "Play"); break;
                case ImageButtons.RefreshDark: InitFlatDark(button, "Refresh"); break;
                case ImageButtons.SearchDark: InitFlatDark(button, "Search"); break;
                case ImageButtons.PushPin: InitPushPin(button); break;
                case ImageButtons.Remove: InitRemove(button); break;

                default: throw new Exception("ImageButton not supported: " + type.ToString());
            }

            // Finish up.
            return button;
        }
 private static extern void CreateImageButton(ImageButtons type);