Example #1
0
        private void DrawPipeLableColor(JCHNode label, string pipeSize, Node nodeUnit, int GasNo)
        {
            initTextNode(label, pipeSize);
            label.IsLiquidGasPipeNode = true;
            addFlowPiping.AddNode(label);
            //if (nodeUnit != null)
            //    nodeUnit.AddFlow.Items.Add(label);

            switch (GasNo)
            {
            case 1:
                label.Foreground = System.Windows.Media.Brushes.MediumPurple;
                break;

            case 2:
                label.Foreground = System.Windows.Media.Brushes.Blue;
                break;

            case 3:
                label.Foreground = System.Windows.Media.Brushes.Green;
                break;

            case 4:
                label.Foreground = System.Windows.Media.Brushes.Red;
                break;
            }
        }
Example #2
0
        void initTextNode(JCHNode label, string text)
        {
            gMeasureString.PageUnit = GraphicsUnit.Pixel;
            Font ft = textFont_piping;

            label.FontFamily = new System.Windows.Media.FontFamily("Arial");
            label.FontSize   = 8;
            label.Foreground = System.Windows.Media.Brushes.Black;
            label.Stroke     = System.Windows.Media.Brushes.Black;
            label.Fill       = System.Windows.Media.Brushes.Transparent;
            label.Text       = text;
            SizeF size = gMeasureString.MeasureString(text, ft);

            label.Size          = new System.Windows.Size(size.Width + 5, size.Height + 3);
            label.ImagePosition = ImagePosition.LeftTop;
            label.Geometry      = new RectangleGeometry(new System.Windows.Rect(0, 0, 0, 0));
            // label.Logical = false;
            //label.Selectable = false;
            label.IsSelectable = false;
            // label.AttachmentStyle = AttachmentStyle.Item;
            // label.ZOrder = 10;
            try
            {
                label.ImageData = new JCHVRF.Model.NextGen.ImageData();
            }
            catch { }
        }
Example #3
0
        private void SetWiringNodeStyleForSystems(JCHNode node)
        {
            node.Geometry = new RectangleGeometry(new Rect(0, 0, 100, 70), 3, 3);
            // node.Stroke = System.Windows.Media.Brushes.RoyalBlue;
            node.Stroke =
                new SolidColorBrush(System.Windows.Media.Color.FromRgb(185, 185, 185)); // System.Windows.Media.Brushes.Gray;
            node.StrokeThickness = 2;
            node.Size            = new Size(125, 75);
            node.DashStyle       = DashStyles.Solid;
            node.Fill            = System.Windows.Media.Brushes.White;
            node.TextMargin      = new Thickness(3);
            if (node.Image == null)
            {
                node.TextPosition = TextPosition.CenterMiddle;
            }
            else
            {
                node.ImageMargin   = new Thickness(3);
                node.ImagePosition = ImagePosition.CenterTop;
                node.TextPosition  = TextPosition.CenterBottom;
            }
            node.IsXSizeable = false; //test resize
            node.IsYSizeable = false; //test resize
            var pointOnNode = new PointCollection();

            pointOnNode.Add(new Point(50, 0));
            pointOnNode.Add(new Point(50, 100));
            node.PinsLayout = pointOnNode;

            //string defaultFolder = AppDomain.CurrentDomain.BaseDirectory;
            //string navigateToFolder = "..\\..\\Image";
            //string sourceDir = System.IO.Path.Combine(defaultFolder, navigateToFolder);
            //string imageFullPath = sourceDir + "\\" + "Path 111.png";

            //ImageBrush brush = new ImageBrush();
            //var bitmap = new Bitmap(imageFullPath);
            //var bitmapImage = BitmapToImageSource(bitmap);
            //brush.ImageSource = bitmapImage;

            //_addflowWiring.PinFill = brush;
            _addflowWiring.PinShape    = PinShape.Circle;
            _addflowWiring.PinSize     = 13;
            node.OutConnectionMode     = ConnectionMode.Pin;
            node.InConnectionMode      = ConnectionMode.Pin;
            _addflowWiring.CanDrawNode = false;
            node.FontSize = 9;
            //node.Tooltip = data.equipmentType + " : " + data.imageName;
            node.IsSelectable = true;
            node.IsEditable   = false;
        }
