/// <summary>
        /// Adds a new element at the current position, and updates the current position
        /// </summary>
        /// <param name="element">New element to add</param>
        /// <param name="flags">Print options</param>
        public void AddUIElement(UIElement element, ElementFlags flags)
        {
            element.Measure(_infiniteSize);
            if (CurX > _fixedDocument.DocumentPaginator.PageSize.Width - MarginX)
            {
                CurY += element.DesiredSize.Height;
                CurX  = MarginX;
            }
            double extraCheck = 0;

            if ((flags & ElementFlags.BottomCheck2) == ElementFlags.BottomCheck2)
            {
                extraCheck = element.DesiredSize.Height;
            }
            if (CurY > _fixedDocument.DocumentPaginator.PageSize.Height - MarginY - extraCheck)
            {
                StartPage();
            }
            _curCanvas.Children.Add(element);
            element.SetValue(Canvas.LeftProperty, CurX);
            element.SetValue(Canvas.TopProperty, CurY);
            CurX += element.DesiredSize.Width;
            if ((flags & ElementFlags.NewLine) == ElementFlags.NewLine)
            {
                CurX  = MarginX;
                CurY += element.DesiredSize.Height;
            }
        }
Example #2
0
        public BinElement(byte[] buf, int position, uint stream_length)
        {
            x1          = Util.ReadWord(buf, position + 4);
            y1          = Util.ReadWord(buf, position + 6);
            x2          = Util.ReadWord(buf, position + 8);
            y2          = Util.ReadWord(buf, position + 10);
            width       = Util.ReadWord(buf, position + 12);
            height      = Util.ReadWord(buf, position + 14);
            text_offset = Util.ReadDWord(buf, position + 20);

            flags = (ElementFlags)Util.ReadDWord(buf, position + 24);
            type  = (ElementType)buf[position + 34];

            if (text_offset < stream_length)
            {
                uint text_length = 0;
                while (buf[text_offset + text_length] != 0)
                {
                    text_length++;
                }

                text = Encoding.ASCII.GetString(buf, (int)text_offset, (int)text_length);

                if ((flags & ElementFlags.HasHotkey) == ElementFlags.HasHotkey)
                {
                    hotkey = text[0];
                    text   = text.Substring(1);
                }
            }
            else
            {
                text = "";
            }
        }
 public void WriteElement(Tag tag, ElementFlags flags)
 {
     byte token = (byte)tag;
     if ((flags & ElementFlags.HasAttributes) != 0)
         token |= 0x80;
     if ((flags & ElementFlags.HasChildren) != 0)
         token |= 0x40;
     base.WriteElement(token);
 }
Example #4
0
 /// <summary>  Sets this DataObject and each of its children to the specified empty
 /// state.  An object in the empty state will be written to an XML stream as
 /// an empty element with no attributes and no child elements.
 /// </summary>
 /// <param name="empty">true to set the empty state, false to clear it
 /// </param>
 public virtual void SetEmpty(bool empty)
 {
     if (empty)
     {
         fFlags |= ElementFlags.Empty;
     }
     else
     {
         fFlags &= ~ElementFlags.Empty;
     }
 }
Example #5
0
        /*
         * public override string ToString()
         * {
         *  List<string> strings = new List<string>( 8 );
         *  foreach( string name in elementNames )
         *  {
         *      if( ReflectionHelpers.GetFieldOrProperty<bool>( this, name ) )
         *      {
         *          strings.Add( name );
         *      }
         *  }
         *  return string.Join( " | ", strings.ToArray() );
         * }
         */

        public void SetElementFlagState(ElementFlags flags, bool isSet)
        {
            if (isSet)
            {
                Value |= flags;
            }
            else
            {
                Value &= ~flags;
            }
        }
Example #6
0
 /// <summary>
 /// Called by children when they are set to a "changed" state. The
 /// parent of any child element that is changed should also be marked as
 /// changed (but not any other children of the parent).
 /// </summary>
 protected void SetChildChanged()
 {
     // don't want to recurse children. This just a call
     // to recurse up the chain
     if (!IsChanged())
     {
         fFlags |= ElementFlags.Dirty;
         if (fParent != null)
         {
             fParent.SetChildChanged();
         }
     }
 }
Example #7
0
        /// <summary>  Constructor</summary>
        /// <param name="def">The metadata that describes this Element
        /// </param>
        protected Element(IElementDef def)
        {
            if (def == null)
            {
                throw new ArgumentNullException
                          ("SIF " + Adk.SifVersion +
                          " does not support this element or attribute, or the required Sdo library is not loaded (" +
                          GetType().ToString() + ")");
            }

            fElementDef = def;
            fFlags      = ElementFlags.Dirty;
        }
