Esempio n. 1
0
        public byte[] Read(ref StructureTreeNode chunkToRead)
        {
            byte[] data = new byte[chunkToRead.Length];
            long   oldStreamPosition = Parser.Stream.Position;

            Parser.Stream.Seek(chunkToRead.Offset, System.IO.SeekOrigin.Begin);

            int bytesRead = Parser.Stream.Read(data, 0, (int)chunkToRead.Length);

            if (bytesRead != chunkToRead.Length)
            {
                throw new ParseException("error reading chunk, could not get number of data to read from stream");
            }
            Parser.Stream.Seek(oldStreamPosition, System.IO.SeekOrigin.Begin);

            return(data);
        }
Esempio n. 2
0
        /// <summary>
        ///     Called when the drop operation is performed on this text box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Editor_DragDropHandler(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("WindowsForms10PersistentObject", false))
            {
                object       data       = e.Data.GetData("WindowsForms10PersistentObject");
                BaseTreeNode sourceNode = data as BaseTreeNode;
                if (sourceNode != null)
                {
                    VariableTreeNode variableNode = sourceNode as VariableTreeNode;
                    if (variableNode != null)
                    {
                        EditionTextBox.SelectedText = SetVariable(variableNode.Item);
                    }
                    else
                    {
                        StructureTreeNode structureTreeNode = sourceNode as StructureTreeNode;
                        if (structureTreeNode != null)
                        {
                            TextualExplanation text = new TextualExplanation();

                            Structure structure = structureTreeNode.Item;
                            CreateDefaultStructureValue(text, structure);
                            EditionTextBox.SelectedText = text.Text;
                        }
                        else
                        {
                            EditionTextBox.SelectedText = StripUseless(sourceNode.Model.FullName, WritingContext());
                        }
                    }
                }

                OLVListItem item = data as OLVListItem;
                if (item != null)
                {
                    IVariable variable = item.RowObject as IVariable;
                    if (variable != null)
                    {
                        EditionTextBox.SelectedText = SetVariable(variable);
                    }
                }
            }
        }