コード例 #1
0
ファイル: Textbox.cs プロジェクト: brunotag/Raumschach
        private void Keyboard_OnPaste(object obj, EventArgs e)
        {
            if (obj != null)
            {
                System.Windows.Forms.IDataObject dataObj = (System.Windows.Forms.IDataObject)obj;
                if (dataObj.GetDataPresent(System.Windows.Forms.DataFormats.Text))
                {
                    string clipboardText = (string)dataObj.GetData(System.Windows.Forms.DataFormats.Text);
                    clipboardText = clipboardText.Replace("\r", "");
                    if (multiline)
                    {
                        clipboardText = clipboardText.Replace("\t", "    ");
                    }

                    Add(clipboardText);

                    Vector2 textSize = Font.MeasureString(clipboardText);
                    cursorLocation.Y += (int)(textSize.Y / Font.LineSpacing) - 1;

                    string[] lines = clipboardText.Split(new char[] { '\n' });
                    cursorLocation.X += lines[lines.Length - 1].Length;

                    UpdateScrolling();
                }
            }
        }
コード例 #2
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            double old = grid.Opacity;

            grid.Opacity = 0;

            await Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() => { }));             // ui refresh

            await Task.Delay(250);

            User32.SetForegroundWindow(process.MainWindowHandle);
            User32.PrintScreen();
            await Task.Delay(500);

            // ImageUIElement.Source = Clipboard.GetImage(); // does not work
            System.Windows.Forms.IDataObject clipboardData = System.Windows.Forms.Clipboard.GetDataObject();
            string name = Path.GetFileNameWithoutExtension(Path.GetRandomFileName());

            if (clipboardData.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap))
            {
                System.Drawing.Bitmap bitmap = (System.Drawing.Bitmap)clipboardData.GetData(System.Windows.Forms.DataFormats.Bitmap);
                bitmap.Save(name + ".png", ImageFormat.Png);
                Console.WriteLine("Clipboard copied to UIElement");
            }
            grid.Opacity = old;

            model.Actions.Add(new ScreenshotVerifyAction
            {
                Name    = name,
                Timeout = 5000
            });
        }
コード例 #3
0
        /// <summary>
        /// Because AviCap saves everything in the Windows Clipboard, we have to get
        /// our captures from there. Since the Clipboard is only accessible from a
        /// STA-Thread, we create one if we aren't already one.
        /// </summary>
        /// <returns>Last image in Clipboard</returns>
        public static Image GetClipboardImage()
        {
            Image       ret    = null;
            ThreadStart method = delegate()
            {
                System.Windows.Forms.IDataObject dataObject = System.Windows.Forms.Clipboard.GetDataObject();
                if (dataObject != null && dataObject.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap))
                {
                    ret = (System.Drawing.Bitmap)dataObject.GetData(System.Windows.Forms.DataFormats.Bitmap);
                }
            };

            if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
            {
                Thread thread = new Thread(method);
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Join();
            }
            else
            {
                method();
            }
            return(ret);
        }
