Beispiel #1
0
    public static void UnpackLayerData()
    {
        Logger.LogDebug("VolumeLayerManager.UnpackLayerData");
        for (int i = 0; i < LayerData.Count; i++)
        {
            VolumeLayerData vlData  = LayerData[i];
            BitPack         bitPack = new BitPack(vlData.Data);
            GroupHeader     gh      = new GroupHeader(bitPack);

            switch (vlData.LayerType)
            {
            case LayerType.Land:
                Agent.CurrentPlayer.Region.Land.DecompressPatches(bitPack, gh, false);
                break;

            case LayerType.Wind:
                break;

            case LayerType.Cloud:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }


        //TODO: Bogus event for debug purpose (generate a texture):
        Region  region  = Agent.CurrentPlayer.Region;
        Surface surface = region.Land;

        surface.IdleUpdate(0f);
        EventManager.Instance.RaiseOnHeightsDecoded(region, surface.SurfaceZ, surface.GridsPerEdge, surface.MinZ, surface.MaxZ);
    }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("grpHId,msgId,nbOfTxs,creDtTm,ttlIntrBKSttlmAmt,intrBkSttlmDt,sttlImInfSttlmMtd,sttlInfPrtry,GRPRTR,GRPTYPE,GRPHRTRID,GRPHSTSID")] GroupHeader groupHeader)
        {
            if (id != groupHeader.grpHId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(groupHeader);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GroupHeaderExists(groupHeader.grpHId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(groupHeader));
        }
Beispiel #3
0
        protected void FireGroupHeaderRendering(GroupHeader groupHeader)
        {
//			Console.WriteLine("\tFireGroupHeaderRendering");
            GroupHeaderEventArgs ghea = new GroupHeaderEventArgs(groupHeader);

            EventHelper.Raise <GroupHeaderEventArgs>(GroupHeaderRendering, this, ghea);
        }
Beispiel #4
0
        /// <summary>
        /// Creates a LayerData packet for compressed land data given a full
        /// simulator heightmap and an array of indices of patches to compress
        /// </summary>
        /// <param name="heightmap">A 256 * 256 array of floating point values
        /// specifying the height at each meter in the simulator</param>
        /// <param name="patches">Array of indexes in the 16x16 grid of patches
        /// for this simulator. For example if 1 and 17 are specified, patches
        /// x=1,y=0 and x=1,y=1 are sent</param>
        /// <returns></returns>
        public LayerDataPacket CreateLandPacket(float[] heightmap, int[] patches)
        {
            LayerDataPacket layer = new LayerDataPacket();

            layer.LayerID.Type = (byte)LayerType.Land;

            GroupHeader header = new GroupHeader();

            header.Stride    = STRIDE;
            header.PatchSize = 16;
            header.Type      = LayerType.Land;

            byte[]  data    = new byte[1536];
            BitPack bitpack = new BitPack(data, 0);

            bitpack.PackBits(header.Stride, 16);
            bitpack.PackBits(header.PatchSize, 8);
            bitpack.PackBits((int)header.Type, 8);

            for (int i = 0; i < patches.Length; i++)
            {
                CreatePatch(bitpack, heightmap, patches[i] % 16, (patches[i] - (patches[i] % 16)) / 16);
            }

            bitpack.PackBits(END_OF_PATCHES, 8);

            layer.LayerData.Data = new byte[bitpack.BytePos + 1];
            Buffer.BlockCopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.BytePos + 1);

            return(layer);
        }
Beispiel #5
0
            static partial void CustomBinaryEndImport(MutagenFrame frame, IDialogTopicInternal obj)
            {
                if (frame.Reader.Complete)
                {
                    return;
                }
                GroupHeader groupMeta = frame.GetGroup();

                if (!groupMeta.IsGroup)
                {
                    return;
                }
                if (groupMeta.GroupType == (int)GroupTypeEnum.TopicChildren)
                {
                    obj.Timestamp = BinaryPrimitives.ReadInt32LittleEndian(groupMeta.LastModifiedSpan);
                    if (FormKey.Factory(frame.MetaData.MasterReferences !, BinaryPrimitives.ReadUInt32LittleEndian(groupMeta.ContainedRecordTypeSpan)) != obj.FormKey)
                    {
                        throw new ArgumentException("Dialog children group did not match the FormID of the parent.");
                    }
                }
                else
                {
                    return;
                }
                frame.Reader.Position += groupMeta.HeaderLength;
                obj.Items.SetTo(Mutagen.Bethesda.Binary.ListBinaryTranslation <DialogItem> .Instance.Parse(
                                    frame: frame.SpawnWithLength(groupMeta.ContentLength),
                                    transl: (MutagenFrame r, RecordType header, out DialogItem listItem) =>
                {
                    return(LoquiBinaryTranslation <DialogItem> .Instance.Parse(
                               frame: r,
                               item: out listItem));
                }));
            }
