Esempio n. 1
0
 private static void SetDepthSelectorState(FidelitySelectionRules.SelectionRule selector, Button depthSelector)
 {
     depthSelector.BackgroundImage = selector.lowest ?
                                     global::CyPhyComponentFidelitySelector.Properties.Resources.tiny_tree_leaf :
                                     global::CyPhyComponentFidelitySelector.Properties.Resources.tiny_tree_root;
 }
Esempio n. 2
0
        private void addXPath(Panel parent, FidelitySelectionRules.SelectionRule selector)
        {
            var xpathPanel   = new System.Windows.Forms.Panel();
            var delButton    = new Button();
            var upButton     = new Button();
            var downButton   = new Button();
            var xpathTextBox = new TextBox();

            xpathPanel.Controls.Add(delButton);
            xpathPanel.Controls.Add(upButton);
            xpathPanel.Controls.Add(downButton);
            xpathPanel.Controls.Add(xpathTextBox);

            xpathPanel.Location = new System.Drawing.Point(0, 10 + 25 * parent.Controls.Count - parent.VerticalScroll.Value);
            xpathPanel.Size     = new System.Drawing.Size(parent.Size.Width - 17 /*leave room for scrollbar*/, 25);
            xpathPanel.Name     = "xpathPanel" + parent.Controls.Count;
            xpathPanel.Tag      = selector;

            delButton.Image    = global::CyPhyComponentFidelitySelector.Properties.Resources.ic_close_black_18dp;
            delButton.Location = new System.Drawing.Point(1, 1);
            delButton.Name     = xpathPanel.Name + delButtonName;
            delButton.UseVisualStyleBackColor = true;
            delButton.Size = new System.Drawing.Size(22, 23);
            delButton.UseVisualStyleBackColor = true;
            delButton.TabStop = false;
            delButton.Click  += DelButton_Click;

            upButton.Image    = global::CyPhyComponentFidelitySelector.Properties.Resources.ic_expand_less_black_18dp;
            upButton.Location = new System.Drawing.Point(delButton.Location.X + delButton.Width + 2, 1);
            upButton.Name     = xpathPanel.Name + upButtonName;
            upButton.UseVisualStyleBackColor = true;
            upButton.Size = new System.Drawing.Size(22, 23);
            upButton.UseVisualStyleBackColor = true;
            upButton.TabStop = false;
            upButton.Click  += UpButton_Click;

            downButton.Image    = global::CyPhyComponentFidelitySelector.Properties.Resources.ic_expand_more_black_18dp;
            downButton.Location = new System.Drawing.Point(upButton.Location.X + upButton.Width + 2, 1);
            downButton.Name     = xpathPanel.Name + downButtonName;
            downButton.UseVisualStyleBackColor = true;
            downButton.Size = new System.Drawing.Size(22, 23);
            downButton.UseVisualStyleBackColor = true;
            downButton.TabStop = false;
            downButton.Click  += DownButton_Click;

            xpathTextBox.Location     = new System.Drawing.Point(downButton.Location.X + downButton.Width + 2, 2);
            xpathTextBox.Name         = xpathPanel.Name + "_xpathBox";
            xpathTextBox.Size         = new System.Drawing.Size(433, 22);
            xpathTextBox.Text         = selector.xpath;
            xpathTextBox.TextChanged += XpathTextBox_TextChanged;
            var source = new AutoCompleteStringCollection();

            source.AddRange(new string[]
            {
                // TODO: generate this list based on a suggested set of queries and the current state of the text box.
                "//*/Component/SpiceModel",
                // "//*/SpiceModel[@Fidelity>1]",
                "//*/SpiceModel[@Name='SPICEModel']",
                "/*/*/*/SpiceModel",
                "//SpiceModel[count(ancestor::*) < 2]",
                "//*/Component[contains(@Classifications, 'resistor')]/SpiceModel",
                "//*[@Name]='GMEName'/SpiceModel",
                "//ComponentAssembly[./*[@Name='ChildGMEName']]/SpiceModel",
            });
            xpathTextBox.AutoCompleteCustomSource = source;
            xpathTextBox.AutoCompleteMode         = AutoCompleteMode.Suggest;
            xpathTextBox.AutoCompleteSource       = AutoCompleteSource.CustomSource;

            var depthSelector = new Button();

            xpathPanel.Controls.Add(depthSelector);
            SetDepthSelectorState(selector, depthSelector);
            depthSelector.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
            depthSelector.Location = new System.Drawing.Point(xpathTextBox.Location.X + xpathTextBox.Width + 2, 1);
            xpathTextBox.Name      = xpathPanel.Name + "_depthSelector";
            depthSelector.Size     = new System.Drawing.Size(34, 23);
            depthSelector.UseVisualStyleBackColor = true;
            depthSelector.TabStop = false;
            depthSelector.Click  += DepthSelector_Click;

            xpathPanel.TabIndex = parent.Controls.Count;
            parent.Controls.Add(xpathPanel);
        }