using ComPDFKit.PDFDocument; using Compdfkit_Tools.Helper; using Compdfkit_Tools.PDFControl; using ComPDFKitViewer.AnnotEvent; using ComPDFKitViewer; using Microsoft.Win32; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows.Media.Imaging; using System.Drawing; using ComPDFKit.PDFPage; using ComPDFKitViewer.PdfViewer; using System.ComponentModel; using System.Runtime.CompilerServices; namespace Forms { public partial class MainWindow : Window, INotifyPropertyChanged { #region property private PDFViewControl passwordViewer; private PDFViewControl pdfViewControl; private CPDFSearchControl searchControl = null; private FromPropertyControl fromPropertyControl; bool LoadPDFFormTool = false; private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 }; public bool CanSave { get { if (pdfViewControl != null && pdfViewControl.PDFView != null) { return pdfViewControl.PDFView.UndoManager.CanSave; } return false; } } public bool CanUndo { get { if (pdfViewControl != null && pdfViewControl.PDFView != null) { return pdfViewControl.PDFView.UndoManager.CanUndo; } return false; } } public bool CanRedo { get { if (pdfViewControl != null && pdfViewControl.PDFView != null) { return pdfViewControl.PDFView.UndoManager.CanRedo; } return false; } } public event PropertyChangedEventHandler PropertyChanged; #endregion public MainWindow() { InitializeComponent(); Loaded += MainWindow_Loaded; DataContext = this; } #region Usercontrol loaded unload initialize private void MainWindow_Loaded(object sender, RoutedEventArgs e) { BotaSideTool.AddBOTAContent(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search); fromPropertyControl = new FromPropertyControl(); LoadDefaultDocument(); } private void PDFFormTool_Loaded(object sender, RoutedEventArgs e) { LoadPDFFormTool = true; } private void PDFFormTool_Unloaded(object sender, RoutedEventArgs e) { LoadPDFFormTool = false; } #endregion #region Open, save and close document private void LoadDocument() { pdfViewControl.PDFView?.Load(); pdfViewControl.PDFView?.SetShowLink(true); PDFGrid.Child = pdfViewControl; pdfViewControl.PDFView.InfoChanged -= PdfViewer_InfoChanged; pdfViewControl.PDFView.InfoChanged += PdfViewer_InfoChanged; pdfViewControl.PDFView.AnnotCommandHandler -= PDFView_AnnotCommandHandler; pdfViewControl.PDFView.AnnotCommandHandler += PDFView_AnnotCommandHandler; pdfViewControl.PDFView.UndoManager.PropertyChanged -= UndoManager_PropertyChanged; pdfViewControl.PDFView.UndoManager.PropertyChanged += UndoManager_PropertyChanged; pdfViewControl.PDFView.SetFormFieldHighlight(true); PasswordUI.Closed -= PasswordUI_Closed; PasswordUI.Canceled -= PasswordUI_Canceled; PasswordUI.Confirmed -= PasswordUI_Confirmed; PasswordUI.Closed += PasswordUI_Closed; PasswordUI.Canceled += PasswordUI_Canceled; PasswordUI.Confirmed += PasswordUI_Confirmed; pdfViewControl.PDFView.ChangeFitMode(FitMode.FitWidth); CPDFSaclingControl.InitWithPDFViewer(pdfViewControl.PDFView); CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100))); ViewSettingBtn.IsChecked = false; PropertyContainer.Child = null; PropertyContainer.Visibility = Visibility.Collapsed; FloatPageTool.InitWithPDFViewer(pdfViewControl.PDFView); InitialPDFViewControl(pdfViewControl); SetFromMode(); BotaSideTool.InitWithPDFViewer(pdfViewControl.PDFView); BotaSideTool.SelectBotaTool(BOTATools.Thumbnail); } private void LoadDefaultDocument() { string defaultFilePath = "Form_Widgets_Test.pdf"; pdfViewControl = new PDFViewControl(); pdfViewControl.PDFView.InitDocument(defaultFilePath); LoadDocument(); } public void InitialPDFViewControl(PDFViewControl newPDFViewer) { PDFFormTool.InitWithPDFViewer(newPDFViewer.PDFView, fromPropertyControl); fromPropertyControl.SetPDFViewer(newPDFViewer.PDFView); PDFFormTool.ClearAllToolState(); newPDFViewer.PDFView.AnnotEditHandler += PDFView_AnnotEditHandler; newPDFViewer.PDFView.AnnotActiveHandler += PDFView_AnnotActiveHandler; newPDFViewer.CustomSignHandle = true; newPDFViewer.PDFView.WidgetClickHandler += PDFView_WidgetClickHandler; } private void SaveFile() { if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null) { CPDFDocument pdfDoc = pdfViewControl.PDFView.Document; if (pdfDoc.WriteToLoadedPath()) { pdfViewControl.PDFView.UndoManager.CanSave = false; return; } SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.Filter = "(*.pdf)|*.pdf"; saveDialog.DefaultExt = ".pdf"; saveDialog.OverwritePrompt = true; if (saveDialog.ShowDialog() == true) { pdfDoc.WriteToFilePath(saveDialog.FileName); } } } #endregion #region Property changed protected void OnPropertyChanged([CallerMemberName] string name = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } private void PdfViewer_InfoChanged(object sender, KeyValuePair e) { if (e.Key == "Zoom") { CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)((double)e.Value * 100))); } } private void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e) { OnPropertyChanged(e.PropertyName); } #endregion #region Context menu private void PDFView_AnnotCommandHandler(object sender, AnnotCommandArgs e) { if (e != null && e.CommandType == CommandType.Context) { if (e.PressOnSelectedText) { e.Handle = true; e.PopupMenu = new ContextMenu(); e.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender }); } else if (e.CommandTarget == TargetType.ImageSelection) { if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.GetSelectImageCount() > 0) { e.Handle = true; e.PopupMenu = new ContextMenu(); MenuItem imageCopyMenu = new MenuItem(); imageCopyMenu = new MenuItem(); imageCopyMenu.Header = "Copy Images"; WeakEventManager.AddHandler(imageCopyMenu, "Click", CopyImage_Click); imageCopyMenu.CommandParameter = e; e.PopupMenu.Items.Add(imageCopyMenu); MenuItem imageExtraMenu = new MenuItem(); imageExtraMenu = new MenuItem(); imageExtraMenu.Header = "Extract Images"; WeakEventManager.AddHandler(imageExtraMenu, "Click", ExtraImage_Click); imageExtraMenu.CommandParameter = e; e.PopupMenu.Items.Add(imageExtraMenu); } } else if (e.CommandTarget == TargetType.WidgetView) { e.Handle = true; e.PopupMenu = new ContextMenu(); e.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender }); e.PopupMenu.Items.Add(new MenuItem() { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender }); e.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender }); } else { e.Handle = true; e.PopupMenu = new ContextMenu(); e.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender }); e.PopupMenu.Items.Add(new Separator()); MenuItem fitWidthMenu = new MenuItem(); fitWidthMenu.Header = "Automatically Resize"; fitWidthMenu.Click += (o, p) => { if (pdfViewControl != null) { pdfViewControl.PDFView?.ChangeFitMode(FitMode.FitWidth); } }; e.PopupMenu.Items.Add(fitWidthMenu); MenuItem fitSizeMenu = new MenuItem(); fitSizeMenu.Header = "Actual Size"; fitSizeMenu.Click += (o, p) => { if (pdfViewControl != null) { pdfViewControl.PDFView?.ChangeFitMode(FitMode.FitSize); } }; e.PopupMenu.Items.Add(fitSizeMenu); MenuItem zoomInMenu = new MenuItem(); zoomInMenu.Header = "Zoom In"; zoomInMenu.Click += (o, p) => { if (pdfViewControl != null) { double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true); pdfViewControl.PDFView?.Zoom(newZoom); } }; e.PopupMenu.Items.Add(zoomInMenu); MenuItem zoomOutMenu = new MenuItem(); zoomOutMenu.Header = "Zoom Out"; zoomOutMenu.Click += (o, p) => { if (pdfViewControl != null) { double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false); pdfViewControl.PDFView?.Zoom(newZoom); } }; e.PopupMenu.Items.Add(zoomOutMenu); e.PopupMenu.Items.Add(new Separator()); MenuItem singleView = new MenuItem(); singleView.Header = "Single Page"; singleView.Click += (o, p) => { if (pdfViewControl != null) { pdfViewControl.PDFView?.ChangeViewMode(ViewMode.Single); } }; e.PopupMenu.Items.Add(singleView); MenuItem singleContinuousView = new MenuItem(); singleContinuousView.Header = "Single Page Continuous"; singleContinuousView.Click += (o, p) => { if (pdfViewControl != null) { pdfViewControl.PDFView?.ChangeViewMode(ViewMode.SingleContinuous); } }; e.PopupMenu.Items.Add(singleContinuousView); MenuItem doubleView = new MenuItem(); doubleView.Header = "Two Pages"; doubleView.Click += (o, p) => { if (pdfViewControl != null) { pdfViewControl.PDFView?.ChangeViewMode(ViewMode.Double); } }; e.PopupMenu.Items.Add(doubleView); MenuItem doubleContinuousView = new MenuItem(); doubleContinuousView.Header = "Two Pages Continuous"; doubleContinuousView.Click += (o, p) => { if (pdfViewControl != null) { pdfViewControl.PDFView?.ChangeViewMode(ViewMode.DoubleContinuous); } }; e.PopupMenu.Items.Add(doubleContinuousView); } } else { e.DoCommand(); } } #endregion #region Password private void PasswordUI_Confirmed(object sender, string e) { if (passwordViewer != null && passwordViewer.PDFView != null && passwordViewer.PDFView.Document != null) { passwordViewer.PDFView.Document.UnlockWithPassword(e); if (passwordViewer.PDFView.Document.IsLocked == false) { PasswordUI.SetShowError("", Visibility.Collapsed); PasswordUI.ClearPassword(); PasswordUI.Visibility = Visibility.Collapsed; PopupBorder.Visibility = Visibility.Collapsed; pdfViewControl = passwordViewer; LoadDocument(); } else { PasswordUI.SetShowError("error", Visibility.Visible); } } } private void PasswordUI_Canceled(object sender, EventArgs e) { PopupBorder.Visibility = Visibility.Collapsed; PasswordUI.Visibility = Visibility.Collapsed; } private void PasswordUI_Closed(object sender, EventArgs e) { PopupBorder.Visibility = Visibility.Collapsed; PasswordUI.Visibility = Visibility.Collapsed; } #endregion #region Expand and collapse panel private void ExpandLeftPanel(bool isExpand) { BotaSideTool.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed; Splitter.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed; if (isExpand) { BodyGrid.ColumnDefinitions[0].Width = new GridLength(260); BodyGrid.ColumnDefinitions[1].Width = new GridLength(15); } else { BodyGrid.ColumnDefinitions[0].Width = new GridLength(0); BodyGrid.ColumnDefinitions[1].Width = new GridLength(0); } } public void ExpandRightPropertyPanel(UIElement properytPanel, Visibility visible) { PropertyContainer.Child = properytPanel; PropertyContainer.Visibility = visible; } #endregion #region UI private void UndoButton_Click(object sender, RoutedEventArgs e) { if (pdfViewControl != null && pdfViewControl.PDFView != null) { pdfViewControl.PDFView.UndoManager?.Undo(); } } private void RedoButton_Click(object sender, RoutedEventArgs e) { if (pdfViewControl != null && pdfViewControl.PDFView != null) { pdfViewControl.PDFView.UndoManager?.Redo(); } } private double CheckZoomLevel(double zoom, bool IsGrowth) { double standardZoom = 100; if (zoom <= 0.01) { return 0.01; } if (zoom >= 10) { return 10; } zoom *= 100; for (int i = 0; i < zoomLevelList.Length - 1; i++) { if (zoom > zoomLevelList[i] && zoom <= zoomLevelList[i + 1] && IsGrowth) { standardZoom = zoomLevelList[i + 1]; break; } if (zoom >= zoomLevelList[i] && zoom < zoomLevelList[i + 1] && !IsGrowth) { standardZoom = zoomLevelList[i]; break; } } return standardZoom / 100; } private void ToolExpand_Click(object sender, RoutedEventArgs e) { ToggleButton expandBtn = sender as ToggleButton; if (expandBtn != null) { bool isExpand = expandBtn.IsChecked == true; ExpandLeftPanel(isExpand); } } private void ExpandSearchBtn_Click(object sender, RoutedEventArgs e) { ExpandLeftPanel(true); ToolExpandBtn.IsChecked = true; BotaSideTool.SelectBotaTool(BOTATools.Search); } private void ViewSettingBtn_Click(object sender, RoutedEventArgs e) { ToggleButton toggleButton = sender as ToggleButton; if (toggleButton != null) { if (toggleButton.IsChecked == true) { CPDFDisplaySettingsControl displayPanel = new CPDFDisplaySettingsControl(); displayPanel.InitWithPDFViewer(pdfViewControl.PDFView); PropertyContainer.Child = displayPanel; PropertyContainer.Visibility = Visibility.Visible; if ((bool)FormBarBtn.IsChecked) { FormBarBtn.IsChecked = false; } } else { PropertyContainer.Child = null; PropertyContainer.Visibility = Visibility.Collapsed; } } } private void FormBarBtn_Click(object sender, RoutedEventArgs e) { ToggleButton toggleButton = sender as ToggleButton; if (toggleButton != null) { if (toggleButton.IsChecked == true) { ExpandRightPropertyPanel(fromPropertyControl, Visibility.Visible); if ((bool)ViewSettingBtn.IsChecked) { ViewSettingBtn.IsChecked = false; } } else { ExpandRightPropertyPanel(null, Visibility.Collapsed); } } } private void NextPageBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { pdfViewControl.PDFView?.GoToPage(pdfViewControl.PDFView.CurrentIndex + 1); } private void PrevPageBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { pdfViewControl.PDFView?.GoToPage(pdfViewControl.PDFView.CurrentIndex - 1); } private void PageInfoBtn_Click(object sender, RoutedEventArgs e) { PasswordUI.Visibility = Visibility.Collapsed; FileInfoUI.Visibility = Visibility.Visible; FileInfoControl.InitWithPDFViewer(pdfViewControl.PDFView); PopupBorder.Visibility = Visibility.Visible; } private void FileInfoCloseBtn_Click(object sender, RoutedEventArgs e) { PopupBorder.Visibility = Visibility.Collapsed; } private void OpenFile_Click(object sender, RoutedEventArgs e) { string filePath = CommonHelper.GetFilePathOrEmpty(); if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null) { if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null) { string oldFilePath = pdfViewControl.PDFView.Document.FilePath; if (oldFilePath.ToLower() == filePath.ToLower()) { return; } } passwordViewer = new PDFViewControl(); passwordViewer.PDFView.InitDocument(filePath); if (passwordViewer.PDFView.Document == null) { MessageBox.Show("Open File Failed"); return; } if (passwordViewer.PDFView.Document.IsLocked) { PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted."); PasswordUI.ClearPassword(); PopupBorder.Visibility = Visibility.Visible; PasswordUI.Visibility = Visibility.Visible; } else { pdfViewControl = passwordViewer; LoadDocument(); } } } private void SaveFileBtn_Click(object sender, RoutedEventArgs e) { SaveFile(); } private void CopyImage_Click(object sender, RoutedEventArgs e) { Dictionary> imageDict = pdfViewControl.PDFView?.GetSelectedImages(); if (imageDict != null && imageDict.Count > 0) { foreach (int pageIndex in imageDict.Keys) { List imageList = imageDict[pageIndex]; foreach (Bitmap image in imageList) { MemoryStream ms = new MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); BitmapImage imageData = new BitmapImage(); imageData.BeginInit(); imageData.StreamSource = ms; imageData.CacheOption = BitmapCacheOption.OnLoad; imageData.EndInit(); imageData.Freeze(); Clipboard.SetImage(imageData); break; } } } } private void ExtraImage_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog(); if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string choosePath = folderDialog.SelectedPath; string openPath = choosePath; Dictionary> imageDict = pdfViewControl.PDFView?.GetSelectedImages(); if (imageDict != null && imageDict.Count > 0) { foreach (int pageIndex in imageDict.Keys) { List imageList = imageDict[pageIndex]; foreach (Bitmap image in imageList) { string savePath = System.IO.Path.Combine(choosePath, Guid.NewGuid() + ".jpg"); image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg); openPath = savePath; } } } Process.Start("explorer", "/select,\"" + openPath + "\""); } } #endregion #region Selection changed private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { SetFromMode(); } private void SetFromMode() { if (LoadPDFFormTool) { PDFFormTool.ClearAllToolState(); } if (pdfViewControl != null && ViewComboBox != null) { if (ViewComboBox.SelectedIndex == 0) { ToolBarContainer.Visibility = Visibility.Collapsed; pdfViewControl.PDFView?.SetShowLink(true); pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.None); pdfViewControl.PDFView?.SetMouseMode(MouseModes.PanTool); pdfViewControl.PDFView?.ReloadDocument(); if (PropertyContainer != null) { fromPropertyControl.CleanProperty(); PropertyContainer.Child = null; ViewSettingBtn.IsChecked = false; FormBarBtn.IsChecked = false; } return; } if (ViewComboBox.SelectedIndex == 1) { PDFFormTool.Visibility = Visibility.Visible; ToolBarContainer.Visibility = Visibility.Visible; pdfViewControl.PDFView?.SetShowLink(false); pdfViewControl.PDFView?.SetMouseMode(MouseModes.FormEditTool); pdfViewControl.PDFView?.ReloadDocument(); if (PropertyContainer != null) { fromPropertyControl.CleanProperty(); PropertyContainer.Child = null; ViewSettingBtn.IsChecked = false; FormBarBtn.IsChecked = false; } } } } #endregion #region Event handle private void PDFView_WidgetClickHandler(object sender, WidgetArgs e) { if (e is WidgetSignArgs) { FormBarBtn.IsChecked = true; ExpandRightPropertyPanel(fromPropertyControl, Visibility.Visible); fromPropertyControl.SetPropertyForType(e, null); } else { FormBarBtn.IsChecked = false; ExpandRightPropertyPanel(null, Visibility.Collapsed); } } private void PDFView_AnnotActiveHandler(object sender, AnnotAttribEvent e) { if (e == null || e.IsAnnotCreateReset) { fromPropertyControl.SetPropertyForType(null, null); } else { switch (e.GetAnnotTypes()) { case AnnotArgsType.WidgetViewForm: WidgetArgs formArgs = e.GetAnnotHandlerEventArgs(AnnotArgsType.WidgetViewForm).First() as WidgetArgs; switch (formArgs.WidgeType) { case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_PUSHBUTTON: case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_COMBOBOX: case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_LISTBOX: ExpandRightPropertyPanel(fromPropertyControl, Visibility.Visible); if ((bool)ViewSettingBtn.IsChecked) { ViewSettingBtn.IsChecked = false; } FormBarBtn.IsChecked = true; break; default: break; } fromPropertyControl.SetPropertyForType(formArgs, e); break; } } } private string GetTime() { DateTime dateTime = DateTime.Now; return " " + dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff"); } private void PDFView_AnnotEditHandler(object sender, List e) { if (e != null && e.Count > 0) { AnnotEditEvent editEvent = e[e.Count - 1]; if (editEvent.EditAction == ActionType.Add) { if (pdfViewControl.PDFView.ToolManager.CurrentAnnotArgs != null) { WidgetArgs widgetArgs = pdfViewControl.PDFView.ToolManager.CurrentAnnotArgs as WidgetArgs; if (widgetArgs != null) { switch (widgetArgs.WidgeType) { case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_PUSHBUTTON: widgetArgs.FieldName = "Button" + GetTime(); break; case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_CHECKBOX: widgetArgs.FieldName = "Checkbox" + GetTime(); break; case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_RADIOBUTTON: widgetArgs.FieldName = "Radio button" + GetTime(); break; case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_TEXTFIELD: widgetArgs.FieldName = "Text" + GetTime(); break; case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_COMBOBOX: widgetArgs.FieldName = "Combobox" + GetTime(); break; case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_LISTBOX: widgetArgs.FieldName = "List" + GetTime(); break; case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS: widgetArgs.FieldName = "Signature" + GetTime(); break; case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_UNKNOWN: break; default: break; } } } pdfViewControl.PDFView.SelectAnnotation(editEvent.PageIndex, editEvent.AnnotIndex); } else if (editEvent.EditAction == ActionType.Del) { fromPropertyControl.CleanProperty(); } } } #endregion #region Close window protected override void OnClosing(CancelEventArgs e) { if (pdfViewControl.PDFView.UndoManager.CanSave) { MessageBoxResult result = MessageBox.Show("Do you want to save your changes before closing the application?", "Message", MessageBoxButton.YesNoCancel); if (result == MessageBoxResult.Yes) { SaveFile(); } else if (result == MessageBoxResult.No) { } else { e.Cancel = true; } } } #endregion } }