Beispiel #6
0
        private void Read(BinaryReader reader)
        {
            Header = reader.Read <GroupHeader>();

            if (Header.InstanceOffset > 0)
            {
                reader.BaseStream.Position = Header.InstanceOffset;
                Instances = reader.ReadArray <teResourceGUID>(Header.NumShaders);
            }

            if (Header.HashOffset > 0)
            {
                reader.BaseStream.Position = Header.HashOffset;
                Hashes = reader.ReadArray <uint>(Header.NumShaders);
            }

            if (Header.FlagsOffset > 0)
            {
                reader.BaseStream.Position = Header.FlagsOffset;
                InstanceFlags = reader.ReadArray <ulong>(Header.NumShaders);
            }

            {
                reader.BaseStream.Position = 72;
                ShaderQualities            = reader.ReadArray <ShaderQuality>(5);

                reader.BaseStream.Position = 104;
                ShaderUnks = reader.ReadArray <ShaderUnk>(5);
            }
        }
Beispiel #7
0
        // apply the style to an existing report
        public void Apply(C1Report rpt)
        {
            if (rpt == null)
            {
                return;
            }

            // default report font
            rpt.Font = Detail.Font;

            // report header
            ReportHeader.Apply(rpt.Sections.Header);

            // page header
            PageHeader.Apply(rpt.Sections.PageHeader);

            // group headers
            foreach (Group group in rpt.Groups)
            {
                GroupHeader.Apply(group.SectionHeader);
            }

            // detail
            Detail.Apply(rpt.Sections.Detail);

            // report footer
            PageFooter.Apply(rpt.Sections.PageFooter);
        }
        public override async void AddAsync()
        {
            GroupHeader = new GroupHeader();
            await UpdateMenuModules();

            base.AddAsync();
        }
Beispiel #9
0
        private void HandleSelectedItem(object listBox, object selectedItem)
        {
            GroupHeader groupHeader = selectedItem as GroupHeader;

            if (groupHeader == null)
            {
                return;
            }
            if (this._pickManaged)
            {
                if (this._ownerId != 0L && this._picId != 0L)
                {
                    this.Share(this._text ?? "", groupHeader.Group.id, groupHeader.Group.name ?? "");
                }
                ParametersRepository.SetParameterForId("PickedGroupForRepost", (object)groupHeader.Group);
                EventAggregator.Current.Publish((object)new PhotoIsRepostedInGroup());
                ((Page)this).NavigationService.GoBackSafe();
            }
            else if (this._shareContentDataProvider != null)
            {
                this._shareContentDataProvider.StoreDataToRepository();
                ShareContentDataProviderManager.StoreDataProvider(this._shareContentDataProvider);
                Navigator.Current.NavigateToNewWallPost(groupHeader.Group.id, true, groupHeader.Group.admin_level, groupHeader.Group.GroupType == GroupType.PublicPage, false, false);
            }
            else
            {
                Navigator.Current.NavigateToGroup(groupHeader.Group.id, groupHeader.Group.name, false);
            }
        }
Beispiel #10
0
        public static LayerData ToLayerMessage(List <LayerPatch> patches, LayerData.LayerDataType type, int offset, int length, out int outlength)
        {
            outlength = 0;
            var layer = new LayerData
            {
                LayerType = type
            };
            bool extended = false;

            switch (type)
            {
            case LayerData.LayerDataType.CloudExtended:
            case LayerData.LayerDataType.LandExtended:
            case LayerData.LayerDataType.WaterExtended:
            case LayerData.LayerDataType.WindExtended:
                extended = true;
                break;
            }

            var header = new GroupHeader
            {
                Stride    = STRIDE,
                PatchSize = LAYER_PATCH_NUM_XY_ENTRIES,
                Type      = type
            };
            var data    = new byte[1500];
            var bitpack = new BitPacker(data, 0);

            bitpack.PackBits(header.Stride, 16);
            bitpack.PackBits(header.PatchSize, 8);
            bitpack.PackBits((uint)header.Type, 8);
            int remainingbits = 1300 * 8; /* 1300 is a bit more than 2 perfectly bad compressed layer patches, wind needs two per packet */

            for (int i = 0; i < length; i++)
            {
                int patchno = i + offset;
                if (patches[patchno].Data.Length != LAYER_PATCH_NUM_XY_ENTRIES * LAYER_PATCH_NUM_XY_ENTRIES)
                {
                    throw new ArgumentException("Patch data must be a 16x16 array");
                }

                if (CompressPatch(bitpack, patches[patchno], extended, ref remainingbits))
                {
                    ++outlength;
                }
                else
                {
                    break;
                }
            }

            bitpack.PackBits(END_OF_PATCHES, 8);

            layer.Data = new byte[bitpack.NumBytes];
            Buffer.BlockCopy(bitpack.Data, 0, layer.Data, 0, bitpack.NumBytes);

            return(layer);
        }
