Exemplo n.º 1
0
        private void UcoPartnerFindCriteriaSetup_FindCriteriaSelectionChanged(System.Object sender, TPartnerFindCriteriaSelectionChangedEventArgs e)
        {
            // MessageBox.Show('Received FindCriteriaSelectionChanged event!');
            FLastSelectedCriteria = e.FSelectedCriteria;

            if (FLastSelectedCriteria != null)
            {
                btnMoveUp.Enabled = true;
                btnMoveDown.Enabled = true;

                if (e.IsFirstInColumn)
                {
                    btnMoveUp.Enabled = false;
                }

                if (e.IsLastInColumn)
                {
                    btnMoveDown.Enabled = false;
                }

                if (e.FCriteriaColumn == TFindCriteriaColumn.fccLeft)
                {
                    btnMoveToRightColumn.Enabled = true;
                    btnMoveToLeftColumn.Enabled = false;
                }
                else
                {
                    btnMoveToLeftColumn.Enabled = true;
                    btnMoveToRightColumn.Enabled = false;
                }
            }
            else
            {
                // no criteria selected
                btnMoveUp.Enabled = false;
                btnMoveDown.Enabled = false;
                btnMoveToLeftColumn.Enabled = false;
                btnMoveToRightColumn.Enabled = false;
            }
        }
        /// <summary>
        /// todoComment
        /// </summary>
        public void MoveRightSelectedCriteriaPanel()
        {
            TPartnerFindCriteriaSelectionChangedEventArgs FindCriteriaSelectionChangedArgs;

            if (FSelectedPanel.CriteriaColumn == TFindCriteriaColumn.fccLeft)
            {
                FCriteriaFieldsLeft.Remove(FSelectedPanel.SelectedCriteriaPanel.Name.Substring(3));

                // MessageBox.Show('PositionInCriteriaColumn: ' + FSelectedPanel.PositionInCriteriaColumn.ToString +
                // 'FCriteriaFieldsRight.Count  1: ' + Int16(FCriteriaFieldsRight.Count  1).ToString);
                if (FSelectedPanel.PositionInCriteriaColumn <= FCriteriaFieldsRight.Count - 1)
                {
                    FCriteriaFieldsRight.Insert(FSelectedPanel.PositionInCriteriaColumn, FSelectedPanel.SelectedCriteriaPanel.Name.Substring(3));
                }
                else
                {
                    FSelectedPanel.PositionInCriteriaColumn = FCriteriaFieldsRight.Add(FSelectedPanel.SelectedCriteriaPanel.Name.Substring(3));
                }

                FSelectedPanel.CriteriaColumn = TFindCriteriaColumn.fccRight;
                DisplayCriteriaFieldControls();

                // Raise FindCriteriaSelectionChangedArgs event and update IsFirstInColumn + IsLastInColumn
                FindCriteriaSelectionChangedArgs = new TPartnerFindCriteriaSelectionChangedEventArgs();
                FindCriteriaSelectionChangedArgs.SelectedCriteria = FSelectedPanel.SelectedCriteriaPanel.Name.Substring(3);
                FindCriteriaSelectionChangedArgs.CriteriaColumn = FSelectedPanel.CriteriaColumn;
                FindCriteriaSelectionChangedArgs.IsFirstInColumn = false;
                FindCriteriaSelectionChangedArgs.IsLastInColumn = false;
                FSelectedPanel.IsFirstInColumn = false;
                FSelectedPanel.IsLastInColumn = false;

                if (FSelectedPanel.PositionInCriteriaColumn == 0)
                {
                    FindCriteriaSelectionChangedArgs.IsFirstInColumn = true;
                    FSelectedPanel.IsFirstInColumn = true;
                }

                if (FSelectedPanel.PositionInCriteriaColumn == FCriteriaFieldsRight.Count - 1)
                {
                    FindCriteriaSelectionChangedArgs.IsLastInColumn = true;
                    FSelectedPanel.IsLastInColumn = true;
                }

                // MessageBox.Show('Raising FindCriteriaSelectionChanged event.');
                OnFindCriteriaSelectionChanged(FindCriteriaSelectionChangedArgs);
            }
        }
        /// <summary>
        /// todoComment
        /// </summary>
        public void MoveDownSelectedCriteriaPanel()
        {
            ArrayList CriteriaFieldsArrayList;
            TPartnerFindCriteriaSelectionChangedEventArgs FindCriteriaSelectionChangedArgs;
            Int32 CurrentIndexInFieldsArrayList;

            if (!FSelectedPanel.IsLastInColumn)
            {
                // MessageBox.Show('Moving item down');
                if (FSelectedPanel.CriteriaColumn == TFindCriteriaColumn.fccLeft)
                {
                    CriteriaFieldsArrayList = FCriteriaFieldsLeft;
                }
                else
                {
                    CriteriaFieldsArrayList = FCriteriaFieldsRight;
                }

                CurrentIndexInFieldsArrayList = CriteriaFieldsArrayList.IndexOf(FSelectedPanel.SelectedCriteriaPanel.Name.Substring(3));
                CriteriaFieldsArrayList.Remove(FSelectedPanel.SelectedCriteriaPanel.Name.Substring(3));
                CriteriaFieldsArrayList.Insert(CurrentIndexInFieldsArrayList + 1, FSelectedPanel.SelectedCriteriaPanel.Name.Substring(3));
                FSelectedPanel.PositionInCriteriaColumn = FSelectedPanel.PositionInCriteriaColumn + 1;
                DisplayCriteriaFieldControls();

                // Raise FindCriteriaSelectionChangedArgs event and update IsFirstInColumn + IsLastInColumn
                FindCriteriaSelectionChangedArgs = new TPartnerFindCriteriaSelectionChangedEventArgs();
                FindCriteriaSelectionChangedArgs.SelectedCriteria = FSelectedPanel.SelectedCriteriaPanel.Name.Substring(3);
                FindCriteriaSelectionChangedArgs.CriteriaColumn = FSelectedPanel.CriteriaColumn;
                FindCriteriaSelectionChangedArgs.IsFirstInColumn = false;
                FindCriteriaSelectionChangedArgs.IsLastInColumn = false;
                FSelectedPanel.IsFirstInColumn = false;
                FSelectedPanel.IsLastInColumn = false;

                if (CurrentIndexInFieldsArrayList + 1 == CriteriaFieldsArrayList.Count - 1)
                {
                    FindCriteriaSelectionChangedArgs.IsLastInColumn = true;
                    FSelectedPanel.IsLastInColumn = true;
                }

                // MessageBox.Show('Raising FindCriteriaSelectionChanged event.');
                OnFindCriteriaSelectionChanged(FindCriteriaSelectionChangedArgs);
            }
        }
 /// <summary>
 /// todoComment
 /// </summary>
 /// <param name="args"></param>
 protected void OnFindCriteriaSelectionChanged(TPartnerFindCriteriaSelectionChangedEventArgs args)
 {
     if (FindCriteriaSelectionChanged != null)
     {
         FindCriteriaSelectionChanged(this, args);
     }
 }
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="ACriteriaName"></param>
        /// <returns></returns>
        public Boolean UnSelectCriteriaPanel(String ACriteriaName)
        {
            System.Windows.Forms.Panel SearchedPanel;
            TPartnerFindCriteriaSelectionChangedEventArgs FindCriteriaSelectionChangedArgs;
            Int32 Counter1;
            Int32 NotFoundInPanelCounter;
            SearchedPanel = pnlLeftColumn;
            NotFoundInPanelCounter = 0;

            while (1 == 1)
            {
                for (Counter1 = 0; Counter1 <= SearchedPanel.Controls.Count - 1; Counter1 += 1)
                {
                    if (SearchedPanel.Controls[Counter1] is Panel)
                    {
                        if (SearchedPanel.Controls[Counter1].Name == "pnl" + ACriteriaName)
                        {
                            // Dehighlight the correct panel
                            // MessageBox.Show('Dehighlighting Panel: ' + SearchedPanel.Controls[Counter1].Name );
                            SearchedPanel.Controls[Counter1].BackColor = SearchedPanel.Controls[Counter1].Parent.BackColor;

                            if (!(FSelectedPanel == null))
                            {
                                if ("pnl" + ACriteriaName == FSelectedPanel.SelectedCriteriaPanel.Name)
                                {
                                    // Raise FindCriteriaSelectionChangedArgs event to signal that no criteria is selected
                                    FindCriteriaSelectionChangedArgs = new TPartnerFindCriteriaSelectionChangedEventArgs();
                                    FindCriteriaSelectionChangedArgs.SelectedCriteria = null;
                                    FindCriteriaSelectionChangedArgs.CriteriaColumn = TFindCriteriaColumn.fccLeft;
                                    FindCriteriaSelectionChangedArgs.IsFirstInColumn = false;
                                    FindCriteriaSelectionChangedArgs.IsLastInColumn = false;

                                    // MessageBox.Show('Raising FindCriteriaSelectionChanged event.');
                                    OnFindCriteriaSelectionChanged(FindCriteriaSelectionChangedArgs);
                                    FSelectedPanel = null;
                                }
                            }

                            return true;
                        }
                    }
                }

                NotFoundInPanelCounter = NotFoundInPanelCounter + 1;

                if (NotFoundInPanelCounter == 1)
                {
                    // Panel with matching name not found in pnlLeftColumn, try in pnlRightColumn
                    SearchedPanel = pnlRightColumn;
                }
                else
                {
                    // No panel with matching name found!
                    return false;
                }
            }
        }
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="ACriteriaName"></param>
        /// <returns></returns>
        public TSelectedCriteriaPanel SelectCriteriaPanel(String ACriteriaName)
        {
            System.Windows.Forms.Panel SearchedPanel;
            System.Windows.Forms.Panel OtherPanel;
            Int32 Counter1;
            Int32 Counter2;
            Int32 NotFoundInPanelCounter;
            TPartnerFindCriteriaSelectionChangedEventArgs FindCriteriaSelectionChangedArgs;
            SearchedPanel = pnlLeftColumn;
            OtherPanel = pnlRightColumn;
            NotFoundInPanelCounter = 0;

            while (1 == 1)
            {
                for (Counter1 = 0; Counter1 <= SearchedPanel.Controls.Count - 1; Counter1 += 1)
                {
                    if (SearchedPanel.Controls[Counter1] is Panel)
                    {
                        if (SearchedPanel.Controls[Counter1].Name == "pnl" + ACriteriaName)
                        {
                            // Highlight the correct panel
                            // MessageBox.Show('Highlighting Panel: ' + SearchedPanel.Controls[Counter1].Name );
                            SearchedPanel.Controls[Counter1].BackColor = System.Drawing.SystemColors.InactiveCaption;

                            // Dehighlight all other panels in the SearchedPanel
                            for (Counter2 = 0; Counter2 <= SearchedPanel.Controls.Count - 1; Counter2 += 1)
                            {
                                if ((SearchedPanel.Controls[Counter2] is Panel)
                                    && (SearchedPanel.Controls[Counter2].Name != SearchedPanel.Controls[Counter1].Name))
                                {
                                    SearchedPanel.Controls[Counter2].BackColor = this.BackColor;

                                    // pnlPersonnelCriteria contains a UserControls which BackColor needs also to be reset
                                    if (SearchedPanel.Controls[Counter2].Name == "pnlPersonnelCriteria")
                                    {
                                        SearchedPanel.Controls[Counter2].Controls[0].BackColor = this.BackColor;
                                    }
                                }
                            }

                            // Dehighlight all panels in the OtherPanel
                            for (Counter2 = 0; Counter2 <= OtherPanel.Controls.Count - 1; Counter2 += 1)
                            {
                                if (OtherPanel.Controls[Counter2] is Panel)
                                {
                                    OtherPanel.Controls[Counter2].BackColor = this.BackColor;

                                    // pnlPersonnelCriteria contains a UserControls which BackColor needs also to be reset
                                    if (OtherPanel.Controls[Counter2].Name == "pnlPersonnelCriteria")
                                    {
                                        OtherPanel.Controls[Counter2].Controls[0].BackColor = this.BackColor;
                                    }
                                }
                            }

                            // Raise FindCriteriaSelectionChangedArgs event
                            FindCriteriaSelectionChangedArgs = new TPartnerFindCriteriaSelectionChangedEventArgs();
                            FindCriteriaSelectionChangedArgs.SelectedCriteria = SearchedPanel.Controls[Counter1].Name.Substring(3);

                            if (SearchedPanel == pnlLeftColumn)
                            {
                                FindCriteriaSelectionChangedArgs.CriteriaColumn = TFindCriteriaColumn.fccLeft;
                            }
                            else
                            {
                                FindCriteriaSelectionChangedArgs.CriteriaColumn = TFindCriteriaColumn.fccRight;
                            }

                            FindCriteriaSelectionChangedArgs.IsFirstInColumn = false;
                            FindCriteriaSelectionChangedArgs.IsLastInColumn = false;

                            if (Counter1 == 0)
                            {
                                FindCriteriaSelectionChangedArgs.IsFirstInColumn = true;
                            }

                            if (Counter1 == SearchedPanel.Controls.Count - 1)
                            {
                                FindCriteriaSelectionChangedArgs.IsLastInColumn = true;
                            }

                            // MessageBox.Show('Raising FindCriteriaSelectionChanged event.');
                            OnFindCriteriaSelectionChanged(FindCriteriaSelectionChangedArgs);
                            return new TSelectedCriteriaPanel(((Panel)SearchedPanel.Controls[Counter1]),
                                FindCriteriaSelectionChangedArgs.CriteriaColumn,
                                FindCriteriaSelectionChangedArgs.IsFirstInColumn,
                                FindCriteriaSelectionChangedArgs.IsLastInColumn,
                                Counter1);
                        }
                    }
                }

                NotFoundInPanelCounter = NotFoundInPanelCounter + 1;

                if (NotFoundInPanelCounter == 1)
                {
                    // Panel with matching name not found in pnlLeftColumn, try in pnlRightColumn
                    SearchedPanel = pnlRightColumn;
                    OtherPanel = pnlLeftColumn;
                }
                else
                {
                    // No panel with matching name found!
                    return null;
                }
            }
        }