How to get 2nd click event on same element

HI,
 I have done on getting the position value of 1st click on Image here as given code:
<Image Name="imgBackground" HorizontalAlignment="Center" VerticalAlignment="Center" Height="799" Width="799" MouseLeftButtonDown="imgBackground_MouseLeftButtonDown" Stretch="Uniform">
</Image>
OpenFileDialog op = new OpenFileDialog();
ImageBrush ib = new ImageBrush();
private void Image_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
op.Title = "Select a picture";
op.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" +
"JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" +
"Portable Network Graphic (*.png)|*.png";
if (op.ShowDialog() == true)
imgBackground.Source = new BitmapImage(new Uri(op.FileName));
private BitmapSource CutImage(BitmapImage img, Point p1, int width, int height)
return new CroppedBitmap(img, new Int32Rect(Convert.ToInt32(p1.X), Convert.ToInt32(p1.Y), width, height));
double xAxis = 0.00;
double yAxis = 0.00;
private void imgBackground_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
Point center = e.GetPosition(imgBackground);
xAxis = center.X;
yAxis = center.Y;
ib.ImageSource = CutImage(new BitmapImage(new Uri(op.FileName)), new Point(xAxis, yAxis), 200, 200);
CanvasPanel.Background = ib;
As in above code, I'm getting center point of that image.
 I want to get one more point on same image and need to calculate distance between two points(1st clicked point and 2nd clicked point)
Suggest me the way to get that.
Regards,
Viswa

I would store the co-ordinates as you click in  a private point variable.
Call that B.
Plus the last point in another A.
as you click, swop B to A and pick up the current, save to B.
And this function seems to do the distance calculation:
public double GetDistanceBetweenPoints(Point p, Point q)
double a = p.X - q.X;
double b = p.Y - q.Y;
double distance = Math.Sqrt(a * a + b * b);
return distance;
http://www.csharpdeveloping.net/Snippet/How_to_get_distance_between_two_points
Hand it A and B.
I would have though what you have called center is just the position the click is.
Tea time now.
Please don't forget to upvote posts which you like and mark those which answer your question.
My latest Technet article - Dynamic XAML

