Бывают списки, в которых со временем может появиться очень много записей, и для удобства работы с ними лучше использовать постраничный просмотр.
Также в этом уроке мы рассмотрим работу с изображениями, передачу файлов на сервер и получение их на форму.
Если хотите начать практику с этого урока, то вам необходимо развернуть учебный проект по инструкции в статье Разворачивание проекта .
При разворачивании проекта используйте backup базы данных, который можете найти в архиве из раздела Ответы прошлого урока. Скопируйте папки Forms , Workflow и Patterns в папку с развернутым проектом, например, в папку D:\WT\Projects\Template\Projects\1. Template .
Инструкция по подключению шаблонов находится по ссылке .
Рассмотрим паттерн Pagination на примере формы списка клиентов.
Подготовка формы
Перейдем в файл списка клиентов (TemplateClientList.xml) и в ContentPanel добавим описание панели PagePanel с объектами, необходимыми для постраничного просмотра списка клиентов:
PagePanelCopy < MyObject Name = "PagePanel" Type = "Panel" Assembly = "BaseControls" >
< Top >
< Object Name = "ClientDatabaseTable" >
< Property Name = "Bottom" />
</ Object >
</ Top >
< Left >
< Calculate >
< Expression >Ceiling(({0} - {1})/2)</ Expression >
< Items >
< Item >
< Object Name = "ContentPanel" >
< Property Name = "Width" />
</ Object >
</ Item >
< Item >
< Object Name = "PagePanel" >
< Property Name = "Width" />
</ Object >
</ Item >
</ Items >
</ Calculate >
</ Left >
< Height >30</ Height >
< Width >
< Object Name = "TotalItemsLabel" >
< Property Name = "Right" />
</ Object >
</ Width >
< MyObject Name = "FirstPageButton" Type = "Button" Assembly = "BaseControls" >
< Top >5</ Top >
< Left >0</ Left >
< Height >
< Object Name = "CurrentPageTextBox" >
< Property Name = "Height" />
</ Object >
</ Height >
< Width >
< Object Name = "FirstPageButton" >
< Property Name = "Height" />
</ Object >
</ Width >
< FlatStyle >Flat</ FlatStyle >
< FlatBorderSize >0</ FlatBorderSize >
< FlatBorderColor >ButtonFlatBorderColor</ FlatBorderColor >
< FlatMouseDownBackColor >ButtonFlatMouseDownBackColor</ FlatMouseDownBackColor >
< FlatMouseOverBackColor >ButtonFlatMouseOverBackColor</ FlatMouseOverBackColor >
< BackgroundImageLayout >Center</ BackgroundImageLayout >
< BackgroundImage >Images\16x16\arrow-collapse-left.png</ BackgroundImage >
< Commands > </ Commands >
</ MyObject >
< MyObject Name = "PrevPageButton" Type = "Button" Assembly = "BaseControls" >
< Top >
< Object Name = "FirstPageButton" >
< Property Name = "Top" />
</ Object >
</ Top >
< Left >
< Calculate >
< Expression >{0} + 3</ Expression >
< Items >
< Item >
< Object Name = "FirstPageButton" >
< Property Name = "Right" />
</ Object >
</ Item >
</ Items >
</ Calculate >
</ Left >
< Height >
< Object Name = "FirstPageButton" >
< Property Name = "Height" />
</ Object >
</ Height >
< Width >
< Object Name = "FirstPageButton" >
< Property Name = "Width" />
</ Object >
</ Width >
< FlatStyle >Flat</ FlatStyle >
< FlatBorderSize >0</ FlatBorderSize >
< FlatBorderColor >ButtonFlatBorderColor</ FlatBorderColor >
< FlatMouseDownBackColor >ButtonFlatMouseDownBackColor</ FlatMouseDownBackColor >
< FlatMouseOverBackColor >ButtonFlatMouseOverBackColor</ FlatMouseOverBackColor >
< BackgroundImageLayout >Center</ BackgroundImageLayout >
< BackgroundImage >Images\16x16\arrow-left.png</ BackgroundImage >
< Commands > </ Commands >
</ MyObject >
< MyObject Name = "CurrentPageTextBox" Type = "TextBox" Assembly = "BaseControls" ChangeForm = "False" >
< Top >
< Object Name = "PrevPageButton" >
< Property Name = "Top" />
</ Object >
</ Top >
< Left >
< Calculate >
< Expression >{0} + 3</ Expression >
< Items >
< Item >
< Object Name = "PrevPageButton" >
< Property Name = "Right" />
</ Object >
</ Item >
</ Items >
</ Calculate >
</ Left >
< Width >30</ Width >
< MaxLength >3</ MaxLength >
< AllowedSymbols >0123456789</ AllowedSymbols >
< TextAlign >Right</ TextAlign >
< Text > </ Text >
</ MyObject >
< MyObject Name = "TotalPagesLabel" Type = "Label" Assembly = "BaseControls" ChangeForm = "False" >
< Top >
< Object Name = "PrevPageButton" >
< Property Name = "Top" />
</ Object >
</ Top >
< Left >
< Object Name = "CurrentPageTextBox" >
< Property Name = "Right" />
</ Object >
</ Left >
< Height >20</ Height >
< Width >40</ Width >
< TextAlign >MiddleLeft</ TextAlign >
< Text > </ Text >
</ MyObject >
< MyObject Name = "NextPageButton" Type = "Button" Assembly = "BaseControls" >
< Top >
< Object Name = "FirstPageButton" >
< Property Name = "Top" />
</ Object >
</ Top >
< Left >
< Calculate >
< Expression >{0} + 3</ Expression >
< Items >
< Item >
< Object Name = "TotalPagesLabel" >
< Property Name = "Right" />
</ Object >
</ Item >
</ Items >
</ Calculate >
</ Left >
< Height >
< Object Name = "FirstPageButton" >
< Property Name = "Height" />
</ Object >
</ Height >
< Width >
< Object Name = "FirstPageButton" >
< Property Name = "Width" />
</ Object >
</ Width >
< FlatStyle >Flat</ FlatStyle >
< FlatBorderSize >0</ FlatBorderSize >
< FlatBorderColor >ButtonFlatBorderColor</ FlatBorderColor >
< FlatMouseDownBackColor >ButtonFlatMouseDownBackColor</ FlatMouseDownBackColor >
< FlatMouseOverBackColor >ButtonFlatMouseOverBackColor</ FlatMouseOverBackColor >
< BackgroundImageLayout >Center</ BackgroundImageLayout >
< BackgroundImage >Images\16x16\arrow-right.png</ BackgroundImage >
< Commands > </ Commands >
</ MyObject >
< MyObject Name = "LastPageButton" Type = "Button" Assembly = "BaseControls" >
< Top >
< Object Name = "PrevPageButton" >
< Property Name = "Top" />
</ Object >
</ Top >
< Left >
< Calculate >
< Expression >{0} + 3</ Expression >
< Items >
< Item >
< Object Name = "NextPageButton" >
< Property Name = "Right" />
</ Object >
</ Item >
</ Items >
</ Calculate >
</ Left >
< Height >
< Object Name = "FirstPageButton" >
< Property Name = "Height" />
</ Object >
</ Height >
< Width >
< Object Name = "FirstPageButton" >
< Property Name = "Width" />
</ Object >
</ Width >
< FlatStyle >Flat</ FlatStyle >
< FlatBorderSize >0</ FlatBorderSize >
< FlatBorderColor >ButtonFlatBorderColor</ FlatBorderColor >
< FlatMouseDownBackColor >ButtonFlatMouseDownBackColor</ FlatMouseDownBackColor >
< FlatMouseOverBackColor >ButtonFlatMouseOverBackColor</ FlatMouseOverBackColor >
< BackgroundImageLayout >Center</ BackgroundImageLayout >
< BackgroundImage >Images\16x16\arrow-collapse-right.png</ BackgroundImage >
< Commands > </ Commands >
</ MyObject >
< MyObject Name = "PerPageLabel" Type = "Label" Assembly = "BaseControls" >
< Top >
< Object Name = "PrevPageButton" >
< Property Name = "Top" />
</ Object >
</ Top >
< Left >
< Calculate >
< Expression >{0} + 20</ Expression >
< Items >
< Item >
< Object Name = "LastPageButton" >
< Property Name = "Right" />
</ Object >
</ Item >
</ Items >
</ Calculate >
</ Left >
< Height >20</ Height >
< Width >110</ Width >
< TextAlign >MiddleRight</ TextAlign >
< Text >строк на странице</ Text >
</ MyObject >
< MyObject Name = "ItemsPerPageComboBox" Type = "ComboBox" Assembly = "BaseControls" ChangeForm = "False" >
< Top >
< Object Name = "PrevPageButton" >
< Property Name = "Top" />
</ Object >
</ Top >
< Left >
< Object Name = "PerPageLabel" >
< Property Name = "Right" />
</ Object >
</ Left >
< Width >50</ Width >
< ValueList >
< Structure Type = "Table" >
< Row >
< Item />
< Item >[Все]</ Item >
</ Row >
< Row >
< Item >5</ Item >
< Item >5</ Item >
</ Row >
< Row >
< Item >10</ Item >
< Item >10</ Item >
</ Row >
< Row >
< Item >50</ Item >
< Item >50</ Item >
</ Row >
< Row >
< Item >100</ Item >
< Item >100</ Item >
</ Row >
</ Structure >
</ ValueList >
< Value >50</ Value >
</ MyObject >
< MyObject Name = "TotalItemsLabel" Type = "Label" Assembly = "BaseControls" ChangeForm = "False" >
< Top >
< Object Name = "PrevPageButton" >
< Property Name = "Top" />
</ Object >
</ Top >
< Left >
< Calculate >
< Expression >{0} + 3</ Expression >
< Items >
< Item >
< Object Name = "ItemsPerPageComboBox" >
< Property Name = "Right" />
</ Object >
</ Item >
</ Items >
</ Calculate >
</ Left >
< Height >20</ Height >
< Width >60</ Width >
< TextAlign >MiddleLeft</ TextAlign >
< Text > </ Text >
</ MyObject >
</ MyObject >
Скачайте архив с изображением для кнопок постраничного просмотра и распакуйте его в папку \Template\Projects\1. Template\Forms\Images\16x16 .
Количество записей в ответе от сервера
Первым делом в запрос ClientSelectSqlQuery для списка клиентов добавим поле Count , в котором будем возвращать общее количество записей в результате запроса:
Copy < SqlQuery Name = "ClientSelectSqlQuery" >
< Text >
SELECT
client.client_id AS "ClientId",
client.title AS "Name",
city.title AS "CityTitle",
client.phone AS "Phone",
client.archive AS "Archive",
COUNT(*) OVER() AS "Count"
FROM
template.client
LEFT JOIN template.city USING(city_id)
WHERE
{SearchKeywords} ISNULL OR client.title ilike '%' || {SearchKeywords} ||'%'
ORDER BY client.title;
</ Text >
</ SqlQuery >
Создадим условие для проверки количества строк в ClientPrimaryGetDataConnection , используя для этого get-проперти Count :
Copy < Condition Name = "NumberOfClientsEqual0Condition" Type = "EqualCondition" Assembly = "Conditions" >
< Items >
< Item >
< DataConnection SourceDataConnection = "ClientPrimaryGetDataConnection" >
< Property Name = "Count" />
</ DataConnection >
</ Item >
< Item >0</ Item >
</ Items >
< DataType Type = "IntegerDataType" />
</ Condition >
Создадим переменную для хранения общего количества записей клиентов в базе данных:
Copy < MyObject Name = "NumberOfClientsVariable" Type = "Variable" Assembly = "SimpleControls" ChangeForm = "False" >
< Value >
< Switch >
< Case >
< When >
< Condition Name = "NumberOfClientsEqual0Condition" />
</ When >
< Then >0</ Then >
</ Case >
< Case >
< DataConnection SourceDataConnection = "ClientPrimaryGetDataConnection" >
< Fields >
< Field Name = "Count" />
</ Fields >
</ DataConnection >
</ Case >
</ Switch >
</ Value >
</ MyObject >
Таким образом, если сервер не вернул никаких строк, то берем ноль, иначе будем брать значение из поля Count, которое соответствует количеству записей в базе данных.
Создадим условие проверки этой переменной, с помощью которого будем блокировать кнопки переключения по страницам:
Copy < Condition Name = "NumberOfClientsVariableEqual0Condition" Type = "EqualCondition" Assembly = "Conditions" >
< Items >
< Item >
< Object Name = "NumberOfClientsVariable" />
</ Item >
< Item >0</ Item >
</ Items >
< DataType Type = "IntegerDataType" />
</ Condition >
Для объекта TotalItemsLabel скорректируем значение тэга <Text>
, указав количество строк которые вернул сервер:
TotalItemsLabelCopy < MyObject Name = "TotalItemsLabel" Type = "Label" Assembly = "BaseControls" ChangeForm = "False" >
< Top >
< Object Name = "PrevPageButton" >
< Property Name = "Top" />
</ Object >
</ Top >
< Left >
< Calculate >
< Expression >{0} + 3</ Expression >
< Items >
< Item >
< Object Name = "ItemsPerPageComboBox" >
< Property Name = "Right" />
</ Object >
</ Item >
</ Items >
</ Calculate >
</ Left >
< Height >20</ Height >
< Width >80</ Width >
< TextAlign >MiddleLeft</ TextAlign >
< Text >
< String >
< Format >из {0}</ Format >
< Items >
< Item >
< Object Name = "NumberOfClientsVariable" />
</ Item >
</ Items >
</ String >
</ Text >
</ MyObject >
Переход между страницами
Создадим переменную для хранения номера текущей страницы:
Copy < MyObject Name = "CurrentPageVariable" Type = "Variable" Assembly = "SimpleControls" >
< Value >1</ Value >
</ MyObject >
Укажем эту переменную в тэге <Text>
объекта CurrentPageTextBox.
CurrentPageTextBoxCopy < MyObject Name = "CurrentPageTextBox" Type = "TextBox" Assembly = "BaseControls" ChangeForm = "False" >
< Top >
< Object Name = "PrevPageButton" >
< Property Name = "Top" />
</ Object >
</ Top >
< Left >
< Calculate >
< Expression >{0} + 3</ Expression >
< Items >
< Item >
< Object Name = "PrevPageButton" >
< Property Name = "Right" />
</ Object >
</ Item >
</ Items >
</ Calculate >
</ Left >
< Width >30</ Width >
< MaxLength >3</ MaxLength >
< AllowedSymbols >0123456789</ AllowedSymbols >
< TextAlign >Right</ TextAlign >
< Text >
< Object Name = "CurrentPageVariable" />
</ Text >
</ MyObject >
Создадим переменную для расчета количества страниц:
Copy < MyObject Name = "TotalPagesVariable" Type = "Variable" Assembly = "SimpleControls" ChangeForm = "False" >
< Value >
< Switch >
< Case >
< When >
< Condition Name = "ItemsPerPageComboBoxIsNullCondition" />
</ When >
< Then >1</ Then >
</ Case >
< Case >
< Calculate >
< Expression >Ceiling({0}/{1})</ Expression >
< Items >
< Item >
< Object Name = "NumberOfClientsVariable" />
</ Item >
< Item >
< Object Name = "ItemsPerPageComboBox" />
</ Item >
</ Items >
</ Calculate >
</ Case >
</ Switch >
</ Value >
</ MyObject >
Где условие ItemsPerPageComboBoxIsNullCondition имеет вид:
Copy < Condition Name = "ItemsPerPageComboBoxIsNullCondition" Type = "IsNullCondition" Assembly = "Conditions" >
< Items >
< Item >
< Object Name = "ItemsPerPageComboBox" />
</ Item >
</ Items >
</ Condition >
Укажем переменную TotalPagesVariable в тэге <Text>
объекта TotalPagesLabel.
TotalPagesLabelCopy < MyObject Name = "TotalPagesLabel" Type = "Label" Assembly = "BaseControls" ChangeForm = "False" >
< Top >
< Object Name = "PrevPageButton" >
< Property Name = "Top" />
</ Object >
</ Top >
< Left >
< Object Name = "CurrentPageTextBox" >
< Property Name = "Right" />
</ Object >
</ Left >
< Height >20</ Height >
< Width >40</ Width >
< TextAlign >MiddleLeft</ TextAlign >
< Text >
< String >
< Format >/ {0}</ Format >
< Items >
< Item >
< Switch >
< Case >
< When >
< Condition Name = "NumberOfClientsVariableEqual0Condition" />
</ When >
< Then >1</ Then >
</ Case >
< Case >
< Object Name = "TotalPagesVariable" />
</ Case >
</ Switch >
</ Item >
</ Items >
</ String >
</ Text >
</ MyObject >
Команда изменения номера текущей страницы на произвольное значение:
Copy < Command Name = "CurrentPageVariableValueSetCommand" Type = "ValueSetCommand" Assembly = "Commands" >
< Object Name = "CurrentPageVariable" >
< Input />
</ Object >
</ Command >
Команда для перехода на предыдущую страницу:
Copy < Command Name = "CurrentPageVariableDecValueSetCommand" Type = "ValueSetCommand" Assembly = "Commands" >
< Object Name = "CurrentPageVariable" >
< Formula >
< Minus DataType = "IntegerDataType" >
< Item >
< Object Name = "CurrentPageVariable" />
</ Item >
< Item >1</ Item >
</ Minus >
</ Formula >
</ Object >
</ Command >
Команда для перехода на следующую страницу:
Copy < Command Name = "CurrentPageVariableIncValueSetCommand" Type = "ValueSetCommand" Assembly = "Commands" >
< Object Name = "CurrentPageVariable" >
< Formula >
< Plus DataType = "IntegerDataType" >
< Item >
< Object Name = "CurrentPageVariable" />
</ Item >
< Item >1</ Item >
</ Plus >
</ Formula >
</ Object >
</ Command >
Условие проверки, является ли текущая страница первой из доступных:
Copy < Condition Name = "CurrentPageVariableEqual1Condition" Type = "EqualCondition" Assembly = "Conditions" >
< Items >
< Item >
< Object Name = "CurrentPageVariable" />
</ Item >
< Item >1</ Item >
</ Items >
< DataType Type = "IntegerDataType" />
</ Condition >
Условие проверки, является ли текущая страница последней из доступных:
Copy < Condition Name = "CurrentPageVariableEqualMaxCondition" Type = "EqualCondition" Assembly = "Conditions" >
< Items >
< Item >
< Object Name = "CurrentPageVariable" />
</ Item >
< Item >
< Object Name = "TotalPagesVariable" />
</ Item >
</ Items >
< DataType Type = "IntegerDataType" />
</ Condition >
Теперь можем скорректировать описание кнопок перехода по страницам:
FirstPageButtonCopy < MyObject Name = "FirstPageButton" Type = "Button" Assembly = "BaseControls" >
< Top >5</ Top >
< Left >0</ Left >
< Height >
< Object Name = "CurrentPageTextBox" >
< Property Name = "Height" />
</ Object >
</ Height >
< Width >
< Object Name = "FirstPageButton" >
< Property Name = "Height" />
</ Object >
</ Width >
< FlatStyle >Flat</ FlatStyle >
< FlatBorderSize >0</ FlatBorderSize >
< FlatBorderColor >ButtonFlatBorderColor</ FlatBorderColor >
< FlatMouseDownBackColor >ButtonFlatMouseDownBackColor</ FlatMouseDownBackColor >
< FlatMouseOverBackColor >ButtonFlatMouseOverBackColor</ FlatMouseOverBackColor >
< BackgroundImageLayout >Center</ BackgroundImageLayout >
< BackgroundImage >Images\16x16\arrow-collapse-left.png</ BackgroundImage >
< Commands >
< Command Name = "CurrentPageVariableValueSetCommand" >1</ Command >
</ Commands >
< Enabled >
< And >
< Not >
< Condition Name = "CurrentPageVariableEqual1Condition" />
</ Not >
< Not >
< Condition Name = "NumberOfClientsVariableEqual0Condition" />
</ Not >
</ And >
</ Enabled >
</ MyObject >
PrevPageButtonCopy < MyObject Name = "PrevPageButton" Type = "Button" Assembly = "BaseControls" >
< Top >
< Object Name = "FirstPageButton" >
< Property Name = "Top" />
</ Object >
</ Top >
< Left >
< Calculate >
< Expression >{0} + 3</ Expression >
< Items >
< Item >
< Object Name = "FirstPageButton" >
< Property Name = "Right" />
</ Object >
</ Item >
</ Items >
</ Calculate >
</ Left >
< Height >
< Object Name = "FirstPageButton" >
< Property Name = "Height" />
</ Object >
</ Height >
< Width >
< Object Name = "FirstPageButton" >
< Property Name = "Width" />
</ Object >
</ Width >
< FlatStyle >Flat</ FlatStyle >
< FlatBorderSize >0</ FlatBorderSize >
< FlatBorderColor >ButtonFlatBorderColor</ FlatBorderColor >
< FlatMouseDownBackColor >ButtonFlatMouseDownBackColor</ FlatMouseDownBackColor >
< FlatMouseOverBackColor >ButtonFlatMouseOverBackColor</ FlatMouseOverBackColor >
< BackgroundImageLayout >Center</ BackgroundImageLayout >
< BackgroundImage >Images\16x16\arrow-left.png</ BackgroundImage >
< Commands >
< Command Name = "CurrentPageVariableDecValueSetCommand" />
</ Commands >
< Enabled >
< And >
< Not >
< Condition Name = "CurrentPageVariableEqual1Condition" />
</ Not >
< Not >
< Condition Name = "NumberOfClientsVariableEqual0Condition" />
</ Not >
</ And >
</ Enabled >
</ MyObject >
NextPageButtonCopy < MyObject Name = "NextPageButton" Type = "Button" Assembly = "BaseControls" >
< Top >
< Object Name = "FirstPageButton" >
< Property Name = "Top" />
</ Object >
</ Top >
< Left >
< Calculate >
< Expression >{0} + 3</ Expression >
< Items >
< Item >
< Object Name = "TotalPagesLabel" >
< Property Name = "Right" />
</ Object >
</ Item >
</ Items >
</ Calculate >
</ Left >
< Height >
< Object Name = "FirstPageButton" >
< Property Name = "Height" />
</ Object >
</ Height >
< Width >
< Object Name = "FirstPageButton" >
< Property Name = "Width" />
</ Object >
</ Width >
< FlatStyle >Flat</ FlatStyle >
< FlatBorderSize >0</ FlatBorderSize >
< FlatBorderColor >ButtonFlatBorderColor</ FlatBorderColor >
< FlatMouseDownBackColor >ButtonFlatMouseDownBackColor</ FlatMouseDownBackColor >
< FlatMouseOverBackColor >ButtonFlatMouseOverBackColor</ FlatMouseOverBackColor >
< BackgroundImageLayout >Center</ BackgroundImageLayout >
< BackgroundImage >Images\16x16\arrow-right.png</ BackgroundImage >
< Commands >
< Command Name = "CurrentPageVariableIncValueSetCommand" />
</ Commands >
< Enabled >
< And >
< Not >
< Condition Name = "CurrentPageVariableEqualMaxCondition" />
</ Not >
< Not >
< Condition Name = "NumberOfClientsVariableEqual0Condition" />
</ Not >
</ And >
</ Enabled >
</ MyObject >
LastPageButtonCopy < MyObject Name = "LastPageButton" Type = "Button" Assembly = "BaseControls" >
< Top >
< Object Name = "PrevPageButton" >
< Property Name = "Top" />
</ Object >
</ Top >
< Left >
< Calculate >
< Expression >{0} + 3</ Expression >
< Items >
< Item >
< Object Name = "NextPageButton" >
< Property Name = "Right" />
</ Object >
</ Item >
</ Items >
</ Calculate >
</ Left >
< Height >
< Object Name = "FirstPageButton" >
< Property Name = "Height" />
</ Object >
</ Height >
< Width >
< Object Name = "FirstPageButton" >
< Property Name = "Width" />
</ Object >
</ Width >
< FlatStyle >Flat</ FlatStyle >
< FlatBorderSize >0</ FlatBorderSize >
< FlatBorderColor >ButtonFlatBorderColor</ FlatBorderColor >
< FlatMouseDownBackColor >ButtonFlatMouseDownBackColor</ FlatMouseDownBackColor >
< FlatMouseOverBackColor >ButtonFlatMouseOverBackColor</ FlatMouseOverBackColor >
< BackgroundImageLayout >Center</ BackgroundImageLayout >
< BackgroundImage >Images\16x16\arrow-collapse-right.png</ BackgroundImage >
< Commands >
< Command Name = "CurrentPageVariableValueSetCommand" >
< Object Name = "TotalPagesVariable" />
</ Command >
</ Commands >
< Enabled >
< And >
< Not >
< Condition Name = "CurrentPageVariableEqualMaxCondition" />
</ Not >
< Not >
< Condition Name = "NumberOfClientsVariableEqual0Condition" />
</ Not >
</ And >
</ Enabled >
</ MyObject >
Но переход между страницами возможен и при ручном вводе значения в поле CurrentPageTextBox. Для этого создадим условие для проверки события нажатия клавиши Enter при редактировании текстового поля:
Copy < Condition Name = "CurrentPageTextBoxKeyEnterPressCondition" Type = "KeyDownCondition" Assembly = "Conditions" >
< Object Name = "CurrentPageTextBox" />
< Key Value = "Enter" />
</ Condition >
Создадим условия проверки введенного значение на удовлетворение минимального и максимального количества страниц:
Copy < Condition Name = "CurrentPageTextBoxNotLessMinCondition" Type = "NotLessCondition" Assembly = "Conditions" >
< Items >
< Item >
< Object Name = "CurrentPageTextBox" />
</ Item >
< Item >1</ Item >
</ Items >
< DataType Type = "IntegerDataType" />
</ Condition >
< Condition Name = "CurrentPageTextBoxNotGreaterMaxCondition" Type = "NotGreaterCondition" Assembly = "Conditions" >
< Items >
< Item >
< Object Name = "CurrentPageTextBox" />
</ Item >
< Item >
< Object Name = "TotalPagesVariable" />
</ Item >
</ Items >
< DataType Type = "IntegerDataType" />
</ Condition >
Создадим Execution, в котором будет отрабатывать событие нажатия клавиши Enter в текстовом поле CurrentPageTextBox :
Copy < Execution >
< ConditionExpression >
< Condition Name = "CurrentPageTextBoxKeyEnterPressCondition" />
</ ConditionExpression >
< Commands >
< If >
< When >
< And >
< Condition Name = "CurrentPageTextBoxNotGreaterMaxCondition" />
< Condition Name = "CurrentPageTextBoxNotLessMinCondition" />
</ And >
</ When >
< Then >
< Command Name = "CurrentPageVariableValueSetCommand" >
< Object Name = "CurrentPageTextBox" />
</ Command >
</ Then >
< ElseIf >
< When >
< Not >
< Condition Name = "CurrentPageTextBoxNotLessMinCondition" />
</ Not >
</ When