Example #4
0
        private void DrawMandatoryNodeVisualsForController(JCHNode node)
        {
            var connectionHandlePoints = GetMandatoryConnectionHandleLocationForController(node);

            if (connectionHandlePoints.Count < 2)
            {
                return;
            }
            var dv = new DrawingVisual();
            var dc = dv.RenderOpen();

            node.Visual.Children.Clear();

            #region DrawDefaultNodePin
            if (connectionHandlePoints[0] != null)
            {
                string defaultFolder    = AppDomain.CurrentDomain.BaseDirectory;
                string navigateToFolder = "..\\..\\Image";
                string sourceDir        = System.IO.Path.Combine(defaultFolder, navigateToFolder);
                string imageFullPath    = sourceDir + "\\" + "CC_plus.png";
                var    bitmap           = new Bitmap(imageFullPath);
                var    bitmapImage      = BitmapToImageSource(bitmap);

                ImageBrush brush = new ImageBrush();
                brush.ImageSource = bitmapImage;

                Rect rect = new Rect(new Point(connectionHandlePoints[0].X - 5, connectionHandlePoints[0].Y - 5), new Point(connectionHandlePoints[0].X + 5, connectionHandlePoints[0].Y + 5));
                dc.DrawRoundedRectangle(brush, null, rect, 5, 5);
            }
            if (connectionHandlePoints[1] != null)
            {
                string defaultFolder    = AppDomain.CurrentDomain.BaseDirectory;
                string navigateToFolder = "..\\..\\Image";
                string sourceDir        = System.IO.Path.Combine(defaultFolder, navigateToFolder);
                string imageFullPath    = sourceDir + "\\" + "CC_minus.png";
                var    bitmap           = new Bitmap(imageFullPath);
                var    bitmapImage      = BitmapToImageSource(bitmap);

                ImageBrush brush = new ImageBrush();
                brush.ImageSource = bitmapImage;

                Rect rect = new Rect(new Point(connectionHandlePoints[1].X - 5, connectionHandlePoints[1].Y - 5), new Point(connectionHandlePoints[1].X + 5, connectionHandlePoints[1].Y + 5));
                dc.DrawRoundedRectangle(brush, null, rect, 5, 5);
            }
            #endregion
            dc.Close();
            node.Visual.Children.Add(dv);
        }
Example #5
0
        private void CustomizeLink(JCHNode nodeStart, JCHNode nodeEnd, Link customLink)
        {
            customLink.IsStretchable = true;
            customLink.IsSelectable  = false;
            customLink.IsAdjustDst   = false;
            customLink.IsAdjustOrg   = false;

            Point start  = utilPiping.getTopCenterPointF(nodeStart);
            Point end    = utilPiping.getTopCenterPointF(nodeEnd);
            Point midPt1 = new Point(start.X + 15, start.Y - 20);
            Point midPt2 = new Point(end.X, end.Y - 20);

            customLink.Points[0] = start;
            customLink.Points.Add(midPt1);
            customLink.Points.Add(midPt2);
            customLink.Points[1] = midPt1;
            customLink.Points[2] = midPt2;
            customLink.Points[3] = end;
        }
Example #6
0
        private List <Point> GetMandatoryConnectionHandleLocationForController(JCHNode node)
        {
            Point pt11 = new Point(node.Location.X + node.Size.Width / 2, node.Location.Y);
            Point pt12 = new Point(node.Location.X + node.Size.Width / 2, node.Location.Y + node.Size.Height);

            if (node.ImageData != null && node.ImageData.equipmentType != null)
            {
                List <Point> listPoints = new List <Point>();
                if (node.ImageData.equipmentType.Equals("Controller") || node.ImageData.equipmentType.Equals("System"))
                {
                    listPoints.Add(pt11);
                    listPoints.Add(pt12);
                }
                return(listPoints);
            }
            else
            {
                List <Point> listPoints = new List <Point>();
                listPoints.Add(pt11);
                listPoints.Add(pt12);
                return(listPoints);
            }
        }
Example #7
0
 private Link SeriesLink(JCHNode nodeStart, JCHNode nodeEnd)
 {
     return(new Link(nodeStart, nodeEnd, 1, 0, "", _addflowWiring));
 }
Example #8
0
 private Link ParallelLink(JCHNode nodeStart, JCHNode nodeEnd)
 {
     return(new Link(nodeStart, nodeEnd, "", _addflowWiring));
 }
Example #9
0
 public static string GetUniqueName(this JCHNode node)
 {
     return(node != null && node.ImageData != null ? node.ImageData.UniqName : string.Empty);
 }
