コード例 #1
0
 public override void WriteBinary(ESPWriter writer)
 {
     if (PartNode != null)
     {
         PartNode.WriteBinary(writer);
     }
     if (VATSTarget != null)
     {
         VATSTarget.WriteBinary(writer);
     }
     if (IKDataStartNode != null)
     {
         IKDataStartNode.WriteBinary(writer);
     }
     if (Data != null)
     {
         Data.WriteBinary(writer);
     }
     if (LimbReplacementModel != null)
     {
         LimbReplacementModel.WriteBinary(writer);
     }
     if (GoreEffectsTargetBone != null)
     {
         GoreEffectsTargetBone.WriteBinary(writer);
     }
     if (TextureFileHashes != null)
     {
         TextureFileHashes.WriteBinary(writer);
     }
 }
コード例 #2
0
ファイル: GraphCreator.cs プロジェクト: dongcd/vs-mef
        /// <summary>
        /// Method to check if a given potential edge is valid or not.
        /// </summary>
        /// <param name="source">The PartNode that would be the source of the potential edge.</param>
        /// <param name="edge">The PartEdge indicating an outgoing edge from the Source Node.</param>
        /// <returns> A boolean indicating if the specified edge should be included in the graph or not.</returns>
        private bool ValidEdge(PartNode source, PartEdge edge)
        {
            string sourceName = source.Name;
            string targetName = edge.Target.Name;

            return(this.RejectionGraph.ContainsKey(sourceName) &&
                   this.RejectionGraph.ContainsKey(targetName));
        }
コード例 #3
0
 /// <summary>
 /// Adds a node to a list if the node and node name is not null and if the list doesn't contains the node already.
 /// </summary>
 /// <param name="node">The node to add.</param>
 /// <param name="list">The list to add to.</param>
 private static void AddNode(PartNode node, List <PartNode> list)
 {
     if (node != null && !string.IsNullOrEmpty(node.Name) && !list.Contains(node))
     {
         Messenger.AddInfo(string.Format(Messages.MSG_PART_FOUND_AND_ADDED_0, node.Name));
         list.Add(node);
     }
 }
コード例 #4
0
        /// <summary>
        /// Opens the Part Editor with the passed PartNode.
        /// </summary>
        /// <param name="partNode">The part node to edit.</param>
        public static void EditPart(PartNode partNode)
        {
            frmPartEditor dlg = new frmPartEditor();

            dlg.Title      = partNode.Title;
            dlg.PartName   = partNode.Name;
            dlg.Category   = partNode.Category;
            dlg.KnownNames = (from PartNode part in allNodes select part.Name).ToList();
            if (dlg.ShowDialog(View.ParentForm) == DialogResult.OK)
            {
                string fullPath = KSPPathHelper.GetAbsolutePath(partNode.FilePath);
                if (File.Exists(fullPath))
                {
                    string allText = File.ReadAllText(fullPath);
                    if (partNode.Name != dlg.NewName)
                    {
                        if (!ChangeParameter(ref allText, partNode.Name, NAME, partNode.Name, dlg.NewName))
                        {
                            return;
                        }

                        Messenger.AddInfo(string.Format(Messages.MSG_NAME_OF_PART_0_CHANGED_1, partNode.Name, dlg.NewName));
                        partNode.Name = dlg.NewName;
                    }
                    if (partNode.Title != dlg.NewTitle)
                    {
                        if (!ChangeParameter(ref allText, partNode.Name, TITLE, partNode.Title, dlg.NewTitle))
                        {
                            return;
                        }

                        Messenger.AddInfo(string.Format(Messages.MSG_TITLE_OF_PART_0_CHANGED_FROM_1_TO_2, partNode.Name, partNode.Title, dlg.NewTitle));
                        partNode.Title = dlg.NewTitle;
                    }
                    if (partNode.Category != dlg.NewCategory)
                    {
                        if (!ChangeParameter(ref allText, partNode.Name, CATEGORY, partNode.Category, dlg.NewCategory))
                        {
                            return;
                        }

                        Messenger.AddInfo(string.Format(Messages.MSG_CATEGORY_OF_PART_0_CHANGED_FROM_1_TO_2, partNode.Name, partNode.Category, dlg.NewCategory));
                        partNode.Category = dlg.NewCategory;

                        foreach (var node in partNode.Nodes)
                        {
                            if (node.Text.StartsWith("Category = "))
                            {
                                node.Text = "Category = " + partNode.Category;
                                break;
                            }
                        }
                    }
                    File.WriteAllText(fullPath, allText);
                }
            }
        }
