gxc
2019-12-25 944b87b6bcccb095cd73f13f4410fb20faf48f74
ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs
@@ -42,15 +42,6 @@
        public void ShowForm(string deviceMac)
        {
            this.listNewDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
            //排序
            this.listNewDevice.Sort((obj1, obj2) =>
            {
                if (obj1.DeviceEpoint > obj2.DeviceEpoint)
                {
                    return 1;
                }
                return -1;
            });
            this.listDeviceType.Clear();
            foreach (var device in listNewDevice)
@@ -83,14 +74,15 @@
            this.ClearBodyFrame();
            //初始化桌布
            this.InitFrameTable();
            var tableContr = new InformationEditorControl();
            this.listview = tableContr.InitControl(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 369, 1368);
            //图片
            var btnPic = new DeviceInfoIconControl(listNewDevice[0]);
            var btnPic = new DeviceInfoIconControl();
            btnPic.Y = Application.GetRealHeight(92);
            btnPic.Gravity = Gravity.CenterHorizontal;
            bodyFrameLayout.AddChidren(btnPic);
            btnPic.InitControl();
            btnPic.InitControl(listNewDevice[0]);
            //设备备注
            string caption = Language.StringByID(R.MyInternationalizationString.uDeviceNote);
@@ -103,14 +95,14 @@
            btnNote.txtInput.FinishInputEvent += () =>
            {
                string oldName = Common.LocalDevice.Current.GetDeviceMacName(listNewDevice[0]);
                if (btnNote.Text.Trim() == string.Empty)
                if (btnNote.Text == string.Empty)
                {
                    btnNote.Text = oldName;
                }
                if (oldName != btnNote.Text.Trim())
                if (oldName != btnNote.Text)
                {
                    //修改名字
                    this.DeviceReName(btnNote.Text.Trim(), false);
                    this.DeviceReName(btnNote.Text, false);
                }
            };
@@ -124,17 +116,45 @@
            //划线
            btnType.AddBottomLine();
            //所属区域
            var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
            listview.AddChidren(rowBeloneArea);
            rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), this.listNewDevice);
            //底线
            rowBeloneArea.AddBottomLine();
            var listCheck = new List<string>();
            rowBeloneArea.SelectRoomEvent += (roomKeys) =>
            {
                foreach (var device in this.listNewDevice)
                {
                    var room = Room.CurrentRoom.GetRoomByDevice(device);
                    string mainKeys = LocalDevice.Current.GetDeviceMainKeys(device);
                    if (room == null)
                    {
                        //这里有点特殊,如果回路没有设置有区域的时候,才设置
                        listCheck.Add(mainKeys);
                        Room.CurrentRoom.ChangedRoom(device, roomKeys);
                    }
                    else if (listCheck.Contains(mainKeys) == true)
                    {
                        //如果这个回路之前都还没有区域,在本界面还没有关闭之前,可以无条件随便变更
                        Room.CurrentRoom.ChangedRoom(device, roomKeys);
                    }
                }
                //保存设备房间索引
                Common.LocalDevice.Current.SaveRealDeviceRoomId(this.listNewDevice, roomKeys);
            };
            //添加全部菜单
            this.AddAllMenuRow();
            //初始化桌布完成
            tableContr.FinishInitControl(bodyFrameLayout, this.listview);
            tableContr = null;
            //保存
            var btnFinish = new BottomClickButton();
            //借用Y轴坐标(让这个区域不能点击菜单)
            var frameBack = new FrameLayout();
            frameBack.Y = btnFinish.Yaxis;
            frameBack.Height = bodyFrameLayout.Height - btnFinish.Yaxis;
            bodyFrameLayout.AddChidren(frameBack);
            btnFinish.TextID = R.MyInternationalizationString.uSave;
            bodyFrameLayout.AddChidren(btnFinish);
            btnFinish.ButtonClickEvent += (sender, e) =>