Example #10
0
 public static bool IsYpNode(this JCHNode node)
 {
     return(node is JCHVRF.Model.NextGen.MyNodeYP);
 }
        /// <summary>
        /// Delete the node ofType JCHNode
        /// </summary>
        /// <param name="deleteNode"></param>
        public void DeleteNodeForController(JCHNode deleteNode)
        {
            var findcontrolsystem =
                Project.CurrentProject.ControlSystemList.Find(t => t.Id == _currentSystem.Id);

            _group = Project.CurrentProject.ControlGroupList.Find(x =>
                                                                  x.ControlSystemID == _currentSystem.Id);
            if (deleteNode.ImageData.equipmentType == "System")
            {
                //For VRF
                if (deleteNode.ImageData.Source.GetType() == typeof(NextGenModel.SystemVRF))
                {
                    var node = (NextGenModel.SystemVRF)deleteNode.ImageData.Source;
                    var find = findcontrolsystem.SystemsOnCanvasList.Find(item =>
                                                                          item.System == (object)node);
                    findcontrolsystem.SystemsOnCanvasList.Remove(find);
                    foreach (NextGenModel.SystemVRF r in Project.CurrentProject.SystemListNextGen)
                    {
                        if (r.Id == node.Id)
                        {
                            int index = r.ControlGroupID.IndexOf(_group.Id);
                            r.ControlGroupID.RemoveAt(index);
                            break;
                        }
                    }
                }
                //For HE
                if (deleteNode.ImageData.Source.GetType() == typeof(RoomIndoor))
                {
                    var node = (RoomIndoor)deleteNode.ImageData.Source;
                    var find = findcontrolsystem.SystemsOnCanvasList.Find(item =>
                                                                          item.System == (object)node);
                    findcontrolsystem.SystemsOnCanvasList.Remove(find);
                    foreach (RoomIndoor r in Project.CurrentProject.ExchangerList)
                    {
                        if (r.SystemID == node.SystemID)
                        {
                            int index = r.ControlGroupID.IndexOf(_group.Id);
                            r.ControlGroupID.RemoveAt(index);
                            break;
                        }
                    }
                }
            }
            //For Controller
            if (deleteNode.ImageData.equipmentType == "Controller")
            {
                var ct = Project.CurrentProject.ControllerList.FindLast(c =>
                                                                        c.Model == deleteNode.ImageData.imageName);
                if (ct != null)
                {
                    if (ct.Quantity <= 1)
                    {
                        Project.CurrentProject.ControllerList.Remove(ct);
                    }
                    else
                    {
                        ct.Quantity -= 1;
                    }
                }
            }

            SelectedSystems = findcontrolsystem.SystemsOnCanvasList;
            if (SelectedSystems != null)
            {
                CheckForErrors(SelectedSystems, Project.CurrentProject.ControllerList.FindAll(c => c.ControlGroupID == _group.Id).Count);
            }
        }