コード例 #5
0
        public frmEdit()
        {
            InitializeComponent();
            PartNode pnode = new PartNode(Application.WorkingDatabase.Root, false);
            var      root  = pnode.Node;

            treeView1.Nodes.Add(root);
            root.ExpandAll();
        }
コード例 #6
0
        /// <summary>
        /// Parses the line for part informations.
        /// </summary>
        /// <param name="file">Full path to the part cfg file.</param>
        /// <param name="line">The line to parse.</param>
        /// <param name="partNode">The node to write the informations to.</param>
        private static void ParsePartLine(string file, string line, ref PartNode partNode)
        {
            string tempLine = line.Trim();

            // TODO: change name to title!
            if (tempLine.ToLower().StartsWith("name =") || tempLine.ToLower().StartsWith("name="))
            {
                string[] nameValuePair = tempLine.Split('=');
                if (nameValuePair.Length != 2)
                {
                    Messenger.AddError(string.Format(Messages.MSG_ERROR_DURING_PART_READING_0_NAME_TITLE_MISSMATCH, file));
                }

                else
                {
                    string name = nameValuePair[1].Trim();
                    partNode.Title = name;
                    partNode.Name  = name;
                }
            }

            else if (tempLine.ToLower().StartsWith("title =") || tempLine.ToLower().StartsWith("title="))
            {
                string[] nameValuePair = tempLine.Split('=');
                if (nameValuePair.Length != 2)
                {
                    Messenger.AddError(string.Format(Messages.MSG_ERROR_DURING_PART_READING_0_NAME_TITLE_MISSMATCH, file));
                }

                else
                {
                    string name = nameValuePair[1].Trim();
                    partNode.Title = name;
                }
            }

            else if (tempLine.ToLower().StartsWith("category =") || tempLine.ToLower().StartsWith("category="))
            {
                string[] nameValuePair = tempLine.Split('=');
                if (nameValuePair.Length != 2)
                {
                    Messenger.AddError(string.Format(Messages.MSG_ERROR_DURING_PART_READING_0_NAME_TITLE_MISSMATCH, file));
                }

                else
                {
                    int    categoryIndex = -1;
                    string category      = nameValuePair[1].Trim();
                    if (int.TryParse(category, out categoryIndex))
                    {
                        category = TranslateCategoryIndex(categoryIndex);
                    }
                    partNode.Category = category;
                }
            }
        }
コード例 #7
0
ファイル: GraphCreator.cs プロジェクト: dongcd/vs-mef
 internal static string GetNodeName(PartNode current)
 {
     if (current.HasExports)
     {
         return(ContainerStart + current.Name);
     }
     else
     {
         return(current.Name);
     }
 }
コード例 #8
0
ファイル: GraphCreator.cs プロジェクト: dongcd/vs-mef
        /// <summary>
        /// Method to convert from custom Node representation to the DGML node representation.
        /// </summary>
        /// <param name="current">The PartNode object which we want to convert.</param>
        /// <returns> A DGML Node representation of the input PartNode.</returns>
        private Node NodeConverter(PartNode current)
        {
            string nodeName    = GetNodeName(current);
            Node   convertered = new Node
            {
                Id       = nodeName,
                Category = current.IsRejectionExpected ? Strings.RejectionExpectedLabel : NormalNodeLabel,
                Group    = current.HasExports ? ContainerString : null,
            };

            convertered.Properties.Add("Level", current.Level.ToString());
            return(convertered);
        }
コード例 #9
0
        public Node GetGeometryRootNode(IEnumerable <Node> geometryNodes, PartNode partsTree, string modelName)
        {
            var rootNode = new Node()
            {
                Id   = modelName,
                Name = modelName
            };

            var root = geometryNodes.Single(g => g.Id == $"{modelName}-Part-{partsTree.Id}");

            foreach (var child in partsTree.Children)
            {
                root.NodeProperty.Add(GetGeometryRootNode(geometryNodes, child, modelName));
            }
            return(root);
        }
