14 Replies Latest reply on Mar 25, 2010 2:00 PM by wpurrer

    Drag and Drop into ProcessBook

    wpurrer

      Maybe some can remember my hijacked post with my Processbook - Addins.

       

      I now on the way to create the first - add in (Treeview with drag and drop)

       

      I'm nearly finished, but the Drag and Drop is now the problem (as you can see the drag and drop should work fine => attachment), but if i drop on the processbook trend nothing happens. (is there a special format, how the  tag has to be formated ?)

        • Re: Drag and Drop into ProcessBook
          cescamilla

          Are you dragging a tag from your treeview and dropping it into a Trend in ProcessBook?

            • Re: Drag and Drop into ProcessBook
              wpurrer

              Yes (in this case the treeview is the ultrwingrid from infragistics,.. which can be used as a tree grid)

               

               

               

              The first step is to drop it on a trend in processbook, the second step would be to choose the type (numeric, trend, sqc,...) and drop it on an empty place in the processbook (like the datafavourites)

                • Re: Drag and Drop into ProcessBook
                  cescamilla

                  I was affraid so.

                   

                  Here is the deal, for drag and drop you need an two objects, a sending object that can define a behaviour for MoveMouse, and another object (the receiver) that can define behaviours for BeforeDropOrPaste and BeforeDragOver.

                   

                  As far as I know the Trend object in ProcessBook does not include either of the methos required for it to be a drag and drop target :(

                   

                  However, not evertything is lost! creating a simple list control I was able to drag n drop from another (the treeview in your case, but I used another listbox) object and send the object to the trend.

                   

                  I know this is not exactly what you were requesting, but it does come closer to a solution.

                   

                   

                   

                  Start a new PDI, create 2 listbox objects and 1 trend. then go to VBA and paste this code.

                  Private Sub Display_Open()
                    ListBox1.AddItem ("SINUSOID")
                    ListBox1.AddItem ("CDT158")
                  End Sub

                  Private Sub ListBox2_BeforeDragOver(ByVal Cancel As MSForms.ReturnBoolean, _
                  ByVal Data As MSForms.DataObject, _
                  ByVal X As Single, _
                  ByVal Y As Single, _
                  ByVal DragState As MSForms.fmDragState, _
                  ByVal Effect As MSForms.ReturnEffect, _
                  ByVal Shift As Integer)
                  Cancel = True
                  Effect = 1
                  End Sub

                  Private Sub ListBox2_BeforeDropOrPaste _
                  (ByVal Cancel As MSForms.ReturnBoolean, _
                  ByVal Action As Long, _
                  ByVal Data As MSForms.DataObject, _
                  ByVal X As Single, _
                  ByVal Y As Single, _
                  ByVal Effect As MSForms.ReturnEffect, _
                  ByVal Shift As Integer)
                  Cancel = True
                  Effect = 1
                  ListBox2.AddItem Data.GetText
                  Trend1.AddTrace (Data.GetText)
                  End Sub

                  Private Sub ListBox1_MouseMove(ByVal Button As Integer, _
                  ByVal Shift As Integer, _
                  ByVal X As Single, _
                  ByVal Y As Single)

                  Dim MyDataObject As DataObject
                  If Button = 1 Then
                  Set MyDataObject = New DataObject
                  Dim Effect As Integer
                  MyDataObject.SetText ListBox1.Value
                  Effect = MyDataObject.StartDrag
                  End If
                  End Sub

                   

                   

                  that should do the trick.

                    • Re: Drag and Drop into ProcessBook
                      wpurrer

                      For the whole Pictures (I have a couple of different structures in AF - Databases) where I created a Processbook - Plugin and filled the AF - Data into  UltraWinGrid (in a TreeView  - Mode) . The User should now use Drag'n'Drop  to create Pictures (similar to the "DataFavourites - Plugin" which comes with 3.2)
                      => We prefer the UltraWinGrid, because it does have the necessary searching capabilities

                       

                      It is working with the  Datafav. or the AF - Browser / AF - Properties so there should be just a matter of the right Parameters in the DoDragDrop(..) . but i don't find the right one ...

                       

                      It is also a mather of adding it to the right trends (there are a couple of trends) or the later create a new trend, a numeric,...

                • Re: Drag and Drop into ProcessBook

                  Hi Wolfgang,

                   


                  Your friendly neighbourhood hijacker here

                   

                  Your problem is you are passing the string objects in DoDragDrop rather than an object of type IDataObject (example = System.Windows.Forms.DataObject class) that a display needs.

                   

                  So for example (in vb.net) you would use:

                  
                  

                  '''
                  Dim MyDO As New DataObject(DataFormats.Text, "\\piservername\sinusoid")
                  object.DoDragDrop(MyDO, DragDropEffects.Copy)

                   

                  Works perfectly fine for me, even on a trend.

                   

                  Enjoy!

                   

                   

                    • Re: Drag and Drop into ProcessBook
                      wpurrer

                      .. very interesting it doesnt work for me:

                       

                       

                       

                        string t = @"\\pimshist\test";
                        DataObject myDo = new DataObject(DataFormats.Text, t);
                        DoDragDrop(myDo, DragDropEffects.Copy);

                       

                      the Mouse Icon Changes, but after drop it on the trend view nothing happens.

                        • Re: Drag and Drop into ProcessBook

                          Hi Wolfgang,

                          OK just figured it out, the functionality for providing drag/drop on to a display/trend and having it update the symbols is provided by the Data Favourites addin - not by ProcessBook itself. 

                           

                          To implement the behaviour you would need to build the logic in to the "Display_OnOleDrop" event of a display (or assume the Data Favourites add in is loaded) - e.g. check the x/y coords in OnOleDrop, find the top most symbol for the coords, check the PBDataObject for data type & value(s) and finally check if the top most symbol supports the "SetTagName" method.  If there is no symbol at the coordinates or a symbol that does not support a SetTagName (or DataSet) then default to a PI Value/Trend/Text object - this must be how the Data Favourites is achieving this...wonder if OSI could confirm this.