Esempio n. 1
0
 /// <summary>
 /// Gets the Items image for drag and drop.
 /// </summary>
 /// <returns>an bitmap rendering of the rule item</returns>
 public static Image getItemImage(Type ruleItem)
 {
     ConstructorInfo constr = ruleItem.GetConstructor(new Type[0]);
     ruleItemBase newRuleItem = (ruleItemBase)constr.Invoke(new object[0] { });
     newRuleItem.initPins();
     ctlRuleItemWidget widget = new ctlRuleItemWidget(newRuleItem, @this => { });
     Bitmap image = new Bitmap(widget.Width, widget.Height);
     widget.DrawToBitmap(image, new Rectangle(0, 0, widget.Width, widget.Height));
     return image;
 }
Esempio n. 2
0
        /// <summary>
        /// Make rule item controls for every rule item present in our rule.
        /// </summary>
        private void addRuleItemControlsAfterDeserialisation()
        {
            this.Parent.Width = this._rule.preferredWidth;
            this.Parent.Height = this._rule.preferredHeight;
            IEnumerable<IRuleItem> childRuleItems = this._rule.getRuleItems();

            foreach (ruleItemBase thisRule in childRuleItems)
            {
                ctlRuleItemWidget newCtl = new ctlRuleItemWidget(thisRule, this.setTsStatus);

                //hook up line events for deserialized control.
                foreach (var pin in newCtl.conPins.Keys.Where(p => p.isConnected))
                {
                    lineChain line = this._rule.GetLineChainFromGuid(pin.parentLineChain);
                    newCtl.OnRuleItemMoved += line.LineMoved;
                    line.onLineDeleted += pin.Disconnected;
                }
               // this._rule.AddctlRuleItemWidgetToGlobalPool(newCtl);
                newCtl.snapToGrid = this.snapWidgetsToGrid;
                this.Controls.Add(newCtl);
                newCtl.BringToFront();
                this.itemWidgets.Add(newCtl);
                if (this.onRuleItemLoaded != null)
                    this.onRuleItemLoaded.Invoke(thisRule);
            }
        }
Esempio n. 3
0
        public void addRuleItem(ruleItemInfo info, int x, int y)
        {
            // Create our rule item
            ruleItemBase newRuleItem = this._rule.addRuleItem(info);

            // add a visual widget for it, and then add it to the visible controls
            ctlRuleItemWidget newCtl = new ctlRuleItemWidget(newRuleItem, this.setTsStatus);
            newCtl.Location = new Point(x, y);
               //     this._rule.AddctlRuleItemWidgetToGlobalPool(newCtl);
            newCtl.snapToGrid = this.snapWidgetsToGrid;
            this.Controls.Add(newCtl);
            newCtl.BringToFront();
            this.itemWidgets.Add(newCtl);
        }
Esempio n. 4
0
        public void deleteRuleItem(ctlRuleItemWidget toDelete)
        {
            this._rule.deleteRuleItem(toDelete.targetRuleItem);

            // remove the associated ctlRuleItem
               // this._rule.deleteCtlRuleItem(toDelete);

            // remove the actual control
            this.Controls.Remove(toDelete);
            this.Invalidate();
        }