12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- using PDF_Master.ViewModels.Form;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace PDF_Master.Views.Form
- {
- /// <summary>
- /// FormsToolContent.xaml 的交互逻辑
- /// </summary>
- public partial class FormsToolContent : UserControl
- {
- private FormsToolContentViewModel ViewModel =>DataContext as FormsToolContentViewModel;
- public FormsToolContent()
- {
- InitializeComponent();
- }
- private void BtnAlignment_Click(object sender, RoutedEventArgs e)
- {
- MenuAlignment.PlacementTarget = this.BtnAlignment;
- MenuAlignment.IsOpen = true;
- }
- /// <summary>
- /// 取消右键弹出下拉菜单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnAlignment_Initialized(object sender, EventArgs e)
- {
- //取消右键菜单的绑定,只能左键点击弹出
- this.BtnAlignment.ContextMenu = null;
- }
- private void BtnMore_Click(object sender, RoutedEventArgs e)
- {
- MenuMore.PlacementTarget = this.BtnMore;
- MenuMore.IsOpen = true;
- }
- private void BtnMore_Initialized(object sender, EventArgs e)
- {
- //取消右键菜单的绑定,只能左键点击弹出
- this.BtnMore.ContextMenu = null;
- }
- private void UserControl_Loaded(object sender, RoutedEventArgs e)
- {
- if(ViewModel != null)
- {
- ViewModel.UncheckedToolsBtnEvent -= ViewModel_UncheckedToolsBtnEvent;
- ViewModel.UncheckedToolsBtnEvent += ViewModel_UncheckedToolsBtnEvent;
- }
-
- }
- private void ViewModel_UncheckedToolsBtnEvent(object sender, string e)
- {
- foreach(var item in PnlTool.Children)
- {
- var btn = item as RadioButton;
- if (btn != null)
- {
- if (btn.IsChecked == true)
- {
- btn.IsChecked = false;
- break;
- }
- }
- }
- }
- private void UserControl_Unloaded(object sender, RoutedEventArgs e)
- {
- if (ViewModel != null)
- {
- ViewModel.UncheckedToolsBtnEvent -= ViewModel_UncheckedToolsBtnEvent;
- }
- }
- }
- }
|