Exemplo n.º 1
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public ClipboardEnviroment()
        {
            // create default session
            CreateSession();

            // get pettern groups
            GetPetternGroups();


            if (System.Windows.Clipboard.ContainsImage())
            {
                _tempiamge = BitmapImageExtensions.BmpSource2BmpImage(
                    ClipboardHelper.GetContentFromClipboardWithRetry(Helpers.ContentType
                                                                     .Image) as BitmapSource);
            }
            if (System.Windows.Clipboard.ContainsText())
            {
                _tempstringC = System.Windows.Clipboard.GetText();
            }

            keyboardHook.KeyDown += keyboardHook_KeyDown;
            keyboardHook.KeyUp   += keyboardHook_KeyUp;

            mouseHook.LeftButtonDown += mouseHook_LeftButtonDown;
            mouseHook.RightButtonUp  += mouseHook_RightButtonUp;

            Hooker();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Save as item an file
        /// </summary>
        /// <param name="recordId"></param>
        /// <returns></returns>
        public static bool SaveAsItem(long recordId, bool source)
        {
            ClipboardRecord item = null;

            if (source)
            {
                item = ClipboardRecordsL.Single(i => i.RowId == recordId);
            }
            else
            {
                item = ClipboardRecordHistoryL.Single(i => i.RowId == recordId);
            }

            if (item != null)
            {
                if (item.ContentType == ContentType.Text)
                {
                    SaveFileDialog opfiledialog = new SaveFileDialog
                    {
                        FileName     = $"Copied Text {recordId}.txt",
                        DefaultExt   = ".txt",
                        Filter       = "TXT Files (*.txt)|*.txt|JSON Files (*.json)|*.json",
                        AddExtension = true,
                        Title        = "Metni tekrar katdedeceğiniz konumu seçin"
                    };
                    bool?result = opfiledialog.ShowDialog();

                    if (result == true)
                    {
                        File.WriteAllText(opfiledialog.FileName, item.ContentText);
                    }
                }
                else if (item.ContentType == ContentType.Image)
                {
                    SaveFileDialog opfiledialog = new SaveFileDialog
                    {
                        FileName     = $"Copied Image {recordId}",
                        DefaultExt   = ".jpg",
                        Filter       = "JPG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png",
                        AddExtension = true,
                        Title        = "Görseli tekrar katdedeceğiniz konumu seçin"
                    };
                    bool?result = opfiledialog.ShowDialog();

                    if (result == true)
                    {
                        BitmapImageExtensions.SaveBitmapSource2File(new BitmapImage(new Uri(item.ContentImage)), opfiledialog.FileName);
                    }
                }
            }

            return(true);
        }