Beispiel #11
0
    /// <summary>
    /// Decompresses all the patches in the given BitPack and assigns heights and normals to the surface.
    /// </summary>
    /// <param name="bitPack"></param>
    /// <param name="groupHeader"></param>
    /// <param name="isLargePatch"></param>
    public void DecompressPatches(BitPack bitPack, GroupHeader groupHeader, bool isLargePatch)
    {
        int j;
        int i;

        int[] patchData = new int[Patch.LARGE_PATCH_SIZE * Patch.LARGE_PATCH_SIZE]; // Large enough for a maximum sized patch

        Patch.InitPatchDecompressor(groupHeader.PatchSize);
        groupHeader.Stride = (UInt16)GridsPerEdge;
        Patch.SetGroupHeader(groupHeader);

        while (true)
        {
            PatchHeader patchHeader = new PatchHeader(bitPack);
            //Logger.LogDebug("Surface.DecompressPatches", $"{patchHeader} w={patchHeader.PatchIds >> 5} h={patchHeader.PatchIds & 0x1f} (PatchesPerEdge={PatchesPerEdge})");

            if (patchHeader.IsEnd)
            {
                break;
            }

            i = patchHeader.PatchIds >> 5;
            j = patchHeader.PatchIds & 0x1f;

            if ((i >= PatchesPerEdge) || (j >= PatchesPerEdge))
            {
                //Logger.LogWarning("Surface.DecompressPatches", $"Received invalid terrain packet - patch header patch ID incorrect! {i}x{j} DcOffset={patchHeader.DcOffset} Range={patchHeader.Range} QuantWBits={patchHeader.QuantWBits} PatchIds={patchHeader.PatchIds}");
                return;
            }

            SurfacePatch surfacePatch = PatchList[j * PatchesPerEdge + i];
            Patch.Decode(bitPack, groupHeader.PatchSize, (patchHeader.QuantWBits & 0xf) + 2, patchData);

            Patch.DeCompress(SurfaceZ, surfacePatch.DataZStart, patchData, patchHeader);

            // Update edges for neighbours.  Need to guarantee that this gets done before we generate vertical stats.
            surfacePatch.UpdateNorthEdge();
            surfacePatch.UpdateEastEdge();
            if (surfacePatch.GetNeighbourPatch(DirectionIndex.West) != null)
            {
                surfacePatch.GetNeighbourPatch(DirectionIndex.West).UpdateEastEdge();
            }
            if (surfacePatch.GetNeighbourPatch(DirectionIndex.SouthWest) != null)
            {
                surfacePatch.GetNeighbourPatch(DirectionIndex.SouthWest).UpdateEastEdge();
                surfacePatch.GetNeighbourPatch(DirectionIndex.SouthWest).UpdateNorthEdge();
            }
            if (surfacePatch.GetNeighbourPatch(DirectionIndex.South) != null)
            {
                surfacePatch.GetNeighbourPatch(DirectionIndex.South).UpdateNorthEdge();
            }

            //// Dirty patch statistics, and flag that the patch has data.
            surfacePatch.DirtyZ();
            surfacePatch.HasReceivedData = true;
            //break; //TODO: Only do the first patch for testing
        }
    }
Beispiel #12
0
        private void DecompressLand(Simulator simulator, BitPack bitpack, GroupHeader group)
        {
            int x;
            int y;

            int[] patches = new int[32 * 32];
            int   count   = 0;

            while (true)
            {
                PatchHeader header = DecodePatchHeader(bitpack);

                if (header.QuantWBits == END_OF_PATCHES)
                {
                    break;
                }

                x = header.PatchIDs >> 5;
                y = header.PatchIDs & 0x1F;

                if (x >= PATCHES_PER_EDGE || y >= PATCHES_PER_EDGE)
                {
                    Logger.Log("Invalid LayerData land packet, x = " + x + ", y = " + y + ", dc_offset = " +
                               header.DCOffset + ", range = " + header.Range + ", quant_wbits = " + header.QuantWBits +
                               ", patchids = " + header.PatchIDs + ", count = " + count, Helpers.LogLevel.Warning, Client);
                    return;
                }

                // Decode this patch
                DecodePatch(patches, bitpack, header, group.PatchSize);

                // Decompress this patch
                float[] heightmap = DecompressPatch(patches, header, group);

                count++;

                if (OnLandPatch != null)
                {
                    try { OnLandPatch(simulator, x, y, group.PatchSize, heightmap); }
                    catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
                }

                if (Client.Settings.STORE_LAND_PATCHES)
                {
                    lock (SimPatches)
                    {
                        if (!SimPatches.ContainsKey(simulator.Handle))
                        {
                            SimPatches.Add(simulator.Handle, new Patch[16 * 16]);
                        }

                        SimPatches[simulator.Handle][y * 16 + x]           = new Patch();
                        SimPatches[simulator.Handle][y * 16 + x].Heightmap = heightmap;
                    }
                }
            }
        }
        public async Task <BaseResponse> SaveGroupAsync(GroupHeader group)
        {
            var r = await new BaseServiceRequest().GetRequest <BaseResponse>(new GroupSaveRequest()
            {
                parameter = group
            }, Method.POST);

            return(r);
        }
