Exemplo n.º 1
0
        /// <summary>
        /// ÊÃéÒ§ãËÁè
        /// </summary>
        private void ReLocationPanelFindOptionCrossDown()
        {
            /* ¨Ñ´ÅӴѺ PanelOption Ẻ«éÒÂ-¢ÇÒ µÒÁÅӴѺ áÅФӹdz¤ÇÒÁ¡ÇéÒ§ÊÙ§ÊØ´¢Í§¤ÍÅÑÁ¹ì */
            int iCountControl = 0;
            int iCol1MaxWidth = 0;
            int iCol2MaxWidth = 0;

            List <PanelOption> lstColumn1 = new List <PanelOption>();
            List <PanelOption> lstColumn2 = new List <PanelOption>();

            foreach (Control c in panelFindOptions.Controls)
            {
                if (!(c is PanelOption))  // If not PanelOption will ignore.
                {
                    continue;
                }

                iCountControl++;

                PanelOption op = (PanelOption)c;
                if (iCountControl % 2 == 1)
                {
                    lstColumn1.Add(op);

                    if (iCol1MaxWidth < op.Width)
                    {
                        iCol1MaxWidth = op.Width;
                    }
                }
                else
                {
                    lstColumn2.Add(op);

                    if (iCol2MaxWidth < op.Width)
                    {
                        iCol2MaxWidth = op.Width;
                    }
                }
            }

            // ¨Ñ´ÇÒ§ Option ãËéµÃ§µÓá˹è§ã¹ Panel
            // áµèÂѧäÁèÁÕ¡ÒâÂÒ¢¹Ò´¢Í§ Form ãËé¾Í´Õ¡Ñº·ÕèáÊ´§
            ReLocationPanelFindOptionColumns(lstColumn1.ToArray(), lstColumn2.ToArray(), iCol1MaxWidth);

            this.Width = (iCol1MaxWidth + iCol2MaxWidth) + (LEFT_OFFSET * 2) + panelFindOptionsButton.Width + (SystemInformation.FrameBorderSize.Width * 2);
        }
Exemplo n.º 2
0
        private void btnClear_Click(object sender, System.EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                foreach (Control c in panelFindOptions.Controls)
                {
                    if (c is PanelOption)
                    {
                        PanelOption po = (PanelOption)c;

                        po.ResetState();
                    }
                }

                ResultGridControl.DataSource = null;
            }
            catch (Exception ex)
            {
                MessageDialog.ShowSystemErrorMsg(this, ex);
            }
            this.Cursor = Cursors.Default;
        }
Exemplo n.º 3
0
        private FindKeywordCollection CreateFindKeyWord()
        {
            FindKeywordCollection keys = new FindKeywordCollection();

            foreach (Control c in panelFindOptions.Controls)
            {
                if (c is PanelOption)
                {
                    PanelOption po = (PanelOption)c;
                    //Fix and Add by Raktai 2007/05/21----------------------------------------------
                    //if (po.ValueType2 is AFDDateTimeValueType)
                    //{
                    //    //po.ValueType2.SetValue(((DateTime)po.ValueType2.GetValue()[0]).AddDays(1).AddSeconds(-1));
                    //    keys.Add(new FindKeyword(po.KeyName, po.Checked, po.FieldMap, po.SelectedOperator, po.SelectedValue1, new object[] { (((DateTime)po.ValueType2.GetValue()[0]).AddDays(1).AddSeconds(-1)) }));
                    //}
                    //else
                    {
                        keys.Add(new FindKeyword(po.KeyName, po.Checked, po.FieldMap, po.SelectedOperator, po.SelectedValue1, po.SelectedValue2));
                    }
                    //End fix and add---------------------------------------------------------------
                }
            }
            return(keys);
        }
