コード例 #1
0
ファイル: frmRuleEdit.cs プロジェクト: randomdude/Lavalamp
        private void addRuleItemObjectToToolbox(ruleItemBase newRuleItem, ruleItemInfo itemInfo)
        {
            TreeNode newTreeItem = new TreeNode((newRuleItem).ruleName()) { Tag = itemInfo };

            // check if rule item is already added.
            // TODO Strong names
            foreach(TreeNode n in tvToolbox.Nodes)
            {
                if (n.Text == (newRuleItem).ruleName())
                    return;
                foreach (TreeNode child in n.Nodes)
                {
                    if (child.Text == (newRuleItem).ruleName())
                        return;
                }

            }

            string catName;
            if (itemInfo.itemType == ruleItemType.RuleItem && itemInfo.ruleItemBaseType.IsDefined(typeof(ToolboxRuleCategoryAttribute), false))
            {
                Object[] attrs = itemInfo.ruleItemBaseType.GetCustomAttributes(typeof(ToolboxRuleCategoryAttribute), false);
                catName = ((ToolboxRuleCategoryAttribute) attrs[0]).name;
            }
            else
            {
                catName = "";
            }
            if (itemInfo.itemType == ruleItemType.scriptFile)
                catName = itemInfo.pythonCategory;

            if (catName != "")
            {
                bool foundIt = false;
                foreach (TreeNode cat in this.tvToolbox.Nodes)
                {
                    if (cat.Text == catName)
                    {
                        cat.Nodes.Add(newTreeItem);
                        foundIt = true;
                        break;
                    }
                }
                if (!foundIt)
                {
                    TreeNode daddy = new TreeNode(catName);
                    daddy.Nodes.Add(newTreeItem);
                    this.tvToolbox.Nodes.Add(daddy);
                }
            }
            else
            {
                this.tvToolbox.Nodes.Add(newTreeItem);
            }
        }
コード例 #2
0
ファイル: frmDebug.cs プロジェクト: randomdude/Lavalamp
        public frmDebug(ruleItemBase debugThis)
        {
            this.InitializeComponent();

            if (debugThis.serial == null)
                this.lblDebugInfo.Text += "ID is null!" + Environment.NewLine;
            else
                this.lblDebugInfo.Text += "ID = " + debugThis.serial.ToString() + Environment.NewLine;

            lblDebugInfo.Text += "pins: " + Environment.NewLine;
            int i = 1;
            foreach (var entry in debugThis.pinInfo)
            {
                var pin = entry.Value;
                lblDebugInfo.Text += string.Format("{0} {5}: {1},{4}{6}description, {2}{4}{6}data-type, {3}{4}{6}current value, {7}{4}",
                    pin.direction, entry.Key, pin.description, pin.valueType, Environment.NewLine,i++,"       ",pin.value.data);
            }
        }
コード例 #3
0
        public ctlRuleItemWidget(ruleItemBase newRuleItemBase, ctlRule.setTsStatusDlg newSetToolbarText)
        {
            this.setToolbarText = newSetToolbarText;

            this.commonConstructorStuff();
            this.loadRuleItem(newRuleItemBase);
            try
            {
                this.ContextMenuStrip = newRuleItemBase.addMenus(this.contextMenuStrip1);
            }
            catch (NotImplementedException)
            {
                // Fair enough, it has no menus to add.
            }

            // this probably should be done in addMenus on the base class but the code to openOptions isn't there so to avoid repeating code its here
            var opt = newRuleItemBase.ruleItemOptions();
            if (opt != null)
            {
                this.ContextMenuStrip.Items.Add(new ToolStripSeparator());
                this.ContextMenuStrip.Items.Add(new ToolStripMenuItem(opt.displayName,null,this.openOptions));
            }
        }
コード例 #4
0
ファイル: pinDataTrigger.cs プロジェクト: randomdude/Lavalamp
 public pinDataTrigger(ruleItemBase parentRuleItem, pin newParentPin)
     : base(parentRuleItem, newParentPin)
 {
 }
コード例 #5
0
ファイル: pinDataTrigger.cs プロジェクト: randomdude/Lavalamp
 public pinDataTrigger(bool initalVal, ruleItemBase parentRuleItem, pin newParentPin)
     : base(initalVal, parentRuleItem, newParentPin)
 {
 }