Example #12
0
        private void drawTextToLink(ng.MyLink myLink, int linkIndex, Node parent, Node node, bool isInch, ng.SystemVRF sysItem)
        {
            if (myLink == null || parent == null || node == null)
            {
                return;
            }

            string p1 = "";   //Low Pressure Gas
            string p2 = "";   //High Pressure Gas
            string p3 = "";   //Liquid
            string p5 = "";

            if (sysItem.IsPipingOK)
            {
                string SpecL   = myLink.SpecL;
                string SpecG_h = myLink.SpecG_h;
                string SpecG_l = myLink.SpecG_l;
                if (!string.IsNullOrEmpty(SpecL) && !string.IsNullOrEmpty(SpecG_h))
                {
                    if (SpecG_l != null && SpecG_l != "-")
                    {
                        p1 = "φ" + SpecG_l + ut_pipeSize;
                    }
                    if (SpecG_h != null && SpecG_h != "-")
                    {
                        p2 = "φ" + SpecG_h + ut_pipeSize;
                    }
                    p3 = "φ" + SpecL + ut_pipeSize;

                    if (isInch)
                    {
                        _dal    = new PipingDAL(thisProject);
                        SpecL   = GetPipeSize_Inch(myLink.SpecL);
                        SpecG_h = GetPipeSize_Inch(myLink.SpecG_h);
                        SpecG_l = GetPipeSize_Inch(myLink.SpecG_l);

                        p1 = "";
                        p2 = "";
                        p3 = "";
                        if (SpecG_l != null && SpecG_l != "-")
                        {
                            p1 = SpecG_l + ut_pipeSize;
                        }
                        if (SpecG_h != null && SpecG_h != "-")
                        {
                            p2 = SpecG_h + ut_pipeSize;
                        }
                        p3 = SpecL + ut_pipeSize;
                    }
                }
            }

            if (sysItem.IsInputLengthManually)
            {
                p5 = Unit.ConvertToControl(myLink.Length, UnitType.LENGTH_M, ut_length).ToString("0.##") + ut_length;
            }

            bool isCoolingOnly;

            if (node is ng.MyNodeIn)
            {
                isCoolingOnly = (node as ng.MyNodeIn).IsCoolingonly;
            }
            else if (node is ng.MyNodeYP)
            {
                isCoolingOnly = (node as ng.MyNodeYP).IsCoolingonly;
            }
            else
            {
                isCoolingOnly = false;
            }

            float   width  = 0;
            float   height = 5;
            JCHNode label1 = new JCHNode();
            Caption Child1 = new Caption();

            if (!string.IsNullOrEmpty(p1))
            {
                if (string.IsNullOrEmpty(p2) && !isCoolingOnly)
                {
                    DrawPipeLableColor(label1, " ", node, 4);
                    Child1 = DrawPipeCaptionColor(Child1, p1, node, 4);
                }
                else
                {
                    DrawPipeLableColor(label1, " ", node, 1);
                    Child1 = DrawPipeCaptionColor(Child1, p1, node, 1);
                }
                height += 8;
            }

            JCHNode label2 = new JCHNode();
            Caption Child2 = new Caption();

            if (!string.IsNullOrEmpty(p2))
            {
                if (parent is ng.MyNodeMultiCH || parent is ng.MyNodeCH)
                {
                    DrawPipeLableColor(label2, " ", node, 4);
                    Child2 = DrawPipeCaptionColor(Child2, p2, node, 4);
                }
                else if (string.IsNullOrEmpty(p1))
                {
                    DrawPipeLableColor(label2, " ", node, 4);
                    Child2 = DrawPipeCaptionColor(Child2, p2, node, 4);
                }
                else
                {
                    if (parent is ng.MyNodeYP)
                    {
                        ng.MyNodeYP pNodeYp = parent as ng.MyNodeYP;
                        if (pNodeYp.ParentNode is ng.MyNodeMultiCH || pNodeYp.ParentNode is ng.MyNodeCH)
                        {
                            DrawPipeLableColor(label2, " ", node, 4);
                            Child2 = DrawPipeCaptionColor(Child2, p2, node, 4);
                        }
                        else
                        {
                            DrawPipeLableColor(label2, " ", node, 2);
                            Child2 = DrawPipeCaptionColor(Child2, p2, node, 2);
                        }
                    }
                    else
                    {
                        DrawPipeLableColor(label2, " ", node, 2);
                        Child2 = DrawPipeCaptionColor(Child2, p2, node, 2);
                    }
                }
                height += 8;
            }

            JCHNode label3 = new JCHNode();
            Caption Child3 = new Caption();

            if (!string.IsNullOrEmpty(p3))
            {
                DrawPipeLableColor(label3, " ", node, 3);
                Child3  = DrawPipeCaptionColor(Child3, p3, node, 3);
                height += 8;
            }
            JCHNode label5 = new JCHNode();
            Caption Child5 = new Caption();

            if (!string.IsNullOrEmpty(p5))
            {
                DrawPipeLableColor(label5, " ", node, 5);
                Child5  = DrawPipeCaptionColor(Child5, p5, node, 5);
                height += 8;
            }
            width       = Math.Max(Math.Max((float)label1.Size.Width, (float)label2.Size.Width), Math.Max((float)label3.Size.Width, (float)label5.Size.Width));
            label1.Size = convertSize(width, height);

            if (sysItem.PipingLayoutType == old.PipingLayoutTypes.BinaryTree)
            {
                SetLinkTextLocationForBinaryTree(myLink, linkIndex, parent, node, label1, sysItem.IsPipingVertical);//TODO
            }
            else if (sysItem.PipingLayoutType == old.PipingLayoutTypes.SchemaA)
            {
                SetLinkTextLocationForSechmaA(myLink, linkIndex, parent, node, label1, sysItem.IsPipingVertical);//TODO
            }
            else
            {
                SetLinkTextLocationForNormal(myLink, linkIndex, parent, node, label1, sysItem.IsPipingVertical);
            }

            System.Windows.Point pf = label1.Location;


            if (!string.IsNullOrEmpty(p1))
            {
                Child1.Location = pf;
                addFlowPiping.AddCaption(Child1);
                addFlowPiping.RemoveNode(label1);
                pf.Y += 8;
            }
            if (!string.IsNullOrEmpty(p2))
            {
                label2.Location = pf;
                Child2.Location = pf;
                addFlowPiping.AddCaption(Child2);
                addFlowPiping.RemoveNode(label2);
                pf.Y += 8;
            }
            if (!string.IsNullOrEmpty(p3))
            {
                label3.Location = pf;
                Child3.Location = pf;
                addFlowPiping.AddCaption(Child3);
                addFlowPiping.RemoveNode(label3);
                pf.Y += 8;
            }
            if (!string.IsNullOrEmpty(p5))
            {
                label5.Location = pf;
                Child5.Location = pf;
                addFlowPiping.AddCaption(Child5);
                addFlowPiping.RemoveNode(label5);
                pf.Y += 8;
            }
        }