Exemplo n.º 4
0
        private void ReLocationPanelFindOptionCrossDown_old()
        {
            //find date type option
            int iCountMaxWidthPO = 0;
            //Modified by Wirachai T. 2008 10 31
            //int iMaxWidth = 350;
            int iMaxWidth = panelFindOptions.Width / 2;

            // End
            foreach (Control c in panelFindOptions.Controls)
            {
                if (c is PanelOption)
                {
                    if (iMaxWidth < c.Width)
                    {
                        iMaxWidth = c.Width;
                    }
                }
            }
            foreach (Control c in panelFindOptions.Controls)
            {
                if (c is PanelOption)
                {
                    if (iMaxWidth == c.Width)
                    {
                        iCountMaxWidthPO++;
                    }
                }
            }

            // calculate number of control foreach column
            int iCountColumn1 = (int)(m_findOptions.Count / 2) + (int)(m_findOptions.Count % 2) + iCountMaxWidthPO;
            int iCountColumn2 = iCountColumn1;// (int)(m_findOptions.Count / 2);

            // Create array of PanelOption control
            PanelOption[] pColumn1      = new PanelOption[iCountColumn1];
            PanelOption[] pColumn2      = new PanelOption[iCountColumn2];
            int           iCountControl = 0;
            int           iCol1MaxWidth = 0;
            int           iCol2MaxWidth = 0;

            iCountColumn1 = 0;
            iCountColumn2 = 0;
            foreach (Control c in panelFindOptions.Controls)
            {
                if (c is PanelOption)
                {
                    iCountControl++;
                    PanelOption op = (PanelOption)c;
                    if (iCountControl % 2 == 1)
                    {   // column 1
                        pColumn1[iCountColumn1] = op;
                        iCountColumn1++;
                        if (iCol1MaxWidth < op.Width)
                        {
                            iCol1MaxWidth = op.Width;
                        }
                        // Add by Wirachai T. 2007/07/11
                        //iCol1MaxWidth += 20;
                        // End Add
                    }
                    else
                    {   // column 2
                        if (op.Width == iMaxWidth)
                        {
                            pColumn1[iCountColumn1] = op;
                            iCountColumn1++;
                            iCountControl--;
                            continue;
                        }

                        pColumn2[iCountColumn2] = op;
                        iCountColumn2++;
                        if (iCol2MaxWidth < op.Width)
                        {
                            iCol2MaxWidth = op.Width;
                        }
                    }
                }
            }
            // Check is PanelOption can Re-Location with selected FindOptionDirection by calculate with of column1 + column2 must <= panelFindOptions.Width (caculate with OFFSET too)
            int iSumColumnWidth = iCol1MaxWidth + iCol2MaxWidth + LEFT_OFFSET;

            if (false)
            {//(iSumColumnWidth > panelFindOptions.Width) {	// If use 2 column, It can't not place in panelFindOptions. Because some part of control will be invisible. So do nothing in this case
                //Modify by Wirachai T. 20070823
                //PanelOption[] po = new PanelOption[pColumn1.Length + pColumn2.Length];
                //pColumn1.CopyTo(po, 0);
                //pColumn2.CopyTo(po, pColumn1.Length);
                //ReLocationPanelFindOptionColumns(po, new PanelOption[0], iCol1MaxWidth);
                PanelOption[] po = new PanelOption[pColumn1.Length + pColumn2.Length];
                for (int i = 0; i < m_findOptions.Count; i++)
                {
                    if (i % 2 == 0)//even
                    {
                        po[i] = pColumn1[i / 2];
                    }
                    else
                    {
                        po[i] = pColumn2[i / 2];
                    }
                }
                ReLocationPanelFindOptionColumns(po, new PanelOption[0], iCol1MaxWidth);
                //====================================================================
            }
            else
            {
                ReLocationPanelFindOptionColumns(pColumn1, pColumn2, iCol1MaxWidth);
            }
        }
