123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- using System;
- using System.Globalization;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Input;
- namespace Compdfkit_Tools.PDFControlUI
- {
- public partial class CPDFBookmarkAddUI : UserControl
- {
- public event EventHandler<BookmarkChangeData> BookmarkAddEvent;
-
- public event EventHandler BookmarkInputExpandEvent;
- private bool toggleState;
- private BookmarkChangeData bookmarkData=new BookmarkChangeData();
- public CPDFBookmarkAddUI()
- {
- InitializeComponent();
- }
-
- private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- toggleState = !toggleState;
- BookmarkInputPanel.Visibility=toggleState?Visibility.Visible:Visibility.Collapsed;
- if(toggleState)
- {
- BookmarkInputExpandEvent?.Invoke(this, EventArgs.Empty);
- }
-
- }
-
- private void ButtonCancel_Click(object sender, MouseButtonEventArgs e)
- {
- HideInputUI(true);
- }
-
- private void ButtonAdd_Click(object sender, RoutedEventArgs e)
- {
- if(!string.IsNullOrEmpty(BookmarkText.Text) && bookmarkData!=null)
- {
- bookmarkData.NewTitle = BookmarkText.Text;
- BookmarkAddEvent?.Invoke(this, bookmarkData);
- bookmarkData = null;
- BookmarkText.Text = string.Empty;
- HideInputUI(true);
- }
- }
- public void SetBookmarkChangeData(BookmarkChangeData newChangeData)
- {
- if(newChangeData!=null)
- {
- PageNumText.Text = string.Format("Page {0}", newChangeData.PageIndex + 1);
- BookmarkText.Text = newChangeData.BookmarkTitle;
- BookmarkText.Focus();
- BookmarkText.SelectAll();
- }
- bookmarkData=newChangeData;
- }
- public void HideInputUI(bool isHide)
- {
- toggleState = !isHide;
- BookmarkInputPanel.Visibility = isHide? Visibility.Collapsed:Visibility.Visible;
- }
- private void DeleteBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- BookmarkText.Text = string.Empty;
- }
- }
- internal class BoolEnableConvert : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value == null)
- {
- return false;
- }
- else
- {
- try
- {
- if (value is string)
- {
- string checkValue=value as string;
- if(checkValue.Length>0)
- {
- return true;
- }
- }
-
- }
- catch(Exception ex)
- {
- }
- return false;
- }
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
|