public PowerOutletSlider(int id) { SetSizeRequest(180, 180); ampBar = new TouchCurvedProgressBar(); ampBar.SetSizeRequest(170, 135); ampBar.curveStyle = CurveStyle.ThreeQuarterCurve; Put(ampBar, 5, 5); ampBar.Show(); ampText = new TouchLabel(); ampText.WidthRequest = 180; ampText.textAlignment = TouchAlignment.Center; ampText.textRender.unitOfMeasurement = UnitsOfMeasurement.Amperage; ampText.text = "0.0"; ampText.textSize = 20; ampText.textColor = "pri"; Put(ampText, 0, 105); ampText.Show(); ss = new TouchSelectorSwitch(id, 3, 0, TouchOrientation.Horizontal); ss.sliderSize = MySliderSize.Large; ss.WidthRequest = 170; ss.HeightRequest = 30; ss.sliderColorOptions[0] = "grey2"; ss.sliderColorOptions[1] = "pri"; ss.sliderColorOptions[2] = "seca"; ss.textOptions[0] = "Off"; ss.textOptions[1] = "Auto"; ss.textOptions[2] = "On"; Put(ss, 5, 145); ss.Show(); outletName = new TouchLabel(); outletName.textColor = "grey3"; outletName.WidthRequest = 100; outletName.textRender.textWrap = TouchTextWrap.Shrink; outletName.textAlignment = TouchAlignment.Center; Put(outletName, 40, 67); outletName.Show(); statusLabel = new TouchLabel(); statusLabel.text = "Off"; statusLabel.textSize = 20; statusLabel.textColor = "grey4"; statusLabel.WidthRequest = 180; statusLabel.textAlignment = TouchAlignment.Center; Put(statusLabel, 0, 37); statusLabel.Show(); outletSubscriber = new OutputChannelValueSubscriber(OnValueChanged); ShowAll(); }
public SettingsSelectorSwitch(string name, string label1, string label2) : base(name) { selectorSwitch = new TouchSelectorSwitch(2); selectorSwitch.currentSelected = 0; selectorSwitch.sliderSize = MySliderSize.Large; selectorSwitch.sliderColorOptions[0] = "pri"; selectorSwitch.sliderColorOptions[1] = "grey2"; selectorSwitch.SetSizeRequest(170, 30); selectorSwitch.ExposeEvent += OnExpose; Put(selectorSwitch, 120, 0); selectorSwitch.Show(); labels = new string[2]; labels[0] = label1; labels[1] = label2; }
protected void OnExpose(object sender, ExposeEventArgs args) { TouchSelectorSwitch ss = sender as TouchSelectorSwitch; int seperation = ss.Allocation.Width / ss.selectionCount; int x = ss.Allocation.Left; TouchText render = new TouchText(); render.textWrap = TouchTextWrap.Shrink; render.alignment = TouchAlignment.Center; render.font.color = "white"; foreach (var l in labels) { render.text = l; render.Render(ss, x, ss.Allocation.Top, seperation, ss.Allocation.Height); x += seperation; } }
public DigitalDisplay() { SetSizeRequest(120, 140); label = new TouchLabel(); label.WidthRequest = 120; label.textAlignment = TouchAlignment.Center; label.textRender.textWrap = TouchTextWrap.Shrink; label.textColor = "grey3"; Put(label, 0, 35); textBox = new TouchLabel(); textBox.text = "Open"; textBox.textColor = "seca"; textBox.textAlignment = TouchAlignment.Center; textBox.textSize = 20; textBox.SetSizeRequest(120, 30); Put(textBox, 0, 0); button = new TouchButton(); button.text = "Force"; button.buttonColor = "grey3"; button.ButtonReleaseEvent += OnForceReleased; button.SetSizeRequest(120, 30); Put(button, 0, 55); selector = new TouchSelectorSwitch(2); selector.SetSizeRequest(120, 30); selector.sliderSize = MySliderSize.Large; selector.textOptions[0] = "Open"; selector.textOptions[1] = "Closed"; selector.sliderColorOptions[0] = "grey2"; selector.sliderColorOptions[1] = "pri"; selector.SelectorChangedEvent += OnSelectorChange; selector.Visible = false; Put(selector, 0, 90); Show(); }
public LightingWindow(params object[] options) : base(false) { sceneTitle = "Lighting"; fixtureName = Devices.Lighting.defaultGadget; if (fixtureName.IsNotEmpty()) { dimmingIsManual = false; } if (options.Length >= 3) { string requestedFixture = options[2] as string; if (requestedFixture != null) { if (Devices.Lighting.CheckGadgetKeyNoThrow(requestedFixture)) { fixtureName = requestedFixture; } } } outletSelectorSwitch = new TouchSelectorSwitch(3); outletSelectorSwitch.WidthRequest = 180; outletSelectorSwitch.sliderColorOptions[1] = "pri"; outletSelectorSwitch.selectedTextColorOptions[1] = "black"; outletSelectorSwitch.sliderColorOptions[2] = "seca"; outletSelectorSwitch.textOptions = new string[] { "Off", "Auto", "On" }; outletSelectorSwitch.SelectorChangedEvent += OnOutletControlSelectorChanged; Put(outletSelectorSwitch, 605, 77); outletSelectorSwitch.Show(); outletStateLabel = new TouchLabel(); outletStateLabel.textAlignment = TouchAlignment.Center; outletStateLabel.WidthRequest = 180; outletStateLabel.textSize = 14; Put(outletStateLabel, 605, 110); outletStateLabel.Show(); dimmingHeader = new TouchLabel(); dimmingHeader.textAlignment = TouchAlignment.Center; dimmingHeader.WidthRequest = 180; dimmingHeader.text = "Dimming Control"; Put(dimmingHeader, 605, 148); dimmingHeader.Show(); modeSelector = new TouchSelectorSwitch(); modeSelector.SetSizeRequest(140, 30); modeSelector.sliderColorOptions[1] = "pri"; modeSelector.selectedTextColorOptions[1] = "black"; modeSelector.textOptions = new string[] { "Manual", "Auto" }; modeSelector.SelectorChangedEvent += OnDimmingModeSelectorChanged; Put(modeSelector, 605, 173); modeSelector.Show(); dimmingProgressBar = new TouchLayeredProgressBar(); dimmingProgressBar.colorProgress = "seca"; dimmingProgressBar.colorProgressSecondary = "pri"; dimmingProgressBar.drawPrimaryWhenEqual = false; dimmingProgressBar.ProgressChangedEvent += OnProgressChanged; dimmingProgressBar.ProgressChangingEvent += OnProgressChanging; dimmingProgressBar.HeightRequest = 280; Put(dimmingProgressBar, 755, 173); dimmingProgressBar.Show(); actualTextBox = new TouchLabel(); actualTextBox.WidthRequest = 140; actualTextBox.textSize = 20; actualTextBox.textColor = "pri"; actualTextBox.textAlignment = TouchAlignment.Center; actualTextBox.textRender.unitOfMeasurement = UnitsOfMeasurement.Percentage; Put(actualTextBox, 605, 209); actualTextBox.Show(); actualLabel = new TouchLabel(); actualLabel.WidthRequest = 140; actualLabel.text = "Current"; actualLabel.textColor = "grey3"; actualLabel.textAlignment = TouchAlignment.Center; Put(actualLabel, 605, 244); actualLabel.Show(); requestedLabel = new TouchLabel(); requestedLabel.WidthRequest = 140; requestedLabel.textSize = 20; requestedLabel.textColor = "seca"; requestedLabel.textAlignment = TouchAlignment.Center; requestedLabel.textRender.unitOfMeasurement = UnitsOfMeasurement.Percentage; Put(requestedLabel, 605, 272); requestedLabel.Show(); requestedTextBox = new TouchTextBox(); requestedTextBox.enableTouch = true; requestedTextBox.TextChangedEvent += (sender, args) => { try { float newLevel = Convert.ToSingle(args.text); if (newLevel < 0.0f) { newLevel = 0.0f; } if (newLevel > 100.0f) { newLevel = 100.0f; } Devices.Lighting.SetDimmingLevel(fixtureName, newLevel); } catch (Exception ex) { MessageBox.Show(ex.Message); args.keepText = false; } }; requestedTextBox.SetSizeRequest(110, 36); requestedTextBox.textSize = 20; requestedTextBox.textColor = "seca"; requestedTextBox.textAlignment = TouchAlignment.Center; requestedTextBox.textRender.unitOfMeasurement = UnitsOfMeasurement.Percentage; requestedTextBox.Visible = false; Put(requestedTextBox, 620, 272); requestedTextBox.Show(); requestedTextLabel = new TouchLabel(); requestedTextLabel.WidthRequest = 140; requestedTextLabel.text = "Requested"; requestedTextLabel.textColor = "grey3"; requestedTextLabel.textAlignment = TouchAlignment.Center; Put(requestedTextLabel, 605, 307); requestedTextLabel.Show(); autoTextBox = new TouchLabel(); autoTextBox.WidthRequest = 140; autoTextBox.Visible = false; autoTextBox.textSize = 20; autoTextBox.textColor = "grey4"; autoTextBox.textAlignment = TouchAlignment.Center; autoTextBox.textRender.unitOfMeasurement = UnitsOfMeasurement.Percentage; Put(autoTextBox, 605, 335); autoTextBox.Show(); autoLabel = new TouchLabel(); autoLabel.WidthRequest = 140; autoLabel.Visible = false; autoLabel.text = "Auto"; autoLabel.textColor = "grey3"; autoLabel.textAlignment = TouchAlignment.Center; Put(autoLabel, 605, 370); autoLabel.Show(); fixtureSettingBtn = new TouchButton(); fixtureSettingBtn.text = Convert.ToChar(0x2699).ToString(); fixtureSettingBtn.SetSizeRequest(30, 30); fixtureSettingBtn.buttonColor = "pri"; fixtureSettingBtn.ButtonReleaseEvent += OnFixtureSettingsButtonReleased; Put(fixtureSettingBtn, 755, 35); fixtureSettingBtn.Show(); lightingStateWidget = new LightingStateWidget(); Put(lightingStateWidget, 55, 77); lightingStateWidget.Show(); combo = new TouchComboBox(Devices.Lighting.GetAllGadgetNames()); combo.comboList.Add("New fixture..."); combo.activeIndex = 0; combo.WidthRequest = 250; combo.ComboChangedEvent += OnComboChanged; Put(combo, 500, 35); combo.Show(); if (fixtureName.IsNotEmpty()) { combo.activeText = fixtureName; } else { combo.activeIndex = 0; } outletSubscriber = new OutputChannelValueSubscriber(OnValueChanged); GetFixtureData(); lightingStateWidget.SetStates(fixtureName); Show(); }
public LightingStateWidget() { SetSizeRequest(540, 380); lightingStateDisplay = new LightingStateDisplay(); lightingStateDisplay.SetSizeRequest(540, 380); lightingStateDisplay.LightingStateSelectionChanged += (obj, args) => { if (args.stateSelected) { adjustDimmingTogetherSelector.Visible = true; adjustDimmingTogetherLabel.Visible = true; deleteStateButton.Visible = true; } else { adjustDimmingTogetherSelector.Visible = false; adjustDimmingTogetherLabel.Visible = false; deleteStateButton.Visible = false; } }; lightingStateDisplay.LightingStateInfoChanged += (obj, hasChanged) => { if (hasChanged) { acceptChangesButton.buttonColor = "pri"; undoChangesButton.buttonColor = "pri"; } else { acceptChangesButton.buttonColor = "grey1"; undoChangesButton.buttonColor = "grey1"; } acceptChangesButton.QueueDraw(); undoChangesButton.QueueDraw(); }; Put(lightingStateDisplay, 0, 0); lightingStateDisplay.Show(); adjustDimmingTogetherSelector = new TouchSelectorSwitch(); adjustDimmingTogetherSelector.SetSizeRequest(180, 30); adjustDimmingTogetherSelector.sliderSize = MySliderSize.Large; adjustDimmingTogetherSelector.textOptions[0] = "Separate"; adjustDimmingTogetherSelector.textOptions[1] = "Together"; adjustDimmingTogetherSelector.sliderColorOptions[1] = "pri"; adjustDimmingTogetherSelector.selectedTextColorOptions[1] = "black"; adjustDimmingTogetherSelector.currentSelected = 1; adjustDimmingTogetherSelector.SelectorChangedEvent += (obj, args) => { lightingStateDisplay.adjustDimmingTogether = args.currentSelectedIndex == 1; }; Put(adjustDimmingTogetherSelector, 0, 350); adjustDimmingTogetherLabel = new TouchLabel(); adjustDimmingTogetherLabel.text = "Adjust Dimming"; adjustDimmingTogetherLabel.WidthRequest = 180; adjustDimmingTogetherLabel.textAlignment = TouchAlignment.Center; Put(adjustDimmingTogetherLabel, 0, 328); acceptChangesButton = new TouchButton(); acceptChangesButton.text = "Accept"; acceptChangesButton.buttonColor = "grey1"; acceptChangesButton.SetSizeRequest(80, 40); acceptChangesButton.ButtonReleaseEvent += (obj, args) => { if (lightingStateDisplay.hasStateInfoChanged) { var parent = Toplevel as Window; var ms = new TouchDialog("Do you want to make the changes permanent", parent, new string[] { "Yes", "No", "Cancel" }); ms.Response += (o, a) => { if (a.ResponseId != ResponseType.Cancel) { var makeChangePermanant = a.ResponseId == ResponseType.Yes; Devices.Lighting.SetLightingFixtureLightingStates( fixtureName, lightingStateDisplay.lightingStates, !makeChangePermanant); lightingStateDisplay.selectedState = -1; lightingStateDisplay.hasStateInfoChanged = false; lightingStateDisplay.QueueDraw(); } }; ms.Run(); ms.Destroy(); } }; Put(acceptChangesButton, 460, 340); acceptChangesButton.Show(); undoChangesButton = new TouchButton(); undoChangesButton.text = "Undo"; undoChangesButton.buttonColor = "grey1"; undoChangesButton.SetSizeRequest(80, 40); undoChangesButton.ButtonReleaseEvent += (obj, args) => { if (lightingStateDisplay.hasStateInfoChanged) { SetStates(fixtureName); } }; Put(undoChangesButton, 370, 340); undoChangesButton.Show(); deleteStateButton = new TouchButton(); deleteStateButton.text = "Delete"; deleteStateButton.SetSizeRequest(80, 40); deleteStateButton.buttonColor = "compl"; deleteStateButton.textColor = "white"; deleteStateButton.ButtonReleaseEvent += (obj, args) => { var parent = Toplevel as Window; var ms = new TouchDialog("Are you sure you want to delete the state", parent); ms.Response += (o, a) => { if (a.ResponseId == ResponseType.Yes) { lightingStateDisplay.RemoveSelectedState(); } }; ms.Run(); ms.Destroy(); }; Put(deleteStateButton, 280, 340); Show(); }