Example #1
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     if (Capture)
     {
         var pos = ClientToLogicalPosition(e.Location);
         if (dragging)
         {
             cursorPos = anchorPos = pos;
             var span = GetSpan(e.Location);
             if (span != null && span.Tag != null)
             {
                 Navigate.Fire(this, new EditorNavigationArgs(span.Tag));
             }
             Invalidate();
         }
         else
         {
             if (IsSelectionEmpty())
             {
                 var span = GetSpan(e.Location);
                 if (span != null && span.Tag != null)
                 {
                     Navigate.Fire(this, new EditorNavigationArgs(span.Tag));
                 }
             }
             SelectionChanged.Fire(this);
         }
         Capture = false;
     }
     base.OnMouseUp(e);
 }
        /// <summary>
        /// Default ctor
        /// </summary>
        protected ModuleItem(IModuleRef moduleRef, IModule module, bool contentsEditable, ItemContext context)
        {
            this.moduleRef = moduleRef;
            this.context   = context;
            this.module    = module;
            LayoutManager  = new StackLayoutManager {
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Padding             = new Padding(0)
            };

            // Build positioned entities layer
            positionedEntities = new PositionedItemContainer();
            positionedEntities.SelectedItems.Changed += (s, _) => SelectionChanged.Fire(this);
            if (contentsEditable)
            {
                var selectHandler = new ItemSelectMouseHandler(positionedEntities, positionedEntities.MouseHandler);
                var moveHandler   = new ItemMoveMouseHandler(positionedEntities, selectHandler);
                var resizeHandler = new ItemResizeMouseHandler(positionedEntities, moveHandler);
                positionedEntities.MouseHandler = resizeHandler;
            }
            Items.Add(positionedEntities, new LayoutConstraints(FillDirection.Both));

            // Build background
            ReloadBackgroundImage();
        }
        /// <summary>
        /// Default ctor
        /// </summary>
        public RailwayEditItem(IRailway railway, ItemContext context)
            : base(railway, context)
        {
            modulesLayer = new PositionedItemContainer();
            modulesLayer.SelectedItems.Changed += (s, _) => SelectionChanged.Fire(this);

            var selectHandler = new ItemSelectMouseHandler(modulesLayer, modulesLayer.MouseHandler);
            var moveHandler   = new ItemMoveMouseHandler(modulesLayer, selectHandler);

            modulesLayer.MouseHandler = moveHandler;

            Items.Add(modulesLayer, new LayoutConstraints(FillDirection.Both));

            AddModules(railway, modulesLayer);
        }
Example #4
0
 /// <summary>
 /// Selection has changed
 /// </summary>
 private void LbModulesSelectedIndexChanged(object sender, EventArgs e)
 {
     UpdateUI();
     SelectionChanged.Fire(this);
 }
Example #5
0
 /// <summary>
 /// Selected item has changed.
 /// </summary>
 private void OnModuleSelectionChanged(object sender, EventArgs e)
 {
     SelectionChanged.Fire(this);
 }
Example #6
0
 /// <summary>
 /// Pass the selected item to the control panel
 /// </summary>
 private void UpdateSelection()
 {
     SelectionChanged.Fire(this);
 }