Exemple #1
0
        public Main(RouterData Data)
        {
            this.Data = Data;

            InitializeComponent();

            RoutingList.Items.Clear();

            foreach (var Item in Data.StaticRoutes)
            {
                RoutingList.Items.Add(CreateLVIFromStaticRoutingRule(Item));
            }
            RoutingList.Refresh();

            Data.StaticRoutes.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(
                delegate(object Sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs EventArgs)
            {
                if (EventArgs.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                {
                    foreach (var ItemObj in EventArgs.NewItems)
                    {
                        StaticRoutingData Item = (StaticRoutingData)ItemObj;

                        RoutingList.Items.Add(CreateLVIFromStaticRoutingRule(Item));
                    }
                }
                else if (EventArgs.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
                {
                    foreach (var ItemObj in EventArgs.OldItems)
                    {
                        StaticRoutingData Item = (StaticRoutingData)ItemObj;

                        foreach (var ListItemObj in RoutingList.Items)
                        {
                            var ListViewItem = ListItemObj as ListViewItem;
                            if (ListViewItem.Tag.Equals(Item))
                            {
                                RoutingList.Items.Remove(ListViewItem);
                                break;
                            }
                        }
                    }
                }

                RefreshDiff();
            }
                );
        }
        public DMRoutingViewController(UIViewController parentViewController, uint joinNumber, string title)
            : base(parentViewController, joinNumber, title, TimeSpan.Zero)
        {
            CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironmentOnProgramStatusEventHandler;
            var uiController = parentViewController.UIController as UIControllerWithSmartObjects;

            if (uiController == null)
            {
                CloudLog.Error("Could not load smartobject for {0}", GetType().Name);
                return;
            }

            _inputList = new RoutingList(uiController,
                                         uiController.Device.SmartObjects[Joins.SmartObjects.DmRoutingInputsList]);
            _outputList = new RoutingList(uiController,
                                          uiController.Device.SmartObjects[Joins.SmartObjects.DmRoutingOutputsList]);
            _inputListButtons  = new ButtonCollection(_inputList);
            _outputListButtons = new ButtonCollection(_outputList);

            _takeButton = new UIButton(this, Digitals.DmRoutingTakeButton)
            {
                EnableJoin = Device.BooleanInput[Digitals.DmRoutingTakeButtonEnable]
            };
            _cancelButton = new UIButton(this, Digitals.DmRoutingCancelButton)
            {
                EnableJoin = Device.BooleanInput[Digitals.DmRoutingCancelButtonEnable]
            };

            _switcher = ((ASystem)UIController.System).Switcher as DmSwitcherBase;

            if (_switcher == null)
            {
                CloudLog.Error("Invalid switcher type for {0}", GetType().Name);
                return;
            }

            var config = ConfigManager.Config.SwitcherConfig;

            UpdateLists(config);
        }