コード例 #10
0
        /// <summary>
        /// Creates a new default TreeNodePart.
        /// </summary>
        /// <param name="file">The full path of the part cfg file.</param>
        /// <returns>The new created PartNode from the passed file.</returns>
        private static PartNode CreateNewPartNode(string file)
        {
            PartNode partNode = new PartNode();

            partNode.FilePath = KSPPathHelper.GetRelativePath(file);
            if (file.Contains(Constants.GAMEDATA))
            {
                string mod = file.Substring(file.IndexOf(Constants.GAMEDATA) + 9);
                mod          = mod.Substring(0, mod.IndexOf(Path.DirectorySeparatorChar));
                partNode.Mod = mod;

                if (!allModFilter.Contains(mod))
                {
                    allModFilter.Add(mod);
                }
            }

            return(partNode);
        }
コード例 #11
0
        public override void WriteXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (PartNode != null)
            {
                ele.TryPathTo("PartNode", true, out subEle);
                PartNode.WriteXML(subEle, master);
            }
            if (VATSTarget != null)
            {
                ele.TryPathTo("VATSTarget", true, out subEle);
                VATSTarget.WriteXML(subEle, master);
            }
            if (IKDataStartNode != null)
            {
                ele.TryPathTo("IKData/StartNode", true, out subEle);
                IKDataStartNode.WriteXML(subEle, master);
            }
            if (Data != null)
            {
                ele.TryPathTo("Data", true, out subEle);
                Data.WriteXML(subEle, master);
            }
            if (LimbReplacementModel != null)
            {
                ele.TryPathTo("LimbReplacementModel", true, out subEle);
                LimbReplacementModel.WriteXML(subEle, master);
            }
            if (GoreEffectsTargetBone != null)
            {
                ele.TryPathTo("GoreEffectsTargetBone", true, out subEle);
                GoreEffectsTargetBone.WriteXML(subEle, master);
            }
            if (TextureFileHashes != null)
            {
                ele.TryPathTo("TextureFileHashes", true, out subEle);
                TextureFileHashes.WriteXML(subEle, master);
            }
        }
コード例 #12
0
ファイル: HomeController.cs プロジェクト: tasinsahin/BLocal
        public ActionResult ShowImportExport(String providerConfigName)
        {
            var providerPair = FetchProviderPair(providerConfigName);
            var allValues    = providerPair.ValueManager.GetAllValuesQualified().ToArray();
            var allParts     = allValues.Select(value => value.Qualifier.Part).Distinct().OrderBy(p => p.ToString()).ToArray();
            var allLocales   = allValues.Select(value => value.Qualifier.Locale).Distinct().OrderBy(l => l.ToString()).ToArray();

            var partNodes = new Dictionary <Part, PartNode>();

            foreach (var part in allParts)
            {
                var isRoot = part.Parent == null;
                var node   = new PartNode(part, isRoot);

                partNodes.Add(part, node);
                if (!isRoot)
                {
                    var fixNode = node;
                    while (fixNode.Part.Parent != null)
                    {
                        var parentNode = new PartNode(fixNode.Part.Parent, fixNode.Part.Parent.Parent == null);
                        if (partNodes.ContainsKey(parentNode.Part))
                        {
                            partNodes[parentNode.Part].SubParts.Add(fixNode);
                            break;
                        }

                        partNodes.Add(parentNode.Part, parentNode);
                        parentNode.SubParts.Add(fixNode);
                        fixNode = parentNode;
                    }
                }
            }
            foreach (var part in allParts.Where(part => part.Parent != null))
            {
                partNodes.Remove(part);
            }

            return(View(new ImportExportData(partNodes.Values, allLocales, providerConfigName)));
        }
コード例 #13
0
ファイル: GraphCreator.cs プロジェクト: dongcd/vs-mef
        /// <summary>
        /// Method to get all the outgoing edges from the current node.
        /// </summary>
        /// <param name="current">The PartNode whose outgoing edges we want to find.</param>
        /// <returns> A list of Links that represent the outgoing edges for the input node.</returns>
        private IEnumerable <Link> EdgeGenerator(PartNode current)
        {
            // Add edges for import/exports between parts
            if (current.RejectsCaused != null)
            {
                foreach (var outgoingEdge in current.RejectsCaused)
                {
                    if (this.ValidEdge(current, outgoingEdge))
                    {
                        string sourceName = GetNodeName(current);
                        string targetName = GetNodeName(outgoingEdge.Target);
                        Link   edge       = new Link
                        {
                            Source   = sourceName,
                            Target   = targetName,
                            Label    = outgoingEdge.Label,
                            Category = EdgeLabel,
                        };
                        yield return(edge);
                    }
                }
            }

            // Create containers for the parts that have exports for the current part
            if (current.HasExports)
            {
                string sourceName = GetNodeName(current);
                foreach (var exportName in current.ExportingContracts)
                {
                    yield return(new Link
                    {
                        Source = sourceName,
                        Target = exportName,
                        Category = ContainerLabel,
                    });
                }
            }
        }
