Пример #1
0
        public static ExecResult <LinkType[]> Execute(LinkType[] alreadySelectedObjects)
        {
            var result = new ExecResult <LinkType[]>();

            try
            {
                var form = new FSelectComponentLevel();
                form.LoadLinkTypes();
                if (alreadySelectedObjects != null)
                {
                    form.SelectLinkTypes(alreadySelectedObjects);
                }


                DialogResult res = form.ShowDialog();
                if (res != DialogResult.OK)
                {
                    result.code = (int)res;
                }
                else
                {
                    List <LinkType> selectedObjects = new List <LinkType>();
                    foreach (LinkType linkType in form.clbLinkTypes.CheckedItems)
                    {
                        selectedObjects.Add(linkType);
                    }

                    result.value = selectedObjects.ToArray();
                }
            }
            catch (Exception ex)
            {
                result.setException(ex);
            }

            return(result);
        }
        private void btnLinkTypeFilter_Click(object sender, EventArgs e)
        {
            ExecResult <LinkType[]> selectLinkTypeResult = FSelectComponentLevel.Execute((LinkType[])lblLinkTypeFilter.Tag);

            if (selectLinkTypeResult.code == 0)
            {
                lblLinkTypeFilter.Tag  = selectLinkTypeResult.value;
                lblLinkTypeFilter.Text = "";
                for (int i = 0; i < selectLinkTypeResult.value.Length; i++)
                {
                    LinkType linkType = selectLinkTypeResult.value[i];

                    if (lblLinkTypeFilter.Text == "")
                    {
                        lblLinkTypeFilter.Text += linkType.ToString();
                    }
                    else
                    {
                        lblLinkTypeFilter.Text += "," + linkType.ToString();
                    }

                    if (i == 5)
                    {
                        break;
                    }
                }
                if (lblLinkTypeFilter.Text != "")
                {
                    lblLinkTypeFilter.Text += "...";
                }


                SetFilterLabel(tpLinkTypeFilter, selectLinkTypeResult.value.Length > 0);
                LoadConnectorList();
            }
        }