Exemplo n.º 1
0
        // Event dời chuột khỏi Button
        private void Btn_MouseLeave(object sender, MouseEventArgs e)
        {
            KButton btn = e.Source as KButton;

            // Thiết lập màu Button về mặc định
            btn.updateBackGround();
        }
Exemplo n.º 2
0
 // Event theo dõi di chuyển của chuột
 private void Btn_PreviewMouseMove(object sender, MouseEventArgs e)
 {
     // Nếu nhấn chuột
     if (e.LeftButton == MouseButtonState.Pressed)
     {
         // Lưu lại nút bị kéo
         draggedButton = (KButton)sender;
         int x = 0;
         DragDrop.DoDragDrop((KButton)sender, x, DragDropEffects.All);
         e.Handled = true;
     }
 }
Exemplo n.º 3
0
 // Khởi tạo các biến
 public PopUp(KienHang kienHang, KButton _b, KhoHang _khoHang, bool isOnline)
 {
     InitializeComponent();
     k       = kienHang;
     b       = _b;
     khoHang = _khoHang;
     isOn    = isOnline;
     this.kichThuoc.Content = kienHang.getWidthInfo();
     this.ngay.Text         = kienHang.getNgayInfo();
     this.thang.Text        = kienHang.getThangInfo();
     this.nam.Text          = kienHang.getNamInfo();
     this.maKien.Text       = kienHang.getMaKienInfo();
     this.donGia.Text       = kienHang.getDonGiaInfo();
 }
Exemplo n.º 4
0
 // Event thả chuột
 private void Btn_Drop(object sender, DragEventArgs e)
 {
     // Nếu đã kéo một nút nào đó
     if (draggedButton != null)
     {
         // Bắt đầu di chuyển
         droppedButton = (KButton)sender;
         draggedButton.move(khoHang, droppedButton);
         draggedButton = null;
         khoHang.writeData();
         // Cập nhật thông tin nếu đang trực tuyến
         if (isOnline == true)
         {
             KhoHang.uploadFile();
         }
     }
 }
Exemplo n.º 5
0
        // Event lướt chuột qua Button
        private void Btn_MouseEnter(object sender, MouseEventArgs e)
        {
            KButton btn = e.Source as KButton;

            // Hiển thị tooltip là thông tin kho hàng
            btn.ToolTip = btn.getInfo();

            // Thay đổi màu của Button
            btn.Background = Brushes.LightBlue;
            if (btn.getKienHang().getWidth() == -2)
            {
                btn.getLeft().Background = Brushes.LightBlue;
            }
            if (btn.getKienHang().getWidth() == 2)
            {
                btn.getRight().Background = Brushes.LightBlue;
            }
        }
Exemplo n.º 6
0
        // Event nhấn chuột
        private void Btn_MouseDown(object sender, MouseButtonEventArgs e)
        {
            KButton btn = e.Source as KButton;

            //Nếu nhấn chuột phải thì xử lý
            if (e.ChangedButton == MouseButton.Right)
            {
                KienHang k = btn.getKienHang();
                // Nếu tồn tại kiện hàng
                if (k.getWidth() != 0)
                {
                    // PopUp cho phép sửa kiện hàng
                    PopUp p = new PopUp(btn.getKienHang(), btn, khoHang, (bool)isOnline);
                    if (p != null)
                    {
                        p.kichThuocEdit.Visibility = Visibility.Collapsed;
                        p.Show();
                    }
                }
                // Nếu không tồn tại kiện hàng
                else
                {
                    // PopUp cho phép thêm kiện hàng
                    PopUp p = new PopUp(btn.getKienHang(), btn, khoHang, (bool)isOnline);
                    if (p != null)
                    {
                        p.kichThuoc.Visibility = Visibility.Collapsed;
                        p.delete.Visibility    = Visibility.Collapsed;
                        p.Show();
                    }
                }
            }
            else
            {
            }
        }