コード例 #14
0
 public void populateCommandSelections(CommandSelections selections)
 {
     selections.ClearModel();
     if (PartNode != null)
     {
         selections.SelectedPart = PartNode.getPart();
     }
     foreach (MeasureTreeNode node in MeasureNodes)
     {
         selections.SelectedMeasure.Add(node.getMeasure());
     }
     foreach (ChordTreeNode node in ChordNodes)
     {
         selections.SelectedChord.Add(node.getChord());
     }
     foreach (NoteTreeNode node in NoteNodes)
     {
         selections.SelectedNote.Add(node.getNote());
     }
     if (EffectNode != null)
     {
         selections.SelectedEffect = EffectNode.getEffect();
     }
 }
コード例 #15
0
        private void Pack_recursive(PartList parts, BoardList boards, PartList TemporarySolution, double tempSolutionArea)
        {
            // loop through remaining parts
            for (PartNode iPart = parts.Tail; iPart != null; iPart = iPart.Prev)
            {
                #region // check if the part is a viable candidate ...
                // if this part has bigger area than the largest board segment available, go to next part
                if (iPart.Area > boards.Tail.Area)
                {
                    continue;
                }
                // if the previous part was the same size, pass this one - we already completed this iteration
                if (iPart != parts.Tail && iPart.Length == iPart.Next.Length && iPart.Width == iPart.Next.Width)
                {
                    continue;
                }
                #endregion

                #region // Find first board that will fit the part ...
                // find first board that will accomodate the part
                BoardNode iBoard = boards.Head;

                // if even the last (bigest) board had a smaller area than the part, non of the rest will fit
                while (iPart.Area > iBoard.Area)
                {
                    iBoard = iBoard.Next;
                }
                while (iBoard != null && (iPart.Length > iBoard.Length || iPart.Width > iBoard.Width))
                {
                    iBoard = iBoard.Next;
                }
                if (iBoard == null)
                {
                    continue; // if this part cannot fit any board, continue to next part
                }
                #endregion

                #region // place the part ...
                double newPackedPartsArea = tempSolutionArea + iPart.Area;
                //append the part to the list of packed parts
                TemporarySolution.Append(new PartNode(iPart)
                {
                    Container = iBoard.ID,
                    dWidth    = iBoard.dWidth,
                    dLength   = iBoard.dLength
                });
                #endregion

                #region // store best solution ...
                //if this is a better solution than the current best one ... replace the current best one
                if (newPackedPartsArea > currentSolutionArea)
                {
                    currentSolutionArea = newPackedPartsArea;
                    currentSolution     = new PartList(TemporarySolution);
                }
                #endregion

                // if there are no more parts, break out of the loop
                if (parts.Count == 1)
                {
                    break;
                }

                #region // Break association and adjust associate if a board is used that is associated with another to prevent overlapping placements ...
                BoardNode iAssocBoard = iBoard.AssociatedBoard;
                double    oAssocLength = 0, oAssocWidth = 0;
                // if the board section used has a buddy from a previous placement, adjust the buddy and break the association
                if (iAssocBoard != null)
                {
                    oAssocLength = iAssocBoard.Length;
                    oAssocWidth  = iAssocBoard.Width;;

                    //we have to adjust the buddy, so as not to place another part on the overlapping area
                    if (iBoard.dWidth < iAssocBoard.dWidth)
                    {
                        //if this is Rem1
                        //if the part is wider than the left portion of Rem1
                        if (iBoard.dWidth + iPart.Width + sawkerf > iAssocBoard.dWidth)
                        {
                            iAssocBoard.Length -= (iBoard.Length + sawkerf);
                        }
                        else
                        {
                            iBoard.Width -= (iAssocBoard.Width + sawkerf);
                        }
                    }
                    else
                    {
                        //if this is Rem2
                        if (iBoard.dLength + iPart.Length + sawkerf > iAssocBoard.dLength)
                        {
                            iAssocBoard.Width -= (iBoard.Width + sawkerf);
                        }
                        else
                        {
                            iBoard.Length -= (iAssocBoard.Length + sawkerf);
                        }
                    }

                    //then break the pair
                    iAssocBoard.AssociatedBoard = null;
                    iBoard.AssociatedBoard      = null;
                }
                #endregion

                #region // remove the current part from the parts list ...
                parts.Remove(iPart);
                #endregion

                #region // replace the used board with 2 overlapping remainder pieces after subtracting the part ...
                // divide the board into two overlapping remainder sections
                boards.Remove(iBoard);
                BoardNode boardSection1 = null;
                double    l             = iBoard.Length - iPart.Length - sawkerf;
                if (l * iBoard.Width >= parts.Head.Area)
                {
                    boardSection1 = new BoardNode(iBoard.ID, l, iBoard.Width, iBoard.dLength + iPart.Length + sawkerf, iBoard.dWidth);
                    boards.InsertItemSortedbyAreaAsc(boardSection1);
                }
                BoardNode boardSection2 = null;
                double    w             = iBoard.Width - iPart.Width - sawkerf;
                if (w * iBoard.Length >= parts.Head.Area)
                {
                    boardSection2 = new BoardNode(iBoard.ID, iBoard.Length, w, iBoard.dLength, iBoard.dWidth + iPart.Width + sawkerf);
                    boards.InsertItemSortedbyAreaAsc(boardSection2);
                    boardSection2.AssociatedBoard = boardSection1;
                    if (boardSection1 != null)
                    {
                        boardSection1.AssociatedBoard = boardSection2;
                    }
                }
                #endregion

                if (boards.Count > 0)
                {
                    #region // pack the remaining parts on the remaining boards ...
                    // pack the remaining parts on the remaining boards
                    Pack_recursive(parts, boards, TemporarySolution, newPackedPartsArea);
                    #endregion
                }

                #region // undo the placement so we can iterate to the next part and test with it ...
                // place the current part back in its exact place ...
                parts.Return(iPart);

                // remove the remainder board sections we added...
                if (boardSection1 != null)
                {
                    boards.Remove(boardSection1);
                }
                if (boardSection2 != null)
                {
                    boards.Remove(boardSection2);
                }

                // restore associations, and the original associated board's size
                if (iAssocBoard != null)
                {
                    iBoard.AssociatedBoard      = iAssocBoard;
                    iAssocBoard.AssociatedBoard = iBoard;
                    iAssocBoard.Length          = oAssocLength;
                    iAssocBoard.Width           = oAssocWidth;
                }

                // place the board back
                if (iBoard.Prev == null)
                {
                    boards.Head = iBoard;
                }
                else
                {
                    iBoard.Prev.Next = iBoard;
                }
                if (iBoard.Next == null)
                {
                    boards.Tail = iBoard;
                }
                else
                {
                    iBoard.Next.Prev = iBoard;
                }
                boards.Count++;

                // remove the part from the temporary solution
                TemporarySolution.Tail = TemporarySolution.Tail.Prev;
                if (TemporarySolution.Tail != null)
                {
                    TemporarySolution.Tail.Next = null;
                }
                else
                {
                    TemporarySolution.Head = null;
                }
                TemporarySolution.Count--;

                #endregion
            }
        }
