Example #1
0
        private void CopyXamlExecute()
        {
            var handle  = InputUtils.FocusedControlInActiveWindow();
            var content = InputUtils.GetText(handle);

            try
            {
                var drawingGroup = SvgUtils.ConvertToDrawingGroup(content);
                if (drawingGroup.Children.Count < 1)
                {
                    throw new XmlException();
                }

                if (ClipboardHelper.SetText(SvgUtils.ConvertToXaml(content)))
                {
                    this.notificationService.Show(new NotificationContent
                    {
                        Content = GetNotificationContent(LocalizationManager.GetLocalizationString(@"Main.XAMLCopied"), drawingGroup),
                        Title   = AppTitle,
                        Type    = NotificationType.Success
                    });
                }
            }
            catch (XmlException)
            {
                this.ShowInvalidSvgMessage();
            }
        }
Example #2
0
        private void SaveExecute()
        {
            var handle  = InputUtils.FocusedControlInActiveWindow();
            var content = InputUtils.GetText(handle);

            try
            {
                var drawingGroup = SvgUtils.ConvertToDrawingGroup(content);
                if (drawingGroup.Children.Count < 1)
                {
                    throw new XmlException();
                }

                var dialog = new SaveFileDialog {
                    Filter = "SVG|*.svg"
                };
                if (!dialog.ShowDialog(Application.Current.MainWindow).Value)
                {
                    return;
                }

                File.WriteAllText(dialog.FileName, content);
                this.notificationService.Show(new NotificationContent
                {
                    Content = GetNotificationContent(LocalizationManager.GetLocalizationString(@"Main.SVGSaved"), drawingGroup),
                    Title   = AppTitle,
                    Type    = NotificationType.Success
                });
            }
            catch (XmlException)
            {
                this.ShowInvalidSvgMessage();
            }
        }
Example #3
0
        private static bool CanCopy()
        {
            var handle = InputUtils.FocusedControlInActiveWindow();

            if (!FocusInIconGenerator(handle))
            {
                return(false);
            }

            var content = InputUtils.GetText(handle);

            return(!string.IsNullOrWhiteSpace(content));
        }