Exemple #1
0
        public ChannelPage(ChannelData channel, ChannelsPage parentChannelsPage, bool isMasterChannel) : base("div")
        {
            _channel            = channel;
            _parentChannelsPage = parentChannelsPage;
            _isMasterChannel    = isMasterChannel;
            SetBorder(BorderKind.Rounded, StylingColor.Secondary);

            #region Initialize Grid

            Grid grid = new Grid(this);
            grid.AddStyling(StylingOption.MarginRight, 2);
            grid.AddStyling(StylingOption.MarginLeft, 2);
            grid.AddStyling(StylingOption.MarginTop, 4);
            grid.AddStyling(StylingOption.MarginBottom, 2);

            #endregion Initialize Grid

            #region TextInputGroup ProgrammName

            MultiInputGroup channelNameMultiInputGroup = new MultiInputGroup();
            channelNameMultiInputGroup.AppendLabel("Kanal:");
            channelNameMultiInputGroup.AppendLabel(channel.ChannelId.ToString());
            channelNameMultiInputGroup.AppendLabel("  Name:");
            _channelNameTextInput = channelNameMultiInputGroup.AppendTextInput("Kanalname?", true, channel.Name);

            channelNameMultiInputGroup.AddStyling(StylingOption.MarginBottom, 2);

            if (!isMasterChannel)
            {
                _deleteChannelButton        = new Button(StylingColor.Danger, asOutline: true, text: "Kanal Löschen", fontAwesomeIcon: "trash");
                _deleteChannelButton.Click += DeleteChannelButtonOnClick;
                channelNameMultiInputGroup.AppendCustomElement(_deleteChannelButton, false);
            }
            else
            {
                _channelNameTextInput.IsDisabled = true;
            }
            grid.AddRow().AppendCollum(channelNameMultiInputGroup);

            #endregion TextInputGroup ProgrammName

            #region add TabNavigate

            _tabNavigation = new TabNavigation(true, true);
            _tabNavigation.AddButton.Click += (sender, args) =>
            {
                ChannelProgramData channelProgramData = ChannelProgramData.CreateNew(channel.ProgramList.Count > 0 ? channel.ProgramList.Max(data => int.TryParse(data.Name, out int parsedInt) ? parsedInt : 1) + 1 : 1);
                channel.ProgramList.Add(channelProgramData);
                ChannelProgrammPage channelProgrammPage = new ChannelProgrammPage(channelProgramData, this, isMasterChannel);
                _channelProgrammPages.Add(channelProgrammPage);
                _tabDictionary.Add(channelProgramData, _tabNavigation.AddTab(channelProgramData.Id.ToString(), channelProgrammPage, channelProgramData.Id == 1));
            };
            grid.AddRow().AppendCollum(_tabNavigation);

            #endregion add TabNavigate

            #region add ChannelProgrammPages

            foreach (ChannelProgramData channelProgramData in channel.ProgramList)
            {
                ChannelProgrammPage channelProgrammPage = new ChannelProgrammPage(channelProgramData, this, isMasterChannel);
                _channelProgrammPages.Add(channelProgrammPage);
                _tabDictionary.Add(channelProgramData, _tabNavigation.AddTab(channelProgramData.Id.ToString(), channelProgrammPage, channelProgramData.Id == channel.ProgramList.First().Id));
                ApplyName(channelProgramData);
            }

            #endregion add ChannelProgrammPages

            #region AddHumiditySensor

            AddHumiditySensor(channel, grid);

            _humiditySensorDropdown.Button.IsDisabled            = _isMasterChannel;
            _humiditySensorEnabledTwoStateButtonGroup.IsDisabled = _isMasterChannel;

            #endregion AddHumiditySensor

            #region SaveChannel Button

            Button saveButton = new Button(StylingColor.Success, true, Button.ButtonSize.Normal, false, "Speichern", fontAwesomeIcon: "save");
            saveButton.AddStyling(StylingOption.MarginTop, 4);
            saveButton.AddStyling(StylingOption.MarginLeft, 4);
            saveButton.AddStyling(StylingOption.MarginBottom, 1);
            saveButton.AddStyling(StylingOption.PaddingLeft, 5);
            saveButton.AddStyling(StylingOption.PaddingRight, 5);
            saveButton.Click += SaveButton_Click;
            grid.AddRow().AppendCollum(saveButton);

            #endregion SaveChannel Button
        }
Exemple #2
0
 public void RemoveProgramm(ChannelProgrammPage channelProgrammPage, ChannelProgramData channelProgram)
 {
     _channelProgrammPages.Remove(channelProgrammPage);
     _channel.ProgramList.Remove(channelProgram);
     _tabNavigation.RemoveTab(channelProgram.Id.ToString(), channelProgrammPage);
 }