private IEnumerator <YieldAction> doUpdateThumbnails()
        {
            imageGrid.clear();
            yield return(Coroutine.WaitSeconds(0.1f));

            foreach (ThumbnailPickerInfo thumbProp in thumbnailProperties)
            {
                if (imageGrid == null)
                {
                    yield break;
                }

                String imageId;
                using (FreeImageBitmap thumb = imageRenderer.renderImage(thumbProp.ImageProperties))
                {
                    imageId = thumbnailImages.addImage(thumb, thumb);
                }

                imageGrid.SuppressLayout = true;
                ButtonGridItem item = imageGrid.addItem("Main", "", imageId);
                item.UserObject = thumbProp;

                imageGrid.SuppressLayout = false;
                imageGrid.layout();

                if (imageGrid.Count == 1) //Select first item
                {
                    imageGrid.SelectedItem = imageGrid.getItem(0);
                }

                yield return(Coroutine.WaitSeconds(0.1f));
            }
        }
예제 #2
0
        void anatomyList_ItemAdded(ButtonGrid arg1, ButtonGridItem arg2)
        {
            Anatomy anatomy = (Anatomy)arg2.UserObject; //Ok to access user object here since it is set during the add.
            Radian  theta   = sceneViewController.ActiveWindow.Camera.getFOVy();

            //Generate thumbnail
            AxisAlignedBox boundingBox = anatomy.WorldBoundingBox;
            Vector3        center      = boundingBox.Center;

            //PROBABLY DON'T NEED THIS, ASPECT IS A SQUARE
            float aspectRatio = (float)ThumbSize / ThumbSize;

            if (aspectRatio < 1.0f)
            {
                theta *= aspectRatio;
            }

            Vector3 translation = center;
            Vector3 direction   = anatomy.PreviewCameraDirection;

            translation += direction * boundingBox.DiagonalDistance / (float)Math.Tan(theta);

            LayerState layers = new LayerState(anatomy.TransparencyNames, 1.0f);

            buttonGridThumbs.itemAdded(arg2, layers, translation, center, anatomy);
        }
예제 #3
0
        /// <summary>
        /// This function will make sure the selected item on the button grid is fully visible.
        /// </summary>
        private void ensureSelectedItemVisible()
        {
            ButtonGridItem selectedItem = slideGrid.SelectedItem;

            if (selectedItem != null)
            {
                IntRect  selectedItemLocation = new IntRect(selectedItem.Left, selectedItem.Top, selectedItem.Width, selectedItem.Height);
                IntCoord clientCoord          = scroll.ClientCoord;
                IntCoord viewCoord            = scroll.ViewCoord;
                selectedItemLocation.Left += clientCoord.left;
                selectedItemLocation.Top  += clientCoord.top;
                if (selectedItemLocation.Top < 0)
                {
                    IntVector2 canvasPos = scroll.CanvasPosition;
                    canvasPos.y          += selectedItemLocation.Top;
                    scroll.CanvasPosition = canvasPos;
                }
                else if (selectedItemLocation.Bottom > viewCoord.height)
                {
                    IntVector2 canvasPos = scroll.CanvasPosition;
                    canvasPos.y          += (selectedItemLocation.Bottom - viewCoord.height);
                    scroll.CanvasPosition = canvasPos;
                }
            }
        }
예제 #4
0
        private ColorMenu(ColorChosenDelegate colorChosenCallback, Action colorClearedCallback)
            : base("Anomalous.GuiFramework.GUI.ColorMenu.ColorMenu.layout")
        {
            this.colorChosenCallback  = colorChosenCallback;
            this.colorClearedCallback = colorClearedCallback;

            colorGrid = new SingleSelectButtonGrid(widget.findWidget("ColorGrid") as ScrollView);
            for (int i = 0; i < 77; ++i)
            {
                ButtonGridItem item = colorGrid.addItem("Main", "", "Colors/" + i);
                item.UserObject = i;
            }
            colorGrid.SelectedValueChanged += new EventHandler(colorGrid_SelectedValueChanged);

            Button moreColorsButton = widget.findWidget("MoreColorsButton") as Button;

            if (RuntimePlatformInfo.ShowMoreColors)
            {
                moreColorsButton.MouseButtonClick += new MyGUIEvent(moreColorsButton_MouseButtonClick);
            }
            else
            {
                moreColorsButton.Visible = false;
                widget.setSize(widget.Width, widget.Height - (widget.Height - moreColorsButton.Top));
            }

            this.Hidden += new EventHandler(ColorMenu_Hidden);

            Button clearColorButton = (Button)widget.findWidget("ClearColorButton");

            clearColorButton.Visible           = colorClearedCallback != null;
            clearColorButton.MouseButtonClick += clearColorButton_MouseButtonClick;
        }