Beispiel #14
0
        public async Task <IActionResult> Create([Bind("grpHId,msgId,nbOfTxs,creDtTm,ttlIntrBKSttlmAmt,intrBkSttlmDt,sttlImInfSttlmMtd,sttlInfPrtry,GRPRTR,GRPTYPE,GRPHRTRID,GRPHSTSID")] GroupHeader groupHeader)
        {
            if (ModelState.IsValid)
            {
                _context.Add(groupHeader);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(groupHeader));
        }
Beispiel #15
0
        private void ListGroups_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            GroupHeader groupHeader = this.listGroups.SelectedItem as GroupHeader;

            if (groupHeader == null)
            {
                return;
            }
            Navigator.Current.NavigateToGroup(groupHeader.Group.id, groupHeader.Group.name, false);
            this.listGroups.SelectedItem = null;
        }
Beispiel #16
0
        // gets a preview image of the style
        public Image GetPreview(bool forceUpdate)
        {
            if (_preview == null || forceUpdate)
            {
                // draw style preview
                Bitmap       bmp = new Bitmap(150, 105);
                StringFormat sf  = StringFormat.GenericTypographic;
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    // highest quality we can get
                    g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                    g.SmoothingMode     = SmoothingMode.HighQuality;

                    // white background
                    Rectangle rc = new Rectangle(0, 0, bmp.Width, bmp.Height);
                    g.FillRectangle(Brushes.White, rc);

                    // content
                    //rc.Inflate(-3, -3);
                    rc.Height = 30;
                    int height = ReportHeader.Render(g, Name, rc);//"Title", rc);
                    rc.Offset(0, height - 1);
                    height = PageHeader.Render(g, "Page Header", rc);
                    rc.Offset(0, height - 1);
                    height = GroupHeader.Render(g, "Group Header", rc);
                    rc.Offset(0, height - 1);
                    height = Detail.Render(g, "  Detail", rc);
                    rc.Offset(0, height - 1);
                    using (Brush br = new SolidBrush(Detail.AlternateColor))
                    {
                        g.FillRectangle(br, rc);
                    }
                }

                // draw style preview into template
                Bitmap bmpTemplate = StyleSelector.BitmapFromStream("styleTemplate.bmp", Color.Red);
                using (Graphics g = Graphics.FromImage(bmpTemplate))
                {
                    Rectangle rc = new Rectangle(0, 71, bmp.Width, bmp.Height);
                    rc.Offset(+2, +2);
                    g.FillRectangle(Brushes.DarkGray, rc);
                    rc.Offset(-2, -2);
                    g.DrawImageUnscaled(bmp, rc);
                    g.DrawRectangle(Pens.Black, rc);
                }

                // save image for next time
                _preview = bmpTemplate;
            }

            // return the value that was asked for
            return(_preview);
        }
Beispiel #17
0
        public static void FillModTypes(
            IBinaryReadStream stream,
            ModTypeFillWrapper fill,
            BinaryOverlayFactoryPackage package)
        {
            int?      lastParsed      = null;
            ModHeader headerMeta      = stream.GetModHeader(package);
            var       minimumFinalPos = checked ((int)(stream.Position + headerMeta.TotalLength));

            fill(
                stream: stream,
                finalPos: minimumFinalPos,
                offset: 0,
                type: headerMeta.RecordType,
                lastParsed: lastParsed,
                recordTypeConverter: null);
            stream.Position = (int)headerMeta.TotalLength;
            while (!stream.Complete)
            {
                GroupHeader groupMeta = stream.GetGroup(package);
                if (!groupMeta.IsGroup)
                {
                    throw new ArgumentException("Did not see GRUP header as expected.");
                }
                if (groupMeta.ContentLength == 0)
                {
                    stream.Position += groupMeta.TotalLength;
                    continue;
                }
                minimumFinalPos = checked ((int)(stream.Position + groupMeta.TotalLength));
                var parsed = fill(
                    stream: stream,
                    finalPos: minimumFinalPos,
                    offset: 0,
                    type: groupMeta.ContainedRecordType,
                    lastParsed: lastParsed,
                    recordTypeConverter: null);
                if (!parsed.KeepParsing)
                {
                    break;
                }
                if (!parsed.KeepParsing)
                {
                    break;
                }
                if (minimumFinalPos > stream.Position)
                {
                    stream.Position = checked ((int)minimumFinalPos);
                }
                lastParsed = parsed.ParsedIndex;
            }
        }
