示例#1
0
        /// <summary>
        /// Gets the tree roots.
        /// </summary>
        /// <returns>List of roots</returns>
        /// <param name="cls">Project details</param>
        private List<TreeNode> GetTreeRoots(UMLClass cls)
        {
            // Map every class node.
            // Namespace - Treenode
            foreach(var cnode in cls.ClassNodes){
                TreeNode tn = new TreeNode(cnode.Namespace);
                tn.Node = cnode;
                TreeNodes.Add(tn);
                if(!map.ContainsKey(tn.Name))
                    map.Add(tn.Name,tn);
            }

            //Create all parent child links
            foreach(var cnode in cls.ClassNodes)
            {
                foreach(var parent in cnode.Links)
                {
                    var parentnode = GetTreeNode(parent);
                    var childnode = GetTreeNode(cnode.Namespace);

                    if(parentnode == null){
                        //If inherits class outside project
                        continue;
                    }
                    parentnode.AddChild(childnode);
                    childnode.Parent = parentnode;
                }
            }

            //At this point, we have a forest. Every tree in the
            //forest wil be drawn separately

            List<TreeNode> Roots = new List<TreeNode>();
            // Add all roots to a list
            foreach(TreeNode tn in TreeNodes)
            {
                var temp = tn;
                while(temp.Parent !=null){
                    temp = temp.Parent;
                }
                if(!Roots.Contains(temp))
                {
                    Roots.Add(temp);
                }
            }
            return Roots;
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AComConfigDialog"/> class.
        /// </summary>
        /// <param name="pins">Pins.</param>
        /// <param name="signal">Signal.</param>
        /// <param name="pin">Pin.</param>
        /// <param name="parent">Parent.</param>
        /// <param name="units">Units.</param>
        public AComConfigDialog(APin[] pins, MeasurementCombination signal = null, APin pin = null, Gtk.Window parent = null, List<string> units = null)
            : base("Analog Inputs Combinations - Dialog", parent, Gtk.DialogFlags.Modal, new object[0])
        {
            this.Build ();

            sbMeanValuesCount.Adjustment.Upper = int.MaxValue;
            sbMeanValuesCount.Adjustment.Lower = 1;

            APins = pins;

            cbColor.Color = GUIHelper.ColorHelper.GetRandomGdkColor ();

            if (signal == null) {
                Combination_ = new MeasurementCombination ();
                Combination_.Color = cbColor.Color;
            } else {
                Combination = signal;
                if (!string.IsNullOrEmpty (Combination.OperationString)) {
                    CompileOperation ();
                } else {
                    SetWarning ();
                }
                buttonOk.Label = "Apply";
            }

            if (pin != null) {
                Combination_.AddPin (pin);
                Combination_.Unit = Combination_.Pins [0].Unit;
            }

            SetupNodeView ();
            DrawNodeView ();
            UpdateCBPins ();
            SetApplyButton ();

            entryOperation.Activated += (sender, e) => {
                if (!CompileTimer.Enabled) {
                    CompileTimer.Start ();
                }
            };
            entryOperation.FocusInEvent += (sender, e) => {
                if (!CompileTimer.Enabled) {
                    CompileTimer.Start ();
                }
            };

            CompileTimer.Elapsed += CompileTimerElapsed;

            Units = units;
            ListStore store = new ListStore (typeof(string));
            Units.ForEach (o => store.AppendValues (new object[]{ o }));
            cbeUnit.Model = store;
            if (!string.IsNullOrEmpty (Combination_.Unit)) {
                if (Units.Contains (Combination_.Unit)) {
                    cbeUnit.Active = Array.IndexOf (Units.ToArray (), Combination_.Unit);
                } else {
                    store.AppendValues (new string[]{ Combination_.Unit });
                    cbeUnit.Active = Units.Count;
                }
            }
        }