@@ -155,53 +175,6 @@
                    this.CloseForm();
                }
            };
            var realHeight = listview.GetChildren(0).Height * listview.ChildrenCount;
            if (bodyFrameLayout.Height - btnFinish.Yaxis + realHeight > listview.Height)
            {
                //促使被挡住的菜单能够向上滑动
                var frameTemp = new FrameLayout();
                frameTemp.Height = frameBack.Height + Application.GetRealHeight(115);
                listview.AddChidren(frameTemp);
            }
        }
        #endregion
        #region ■ 初始化桌布_________________________
        /// <summary>
        /// 初始化桌布
        /// </summary>
        private void InitFrameTable()
        {
            //弧度的圆的一半的高度(固定)
            int halfRoundHeigth = Application.GetRealHeight(116) / 2;
            //弧度的圆
            var btnRound = new NormalViewControl(bodyFrameLayout.Width, halfRoundHeigth * 2, false);
            btnRound.Y = Application.GetRealHeight(369);
            btnRound.BackgroundColor = UserCenterColor.Current.White;
            btnRound.Radius = (uint)halfRoundHeigth;
            bodyFrameLayout.AddChidren(btnRound);
            //明细列表的桌布,白色背景(覆盖弧度的圆的半边)
            var detailBackFrame = new FrameLayout();
            detailBackFrame.Y = btnRound.Bottom - btnRound.Height / 2;
            detailBackFrame.Height = Application.GetRealHeight(1368);//高度就是要它超过
            detailBackFrame.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(detailBackFrame);
            //信息编辑
            var btnTile = new NormalViewControl(800, 60, true);
            btnTile.X = ControlCommonResourse.XXLeft;
            btnTile.TextSize = 15;
            btnTile.TextColor = UserCenterColor.Current.TextColor2;
            btnTile.TextID = R.MyInternationalizationString.uInfoEditor;
            detailBackFrame.AddChidren(btnTile);
            this.listview = new VerticalListControl(12);
            listview.Y = btnTile.Bottom + Application.GetRealHeight(17);
            listview.Height = Application.GetRealHeight(1368) - halfRoundHeigth - btnTile.Bottom - Application.GetRealHeight(17);
            detailBackFrame.AddChidren(listview);
        }
        #endregion
@@ -227,8 +200,19 @@
                    this.AddDoorLocksTimeRow();
                }
            }
            else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.AirConditioner_ZbGateway)
            {
                //添加【室内机设置】行(空调专用)
                this.AddIndoorUnitSettionRow();
            }
            else
            {
                //添加【绑定目标】行(pir传感器专用)
                this.AddPirSensorBindRow();
                //添加【方向与限位】行(开合帘,卷帘专用)
                this.AddDirectionAndLimitRow();
                //添加【手拉控制】行(开合帘专用)
                this.AddHandPullControlRow();
                //添加【按键设置】行(面板专用)
                this.AddPanelSettionRow();
                //添加【功能设置】行
@@ -267,9 +251,55 @@
                btnRow.AddRightArrow();
                //底线
                btnRow.AddBottomLine();
                btnRow.ButtonClickEvent += (sender, e) =>
                {
                };
                var doorLock = this.listNewDevice[0] as ZigBee.Device.DoorLock;
                btnRow.ButtonClickEvent += async (sender, e) =>
                 {
                     if (UserCenterResourse.UserInfo.AuthorityNo == 1)
                     {
                         Action action = null;
                         Action actionNone = null;
                         action = () =>
                         {
                             var userManagement = new Shared.Phone.UserCenter.DoorLock.UserManagement(doorLock);
                             Shared.Phone.UserView.HomePage.Instance.AddChidren(userManagement);
                             Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                             userManagement.Show();
                         };
                         actionNone = () =>
                         {
                             Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock, action);
                         };
                         HdlCheckLogic.Current.CheckSecondarySecurity(action, actionNone);
                     }
                     else
                     {
                         CommonPage.Loading.Start("");
                         var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid);
                         if (result == false)
                         {
                             Action action = null;
                             Action actionNone = null;
                             action = () =>
                             {
                                 var userManagement = new Shared.Phone.UserCenter.DoorLock.UserManagement(doorLock);
                                 Shared.Phone.UserView.HomePage.Instance.AddChidren(userManagement);
                                 Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                                 userManagement.Show();
                             };
                             actionNone = () =>
                             {
                                 Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock, action);
                             };
                             HdlCheckLogic.Current.CheckSecondarySecurity(action, actionNone);
                         }
                         else
                         {
                             this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.AccountIsFreezed));
                         }
                         CommonPage.Loading.Hide();
                     }
                 };
            }
        }
