示例#1
0
        private void Button_CreateLineGroup_Click(object sender, EventArgs e)
        {
            StreamHeaderGroup HeaderGroup = new StreamHeaderGroup();

            HeaderGroup.HeaderName = "New_Line_Group";

            TreeNode NewHeaderNode = new TreeNode();

            NewHeaderNode.Text = "New_Line_Group";
            NewHeaderNode.Tag  = HeaderGroup;
            linesTree.Nodes.Add(NewHeaderNode);
        }
示例#2
0
        private void Button_CreateLineGroup_Click(object sender, EventArgs e)
        {
            StreamHeaderGroup HeaderGroup = new StreamHeaderGroup();

            HeaderGroup.HeaderName = "New_Line_Group";

            TreeNode NewHeaderNode = new TreeNode();

            NewHeaderNode.Text = "New_Line_Group";
            NewHeaderNode.Tag  = HeaderGroup;
            linesTree.Nodes.Add(NewHeaderNode);

            Text          = Language.GetString("$STREAM_EDITOR_TITLE") + "*";
            bIsFileEdited = true;
        }
示例#3
0
        private void UpdateStream()
        {
            List <StreamLine>              lines          = new List <StreamLine>();
            List <StreamLoader>            loaders        = new List <StreamLoader>();
            Dictionary <int, StreamLoader> currentLoaders = new Dictionary <int, StreamLoader>();
            Dictionary <int, bool>         temp           = new Dictionary <int, bool>();

            foreach (TreeNode node in linesTree.Nodes)
            {
                StreamHeaderGroup HeaderGroup = (StreamHeaderGroup)node.Tag;
                Debug.Assert(HeaderGroup != null, "We expect to be looking at a valid HeaderGroup.");

                foreach (TreeNode child in node.Nodes)
                {
                    StreamLine line = (child.Tag as StreamLine);
                    line.lineID = lines.Count;
                    line.Group  = HeaderGroup.HeaderName;

                    lines.Add(line);
                    temp = new Dictionary <int, bool>();

                    for (int i = 0; i != currentLoaders.Count; i++)
                    {
                        temp.Add(currentLoaders.ElementAt(i).Key.GetHashCode(), false);
                    }

                    foreach (var loader in currentLoaders)
                    {
                        foreach (var load in line.loadList)
                        {
                            if (loader.Key == load.GetHashCode())
                            {
                                temp[loader.Key] = true;
                            }
                        }
                    }

                    for (int i = 0; i != temp.Count;)
                    {
                        if (temp.ElementAt(i).Value == false)
                        {
                            loaders.Add(currentLoaders[temp.ElementAt(i).Key]);
                            currentLoaders.Remove(temp.ElementAt(i).Key);
                            temp.Remove(temp.ElementAt(i).Key);
                        }
                        else
                        {
                            i++;
                        }
                    }

                    foreach (StreamLoader loader in line.loadList)
                    {
                        if (!currentLoaders.ContainsKey(loader.GetHashCode()))
                        {
                            loader.start = line.lineID;
                            loader.end   = line.lineID;
                            currentLoaders.Add(loader.GetHashCode(), loader);
                            temp.Add(loader.GetHashCode(), true);
                        }
                        else
                        {
                            currentLoaders[loader.GetHashCode()].end = line.lineID;
                        }
                    }
                }
            }
            foreach (var loader in currentLoaders)
            {
                loaders.Add(loader.Value);
            }

            currentLoaders = null;
            temp           = null;

            Sort(loaders);
            Dictionary <int, List <StreamLoader> > organised = new Dictionary <int, List <StreamLoader> >();
            List <StreamGroup> groups = new List <StreamGroup>();

            for (int i = 0; i < groupTree.Nodes.Count; i++)
            {
                var group = (groupTree.Nodes[i].Tag as StreamGroup);
                if (!organised.ContainsKey(i))
                {
                    organised.Add(i, new List <StreamLoader>());
                    groups.Add(group);
                }
            }

            foreach (StreamLoader pair in loaders)
            {
                // The main idea of this is to find if the user has changed the group.
                // We have to iterate through the groups first and find out if this change has indeed happened.
                for (int i = 0; i < groups.Count; i++)
                {
                    var group = groups[i];

                    // If there the user has assigned a preferred group then we can look for that too.
                    // To make sure we are saving everything necessary, lets just replace everything relating to groups.
                    if (pair.PreferredGroup == group.Name)
                    {
                        pair.AssignedGroup = group.Name;
                        pair.GroupID       = i;
                        pair.Type          = group.Type;
                        break;
                    }

                    // So we check if they have modified - if yes, then we reset the group assignment so the toolkit
                    // treats this as a newly created StreamLoader.
                    if (pair.AssignedGroup == group.Name)
                    {
                        if (pair.Type != group.Type)
                        {
                            pair.AssignedGroup = string.Empty;
                            pair.GroupID       = -1;
                        }
                        break;
                    }
                }

                // This will handle any non-declared group assignments.
                if (string.IsNullOrEmpty(pair.AssignedGroup) && pair.GroupID == -1)
                {
                    if (pair.Type != GroupTypes.Null)
                    {
                        for (int i = 0; i < groups.Count; i++)
                        {
                            var group = groups[i];
                            if (group.Type == pair.Type)
                            {
                                pair.GroupID       = i;
                                pair.AssignedGroup = group.Name;
                                break;
                            }
                        }
                    }
                }

                if (!organised.ContainsKey(pair.GroupID))
                {
                    organised.Add(pair.GroupID, new List <StreamLoader>());
                    organised[pair.GroupID].Add(pair);
                }
                else
                {
                    organised[pair.GroupID].Add(pair);
                }
            }

            List <StreamLoader> streamLoaders = new List <StreamLoader>();
            int idx = 0;

            foreach (KeyValuePair <int, List <StreamLoader> > pair in organised)
            {
                var group = groups[idx];
                group.startOffset = streamLoaders.Count;
                streamLoaders.AddRange(pair.Value);
                group.endOffset = streamLoaders.Count - group.startOffset;
                idx++;
            }

            stream.Lines   = lines.ToArray();
            stream.Groups  = groups.ToArray();
            stream.Loaders = streamLoaders.ToArray();
        }