예제 #5
0
        void item_MouseDrag(ButtonGridItem source, MouseEventArgs arg)
        {
            if (bookmarksController.PremiumBookmarks)
            {
                dragIconPreview.setPosition(arg.Position.x - (dragIconPreview.Width / 2), arg.Position.y - (int)(dragIconPreview.Height * .75f));
                if (!dragIconPreview.Visible && (Math.Abs(dragMouseStartPosition.x - arg.Position.x) > 5 || Math.Abs(dragMouseStartPosition.y - arg.Position.y) > 5))
                {
                    dragIconPreview.Visible = true;
                    dragIconPreview.setImageTexture(liveThumbController.getTextureName(source));
                    dragIconPreview.setImageCoord(liveThumbController.getTextureCoord(source));
                    LayerManager.Instance.upLayerItem(dragIconPreview);
                }

                int x = arg.Position.x;
                int y = arg.Position.y;

                BookmarksTreeNode node = null;
                if (folderTree.contains(x, y))
                {
                    node = folderTree.itemAt(x, y) as BookmarksTreeNode;
                }
                if (node != currentDragNode)
                {
                    if (currentDragNode != null)
                    {
                        currentDragNode.showHover(false);
                    }
                    currentDragNode = node;
                    if (currentDragNode != null)
                    {
                        currentDragNode.showHover(true);
                    }
                }
            }
        }
예제 #6
0
 void item_MouseButtonReleased(ButtonGridItem source, MouseEventArgs arg)
 {
     if (bookmarksController.PremiumBookmarks)
     {
         if (dragIconPreview.Visible)
         {
             wasDragging = true;
             dragIconPreview.setItemResource(null);
             dragIconPreview.Visible = false;
             IntVector2 mousePos = arg.Position;
             if (currentDragNode != null)
             {
                 BookmarkPath path     = currentDragNode.UserData as BookmarkPath;
                 Bookmark     bookmark = liveThumbController.getUserObject(source);
                 currentDragNode.showHover(false);
                 try
                 {
                     bookmarksController.moveBookmark(path, bookmark);
                 }
                 catch (Exception ex)
                 {
                     MessageBox.show(String.Format("There was an error moving this bookmark."), "Move Error", MessageBoxStyle.IconError | MessageBoxStyle.Ok);
                     Log.Error("Exception moving bookmark. Type {0}. Message {1}.", ex.GetType().ToString(), ex.Message);
                 }
             }
         }
     }
 }
 void dragItems_ItemActivated(ButtonGridItem item)
 {
     if (item != null)
     {
         view._fireItemActivated((DragAndDropItem)item.UserObject);
     }
 }
예제 #8
0
        void stateController_StateUpdated(MedicalState state)
        {
            ButtonGridItem entry = entries[state];

            entry.Caption = state.Name;
            //imageAtlas.replaceImage(state, state.Thumbnail);
        }
        private void addDocument(string document)
        {
            ButtonGridItem item = documentGrid.insertItem(0, documentController.getFileTypePrettyName(document), Path.GetFileNameWithoutExtension(document), documentController.getFileTypeIcon(document));

            item.UserObject = document;
            documentsToItems.Add(document, item);
        }
예제 #10
0
 private void toggleAnatomyTransparency(ButtonGridItem item)
 {
     if (item != null)
     {
         Anatomy selectedAnatomy = buttonGridThumbs.getUserObject(item);
         if (anatomyController.ShowPremiumAnatomy || selectedAnatomy.ShowInBasicVersion)
         {
             if (selectedAnatomy.CurrentAlpha >= 0.9999f)
             {
                 selectedAnatomy.smoothBlend(0.7f, MedicalConfig.CameraTransitionTime, EasingFunction.EaseOutQuadratic);
             }
             else if (selectedAnatomy.CurrentAlpha <= 0.00008f)
             {
                 selectedAnatomy.smoothBlend(1.0f, MedicalConfig.CameraTransitionTime, EasingFunction.EaseOutQuadratic);
             }
             else
             {
                 selectedAnatomy.smoothBlend(0.0f, MedicalConfig.CameraTransitionTime, EasingFunction.EaseOutQuadratic);
             }
         }
         else
         {
             showBuyMessage();
         }
     }
 }