@@ -291,18 +321,60 @@
                btnRow.UseClickStatu = false;
                listview.AddChidren(btnRow);
                btnRow.AddLeftCaption(caption, 600);
                //向右图标
                var btnswitch = btnRow.AddMostRightEmptyIcon(104, 63);
                btnRow.ChangedChidrenBindMode(btnswitch, ChidrenBindMode.NotBind);
                btnswitch.UnSelectedImagePath = "Item/Switch.png";
                btnswitch.SelectedImagePath = "Item/SwitchSelected.png";
                //开关图标
                var btnswitch = btnRow.AddMostRightSwitchIcon();
                //底线
                btnRow.AddBottomLine();
                btnswitch.ButtonClickEvent += (sender, e) =>
                var doorLock = (ZigBee.Device.DoorLock)listNewDevice[0];
                if (string.IsNullOrEmpty(doorLock.RemoteUnlockPassword) == false)
                {
                    btnswitch.IsSelected = !btnswitch.IsSelected;
                };
                    btnswitch.IsSelected = true;
                }
                btnswitch.ButtonClickEvent += async (sender, e) =>
                 {
                     if (UserCenterResourse.UserInfo.AuthorityNo == 1)
                     {
                         if (btnswitch.IsSelected == true)
                         {
                             btnswitch.IsSelected = false;
                             doorLock.RemoteUnlockPassword = string.Empty;
                             return;
                         }
                         var frame = new DoorLock.DoorLockCommonLayout();
                         frame.RemotePasswordDialog((ZigBee.Device.DoorLock)listNewDevice[0], btnswitch.btnIcon);
                         frame = null;
                     }
                     else
                     {
                         var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid);
                         if (result == false)
                         {
                             var result1 = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockUnlockAccess(doorLock, Shared.Common.Config.Instance.Guid);
                             if (result1 == true)
                             {
                                 if (btnswitch.IsSelected == true)
                                 {
                                     btnswitch.IsSelected = false;
                                     doorLock.RemoteUnlockPassword = string.Empty;
                                     return;
                                 }
                                 var frame = new DoorLock.DoorLockCommonLayout();
                                 frame.RemotePasswordDialog((ZigBee.Device.DoorLock)listNewDevice[0], btnswitch.btnIcon);
                                 frame = null;
                             }
                             else
                             {
                                 this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.NoAccess));
                             }
                         }
                         else
                         {
                             this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.AccountIsFreezed));
                         }
                     }
                 };
            }
        }
@@ -327,9 +399,32 @@
                btnRow.AddRightArrow();
                //底线
                btnRow.AddBottomLine();
                btnRow.ButtonClickEvent += (sender, e) =>
                {
                };
                var doorLock = this.listNewDevice[0] as ZigBee.Device.DoorLock;
                btnRow.ButtonClickEvent += async (sender, e) =>
                 {
                     if (UserCenterResourse.UserInfo.AuthorityNo == 1)
                     {
                         var tempPage = new Shared.Phone.UserCenter.DoorLock.TimeSettignPage(doorLock, "DoorLockTime");
                         Shared.Phone.UserView.HomePage.Instance.AddChidren(tempPage);
                         Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                         tempPage.Show();
                     }
                     else
                     {
                         var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid);
                         if (result == false)
                         {
                             var tempPage = new Shared.Phone.UserCenter.DoorLock.TimeSettignPage(doorLock, "DoorLockTime");
                             Shared.Phone.UserView.HomePage.Instance.AddChidren(tempPage);
                             Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                             tempPage.Show();
                         }
                         else
                         {
                             this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.AccountIsFreezed));
                         }
                     }
                 };
            }
        }