示例#4
0
        private void BuildData()
        {
            linesTree.Nodes.Clear();
            blockView.Nodes.Clear();
            groupTree.Nodes.Clear();
            PropertyGrid_Stream.SelectedObject = null;
            stream = new StreamMapLoader(file);

            for (int i = 0; i < stream.GroupHeaders.Length; i++)
            {
                TreeNode node = new TreeNode("group" + i);
                node.Text = stream.GroupHeaders[i];
                StreamHeaderGroup HeaderGroup = new StreamHeaderGroup();
                HeaderGroup.HeaderName = node.Text;
                node.Tag = HeaderGroup;
                linesTree.Nodes.Add(node);
            }
            for (int i = 0; i < stream.Groups.Length; i++)
            {
                var      line = stream.Groups[i];
                TreeNode node = new TreeNode();
                node.Name = "GroupLoader" + i;
                node.Text = line.Name;
                node.Tag  = line;

                for (int x = line.startOffset; x < line.startOffset + line.endOffset; x++)
                {
                    var loader = stream.Loaders[x];
                    loader.AssignedGroup = line.Name;
                    loader.GroupID       = i;
                }

                groupTree.Nodes.Add(node);
            }
            for (int i = 0; i != stream.Lines.Length; i++)
            {
                var      line = stream.Lines[i];
                TreeNode node = new TreeNode();
                node.Name = line.Name;
                node.Text = line.Name;
                node.Tag  = line;

                List <StreamLoader> list = new List <StreamLoader>();
                for (int x = 0; x < stream.Loaders.Length; x++)
                {
                    var loader = stream.Loaders[x];
                    if (line.lineID >= loader.start && line.lineID <= loader.end)
                    {
                        var newLoader = new StreamLoader(loader);
                        list.Add(newLoader);
                    }
                }
                line.loadList = list.ToArray();
                linesTree.Nodes[line.groupID].Nodes.Add(node);
            }
            for (int i = 0; i < stream.Blocks.Length; i++)
            {
                TreeNode node = new TreeNode();
                node.Name = "Block" + i;
                node.Text = "Block: " + i;
                node.Tag  = stream.Blocks[i];
                blockView.Nodes.Add(node);
            }
        }