Example #8
0
 /// <summary>  Sets this DataObject and each of its children to the specified dirty
 /// state. An object in the dirty state will not be written to an XML stream
 /// when a SIF message is rendered.
 /// </summary>
 /// <param name="changed">true to set the dirty state, false to clear it
 /// </param>
 public virtual void SetChanged(bool changed)
 {
     if (changed)
     {
         fFlags |= ElementFlags.Dirty;
         if (fParent != null)
         {
             fParent.SetChildChanged();
         }
     }
     else
     {
         fFlags &= ~ElementFlags.Dirty;
     }
 }
        /// <summary>
        /// Adds a current style TextBox element at the current position
        /// </summary>
        /// <param name="text">Text to add</param>
        /// <param name="width">Width of element</param>
        /// <param name="height">Height of element</param>
        /// <param name="flags">Print options</param>
        public void AddTextBox(string text, double width, double height, ElementFlags flags)
        {
            TextBox tb = new TextBox();

            tb.Text                     = text;
            tb.FontFamily               = CurrentFontFamily;
            tb.FontSize                 = CurrentFontSize;
            tb.FontWeight               = CurrentFontWeight;
            tb.FontStyle                = CurrentFontStyle;
            tb.VerticalAlignment        = VerticalAlignment.Center;
            tb.VerticalContentAlignment = VerticalAlignment.Center;
            if ((flags & ElementFlags.HorzCenter) == ElementFlags.HorzCenter)
            {
                tb.HorizontalContentAlignment = HorizontalAlignment.Center;
            }
            else if ((flags & ElementFlags.HorzRight) == ElementFlags.HorzRight)
            {
                tb.HorizontalContentAlignment = HorizontalAlignment.Right;
            }
            tb.Margin = CurrentElementMargin;
            if (CurrentElementBackground != null)
            {
                tb.Background = CurrentElementBackground;
            }
            if (CurrentElementForeground != null)
            {
                tb.Foreground = CurrentElementForeground;
            }
            Grid grid = new Grid();

            if (CurrentElementBackground != null)
            {
                grid.Background = CurrentElementBackground;
            }
            if (width != 0)
            {
                grid.Width = width;
            }
            if (height != 0)
            {
                grid.Height = height;
            }
            grid.Children.Add(tb);
            AddUIElement(grid, flags);
        }
Example #10
0
        public static List <Primitive> ExtractPrimitives(MDL0Polygon *polygon)
        {
            List <Primitive> list = new List <Primitive>();

            VoidPtr      dataAddr = polygon->PrimitiveData;
            ElementFlags e        = new ElementFlags(polygon->_elemFlags, polygon->_texFlags);
            //ModelEntrySize e = new ModelEntrySize(polygon->_flags);

            int nodeIndex = 0;

            ushort[]  nodeBuffer = new ushort[16];
            Primitive p;

            while ((p = ExtractPrimitive(ref dataAddr, e, nodeBuffer, ref nodeIndex)) != null)
            {
                list.Add(p);
            }

            return(list);
        }
        /// <summary>
        /// Add a current style CheckBox element at the current position
        /// </summary>
        /// <param name="value">Checkbox value to add</param>
        /// <param name="width">Width of element</param>
        /// <param name="height">Height of element</param>
        /// <param name="flags">Print options</param>
        public void AddCheckBox(bool value, double width, double height, ElementFlags flags)
        {
            CheckBox cb = new CheckBox();

            cb.IsChecked         = value;
            cb.VerticalAlignment = VerticalAlignment.Center;
            if ((flags & ElementFlags.HorzCenter) == ElementFlags.HorzCenter)
            {
                cb.HorizontalAlignment = HorizontalAlignment.Center;
            }
            else if ((flags & ElementFlags.HorzRight) == ElementFlags.HorzRight)
            {
                cb.HorizontalAlignment = HorizontalAlignment.Right;
            }
            if (CurrentElementForeground != null)
            {
                cb.Foreground = CurrentElementForeground;
            }
            if (CurrentElementBackground != null)
            {
                cb.Background = CurrentElementBackground;
            }
            Grid grid = new Grid();

            if (CurrentElementBackground != null)
            {
                grid.Background = CurrentElementBackground;
            }
            if (width != 0)
            {
                grid.Width = width;
            }
            if (height != 0)
            {
                grid.Height = height;
            }
            grid.Children.Add(cb);
            AddUIElement(grid, flags);
        }