@@ -359,45 +454,11 @@
            btnFunction.ButtonClickEvent += (sender, e) =>
            {
                var form = new DevicePanel.PanelButtonSettionForm();
                form.AddForm(listNewDevice[0].DeviceAddr);
                form.AddForm(listNewDevice[0]);
            };
        }
        #endregion
        #region ■ 功能设置(通用)_____________________
        /// <summary>
        /// 添加【功能设置】行
        /// </summary>
        private void AddFunctionSettionRow()
        {
            //功能设置
            string caption = Language.StringByID(R.MyInternationalizationString.uFunctionSettingUp);
            var btnFunction = new FrameRowControl(listview.rowSpace / 2);
            listview.AddChidren(btnFunction);
            btnFunction.AddLeftCaption(caption, 600);
            //向右图标
            btnFunction.AddRightArrow();
            //底线
            btnFunction.AddBottomLine();
            btnFunction.ButtonClickEvent += (sender, e) =>
            {
                //河东的面板设备
                if (deviceEnumInfo.BeloneType == DeviceBeloneType.A按键面板 && deviceEnumInfo.IsHdlDevice == true)
                {
                    var form = new DevicePanel.PanelFunctionSettionForm();
                    form.AddForm(listNewDevice[0].DeviceAddr);
                }
                else
                {
                    var form = new DeviceRelay.DeviceFunctionSettionForm();
                    form.AddForm(listNewDevice[0].DeviceAddr);
                }
            };
        }
        #endregion;
        #region ■ 干接点设置(干接点)_________________
