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.CustomControl.CompositeControl
{
///
/// ThicknessContentPop.xaml 的交互逻辑
///
public partial class SlidContentPop : UserControl
{
public event EventHandler OpacityValueChangedHandler;
public bool isOpenLayout { get; private set; }
public SlidContentPop()
{
InitializeComponent();
}
public void SetOpacity(double opacity)
{
bool changeFromDropBox = false;
if(opacity == 0.25)
{
if (OpacityDropBox.SelectedIndex != 0)
changeFromDropBox = true;
OpacityDropBox.SelectedIndex = 0;
}
else if(opacity == 0.50)
{
if (OpacityDropBox.SelectedIndex != 1)
changeFromDropBox = true;
OpacityDropBox.SelectedIndex = 1;
}
else if(opacity == 0.75)
{
if (OpacityDropBox.SelectedIndex != 2)
changeFromDropBox = true;
OpacityDropBox.SelectedIndex = 2;
}
else if(opacity ==1)
{
if (OpacityDropBox.SelectedIndex != 3)
changeFromDropBox = true;
OpacityDropBox.SelectedIndex = 3;
}
if (changeFromDropBox == false)
OpacitySlider.Value = opacity;
}
private void OpacitySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
{
OpacityValueChangedHandler?.Invoke(this, e.NewValue);
}
private void OpacityDropBox_DropDownClosed(object sender, EventArgs e)
{
isOpenLayout = false;
}
private void OpacityDropBox_DropDownOpened(object sender, EventArgs e)
{
isOpenLayout = true;
}
private void OpacityDropBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
switch(OpacityDropBox.SelectedIndex)
{
case 0:
OpacitySlider.Value = 0.25;
break;
case 1:
OpacitySlider.Value = 0.50;
break;
case 2:
OpacitySlider.Value = 0.75;
break;
case 3:
OpacitySlider.Value = 1;
break;
}
}
}
}