Exemplo n.º 7
0
        private void GenerateMapZoom1Khu(int khu = 1, string fileName = "../../../Resources/input.txt")
        {
            // Khởi tạo các biến số kho hàng, stackPanel, buttonList và drawArea
            drawArea.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            drawArea.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            drawArea.Padding       = new Thickness(drawAreaPaddingX, drawAreaPaddingY, drawAreaPaddingX, drawAreaPaddingY);
            khoHang                = new KhoHang(fileName);
            stackPanel             = new StackPanel();
            stackPanel.Orientation = Orientation.Horizontal;
            if (buttonList != null)
            {
                buttonList.Clear();
            }
            buttonList = new List <List <List <KButton> > >();
            khu--;
            {
                // Khởi tạo các biến số khu hàng, wrapPanel
                KhuHang   khuHang   = khoHang.getKhu(khu);
                WrapPanel wrapPanel = new WrapPanel();
                int       row       = khuHang.getNRow();
                int       col       = khuHang.getNCol();
                wrapPanel.Height            = buttonHeight * (row + 1);
                wrapPanel.Width             = buttonWidth * col;
                wrapPanel.VerticalAlignment = VerticalAlignment.Top;
                List <List <KButton> > button_list;

                button_list = new List <List <KButton> >();
                for (int i = 0; i < row; ++i)
                {
                    button_list.Add(new List <KButton>());
                    for (int j = 0; j < col; ++j)
                    {
                        KButton btn = new KButton(khu + 1, i, j, khuHang.get(i, j));
                        btn.FontSize         += 10;
                        btn.Height            = buttonHeight;
                        btn.Width             = buttonWidth;
                        btn.Content           = btn.Name;
                        btn.AllowDrop         = true;
                        btn.PreviewMouseMove += Btn_PreviewMouseMove;
                        btn.Drop             += Btn_Drop;
                        btn.MouseDown        += Btn_MouseDown;
                        btn.GotMouseCapture  += Btn_GotMouseCapture;
                        btn.MouseEnter       += Btn_MouseEnter;
                        btn.MouseLeave       += Btn_MouseLeave;
                        btn.upBackGround();
                        button_list[i].Add(btn);
                    }
                }

                // Thiết lập buttonList
                for (int i = 0; i < row; ++i)
                {
                    for (int j = 0; j < col; ++j)
                    {
                        if (j == 0)
                        {
                            button_list[i][j].setLeft(null);
                        }
                        else
                        {
                            button_list[i][j].setLeft(button_list[i][j - 1]);
                        }

                        if (j == col - 1)
                        {
                            button_list[i][j].setRight(null);
                        }
                        else
                        {
                            button_list[i][j].setRight(button_list[i][j + 1]);
                        }
                    }
                }

                for (int i = 0; i < row; i++)
                {
                    for (int j = 0; j < col; j++)
                    {
                        wrapPanel.Children.Add(button_list[i][j]);
                    }
                }

                // Tạo hiệu ứng xoay khu hàng
                RotateTransform rotateTransform = new RotateTransform();
                rotateTransform.Angle     = khuHang.getAngle();
                wrapPanel.LayoutTransform = rotateTransform;

                // Thêm tên khu hàng
                Label khuHangName = new Label();
                khuHangName.Height  = buttonHeight;
                khuHangName.Width   = wrapPanel.Width;
                khuHangName.Content = "Khu hàng " + (khu + 1).ToString();
                khuHangName.HorizontalContentAlignment = HorizontalAlignment.Center;
                khuHangName.Padding = new Thickness(0);

                stackPanel.Children.Add(wrapPanel);
                stackPanel.HorizontalAlignment = HorizontalAlignment.Center;
                stackPanel.VerticalAlignment   = VerticalAlignment.Center;
                buttonList.Add(button_list);
                currentWrapPanel = wrapPanel;
                currentAngle     = khuHang.getAngle();
                sldZoom.Value    = 50;
                wrapPanel.Children.Add(khuHangName);
            }
            drawArea.Content = stackPanel;
            drawArea.Loaded += Page_Loaded;
        }
Exemplo n.º 8
0
 public void setRight(KButton b)
 {
     right = b;
 }
Exemplo n.º 9
0
 // Thiết lập các biến
 public void setLeft(KButton b)
 {
     left = b;
 }
Exemplo n.º 10
0
 // Di chuyển kiện hàng và cập nhật nền Button
 public void move(KhoHang k, KButton b)
 {
     k.Move(khu, x, y, b.khu, b.x, b.y);
     this.updateBackGround();
     b.updateBackGround();
 }