Example #13
0
        public void drawTextToIDUNode(ng.SystemVRF sysItem, ng.MyNodeIn nodeUnit)
        {
            //DOUBT
            //if (nodeUnit.Children != null)
            //{
            //    nodeUnit.Children.Clear();
            //}

            string text = "";

            old.RoomIndoor riItem = nodeUnit.RoomIndooItem;
            if (riItem == null)
            {
                return;
            }

            string model = riItem.IndoorItem.Model_York;

            if (isHitachi)
            {
                model = riItem.IndoorItem.Model_Hitachi;
            }
            if (sysItem.OutdoorItem.Type != null && (sysItem.OutdoorItem.Type.Contains("YVAHP") || sysItem.OutdoorItem.Type.Contains("YVAHR")))
            {
                model = riItem.IndoorItem.Model_York;
            }

            text = riItem.IndoorName + "\n" + model;
            if (!string.IsNullOrEmpty(riItem.RoomID))
            {
                string floorName = "";
                foreach (old.Floor f in thisProject.FloorList)
                {
                    foreach (old.Room rm in f.RoomList)
                    {
                        if (rm.Id == riItem.RoomID)
                        {
                            floorName = f.Name;
                            break;
                        }
                    }
                }

                text = floorName + "\n" + riItem.RoomName + ":" + text;
            }
            else
            {
                if (!string.IsNullOrEmpty(riItem.DisplayRoom))
                {
                    text = riItem.DisplayRoom + ":" + text;
                }
            }

            JCHNode label = new JCHNode();

            initTextNode(label, text);

            label.ImagePosition = ImagePosition.CenterBottom;

            if (label.Size.Width < nodeUnit.Size.Width)
            {
                label.Size = convertSize(nodeUnit.Size.Width, label.Size.Height);
            }

            //addFlowPiping.Items.Add(label);
            nodeUnit.Stroke = System.Windows.Media.Brushes.RoyalBlue;
            //nodeUnit.AddFlow.AddNode(label);
            //nodeUnit.AddFlow.Items.Add(label);

            //DOUBT
            //nodeUnit.HighlightChildren = true;

            JCHNode label2 = new JCHNode();
            string  text2  = "";

            text2  = "Cooling: " + Unit.ConvertToControl(riItem.ActualCoolingCapacity, UnitType.POWER, ut_power).ToString("n1") + ut_power;
            text2 += "\nHeating: " + Unit.ConvertToControl(riItem.ActualHeatingCapacity, UnitType.POWER, ut_power).ToString("n1") + ut_power;
            text2 += "\nSensible Cooling: " + Unit.ConvertToControl(riItem.ActualSensibleHeat, UnitType.POWER, ut_power).ToString("n1") + ut_power;
            initTextNode(label2, text2);

            label2.ImagePosition = ImagePosition.LeftMiddle;

            if (label2.Size.Width < nodeUnit.Size.Width)
            {
                label2.Size = convertSize(nodeUnit.Size.Width, label2.Size.Height);
            }
            //nodeUnit.AddFlow.AddNode(label2);
            //nodeUnit.AddFlow.Items.Add(label2);

            //addFlowPiping.AddNode(label2);         // This line show Cooling, Heating and Heating on Canvas
            //nodeUnit.AddFlow.Items.Add(label2);

            label.Location  = convertPointFToWinPoint(nodeUnit.Location.X, nodeUnit.Location.Y - label.Size.Height);
            label2.Location = convertPointFToWinPoint(nodeUnit.Location.X, nodeUnit.Location.Y + nodeUnit.Size.Height);

            if (sysItem.PipingLayoutType == old.PipingLayoutTypes.Normal)
            {
                if (!sysItem.IsPipingVertical)
                {
                    label2.Location = convertPointFToWinPoint(label2.Location.X, label2.Location.Y + 8);
                }
            }
            else if (sysItem.PipingLayoutType == old.PipingLayoutTypes.BinaryTree)
            {
                if (!sysItem.IsPipingVertical)
                {
                    label.Location  = convertPointFToWinPoint(nodeUnit.Location.X, nodeUnit.Location.Y + nodeUnit.Size.Height);
                    label2.Location = convertPointFToWinPoint(label2.Location.X, label2.Location.Y + label.Size.Height);
                }
            }
        }
