public async Task <HttpResponseMessage> RemoveMenuItemImage(LibBookingService.Dtos.Image image)
        {
            try
            {
                Image img = await _db.Images.Where(i => i.Id == image.Id).FirstOrDefaultAsync();

                img.Deleted = true;

                _db.SetModified(img);
                await _db.SaveChangesAsync();

                MenuItemImage resImg = await _db.MenuItemImages.Where(i => i.Image_id == image.Id && i.MenuItem_id == image.Source).FirstOrDefaultAsync();

                resImg.Deleted = true;

                _db.SetModified(resImg);
                await _db.SaveChangesAsync();

                return(Request.CreateResponse(HttpStatusCode.OK, "Success"));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Failed"));
            }
        }
예제 #2
0
        private static void OnCommandChanged(DependencyObject a_dependencyObject, DependencyPropertyChangedEventArgs a_e)
        {
            MenuItem menuItem = a_dependencyObject as MenuItem;

            if (menuItem == null)
            {
                throw new InvalidOperationException(@"MenuItem required");
            }

            ICommand oldCommand = a_e.OldValue as ICommand;

            if (oldCommand != null)
            {
                menuItem.Command = null;
                menuItem.Icon    = null;
                CommandToolTipHelper.ApplyCommandToolTip(menuItem, null);

                ICommandDescriptionProvider oldDescProvider = a_e.OldValue as ICommandDescriptionProvider;
                if (GetOverrideHeader(menuItem) && oldDescProvider != null)
                {
                    BindingOperations.ClearBinding(
                        menuItem,
                        MenuItem.HeaderProperty);
                }
            }

            ICommand newCommand = a_e.NewValue as ICommand;

            if (newCommand != null)
            {
                menuItem.Command = newCommand;

                Uri imageUri = CommandImageHelper.GetCommandImageUri(newCommand);
                if (imageUri != null)
                {
                    MenuItemImage image = new MenuItemImage
                    {
                        Source = new BitmapImage(imageUri)
                    };
                    menuItem.Icon = image;
                }

                // Header
                ICommandDescriptionProvider newDescProvider = a_e.NewValue as ICommandDescriptionProvider;
                if (GetOverrideHeader(menuItem) && newDescProvider != null)
                {
                    BindingOperations.SetBinding(
                        menuItem,
                        MenuItem.HeaderProperty,
                        new Binding("Text")
                    {
                        Source = newDescProvider.Description
                    });
                }

                // tooltip
                CommandToolTipHelper.ApplyCommandToolTip(menuItem, newCommand);
            }
        }
예제 #3
0
        public void Refresh()
        {
            _root.GetChildren().ForEach(x => x.Dispose());
            _root.Clear();
            MenuItemImage loading = new MenuItemImage("loadingGif");

            _root.AddChild(2, 2, 2, 5, loading);
            loading.SetGif(GetLoadingGif(), 12);

            _requests = _api.DefaultApps.Friends.GetFriendRequests().Wait();

            _root.Clear();
            loading.Dispose();

            RenderPage(0);
        }
예제 #4
0
        public void Refresh()
        {
            _root.GetChildren().ForEach(x => x.Dispose());
            _root.Clear();
            MenuItemImage loading = new MenuItemImage("loadingGif");

            _root.AddChild(2, 2, 2, 5, loading);
            loading.SetGif(GetLoadingGif(), 12);

            _users = _api.User.CurrentRoomUsers().Wait().Users.ToList();
            _users.Remove(_users.Find(x => x.UserId == _api.User.UserId));
            _friends = _api.DefaultApps.Friends.ListFriends().Wait().Select(x => x.UserId).ToList();

            _root.Clear();
            loading.Dispose();

            RenderPage(0);
        }
예제 #5
0
        /// <summary>
        /// Returns the ContextMenu used when the user Right-Click on a selected cell.
        /// </summary>
        /// <returns></returns>
        public virtual MenuCollection GetContextMenus()
        {
            MenuCollection l_Array = new MenuCollection();

            bool l_EnableCopyPasteSelection = false;

            if ((m_Grid.ContextMenuStyle & ContextMenuStyle.CopyPasteSelection) == ContextMenuStyle.CopyPasteSelection)
            {
                l_EnableCopyPasteSelection = true;
            }

            bool l_EnableClearSelection = false;

            if ((m_Grid.ContextMenuStyle & ContextMenuStyle.ClearSelection) == ContextMenuStyle.ClearSelection)
            {
                l_EnableClearSelection = true;
            }

//			bool l_EnablePropertySelection = false;
//			if ( (m_Grid.ContextMenuStyle & ContextMenuStyle.PropertySelection) == ContextMenuStyle.PropertySelection)
//				l_EnablePropertySelection = true;

            if (m_ContextMenuItems != null && m_ContextMenuItems.Count > 0)
            {
                foreach (MenuItem m in m_ContextMenuItems)
                {
                    l_Array.Add(m);
                }

                if (l_EnableClearSelection || l_EnableCopyPasteSelection)                  //|| l_EnablePropertySelection)
                {
                    l_Array.Add(new MenuItem("-"));
                }
            }

            if (l_EnableCopyPasteSelection)
            {
//				//CUT (not implemented)
//				MenuItem l_mnCut = new MenuItemImage("Cut", new EventHandler(Selection_Cut), m_MenuImageList, m_iImageCut);
//				l_mnCut.Enabled = false;
//				l_Array.Add(l_mnCut);

                //COPY
                MenuItem l_mnCopy = new MenuItemImage("Copy", new EventHandler(Selection_Copy), m_MenuImageList, m_iImageCopy);
                l_Array.Add(l_mnCopy);

                //PASTE
                MenuItem l_mnPaste = new MenuItemImage("Paste", new EventHandler(Selection_Paste), m_MenuImageList, m_iImagePaste);
                l_mnPaste.Enabled = IsValidClipboardForPaste();
                l_Array.Add(l_mnPaste);
            }

            if (l_EnableClearSelection)
            {
                if (l_EnableCopyPasteSelection)                // && l_EnablePropertySelection)
                {
                    l_Array.Add(new MenuItem("-"));
                }

                MenuItem l_mnClear = new MenuItemImage("Clear", new EventHandler(Selection_ClearValues), m_MenuImageList, m_iImageClear);
                l_Array.Add(l_mnClear);
            }
//			if (l_EnablePropertySelection)
//			{
//				MenuItem l_mnFormatCells = new MenuItem("Format Cells ...", new EventHandler(Selection_FormatCells));
//				m_Grid.SetMenuImage(l_mnFormatCells,m_iImageFormatCells);
//				l_Array.Add(l_mnFormatCells);
//			}

            return(l_Array);
        }
예제 #6
0
 private void CreateLoadinGif()
 {
     _loading = new MenuItemImage("loading");
     _roomListGrid.AddChild(2, 2, 2, 5, _loading);
     _loading.SetGif(GetLoadingGif(), 12);
 }