コード例 #4
0
 protected void CopyFromClipbordInlineShape()
 {   
     InlineShape inlineShape = m_word.ActiveDocument.InlineShapes[m_i];
     inlineShape.Select();
     m_word.Selection.Copy();
     Computer computer = new Computer();
     //Image img = computer.Clipboard.GetImage();
     if (computer.Clipboard.GetDataObject() != null)
     {
         System.Windows.Forms.IDataObject data = computer.Clipboard.GetDataObject();
         if (data.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap))
         {
             Image image = (Image)data.GetData(System.Windows.Forms.DataFormats.Bitmap, true);                
             image.Save(Server.MapPath("~/ImagesGet/image.gif"), System.Drawing.Imaging.ImageFormat.Gif);
             image.Save(Server.MapPath("~/ImagesGet/image.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
           
         }
         else
         {
             LabelMessage.Text="The Data In Clipboard is not as image format";
         }
     }
     else
     {
         LabelMessage.Text="The Clipboard was empty";
     }
 }
コード例 #5
0
        public async Task Execute(IntPtr windowHandle)
        {
            Bitmap bitmapFile = (Bitmap)Bitmap.FromFile(Name + ".png", true);

            bitmapFile.Save("cmp1.png");

            bool match = false;

            for (int i = 0; i < 10; i++)
            {
                User32.PrintScreen();

                await Task.Delay(500);

                System.Windows.Forms.IDataObject clipboardData = System.Windows.Forms.Clipboard.GetDataObject();
                System.Drawing.Bitmap            screenShot    = (System.Drawing.Bitmap)clipboardData.GetData(System.Windows.Forms.DataFormats.Bitmap);
                screenShot.MakeTransparent();
                screenShot.Save("cmp2.png");
                if (CompareBitmapsFast(screenShot, bitmapFile))
                {
                    match = true;
                    break;
                }
                Thread.Sleep(100);
            }

            if (!match)
            {
                throw new TestException(TestError.ScreenshotMismatch);
            }
        }
コード例 #6
0
 protected override void Execute(CodeActivityContext context)
 {
     try
     {
         Int32  _timeout = Timeout.Get(context);
         string data     = "";
         Thread.Sleep(_timeout);
         latch = new CountdownEvent(1);
         Thread td = new Thread(() =>
         {
             System.Windows.Forms.IDataObject clipBoardBefore = System.Windows.Forms.Clipboard.GetDataObject();
             if (clipBoardBefore.GetDataPresent(System.Windows.DataFormats.Text))
             {
                 data = (string)clipBoardBefore.GetData(System.Windows.DataFormats.Text);
             }
             refreshData(latch);
         });
         td.TrySetApartmentState(ApartmentState.STA);
         td.IsBackground = true;
         td.Start();
         latch.Wait();
         Result.Set(context, data);
     }
     catch (Exception e)
     {
         SharedObject.Instance.Output(SharedObject.enOutputType.Error, "有一个错误产生", e.Message);
         if (ContinueOnError.Get(context))
         {
         }
         else
         {
             throw;
         }
     }
 }
コード例 #7
0
        public Image CopyImage(string cell1, string cell2 = "")
        {
            System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();
            this.GetRange(cell1, cell2).CopyPicture(XlPictureAppearance.xlScreen, XlCopyPictureFormat.xlBitmap);
            Image image = (Image)data.GetData(System.Windows.Forms.DataFormats.Bitmap, true);

            return(image);
        }
コード例 #8
0
        /// <summary>
        /// 获取选中的文本内容
        /// </summary>
        /// <returns>当前选中的内容文本</returns>
        public string GetSelectionString()
        {
            this.webBrowser.Document.ExecCommand("Copy", false, null);
            System.Windows.Forms.IDataObject ido = System.Windows.Forms.Clipboard.GetDataObject();
            string result = ido.GetData(DataFormats.Text).ToSafeString();

            System.Windows.Forms.Clipboard.Clear();
            return(result);
        }
コード例 #9
0
ファイル: Clipboard.cs プロジェクト: weimingtom/Sakura
 public static string GetText()
 {
     System.Windows.Forms.IDataObject iData = System.Windows.Forms.Clipboard.GetDataObject();
     if (iData.GetDataPresent(System.Windows.Forms.DataFormats.Text))
     {
         return((string)iData.GetData(System.Windows.Forms.DataFormats.Text));
     }
     return("");
 }
コード例 #10
0
        public Image CopyImage(Range ran, string cells)
        {
            System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();
            string[] r = cells.Split(':');
            ran.Range[r[0], r[1]].CopyPicture(XlPictureAppearance.xlScreen, XlCopyPictureFormat.xlBitmap);
            Image image = (Image)data.GetData(System.Windows.Forms.DataFormats.Bitmap, true);

            return(image);
        }
コード例 #11
0
 public static Image GetImage()
 {
     System.Windows.Forms.IDataObject dataObject = GetDataObject();
     if (dataObject != null)
     {
         return(dataObject.GetData(DataFormats.Bitmap, true) as Image);
     }
     return(null);
 }
コード例 #12
0
 public static bool ContainsText(TextDataFormat format)
 {
     if (!System.Windows.Forms.ClientUtils.IsEnumValid(format, (int)format, 0, 4))
     {
         throw new InvalidEnumArgumentException("format", (int)format, typeof(TextDataFormat));
     }
     System.Windows.Forms.IDataObject dataObject = GetDataObject();
     return((dataObject != null) && dataObject.GetDataPresent(ConvertToDataFormats(format), false));
 }
コード例 #13
0
 public static Stream GetAudioStream()
 {
     System.Windows.Forms.IDataObject dataObject = GetDataObject();
     if (dataObject != null)
     {
         return(dataObject.GetData(DataFormats.WaveAudio, false) as Stream);
     }
     return(null);
 }
コード例 #14
0
 public static object GetData(string format)
 {
     System.Windows.Forms.IDataObject dataObject = GetDataObject();
     if (dataObject != null)
     {
         return(dataObject.GetData(format));
     }
     return(null);
 }
コード例 #15
0
    public OutlookDataObject(System.Windows.Forms.IDataObject underlyingDataObject)
    {
        this.underlyingDataObject    = underlyingDataObject;
        this.comUnderlyingDataObject = (System.Runtime.InteropServices.ComTypes.IDataObject) this.underlyingDataObject;

        FieldInfo innerDataField = this.underlyingDataObject.GetType().GetField("innerData", BindingFlags.NonPublic | BindingFlags.Instance);

        this.oleUnderlyingDataObject   = (System.Windows.Forms.IDataObject)innerDataField.GetValue(this.underlyingDataObject);
        this.getDataFromHGLOBLALMethod = this.oleUnderlyingDataObject.GetType().GetMethod("GetDataFromHGLOBLAL", BindingFlags.NonPublic | BindingFlags.Instance);
    }
コード例 #16
0
        public static IEnumerable <File> Decode(System.Windows.Forms.IDataObject data)
        {
            IntPtr fileGroupDescriptorWPointer = IntPtr.Zero;

            try
            {
                //use the underlying IDataObject to get the FileGroupDescriptorW as a MemoryStream
                MemoryStream fileGroupDescriptorStream = (MemoryStream)data.GetData("FileGroupDescriptorW");
                byte[]       fileGroupDescriptorBytes  = new byte[fileGroupDescriptorStream.Length];
                fileGroupDescriptorStream.Read(fileGroupDescriptorBytes, 0, fileGroupDescriptorBytes.Length);
                fileGroupDescriptorStream.Close();

                //copy the file group descriptor into unmanaged memory
                fileGroupDescriptorWPointer = Marshal.AllocHGlobal(fileGroupDescriptorBytes.Length);
                Marshal.Copy(fileGroupDescriptorBytes, 0, fileGroupDescriptorWPointer, fileGroupDescriptorBytes.Length);

                //marshal the unmanaged memory to to FILEGROUPDESCRIPTORW struct
                object fileGroupDescriptorObject = Marshal.PtrToStructure(fileGroupDescriptorWPointer, typeof(NativeMethods.FILEGROUPDESCRIPTORW));
                NativeMethods.FILEGROUPDESCRIPTORW fileGroupDescriptor = (NativeMethods.FILEGROUPDESCRIPTORW)fileGroupDescriptorObject;

                //create a new array to store file names in of the number of items in the file group descriptor
                List <File> files = new List <File>();

                //get the pointer to the first file descriptor
                IntPtr fileDescriptorPointer = (IntPtr)((int)fileGroupDescriptorWPointer + Marshal.SizeOf(fileGroupDescriptorWPointer));

                //loop for the number of files acording to the file group descriptor
                for (int fileDescriptorIndex = 0; fileDescriptorIndex < fileGroupDescriptor.cItems; fileDescriptorIndex++)
                {
                    //marshal the pointer top the file descriptor as a FILEDESCRIPTORW struct and get the file name
                    NativeMethods.FILEDESCRIPTORW fileDescriptor = (NativeMethods.FILEDESCRIPTORW)Marshal.PtrToStructure(fileDescriptorPointer, typeof(NativeMethods.FILEDESCRIPTORW));
                    File file = new File();
                    file.Name = fileDescriptor.cFileName;
                    file.Size = (long)fileDescriptor.nFileSizeLow + ((long)fileDescriptor.nFileSizeHigh << 32);
                    files.Add(file);

                    //move the file descriptor pointer to the next file descriptor
                    fileDescriptorPointer = (IntPtr)((int)fileDescriptorPointer + Marshal.SizeOf(fileDescriptor));
                }

                int index = 0;
                foreach (File f in files)
                {
                    f.Content = GetData(data, FileContents, index++);
                }

                //return the array of files
                return(files);
            }
            finally
            {
                //free unmanaged memory pointer
                Marshal.FreeHGlobal(fileGroupDescriptorWPointer);
            }
        }
コード例 #17
0
        /// <summary>
        /// Called when the user presses CTRL+V or chooses Paste on the diagram.
        /// This method assumes we only want to paste things onto the diagram
        /// - not onto anything contained in the diagram.
        /// The base method pastes in a free space on the diagram.
        /// But if the menu was used to invoke paste, we want to paste in the cursor position.
        /// </summary>
        protected override void ProcessOnMenuPasteCommand()
        {
            // If true, this method assumes we're only pasting on the diagram.
            // Anything selected will be deselected, and paste will be onto diagram.
            const bool pasteOnlyOnDiagram = true;

            CircuitsDocView docView = this.CurrentModelingDocView as CircuitsDocView;

            // Retrieve data from clipboard:
            System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();

            Diagram diagram = docView.CurrentDiagram;

            if (diagram == null)
            {
                return;
            }

            if (!docView.IsContextMenuShowing)
            {
                // User hit CTRL+V - just use base method.

                // Deselect anything that's selected, otherwise
                // pasted item will be incompatible:
                if (pasteOnlyOnDiagram && !this.IsDiagramSelected())
                {
                    docView.SelectObjects(1, new object[] { diagram }, 0);
                }

                // Paste into a convenient spare space on diagram:
                base.ProcessOnMenuPasteCommand();
            }
            else
            {
                // User right-clicked - paste at mouse position.

                // Utility class:
                DesignSurfaceElementOperations op = diagram.ElementOperations;

                ShapeElement pasteTarget = pasteOnlyOnDiagram ? diagram : this.CurrentSelection.OfType <ShapeElement>().First();

                // Check whether what's in the paste buffer is acceptable on the target.
                if (op.CanMerge(pasteTarget, data))
                {
                    // Although op.Merge would be a no-op if CanMerge failed, we check CanMerge first
                    // so that we don't create an empty transaction (after which Undo would be no-op).
                    using (Transaction t = diagram.Store.TransactionManager.BeginTransaction("paste"))
                    {
                        PointD place = docView.ContextMenuMousePosition;
                        op.Merge(pasteTarget, data, PointD.ToPointF(place));
                        t.Commit();
                    }
                }
            }
        }
コード例 #18
0
ファイル: TfsManager.cs プロジェクト: jeason0813/Salma
        /// <summary>
        /// The add step for work item "Test Case".
        /// </summary>
        /// <param name="dataObject"></param>
        /// <param name="workItem"></param>
        public void AddStep(IDataObject dataObject, WorkItem workItem, out bool comment, bool isAddStep)
        {
            var    popup = new StepActionsResult();
            string temp  = Regex.Replace(dataObject.GetData(DataFormats.Text).ToString(), @"\s+", " ");

            popup.action.Text = temp;
            popup.Create(null, Icons.AddDetails);
            ITestManagementService testService = collection.GetService <ITestManagementService>();
            var project  = testService.GetTeamProject(workItem.Project.Name);
            var testCase = project.TestCases.Find(workItem.Id);
            var step     = testCase.CreateTestStep();

            if (!popup.IsCanceled)
            {
                switch (tfsVersion)
                {
                case TfsVersion.Tfs2011:

                    step.Title          = "<div><p><span>" + popup.action.Text + "</span></p></div>";
                    step.ExpectedResult = "<div><p><span>" + popup.expectedResult.Text + "</span></p></div>";


                    //step.Title = popup.action.Text;
                    //step.ExpectedResult = popup.expectedResult.Text;

                    break;

                case TfsVersion.Tfs2010:

                    step.Title          = popup.action.Text;
                    step.ExpectedResult = popup.expectedResult.Text;

                    break;
                }
                if (isAddStep)
                {
                    testCase.Actions.Add(step);
                }
                else
                {
                    testCase.Actions.Clear();
                    testCase.Actions.Add(step);
                }
                testCase.Save();
                workItem.Save();
                comment = true;
            }
            else
            {
                comment = false;
            }
        }
コード例 #19
0
ファイル: ClipboardUtil.cs プロジェクト: Avinash-acid/saveenr
        public static void SetDataCSVFromTable(System.Windows.Forms.IDataObject dataobject, System.Data.DataTable datatable)
        {
            var default_encoding = System.Text.Encoding.Default;
            var out_memstream    = new System.IO.MemoryStream();
            var streamwriter     = new System.IO.StreamWriter(out_memstream, default_encoding);
            var csvwriter        = new CSV.CSVWriter(streamwriter);

            ExportToCSV(datatable, csvwriter);
            var bytes        = out_memstream.ToArray();
            var in_memstream = new System.IO.MemoryStream(bytes);

            dataobject.SetData(System.Windows.Forms.DataFormats.CommaSeparatedValue, in_memstream);
        }
コード例 #20
0
        public string ReturnTextFromClipBoard()
        {
            System.Windows.Forms.IDataObject iData = System.Windows.Forms.Clipboard.GetDataObject();

            if (iData.GetDataPresent(System.Windows.Forms.DataFormats.Text))
            {
                return((String)iData.GetData(System.Windows.Forms.DataFormats.Text));
            }
            else
            {
                return(null);
            }
        }
コード例 #21
0
ファイル: ClipboardHandler.cs プロジェクト: xuanximoming/key
 public static bool CanGetData(string strFormat)
 {
     try
     {
         System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();
         return(data != null && data.GetDataPresent(strFormat));
     }
     catch (Exception ext)
     {
         //ZYErrorReport.Instance.DebugPrint("CanGetData:试图获得" + strFormat + "格式的剪切板数据错误:" + ext.Message );
         return(false);
     }
 }
コード例 #22
0
        /// <summary>
        /// 从系统剪贴板中copy文本
        /// </summary>
        protected void PasteFromClipboard()
        {
            // Declares an IDataObject to hold the data returned from the clipboard.
            // Retrieves the data from the clipboard.
            System.Windows.Forms.IDataObject iData = System.Windows.Forms.Clipboard.GetDataObject();

            // Determines whether the data is in a format you can use.
            if (iData.GetDataPresent(System.Windows.Forms.DataFormats.Text))
            {
                // Yes it is, so display it in a text box.
                InsertText((String)iData.GetData(System.Windows.Forms.DataFormats.Text));
            }
        }
コード例 #23
0
ファイル: ClipboardHandler.cs プロジェクト: xuanximoming/key
 /// <summary>
 /// 是否可以从操作系统剪切板获得文本
 /// </summary>
 /// <returns>true 可以从操作系统剪切板获得文本,false 不可以</returns>
 public static bool CanGetText()
 {
     // Clipboard.GetDataObject may throw an exception...
     try
     {
         System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();
         return(data != null && data.GetDataPresent(System.Windows.Forms.DataFormats.Text));
     }
     catch (Exception ext)
     {
         //ZYErrorReport.Instance.DebugPrint("CanGetText:试图获得文本格式的剪切板数据错误:" + ext.Message );
         return(false);
     }
 }
コード例 #24
0
        /// <summary>
        /// Converts a window dataobject to an inputshare clipboard data object
        /// </summary>
        /// <param name="data"></param>
        /// <param name="attempt"></param>
        /// <returns></returns>
        public static ClipboardDataBase ConvertToGeneric(System.Windows.Forms.IDataObject data, int attempt = 0)
        {
            try
            {
                System.Windows.Forms.DataObject obj = data as System.Windows.Forms.DataObject;
                if (data.GetDataPresent(DataFormats.Bitmap, true))
                {
                    using (Image i = obj.GetImage())
                    {
                        using (MemoryStream ms = new MemoryStream())
                        {
                            i.Save(ms, Settings.ImageEncodeFormat);
                            return(new ClipboardImageData(ms.ToArray(), true));
                        }
                    }
                }
                else if (data.GetDataPresent(DataFormats.Text))
                {
                    return(new ClipboardTextData((string)data.GetData(DataFormats.UnicodeText)));
                }
                else if (data.GetDataPresent(DataFormats.FileDrop))
                {
                    return(ReadFileDrop(data));
                }

                else
                {
                    ISLogger.Write("possible data formats: ");
                    foreach (var format in data.GetFormats())
                    {
                        ISLogger.Write(format);
                    }

                    throw new ClipboardTranslationException("Dataobject not implemented");
                }
            }
            catch (COMException ex)
            {
                ISLogger.Write("COM exception: " + ex.Message);
                Thread.Sleep(25);
                if (attempt > 10)
                {
                    throw new Exception("Could not read clipboard after 10 attempts.");
                }

                int n = attempt + 1;
                return(ConvertToGeneric(data, n));
            }
        }
コード例 #25
0
        public static StringCollection GetFileDropList()
        {
            System.Windows.Forms.IDataObject dataObject = GetDataObject();
            StringCollection strings = new StringCollection();

            if (dataObject != null)
            {
                string[] data = dataObject.GetData(DataFormats.FileDrop, true) as string[];
                if (data != null)
                {
                    strings.AddRange(data);
                }
            }
            return(strings);
        }
コード例 #26
0
ファイル: ClipboardHandler.cs プロジェクト: xuanximoming/key
 /// <summary>
 /// 从操作系统剪切板获得文本
 /// </summary>
 /// <returns>获得的文本,若操作失败则返回空对象</returns>
 public static string GetTextFromClipboard()
 {
     try
     {
         System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();
         if (data.GetDataPresent(System.Windows.Forms.DataFormats.UnicodeText))
         {
             string strText = ( string)data.GetData(System.Windows.Forms.DataFormats.UnicodeText);
             return(strText);
         }
     }
     catch
     {}
     return(null);
 }
コード例 #27
0
ファイル: ClipboardHandler.cs プロジェクト: xuanximoming/key
 public static object GetDataFromClipboard(string strFormat)
 {
     try
     {
         System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();
         if (data != null && data.GetDataPresent(strFormat))
         {
             return(data.GetData(strFormat));
         }
     }
     catch (Exception ext)
     {
         //ZYErrorReport.Instance.DebugPrint("GetDataFromClipboard:试图获得" + strFormat + "格式的剪切板数据错误:" + ext.Message );
     }
     return(null);
 }
コード例 #28
0
 public System.Drawing.Image getCaptureImage()
 {
     System.Windows.Forms.IDataObject iData    = System.Windows.Forms.Clipboard.GetDataObject();
     System.Drawing.Image             retImage = null;
     if (iData != null)
     {
         if (iData.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap))
         {
             retImage = (System.Drawing.Image)iData.GetData(System.Windows.Forms.DataFormats.Bitmap);
         }
         else if (iData.GetDataPresent(System.Windows.Forms.DataFormats.Dib))
         {
             retImage = (System.Drawing.Image)iData.GetData(System.Windows.Forms.DataFormats.Dib);
         }
     }
     return(retImage);
 }