Beispiel #18
0
    public static void DeCompress(float[] dest, uint destOffset, int[] src, PatchHeader patchHeader)
    {
        {
            int i;
            int j;

            float[] block       = new float[LARGE_PATCH_SIZE * LARGE_PATCH_SIZE];
            int     tblockIndex = 0;

            int tpatchIndex;

            GroupHeader groupHeader = GroupHeader;
            int         size        = groupHeader.PatchSize;
            float       range       = patchHeader.Range;
            int         prequant    = (patchHeader.QuantWBits >> 4) + 2;
            int         quantize    = 1 << prequant;
            float       hmin        = patchHeader.DcOffset;
            int         stride      = groupHeader.Stride;

            float ooq               = 1f / (float)quantize;
            int   dqIndex           = 0;
            int   decopyMatrixIndex = 0;

            float mult   = ooq * range;
            float addval = mult * (float)(1 << (prequant - 1)) + hmin;

            for (i = 0; i < size * size; i++)
            {
                block[tblockIndex++] = src[DeCopyMatrix[decopyMatrixIndex++]] * PatchDequantizeTable[dqIndex++];
            }

            if (size == 16)
            {
                idct_patch(block);
            }
            else
            {
                idct_patch_large(block);
            }

            for (j = 0; j < size; j++)
            {
                tpatchIndex = j * stride;
                tblockIndex = j * size;
                for (i = 0; i < size; i++)
                {
                    dest[destOffset + tpatchIndex++] = block[tblockIndex++] * mult + addval;
                }
            }
        }
    }
        private void Group_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (!(sender is FrameworkElement))
            {
                return;
            }
            GroupHeader dataContext = (sender as FrameworkElement).DataContext as GroupHeader;

            if (dataContext == null)
            {
                return;
            }
            Navigator.Current.NavigateToGroup(dataContext.Group.id, dataContext.Group.name, false);
        }
Beispiel #20
0
        private void PrintHeader(Components c, GroupHeader header)
        {
            RowSpec row  = new RowSpec();
            string  note = "";

            row.Name = header.TypeDescription + " " + header.Manufacturer;
            if (header.NoteNumber > 0 || header.NoteNumber1 > 0)
            {
                note = "Примеч. " + (header.NoteNumber > 0 ? header.NoteNumber.ToString() : "") +
                       (header.NoteNumber1 > 0 ? ", " + header.NoteNumber1.ToString() : "");
                row.Note = note;
            }
            Others.Add(row);
        }
Beispiel #21
0
        private float[] DecompressPatch(int[] patches, PatchHeader header, GroupHeader group)
        {
            float[] block    = new float[group.PatchSize * group.PatchSize];
            float[] output   = new float[group.PatchSize * group.PatchSize];
            int     prequant = (header.QuantWBits >> 4) + 2;
            int     quantize = 1 << prequant;
            float   ooq      = 1.0f / (float)quantize;
            float   mult     = ooq * (float)header.Range;
            float   addval   = mult * (float)(1 << (prequant - 1)) + header.DCOffset;

            if (group.PatchSize == 16)
            {
                for (int n = 0; n < 16 * 16; n++)
                {
                    block[n] = patches[CopyMatrix16[n]] * DequantizeTable16[n];
                }

                float[] ftemp = new float[16 * 16];

                for (int o = 0; o < 16; o++)
                {
                    IDCTColumn16(block, ftemp, o);
                }
                for (int o = 0; o < 16; o++)
                {
                    IDCTLine16(ftemp, block, o);
                }
            }
            else
            {
                for (int n = 0; n < 32 * 32; n++)
                {
                    block[n] = patches[CopyMatrix32[n]] * DequantizeTable32[n];
                }

                Logger.Log("Implement IDCTPatchLarge", Helpers.LogLevel.Error, Client);
            }

            for (int j = 0; j < block.Length; j++)
            {
                output[j] = block[j] * mult + addval;
            }

            return(output);
        }
Beispiel #22
0
        private static string GetSubtitle(Group group)
        {
            if (!string.IsNullOrWhiteSpace(group.activity) && group.GroupType != GroupType.Event)
            {
                return(group.activity);
            }
            switch (group.GroupType)
            {
            case GroupType.Group:
                return(GroupHeader.GetGroupTypeText(group));

            case GroupType.PublicPage:
                return(CommonResources.PublicPage);

            default:
                return("");
            }
        }
