Ejemplo n.º 1
0
        protected override void loadData()
        {
            base.loadData();
            Labelset labelset = (Labelset)EditedModel;

            if (labelset == null)
            {
                return;
            }
            labelsetProxy = new(LabelableObjectRegister.Instance, (sysObj => new LabelProxy(labelset, sysObj)));
            initLabelsTable();
        }
Ejemplo n.º 2
0
 private void doAssociation <TProxy, TElement>(TProxy elementProxyA, TElement elementB, ObservableProxyEnumerable <TProxy, TElement> otherProxies)
     where TElement : class, Model.General.INotifyPropertyChanged
     where TProxy : RouterIOProxy <TElement>, new()
 {
     foreach (TProxy elementProxy in otherProxies)
     {
         if (elementProxy.AssociatedElement == elementB)
         {
             elementProxy.AssociatedElement = null;
         }
     }
     elementProxyA.AssociatedElement = elementB;
 }
Ejemplo n.º 3
0
        private void initAssociationsTable <TElement, TProxy>
            (ref CustomDataGridView <TProxy> tableCDGV, ref DataGridView tableOriginal,
            ref Panel containerPanel, ref ObservableProxyEnumerable <TProxy, TElement> proxyListRef,
            ObservableList <TElement> listA, ObservableList <TElement> listB,
            Func <TElement, string> elementNameGetter, Func <TElement, int> elementIndexGetter)
            where TElement : class, Model.General.INotifyPropertyChanged
            where TProxy : RouterIOProxy <TElement>, new()
        {
            tableCDGV = createTable <TProxy>(containerPanel, ref tableOriginal);
            tableCDGV.VerticalHeader = true;
            CustomDataGridViewColumnDescriptorBuilder <TProxy> builder;

            if ((listA == null) || (listB == null))
            {
                return;
            }

            // Create database
            ObservableProxyEnumerable <TProxy, TElement> proxyList = new ObservableProxyEnumerable <TProxy, TElement>(listA, (elementA) => new TProxy()
            {
                Original = elementA
            });

            proxyListRef = proxyList;

            // Column: sideA name
            builder = getColumnDescriptorBuilderForTable <TProxy>(tableCDGV);
            builder.Header("");
            builder.Width(150);
            builder.DividerWidth(3);
            builder.InitializerMethod((elementProxyA, cell) => { cell.Value = elementNameGetter(elementProxyA.Original); });
            builder.BuildAndAdd();

            // Columns for associations
            foreach (TElement elementB in listB)
            {
                builder = getColumnDescriptorBuilderForTable <TProxy>(tableCDGV);
                builder.Type(DataGridViewColumnType.SmallIcon);
                builder.Header(elementNameGetter(elementB));
                builder.Width(30);
                builder.IconColor(ICONCOLOR_ASSOCIATION);
                builder.IconType(DataGridViewSmallIconCell.IconTypes.Circle);
                builder.IconShown(false);
                builder.UpdaterMethod((elementProxyA, cell) =>
                {
                    DataGridViewSmallIconCell typedCell = ((DataGridViewSmallIconCell)cell);
                    bool active = (elementProxyA.AssociatedElement == elementB);
                    if (active)
                    {
                        cell.Style.BackColor = BACKCOLOR_ASSOCIATION_ACTIVE;
                        typedCell.IconShown  = true;
                    }
                    else
                    {
                        cell.Style.BackColor = BACKCOLOR_ASSOCIATION_INACTIVE;
                        typedCell.IconShown  = false;
                    }
                });
                builder.AddChangeEvent("#" + elementIndexGetter(elementB));
                builder.CellDoubleClickHandlerMethod((elementProxyA, cell, e) => { doAssociation(elementProxyA, elementB, proxyList); });
                builder.BuildAndAdd();
            }

            // Bind database
            tableCDGV.BoundCollection = proxyList;
        }