-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClass1.cs
50 lines (46 loc) · 1.66 KB
/
Class1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using ABB.Robotics.Math;
using ABB.Robotics.RobotStudio;
using ABB.Robotics.RobotStudio.Environment;
using ABB.Robotics.RobotStudio.Stations;
using ABB.Robotics.RobotStudio.Stations.Forms;
using RobotStudio.API.Internal;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
namespace TwRobotstudioDclickCenter
{
public class Class1
{
// This is the entry point which will be called when the Add-in is loaded
public static void AddinMain()
{
Logger.AddMessage(new LogMessage("TW Robotstudio Doubleclick to center loaded."));
GraphicPicker.GraphicPick += GraphicPicker_GraphicPick;
}
static long LastClick = 0;
static ProjectObject lastPickedObject;
private static void GraphicPicker_GraphicPick(object sender, GraphicPickEventArgs e)
{
try
{
if (DateTime.Now.Ticks - LastClick < TimeSpan.TicksPerMillisecond * 200)
{
if (e.PickedObject == lastPickedObject)
{
if (sender is ABB.Robotics.RobotStudio.Stations.Forms.GraphicPicker gp)
{
GraphicControl.ActiveGraphicControl.ViewCenter(e.PickedPosition, (float)0.1);
}
}
}
lastPickedObject = e.PickedObject;
LastClick = DateTime.Now.Ticks;
}
catch (Exception ex)
{
Logger.AddMessage(new LogMessage("TW Robotstudio Doubleclick: " + ex.ToString(),LogMessageSeverity.Error));
}
}
}
}