Beispiel #23
0
        public override int GetHashCode()
        {
            int retval = 0;

            if (GroupName != null)
            {
                retval += GroupName.GetHashCode();
            }
            if (GroupHeader != null)
            {
                retval += GroupHeader.GetHashCode();
            }
            if (GroupFooter != null)
            {
                retval += GroupFooter.GetHashCode();
            }
            return(retval);
        }
        public async Task <IActionResult> GetGroupInfo(int id)
        {
            try
            {
                var g = await work.GetRepository <Group>().GetFirstOrDefaultAsync(predicate: x => x.Id == id);

                if (g != null)
                {
                    GroupHeader header = new GroupHeader();
                    header.group      = g;
                    header.GroupUsers = new ObservableCollection <GroupUser>();
                    header.GroupFuncs = new List <GroupFunc>();
                    work.GetRepository <GroupUser>()
                    .GetAll(predicate: x => x.GroupCode == g.GroupCode).ToList()?.ForEach(arg =>
                    {
                        header.GroupUsers.Add(arg);
                    });
                    work.GetRepository <GroupFunc>()
                    .GetAll(predicate: x => x.GroupCode == g.GroupCode).ToList().ForEach(arg =>
                    {
                        header.GroupFuncs.Add(arg);
                    });
                    return(Ok(new ConsumptionResponse()
                    {
                        success = true, dynamicObj = header,
                    }));
                }
                else
                {
                    return(Ok(new ConsumptionResponse()
                    {
                        success = false, message = "未包含组信息"
                    }));
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "");
                return(Ok(new ConsumptionResponse()
                {
                    success = false
                }));
            }
        }
 public void Handle(GroupSubscribedUnsubscribedEvent message)
 {
     if (this._manageSourcesMode != ManageSourcesMode.ManagePushNotificationsSources)
     {
         return;
     }
     if (message.IsSubscribed)
     {
         this.GroupsVM.LoadData(true, false, (Action <BackendResult <ProfilesAndGroups, ResultCode> >)null, false);
     }
     else
     {
         GroupHeader groupHeader = this.GroupsVM.Collection.FirstOrDefault <GroupHeader>((Func <GroupHeader, bool>)(fh => fh.Group.id == message.group.id));
         if (groupHeader == null)
         {
             return;
         }
         this.GroupsVM.Delete(groupHeader);
     }
 }
Beispiel #26
0
 public void Handle(GroupSubscribedUnsubscribedEvent message)
 {
     if (this._manageSourcesMode != ManageSourcesMode.ManagePushNotificationsSources)
     {
         return;
     }
     if (message.IsSubscribed)
     {
         this.GroupsVM.LoadData(true, false, null, false);
     }
     else
     {
         GroupHeader groupHeader = (GroupHeader)Enumerable.FirstOrDefault <GroupHeader>(this.GroupsVM.Collection, (Func <GroupHeader, bool>)(fh => fh.Group.id == message.group.id));
         if (groupHeader == null)
         {
             return;
         }
         this.GroupsVM.Delete(groupHeader);
     }
 }
Beispiel #27
0
        private void LayerDataHandler(Packet packet, Simulator simulator)
        {
            LayerDataPacket layer   = (LayerDataPacket)packet;
            BitPack         bitpack = new BitPack(layer.LayerData.Data, 0);
            GroupHeader     header  = new GroupHeader();
            LayerType       type    = (LayerType)layer.LayerID.Type;

            // Stride
            header.Stride = bitpack.UnpackBits(16);
            // Patch size
            header.PatchSize = bitpack.UnpackBits(8);
            // Layer type
            header.Type = (LayerType)bitpack.UnpackBits(8);

            switch (type)
            {
            case LayerType.Land:
                if (OnLandPatch != null || Client.Settings.STORE_LAND_PATCHES)
                {
                    DecompressLand(simulator, bitpack, header);
                }
                break;

            case LayerType.Water:
                Logger.Log("Got a Water LayerData packet, implement me!", Helpers.LogLevel.Error, Client);
                break;

            case LayerType.Wind:
                DecompressWind(simulator, bitpack, header);
                break;

            case LayerType.Cloud:
                DecompressCloud(simulator, bitpack, header);
                break;

            default:
                Logger.Log("Unrecognized LayerData type " + type.ToString(), Helpers.LogLevel.Warning, Client);
                break;
            }
        }
        public override async void Add()
        {
            try
            {
                UpdateLoading(true, "正在加载...");
                GroupHeader = new GroupHeader();
                await UpdateMenuModules();

                SelectPageTitle = "编辑组信息";
                SelectPageIndex = 1;
                base.Add();
            }
            catch (Exception ex)
            {
                Msg.Error(ex.Message);
                Log.Error(ex.Message);
            }
            finally
            {
                UpdateLoading(false);
            }
        }
