Exemplo n.º 1
0
        private void UpdateButtonsEnabledStatus()
        {
            UIOutputItem source = SelectedSource;
            UIInputItem  target = SelectedTarget;

            List <UIExchangeItem> sources = _treeSource.GetCheckedExchangeItems();

            bool checkedSourceAndTarget = source != null && target != null;

            // Make it look as if inactive rather than do it as
            // tooltips will not work on inactive buttons

            btnLinkAdd.ForeColor = checkedSourceAndTarget
                ? SystemColors.ActiveCaptionText : SystemColors.InactiveCaptionText;
            btnLinkRemove.ForeColor = listLinks.SelectedItem != null
                ? SystemColors.ActiveCaptionText : SystemColors.InactiveCaptionText;

            btnViewer.ForeColor = checkedSourceAndTarget
                ? SystemColors.ActiveCaptionText : SystemColors.InactiveCaptionText;

            btnAddSources.ForeColor = checkedSourceAndTarget
                ? SystemColors.ActiveCaptionText : SystemColors.InactiveCaptionText;
            btnArgEdit.ForeColor = source != null && source.IExchangeItem is IAdaptedOutput
                ? SystemColors.ActiveCaptionText : SystemColors.InactiveCaptionText;
        }
Exemplo n.º 2
0
        private void listBoxConnections_SelectedValueChanged(object sender, EventArgs e)
        {
            if (listBoxConnections.SelectedItem != null)
            {
                Link selected = listBoxConnections.SelectedItem as Link;

                if (selected != null)
                {
                    uncheckAllNodes(true, true);
                    uncheckAllNodes(false, true);

                    UIInputItem item = selected.Target;

                    if (fastLookUpInputs.ContainsKey(item))
                    {
                        TreeNode node = fastLookUpInputs[item];
                        node.Checked = true;
                    }

                    foreach (UIOutputItem output in selected.Sources)
                    {
                        if (fastLookUpOutputs.ContainsKey(output))
                        {
                            TreeNode node = fastLookUpOutputs[output];
                            node.Checked = true;
                        }
                    }

                    currentLink = new Link(selected.Sources, selected.Target);
                }
            }
        }
Exemplo n.º 3
0
        public FactoriesDialog(List <UIModel> models, UIOutputItem itemOut, UIInputItem itemIn)
        {
            _itemOut = itemOut;
            _itemIn  = itemIn;

            UIAdaptedFactory factory;
            string           firstSourceFactory = null;

            foreach (UIModel model in models)
            {
                foreach (IAdaptedOutputFactory iFactory in model.LinkableComponent.AdaptedOutputFactories)
                {
                    factory = new UIAdaptedFactory();

                    if (_itemOut.Component == model.LinkableComponent)
                    {
                        factory.InitialiseAsNative(iFactory.Id, model.LinkableComponent);

                        if (firstSourceFactory == null)
                        {
                            firstSourceFactory = factory.ToString();
                        }
                    }
                    else
                    {
                        factory.InitialiseAs3rdParty(iFactory.GetType(), model.LinkableComponent);
                    }

                    AddFactory(factory);
                }
            }

            InitializeComponent();

            groupBox2.Text = string.Format(
                "Factory sources that adapt \"{0}\" -> \"{1}\"",
                itemOut.Caption, itemIn.Caption);

            UpdateUIFactories();

            if (firstSourceFactory != null)
            {
                cbFactories.SelectedIndex = cbFactories.FindStringExact(firstSourceFactory);
            }

            UpdateControlEnabling();
        }
