# Time    : 2024/7/25 17:12
# Author  : wangchao
# File    : PageManagementPage.py
# Description :
import re
import time

from BasePage.BasePage import BasePage
from BuildInLibrary.BuildInLibrary import BuildInLibrary
from Config import Config
from Pages.PageManagementPage.PageManagementPage import PageManagementPage


class StaticTextPage(BasePage):

	def __init__(self, page):
		super().__init__(page)

	# 创建静态文本
	def create_static_text(self):
		# 点击展开组件菜单
		pmp = PageManagementPage(self.page)
		self._click(pw_locator=pmp.component_box_locator)
		# 点击静态文本组件
		self._click(pw_locator=pmp.static_text_component_locator)
		# 拖拉组件到画布
		self._drag_and_drop_to_user_position(pmp.static_text_component_locator, Config.target_point_x,
												 Config.target_point_y)
		time.sleep(0.5) # 等待0.5s加载属性栏

	def set_xywh(self):
		"""
		拖出静态文本组件，设置x、y、w、h属性
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()  # 拖出静态文本组件
		pmp.location_attribute_set_x_axis(300)  # x
		pmp.location_attribute_set_y_axis(400)  # y
		pmp.location_attribute_set_width(400)  # w
		pmp.location_attribute_set_high(200)  # h

	def set_rotation_angle(self):
		"""
		拖出静态文本组件，设置旋转角度
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()
		pmp.location_attribute_set_rotation_angle(45)  # 旋转角度

	def set_lock(self):
		"""
		拖出静态文本组件，设置锁定
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()
		pmp.location_attribute_set_lock()

	def set_solid_color_background(self):
		"""
		拖出静态文本组件，设置纯色背景
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()
		pmp.appearance_attribute_set_solid_color_background()

	def set_gradient_color_background(self):
		"""
		拖出静态文本组件，设置渐变色背景
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()
		pmp.appearance_attribute_set_gradient_color_background()

	def set_stretch_type_image_background(self):
		"""
		拖出静态文本组件，设置图片背景，且为拉伸类型
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()
		pmp.location_attribute_set_width(400)
		pmp.location_attribute_set_high(200)
		time.sleep(0.5)
		pmp.appearance_attribute_set_image_background_stretch_type()  # 设置为拉伸类型

	def set_adapt_type_image_background(self):
		"""
		拖出静态文本组件，设置图片背景，且为自适应类型
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()
		pmp.location_attribute_set_width(400)
		pmp.location_attribute_set_high(200)
		time.sleep(0.5)
		pmp.appearance_attribute_set_image_background_adapt_type()  # 设置为自适应类型

	def set_cover_type_image_background(self):
		"""
		拖出静态文本组件，设置图片背景，且为覆盖类型
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()
		pmp.location_attribute_set_width(400)
		pmp.location_attribute_set_high(200)
		pmp.appearance_attribute_set_image_background_cover_type()  # 设置为覆盖类型

	def set_actual_type_image_background(self):
		"""
		拖出静态文本组件，设置图片背景，且为实际大小类型
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()
		pmp.location_attribute_set_width(400)
		pmp.location_attribute_set_high(200)
		time.sleep(0.5)
		pmp.appearance_attribute_set_image_background_actual_type()  # 设置为实际大小类型

	def set_straight_line_frame(self):
		"""
		拖出静态文本组件，设置直线边框，宽度为5，颜色为红色
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()  # 拖出静态文本组件
		pmp.location_attribute_set_width(400)
		pmp.location_attribute_set_high(200)
		time.sleep(0.5)
		pmp.appearance_attribute_set_frame_width(5)  # 边框宽度
		pmp.appearance_attribute_set_straight_line_frame()  # 直线
		pmp.appearance_attribute_set_frame_colour()  # 边框颜色

	def set_dashed_line_frame(self):
		"""
		拖出静态文本组件，设置虚线边框，宽度为5，颜色为红色
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()  # 拖出静态文本组件
		pmp.location_attribute_set_width(400)
		pmp.location_attribute_set_high(200)
		time.sleep(0.5)
		pmp.appearance_attribute_set_frame_width(5)  # 边框宽度
		pmp.appearance_attribute_set_dashed_line_frame()  # 虚线
		pmp.appearance_attribute_set_frame_colour()  # 边框颜色

	def set_scircular_dots_frame(self):
		"""
		拖出静态文本组件，设置圆点边框，宽度为5，颜色为红色
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()  # 拖出静态文本组件
		pmp.location_attribute_set_width(400)
		pmp.location_attribute_set_high(200)
		time.sleep(0.5)
		pmp.appearance_attribute_set_frame_width(5)  # 边框宽度
		pmp.appearance_attribute_set_scircular_dots_frame()  # 圆点
		pmp.appearance_attribute_set_frame_colour()  # 边框颜色

	def set_no_frame(self):
		"""
		拖出静态文本组件，设置无边框，宽度为5，颜色为红色
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()  # 拖出静态文本组件
		pmp.location_attribute_set_width(400)
		pmp.location_attribute_set_high(200)
		time.sleep(0.5)
		pmp.appearance_attribute_set_frame_width(5)  # 边框宽度
		pmp.appearance_attribute_set_no_frame()  # 圆点
		pmp.appearance_attribute_set_frame_colour()  # 边框颜色

	def set_shadow(self):
		"""
		拖出静态文本组件，设置内外阴影
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()  # 拖出静态文本组件
		pmp.location_attribute_set_width(400)
		pmp.location_attribute_set_high(200)
		time.sleep(0.5)
		pmp.appearance_attribute_set_external_shadow()
		time.sleep(1)
		pmp.appearance_attribute_set_internal_shadow()

	def set_rounded_corners(self):
		"""
		拖出静态文本组件，设置圆角
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()  # 拖出静态文本组件
		pmp.location_attribute_set_width(400)
		pmp.location_attribute_set_high(200)
		time.sleep(0.5)
		pmp.appearance_attribute_set_frame_width(5)
		pmp.appearance_attribute_set_rounded_corners(50)

	def set_opacity(self):
		"""
		拖出静态文本组件，设置不透明度
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()  # 拖出静态文本组件
		pmp.appearance_attribute_set_solid_color_background()
		time.sleep(0.5)
		pmp.appearance_attribute_set_opacity()


	def set_left_aligned(self):
		"""
		拖出静态文本组件，设置左对齐
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()  # 拖出静态文本组件
		pmp.location_attribute_set_width(400)
		pmp.location_attribute_set_high(200)
		time.sleep(0.5)
		pmp.text_attribute_set_left_aligned()

	def set_center_aligned(self):
		"""
		拖出静态文本组件，设置左对齐
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()  # 拖出静态文本组件
		pmp.location_attribute_set_width(400)
		pmp.location_attribute_set_high(200)
		time.sleep(0.5)
		pmp.text_attribute_set_center_aligned()

	def set_right_aligned(self):
		"""
		拖出静态文本组件，设置左对齐
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()  # 拖出静态文本组件
		pmp.location_attribute_set_width(400)
		pmp.location_attribute_set_high(200)
		time.sleep(0.5)
		pmp.text_attribute_set_right_aligned()

	def set_font_style(self):
		"""
		拖出静态文本组件，设置字号,字体颜色,加粗,斜体,下划线
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()  # 拖出静态文本组件
		pmp.text_attribute_set_font_size() # 字号
		time.sleep(0.5)
		pmp.text_attribute_set_font_color() # 字体颜色
		time.sleep(0.5)
		pmp.text_attribute_set_bold() #加粗
		pmp.text_attribute_set_italic() #斜体
		pmp.text_attribute_set_underline() #下划线

	def set_font_type(self):
		"""
		拖出静态文本组件，设置字体类型,手写体
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()  # 拖出静态文本组件
		pmp.text_attribute_set_font_size()
		time.sleep(0.5)
		pmp.text_attribute_set_font_type()

	def set_font_distance(self):
		"""
		拖出静态文本组件，设置字距,行高
		:return:
		"""
		pmp = PageManagementPage(self.page)
		self.create_static_text()  # 拖出静态文本组件
		pmp.text_attribute_set_font_size()
		time.sleep(0.5)
		pmp.text_attribute_set_font_distance(40) #字距
		pmp.text_attribute_set_font_row_heigh(80) # 行高