Beispiel #29
0
        public static async Task <ScannedHeaders> ScanHeaders(Stream streamToScan, long bytesToScan)
        {
            var scannedHeaders = new ScannedHeaders()
            {
                Groups  = new List <ScannedHeaders.ScanResult <GroupHeader> >(),
                Records = new List <ScannedHeaders.ScanResult <RecordHeader> >(),
            };
            long endIndex = streamToScan.Position + bytesToScan;

            // Re-use the same allocation for each header, as a
            // record header and group header are the same size (24 bytes)
            byte[] headerBytes = new byte[24];
            while (streamToScan.Position < endIndex)
            {
                await streamToScan.ReadAsync(headerBytes, 0, headerBytes.Length);

                string type = Encoding.UTF8.GetString(headerBytes, 0, 4);

                switch (type)
                {
                case "GRUP":
                    var groupHeader   = GroupHeader.Parse(headerBytes);
                    var scannedHeader = new ScannedHeaders.ScanResult <GroupHeader>(streamToScan.Position - 24, groupHeader);
                    scannedHeaders.Groups.Add(scannedHeader);
                    // Skip past the records in the group
                    streamToScan.Seek(groupHeader.DataSize, SeekOrigin.Current);
                    break;

                default:
                    var recordHeader  = RecordHeader.Parse(headerBytes);
                    var scannedRecord = new ScannedHeaders.ScanResult <RecordHeader>(streamToScan.Position - 24, recordHeader);
                    scannedHeaders.Records.Add(scannedRecord);
                    // SKip past the fields in the record
                    streamToScan.Seek(recordHeader.DataSize, SeekOrigin.Current);
                    break;
                }
            }
            return(scannedHeaders);
        }
        public static RecordType GetNextType(
            IMutagenReadStream reader,
            out int contentLength,
            out long finalPos,
            bool hopGroup = true)
        {
            GroupHeader groupMeta = reader.GetGroup();
            RecordType  ret       = groupMeta.RecordType;

            contentLength = checked ((int)groupMeta.TotalLength);
            if (groupMeta.IsGroup)
            {
                if (hopGroup)
                {
                    ret = groupMeta.ContainedRecordType;
                }
                finalPos = reader.Position + groupMeta.TotalLength;
            }
            else
            {
                finalPos = reader.Position + reader.MetaData.Constants.MajorConstants.HeaderLength + contentLength;
            }
            return(ret);
        }
