wei
2021-10-14 edd75644a148ccdd60057064d625141fd49f04b0
捕抓场景编辑背景图、场景名称、
5个文件已修改
455 ■■■■■ 已修改文件
.vs/HDL_APP_Project/xs/UserPrefs.xml 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL-ON_Android/Properties/AndroidManifest.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/MainPage.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI1-Login/LoginPage.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Scene/CatchSceneAddPage.cs 414 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HDL_APP_Project/xs/UserPrefs.xml
@@ -1,24 +1,27 @@
<Properties StartupConfiguration="{D998E133-F0DD-4760-BE3C-461632F54DA4}|Default">
  <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget" />
  <MonoDevelop.Ide.Workbench ActiveDocument="HDL-ON_iOS/Info.plist">
<Properties StartupConfiguration="{09712674-2A38-407B-B1E2-560B2C352F9A}|Default">
  <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneSimulatorTarget.220222E9-B9CA-4834-9318-2BC22465F050" />
  <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/DAL/Server/HttpUtil.cs">
    <Files>
      <File FileName="HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/AirFreshControlPage.cs" Line="211" Column="33" />
      <File FileName="HDL_ON/DAL/DriverLayer/Control.cs" Line="356" Column="21" />
      <File FileName="HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmCenterPage.cs" Line="331" Column="68" />
      <File FileName="HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddAlarmDeploymentPage.cs" Line="306" Column="44" />
      <File FileName="HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddInputPage.cs" Line="89" Column="58" />
      <File FileName="HDL_ON/UI/MainPage.cs" Line="5" Column="17" />
      <File FileName="HDL_ON/DAL/Server/HttpUtil.cs" Line="21" Column="36" />
      <File FileName="HDL_ON/DAL/Mqtt/MqttClient.cs" Line="446" Column="41" />
      <File FileName="HDL_ON/DAL/DriverLayer/Control.cs" />
      <File FileName="HDL_ON/UI/UI2/FuntionControlView/ArmCenter/ArmCenterPage.cs" />
      <File FileName="HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddAlarmDeploymentPage.cs" />
      <File FileName="HDL_ON/UI/UI2/FuntionControlView/ArmCenter/AddInputPage.cs" />
      <File FileName="HDL_ON/UI/MainPage.cs" />
      <File FileName="HDL_ON/DAL/Mqtt/MqttClient.cs" />
      <File FileName="HDL-ON_iOS/Info.plist" />
      <File FileName="HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs" Line="561" Column="73" />
      <File FileName="HDL_ON/UI/UI1-Login/LoginPage.cs" Line="236" Column="59" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Scene/CatchSceneAddPage.cs" Line="336" Column="62" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Scene/CatchSceneCatchFunctionListPage.cs" Line="38" Column="29" />
      <File FileName="HDL_ON/DAL/Server/HttpUtil.cs" Line="21" Column="73" />
    </Files>
    <Pads>
      <Pad Id="ProjectPad">
        <State name="__root__">
          <Node name="HDL_APP_Project" expanded="True">
            <Node name="HDL-ON_iOS" expanded="True">
              <Node name="Info.plist" selected="True" />
            </Node>
            <Node name="HDL-ON_Android" selected="True" />
            <Node name="HDL-ON_iOS" expanded="True" />
          </Node>
        </State>
      </Pad>
@@ -35,8 +38,8 @@
    <String>Shared.Droid.TouchID/Shared.Droid.TouchID.csproj</String>
    <String>Shared.IOS/Shared.IOS.csproj</String>
  </DisabledProjects>
  <MonoDevelop.Ide.Workspace ActiveConfiguration="Release|iPhone" />
  <MonoDevelop.Ide.ItemProperties.HDL-ON__Android PreferredExecutionTarget="Android.SelectDevice" />
  <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
  <MonoDevelop.Ide.ItemProperties.HDL-ON__Android PreferredExecutionTarget="Android.364c4b3158493098" />
  <MonoDevelop.Ide.DebuggingService.Breakpoints>
    <BreakpointStore>
      <Breakpoint file="/Users/kaede/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/FuntionControlView/Electrical/IrFanPage.cs" relfile="HDL_ON/UI/UI2/FuntionControlView/Electrical/IrFanPage.cs" line="42" column="1" />
HDL-ON_Android/Properties/AndroidManifest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="202110131" android:versionName="1.2.202110131" package="com.hdl.onpro">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="202110141" android:versionName="1.2.202110141" package="com.hdl.onpro">
    <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="28" />
    <!-- 乐橙可视对讲需要的权限 -->
    <!--<uses-permission android:name="android.permission.INTERNET" />-->