コード例 #29
0
 public static string GetText(TextDataFormat format)
 {
     if (!System.Windows.Forms.ClientUtils.IsEnumValid(format, (int)format, 0, 4))
     {
         throw new InvalidEnumArgumentException("format", (int)format, typeof(TextDataFormat));
     }
     System.Windows.Forms.IDataObject dataObject = GetDataObject();
     if (dataObject != null)
     {
         string data = dataObject.GetData(ConvertToDataFormats(format), false) as string;
         if (data != null)
         {
             return(data);
         }
     }
     return(string.Empty);
 }
        protected override void ProcessOnStatusPasteCommand(System.ComponentModel.Design.MenuCommand cmd)
        {
            base.ProcessOnStatusPasteCommand(cmd);

            if (!cmd.Enabled && this.SingleSelection is ElementListCompartment)
            {
                var          compartment = (ElementListCompartment)this.SingleSelection;
                ShapeElement pasteTarget = compartment.ParentShape;

                System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();

                if (pasteTarget != null && this.ElementOperations.CanMerge(pasteTarget, data))
                {
                    cmd.Enabled = true;
                }
            }
        }
コード例 #31
0
 private DragEventArgs CreateDragEventArgs(object pDataObj, int grfKeyState, NativeMethods.POINTL pt, int pdwEffect)
 {
     System.Windows.Forms.IDataObject data = null;
     if (pDataObj == null)
     {
         data = this.lastDataObject;
     }
     else if (pDataObj is System.Windows.Forms.IDataObject)
     {
         data = (System.Windows.Forms.IDataObject) pDataObj;
     }
     else if (pDataObj is System.Runtime.InteropServices.ComTypes.IDataObject)
     {
         data = new DataObject(pDataObj);
     }
     else
     {
         return null;
     }
     DragEventArgs args = new DragEventArgs(data, grfKeyState, pt.x, pt.y, (DragDropEffects) pdwEffect, this.lastEffect);
     this.lastDataObject = data;
     return args;
 }
