拆分容器将不会更新

时间:2018-07-03 10:52:48

标签: c# timer refresh paint splitcontainer

我有一种形式的分割式容器。在左侧面板中,显示作业信息,在右侧面板中,绘制日历,以图形方式显示订单期间。效果也很好。

但是现在您可以在每个订单中放置贴纸了。双击日历日,将显示或创建相应的标签。只需单击一下,相应的订单号就会存储在注册表中,用于另一个程序。

我的问题是,创建或删除标签后,日历并不总是更新。我做了一个文件日志,发现他跳入了相应的方法,但是无论如何都无法执行它们。当我进入调试模式时,一切正常。

有人可以提示我我做错了吗?

以下是各个代码片段:

private void splitPanelV_Panel2_Paint(object sender, PaintEventArgs e)
    {
        try
        {
            Paint_Cal(e.Graphics);
            Paint_AllOrders(e.Graphics);

            btnRefresh.Focus();
        }
        catch (Exception ex) {
            MessageBox.Show(ex.ToString());
        }
    }

private void MyMouseDown(object sender, MouseEventArgs e)
    {
        m_objSender = sender;
        m_meaEventArgs = e;

        //txtDebug.Text += "Begin MouseDown" + Environment.NewLine;
        myLogger.d(TAG, "Begin MouseDown");

        // This is the first mouse click.
        if (m_bolIsFirstClick)
        {
            m_bolIsFirstClick = false;

            // Determine the location and size of the double click 
            // rectangle area to draw around the cursor point.
            m_recDoubleClick = new Rectangle(
                e.X - (SystemInformation.DoubleClickSize.Width / 2),
                e.Y - (SystemInformation.DoubleClickSize.Height / 2),
                SystemInformation.DoubleClickSize.Width,
                SystemInformation.DoubleClickSize.Height);
            Invalidate();

            // Start the double click timer.
            m_TimerDoubleClick.Start();
        }

        // This is the second mouse click.
        else
        {
            // Verify that the mouse click is within the double click
            // rectangle and is within the system-defined double 
            // click period.
            if (m_recDoubleClick.Contains(e.Location) && m_intMilliseconds < SystemInformation.DoubleClickTime)
            {
                m_bolIsDoubleClick = true;
            }
        }
        //txtDebug.Text += "End MouseDown" + Environment.NewLine;
        myLogger.d(TAG, "End MouseDown");
    }

private void m_TimerDoubleClick_Tick(object sender, EventArgs e) 
    {
        m_intMilliseconds += 100;
        if (m_intMilliseconds >= SystemInformation.DoubleClickTime)
        {
            m_TimerDoubleClick.Stop();

            //WENN DoubleClick DANN DoubleClick-Methode
            if (m_bolIsDoubleClick)
            {
                //MyMouseDoubleClick(m_objSender, m_meaEventArgs);
                this.Invoke(new MyMouseDoubleClickDelegate(MyMouseDoubleClick), new object[] { m_objSender, m_meaEventArgs });
            }
            else //SONST SingleClick-Methode
            {
                //MyMouseClick(m_objSender, m_meaEventArgs);
                this.Invoke(new MyMouseClickDelegate(MyMouseClick), new object[] { m_objSender, m_meaEventArgs });
            }

            m_bolIsFirstClick = true;
            m_bolIsDoubleClick = false;
            m_intMilliseconds = 0;
        }
    }

private void RefreshForm()
    {
        myLogger.d(TAG, "ShowPanelLeft()");
        ShowPanelLeft();
        myLogger.d(TAG, "this.Refresh()");
        this.Refresh();
        //Point ptPos = this.Location;
        //this.Location = ptPos;
        //splitPanelV.Invalidate();
        Application.DoEvents();

        btnRefresh.Focus();
    }

private void MyMouseDoubleClick(object sender, MouseEventArgs e)
    {
        ....
         frmSticker objStickerform = new frmSticker();

                                //Berechnung des Delta für die x-Achse
                                intDeltaX = M_DELTA_X;
                                if ((e.X + objStickerform.Width + M_DELTA_X) > this.Width)
                                {
                                    intDeltaX = -M_DELTA_X - objStickerform.Width;
                                }

                                //Berechnung des Delta für die y-Achse
                                intDeltaY = M_DELTA_Y;
                                if ((e.Y + objStickerform.Height + M_DELTA_Y) > this.Height)
                                {
                                    intDeltaY = -M_DELTA_Y;
                                }

                                //Sticker an die gewünschte Position verschieben
                                intStickerLeft = this.Left + splitPanelV.Panel2.Left + e.X + intDeltaX;
                                intStickerTop = this.Top + splitPanelV.Panel2.Top + e.Y + intDeltaY;
                                objStickerform.Left = intStickerLeft;
                                objStickerform.Top = intStickerTop;

                                //WENN ein Sticker gefunden wurde DANN zeige ihn an
                                if (bolFound)
                                {
                                    objStickerform.InitSticker(objSticker);
                                }
                                else //SONST öffne einen neuen Sticker
                                {
                                    objNewSticker = new clsSticker();
                                    objNewSticker.Date = Convert.ToDateTime(dtMouseDate.ToShortDateString());
                                    objNewSticker.OrderNumber = m_lstDataFiltered[i].OrderNumber;
                                    objNewSticker.Type = (int)Stickertype.User;
                                    objNewSticker.Username = txtUser.Text;

                                    objStickerform.InitSticker(objNewSticker);
                                }

                                //Sticker anzeigen
                                objStickerform.ShowDialog();
                                switch (objStickerform.m_ButtonType)
                                {
                                    case WhatButtonClicked.New: //Neuen Sticker speichern
                                        //txtDebug.Text += "Sticker save" + Environment.NewLine;
                                        myLogger.d(TAG, "Sticker save");
                                        if (objStickerform.m_objSticker.Text.Trim() != string.Empty)
                                        {
                                            try
                                            {
                                                m_objDB.StickerSave(objStickerform.m_objSticker);
                                                objData = m_lstData.Find(a => a.OrderNumber == m_int_CurrentOrderNo);
                                                objData.Sticker[(int)Stickertype.User].Add(objStickerform.m_objSticker);
                                            }
                                            catch (Exception ex)
                                            {
                                                MessageBox.Show(ex.ToString(), "Fehler beim Sticker erstellen", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                            }
                                        }
                                        break;
                                    case WhatButtonClicked.Delete: //Bestehenden Sticker löschen
                                        //txtDebug.Text += "Sticker del" + Environment.NewLine;
                                        myLogger.d(TAG, "Sticker del");
                                        try
                                        {
                                            m_objDB.StickerDelete(objStickerform.m_objSticker);
                                            objData = m_lstData.Find(a => a.OrderNumber == m_int_CurrentOrderNo);
                                            objData.Sticker[(int)Stickertype.User].Remove(objStickerform.m_objSticker);
                                        }
                                        catch (Exception ex)
                                        {
                                            MessageBox.Show(ex.ToString(), "Fehler beim Sticker erstellen", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        }
                                        break;
                                    case WhatButtonClicked.Nothing: //Stickerfenster schließen
                                        objStickerform.Close();
                                        break;
                                }
                                objStickerform.Close();
                                RefreshForm();
                                return;
        ...
    }

0 个答案:

没有答案