예제 #11
0
        void taskController_TaskAdded(Task task)
        {
            if (task.ShowOnTaskMenu)
            {
                task.IconChanged       += task_IconChanged;
                iconGrid.SuppressLayout = true;
                ButtonGridItem item = iconGrid.addItem(task.Category, task.Name, task.IconName);
                item.UserObject            = task;
                item.ItemClicked          += new EventHandler(item_ItemClicked);
                task.RequestShowInTaskbar += new TaskDelegate(taskItem_RequestShowInTaskbar);
                item.MouseButtonPressed   += new EventDelegate <ButtonGridItem, MouseEventArgs>(item_MouseButtonPressed);
                item.MouseDrag            += new EventDelegate <ButtonGridItem, MouseEventArgs>(item_MouseDrag);
                item.MouseButtonReleased  += new EventDelegate <ButtonGridItem, MouseEventArgs>(item_MouseButtonReleased);
                iconGrid.SuppressLayout    = false;
                iconGrid.resizeAndLayout();
                realTaskItems.Add(item);

                //Does this task match search results
                String searchText = searchBox.OnlyText;

                if (!String.IsNullOrWhiteSpace(searchText))
                {
                    searchText = searchText.ToLowerInvariant();
                    if (task.Name.ToLowerInvariant().Contains(searchText))
                    {
                        createSearchTaskItem(task);
                    }
                }
            }
        }
예제 #12
0
        public void setHighlightTasks(String highlightSectionTitle, IEnumerable <Task> tasks)
        {
            iconGrid.SuppressLayout = true;
            addGroupsToSortList     = false;

            foreach (var item in highlightCategoryItems)
            {
                iconGrid.removeItem(item);
            }

            highlightCategoryItems.Clear();

            this.highlightSectionTitle = highlightSectionTitle;

            if (tasks != null)
            {
                foreach (var task in tasks)
                {
                    ButtonGridItem item = iconGrid.addItem(highlightSectionTitle, task.Name, task.IconName);
                    item.UserObject           = task;
                    item.ItemClicked         += new EventHandler(item_ItemClicked);
                    item.MouseButtonPressed  += new EventDelegate <ButtonGridItem, MouseEventArgs>(item_MouseButtonPressed);
                    item.MouseDrag           += new EventDelegate <ButtonGridItem, MouseEventArgs>(item_MouseDrag);
                    item.MouseButtonReleased += new EventDelegate <ButtonGridItem, MouseEventArgs>(item_MouseButtonReleased);
                    highlightCategoryItems.Add(item);
                }
            }

            addGroupsToSortList     = true;
            iconGrid.SuppressLayout = false;
            iconGrid.resizeAndLayout();
        }
예제 #13
0
        void addSlideToGrid(Slide slide, int index)
        {
            ButtonGridItem item;

            if (index == -1)
            {
                item = slideGrid.addItem("", "Slide " + (slideGrid.Count + 1));
            }
            else
            {
                slideGrid.SuppressLayout = true;
                item = slideGrid.insertItem(index, "", "Slide " + (index + 1));
                foreach (ButtonGridItem laterItem in slideGrid.Items.Skip(++index))
                {
                    laterItem.Caption = "Slide " + ++index;
                }
                slideGrid.SuppressLayout = false;
                slideGrid.layout();
            }
            item.UserObject = slide;
            slideImageManager.loadThumbnail(slide, (loadedThumbSlide, id) =>
            {
                //Ensure that the item still exists
                ButtonGridItem imageUpdateItem = slideGrid.findItemByUserObject(loadedThumbSlide);
                if (imageUpdateItem != null)
                {
                    imageUpdateItem.setImage(id);
                }
            });
            item.MouseButtonPressed  += item_MouseButtonPressed;
            item.MouseButtonReleased += item_MouseButtonReleased;
            item.MouseDrag           += item_MouseDrag;
        }
예제 #14
0
 void item_MouseButtonPressed(ButtonGridItem source, MouseEventArgs arg)
 {
     dragMouseStartPosition = arg.Position;
     firstDrag      = true;
     dragHoverIndex = -1;
     dragHoverItem  = null;
 }
        private void removeDocument(string document)
        {
            ButtonGridItem item = documentsToItems[document];

            documentGrid.removeItem(item);
            documentsToItems.Remove(document);
        }
예제 #16
0
 public IntCoord getTextureCoord(ButtonGridItem item)
 {
     if (item != null)
     {
         return(((ButtonGridItemLiveThumbnailHost)item.UserObject).TextureCoord);
     }
     return(default(IntCoord));
 }
예제 #17
0
 public String getTextureName(ButtonGridItem item)
 {
     if (item != null)
     {
         return(((ButtonGridItemLiveThumbnailHost)item.UserObject).TextureName);
     }
     return(null);
 }
예제 #18
0
 public UserObjectType getUserObject(ButtonGridItem item)
 {
     if (item != null)
     {
         return(((ButtonGridItemLiveThumbnailHost)item.UserObject).UserObject);
     }
     return(default(UserObjectType));
 }