Similar Messages

  • How to get 2nd line in smartforms using template

    how to get 2nd line in smartforms main window using template. i have also defined loop .

    if possible can you try with the TABLES..
    Put one TABLE in your MAIN window
    create table lines as per your requirment...consider all lines like 6 for header, 1 for main, 1 for total
    Now, you will find three section under the tables: header, main, footer...
    in header section, create a table line, assign one of the proper lines from the line types.. repeat for your all lines.
    in main section, you can access your data form the loop.
    the footer secion will be called, just after the main will be finished.
    Regards,
    Naimesh Patel

  • How to get two parameters in the same line of selection screen?

    hello
    i need to get my selection csreen like bellow.
    r1 radiobuttion  -some space --p1 parameter
    i should not get the parameter in the next line of  radiobuttion.
    how to get two parameters in the same line of selection screen?

    hi....
    modify the following code
    it will work
    SELECTION-SCREEN BEGIN OF BLOCK SL1 WITH FRAME TITLE TEXT-003.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 10(15) TEXT-001
                     FOR FIELD P1.
    SELECTION-SCREEN POSITION POS_LOW.
    PARAMETERS : P1 TYPE   C USER-COMMAND R2 RADIOBUTTON GROUP R2 DEFAULT 'X',
      P2 TYPE SCARR-CARRNAME,
      P3 TYPE CHAR1 RADIOBUTTON GROUP R2.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK SL1.

  • How to handle double click event in a text control

    Hi,
       Will u please send me information on handling double click events inside text control and also about locking and unlocking of DB tables for updation.
    Regards,
    Praba.

    Hi Prabhavathi,
    Here is how you handle double click events in Textedit control.
    1)Create a custom control in screen (say TEXT_CONTROL)
    2)In main program,
    a) Declarations:
    data: obj type ref to cl_gui_custiom_control.
          text type ref to cl_gui_textedit.
    b) Create the instance of custom container
    c) Create the instance of textedit control.
    3)Now to handle double click events , create a local class as follows.
    class shail_event definition.
    public section.
    methods:
    handle_doubleclick for event dblclick of cl_gui_textedit .
    endclass.
    class shail_event implementation.
    method handle_doubleclick .
    here do the coding for handling the double click.
    endmethod.
    endclass.
    4) Create an instance of the handler class(ie.ZSHAIL_EVENT).Let it be named hand.
    5) Define varibles for event.
    DATA: i_events TYPE cntl_simple_events,
          wa_events TYPE cntl_simple_event.
    SET HANDLER hand->handle_doubleclick for text.
    wa_events-eventid = cl_gui_textedit=>event_double_click.
    wa_events-appl_event = 'X'. "This is an application event
    APPEND wa_events TO i_events.
    6)
        CALL METHOD texte->set_registered_events
          EXPORTING
            events                    = i_events
          EXCEPTIONS
            cntl_error                = 1
            cntl_system_error         = 2
            illegal_event_combination = 3
            OTHERS                    = 4.
        IF sy-subrc <> 0.
         MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    These are the basic steps needed for handling events in Textedit control.You can go to SE24 and type CL_GUI_TEXTEDIT to find the associated events of the class.
    If you want the program, kindly send your mail-id so that I can mail it to you.
    Regards,
    Sylendra.

  • When launching Illustrator on Mac OSX 10.9 I get an erro that the program is no longer supported on PowerPC. I tried moving the plug-ins to a different folder as the Adobe site suggested but no luck. Any ideas how to get this launched again? Same issue fo

    When launching Illustrator on Mac OSX 10.9 I get an error that the program is no longer supported on PowerPC. I tried moving the plug-ins to a different folder as the Adobe site suggested but no luck. Any ideas how to get this launched again? Same issue for Photoshop and InDesign

    You will need to uninstall, run the Cleaner tool and reinstall you adobe applications. Adobe apps don't take kindly to inplace updates of the OS on Macs.
    Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6

  • How to get 64 bit version for premiere elements 12

    How to get  64-bit version for Premier Elements 12 ? 
    I download from ADMISY site.
    Click on win 64 bit and download it.
    When I try to install ther is a error  this download version is not for 64 bit I have try many times but same result

    Hello
    I have been away some days
    ADMISY is a software partners for Adobe
    I running Win 7 Home Edition
    I have received a card with a code when I bought the program and the I
    download from ADMISY
    Sending serial and installation warning
    PhotoshopElements_12_WWEFDJ.7z
    PhotoshopElements_12_WWEFDJ
    PremiereElements_12_WWEFDJ_win32.7z
    PremiereElements_12_WWEFDJ_win32
    I can not find a 64 bit version of 32-bit or 64-bit version of downloads
    This is information I have
    Best regards
    Erling Magnusson
    2015-02-04 22:33 GMT+01:00 Adobe Forums <[email protected]>:
        How to get 64 bit version for premiere elements 12  created by A.T.
    Romano <https://forums.adobe.com/people/A.T.+Romano> in *Premiere
    Elements* - View the full discussion
    <https://forums.adobe.com/message/7162950#7162950>

  • How to get the focus of particular UI Element

    Hi All,
    How to get the focus of particular UI Element in webdynpro Page,
    I have a page where i am creating a ALV, I want to get that keyboard focus is on that element is there or not?
    Can anyone please give some update?
    Best regards,
    Rohit

    I would suggest try invoking REFRESH of ALV on the ON_CELL_ACTION event.
    Below excerpt is from Thomas
    The Events of inner UI elements are not exposed directly as they normally would be if they were standalone. Generally you can capture them using either the
    ON_DATA_CHECK:
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/c8/6c80dbedfe42d1a93f8e6df1d7244a/frameset.htm
    This gets trigger for any press of ENTER, so it generally works like the Input Field onEnter.
    You could also consider ON_CELL_ACTION:
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/45/12093591152464e10000000a1553f7/frameset.htm
    It is a higher level Event that encompasses both ON_DATA_CHECK and ON_CLICK.
    if you want to capture & refresh on some hot key combination then refer to this thread
    [https://www.sdn.sap.com/irj/scn/profile?editmode=true&userid=3760417]

  • How to get the name of a Data Element of a generic Table!

    Hi guys!
    In my function i have the following import paramenter
    i_outtab type standard table
    now i import a table and i want to get the dataelement of the fields.
    is there a way to do this??

    Hello Thomas
    Perhaps the following sample report may be useful for you.
    *& Report  ZUS_SDN_RTTI_STRUCT_COMPONENTS
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1145711"></a>
    *& Thread: How to get the name of a Data Element of a generic Table!
    REPORT  zus_sdn_rtti_struct_components.
    TYPE-POOLS: abap.
    TYPES: BEGIN OF ty_s_outtab.
    TYPES: bukrs    TYPE bukrs.
    TYPES: kunnr    TYPE kunnr.
    TYPES: END OF ty_s_outtab.
    DATA: gdo_data    TYPE REF TO data.
    DATA: gs_outtab   TYPE ty_s_outtab.
    DATA: go_typedescr  TYPE REF TO cl_abap_typedescr,
          go_structdescr  TYPE REF TO cl_abap_structdescr,
          go_datadescr    type ref to cl_abap_datadescr.
    DATA: gs_comp        TYPE abap_compdescr,
          gd_dtel        type string,
          gt_dfies        type ddfields.
    FIELD-SYMBOLS:
      <gs_struct> TYPE ANY.
    START-OF-SELECTION.
      BREAK-POINT.
      GET REFERENCE OF gs_outtab INTO gdo_data.
      ASSIGN gdo_data->* TO <gs_struct>.
      go_typedescr = cl_abap_typedescr=>describe_by_data( <gs_struct> ).
      go_structdescr ?= go_typedescr.
      BREAK-POINT.
      LOOP AT go_structdescr->components INTO gs_comp.
        go_datadescr = GO_STRUCTDESCR->GET_COMPONENT_TYPE( gs_comp-name ).
        gd_dtel = go_datadescr->get_relative_name( ).
        write: / syst-tabix, 'Data element =', gd_dtel.
      ENDLOOP.
    END-OF-SELECTION.
    Regards
      Uwe

  • How to get "double click" as an event in Module Pool

    Dear Experts,
    Being new to ABAp, I am struck in a problem.
    I want to get double click as an event in my module pool program.
    On the screen I have two input/output fields. The attributes of them are as below:
    1) 1st I/O field Attributes:
    Name: WA_AUFN-A
    Dropdown: List box
    Display: Resp. to DblClk = Checked
    1) 2nd  I/O field Attributes:
    Name: IT_AUF-A
    Dropdown: No drop down box
    Display: Resp. to DblClk = UN- Checked
    I get some data populated in 1st I/O field in list display.
    My Requirement:
    As I select one of the data from the 1st I/O field and double click on it, then what I want is that the same selected data
    should appear in the 2nd I/O field.
    So I want to know how can I capture "Double click as an event".
    Can any1 help me out.
    Regards
    Chandan

    Hi Chandan,
    below is the explanation.
    for example if u have 2 screen fields VBAK-VBELN & VBAK-VKORG.
    VBAK-VBELN has some value say 1000. based on this one u have to fill VBAK_VKORG.
    Data: l_f_field like HELP_INFO-DYNPROFLD,
            l_f_value like vbak-vbeln.
    case pick.
    GET CURSOR FIELD l_f_field.
    with this u will get to know on which field user is double clicked. so, in this case l_f_filed will have a value of VBAK-VBELN
    if l_f_field = ''VABK-VBELN' and
      l_f_value = '1000'. "this is optional, based on ur requirement
    VBAK-VKORG = '0780'. "fill here
    endif.
    endcase.
    Let me know if it is not clear.
    Regards,
    Prasad

  • How to get selectall/deselectall event

    Dear  Experts,
    How to get event, tableview selectall/dselect all event..
    i need to write some logic when we choose selectall on tableview control.
    so how can i find selectall event
    your cooperation will be highly appreciated.
    sincerely

    Hi Ganesh,
    This is indeed simple....
    Provide two buttons on screen for the same.....and then put the following code in onInputProcessing....
      DATA: event       TYPE REF TO   IF_HTMLB_DATA.
      event = cl_htmlb_manager=>get_event( request ).
      IF event IS NOT INITIAL .
        IF event->EVENT_NAME = 'button' and event->EVENT_TYPE = 'click'.
          but_event ?= event.
          CASE event->EVENT_ID.
            when 'SelectAll'.
              cl_htmlb_manager=>check_tableview_all_rows( rowcount = 10
                            request = request
                            id = 'Table_view_Id'
                            check = 'X' ).
            when 'DeSelectAll'.
              cl_htmlb_manager=>check_tableview_all_rows( rowcount = 10
                              request = request
                              id = 'TV1'
                              check = '' ).
    Also there is a small advise....before posting the question, please take some effort to search through the forum, as many issues have already been resolved...
    Hope this helps.
    <b><i>Do reward each useful answer..!</i></b>
    Thanks,
    Tatvagna.

  • How to get the cancel event of inlineDocument-style dialog.

    Hi experts,
    My customer has a question about ADF dialog framework.
    When we open new inlineDocument-style dialog from af:commandButtton, how can we get dialog cancel event?
    [Sample code]
    <af:commandButton id="cb2" action="dialog:test"
    windowModalityType="modeless"
    text="dialog:test" windowHeight="500"
    windowWidth="800"
    windowEmbedStyle="inlineDocument"
    useWindow="true"/>
    When we use af:popup, it has popupCanceledlListener attribute so that we can handle the situation where users click close button or Esc button.
    Does dialog have a similar feature?
    We can set a returnListener for dialog, but it doesn't work in case users click close button.
    Regards,
    Atsushi

    is this what you are looking for [url http://www.oracle.com/technetwork/developer-tools/adf/learnmore/77-ok-cancel-support-in-dialog-351871.pdf]Handling the af:dialog Ok and CANCEL buttons
    and [url https://blogs.oracle.com/jdevotnharvest/entry/strategies_for_controlling_the_af]Strategies for controlling the af:popup close event
    Edited by: Mohammad Jabr on Apr 27, 2012 11:34 AM

  • How to get the Clicked Item of a ListBox?

    I need to get the clicked item of a listbox.
    The item can be at first selected, when I click it again, it
    automatically gets de-selected, but I want to get that item
    whenever I click it. Any idea how to do this?
    This line does not work, because it gets the selected item.
    var pattern:String = event.currentTarget.selectedItem.myname;
    This one must work,but something is missing.
    Anyone can help me with this?
    marks is my ArrayCollection;
    var pattern:String =marks.getItemAt[??].myname;

    Here is my code. Am using this function in the itemclick
    event of the ListBox.
    My ListBox is a multi-select listbox. So am selecting several
    items by pressing "Ctrl" key and selecting each item using click.
    Say I have selected 4 items, when I press "Ctrl" and
    de-select one of the items, I want to get the itemname of the
    deselected item.
    public function createMarksList(event:ListEvent):void{
    // Alert.show(new
    String(event.currentTarget.selectedItem.myname));
    // var pattern:String =
    event.currentTarget.selectedItem.myname;
    // pattern = pattern += "," + pattern;
    // text1.text = pattern;
    <mx:List x="9" y="46" width="121" height="121"
    id="lstMarks" allowMultipleSelection="true"
    itemClick="createMarksList(event)"></mx:List>
    So, your help is required here buddy.
    I sitll can't figure out.
    Thx

  • How to get the table Event action in the controller???

    HI
    Based on my requirement i have extended my controller,but i want to perform some validation like ,,,,
    i have table in one region ,in which one column is having a Button (flex field) action with image,
    i want to write the code in the controller according to the validation ,,,,but i am unable to find the event action in the main controller,
    how to get the event action ?,,,,, of the item type as image
    thanks in advance
    Kash

    If not you can use image component with clientListener and serverListener to preform your requirement set clientListener click event and then inside clientListener java script method call the
    serverListener then will execute serverListener method.

  • How to get "Double-click to edit" behavior in fields added to Master slides

    Hi! I edited a master slide to add a box of Placeholder Text. Now the word "Text" appears whenever I make a new slide (child of the master), which is fine. But if I don't change the text on a particular slide, the word "Text" shows up there when I run the slideshow. This is different from the behavior of the Apple-defined placeholder text, where the phrase "Double-click to edit" does NOT appear when you run the slideshow.
    I've searched the help files and tried various Inspector settings, but cannot seem to get this wonderful timesaving feature working for my own Master Slide fields. Is it possible?

    I was just looking for a solution to this... how timely! The closest I found to being able to have an "apple-defined placeholder" is by following all your steps (editing master, making new text box), but then doing the following:
    1) select the text box
    2) go to the "Format">"Advanced" menu and select "Define as Text Placeholder."
    This isn't the same, since the text will always show up on the slides (as opposed to only showing up if YOU wrote something in the box... you can delete it if you want, but its not the same as apple's default), but it does have the functionality you want. I hope this helps you!
    EDITED TO ADD:
    ...aaaand the age-old trick of reading the manual works again. Go to page 188 of the linked document and you'll see that there's a different way to do it. In short:
    1) Make a text box in a master slide, keep it selected.
    2) In the Inspector, go to "slide inspector" (second from right), and select the "appearance" tab.
    3) Check the checkbox next to "Define as Text Placeholder." Assign it a tag.
    For me, I found that once I did this, I could delete the text inside the textbox and it wouldn't automatically be deleted. I assume that assigning it a tag has something to do with that. I still don't know how to get text to automatically show up in the textbox... that seems to be a special functionality reserved for the apple-defined boxes. Again, I hope this helps!
    Message was edited by: Eliezer Kanal

  • How to handle mouse click event on up-arrow of JSpinner?

    Hi Everybody,
    I have a JSpinner component holding a date field in it (dd/mm/yyyy). I have handeled keyboard up and down arrow key events for the component and that's working as expected. Now I want to make it work for mouse clicks on the up (UP_ARROW_SUBCOMPONENT) and down arrow (DOWN_ARROW_SUBCOMPONENT) buttons of the component.
    Could somebody guide me how to do it? My investigatoin hints me to use JSpinnerMouseEventData but I am not exactly getting how to get it done.
    Thanks in advance!

    if you just want to add a mouseListener to the spinner's buttons, try this
    (only coded it for the up/next button)
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Testing
      public void buildGUI()
        JSpinner spinner = new JSpinner(new SpinnerNumberModel(50, 0, 100, 5));
        spinner.setUI(new javax.swing.plaf.basic.BasicSpinnerUI(){
          protected Component createNextButton()
            Component c = super.createNextButton();
            c.addMouseListener(new MouseAdapter(){
              public void mousePressed(MouseEvent me){
                System.out.println("mousie, going up");
            return c;
        JFrame f = new JFrame();
        f.getContentPane().add(spinner);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
      public static void main(String[] args)
        SwingUtilities.invokeLater(new Runnable(){
          public void run(){
            new Testing().buildGUI();
    }

Maybe you are looking for

  • How to delete the duplicate copy in version management?

    Hi, I have reverted the previous version. it is getting back the version on my user id. but i selected the active version again and clicking on RETRIVE button..now it is creating another duplication version. so i want to delete that one. anybody can

  • How can I sync a .mov file of a home-made video?

    How can I sync a .mov file of a home-made video?

  • Terrible service in my neighborhood... what can be done?

    For whatever reason, my entire neighborhood is in a dead zone... almost anywhere you walk outside only gets ~2 bars.  I contacted Verizon to see if something could be done... and the representative said they would send someone out to confirm the issu

  • Automate FI (OB52)/CO(OKP1) posting period

    Hi, We would like to automate the FI & CO period opening procedure by batch process.  Iu2019ve two Qs; 1) OB52: The standard programs RFPERIOD_OPEN and RFPERIOD_CLOSE do not have dynamic date selection option while creating variant. 2)OKP1 : There is

  • Dimension relationship

    Hi, Is there a way to define relationships in 2 BPC dimensions or any other work arround to achive below requirement? Let say I have 2 dimensions (Facility and Products) One product can exisit in multiple facilities, how can I link products to facili