Beispiel #1
0
        private void btnAddMeasure_Click(object sender, EventArgs e)
        {
            //if (this.measuresTreeView.SelectedNodes
            UltraGridRow parentGridRow = null;
            UltraGridRow childGridRow  = null;



            if (this.ugSimulationgropus.ActiveRow != null)
            {
                parentGridRow = (UltraGridRow)ugSimulationgropus.ActiveRow;
            }

            if (parentGridRow != null && parentGridRow.Band.Key == "ZONE")
            {
                childGridRow  = parentGridRow;
                parentGridRow = parentGridRow.ParentRow;
            }

            if (parentGridRow == null && this.ugSimulationgropus.Rows.Count == 1)
            {
                this.ugSimulationgropus.ActiveRow = ugSimulationgropus.Rows[0];
                parentGridRow = (UltraGridRow)ugSimulationgropus.Rows[0];
            }

            if (parentGridRow != null && (parentGridRow.Band.Index == 0 || parentGridRow.Band.Index == 1) &&
                parentGridRow.Band.Key != "ZONE")
            {
                if (measuresTreeView.SelectedNodes?.Count > 0)
                {
                    List <SimulationMeasure> selectedMeasures = new List <SimulationMeasure>();
                    foreach (UltraTreeNode measureNode in measuresTreeView.SelectedNodes)
                    {
                        SimulationMeasure measure = measureNode.ListObject as SimulationMeasure;
                        if (measureNode.Level == 2)
                        {
                            UltraDataRow            dr       = parentGridRow.ListObject as UltraDataRow;
                            UltraDataRowsCollection rowsList = dr.GetChildRows("ZONE");
                            bool isMeasureExists             = false;
                            foreach (UltraDataRow row in rowsList)
                            {
                                if (measure.Name == Convert.ToString(row["Configuration"]))
                                {
                                    isMeasureExists = true;
                                    break;
                                }
                            }
                            if (!isMeasureExists)
                            {
                                UltraDataRow measureRow = rowsList.Add(new object[] { measure.Name });
                            }
                            else
                            {
                                MessageBox.Show("Measure already exists");
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private List <SimulationMeasure> GetSelectedMeasures()
        {
            List <SimulationMeasure> selectedMeasures = new List <SimulationMeasure>();

            if (measuresTreeView.SelectedNodes?.Count > 0)
            {
                foreach (UltraTreeNode measureNode in measuresTreeView.SelectedNodes)
                {
                    SimulationMeasure measure = measureNode.ListObject as SimulationMeasure;
                    if (measureNode.Level == 2 && measure.Type != SimulationMeasureType.None)
                    {
                        selectedMeasures.Add(measure);
                    }
                }
            }
            return(selectedMeasures);
        }
Beispiel #3
0
        public void CreateMeasuresFolderStructure()
        {
            string   measureFolder = ApplicationManager.Instance.GetMeasuresFolder();
            string   aa            = "http://bcl.nrel.gov/api/taxonomy/measure";
            taxonomy result        = DownloadAndDeserializeJsonData <taxonomy>(aa);

            if (result != null)
            {
                IEnumerable <string> measureFiles = Directory.EnumerateFiles(measureFolder, "measure.xml", SearchOption.AllDirectories);
                List <measure>       measures     = new List <measure>();
                foreach (string measureFilePath in measureFiles)
                {
                    measure m = null;
                    try
                    {
                        m = XMLHelper.Deserialize <measure>(File.ReadAllText(measureFilePath));
                    }
                    catch (Exception ex)
                    {
                    }
                    if (m != null)
                    {
                        //SimulationMeasureType measureType = SimulationMeasureType.None;
                        //foreach (var item in m.attributes)
                        //{
                        //    if (item?.name == "Measure Type" && Enum.TryParse<SimulationMeasureType>(item.value, out measureType))
                        //    {
                        //        m.MeasureType = measureType;
                        //        break;
                        //    }
                        //}
                        measures.Add(m);
                    }
                }


                List <SimulationMeasure> simulationMeasures = new List <SimulationMeasure>();
                foreach (Term term in result.term)
                {
                    SimulationMeasure measureCategory = new SimulationMeasure();
                    measureCategory.Name        = term.name;
                    measureCategory.Description = term.description;
                    simulationMeasures.Add(measureCategory);

                    if (term.term?.Count > 0)
                    {
                        measureCategory.Measures = new List <SimulationMeasure>();
                        foreach (Term childTerm in term.term)
                        {
                            SimulationMeasure childCategory = new SimulationMeasure();
                            childCategory.Name        = childTerm.name;
                            childCategory.Description = childTerm.description;
                            measureCategory.Measures.Add(childCategory);
                            string         measureTag   = string.Format("{0}.{1}", term.name, childTerm.name);
                            List <measure> termMeasures = measures.Where(m => m.tags.tag == measureTag).ToList();
                            if (termMeasures?.Count > 0)
                            {
                                childCategory.Measures = new List <SimulationMeasure>();
                                foreach (measure simMeausre in termMeasures)
                                {
                                    SimulationMeasure termMeasure = new SimulationMeasure();
                                    termMeasure.Name        = simMeausre.name;
                                    termMeasure.Description = simMeausre.description;
                                    SimulationMeasureType measureType = SimulationMeasureType.None;
                                    foreach (var item in simMeausre.attributes)
                                    {
                                        if (item?.name == "Measure Type" && Enum.TryParse <SimulationMeasureType>(item.value, out measureType))
                                        {
                                            termMeasure.Type = measureType;
                                            break;
                                        }
                                    }
                                    childCategory.Measures.Add(termMeasure);
                                }
                            }
                        }
                    }
                }

                measuresTreeView.DataSource = simulationMeasures;
            }
        }
Beispiel #4
0
        private void measuresTreeView_InitializeDataNode(object sender, Infragistics.Win.UltraWinTree.InitializeDataNodeEventArgs e)
        {
            //if (e.Node.Nodes.Count == 0)
            //    e.Node.Visible = false;
            SimulationMeasure measure = e.Node.ListObject as SimulationMeasure;

            if (e.Node.IsRootLevelNode)
            {
                e.Node.Override.NodeAppearance.BackColor     = Color.Gray;
                e.Node.Override.NodeAppearance.ForeColor     = Color.White;
                e.Node.Override.NodeAppearance.BorderColor   = Color.Black;
                e.Node.Override.NodeAppearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;
                e.Node.Override.BorderStyleNode = Infragistics.Win.UIElementBorderStyle.Solid;
                if (measure?.Measures != null)
                {
                    int count = measure.Measures.Select(m => m.Measures == null ? new List <SimulationMeasure>() : m.Measures).Count();

                    if (!e.Reinitialize)
                    {
                        e.Node.Text = string.Format("{0} ({1})", e.Node.Text, count);
                    }
                }
            }
            else
            {
                switch (e.Node.Level)
                {
                case 1:
                {
                    e.Node.Override.NodeAppearance.BackColor     = Color.LightGray;
                    e.Node.Override.NodeAppearance.ForeColor     = Color.Black;
                    e.Node.Override.NodeAppearance.BorderColor   = Color.Gray;
                    e.Node.Override.NodeAppearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;
                    e.Node.Override.BorderStyleNode = Infragistics.Win.UIElementBorderStyle.Solid;
                }
                break;

                case 2:
                {
                    if (measure != null)
                    {
                        Color color = e.Node.Override.NodeAppearance.BackColor;
                        if (measure.Type == SimulationMeasureType.ModelMeasure)
                        {
                            color = Color.FromArgb(200, 214, 230);
                        }

                        if (measure.Type == SimulationMeasureType.EnergyPlusMeasure)
                        {
                            color = Color.FromArgb(202, 218, 169);
                        }

                        if (measure.Type == SimulationMeasureType.ReportingMeasure)
                        {
                            color = Color.FromArgb(206, 149, 139);
                        }

                        e.Node.Override.NodeAppearance.BackColor = color;
                        // e.Node.Override.NodeAppearance.ForeColor = Color.White;
                        e.Node.Override.NodeAppearance.BorderColor = Color.Black;
                        e.Node.Override.BorderStyleNode            = Infragistics.Win.UIElementBorderStyle.Solid;
                        e.Node.LeftImagesAlignment = Infragistics.Win.VAlign.Default;
                        if (measure.Type == SimulationMeasureType.ReportingMeasure)
                        {
                            e.Node.LeftImages.Add(Properties.Resources.rm32x32);
                        }

                        if (measure.Type == SimulationMeasureType.EnergyPlusMeasure)
                        {
                            e.Node.LeftImages.Add(Properties.Resources.em32x32);
                        }
                        if (measure.Type == SimulationMeasureType.ModelMeasure)
                        {
                            e.Node.LeftImages.Add(Properties.Resources.mm32x32);
                        }
                    }
                }
                break;

                default:
                    break;
                }
            }
        }