Exemple #1
0
        private void btnFavorite_MouseMove(object sender, MouseEventArgs e)
        {
            if (m_holdFavorite != null && !m_bStartDrag && m_lastPoint != e.Location)
            {
                bool bAllowDrag = false;
                if (Math.Abs(e.Location.X - m_lastPoint.X) >= C_ABS_LIMITED_X_AXIS)
                {
                    bAllowDrag = true;
                }

                if (!bAllowDrag && Math.Abs(e.Location.Y - m_lastPoint.Y) >= C_ABS_LIMITED_Y_AXIS)
                {
                    bAllowDrag = true;
                }

                if (!bAllowDrag)
                {
                    return;
                }

                m_bStartDrag = true;
                if (DoDragDrop(m_holdFavorite, DragDropEffects.Move) != DragDropEffects.Move)
                {
                    m_holdFavorite = null;
                    m_bStartDrag   = false;
                }
            }
        }
Exemple #2
0
        private void flowFavorite_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(ScreenFavoriteData)))
            {
                ScreenFavoriteData data = (ScreenFavoriteData)e.Data.GetData(typeof(ScreenFavoriteData));

                if (data.DIRECTION == ScreenFavoriteData.eDirection.FromMenu)  // if drag from MenuControl, it will copy to favorite.
                {
                    if (AddButtonFavorite(data))
                    {
                        // Check before add
                        MenuFrameValidator validator = new MenuFrameValidator();
                        ErrorItem          errorItem = validator.CheckExistFavorite(Common.CurrentUserInfomation.UserCD, data.SCREEN_CD.ToNZString());

                        if (errorItem != null)
                        {
                            MessageDialog.ShowBusiness(this, errorItem.Message);
                            return;
                        }

                        m_menuController.AddScreenFavorite(new NZString(null, data.USER_ACCOUNT), new NZString(null, data.SCREEN_CD));
                    }
                }
            }
        }
Exemple #3
0
        private void menuTree1_MouseMove(object sender, MouseEventArgs e)
        {
            if (m_holdFavorite != null && !m_bStartDrag && m_lastPoint != e.Location)
            {
                bool bAllowDrag = false;
                if (Math.Abs(e.Location.X - m_lastPoint.X) >= C_ABS_LIMITED_X_AXIS)
                {
                    bAllowDrag = true;
                }

                if (!bAllowDrag && Math.Abs(e.Location.Y - m_lastPoint.Y) >= C_ABS_LIMITED_Y_AXIS)
                {
                    bAllowDrag = true;
                }

                if (!bAllowDrag)
                {
                    return;
                }

                //Start drag-n-drop.
                m_bStartDrag = true;


                // Synchronize call method.
                DragDropEffects effect = DoDragDrop(m_holdFavorite, DragDropEffects.Copy);
                if (effect != DragDropEffects.Copy)
                {
                    m_holdFavorite = null;
                    m_bStartDrag   = false;
                }
            }
        }
Exemple #4
0
        private void menuTree1_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(ScreenFavoriteData)))
            {
                ScreenFavoriteData data = (ScreenFavoriteData)e.Data.GetData(typeof(ScreenFavoriteData));

                if (data.DIRECTION == ScreenFavoriteData.eDirection.FromFavorite)
                {
                    RemoveButtonFavorite(data);
                }
            }
        }
Exemple #5
0
 private void flowFavorite_DragEnter(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(typeof(ScreenFavoriteData)))
     {
         ScreenFavoriteData data = (ScreenFavoriteData)e.Data.GetData(typeof(ScreenFavoriteData));
         e.Effect = (data.DIRECTION == ScreenFavoriteData.eDirection.FromMenu) ? DragDropEffects.Copy : DragDropEffects.None;
     }
     else
     {
         e.Effect = DragDropEffects.None;
     }
 }
Exemple #6
0
        private void btnFavorite_MouseDown(object sender, MouseEventArgs e)
        {
            Button             btn  = (Button)sender;
            ScreenFavoriteData data = new ScreenFavoriteData();

            data.USER_ACCOUNT = Common.CurrentUserInfomation.UserCD.StrongValue;
            data.SCREEN_CD    = ((ScreenFavoriteData)btn.Tag).SCREEN_CD;
            data.DIRECTION    = ScreenFavoriteData.eDirection.FromFavorite;

            m_holdFavorite = data;
            m_bStartDrag   = false;
            m_lastPoint    = e.Location;
        }
Exemple #7
0
        private void menuTree1_MenuItemDown(object sender, MenuItem item, System.Windows.Forms.MouseEventArgs e)
        {
            // Start hold object to prepare data before drag and drop.
            ScreenFavoriteData data = new ScreenFavoriteData();

            data.USER_ACCOUNT = Common.CurrentUserInfomation.UserCD.StrongValue;
            data.SCREEN_CD    = ((MenuSubItemDTO)item.Tag).SCREEN_CD.StrongValue;
            data.DIRECTION    = ScreenFavoriteData.eDirection.FromMenu;

            m_holdFavorite = data;
            m_bStartDrag   = false;
            m_lastPoint    = e.Location;
        }
