.. versionchanged:: 0.9
            Update device registration in real-time while dragging video
            control point to new position.

        .. versionchanged:: 0.12
            Add ``dynamic_electrode_state_shapes`` layer to show dynamic
            electrode actuations.

def create_ui(self):
        '''
        .. versionchanged:: 0.9
            Update device registration in real-time while dragging video
            control point to new position.

        .. versionchanged:: 0.12
            Add ``dynamic_electrode_state_shapes`` layer to show dynamic
            electrode actuations.
        '''
        super(DmfDeviceCanvas, self).create_ui()
        self.video_sink = VideoSink(*[self.socket_info[k]
                                      for k in ['transport', 'host', 'port']])
        # Initialize video sink socket.
        self.video_sink.reset()
        # Required to have key-press and key-release events trigger.
        self.widget.set_flags(gtk.CAN_FOCUS)
        self.widget.add_events(gtk.gdk.KEY_PRESS_MASK |
                               gtk.gdk.KEY_RELEASE_MASK)
        # Create initial (empty) cairo surfaces.
        surface_names = ('background', 'shapes', 'connections', 'routes',
                         'channel_labels', 'static_electrode_state_shapes',
                         'dynamic_electrode_state_shapes', 'registration')
        self.df_surfaces = pd.DataFrame([[self.get_surface(), 1.]
                                         for i in xrange(len(surface_names))],
                                        columns=['surface', 'alpha'],
                                        index=pd.Index(surface_names,
                                                       name='name'))

        def _update_registration(event):
            try:
                start_event = self.start_event.copy()
                self.start_event = event.copy()
                self.emit('point-pair-selected', {'start_event': start_event,
                                                  'end_event': event})
            except AttributeError:
                # Mouse button was released, causing `self.start_event` to be
                # `None` before event was handled here.
                pass

        # Debounce calls to `_update_registration` function to prevent too many
        # calls being triggered from mouse movement events.
        update_registration = debounce.Debounce(_update_registration, wait=10)

        def _on_mouse_move(area, event):
            # XXX Need to make a copy of the event here since the original
            # event will be deallocated before the debounced
            # `update_registration` function is called.
            event = event.copy()

            if self.mode == 'register_video' and self.start_event is not None:
                update_registration(event.copy())

        # Connect video registration update event to mouse movement event.
        self.widget.connect("motion_notify_event", _on_mouse_move)