Beispiel #1
0
        private void Window_MouseMove(object sender, MouseEventArgs e)
        {
            //drag is heppen
            //Prepare for Drag and Drop
            Point  mpos = e.GetPosition(null);
            Vector diff = this._startPoint - mpos;

            if (e.LeftButton == MouseButtonState.Pressed &&
                (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                 Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
            {
                //hooking on Mouse Up
                InterceptMouse.m_hookID = InterceptMouse.SetHook(InterceptMouse.m_proc);

                //ataching the event for hadling drop
                this.QueryContinueDrag += queryhandler;
                //begin drag and drops

                DataObject dataObj = new DataObject(this.text1);
                if ((sender as Canvas) == null)
                {
                    return;
                }
                if ((sender as Canvas).Tag.ToString().EndsWith(".enc"))
                {
                    DecryptDirectory = (sender as Canvas).Tag.ToString();
                }
                else if (Tools.isDirectory((sender as Canvas).Tag.ToString()))
                {
                    DecryptDirectory = (sender as Canvas).Tag.ToString();
                }
                else
                {
                    DecryptDirectory = (sender as Canvas).Tag.ToString() + ".enc";
                }
                DragDrop.DoDragDrop(this.text1, dataObj, DragDropEffects.Move);
                if (!File.Exists(DecryptDirectory))
                {
                    FileDirectory.RemoveAll(item => item == (sender as Canvas).Tag.ToString());
                    (sender as Canvas).Height = 0;
                    (sender as Canvas).Width  = 0;
                    (sender as Canvas).Tag    = null;
                    (sender as Canvas).Children.Clear();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Continuosly tracking Dragging mouse position
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DragSourceQueryContinueDrag(object sender, QueryContinueDragEventArgs e)
        {
            //when keystate is non, draop is heppen
            if (e.KeyStates == DragDropKeyStates.None)
            {
                //unsubscribe event
                this.QueryContinueDrag -= queryhandler;
                e.Handled = true;
                //Unhooking on Mouse Up
                InterceptMouse.UnhookWindowsHookEx(InterceptMouse.m_hookID);

                //notifiy user about drop result
                Task.Run
                (
                    () =>
                {
                    //Drop hepend outside Instantly app
                    if (InterceptMouse.IsMouseOutsideApp)
                    {
                        if (Tools.isDirectory(DecryptDirectory))
                        {
                            string[] subfiles = Tools.getAllFileList(DecryptDirectory);
                            foreach (string subfile in subfiles)
                            {
                                if (subfile.Substring(subfile.Length - 4).CompareTo(".enc") == 0)
                                {
                                    aes.DecryptFile(subfile);
                                    File.Delete(subfile);
                                }
                            }
                        }
                        else
                        {
                            if (DecryptDirectory.Substring(DecryptDirectory.Length - 4).CompareTo(".enc") == 0)
                            {
                                aes.DecryptFile(DecryptDirectory);
                                File.Delete(DecryptDirectory);
                            }
                        }
                    }
                }
                );
            }
        }