@@ -429,7 +490,214 @@
            btnBackLight.AddBottomLine();
            btnBackLight.ButtonClickEvent += (sender, e) =>
            {
                var form = new DeviceRelay.DeviceDryContactSettionForm();
                var form = new DeviceDryContactSettionForm();
                form.AddForm(listNewDevice[0]);
            };
        }
        #endregion
        #region ■ 绑定目标(pir传感器专用)____________
        /// <summary>
        /// 添加【绑定目标】行(pir传感器专用)
        /// </summary>
        private void AddPirSensorBindRow()
        {
            if (this.deviceEnumInfo.ConcreteType != DeviceConcreteType.Sensor_Pir)
            {
                return;
            }
            //绑定目标
            string caption = Language.StringByID(R.MyInternationalizationString.uBindTargets);
            var btnFunction = new FrameRowControl(listview.rowSpace / 2);
            listview.AddChidren(btnFunction);
            btnFunction.AddLeftCaption(caption, 600);
            //向右图标
            btnFunction.AddRightArrow();
            //底线
            btnFunction.AddBottomLine();
            btnFunction.ButtonClickEvent += (sender, e) =>
            {
                var form = new DevicePirSensor.PirSensorBindTargetSettionForm();
                form.AddForm((IASZone)this.listNewDevice[0]);
            };
        }
        #endregion;
        #region ■ 功能设置(通用)_____________________
        /// <summary>
        /// 添加【功能设置】行
        /// </summary>
        private void AddFunctionSettionRow()
        {
            //只有回路数大于1才能有这个菜单
            if (Common.LocalDevice.Current.GetDevicesCountByMac(listNewDevice[0].DeviceAddr) == 1)
            {
                return;
            }
            //功能设置
            string caption = Language.StringByID(R.MyInternationalizationString.uFunctionSettingUp);
            var btnFunction = new FrameRowControl(listview.rowSpace / 2);
            listview.AddChidren(btnFunction);
            btnFunction.AddLeftCaption(caption, 600);
            //向右图标
            btnFunction.AddRightArrow();
            //底线
            btnFunction.AddBottomLine();
            btnFunction.ButtonClickEvent += (sender, e) =>
            {
                //河东的面板设备
                if (deviceEnumInfo.BeloneType == DeviceBeloneType.A按键面板 && deviceEnumInfo.IsHdlDevice == true)
                {
                    var form = new DevicePanel.PanelFunctionSettionForm();
                    form.AddForm(listNewDevice[0]);
                }
                else
                {
                    var form = new DeviceFunctionSettionForm();
                    form.AddForm(listNewDevice[0], false);
                }
            };
        }
        #endregion;
        #region ■ 方向与限位(窗帘)___________________
        /// <summary>
        /// 添加【方向与限位】行(窗帘专用)
        /// </summary>
        private void AddDirectionAndLimitRow()
        {
            if (deviceEnumInfo.BeloneType != DeviceBeloneType.A窗帘)
            {
                return;
            }
            var deviceCurtain = (Rollershade)this.listNewDevice[0];
            if (deviceCurtain.WcdType != 4 && deviceCurtain.WcdType != 0)
            {
                //开合帘,卷帘专用
                return;
            }
            //方向与限位
            string caption = Language.StringByID(R.MyInternationalizationString.uDirectionAndLimit);
            var btnFunction = new FrameRowControl(listview.rowSpace / 2);
            listview.AddChidren(btnFunction);
            btnFunction.AddLeftCaption(caption, 600);
            //向右图标
            btnFunction.AddRightArrow();
            //底线
            btnFunction.AddBottomLine();
            btnFunction.ButtonClickEvent += (sender, e) =>
            {
                if (deviceCurtain.WcdType == 4)
                {
                    var form = new DeviceCurtain.AutoOpenDirectionAndLimitSettionForm();
                    form.AddForm(deviceCurtain);
                }
                else if (deviceCurtain.WcdType == 0)
                {
                    var form = new DeviceCurtain.SiphonateDirectionAndLimitSettionForm();
                    form.AddForm(deviceCurtain);
                }
            };
        }
        #endregion;
        #region ■ 手拉控制(开合帘)___________________
        /// <summary>
        /// 添加【手拉控制】行(开合帘专用)
        /// </summary>
        private void AddHandPullControlRow()
        {
            if (deviceEnumInfo.BeloneType != DeviceBeloneType.A窗帘)
            {
                return;
            }
            var deviceCurtain = (Rollershade)this.listNewDevice[0];
            if (deviceCurtain.WcdType != 4)
            {
                //开合帘专用
                return;
            }
            //手拉控制
            string caption = Language.StringByID(R.MyInternationalizationString.uHandPullControl);
            var btnFunction = new FrameRowControl(listview.rowSpace / 2);
            btnFunction.UseClickStatu = false;
            listview.AddChidren(btnFunction);
            btnFunction.AddLeftCaption(caption, 600);
            //开关图标
            var btnSwitch = btnFunction.AddMostRightSwitchIcon();
            //底线
            btnFunction.AddBottomLine();
            btnSwitch.ButtonClickEvent += async (sender, e) =>
            {
                //切换模式
                var result = await HdlDeviceCurtainLogic.Current.SetHandPullControl(deviceCurtain, !btnSwitch.IsSelected);
                if (result == true)
                {
                    btnSwitch.IsSelected = !btnSwitch.IsSelected;
                }
            };
            //添加属性上报监听
            string mainkeys = LocalDevice.Current.GetDeviceMainKeys(this.listNewDevice[0]);
            HdlGatewayReceiveLogic.Current.AddAttributeEvent("HandPullControl", ReceiveComandDiv.A设备属性上报, (device) =>
            {
                string checkKey = LocalDevice.Current.GetDeviceMainKeys(device);
                if (mainkeys != checkKey || device.DeviceStatusReport.CluterID != 258)
                {
                    return;
                }
                foreach (var attriBute in device.DeviceStatusReport.AttriBute)
                {
                    if (attriBute.AttributeId == 23)
                    {
                        //手拉控制
                        if (0 < (attriBute.AttriButeData & 0x04))
                        {
                            btnSwitch.IsSelected = true;
                        }
                    }
                }
            });
            //发送命令
            deviceCurtain.ReadCurtainDirectionAndMode();
        }
        #endregion;
        #region ■ 室内机设置(空调)___________________
        /// <summary>
        /// 添加【室内机设置】行(空调专用)
        /// </summary>
        private void AddIndoorUnitSettionRow()
        {
            if (this.deviceEnumInfo.ConcreteType != DeviceConcreteType.AirConditioner_ZbGateway)
            {
                return;
            }
            //室内机设置
            string caption = Language.StringByID(R.MyInternationalizationString.uIndoorUnitSettion);
            var btnFunction = new FrameRowControl(listview.rowSpace / 2);
            listview.AddChidren(btnFunction);
            btnFunction.AddLeftCaption(caption, 600);
            //向右图标
            btnFunction.AddRightArrow();
            //底线
            btnFunction.AddBottomLine();
            btnFunction.ButtonClickEvent += (sender, e) =>
            {
                var form = new DeviceAirConditioner.IndoorUnitListForm();
                form.AddForm(listNewDevice[0].DeviceAddr);
            };
        }
