| | |
| | | using HDL_ON.DriverLayer; |
| | | using HDL_ON.Entity; |
| | | using HDL_ON.UI.CSS; |
| | | using Java.Util.Functions; |
| | | using Shared; |
| | | |
| | | namespace HDL_ON.UI |
| | |
| | | |
| | | attrView.AddChidren(new Button() { Height = Application.GetRealHeight(18) }); |
| | | |
| | | btnSwitch = new Button() |
| | | var btnOn = new Button() |
| | | { |
| | | Gravity = Gravity.CenterHorizontal, |
| | | X = Application.GetRealWidth(100), |
| | | Y = Application.GetRealHeight(466), |
| | | Width = Application.GetMinRealAverage(32), |
| | | Height = Application.GetMinRealAverage(32), |
| | | //UnSelectedImagePath = "Public/PowerClose.png", |
| | | UnSelectedImagePath = "Public/PowerOpen.png", |
| | | }; |
| | | controlView.AddChidren(btnOn); |
| | | |
| | | var btnOff = new Button() |
| | | { |
| | | X = Application.GetRealWidth(180), |
| | | Y = Application.GetRealHeight(466), |
| | | Width = Application.GetMinRealAverage(32), |
| | | Height = Application.GetMinRealAverage(32), |
| | | UnSelectedImagePath = "Public/PowerClose.png", |
| | | SelectedImagePath = "Public/PowerOpen.png", |
| | | //UnSelectedImagePath = "Public/PowerOpen.png", |
| | | }; |
| | | controlView.AddChidren(btnSwitch); |
| | | btnSwitch.MouseUpEventHandler = (sender, e) => { |
| | | if (btnSwitch.IsSelected) |
| | | controlView.AddChidren(btnOff); |
| | | btnOn.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | btnSwitch.IsSelected = false; |
| | | var d = new Dictionary<string, string>(); |
| | | d.Add(FunctionAttributeKey.OnOff, "off"); |
| | | function.Control(d); |
| | | } |
| | | else |
| | | { |
| | | btnSwitch.IsSelected = true; |
| | | var d = new Dictionary<string, string>(); |
| | | d.Add(FunctionAttributeKey.OnOff, "on"); |
| | | function.Control(d); |
| | | } |
| | | }; |
| | | |
| | | btnOff.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | var d = new Dictionary<string, string>(); |
| | | d.Add(FunctionAttributeKey.OnOff, "off"); |
| | | function.Control(d); |
| | | }; |
| | | |
| | | |
| | |
| | | btnSwitchIcon.MouseUpEventHandler = (sender, e) => { |
| | | if (btnSwitchIcon.IsSelected) |
| | | { |
| | | btnSwitchIcon.IsSelected = btnSwitch.IsSelected = false; |
| | | var d = new Dictionary<string, string>(); |
| | | d.Add(FunctionAttributeKey.OnOff, "off"); |
| | | function.Control(d); |
| | | } |
| | | else |
| | | { |
| | | btnSwitchIcon.IsSelected = btnSwitch.IsSelected = true; |
| | | var d = new Dictionary<string, string>(); |
| | | d.Add(FunctionAttributeKey.OnOff, "on"); |
| | | function.Control(d); |
| | | } |
| | | }; |
| | | btnSwitch.MouseUpEventHandler += (sender, e) => { |
| | | btnSwitchIcon.IsSelected = btnSwitch.IsSelected; |
| | | }; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | Button btnSwitch; |
| | | |
| | | /// <summary> |
| | | /// 加载调光属性设置控件 |
| | |
| | | }; |
| | | dimmerView.AddChidren(btnBrightnessText); |
| | | |
| | | dimmerBar.OnStopTrackingTouchEvent = (sender, e) => { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | var d = new Dictionary<string, string>(); |
| | | d.Add(FunctionAttributeKey.Brightness, e.ToString()); |
| | | function.Control(d); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | }; |
| | | |
| | | dimmerBar.OnProgressChangedEvent = (sender, e) => |
| | | { |
| | | if (e == 0 && lastBrightness != 0) |
| | | { |
| | | btnSwitch.IsSelected = false; |
| | | lastBrightness = 0; |
| | | } |
| | | else |
| | | { |
| | | if (lastBrightness == 0) |
| | | lastBrightness = e; |
| | | btnSwitch.IsSelected = true; |
| | | } |
| | | if (e == 0 || e == 100) |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100); |
| | | btnBrightnessText.Text = dimmerBar.Progress + "%"; |
| | | }; |
| | | |
| | | btnSwitch.MouseUpEventHandler += (sender, e) => { |
| | | if (btnSwitch.IsSelected) |
| | | { |
| | | dimmerBar.Progress = 100; |
| | | } |
| | | else |
| | | { |
| | | dimmerBar.Progress = 0; |
| | | } |
| | | btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100); |
| | | btnBrightnessText.Text = dimmerBar.Progress + "%"; |
| | | }; |
| | |
| | | }; |
| | | dimmerView.AddChidren(btnBrightnessText); |
| | | |
| | | dimmerBar.OnStopTrackingTouchEvent = (sender, e) => { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | var d = new Dictionary<string, string>(); |
| | | d.Add(FunctionAttributeKey.Brightness, e.ToString()); |
| | | function.Control(d); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | }; |
| | | |
| | | dimmerBar.OnProgressChangedEvent = (sender, e) => |
| | | { |
| | | if (e == 0 && lastBrightness != 0) |
| | | { |
| | | btnSwitch.IsSelected = false; |
| | | lastBrightness = 0; |
| | | } |
| | | else |
| | | { |
| | | if (lastBrightness == 0) |
| | | lastBrightness = e; |
| | | btnSwitch.IsSelected = true; |
| | | } |
| | | |
| | | if (e == 0 || e == 100) |
| | |
| | | btnBrightnessText.Text = dimmerBar.Progress + "%"; |
| | | }; |
| | | |
| | | btnSwitch.MouseUpEventHandler += (sender, e) => { |
| | | if (btnSwitch.IsSelected) |
| | | { |
| | | dimmerBar.Progress = 100; |
| | | } |
| | | else |
| | | { |
| | | dimmerBar.Progress = 0; |
| | | } |
| | | btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100); |
| | | btnBrightnessText.Text = dimmerBar.Progress + "%"; |
| | | }; |
| | | |
| | | //attrView.AddChidren(new Button() { Height = Application.GetRealHeight(10) }); |
| | | |
| | |
| | | ColorImagePath = "FunctionIcon/Light/ColorWheel.png", |
| | | }; |
| | | framePickerBack.AddChidren(colorPicker); |
| | | if (function.trait_on_off.curValue.ToString() == "off") |
| | | { |
| | | colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png"; |
| | | } |
| | | //if (function.trait_on_off.curValue.ToString() == "off") |
| | | //{ |
| | | // colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png"; |
| | | //} |
| | | //colorPicker.MouseDownEventHandler = (sender, e) => { |
| | | // MainPage.BasePageView.ScrollEnabled = false; |
| | | //}; |
| | |
| | | }; |
| | | colorPicker.ColorChaged += (sender2, e2) => |
| | | { |
| | | if ( pointIsRight == false) |
| | | { |
| | | return; |
| | | } |
| | | //if (colorPicker.ColorImagePath == "FunctionIcon/Light/ColorWheelGray.png") |
| | | //{ |
| | | // return; |
| | | //} |
| | | if (function.refreshTime.AddMilliseconds(350) > DateTime.Now) |
| | | { |
| | | MainPage.Log("频繁控制,退出"); |
| | | return; |
| | | } |
| | | function.refreshTime = DateTime.Now; |
| | | rgbString = (e2[0] + "," + e2[1] + "," + e2[2]).ToString(); |
| | | |
| | | btnCurColor.BackgroundColor = (uint)(0xFF000000 + rgbTemp.GetRGBcolor(rgbString)); |
| | | var d = new Dictionary<string, string>(); |
| | | d.Add(FunctionAttributeKey.RGB, rgbString); |
| | |
| | | colorPicker.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | pointIsRight = this.CheckPoint(circleR, colorPicker.Width / 2, colorPicker.Height / 2, (int)e.X, (int)e.Y); |
| | | if (function.trait_on_off.curValue.ToString() == "off" || pointIsRight == false) |
| | | if (pointIsRight == false) |
| | | { |
| | | //pointIsRight:点的区域不是圆盘内 |
| | | return; |
| | | } |
| | | |
| | | //if (colorPicker.ColorImagePath == "FunctionIcon/Light/ColorWheelGray.png") |
| | | //{ |
| | | // return; |
| | | //} |
| | | //显示白点 |
| | | btnWhiteRound.X = (int)e.X - btnWhiteRound.Width / 2; |
| | | btnWhiteRound.Y = (int)e.Y - btnWhiteRound.Height / 2; |
| | |
| | | }; |
| | | controlView.AddChidren(dimmerBar); |
| | | |
| | | dimmerBar.OnStopTrackingTouchEvent = (sender, e) => { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | var d = new Dictionary<string, string>(); |
| | | d.Add(FunctionAttributeKey.Brightness, e.ToString()); |
| | | function.Control(d); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | }; |
| | | |
| | | dimmerBar.OnProgressChangedEvent = (sender, e) => |
| | | { |
| | | if (e == 0 && lastBrightness != 0) |
| | | { |
| | | btnSwitch.IsSelected = false; |
| | | lastBrightness = 0; |
| | | } |
| | | else |
| | | { |
| | | if (lastBrightness == 0) |
| | | lastBrightness = e; |
| | | btnSwitch.IsSelected = true; |
| | | } |
| | | if (e == 0 || e == 100) |
| | | { |
| | |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | } |
| | | if (e == 0) |
| | | { |
| | | if (function.trait_on_off.curValue.ToString() == "on") |
| | | { |
| | | function.SetAttrState(FunctionAttributeKey.OnOff, "off"); |
| | | colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png"; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (function.trait_on_off.curValue.ToString() == "off") |
| | | { |
| | | function.SetAttrState(FunctionAttributeKey.OnOff, "on"); |
| | | colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheel.png"; |
| | | } |
| | | } |
| | | //if (e == 0) |
| | | //{ |
| | | // if (colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheelGray.png") |
| | | // { |
| | | // colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png"; |
| | | // } |
| | | //} |
| | | //else |
| | | //{ |
| | | // if (colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheel.png") |
| | | // { |
| | | // colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheel.png"; |
| | | // } |
| | | //} |
| | | }; |
| | | |
| | | |
| | | |
| | | var btnMaxValuesText = new Button() |
| | |
| | | }; |
| | | controlView.AddChidren(btnMaxValuesText); |
| | | |
| | | btnSwitch.MouseUpEventHandler += (sender, e) => { |
| | | if (btnSwitch.IsSelected) |
| | | { |
| | | dimmerBar.Progress = 100; |
| | | function.SetAttrState(FunctionAttributeKey.OnOff, "on"); |
| | | colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheel.png"; |
| | | } |
| | | else |
| | | { |
| | | dimmerBar.Progress = 0; |
| | | function.SetAttrState(FunctionAttributeKey.OnOff, "off"); |
| | | colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png"; |
| | | } |
| | | }; |
| | | #endregion |
| | | |
| | | int heightMore = 375 - magriHeight-20; |