Example #12
0
        protected Element(SerializationInfo info,
                          StreamingContext context)
        {
            fFlags  = (ElementFlags)info.GetInt32("fFlags");
            fParent = (Element)info.GetValue("fParent", typeof(Element));
            IElementDef foundElementDef = null;
            string      path            = info.GetString("fElementDef.SDOPath");

            if (path.Length > 0)
            {
                foundElementDef = Adk.Dtd.LookupElementDef(path);
            }
            if (foundElementDef == null)
            {
                // TODO:  MLW - I consider this a hack.  On deserialization, the no-arguments constructor is
                // not called.  Also, SIFElements that were serialized without a parent but normally do have a parent
                // are not returned by the lookupElementDef() call above.  To fix this, I instantiate
                // a new object of this type, and then see what the elementdef of that object is.
                SifElement instanceOfThisType =
                    (SifElement)Activator.CreateInstance(this.GetType());
                foundElementDef = instanceOfThisType.ElementDef;
            }
            fElementDef = foundElementDef;
        }
Example #13
0
        public BinElement(byte[] buf, int position, uint stream_length)
        {
            x1 = Util.ReadWord (buf, position + 4);
            y1 = Util.ReadWord (buf, position + 6);
            x2 = Util.ReadWord (buf, position + 8);
            y2 = Util.ReadWord (buf, position + 10);
            width = Util.ReadWord (buf, position + 12);
            height = Util.ReadWord (buf, position + 14);
            text_offset = Util.ReadDWord (buf, position + 20);

            flags = (ElementFlags)Util.ReadDWord (buf, position + 24);
            type = (ElementType)buf[position + 34];

            if (text_offset < stream_length) {
                uint text_length = 0;
                while (buf[text_offset + text_length] != 0) text_length ++;

                text = Encoding.ASCII.GetString (buf, (int)text_offset, (int)text_length);

                if ((flags & ElementFlags.HasHotkey) == ElementFlags.HasHotkey) {
                    hotkey = Encoding.ASCII.GetBytes (new char[] {text[0]})[0];
                    text = text.Substring (1);
                }
            }
            else
                text = "";
        }
Example #14
0
        private static Primitive ExtractPrimitive(ref VoidPtr address, ElementFlags entryInfo, ushort[] nodeBuffer, ref int nodeIndex)
        {
Top:
            PrimitiveHeader * header = (PrimitiveHeader *)address;
            GLPrimitiveType type;

            switch (header->Type)
            {
            case WiiPrimitiveType.BoneDef1:
            {
                if (*(bushort *)header->Data == 0xB000)
                {
                    nodeIndex = 0;
                }
                nodeBuffer[nodeIndex++] = header->Entries;

                //nodeBuffer[(*(bushort*)header->Data - 0xB000) / 0x0C] = header->Entries;
                address += 5;
                goto Top;
            }

            case WiiPrimitiveType.BoneDef2:
            case WiiPrimitiveType.BoneDef3:
            { address += 5; goto Top; }

            case WiiPrimitiveType.Lines: { type = GLPrimitiveType.Lines; break; }

            case WiiPrimitiveType.LineStrip: { type = GLPrimitiveType.LineStrip; break; }

            case WiiPrimitiveType.Points: { type = GLPrimitiveType.Points; break; }

            case WiiPrimitiveType.Quads: { type = GLPrimitiveType.Quads; break; }

            case WiiPrimitiveType.TriangleFan: { type = GLPrimitiveType.TriangleFan; break; }

            case WiiPrimitiveType.Triangles: { type = GLPrimitiveType.Triangles; break; }

            case WiiPrimitiveType.TriangleStrip: { type = GLPrimitiveType.TriangleStrip; break; }

            default: return(null);
            }

            Primitive primitive = new Primitive();

            primitive._type = GLPrimitiveType.Triangles;


            int   entries = primitive._elementCount = header->Entries;
            int   stride  = entryInfo.Stride;
            byte *data    = (byte *)header->Data;

            //Pos matrices
            if (entryInfo.PosNormMatrixIndex)
            {
                primitive._weightIndices = ParseWeights(data, entries, stride, nodeBuffer);
                data += 1;
            }

            //Tex matrices
            for (int i = 0; i < 8; i++)
            {
                if (entryInfo.TexMatrixIndex[i])
                {
                    data++;
                }
            }

            XFDataFormat *fPtr = &entryInfo.PositionFormat;

            primitive._vertexIndices = ParseElement(ref data, *fPtr++, entries, stride);
            primitive._normalIndices = ParseElement(ref data, *fPtr++, entries, stride);

            //Color Data
            for (int i = 0; i < 2;)
            {
                primitive._colorIndices[i++] = ParseElement(ref data, *fPtr++, entries, stride);
            }

            //UV Data
            for (int i = 0; i < 8;)
            {
                primitive._uvIndices[i++] = ParseElement(ref data, *fPtr++, entries, stride);
            }

            address += stride * entries + 3;

            return(primitive);
        }