Example #14
0
        private void drawTextToOtherNode(Node node, Node parent, ng.SystemVRF sysItem)
        {
            if (node == null)
            {
                return;
            }

            //DOUBT
            //if (node.Children != null)
            //{
            //    node.Children.Clear();
            //}

            if (!sysItem.IsPipingOK)
            {
                return;
            }

            if (node is ng.MyNodeYP)
            {
                ng.MyNodeYP nodeYP = node as ng.MyNodeYP;
                if (!string.IsNullOrEmpty(nodeYP.Model) && sysItem.IsPipingOK)
                {
                    JCHNode label1 = new JCHNode();
                    initTextNode(label1, " ");

                    Caption Cap1 = initCaptionText(nodeYP.Model, nodeYP);

                    label1.Location = convertPointFToWinPoint(nodeYP.Location.X + 20, nodeYP.Location.Y - label1.Size.Height);
                    if (sysItem.PipingLayoutType == old.PipingLayoutTypes.BinaryTree)
                    {
                        if (!sysItem.IsPipingVertical)
                        {
                            label1.Location = convertPointFToWinPoint(nodeYP.Location.X + 10, nodeYP.Location.Y);
                        }
                        else
                        {
                            label1.Location = convertPointFToWinPoint(nodeYP.Location.X + 15, nodeYP.Location.Y - label1.Size.Height);
                        }
                    }
                    else if (sysItem.PipingLayoutType == old.PipingLayoutTypes.SchemaA)
                    {
                        if (!sysItem.IsPipingVertical)
                        {
                            label1.Location = convertPointFToWinPoint(label1.Location.X + 3, label1.Location.Y);
                        }
                        else
                        {
                            label1.Location = convertPointFToWinPoint(label1.Location.X - 8, label1.Location.Y + 20);
                        }
                    }
                    else if (sysItem.PipingLayoutType == old.PipingLayoutTypes.Normal)
                    {
                        if (sysItem.IsPipingVertical)
                        {
                            label1.Location = convertPointFToWinPoint(nodeYP.Location.X + 20, nodeYP.Location.Y - label1.Size.Height - 8);
                        }
                        else
                        {
                            label1.Location = convertPointFToWinPoint(nodeYP.Location.X + 20, nodeYP.Location.Y - label1.Size.Height);
                        }
                    }

                    //addFlowPiping.AddNode(label1);

                    //nodeYP.AddFlow.Items.Add(label1);

                    Cap1.Location = label1.Location;
                    addFlowPiping.AddCaption(Cap1);

                    if (nodeYP.Model != "")
                    {
                        if (sysItem.IsExportToReport)
                        {
                            InsertPipingKitTable("BranchKit", sysItem.Name, nodeYP.Model, 1, sysItem.Id);
                        }
                    }
                    addFlowPiping.RemoveNode(label1);
                }
            }
            else if (node is ng.MyNodeCH)
            {
                ng.MyNodeCH nodeCH = node as ng.MyNodeCH;
                if (!string.IsNullOrEmpty(nodeCH.Model))
                {
                    if (sysItem.IsExportToReport)
                    {
                        InsertPipingKitTable("CHBox", sysItem.Name, nodeCH.Model, 1, sysItem.Id);
                    }
                    if (sysItem.IsPipingOK)
                    {
                        JCHNode label1 = new JCHNode();
                        initTextNode(label1, nodeCH.Model);
                        if (!sysItem.IsPipingVertical)
                        {
                            label1.Location = convertPointFToWinPoint(nodeCH.Location.X + nodeCH.Size.Width / 2 + 5, nodeCH.Location.Y - label1.Size.Height);
                        }
                        else
                        {
                            label1.Location = convertPointFToWinPoint((nodeCH.Location.X - 50) + nodeCH.Size.Width / 2 - label1.Size.Width / 2, (nodeCH.Location.Y + 12) - label1.Size.Height);
                        }

                        addFlowPiping.AddNode(label1);

                        nodeCH.AddFlow.Items.Add(label1);
                    }
                }
            }
            else if (node is ng.MyNodeMultiCH)
            {
                ng.MyNodeMultiCH nodeMCH = node as ng.MyNodeMultiCH;
                if (!string.IsNullOrEmpty(nodeMCH.Model))
                {
                    if (sysItem.IsExportToReport)
                    {
                        InsertPipingKitTable("CHBox", sysItem.Name, nodeMCH.Model, 1, sysItem.Id);
                    }
                    if (sysItem.IsPipingOK)
                    {
                        JCHNode label1 = new JCHNode();
                        initTextNode(label1, nodeMCH.Model);
                        if (sysItem.IsPipingVertical)
                        {
                            label1.Location = convertPointFToWinPoint(nodeMCH.Location.X + nodeMCH.Size.Width / 2 - label1.Size.Width / 2, nodeMCH.Location.Y - label1.Size.Height);
                        }
                        else
                        {
                            if (parent is ng.MyNodeYP && parent.Location.Y > node.Location.Y)
                            {
                                label1.Location = convertPointFToWinPoint(nodeMCH.Location.X + nodeMCH.Size.Width / 2 - label1.Size.Width / 2, nodeMCH.Location.Y - label1.Size.Height);
                            }
                            else
                            {
                                label1.Location = convertPointFToWinPoint(nodeMCH.Location.X + nodeMCH.Size.Width / 2 + 5, nodeMCH.Location.Y - label1.Size.Height);
                            }
                        }

                        addFlowPiping.AddNode(label1);

                        nodeMCH.AddFlow.Items.Add(label1);
                    }
                }
            }
        }
        ////ToDo: Used to Initialize Hvacsystem in a better way
        //internal void UpdateHvacSystem(SystemBase newSystem)
        //{
        //    CurrentSystem = newSystem;
        //}

        private void OnSelectedItemChanged(Item selectedItem)
        {
            try
            {
                GetCurrentVRFSystem();
                // TODO: handle in case of manual piping
                //if (currentSystemVRF != null && selectedItem!=null && !(selectedItem is NextGenModel.MyLink) && !(selectedItem is NextGenModel.MyNodeCH))
                //{
                //    //currentSystemVRF.IsManualPiping = true;
                //}
                //Start bug 2959
                //var views = regionManager.Regions["MasterDesignerRightTopArea"].Views.OfType<UIElement>().ToList();
                //views[1].Visibility = Visibility.Visible;
                //End bug 2959
                JCHNode item = selectedItem as JCHNode;
                if (item == null)
                {
                    return;
                }

                if (!item.IsSelected)
                {
                    regionManager.RequestNavigate(RegionNames.MasterDesignerPropertiesRegion, ViewKeys.CanvasProperties);
                    return;
                }
                NavigationParameters param = new NavigationParameters();
                if (item is MyNodeCHBase)
                {
                    int itemIndex = selectedItem.AddFlow.Items.IndexOf(selectedItem);
                    param.Add("AddFlow", item.AddFlow);
                    param.Add("Index", itemIndex);
                    regionManager.RequestNavigate(RegionNames.MasterDesignerPropertiesRegion, ViewKeys.CHBoxProperties, param);
                }
                else if (item.ImageData != null)
                {
                    ImageData data = item.ImageData;

                    if (item is MyNodeCHBase)
                    {
                        int itemIndex = selectedItem.AddFlow.Items.IndexOf(selectedItem.AddFlow.Items.OfType <JCHNode>().FirstOrDefault(a => a.ImageData.NodeNo == item.ImageData.NodeNo));
                        param.Add("AddFlow", item.AddFlow);
                        param.Add("Index", itemIndex);
                        regionManager.RequestNavigate(RegionNames.MasterDesignerPropertiesRegion, ViewKeys.CHBoxProperties, param);
                    }
                    else
                    {
                        switch (data.equipmentType)
                        {
                        case "Indoor":
                            if (CurrentSystem != null)
                            {
                                RoomIndoor roomIndoor = JCHVRF.Model.Project.CurrentProject.RoomIndoorList.FirstOrDefault(mm => mm.SystemID.Equals(CurrentSystem.Id) && mm.IndoorNO == data.NodeNo);
                                param.Add("IndoorItem", roomIndoor);
                                param.Add("CurrentSystem", CurrentSystem);
                                regionManager.RequestNavigate(RegionNames.MasterDesignerPropertiesRegion, ViewKeys.IDUProperties, param);
                            }
                            break;

                        case "Outdoor":
                            var tempSystem = JCHVRF.Model.Project.CurrentProject.SystemListNextGen.FirstOrDefault(sys => sys.Id == CurrentSystem.Id);
                            if (tempSystem != null)
                            {
                                param.Add("OduImageData", data);
                                param.Add("CurrentSystem", tempSystem);
                                regionManager.RequestNavigate(RegionNames.MasterDesignerPropertiesRegion, ViewKeys.ODUProperties, param);
                            }
                            break;

                        case "Pipe":
                            int itemIndex = selectedItem.AddFlow.Items.IndexOf(selectedItem.AddFlow.Items.OfType <JCHNode>().FirstOrDefault(a => a.ImageData.NodeNo == item.ImageData.NodeNo));
                            param.Add("AddFlow", item.AddFlow);
                            param.Add("Index", itemIndex);
                            regionManager.RequestNavigate(RegionNames.MasterDesignerPropertiesRegion, ViewKeys.CHBoxProperties, param);
                            break;

                        case "HeatExchanger":
                            RoomIndoor roomHeatExchanger = JCHVRF.Model.Project.CurrentProject.ExchangerList.FirstOrDefault(mm => mm.SystemID.Equals(CurrentSystem.Id));
                            param.Add("IndoorItem", roomHeatExchanger);
                            regionManager.RequestNavigate(RegionNames.MasterDesignerPropertiesRegion, "HeatExchangerCanvasProperties", param);     //sss
                            break;

                        //Start bug 2959
                        //case "HeaderBranch":
                        //    views[1].Visibility = Visibility.Collapsed;
                        //    break;
                        //End bug 2959
                        default:
                            regionManager.RequestNavigate(RegionNames.MasterDesignerPropertiesRegion, ViewKeys.CanvasProperties);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                int?id = Project.GetProjectInstance?.projectID;
                Logger.LogProjectError(id, ex);
            }
        }
Example #16
0
 public static bool IsIndoorUnit(this JCHNode node)
 {
     return(node.ImageData != null && node.ImageData.equipmentType != null &&
            node.ImageData.equipmentType.Equals("Indoor"));
 }
        /// <summary>
        /// Delete the node ofType WiringNodeCentralControl
        /// </summary>
        /// <param name="deleteNode"></param>
        public void DeleteEquipmentOnCanvas(JCHNode deleteNode)
        {
            var findcontrolsystem = Project.CurrentProject.ControlSystemList.Find(t => t.Id == _currentSystem.Id);
            var node = (NextGenModel.WiringNodeCentralControl)deleteNode;

            _group = Project.CurrentProject.ControlGroupList.Find(x =>
                                                                  x.ControlSystemID == _currentSystem.Id);

            //For VRF
            if (node.SystemItem != null)
            {
                var objNode = node.SystemItem;
                var vrfList = findcontrolsystem.SystemsOnCanvasList.FindAll(item => item.System.GetType() == typeof(NextGenModel.SystemVRF));
                var findHE  = vrfList.Find(item => ((NextGenModel.SystemVRF)item.System).Id == objNode.Id);
                findcontrolsystem.SystemsOnCanvasList.Remove(findHE);
                foreach (NextGenModel.SystemVRF r in Project.CurrentProject.SystemListNextGen)
                {
                    if (r.Id == node.SystemItem.Id)
                    {
                        int index = r.ControlGroupID.IndexOf(_group.Id);
                        r.ControlGroupID.RemoveAt(index);
                        break;
                    }
                }
            }
            //For HE
            else if (node.RoomIndoorItem != null)
            {
                var objNode = node.RoomIndoorItem;
                var heList  = findcontrolsystem.SystemsOnCanvasList.FindAll(item => item.System.GetType() == typeof(RoomIndoor));
                var findHE  = heList.Find(item => ((RoomIndoor)item.System).SystemID == objNode.SystemID);
                findcontrolsystem.SystemsOnCanvasList.Remove(findHE);
                foreach (RoomIndoor r in Project.CurrentProject.ExchangerList)
                {
                    if (r.SystemID == node.RoomIndoorItem.SystemID)
                    {
                        int index = r.ControlGroupID.IndexOf(_group.Id);
                        r.ControlGroupID.RemoveAt(index);
                        break;
                    }
                }
            }
            //For Controller
            else if (node.Controller != null)
            {
                var ct = Project.CurrentProject.ControllerList.Find(c =>
                                                                    c.ControlGroupID == _group.Id && c.Model == node.Controller.Model);
                if (ct != null)
                {
                    if (ct.Quantity <= 1)
                    {
                        Project.CurrentProject.ControllerList.Remove(ct);
                    }
                    else
                    {
                        ct.Quantity -= 1;
                    }
                }
            }
            SelectedSystems = findcontrolsystem.SystemsOnCanvasList;
            if (SelectedSystems != null)
            {
                CheckForErrors(SelectedSystems, Project.CurrentProject.ControllerList.FindAll(c => c.ControlGroupID == _group.Id).Count);
            }
        }