HDL_ON/UI/MainPage.cs
@@ -25,7 +25,7 @@
        /// <summary>
        /// 版本号
        /// </summary>
        public static string VersionString = "1.2.1013";
        public static string VersionString = "1.2.1014";
        ///// <summary>
        ///// 客户端类型
        ///// </summary>
HDL_ON/UI/UI1-Login/LoginPage.cs
@@ -231,9 +231,9 @@
                    //etAccount.Text = "15217626103";//昆明金茂项目
                    //etAccount.Text = "18598273624";
                    //etAccount.Text = "tf@smarttech.com.ua";
                    //etAccount.Text = "18814122445";//董泽斌 天河办公室
                    etAccount.Text = "18814122445";//董泽斌 天河办公室
                    //etAccount.Text = "18824864143";//"464027401@qq.com"; //"2791308028@qq.com";//13697499568
                    etAccount.Text = "18402017839";//wjc
                    //etAccount.Text = "18402017839";//wjc
                    //etAccount.Text = "13430286286";//cwc
                }
                b = !b;
HDL_ON/UI/UI2/3-Intelligence/Scene/CatchSceneAddPage.cs
@@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using System.Threading;
using HDL_ON.DAL.Server;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI
{
    public class CatchSceneAddPage : FrameLayout
    public partial class CatchSceneAddPage : FrameLayout
    {
        FrameLayout bodyView;
        private ImageView addSceneImageView;
@@ -23,6 +25,37 @@
        /// 捕捉的区域列表
        /// </summary>
        private List<Room> catchRooms = new List<Room>();
        Button btnAddFunctionTitle;
        #region 图标选择部分图标
        /// <summary>
        /// 背景图选项区域
        /// </summary>
        FrameLayout pictureOptionView;
        /// <summary>
        /// 背景图选项选择区域
        /// </summary>
        VerticalScrolViewLayout optionView;
        /// <summary>
        /// 默认图库按钮
        /// </summary>
        Button btnDefaultGallery;
        /// <summary>
        /// 拍照按钮
        /// </summary>
        Button btnTakePicture;
        /// <summary>
        /// 相册按钮
        /// </summary>
        Button btnAlbum;
        /// <summary>
        /// 取消按钮
        /// </summary>
        Button btnCancel;
        #endregion
        /// <summary>
        /// 回调更新
@@ -344,6 +377,10 @@
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                }
            };
            LoadEventList();
        }