コード例 #32
0
 public int QueryAcceptData(System.Runtime.InteropServices.ComTypes.IDataObject lpdataobj, IntPtr lpcfFormat, int reco, int fReally, IntPtr hMetaPict)
 {
     if (reco != 1)
     {
         return -2147467263;
     }
     if (this.owner.AllowDrop || this.owner.EnableAutoDragDrop)
     {
         MouseButtons mouseButtons = Control.MouseButtons;
         Keys modifierKeys = Control.ModifierKeys;
         int keyState = 0;
         if ((mouseButtons & MouseButtons.Left) == MouseButtons.Left)
         {
             keyState |= 1;
         }
         if ((mouseButtons & MouseButtons.Right) == MouseButtons.Right)
         {
             keyState |= 2;
         }
         if ((mouseButtons & MouseButtons.Middle) == MouseButtons.Middle)
         {
             keyState |= 0x10;
         }
         if ((modifierKeys & Keys.Control) == Keys.Control)
         {
             keyState |= 8;
         }
         if ((modifierKeys & Keys.Shift) == Keys.Shift)
         {
             keyState |= 4;
         }
         this.lastDataObject = new DataObject(lpdataobj);
         if (!this.owner.EnableAutoDragDrop)
         {
             this.lastEffect = DragDropEffects.None;
         }
         DragEventArgs drgevent = new DragEventArgs(this.lastDataObject, keyState, Control.MousePosition.X, Control.MousePosition.Y, DragDropEffects.Move | DragDropEffects.Copy | DragDropEffects.Scroll, this.lastEffect);
         if (fReally == 0)
         {
             drgevent.Effect = ((keyState & 8) == 8) ? DragDropEffects.Copy : DragDropEffects.Move;
             this.owner.OnDragEnter(drgevent);
         }
         else
         {
             this.owner.OnDragDrop(drgevent);
             this.lastDataObject = null;
         }
         this.lastEffect = drgevent.Effect;
         if (drgevent.Effect == DragDropEffects.None)
         {
             return -2147467259;
         }
         return 0;
     }
     this.lastDataObject = null;
     return -2147467259;
 }
