//private void CloseBtn_Click(object sender, RoutedEventArgs e)
        //{
        //    Close();
        //}
        #endregion


        #region Private methods

        private async void PasteImagesFromClipboard()
        {
            if (!ImagePaster.CanPasteImageFromClipboard())
            {
                return;
            }
            try
            {
                var imageSources = await ImagePaster.GetPasteImagesFromClipboard();

                if (imageSources.Count <= 0)
                {
                    return;
                }
                imageSources.ForEach(m => ImageItemsSource.Add(new Image
                {
                    Source = m,
                }));
            }
            catch (Exception ex)
            {
                App.Log.Error(ex.ToString());
                Extentions.ShowMessageBox("无效的粘贴!");
            }
        }
Exemple #2
0
        private async void PasteImagesFromClipboard(object sender, RoutedEventArgs e)
        {
            if (ImagePaster.CanInternalPasteFromClipboard())
            {
                var baseInfos = ImagePaster.GetInternalPasteDataFromClipboard() as List <ImageControlBaseInfo>;
                if (baseInfos != null)
                {
                    _controlManager.SelectNone();
                    _controlManager.ContinuedAddCount++;
                    _controlManager.AddElements(baseInfos.Select(m => PackageBaseInfoToControl(m, true)));
                    return;
                }
            }

            if (!ImagePaster.CanPasteImageFromClipboard())
            {
                return;
            }
            try
            {
                var imageSources = await ImagePaster.GetPasteImagesFromClipboard();

                if (imageSources.Count <= 0)
                {
                    return;
                }
                _controlManager.SelectNone();
                _controlManager.ContinuedAddCount++;
                var translate = _userConfigution.ImageSetting.PasteMoveUnitDistace * _controlManager.ContinuedAddCount;
                var controls  = new List <ImageControl>(imageSources.Count);
                controls.AddRange(imageSources.Select(imageSource => PackageImageToControl(new AnimatedGif {
                    Source = imageSource, Stretch = Stretch.Fill
                }, new Point(translate, translate))));
                _controlManager.AddElements(controls);
            }
            catch (Exception ex)
            {
                App.Log.Error(ex.ToString());
                Extentions.ShowMessageBox("无效的粘贴!");
            }
        }
Exemple #3
0
        private void MainMenu_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            var element = sender as UserControl;

            var menuItems = element?.ContextMenu?.Items?.OfType <MenuItem>().ToArray();

            if (menuItems == null)
            {
                return;
            }
            var menuItem = menuItems.SingleOrDefault(m => m.Tag.ToString() == "SaveAs");

            if (menuItem != null)
            {
                menuItem.Visibility = _userConfigution.WindowState.InitEasyImagePath == null
                    ? Visibility.Collapsed
                    : Visibility.Visible;
            }
            menuItem = menuItems.SingleOrDefault(m => m.Tag.ToString() == "Paste");
            if (menuItem != null)
            {
                menuItem.IsEnabled = ImagePaster.CanPasteImageFromClipboard();
            }
        }