@@ -436,5 +473,380 @@
        }
        /// <summary>
        /// 加载图标选择选项
        /// </summary>
        void LoadPictureOptionView()
        {
            var pView = new FrameLayout()
            {
                BackgroundColor = CSS_Color.DialogTransparentColor1,
            };
            bodyView.AddChidren(pView);
            pictureOptionView = new FrameLayout()
            {
                Y = Application.GetRealHeight(445),
                Height = Application.GetRealHeight(250),
                AnimateSpeed = 0.3f,
                Animate = Animate.DownToUp,
            };
            pView.AddChidren(pictureOptionView);
            optionView = new VerticalScrolViewLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(150),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Radius = (uint)Application.GetRealWidth(12),
            };
            pictureOptionView.AddChidren(optionView);
            btnDefaultGallery = new Button()
            {
                Height = Application.GetRealHeight(50),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.TextualColor,
                SelectedTextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextID = StringId.DefaultGallery,
            };
            optionView.AddChidren(btnDefaultGallery);
            optionView.AddChidren(new Button() { Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor });
            btnTakePicture = new Button()
            {
                Height = Application.GetRealHeight(50),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.TextualColor,
                SelectedTextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextID = StringId.TakePicture,
            };
            optionView.AddChidren(btnTakePicture);
            optionView.AddChidren(new Button() { Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor });
            btnAlbum = new Button()
            {
                Height = Application.GetRealHeight(50),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.TextualColor,
                SelectedTextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextID = StringId.Album,
            };
            optionView.AddChidren(btnAlbum);
            optionView.AddChidren(new Button() { Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor });
            btnCancel = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(8) + optionView.Bottom,
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(50),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Radius = (uint)Application.GetRealWidth(12),
                TextID = StringId.Cancel,
                TextColor = CSS_Color.WarningColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
            };
            pictureOptionView.AddChidren(btnCancel);
            LoadEvent_PictureOptionViewEventList(pView);
    }
    }
    //--------------------------------------
    public partial class CatchSceneAddPage
    {
        void LoadEventList()
        {
            LoadEvent_ChangeSceneImage();
            LoadEvent_ChangeSceneZone();
            LoadEvent_EditRoomName();
        }
        /// <summary>
        /// 修改场景所属区域
        /// </summary>
        void LoadEvent_ChangeSceneZone()
        {
            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                Action backAction = () => {
                    btnZoneName.Text = scene.GetRoomListName();
                };
                var ssl = new SetSceneLocationPage(scene, backAction);
                MainPage.BasePageView.AddChidren(ssl);
                ssl.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            btnZoneName.MouseUpEventHandler = eventHandler;
            belongToZoneRow.MouseUpEventHandler = eventHandler;
            btnBelongToZoneRight.MouseUpEventHandler = eventHandler;
        }
        /// <summary>
        /// 修改场景背景事件
        /// </summary>
        void LoadEvent_ChangeSceneImage()
        {
            addSceneImageView.MouseUpEventHandler = (sender, e) => {
                LoadPictureOptionView();
            };
        }
        /// <summary>
        /// 加载背景图选择区域事件列表
        /// </summary>
        void LoadEvent_PictureOptionViewEventList(FrameLayout pView)
        {
            pictureOptionView.MouseUpEventHandler = (sender, e) =>
            {
                pictureOptionView.Parent.RemoveFromParent();
            };
            pView.MouseUpEventHandler = (sender, e) =>
            {
                pictureOptionView.Parent.RemoveFromParent();
            };
            btnCancel.MouseUpEventHandler = (sender, e) =>
            {
                pictureOptionView.Parent.RemoveFromParent();
            };
            btnTakePicture.MouseDownEventHandler = (sender, e) => {
                btnTakePicture.IsSelected = true;
            };
            btnTakePicture.MouseUpEventHandler = (sender, e) =>
            {
                btnTakePicture.IsSelected = false;
                //var pid = Guid.NewGuid();
                //CropImage.TakePicture((imagePath) =>
                //{
                //    if (imagePath != null)
                //    {
                //        addSceneImageView.ImagePath = imagePath.ToString();
                //        scene.ImagePath = addSceneImageView.ImagePath;
                //        MainPage.Log("SelectPicture 裁剪图片返回路径: " + imagePath);
                //    }
                //}, pid.ToString(), 4, 3);
                var imageName = Guid.NewGuid().ToString();
                //var imageName = scene.sid;
                CropImage.TakePicture((imagePath) =>
                {
                    CropImageCallBack(imagePath);
                }, imageName, 4, 3);
                //if (pageTitleId == StringId.EditScene)
                //{
                //    scene.SaveFunctionData();
                //}
                pictureOptionView.Parent.RemoveFromParent();
            };
            btnAlbum.MouseDownEventHandler = (sender, e) => {
                btnAlbum.IsSelected = true;
            };
            btnAlbum.MouseUpEventHandler = (sender, e) =>
            {
                btnAlbum.IsSelected = false;
                //var pid = Guid.NewGuid();
                //CropImage.SelectPicture((imagePath) =>
                //{
                //    if (imagePath != null)
                //    {
                //        addSceneImageView.ImagePath = imagePath.ToString();
                //        scene.ImagePath = addSceneImageView.ImagePath;
                //        MainPage.Log("SelectPicture 裁剪图片返回路径: " + imagePath);
                //    }
                //}, pid.ToString(), 4, 3);
                //从相册选择图片裁剪
                var imageName = Guid.NewGuid().ToString();
                //var imageName = scene.sid;
                CropImage.SelectPicture((imagePath) =>
                {
                    CropImageCallBack(imagePath);
                }, imageName, 4, 3);
                //if (pageTitleId == StringId.EditScene)
                //{
                //    scene.SaveFunctionData();
                //}
                pictureOptionView.Parent.RemoveFromParent();
            };
            btnDefaultGallery.MouseUpEventHandler = (sender, e) => {
                pictureOptionView.Parent.RemoveFromParent();
                Action<string> action = (obj) => {
                    scene.ImagePath = obj;
                    addSceneImageView.ImageBytes = null;//解决有ImageBytes不加载ImagePath
                    addSceneImageView.ImagePath = scene.ImagePath;
                };
                var galleryPage = new GalleryPage(scene.ImagePath, action);
                MainPage.BasePageView.AddChidren(galleryPage);
                galleryPage.LoadPage(true);
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
        }
        /// <summary>
        /// 裁剪完照片回调,统一处理
        /// </summary>
        /// <param name="imagePath">裁剪后的真实路径</param>
        /// <param name="imageName">自定义的图片名称</param>
        void CropImageCallBack(string selectImagePath)
        {
            if (string.IsNullOrEmpty(selectImagePath) == true)
            {
                return;
            }
            //上传成功到回调
            Action<string> uploadSuccessAction = (imageUrl) =>
            {
                //2020-12-03 需要讲最新的图片路径同步到云端
                scene.ImagePath = imageUrl;
            };
            //上传图片到云端
            UploadImage(selectImagePath, addSceneImageView, scene, uploadSuccessAction);
        }
        /// <summary>
        /// 加载修改场景名称窗口事件
        /// </summary>
        void LoadEvent_EditRoomName()
        {
            Action<string> callBack = (str) =>
            {
                //名称不能为空
                if (string.IsNullOrEmpty(str))
                {
                    new Tip()
                    {
                        CloseTime = 1,
                        Text = Language.StringByID(StringId.SceneNameCannotBeEmpty),
                        Direction = AMPopTipDirection.None,
                    }.Show(bodyView);
                    return;
                }
                btnSceneName.Text = str;
                scene.name = str;
            };
            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                List<string> sceneNameList = new List<string>();
                foreach (var tempScene in FunctionList.List.scenes)
                {
                    sceneNameList.Add(tempScene.name);
                }
                new PublicAssmebly().LoadDialog_EditParater(StringId.SceneName, scene.name, callBack, StringId.SceneNameCannotBeEmpty, StringId.SceneNameAlreadyExists, sceneNameList);
            };
            sceneNameView.MouseUpEventHandler = eventHandler;
            btnSceneName.MouseUpEventHandler = eventHandler;
            btnEditSceneNameIcon.MouseUpEventHandler = eventHandler;
        }
        /// <summary>
        /// 上传图片方法
        /// </summary>
        /// <param name="selectImagePath">裁剪后的图片路径</param>
        /// <param name="imageView"></param>
        /// <param name="uploadSuccessAction"></param>
        void UploadImage(string selectImagePath, ImageView imageView, Scene mScene, Action<string> uploadSuccessAction)
        {
            try
            {
                //MainPage.Log("SelectPicture 裁剪图片返回路径: " + selectImagePath);
                //1.读取裁剪后的图片,然后删除
                var imageBytes = Shared.IO.FileUtils.ReadFile(selectImagePath);
                System.IO.File.Delete(selectImagePath);
                var waitPage = new Loading();
                bodyView.AddChidren(waitPage);
                waitPage.Start(Language.StringByID(StringId.PleaseWait));
                //开始上传
                new Thread(() =>
                {
                    try
                    {
                        var newImageName = mScene.name.Trim() + ".png";
                        var uploadImageObj = new UploadImageObj()
                        {
                            prefix = "Scene" + Utlis.GetTimestamp(),
                            fileName = newImageName,
                            uid = mScene.sid,
                            content = imageBytes,
                        };
                        var imageUrl = ImageUtlis.Current.UploadImage(uploadImageObj);
                        if (!string.IsNullOrEmpty(imageUrl) && imageUrl.Contains(newImageName))
                        {
                            //上传成功
                            Application.RunOnMainThread(() =>
                            {
                                //Utlis.WriteLine("上传成功:" + imageUrl);
                                //1.2如果是自定义图片删除之前的
                                if (!string.IsNullOrEmpty(imageView.ImagePath) && !imageView.ImagePath.Contains("Classification/Room/Roombg"))
                                {
                                    //Utlis.WriteLine("删除: " + imageView.ImagePath);
                                    System.IO.File.Delete(imageView.ImagePath);
                                }
                                //重命名保存
                                ImageUtlis.Current.WriteFileByBytes(imageUrl, imageBytes);
                                imageView.ImagePath = null;
                                imageView.ImageBytes = imageBytes;
                                //上传成功
                                Utlis.ShowTip(Language.StringByID(StringId.UploadSuccessfully));
                                uploadSuccessAction?.Invoke(imageUrl);
                            });
                        }
                        else
                        {
                            //上传失败
                            Application.RunOnMainThread(() =>
                            {
                                //上传失败
                                Utlis.ShowTip(Language.StringByID(StringId.UploadFailed));
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    finally
                    {
                        Application.RunOnMainThread(() =>
                        {
                            if (waitPage != null)
                            {
                                waitPage.RemoveFromParent();
                                waitPage = null;
                            }
                        });
                    }
                })
                { IsBackground = true }.Start();
            }
            catch { }
        }
    }
}