コード例 #33
0
ファイル: TfsManager.cs プロジェクト: nkravch/SALMA-2.0
        /// <summary>
        /// The add step for work item "Test Case".
        /// </summary>
        /// <param name="dataObject"></param>
        /// <param name="workItem"></param>
        public void AddStep(IDataObject dataObject, WorkItem workItem, out bool comment,bool isAddStep)
        {
            var popup = new StepActionsResult();
            string temp = Regex.Replace(dataObject.GetData(DataFormats.Text).ToString(), @"\s+", " ");
            popup.action.Text = temp;
            popup.Create(null, Icons.AddDetails);
            ITestManagementService testService = collection.GetService<ITestManagementService>();
            var project = testService.GetTeamProject(workItem.Project.Name);
            var testCase = project.TestCases.Find(workItem.Id);
            var step = testCase.CreateTestStep();

            if (!popup.IsCanceled)
            {
                switch (tfsVersion)
                {
                    case TfsVersion.Tfs2011:

                        step.Title = "<div><p><span>" + popup.action.Text + "</span></p></div>";
                        step.ExpectedResult = "<div><p><span>" + popup.expectedResult.Text + "</span></p></div>";


                        //step.Title = popup.action.Text;
                        //step.ExpectedResult = popup.expectedResult.Text;

                        break;
                    case TfsVersion.Tfs2010:

                        step.Title = popup.action.Text;
                        step.ExpectedResult = popup.expectedResult.Text;

                        break;
                }
                if (isAddStep)
                {
                    testCase.Actions.Add(step);
                }
                else
                {
                    testCase.Actions.Clear();
                    testCase.Actions.Add(step);
                }
                testCase.Save();
                workItem.Save();
                comment = true;
            }
            else
            {
                comment = false;
            }
        }