@@ -489,7 +757,7 @@
            btnNewVersion.UnSelectedImagePath = "Item/NewVersion.png";
            btnNewVersion.Visible = false;
            btnNewVersion.X = Application.GetRealWidth(242);
            btnNewVersion.Y= Application.GetRealHeight(23);
            btnNewVersion.Y = Application.GetRealHeight(23);
            rowUpDate.AddChidren(btnNewVersion, ChidrenBindMode.BindEventOnly);
            rowUpDate.ButtonClickEvent += (sender, e) =>
@@ -510,7 +778,7 @@
        /// <param name="oTADevice">ota设备</param>
        private void SetDeviceVersionInfo(PicViewControl btnNewVersion, OTADevice oTADevice)
        {
            new System.Threading.Thread(async () =>
            HdlThreadLogic.Current.RunThread(async () =>
            {
                bool receiveImageInfo = false;
                //设置设备全部的镜像信息
@@ -548,8 +816,7 @@
                        }
                    });
                }
            })
            { IsBackground = true }.Start();
            });
        }
        #endregion
@@ -560,7 +827,7 @@
        /// 设备重命名
        /// </summary>
        /// <param name="i_deviceName">deviceName.</param>
        private async void DeviceReName(string i_deviceName,bool closeForm)
        private async void DeviceReName(string i_deviceName, bool closeForm)
        {
            //开启进度条
            this.ShowProgressBar();
@@ -621,7 +888,7 @@
            {
                menuCount = 2;
            }
            var frame = new TopRightMenuControl(this, menuCount);
            var frame = new TopRightMenuControl(menuCount);
            if (canTest == true)
            {
                //定位
@@ -653,23 +920,14 @@
        /// </summary>
        private async void DoDeleteDevice()
        {
            //开启进度条
            this.ShowProgressBar();
            //删除设备
            bool result = await Common.LocalDevice.Current.DeleteDevice(listNewDevice);
            this.CloseProgressBar();
            if (result == false)
            {
                return;
            }
            Application.RunOnMainThread(() =>
            {
                //关闭界面
                this.CloseForm();
            });
            //关闭界面
            this.CloseForm();
        }
        #endregion
@@ -678,12 +936,13 @@
        /// <summary>
        /// 画面关闭
        /// </summary>
        public override void CloseForm()
        public override void CloseFormBefore()
        {
            HdlGatewayReceiveLogic.Current.RemoveEvent("HandPullControl");
            //移除获取设备硬件信息的监听线程
            HdlDeviceHardInfoLogic.Current.RemoveDeviceHardInfoThread(listNewDevice[0]);
            base.CloseForm();
            base.CloseFormBefore();
        }
        #endregion