コード例 #6
0
        private void loadRuleItem(ruleItemBase newRuleItem)
        {
            this.targetRuleItem = newRuleItem;

            // Load up input/output pin icons
            this.conPins.Clear();
            foreach (pin thisPin in this.targetRuleItem.pinInfo.Values)
            {
                this.addIcon(thisPin);

                // Note down pin as belonging to this ruleItem.
                thisPin.parentRuleItem = this.targetRuleItem.serial;
            }

            this.Location = newRuleItem.location;
            this.Size = newRuleItem.preferredSize();

            // wire up events
            foreach (PictureBox thisCtl in this.conPins.Values)
                thisCtl.Click += new EventHandler(this.onPinClick);

            this.addEvents(newRuleItem.controls);

            // Load any controls that the item wants
            foreach (Control thisCtl in newRuleItem.controls)
            {
                if (thisCtl.GetType() == typeof(ContextMenuStrip))
                {
                    while (((ContextMenuStrip)thisCtl).Items.Count > 0 )
                        this.contextMenuStrip1.Items.Add(((ContextMenuStrip)thisCtl).Items[0]);
                }
                else
                {
                    this.Controls.Add(thisCtl);
                }
            }

            newRuleItem.onResize(this);
            this.ruleItemBaseForm_Resize(new object(), new EventArgs());
        }
コード例 #7
0
        public void ReadXml(XmlReader reader)
        {
            bool keepGoing = true;
            while (keepGoing)
            {
                if (reader.Name == "ruleItems" && reader.NodeType == XmlNodeType.EndElement)
                    keepGoing = false;

                if (reader.Name == "ctlRuleItemWidget")
                {
                    String targetRuleItemTypeString = reader.GetAttribute("type");
                    // todo: reduce code duplication between this and ruleEditor
                    Assembly myAss = Assembly.GetExecutingAssembly();
                    Type targetRuleItemType;
                    try
                    {
                        // Pull type out of myAss
                        targetRuleItemType = myAss.GetType(targetRuleItemTypeString);
                    }
                    catch (ArgumentException)
                    {
                        // todo: prompt user for location
                        throw new Exception("Unable to load ruleItem of type " + targetRuleItemTypeString);
                    }

                    ConstructorInfo targetRuleItemConstructorInfo =
                        targetRuleItemType.GetConstructor(new Type[0]);
                    this.targetRuleItem = (ruleItemBase) targetRuleItemConstructorInfo.Invoke(new Object[0]);
                }
                if (keepGoing)
                    keepGoing = reader.Read();
            }
        }
コード例 #8
0
ファイル: rule.cs プロジェクト: randomdude/Lavalamp
 /// <summary>
 /// Make a new timeline event in the future
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <param name="timebeforeevent">Deltas until event should fire</param>
 private void serviceNewTimelineEventInFuture(ruleItemBase sender, timelineEventArgs e, int timebeforeevent)
 {
     _timeline.addEventAtDelta(e, timebeforeevent);
 }
コード例 #9
0
ファイル: rule.cs プロジェクト: randomdude/Lavalamp
 /// <summary>
 /// Make a new timeline event at the next delta
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void serviceNewTimelineEvent(ruleItemBase sender, timelineEventArgs e)
 {
     _timeline.addEventAtNextDelta(e);
 }
コード例 #10
0
ファイル: rule.cs プロジェクト: randomdude/Lavalamp
        public void deleteRuleItem(ruleItemBase toDelete)
        {
            // Remove any lineChains attatched to the to-delete item
            foreach (pin thisPin in toDelete.pinInfo.Values)
            {
                if (thisPin.isConnected)
                {
                    lineChain tonuke = GetLineChainFromGuid(thisPin.parentLineChain);
                    tonuke.requestDelete();
                }
            }

            // mark as deleted.
            toDelete.isDeleted = true;
            //actually remove the item from the list.
            ruleItems.Remove(toDelete.serial.ToString());
        }
コード例 #11
0
ファイル: rule.cs プロジェクト: randomdude/Lavalamp
 public void AddRuleItemToGlobalPool(ruleItemBase addThis)
 {
     addThis.newTimelineEvent += serviceNewTimelineEvent;
     addThis.newTimelineEventInFuture += serviceNewTimelineEventInFuture;
     ruleItems.Add(addThis.serial.id.ToString(), addThis);
 }
コード例 #12
0
ファイル: pin.cs プロジェクト: randomdude/Lavalamp
        public void createValue(ruleItems.ruleItemBase parentRuleItem)
        {
            // Set the .value of our pin to an object of type according to .valueType.
            // Call the appropriate constructor, finding it via reflection.
            // We pass the constructor the parent ruleItemBase, and the parent pin.

            // Find the constructor
            ConstructorInfo pinValueTypeConstructor = valueType.GetConstructor(new Type[] { typeof(ruleItems.ruleItemBase), typeof(pin) });

            // Call the constructor, storing the new object.
            value = (IPinData) pinValueTypeConstructor.Invoke(new object[] {parentRuleItem, this});
            parent = parentRuleItem;
        }
コード例 #13
0
ファイル: frmRuleEdit.cs プロジェクト: randomdude/Lavalamp
 private void loadAssemblyForRuleItem(ruleItemBase item)
 {
     if (item.GetType().Assembly.FullName != Assembly.GetExecutingAssembly().FullName)
     {
         this.populateToolboxFromAssembly(Assembly.Load(item.GetType().Assembly.FullName));
         this.tvToolbox.Refresh();
     }
 }