Exemple #8
0
        /// <summary>
        /// Add button into favorite.
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private bool AddButtonFavorite(ScreenFavoriteData data)
        {
            // Check duplicate control on container.
            for (int i = 0; i < flowFavorite.Controls.Count; i++)
            {
                ScreenFavoriteData tagData = (ScreenFavoriteData)flowFavorite.Controls[i].Tag;
                if (tagData.SCREEN_CD == data.SCREEN_CD)
                {
                    MessageDialog.ShowBusiness(this, Message.LoadMessage(Messages.eValidate.VLM9017.ToString()));
                    return(false);
                }
            }

            // Save favorite into Container.
            try
            {
                FavoriteButton button = new FavoriteButton();
                button.Tag         = data;
                button.Size        = m_defaultButtonSize;
                button.BackColor   = flowFavorite.BackColor;
                button.BorderColor = ColorHelper.ShiftBrighness(button.BackColor, -100);

                DatabaseScreen dbScreen = m_databaseScreenCache.Get(data.SCREEN_CD);
                if (dbScreen != null)
                {
                    button.Text = dbScreen.ScreenDescription.NVL(string.Empty);

                    ImageItem imageItem = m_imageCache[dbScreen.ImageCD.StrongValue];
                    if (imageItem == null)
                    {
                        button.Image = Properties.Resources.img_not_found;
                    }
                    else
                    {
                        button.Image = imageItem.ImageBin;
                    }
                }

                button.MouseDown += new MouseEventHandler(btnFavorite_MouseDown);
                button.MouseMove += new MouseEventHandler(btnFavorite_MouseMove);
                button.MouseUp   += new MouseEventHandler(btnFavorite_MouseUp);
                button.Click     += new EventHandler(btnFavorite_Click);
                flowFavorite.Controls.Add(button);
                return(true);
            }
            catch (Exception err)
            {
                MessageDialog.ShowBusiness(this, "Can't add favorite. " + err.Message);
                return(false);
            }
        }
Exemple #9
0
        /// <summary>
        /// Load Favorite button
        /// </summary>
        private void LoadFavorite()
        {
            flowFavorite.Controls.Clear();

            List <string> screens = m_menuController.LoadScreenFavorite(Common.CurrentUserInfomation.UserCD);

            for (int i = 0; i < screens.Count; i++)
            {
                ScreenFavoriteData data = new ScreenFavoriteData();
                data.SCREEN_CD    = screens[i];
                data.USER_ACCOUNT = Common.CurrentUserInfomation.UserCD.StrongValue;
                AddButtonFavorite(data);
            }
        }
Exemple #10
0
 private void menuTree1_DragEnter(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(typeof(ScreenFavoriteData)))
     {
         ScreenFavoriteData data = (ScreenFavoriteData)e.Data.GetData(typeof(ScreenFavoriteData));
         if (data.DIRECTION == ScreenFavoriteData.eDirection.FromFavorite)
         {
             e.Effect = e.AllowedEffect;
         }
         else
         {
             e.Effect = DragDropEffects.None;
         }
     }
     else
     {
         e.Effect = DragDropEffects.None;
     }
 }
Exemple #11
0
        /// <summary>
        /// Remove button from favorite flow and database.
        /// </summary>
        /// <param name="data"></param>
        private void RemoveButtonFavorite(ScreenFavoriteData data)
        {
            // Save favorite;
            try
            {
                // Remove button from favorite.
                m_menuController.RemoveScreenFavorite(Common.CurrentUserInfomation.UserCD, new NZString(null, data.SCREEN_CD));

                for (int i = 0; i < flowFavorite.Controls.Count; i++)
                {
                    ScreenFavoriteData tagData = (ScreenFavoriteData)flowFavorite.Controls[i].Tag;
                    if (tagData.SCREEN_CD == data.SCREEN_CD)
                    {
                        flowFavorite.Controls.RemoveAt(i);
                        break;
                    }
                }
            }
            catch (Exception err)
            {
                MessageDialog.ShowBusiness(this, "Can't add favorite. " + err.Message);
            }
        }
Exemple #12
0
        void btnFavorite_Click(object sender, EventArgs e)
        {
            ScreenFavoriteData data = (ScreenFavoriteData)((Button)sender).Tag;

            OpenScreen(data.SCREEN_CD);
        }
Exemple #13
0
 private void btnFavorite_MouseUp(object sender, MouseEventArgs e)
 {
     m_holdFavorite = null;
     m_bStartDrag   = false;
 }
Exemple #14
0
 private void menuTree1_MouseUp(object sender, MouseEventArgs e)
 {
     // Release drag-n-drop.
     m_holdFavorite = null;
     m_bStartDrag   = false;
 }