Exemplo n.º 4
0
        private void OnAddSources(object sender, System.EventArgs e)
        {
            UIOutputItem source = SelectedSource;
            UIInputItem  target = SelectedTarget;

            if (source == null || target == null)
            {
                return;
            }

            FactoriesDialog dlg = new FactoriesDialog(_models, source, target);

            if (dlg.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _treeSource.TreeAdd(dlg.Adapters);

            UpdateButtonsEnabledStatus();
        }
Exemplo n.º 5
0
        private void OnViewElementSet(object sender, System.EventArgs e)
        {
            UIOutputItem source = SelectedSource;
            UIInputItem  target = SelectedTarget;

            ArrayList elementSets = new ArrayList();

            if (source != null)
            {
                elementSets.Add(source.ElementSet);
            }
            if (target != null)
            {
                elementSets.Add(target.ElementSet);
            }

            if (elementSets.Count > 0)
            {
                _elementSetViewer.PopulateDialog(elementSets);
                _elementSetViewer.ShowDialog();
            }
        }
Exemplo n.º 6
0
        void SetValidAdatedOutputs(TreeNode outputSender = null)
        {
            UIInputItem  input  = null;
            UIOutputItem output = null;

            if (outputSender != null && outputSender.Tag is UIOutputItem)
            {
                output = outputSender.Tag as UIOutputItem;
            }
            else
            {
                SetErrorText("No output item has been selected");
            }

            List <UIInputItem> checkedInputs = GetDownStreamCheckedItems <UIInputItem>(treeViewTargets.Nodes);

            if (checkedInputs.Count != 1)
            {
                SetErrorText("More than one input item has been selected");
            }
            else
            {
                input = checkedInputs[0];
            }

            if (input == null)
            {
                listBoxAdaptedOutputs.DataSource = null;
                return;
            }

            if (output == null)
            {
                listBoxAdaptedOutputs.DataSource = null;
                return;
            }

            List <UIAdaptedOutputItem> ids = new List <UIAdaptedOutputItem>();


            foreach (UIAdaptedFactory factory in externalFactories)
            {
                IIdentifiable[] idf = factory.GetAvailableAdaptedOutputIds(output, input);

                foreach (IIdentifiable f in idf)
                {
                    ITimeSpaceAdaptedOutput adpout   = (ITimeSpaceAdaptedOutput)factory.CreateAdaptedOutput(f, output, input);
                    UIAdaptedOutputItem     uiadpout = new UIAdaptedOutputItem(factory, f, adpout, output);
                    ids.Add(uiadpout);
                }
            }

            foreach (IAdaptedOutputFactory factory in connection.SourceModel.LinkableComponent.AdaptedOutputFactories)
            {
                UIAdaptedFactory fac = new UIAdaptedFactory();
                fac.InitialiseAsNative(factory.Id, connection.SourceModel.LinkableComponent);

                IIdentifiable[] idf = factory.GetAvailableAdaptedOutputIds(output, input);

                foreach (IIdentifiable f in idf)
                {
                    UIAdaptedFactory tempFac = new UIAdaptedFactory();
                    tempFac.InitialiseAsNative(factory.Id, connection.SourceModel.LinkableComponent);

                    ITimeSpaceAdaptedOutput adpout   = (ITimeSpaceAdaptedOutput)factory.CreateAdaptedOutput(f, output, input);
                    UIAdaptedOutputItem     uiadpout = new UIAdaptedOutputItem(tempFac, f, adpout, output);
                    ids.Add(uiadpout);
                }
            }

            foreach (TreeNode node in outputSender.Nodes)
            {
                if (node.Tag != null && node.Tag is UIAdaptedOutputItem)
                {
                    UIAdaptedOutputItem item = (UIAdaptedOutputItem)node.Tag;

                    for (int i = 0; i < ids.Count; i++)
                    {
                        if (item.Id == ids[i].Id)
                        {
                            ids.RemoveAt(i);
                            break;
                        }
                    }
                }
            }

            listBoxAdaptedOutputs.DataSource    = ids;
            listBoxAdaptedOutputs.DisplayMember = "Caption";
        }
Exemplo n.º 7
0
        void updateTargetsTreeView()
        {
            treeViewTargets.SuspendLayout();
            treeViewTargets.Nodes.Clear();

            fastLookUpInputs = new Dictionary <UIInputItem, TreeNode>();

            UIModel targetModel = connection.TargetModel;
            Dictionary <string, TreeNode> quantities = new Dictionary <string, TreeNode>();

            foreach (IBaseInput input in targetModel.LinkableComponent.Inputs)
            {
                IValueDefinition value = input.ValueDefinition;
                TreeNode         node  = null;

                if (!quantities.ContainsKey(value.Caption))
                {
                    node          = new TreeNode(value.Caption);
                    node.ImageKey = "valueDef";
                    quantities.Add(value.Caption, node);
                    treeViewTargets.Nodes.Add(node);
                }
                else
                {
                    node = quantities[value.Caption];
                }

                TreeNode item = new TreeNode(input.Id);
                item.ImageKey = "id";
                item.Tag      = input;
                node.Nodes.Add(item);

                if (input is ITimeSpaceInput)
                {
                    ITimeSpaceInput tspaceInput = (ITimeSpaceInput)input;

                    UIInputItem uitem = (from n in connection.Links
                                         where n.Target != null && n.Target.ExchangeItem == tspaceInput
                                         select n.Target).FirstOrDefault();
                    if (uitem != null)
                    {
                    }
                    else
                    {
                        uitem = new UIInputItem(tspaceInput);
                    }

                    item.Tag = uitem;
                    fastLookUpInputs.Add(uitem, item);

                    if (tspaceInput.SpatialDefinition is IElementSet)
                    {
                        IElementSet eSet = (IElementSet)tspaceInput.SpatialDefinition;

                        switch (eSet.ElementType)
                        {
                        case ElementType.IdBased:
                            item.ImageKey = "id";
                            break;

                        case ElementType.Point:

                            if (!eSet.HasZ)
                            {
                                item.ImageKey         = "point2d";
                                item.SelectedImageKey = "point2d";
                            }
                            else
                            {
                                item.ImageKey         = "point3d";
                                item.SelectedImageKey = "point3d";
                            }

                            break;

                        case ElementType.Polygon:
                            if (!eSet.HasZ)
                            {
                                item.ImageKey         = "polygon2d";
                                item.SelectedImageKey = "polygon2d";
                            }
                            else
                            {
                                item.ImageKey         = "polygon3d";
                                item.SelectedImageKey = "polygon3d";
                            }
                            break;

                        case ElementType.Polyhedron:
                            item.ImageKey         = "polyhedra";
                            item.SelectedImageKey = "polyhedra";
                            break;

                        case ElementType.PolyLine:
                            if (!eSet.HasZ)
                            {
                                item.ImageKey         = "mline2d";
                                item.SelectedImageKey = "mline2d";
                            }
                            else
                            {
                                item.ImageKey         = "mline3d";
                                item.SelectedImageKey = "mline3d";
                            }
                            break;
                        }
                    }
                }
            }

            treeViewTargets.ExpandAll();
            treeViewTargets.ResumeLayout();
        }
Exemplo n.º 8
0
        public Recipe GetRecipe(string recipeFilePath)
        {
            Recipe recipe = new Recipe();

            #region assign default value
            recipe.DatalogConfiguration.datalog_name_rule_1 = @"{Customer_ID}/{Device_Name}/{Customer_LotNo}/{Sub_LotNo}/";
            recipe.DatalogConfiguration.datalog_name_rule_2 = @"{Customer_LotNo}_{Sub_LotNo}_{Test_BinNo}_{Test_Code}_{Start_Time}";
            #endregion

            using (StreamReader sr = new StreamReader(recipeFilePath))
            {
                string line = string.Empty;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.StartsWith("#"))
                    {
                        continue;
                    }

                    string[] s = line.Split('=');

                    if (s[0].Trim() == "datalog_name_rule_1")
                    {
                        recipe.DatalogConfiguration.datalog_name_rule_1 = s[1].Trim();
                    }

                    if (s[0].Trim() == "datalog_name_rule_2")
                    {
                        recipe.DatalogConfiguration.datalog_name_rule_2 = s[1].Trim();
                    }

                    if (s[0].Trim().ToLower().StartsWith("[input_oi_"))
                    {
                        UIInputItem item = new UIInputItem();
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (line.StartsWith("#"))
                            {
                                continue;
                            }

                            s = line.Split('=');

                            if (s[0].StartsWith("[") && s[0].EndsWith("]"))
                            {
                                break;
                            }

                            if (s[0].Trim() == "Name")
                            {
                                item.Name = s[1].Trim();
                            }
                            else if (s[0].Trim() == "Pattern")
                            {
                                item.Pattern = s[1].Trim();
                            }
                            else if (s[0].Trim() == "Index")
                            {
                                item.Index = s[1].Trim();
                            }

                            if (!string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(item.Pattern) && !string.IsNullOrEmpty(item.Index))
                            {
                                recipe.UIInputItemConfiguration.listUIInputItems.Add(item);
                                break;
                            }
                        }
                    }

                    if (s[0].Trim().ToLower() == "[testcode_config]")
                    {
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (line.StartsWith("#"))
                            {
                                continue;
                            }

                            s = line.Split('=');

                            if (s[0].StartsWith("[") && s[0].EndsWith("]"))
                            {
                                break;
                            }

                            if (s.Length == 2)
                            {
                                try
                                {
                                    recipe.TestCodeConvertConfiguration.dictTestCode.Add(s[0].Trim(), s[1].Trim());
                                }
                                catch
                                { }
                            }
                        }
                    }

                    if (s[0].Trim().ToLower() == "[stdf_variable_config]")
                    {
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (line.StartsWith("#"))
                            {
                                continue;
                            }

                            s = line.Split('=');

                            if (s[0].StartsWith("[") && s[0].EndsWith("]"))
                            {
                                break;
                            }

                            if (s.Length == 2)
                            {
                                try
                                {
                                    recipe.SpecialSTDFCondition.dictSTDFVariable.Add(s[0].Trim(), s[1].Trim());
                                }
                                catch
                                { }
                            }
                        }
                    }

                    if (s[0].Trim().ToLower() == "[stdf_constant_config]")
                    {
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (line.StartsWith("#"))
                            {
                                continue;
                            }

                            s = line.Split('=');

                            if (s[0].StartsWith("[") && s[0].EndsWith("]"))
                            {
                                break;
                            }

                            if (s.Length == 2)
                            {
                                try
                                {
                                    recipe.SpecialSTDFCondition.dictSTDFConstant.Add(s[0].Trim(), s[1].Trim());
                                }
                                catch
                                { }
                            }
                        }
                    }
                }
                sr.Close();
            }

            return(recipe);
        }