コード例 #34
0
ファイル: TfsManager.cs プロジェクト: nkravch/SALMA-2.0
        /// <summary>
        /// The add details for work item.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <param name="fieldName">
        /// The field name.
        /// </param>
        /// <param name="dataObject">
        /// The data Object.
        /// </param>
        public void AddDetailsForWorkItem(int id, string fieldName, IDataObject dataObject, out bool comment)
        {
            //var html = dataObject.GetData(DataFormats.Html).ToString();
            string html = ClipboardHelper.Instanse.CopyFromClipboard();

            WorkItem workItem = ItemsStore.GetWorkItem(id);
            string attachmentName = string.Empty;
            html = html.CleanHeader();
            IDictionary<string, string> links = html.GetLinks();

            foreach (var link in links)
            {
                if (File.Exists(link.Value) &&
                    !(new FileInfo(link.Value).Extension == ".thmx" || new FileInfo(link.Value).Extension == ".xml" ||
                      new FileInfo(link.Value).Extension == ".mso"))
                {
                    var attach = new Attachment(link.Value);
                    if (tfsVersion == TfsVersion.Tfs2010)
                    {

                        var attachIndex = workItem.Attachments.Add(attach);
                        workItem.Save();
                        attachmentName += string.Format("Name={0} Id={1},", workItem.Attachments[attachIndex].Name, workItem.Attachments[attachIndex].Id);
                        string uri = attach.Uri.ToString();
                        html = html.Replace(link.Key, uri);
                    }
                    else
                    {
                        workItem.Attachments.Add(attach);
                        workItem.Save();
                        string uri = attach.Uri.ToString();
                        html = html.Replace(link.Key, uri);
                    }

                }
                else
                {
                    html = html.Replace(link.Key, string.Empty);
                }
            }

            Field itemField = workItem.Fields.Cast<Field>().FirstOrDefault(f => f.Name == fieldName);
            //Field fieldSteps = workItem.Fields.Cast<Field>().FirstOrDefault(f => f.Id == 10265);
            Field fieldSteps = workItem.Fields.Cast<Field>().FirstOrDefault(f => f.Name == "Steps");
            var fields = workItem.Fields;
            if (fieldSteps == null)
            {
                fieldSteps = workItem.Fields.Cast<Field>().FirstOrDefault(f => f.Name == "Шаги");
                //fieldSteps = workItem.Fields.Cast<Field>().FirstOrDefault(f => f.Id == 10032);
            }
            comment = false;
            if (itemField != null)
            {
                if (fieldSteps != null && fieldName == fieldSteps.Name)
                {
                        AddStep(dataObject, workItem, out comment, true);
                }
                else
                {

                    if (tfsVersion == TfsVersion.Tfs2010)
                    {
                        if (itemField.FieldDefinition.FieldType == FieldType.Html)
                        {
                            itemField.Value += html.ClearComments();
                        }
                        else
                        {
                            string temp = Regex.Replace(dataObject.GetData(DataFormats.Text).ToString(), @"\s+", " ");
                            itemField.Value += "\r" + temp;
                            if (attachmentName != string.Empty)
                                itemField.Value += string.Format("\r({0}: {1})", Resources.SeeAttachments_Text, attachmentName.TrimEnd(','));
                        }

                    }
                    else
                    {
                        itemField.Value += html.ClearComments();
                    }
                    workItem.Save();
                    comment = true;
                }


            }
        }
コード例 #35
0
 int UnsafeNativeMethods.IOleDropTarget.OleDrop(object pDataObj, int grfKeyState, long pt, ref int pdwEffect)
 {
     NativeMethods.POINTL pointl = new NativeMethods.POINTL {
         x = this.GetX(pt),
         y = this.GetY(pt)
     };
     DragEventArgs e = this.CreateDragEventArgs(pDataObj, grfKeyState, pointl, pdwEffect);
     if (e != null)
     {
         this.owner.OnDragDrop(e);
         pdwEffect = (int) e.Effect;
     }
     else
     {
         pdwEffect = 0;
     }
     this.lastEffect = DragDropEffects.None;
     this.lastDataObject = null;
     return 0;
 }
コード例 #36
0
ファイル: MainWindow.xaml.cs プロジェクト: CryZe/WindEditor2
 void m_glControl_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
 {
     m_isDragDropHovering = true;
     m_dragDropData = e.Data;
 }