Exemplo n.º 5
0
        private void RefreshFindConditionLayout()
        {
            int width1 = 0;

            using (Graphics g = this.CreateGraphics())
            {
                Font font = grpFindOptions.Font;
                foreach (Control c in panelFindOptions.Controls)
                {
                    if (c is PanelOption)
                    {
                        PanelOption pOption = (PanelOption)c;

                        int iTmpWidth = pOption.ValueType1.GetWidth(g, font);
                        if (iTmpWidth > width1)
                        {
                            width1 = iTmpWidth;
                        }
                    }
                }
            }


            foreach (Control c in panelFindOptions.Controls)
            {
                if (c is PanelOption)
                {
                    PanelOption po = (PanelOption)c;

                    int iNewWidth = po.SetInputWidth(width1, width1);

                    if (po.ValueType1 != null)
                    {
                        if (po.ValueType1 is DateTimeValueType)
                        {
                            if (po.SelectedValue1 == null)
                            {
                                DateTime dtMinTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
                                po.ValueType1.SetValue(dtMinTime);
                            }
                        }
                    }
                    if (po.ValueType2 != null)
                    {
                        if (po.ValueType2 is DateTimeValueType)
                        {
                            if (po.SelectedValue2 == null)
                            {
                                DateTime dtMaxTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
                                po.ValueType2.SetValue(dtMaxTime);
                            }
                        }
                    }
                    po.Width = iNewWidth;
                }
            }


            // Re Location for each PanelFindOption by using FindOptionDirection
            ReLocationPanelFindOption();
        }
Exemplo n.º 6
0
        private void CreateFindOptions()
        {
            int iOptionNameWidth = 0;
            int iCompareWidth    = 0;

            using (Graphics g = this.CreateGraphics())
            {
                // calculate width
                foreach (FindOption fOption in m_findOptions)
                {
                    int iTmp = (int)g.MeasureString(fOption.Caption + "---", this.Font).Width;
                    if (iTmp > iOptionNameWidth)
                    {
                        iOptionNameWidth = iTmp;
                    }

                    foreach (FindOperator oper in fOption.FindOperators)
                    {
                        //iTmp = (int)g.MeasureString(oper.ToString() + "-", this.Font).Width + SystemInformation.MenuButtonSize.Width;
                        iTmp = (int)g.MeasureString(oper.Display + "-", this.Font).Width + SystemInformation.MenuButtonSize.Width;
                        if (iTmp > iCompareWidth)
                        {
                            iCompareWidth = iTmp;
                        }
                    }
                }
            }

            // calculate height of panel option from textbox
            TextBox txtBoxTemp = new TextBox();

            txtBoxTemp.Text = "TEST";
            int iPanelOptionHeight = txtBoxTemp.Height;

            txtBoxTemp.Dispose();



            // create control
            panelFindOptions.Controls.Clear();
            int iTop = YSPACE_PANEL_OPTION;

            foreach (FindOption fOption in m_findOptions)
            {
                PanelOption pOption = new PanelOption(fOption, iOptionNameWidth, iCompareWidth);
                pOption.Location           = new Point(LEFT_OFFSET, iTop);
                pOption.Height             = iPanelOptionHeight;
                pOption.OnKeyEnterPressed += new KeyPressEventHandler(pOption_OnKeyEnterPressed);
                panelFindOptions.Controls.Add(pOption);

                iTop += pOption.Height + YSPACE_PANEL_OPTION;
            }
            // resize find option group
            int iOffset        = grpFindOptions.Height - panelFindOptions.Height;
            int iDefaultHeight = btnClear.Bottom + btnClear.Left;
            int iNewHeight     = (iDefaultHeight > iTop) ? iDefaultHeight : iTop + 10;

            grpFindOptions.SizeChanged -= new EventHandler(this.grpFindOptions_Resize);
            grpFindOptions.Height       = iOffset + iNewHeight;
            grpFindOptions.SizeChanged += new EventHandler(this.grpFindOptions_Resize);
        }