Beispiel #31
0
		protected void FireGroupHeaderRendering (GroupHeader groupHeader)
		{
//			Console.WriteLine("\tFireGroupHeaderRendering");
			GroupHeaderEventArgs ghea = new GroupHeaderEventArgs(groupHeader);
			EventHelper.Raise<GroupHeaderEventArgs>(GroupHeaderRendering,this,ghea);
		}
        private void LayerDataHandler(Packet packet, Simulator simulator)
        {
            LayerDataPacket layer = (LayerDataPacket)packet;
            BitPack bitpack = new BitPack(layer.LayerData.Data, 0);
            GroupHeader header = new GroupHeader();
            LayerType type = (LayerType)layer.LayerID.Type;

            // Stride
            header.Stride = bitpack.UnpackBits(16);
            // Patch size
            header.PatchSize = bitpack.UnpackBits(8);
            // Layer type
            header.Type = (LayerType)bitpack.UnpackBits(8);

            switch (type)
            {
                case LayerType.Land:
                    if (OnLandPatch != null || Client.Settings.STORE_LAND_PATCHES)
                        DecompressLand(simulator, bitpack, header);
                    break;
                case LayerType.Water:
                    Logger.Log("Got a Water LayerData packet, implement me!", Helpers.LogLevel.Error, Client);
                    break;
                case LayerType.Wind:
                    DecompressWind(simulator, bitpack, header);
                    break;
                case LayerType.Cloud:
                    DecompressCloud(simulator, bitpack, header);
                    break;
                default:
                    Logger.Log("Unrecognized LayerData type " + type.ToString(), Helpers.LogLevel.Warning, Client);
                    break;
            }
        }
 private void DecompressCloud(Simulator simulator, BitPack bitpack, GroupHeader group)
 {
     ;
 }
        private void DecompressLand(Simulator simulator, BitPack bitpack, GroupHeader group)
        {
            int x;
            int y;
            int[] patches = new int[32 * 32];
            int count = 0;

            while (true)
            {
                PatchHeader header = DecodePatchHeader(bitpack);

                if (header.QuantWBits == END_OF_PATCHES)
                    break;

                x = header.PatchIDs >> 5;
                y = header.PatchIDs & 0x1F;

                if (x >= PATCHES_PER_EDGE || y >= PATCHES_PER_EDGE)
                {
                    Logger.Log("Invalid LayerData land packet, x = " + x + ", y = " + y + ", dc_offset = " +
                        header.DCOffset + ", range = " + header.Range + ", quant_wbits = " + header.QuantWBits +
                        ", patchids = " + header.PatchIDs + ", count = " + count, Helpers.LogLevel.Warning, Client);
                    return;
                }

                // Decode this patch
                DecodePatch(patches, bitpack, header, group.PatchSize);

                // Decompress this patch
                float[] heightmap = DecompressPatch(patches, header, group);

                count++;

                if (OnLandPatch != null)
                {
                    try { OnLandPatch(simulator, x, y, group.PatchSize, heightmap); }
                    catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
                }

                if (Client.Settings.STORE_LAND_PATCHES)
                {
                    lock (SimPatches)
                    {
                        if (!SimPatches.ContainsKey(simulator.Handle))
                            SimPatches.Add(simulator.Handle, new Patch[16 * 16]);

                        SimPatches[simulator.Handle][y * 16 + x] = new Patch();
                        SimPatches[simulator.Handle][y * 16 + x].Heightmap = heightmap;
                    }
                }
            }
        }
        private float[] DecompressPatch(int[] patches, PatchHeader header, GroupHeader group)
        {
            float[] block = new float[group.PatchSize * group.PatchSize];
            float[] output = new float[group.PatchSize * group.PatchSize];
            int prequant = (header.QuantWBits >> 4) + 2;
            int quantize = 1 << prequant;
            float ooq = 1.0f / (float)quantize;
            float mult = ooq * (float)header.Range;
            float addval = mult * (float)(1 << (prequant - 1)) + header.DCOffset;

            if (group.PatchSize == 16)
            {
                for (int n = 0; n < 16 * 16; n++)
                {
                    block[n] = patches[CopyMatrix16[n]] * DequantizeTable16[n];
                }

                float[] ftemp = new float[16 * 16];

                for (int o = 0; o < 16; o++)
                    IDCTColumn16(block, ftemp, o);
                for (int o = 0; o < 16; o++)
                    IDCTLine16(ftemp, block, o);
            }
            else
            {
                for (int n = 0; n < 32 * 32; n++)
                {
                    block[n] = patches[CopyMatrix32[n]] * DequantizeTable32[n];
                }

                Logger.Log("Implement IDCTPatchLarge", Helpers.LogLevel.Error, Client);
            }

            for (int j = 0; j < block.Length; j++)
            {
                output[j] = block[j] * mult + addval;
            }

            return output;
        }
        /// <summary>
        /// Creates a LayerData packet for compressed land data given a full
        /// simulator heightmap and an array of indices of patches to compress
        /// </summary>
        /// <param name="heightmap">A 256 * 256 array of floating point values
        /// specifying the height at each meter in the simulator</param>
        /// <param name="patches">Array of indexes in the 16x16 grid of patches
        /// for this simulator. For example if 1 and 17 are specified, patches
        /// x=1,y=0 and x=1,y=1 are sent</param>
        /// <returns></returns>
        public LayerDataPacket CreateLandPacket(float[] heightmap, int[] patches)
        {
            LayerDataPacket layer = new LayerDataPacket();
            layer.LayerID.Type = (byte)LayerType.Land;

            GroupHeader header = new GroupHeader();
            header.Stride = STRIDE;
            header.PatchSize = 16;
            header.Type = LayerType.Land;

            byte[] data = new byte[1536];
            BitPack bitpack = new BitPack(data, 0);
            bitpack.PackBits(header.Stride, 16);
            bitpack.PackBits(header.PatchSize, 8);
            bitpack.PackBits((int)header.Type, 8);

            for (int i = 0; i < patches.Length; i++)
            {
                CreatePatch(bitpack, heightmap, patches[i] % 16, (patches[i] - (patches[i] % 16)) / 16);
            }

            bitpack.PackBits(END_OF_PATCHES, 8);

            layer.LayerData.Data = new byte[bitpack.BytePos + 1];
            Buffer.BlockCopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.BytePos + 1);

            return layer;
        }
Beispiel #37
0
		protected void FireGroupHeaderRendering (GroupHeader groupHeader)
		{
			GroupHeaderEventArgs ghea = new GroupHeaderEventArgs(groupHeader);
			EventHelper.Raise<GroupHeaderEventArgs>(GroupHeaderRendering,this,ghea);
		}