예제 #19
0
 void imageGrid_ItemActivated(ButtonGridItem item)
 {
     if (SelectedValue != null)
     {
         Accepted = true;
         close();
     }
 }
예제 #20
0
 void item_MouseButtonReleased(ButtonGridItem source, MouseEventArgs arg)
 {
     dragIconPreview.Visible = false;
     if (TaskItemDropped != null)
     {
         TaskItemDropped.Invoke((Task)source.UserObject, arg.Position);
     }
 }
예제 #21
0
        void bookmarksController_BookmarkRemoved(Bookmark bookmark)
        {
            ButtonGridItem item = liveThumbController.findItemByUserObject(bookmark);

            if (item != null)
            {
                bookmarksList.removeItem(item);
            }
        }
예제 #22
0
        void slideImageManager_ThumbUpdating(Slide slide)
        {
            ButtonGridItem item = slideGrid.findItemByUserObject(slide);

            if (item != null)
            {
                item.setImage(null); //Null the image or else the program gets crashy
            }
        }
예제 #23
0
        void slideImageManager_ThumbUpdated(Slide slide, String key)
        {
            ButtonGridItem item = slideGrid.findItemByUserObject(slide);

            if (item != null)
            {
                item.setImage(key);
            }
        }
예제 #24
0
        private void showEditorsForSelectedSlide()
        {
            ButtonGridItem item = slideGrid.SelectedItem;

            if (item != null)
            {
                slideEditController.editSlide((Slide)item.UserObject);
            }
        }
예제 #25
0
        private void addMedicalState(MedicalState state)
        {
            String         imageId = imageAtlas.addImage(state, state.Thumbnail);
            ButtonGridItem entry   = stateListBox.addItem("", state.Name, imageId);

            entry.UserObject = state;
            entries.Add(state, entry);
            entry.ItemClicked += entry_ItemClicked;
        }
예제 #26
0
 void item_ItemClicked(object sender, EventArgs e)
 {
     if (!wasDragging)
     {
         ButtonGridItem listItem = (ButtonGridItem)sender;
         Bookmark       bookmark = liveThumbController.getUserObject(listItem);
         bookmarksController.applyBookmark(bookmark);
         this.hide();
     }
 }
예제 #27
0
        void item_MouseButtonPressed(ButtonGridItem source, MouseEventArgs arg)
        {
            var localPosition = arg.Position;

            localPosition.x -= source.AbsoluteLeft;
            localPosition.y -= source.AbsoluteTop;

            allowIconDrag = localPosition.x < dragAreaSize.x && localPosition.y < dragAreaSize.y;

            dragMouseStartPosition = arg.Position;
        }
예제 #28
0
        public void addItemTemplate(AddItemTemplate itemTemplate)
        {
            itemTemplate.reset();
            ButtonGridItem item = itemGrid.addItem(itemTemplate.Group, itemTemplate.TypeName, itemTemplate.ImageName);

            item.UserObject = itemTemplate;
            if (itemGrid.SelectedItem == null)
            {
                itemGrid.SelectedItem = item;
            }
        }
예제 #29
0
        private void createSearchTaskItem(Task task)
        {
            ButtonGridItem item = iconGrid.addItem(SearchResultsCategory, task.Name, task.IconName);

            item.UserObject           = task;
            item.ItemClicked         += new EventHandler(item_ItemClicked);
            item.MouseButtonPressed  += new EventDelegate <ButtonGridItem, MouseEventArgs>(item_MouseButtonPressed);
            item.MouseDrag           += new EventDelegate <ButtonGridItem, MouseEventArgs>(item_MouseDrag);
            item.MouseButtonReleased += new EventDelegate <ButtonGridItem, MouseEventArgs>(item_MouseButtonReleased);
            searchResults.Add(item);
        }
예제 #30
0
        void bookmarksController_BookmarkAdded(Bookmark bookmark)
        {
            ButtonGridItem item = bookmarksList.addItem("User", bookmark.Name);

            item.ItemClicked         += new EventHandler(item_ItemClicked);
            item.MouseDrag           += new EventDelegate <ButtonGridItem, MouseEventArgs>(item_MouseDrag);
            item.MouseButtonReleased += new EventDelegate <ButtonGridItem, MouseEventArgs>(item_MouseButtonReleased);
            item.MouseButtonPressed  += new EventDelegate <ButtonGridItem, MouseEventArgs>(item_MouseButtonPressed);
            item.UserObject           = bookmark;
            liveThumbController.itemAdded(item, bookmark.Layers, bookmark.CameraPosition.Translation, bookmark.CameraPosition.LookAt, bookmark);
        }