//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("无效的粘贴!");
            }
        }