コード例 #16
0
ファイル: PartEdge.cs プロジェクト: dongcd/vs-mef
 /// <summary>
 /// Initializes a new instance of the <see cref="PartEdge"/> class.
 /// </summary>
 /// <param name="other">The Node at the tail of the edge.</param>
 /// <param name="description">The label associated with the node.</param>
 internal PartEdge(PartNode other, string description)
 {
     this.Target = other;
     this.Label  = description;
 }
コード例 #17
0
        private void Select(TreeNode node)
        {
            PartNode pnode = node.Tag as PartNode;

            odxListView1.Folder = pnode.Part as PartFolder;
        }
コード例 #18
0
        /// <summary>
        /// Removes the part from KSP and unchecks it in the mod selection.
        /// </summary>
        /// <param name="partNode">The part node to remove.</param>
        public static void RemovePart(PartNode partNode)
        {
            if (partNode == null)
            {
                return;
            }

            string  partPath = Path.GetDirectoryName(KSPPathHelper.GetAbsolutePath(partNode.FilePath));
            ModNode node     = ModSelectionTreeModel.SearchNodeByDestination(partNode.FilePath, ModSelectionController.Model);

            DialogResult dlgResult = DialogResult.Cancel;

            if (node == null)
            {
                dlgResult = MessageBox.Show(View.ParentForm, Messages.MSG_PART_NOT_FROM_MOD_DELETE_WARNING, string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            }

            if (partNode.Nodes != null && partNode.Nodes.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(Messages.MSG_PART_USED_DELETE_WARNING);
                foreach (PartNode tempNode in partNode.Nodes)
                {
                    sb.AppendFormat("- {0}{1}", tempNode.Title, Environment.NewLine);
                }
                sb.AppendLine();
                sb.AppendLine(Messages.MSG_DELETE_ANYWAY);
                dlgResult = MessageBox.Show(View.ParentForm, sb.ToString(), string.Empty, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            }

            if ((node != null || dlgResult == DialogResult.Yes) && Directory.Exists(partPath))
            {
                Messenger.AddInfo(string.Format(Messages.MSG_DIR_0_OF_PART_1_DELETED, partPath, Path.GetFileName(partPath)));
                Directory.Delete(partPath, true);

                if (partNode.Nodes != null)
                {
                    foreach (var n in partNode.Nodes)
                    {
                        var craft = n.Tag as CraftNode;
                        if (craft == null)
                        {
                            continue;
                        }

                        craft.RemovePartRelation(partNode);
                    }
                }

                if (node != null)
                {
                    node = node.Parent as ModNode;
                    node.SetChecked(false);
                    node.IsInstalled = false;
                    node.NodeType    = NodeType.UnknownFolder;
                    Messenger.AddInfo(string.Format(Messages.MSG_MODNODE_0_UNCHECKED, node.Name));
                    foreach (ModNode child in node.Nodes)
                    {
                        child.SetChecked(false);
                        child.IsInstalled = false;
                        child.NodeType    = child.IsFile ? NodeType.UnknownFile : NodeType.UnknownFolder;
                        Messenger.AddInfo(string.Format(Messages.MSG_MODNODE_0_UNCHECKED, child.Name));
                    }
                }

                model.Nodes.Remove(partNode);
                allNodes.Remove(partNode);
            }
        }
コード例 #19
0
        public override void ReadXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ele.TryPathTo("PartNode", false, out subEle))
            {
                if (PartNode == null)
                {
                    PartNode = new SimpleSubrecord <String>();
                }

                PartNode.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("VATSTarget", false, out subEle))
            {
                if (VATSTarget == null)
                {
                    VATSTarget = new SimpleSubrecord <String>();
                }

                VATSTarget.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("IKData/StartNode", false, out subEle))
            {
                if (IKDataStartNode == null)
                {
                    IKDataStartNode = new SimpleSubrecord <String>();
                }

                IKDataStartNode.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Data", false, out subEle))
            {
                if (Data == null)
                {
                    Data = new BodyPartInfo();
                }

                Data.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("LimbReplacementModel", false, out subEle))
            {
                if (LimbReplacementModel == null)
                {
                    LimbReplacementModel = new SimpleSubrecord <String>();
                }

                LimbReplacementModel.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("GoreEffectsTargetBone", false, out subEle))
            {
                if (GoreEffectsTargetBone == null)
                {
                    GoreEffectsTargetBone = new SimpleSubrecord <String>();
                }

                GoreEffectsTargetBone.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("TextureFileHashes", false, out subEle))
            {
                if (TextureFileHashes == null)
                {
                    TextureFileHashes = new SimpleSubrecord <Byte[]>();
                }

                TextureFileHashes.ReadXML(subEle, master);
            }
        }
コード例 #20
0
        /// <summary>
        /// Parses the file content and creates a PartNode foreach found part.
        /// </summary>
        /// <param name="file">Full path to the part file.</param>
        /// <returns>A list of PartNodes from the passed file.</returns>
        private static List <PartNode> CreatePartNodes(string file)
        {
            var result = new List <PartNode>();

            if (string.IsNullOrEmpty(file))
            {
                return(result);
            }

            string[] lines = File.ReadLines(file).ToArray();
            if (lines.Length == 0)
            {
                return(result);
            }

            int      braceCount      = 0;
            bool     isPartFile      = false;
            bool     isWithinPartDev = false;
            PartNode partNode        = null;

            foreach (string line in lines)
            {
                if (line == null)
                {
                    Messenger.AddError(string.Format(Messages.MSG_ERROR_DURING_PART_READING_0_UNEXPECTED_EMPTY_LINE, file));
                    continue;
                }

                if (line.ToLower().Trim().StartsWith("part {") || line.ToLower().Trim().StartsWith("part{"))
                {
                    isPartFile      = true;
                    isWithinPartDev = true;
                    braceCount     += 1;
                    AddNode(partNode, result);
                    partNode = CreateNewPartNode(file);
                }

                else if (line.ToLower().Trim().StartsWith("part"))
                {
                    isPartFile = true;
                }

                else if (line.Trim().StartsWith("{") || (!line.Contains("//") && line.Contains("{")))
                {
                    braceCount += 1;
                    if (braceCount == 1 && isPartFile)
                    {
                        isWithinPartDev = true;
                        AddNode(partNode, result);
                        partNode = CreateNewPartNode(file);
                    }
                    else
                    {
                        isWithinPartDev = false;
                    }
                }

                else if (line.Trim().StartsWith("}"))
                {
                    braceCount -= 1;
                    if (braceCount == 1 && isPartFile)
                    {
                        isWithinPartDev = true;
                    }
                    else if (braceCount > 1)
                    {
                        isWithinPartDev = false;
                    }
                    else if (braceCount == 0)
                    {
                        isWithinPartDev = false;
                        AddNode(partNode, result);
                    }
                }

                if (isPartFile && isWithinPartDev)
                {
                    ParsePartLine(file, line, ref partNode);
                }
            }

            AddNode(partNode, result);

            return(result);
        }
コード例 #21
0
        static public PartList Pack(PartList parts, BoardList boards, double sawkerf = 4, double boardMarginLength = 0, double boardMarginWidth = 0, double partPaddingLength = 0, double partPaddingWidth = 0)
        {
            // order the parts by Area, Ascending
            var orderredParts = parts.OrderredByArea();
            var oderredBoards = boards.OrderredByArea();

            // add padding to parts
            orderredParts.InflateAll(partPaddingWidth, partPaddingLength);

            // init the bag for the solution
            PartList completeSolution = new PartList();

            // repeat until all parts are placed, or boards used up
            int iteration = 0;

            while (orderredParts.Count > 0 && oderredBoards.Count > 0)
            {
                // for this iteration, prepare to hold the best board's packing solution
                PartList bestsolution         = null;
                double   bestsolutioncoverage = 0;

                // we will pack each board in its own thread, so we need to track the threads
                List <Task> threads = new List <Task>();

                // loop through the available board sections
                for (BoardNode iBoard = oderredBoards.Head; iBoard != null; iBoard = iBoard.Next)
                {
                    threads.Add(
                        Task.Factory.StartNew((o) =>
                    {
                        Thread.CurrentThread.Priority = ThreadPriority.Highest;
                        // for every board
                        BoardNode tiBoard = new BoardNode((BoardNode)o);
                        // subtract the margin from the board
                        tiBoard.Inflate(-boardMarginWidth, -boardMarginLength);

                        // init a packer object
                        Packer iPacker = new Packer()
                        {
                            boardArea = tiBoard.Area,
                            sawkerf   = sawkerf
                        };

                        // pack the board recursively, starting at the first part and an empty solution
                        iPacker.Pack_recursive(new PartList(orderredParts), new BoardList(tiBoard), new PartList(), 0);

                        //Trace.WriteLine($"......in iteration {iteration+1}: Board {iPacker.currentSolution.Head.Container} packed to {iPacker.currentSolutionArea/iPacker.boardArea:0 %} :\r\n{iPacker.currentSolution.ToString()}");

                        // replace the best solution if this one is better
                        lock (lck)
                            if (iPacker.currentSolutionArea / iPacker.boardArea > bestsolutioncoverage)
                            {
                                bestsolutioncoverage = iPacker.currentSolutionArea / iPacker.boardArea;
                                bestsolution         = iPacker.currentSolution;
                            }
                    }, iBoard));
                }
                Task.WaitAll(threads.ToArray());

                // if no board could be packed, stop
                if (bestsolutioncoverage == 0)
                {
                    Trace.WriteLine("STOPPING: Non of the parts left to place would fit any of the available boards...");
                    break;
                }

                boards[bestsolution.Head.Container].Solution = new PartList(bestsolution);
                // report the best packking for this iteration
                Trace.WriteLine($"Best solution for iteration {++iteration}: Board {bestsolution.Head.Container} packed to {bestsolutioncoverage:0 %} :\r\n{bestsolution.ToString()}");

                // remove best packed board from the list of available boards
                oderredBoards.Remove(bestsolution.Head.Container);

                // remove the parts packed from the list of required parts
                for (PartNode iPart = bestsolution.Head; iPart != null; iPart = iPart.Next)
                {
                    orderredParts.Remove(iPart.ID);
                }

                // add this partial solution to the complete solution...
                completeSolution.Append(bestsolution);
            }

            // return the solution
            return(completeSolution);
        }
コード例 #22
0
 protected bool Equals(PartNode other)
 {
     return Equals(Part, other.Part);
 }
コード例 #23
0
        public override void ReadBinary(ESPReader reader)
        {
            List <string> readTags = new List <string>();

            while (reader.BaseStream.Position < reader.BaseStream.Length)
            {
                string subTag = reader.PeekTag();

                switch (subTag)
                {
                case "BPNN":
                    if (readTags.Contains("BPNN"))
                    {
                        return;
                    }
                    PartNode.ReadBinary(reader);
                    break;

                case "BPNT":
                    if (readTags.Contains("BPNT"))
                    {
                        return;
                    }
                    VATSTarget.ReadBinary(reader);
                    break;

                case "BPNI":
                    if (readTags.Contains("BPNI"))
                    {
                        return;
                    }
                    IKDataStartNode.ReadBinary(reader);
                    break;

                case "BPND":
                    if (readTags.Contains("BPND"))
                    {
                        return;
                    }
                    Data.ReadBinary(reader);
                    break;

                case "NAM1":
                    if (readTags.Contains("NAM1"))
                    {
                        return;
                    }
                    LimbReplacementModel.ReadBinary(reader);
                    break;

                case "NAM4":
                    if (readTags.Contains("NAM4"))
                    {
                        return;
                    }
                    GoreEffectsTargetBone.ReadBinary(reader);
                    break;

                case "NAM5":
                    if (readTags.Contains("NAM5"))
                    {
                        return;
                    }
                    if (TextureFileHashes == null)
                    {
                        TextureFileHashes = new SimpleSubrecord <Byte[]>();
                    }

                    TextureFileHashes.ReadBinary(reader);
                    break;

                default:
                    return;
                }

                readTags.Add(subTag);
            }
        }
コード例 #24
0
ファイル: HomeController.cs プロジェクト: tasinsahin/BLocal
 protected bool Equals(PartNode other)
 {
     return(Equals(Part, other.Part));
 }
コード例 #25
0
        public ActionResult ShowImportExport(String providerConfigName)
        {
            var providerPair = FetchProviderPair(providerConfigName);
            var allValues = providerPair.ValueManager.GetAllValuesQualified().ToArray();
            var allParts = allValues.Select(value => value.Qualifier.Part).Distinct().OrderBy(p => p.ToString()).ToArray();
            var allLocales = allValues.Select(value => value.Qualifier.Locale).Distinct().OrderBy(l => l.ToString()).ToArray();

            var partNodes = new Dictionary<Part, PartNode>();
            foreach (var part in allParts) {
                var isRoot = part.Parent == null;
                var node = new PartNode(part, isRoot);

                partNodes.Add(part, node);
                if (!isRoot) {
                    var fixNode = node;
                    while (fixNode.Part.Parent != null) {
                        var parentNode = new PartNode(fixNode.Part.Parent, fixNode.Part.Parent.Parent == null);
                        if (partNodes.ContainsKey(parentNode.Part)) {
                            partNodes[parentNode.Part].SubParts.Add(fixNode);
                            break;
                        }

                        partNodes.Add(parentNode.Part, parentNode);
                        parentNode.SubParts.Add(fixNode);
                        fixNode = parentNode;
                    }
                }
            }
            foreach (var part in allParts.Where(part => part.Parent != null))
                partNodes.Remove(part);

            return View(new ImportExportData(partNodes.Values, allLocales, providerConfigName));
        }