コード例 #1
0
ファイル: GrpElement.cs プロジェクト: directhex/scsharp
 public GrpElement(UIScreen screen, Grp grp, byte[] palette, ushort x, ushort y)
     : base(screen, x, y, grp.Width, grp.Height)
 {
     this.Palette = palette;
     this.grp = grp;
     this.frame = 0;
 }
コード例 #2
0
    public static void Main(string[] args)
    {
        string filename    = args[0];
        string palettename = args[1];

        Console.WriteLine("grp file {0}", filename);
        Console.WriteLine("palette file {0}", palettename);

        FileStream fs = File.OpenRead(filename);

        Grp grp = new Grp();

        ((MpqResource)grp).ReadFromStream(fs);
        Pcx pal = new Pcx();

        pal.ReadFromStream(File.OpenRead(palettename), -1, -1);

        for (int i = 0; i < grp.FrameCount; i++)
        {
            BMP.WriteBMP(String.Format("output{0:0000}.bmp", i),
                         grp.GetFrame(i),
                         grp.Width, grp.Height,
                         pal.Palette);
        }
    }
コード例 #3
0
ファイル: Sprite.cs プロジェクト: xerohour/scsharp
        public Sprite(Sprite parentSprite, ushort images_entry, byte[] palette)
        {
            this.parent_sprite = parentSprite;
            this.mpq           = parentSprite.mpq;
            this.palette       = palette;
            this.images_entry  = images_entry;

            uint grp_index = GlobalResources.Instance.ImagesDat.GrpIndexes [images_entry];

            grp_path = GlobalResources.Instance.ImagesTbl[(int)grp_index - 1];

            grp = (Grp)mpq.GetResource("unit\\" + grp_path);

            this.buf      = GlobalResources.Instance.IScriptBin.Contents;
            iscript_entry = GlobalResources.Instance.ImagesDat.IScriptIndexes [images_entry];

            script_entry_offset = GlobalResources.Instance.IScriptBin.GetScriptEntryOffset(iscript_entry);

            Console.WriteLine("new dependent sprite: unit\\{0} (image {1}, iscript id {2}, script_entry_offset {3:X})",
                              grp_path, images_entry, iscript_entry, script_entry_offset);

            /* make sure the offset points to "SCEP" */
            if (Util.ReadDWord(buf, script_entry_offset) != 0x45504353)
            {
                Console.WriteLine("invalid script_entry_offset");
            }

            int x, y;

            parentSprite.GetPosition(out x, out y);
            SetPosition(x, y);
        }
コード例 #4
0
ファイル: Sprite.cs プロジェクト: xerohour/scsharp
        public Sprite(Mpq mpq, int sprite_entry, byte[] palette, int x, int y)
        {
            this.mpq     = mpq;
            this.palette = palette;

            images_entry = GlobalResources.Instance.SpritesDat.ImagesDatEntries [sprite_entry];
            //			Console.WriteLine ("image_dat_entry == {0}", images_entry);

            uint grp_index = GlobalResources.Instance.ImagesDat.GrpIndexes [images_entry];

            //			Console.WriteLine ("grp_index = {0}", grp_index);
            grp_path = GlobalResources.Instance.ImagesTbl[(int)grp_index - 1];
            //			Console.WriteLine ("grp_path = {0}", grp_path);

            grp = (Grp)mpq.GetResource("unit\\" + grp_path);

            iscript_entry       = GlobalResources.Instance.ImagesDat.IScriptIndexes [images_entry];
            script_entry_offset = GlobalResources.Instance.IScriptBin.GetScriptEntryOffset(iscript_entry);

            Console.WriteLine("new sprite: unit\\{0} @ {1}x{2} (image {3}, iscript id {4}, script_entry_offset {5:X})",
                              grp_path, x, y, images_entry, iscript_entry, script_entry_offset);

            this.buf = GlobalResources.Instance.IScriptBin.Contents;

            /* make sure the offset points to "SCPE" */
            if (Util.ReadDWord(buf, script_entry_offset) != 0x45504353)
            {
                Console.WriteLine("invalid script_entry_offset");
            }

            SetPosition(x, y);
        }
コード例 #5
0
        void TileRow(Surface surf, Grp grp, byte[] pal, int l, int c, int r, int y)
        {
            Surface lsurf = GuiUtil.CreateSurfaceFromBitmap(grp.GetFrame(l),
                                                            grp.Width, grp.Height,
                                                            pal,
                                                            41, 0);

            Surface csurf = GuiUtil.CreateSurfaceFromBitmap(grp.GetFrame(c),
                                                            grp.Width, grp.Height,
                                                            pal,
                                                            41, 0);


            Surface rsurf = GuiUtil.CreateSurfaceFromBitmap(grp.GetFrame(r),
                                                            grp.Width, grp.Height,
                                                            pal,
                                                            41, 0);


            surf.Blit(lsurf, new Point(0, y));
            for (int x = grp.Width; x < surf.Width - grp.Width; x += grp.Width)
            {
                surf.Blit(csurf, new Point(x, y));
            }
            surf.Blit(rsurf, new Point(surf.Width - grp.Width, y));
        }
コード例 #6
0
    private Grp ensureGroup(bool write, string groupName, byte groupType)
    {
        Grp g = null;

        if (namedGroups.ContainsKey(groupName))
        {
            g = namedGroups[groupName];
            if (g.type != groupType)
            {
                throw new Exception("bad group type");
            }
        }
        else
        {
            g = new Grp();
            write_raw_varint32((1 << TAG_TYPE_BITS) | RAW_TYPE_SCHEMA);
            write_rawbyte(groupType);
            write_rawstring(groupName);
            g.type = groupType;
            g.name = groupName;
            namedGroups.Add(g.name, g);
        }
        if (version == null)
        {
            version = g;
        }
        return(g);
    }
コード例 #7
0
 public GrpElement(UIScreen screen, Grp grp, byte[] palette, ushort x, ushort y)
     : base(screen, x, y, grp.Width, grp.Height)
 {
     this.Palette = palette;
     this.grp     = grp;
     this.frame   = 0;
 }
コード例 #8
0
ファイル: DialogBoxElement.cs プロジェクト: xerohour/scsharp
        void TileRow(CALayer surf, Grp grp, byte[] pal, int l, int c, int r, int y)
        {
            CALayer l_layer = GuiUtil.CreateLayerFromBitmap(grp.GetFrame(l),
                                                            grp.Width, grp.Height,
                                                            pal,
                                                            41, 0);

            CALayer c_layer = GuiUtil.CreateLayerFromBitmap(grp.GetFrame(c),
                                                            grp.Width, grp.Height,
                                                            pal,
                                                            41, 0);


            CALayer r_layer = GuiUtil.CreateLayerFromBitmap(grp.GetFrame(r),
                                                            grp.Width, grp.Height,
                                                            pal,
                                                            41, 0);

#if notyet
            surf.Blit(lsurf, new Point(0, y));
            for (int x = grp.Width; x < surf.Width - grp.Width; x += grp.Width)
            {
                surf.Blit(csurf, new Point(x, y));
            }
            surf.Blit(rsurf, new Point(surf.Width - grp.Width, y));
#endif
        }
コード例 #9
0
        public async Task <IActionResult> PutGrp(int id, Grp grp)
        {
            if (id != grp.Grp1)
            {
                return(BadRequest());
            }

            _context.Entry(grp).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GrpExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #10
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Button oBtn = sender as Button;

            if (oBtn != null && FormLoaded)
            {
                dataGridView1.Rows.Clear();

                DyeParameters.FromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString());
                DyeParameters.ToDate   = Convert.ToDateTime(dtpToDate.Value.ToShortDateString());
                DyeParameters.ToDate   = DyeParameters.ToDate.AddHours(23);

                var CommTransGrps = repo.CommissionTransactions(DyeParameters).GroupBy(x => x.GreigeCom_GrnNo);
                using (var context = new TTI2Entities())
                {
                    foreach (var Grp in CommTransGrps)
                    {
                        var index = dataGridView1.Rows.Add();
                        dataGridView1.Rows[index].Cells[0].Value = Grp.FirstOrDefault().GreigeCom_GrnNo.ToString();
                        dataGridView1.Rows[index].Cells[1].Value = Grp.FirstOrDefault().GreigeCom_Transdate;
                        dataGridView1.Rows[index].Cells[2].Value = Grp.FirstOrDefault().GreigeCom_Custdoc;
                        var Pk = Grp.FirstOrDefault().GreigeCom_ProductType_FK;
                        dataGridView1.Rows[index].Cells[3].Value = context.TLADM_Griege.Find(Pk).TLGreige_Description;
                        dataGridView1.Rows[index].Cells[4].Value = Grp.FirstOrDefault().GreigeCom_Custdoc;
                        dataGridView1.Rows[index].Cells[5].Value = Grp.Count();
                        dataGridView1.Rows[index].Cells[6].Value = Grp.Sum(x => x.GreigeCom_NettWeight);
                    }
                }

                comboCustomers.Items.Clear();
                comboQuality.Items.Clear();

                frmViewCommissionReceipts_Load(this, null);
            }
        }
コード例 #11
0
ファイル: CursorAnimator.cs プロジェクト: xerohour/scsharp
 public CursorAnimator(Grp grp, byte[] palette)
 {
     this.grp     = grp;
     this.x       = 100;
     this.y       = 100;
     this.palette = palette;
     surfaces     = new Surface[grp.FrameCount];
 }
コード例 #12
0
ファイル: CursorAnimator.cs プロジェクト: directhex/scsharp
 public CursorAnimator(Grp grp, byte[] palette)
 {
     this.grp = grp;
     this.x = 100;
     this.y = 100;
     this.palette = palette;
     surfaces = new Surface[grp.FrameCount];
 }
コード例 #13
0
    private Itm ensureItem(bool write, Grp parent, string itemName, byte itemType, string isaName, byte isaType)
    {
        Grp isa = null;

        if (!string.IsNullOrEmpty(isaName))
        {
            isa = ensureGroup(write, isaName, isaType);
        }
        return(ensureItem(write, parent, itemName, itemType, isa));
    }
コード例 #14
0
ファイル: Channel.cs プロジェクト: Mordrag/X-Air-Universal
 public Channel(string baseAddress)
 {
     _baseAddress = baseAddress;
     Config = new Config(_baseAddress);
     Preamp = new Preamp(_baseAddress);
     Gate = new Gate(_baseAddress);
     Dyn = new Dyn(_baseAddress);
     Eq = new Eq4(_baseAddress);
     Mix = new Mix(_baseAddress);
     Grp = new Grp(_baseAddress);
     Automix = new Automix(_baseAddress);
 }
コード例 #15
0
ファイル: CursorAnimator.cs プロジェクト: xerohour/scsharp
        public CursorAnimator(Grp grp, byte[] palette)
        {
            this.grp     = grp;
            this.x       = 100;
            this.y       = 100;
            this.palette = palette;
            frames       = new CGImage[grp.FrameCount];

            Bounds      = new RectangleF(100, 100, grp.Width, grp.Height);
            AnchorPoint = new PointF(0, 0);
            SetNeedsDisplay();
        }
コード例 #16
0
        public IActionResult ByState( )
        {
            // Get every orders with customers
            var orders = _ctx.Orders.Include(o => o.Customer).ToList();

            // Get every orders grouped by state
            var groupedResult = orders.GroupBy(o => o.Customer.State).ToList()
                                //Create a new object from the grouping with the state and the number of total states
                                .Select(Grp => new
            {
                State = Grp.Key,
                Total = Grp.Sum(x => x.OrderTotal)
            })
                                .OrderByDescending(res => res.Total).ToList();

            return(new ObjectResult(groupedResult));
        }
コード例 #17
0
        public IActionResult ByCustomer(int n)
        {
            // Get every orders with customers
            var orders = _ctx.Orders.Include(o => o.Customer).ToList();

            // Get every orders grouped by customer id
            var groupedResult = orders.GroupBy(o => o.Customer.Id).ToList()
                                //Create a new object from the grouping with the customername and total orders
                                .Select(Grp => new
            {
                Name  = _ctx.Customers.Find(Grp.Key).Name,
                Total = Grp.Sum(x => x.OrderTotal)
            })
                                .OrderByDescending(res => res.Total)
                                .Take(n)
                                .ToList();

            return(new ObjectResult(groupedResult));
        }
コード例 #18
0
        private void AddUcToPanelTitle(Panel argPanel, Grp argName, string argTitle, string argText)
        {
            UC.UCTitle Uc = new UC.UCTitle();

            if (argPanel.Tag.ToString() == "MONTH")
            {
                Uc._typeDisplay = UC.UCTitle.TypeDisplay.MONTH;
            }
            else if (argPanel.Tag.ToString() == "SEASON")
            {
                Uc._typeDisplay = UC.UCTitle.TypeDisplay.SEASON;
            }
            Uc.setDisplay();
            Uc.SetTitle(argTitle);
            Uc.SetText(argText);
            Uc.Tag = argName.ToString();
            Uc.ValueChangeEvent += Uc_ValueChangeEvent;
            argPanel.Controls.Add(Uc);
            _dntTitle.Add(argName, Uc);
        }
コード例 #19
0
    private Itm ensureItem(bool write, Grp parent, string itemName, byte itemType, Grp isa)
    {
        Itm item = null;

        if (parent.namedItems.ContainsKey(itemName))
        {
            item = parent.namedItems[itemName];
            if (itemType != item.type)
            {
                throw new Exception("itemtypemismatch");
            }
        }
        else
        {
            item      = new Itm();
            item.id   = ++parent.count;
            item.name = itemName;
            item.type = itemType;
            item.isa  = isa;
            parent.namedItems.Add(item.name, item);
            parent.indexedItems.Add(item.id, item);
            {
                if (item.isa == null)
                {
                    write_raw_varint32((2 << TAG_TYPE_BITS) | RAW_TYPE_SCHEMA);
                }
                else
                {
                    write_raw_varint32((3 << TAG_TYPE_BITS) | RAW_TYPE_SCHEMA);
                }
                write_rawbyte(item.type);
                write_rawstring(item.name);
                write_rawstring(parent.name);
                if (item.isa != null)
                {
                    write_rawstring(item.isa.name);
                }
            }
        }
        return(item);
    }
コード例 #20
0
ファイル: animate-grp.cs プロジェクト: xerohour/scsharp
    public static void Main(string[] args)
    {
        Application.Init();

        string filename = args[0];

        Console.WriteLine("grp file {0}", filename);

        FileStream fs = File.OpenRead(filename);

        grp = new Grp();

        ((MpqResource)grp).ReadFromStream(fs);

        CreateWindow();
        drawing_area.ExposeEvent += OnExposed;

        GLib.Timeout.Add(100, Animate);

        Application.Run();
    }
コード例 #21
0
        public async Task <ActionResult <Grp> > PostGrp(Grp grp)
        {
            _context.Grps.Add(grp);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (GrpExists(grp.Grp1))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetGrp", new { id = grp.Grp1 }, grp));
        }
コード例 #22
0
        private void chkPrevious_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox oChk = (CheckBox)sender;
            IList <TLCMT_PanelIssue> PanelIssue = new List <TLCMT_PanelIssue>();

            if (oChk != null && oChk.Checked && formloaded)
            {
                var selected = (TLADM_Departments)cmboCMT.SelectedItem;
                if (selected != null)
                {
                    using (var context = new TTI2Entities())
                    {
                        var Dt = dtpTransDate.Value;
                        var ExistingGrouped = context.TLCMT_PanelIssue.Where(x => x.CMTPI_Closed && x.CMTPI_Date >= Dt && x.CMTPI_Department_FK == selected.Dep_Id).GroupBy(x => x.CMTPI_DeliveryNumber).ToList();
                        foreach (var Grp in ExistingGrouped)
                        {
                            PanelIssue.Add(Grp.FirstOrDefault());
                        }

                        formloaded = false;
                        cmboPrevious.DataSource    = PanelIssue;
                        cmboPrevious.ValueMember   = "CMTPI_Pk";
                        cmboPrevious.DisplayMember = "CMTPI_DeliveryNumber";
                        cmboPrevious.SelectedValue = -1;
                        formloaded = true;
                    }
                }
            }
            else
            {
                label2.Text = string.Empty;
                label6.Text = string.Empty;
                label7.Text = string.Empty;

                cmboPrevious.DataSource = null;
                cmboPrevious.Items.Clear();
            }
        }
コード例 #23
0
		void TileRow (Surface surf, Grp grp, byte[] pal, int l, int c, int r, int y)
		{
			Surface lsurf = GuiUtil.CreateSurfaceFromBitmap (grp.GetFrame (l),
									 grp.Width, grp.Height,
									 pal,
									 41, 0);

			Surface csurf = GuiUtil.CreateSurfaceFromBitmap (grp.GetFrame (c),
									 grp.Width, grp.Height,
									 pal,
									 41, 0);


			Surface rsurf = GuiUtil.CreateSurfaceFromBitmap (grp.GetFrame (r),
									 grp.Width, grp.Height,
									 pal,
									 41, 0);


			surf.Blit (lsurf, new Point (0,y));
			for (int x = grp.Width; x < surf.Width - grp.Width; x += grp.Width)
				surf.Blit (csurf, new Point (x, y));
			surf.Blit (rsurf, new Point (surf.Width - grp.Width,y));
		}
コード例 #24
0
    public bool readItem()
    {
        int wireTag;
        int wireType;
        int wireFieldNumber;
        Grp group = null;
        Itm item  = null;

        if (scannedField == null)
        {
            scannedField = new Fld();
        }

        do
        {
            scannedField.clear();

            if (this.eos)
            {
                return(false);
            }

            wireTag = read_rawvarint32();
            if (wireTag == 0)
            {
                return(false);
            }
            wireType = wireTag & TAG_TYPE_MASK;
            //wireFieldNumber = wireTag >>> TAG_TYPE_BITS;
            wireFieldNumber = (int)((uint)wireTag >> TAG_TYPE_BITS);

            item = null;

            switch (wireType)
            {
            case RAW_TYPE_END_GROUP:
            {
                item = stack.Pop();
                scannedField.name      = item.name;
                scannedField.level     = stack.Count;
                scannedField.index     = item.id;
                scannedField.isa_name  = item.isa.name;
                scannedField.type_name = "end_group";
                scannedField.is_end    = true;
            }
            break;

            case RAW_TYPE_FIXED32:
            {
                item = peekIsa(false).indexedItems[wireFieldNumber];
                scannedField.name  = item.name;
                scannedField.level = stack.Count;
                scannedField.index = item.id;
                switch (item.type)
                {
                case ITM_TYPE_FIXED32:
                    scannedField.type_name = "fixed32";
                    scannedField.value     = read_rawlittleendian32();
                    break;

                case ITM_TYPE_SINGLE:
                    scannedField.type_name = "single";
                    //scannedField.value = Float.intBitsToFloat(read_rawlittleendian32());
                    scannedField.value = BitConverter.ToSingle(BitConverter.GetBytes(read_rawlittleendian32()), 0);
                    break;

                default:
                    throw new Exception("bad type for fixed32");
                }
            }
            break;

            case RAW_TYPE_FIXED64:
            {
                item = peekIsa(false).indexedItems[wireFieldNumber];
                scannedField.name  = item.name;
                scannedField.level = stack.Count;
                scannedField.index = item.id;
                switch (item.type)
                {
                case ITM_TYPE_FIXED64:
                    scannedField.type_name = "fixed64";
                    scannedField.value     = read_rawlittleendian64();
                    break;

                case ITM_TYPE_DOUBLE:
                    scannedField.type_name = "double";
                    //scannedField.value = Double.longBitsToDouble(read_rawlittleendian64());
                    scannedField.value = BitConverter.Int64BitsToDouble(read_rawlittleendian64());
                    break;

                default:
                    throw new Exception("bad type for fixed64");
                }
            }
            break;

            case RAW_TYPE_LENGTH_DELIMITED:
            {
                item = peekIsa(false).indexedItems[wireFieldNumber];
                scannedField.name  = item.name;
                scannedField.level = stack.Count;
                scannedField.index = item.id;
                switch (item.type)
                {
                case ITM_TYPE_STRING:
                {
                    scannedField.type_name = "string";
                    scannedField.value     = read_rawstring();
                }
                break;

                case ITM_TYPE_BYTES:
                {
                    scannedField.type_name = "bytes";
                    int    size  = read_rawvarint32();
                    byte[] bytes = read_rawbytes(size);
                    scannedField.value = bytes;
                }
                break;

                default:
                    throw new Exception("bad type for length delimited");
                }
            }
            break;

            case RAW_TYPE_SCHEMA:
                switch (wireFieldNumber)
                {
                case 1:
                {
                    group      = new Grp();
                    group.type = (byte)read_rawbyte();
                    group.name = read_rawstring();
                    namedGroups.Add(group.name, group);
                    if (version == null)
                    {
                        version = group;
                    }
                }
                break;

                case 2:
                {
                    item      = new Itm();
                    item.type = (byte)read_rawbyte();
                    item.name = read_rawstring();
                    group     = namedGroups[read_rawstring()];
                    item.id   = ++group.count;
                    group.namedItems.Add(item.name, item);
                    group.indexedItems.Add(item.id, item);
                }
                break;

                case 3:
                {
                    item      = new Itm();
                    item.type = (byte)read_rawbyte();
                    item.name = read_rawstring();
                    group     = namedGroups[read_rawstring()];
                    item.id   = ++group.count;
                    item.isa  = namedGroups[read_rawstring()];
                    group.namedItems.Add(item.name, item);
                    group.indexedItems.Add(item.id, item);
                }
                break;

                default:
                    throw new Exception("bad field number for reserved");
                }
                break;

            case RAW_TYPE_START_GROUP:
            {
                item = peekIsa(false).indexedItems[wireFieldNumber];
                scannedField.name      = item.name;
                scannedField.index     = item.id;
                scannedField.level     = stack.Count;
                scannedField.type_name = "start_group";
                scannedField.is_start  = true;
                stack.Push(item);
            }
            break;

            case RAW_TYPE_VARINT:
            {
                item = peekIsa(false).indexedItems[wireFieldNumber];
                scannedField.name  = item.name;
                scannedField.level = stack.Count;
                scannedField.index = item.id;
                switch (item.type)
                {
                case ITM_TYPE_BOOLEAN:
                    scannedField.type_name = "bool";
                    scannedField.value     = read_rawvarint32() != 0;
                    break;

                case ITM_TYPE_ENUM:
                    scannedField.type_name = "enum";
                    scannedField.isa_name  = item.isa.name;
                    scannedField.value     = item.isa.indexedItems[read_rawvarint32()].name;
                    break;

                case ITM_TYPE_UINT32:
                    scannedField.type_name = "uint32";
                    scannedField.value     = read_rawvarint32();
                    break;

                case ITM_TYPE_UINT64:
                    scannedField.type_name = "uint64";
                    scannedField.value     = read_rawvarint64();
                    break;

                case ITM_TYPE_SINT32:
                    scannedField.type_name = "sint32";
                    {
                        int n = read_rawvarint32();
                        scannedField.value = ((int)((uint)n >> 1)) ^ -(n & 1);
                    }
                    break;

                case ITM_TYPE_SINT64:
                    scannedField.type_name = "sint64";
                    {
                        long n = read_rawvarint64();
                        scannedField.value = ((long)((ulong)n >> 1)) ^ -(n & 1);
                    }
                    break;

                default:
                    throw new Exception("bad type for readVarint");
                }
            }
            break;

            default:
                throw new Exception("invalidwiretype");
            }
        } while (wireType == RAW_TYPE_SCHEMA);

        return(true);
    }
コード例 #25
0
    private Itm ensureItem(bool write, string parentName, byte parentType, string itemName, byte itemType, string isaName, byte isaType)
    {
        Grp parent = ensureGroup(write, parentName, parentType);

        return(ensureItem(write, parent, itemName, itemType, isaName, isaType));
    }
コード例 #26
0
ファイル: GrpButtonElement.cs プロジェクト: directhex/scsharp
 public GrpButtonElement(UIScreen screen, Grp grp, byte[] palette, ushort x, ushort y)
     : base(screen, grp, palette, x, y)
 {
 }
コード例 #27
0
        protected override void ResourceLoader()
        {
            base.ResourceLoader();

            /* create the element corresponding to the hud */
            hudElement         = new ImageElement(this, 0, 0, 640, 480, TranslucentIndex);
            hudElement.Text    = String.Format(Builtins.Game_ConsolePcx, Util.RaceCharLower[(int)Game.Instance.Race]);
            hudElement.Visible = true;
            Elements.Add(hudElement);

            /* create the portrait playing area */
            portraitElement         = new MovieElement(this, 415, 415, 48, 48, false);
            portraitElement.Visible = true;
            Elements.Add(portraitElement);

            Pcx pcx = new Pcx();

            pcx.ReadFromStream((Stream)mpq.GetResource("game\\tunit.pcx"), -1, -1);
            //unit_palette = pcx.Palette;

            pcx = new Pcx();
            pcx.ReadFromStream((Stream)mpq.GetResource("tileset\\badlands\\dark.pcx"), 0, 0);
            tileset_palette = pcx.Palette;

            if (scenario.Tileset == Tileset.Platform)
            {
                Spk starfield = (Spk)mpq.GetResource("parallax\\star.spk");

                starfield_layers = new Surface [starfield.Layers.Length];
                for (int i = 0; i < starfield_layers.Length; i++)
                {
                    starfield_layers[i] = new Surface(Painter.SCREEN_RES_X, Painter.SCREEN_RES_Y);

                    starfield_layers[i].TransparentColor = Color.Black;

                    for (int o = 0; o < starfield.Layers[i].Objects.Length; o++)
                    {
                        ParallaxObject obj = starfield.Layers[i].Objects[o];

                        starfield_layers[i].Fill(new Rectangle(new Point(obj.X, obj.Y), new Size(2, 2)),
                                                 Color.White);
                    }
                }
            }

            mapRenderer = new MapRenderer(mpq, scenario, Painter.SCREEN_RES_X, Painter.SCREEN_RES_Y);

            // load the cursors we'll show when scrolling with the mouse
            string[] cursornames = new string[] {
                "cursor\\ScrollUL.grp",
                "cursor\\ScrollU.grp",
                "cursor\\ScrollUR.grp",
                "cursor\\ScrollR.grp",
                "cursor\\ScrollDR.grp",
                "cursor\\ScrollD.grp",
                "cursor\\ScrollDL.grp",
                "cursor\\ScrollL.grp",
            };
            ScrollCursors = new CursorAnimator [cursornames.Length];
            for (int i = 0; i < cursornames.Length; i++)
            {
                ScrollCursors[i] = new CursorAnimator((Grp)mpq.GetResource(cursornames[i]),
                                                      effectpal.Palette);
                ScrollCursors[i].SetHotSpot(60, 60);
            }

            // load the mag cursors
            string[] magcursornames = new string[] {
                "cursor\\MagG.grp",
                "cursor\\MagY.grp",
                "cursor\\MagR.grp"
            };
            MagCursors = new CursorAnimator [magcursornames.Length];
            for (int i = 0; i < magcursornames.Length; i++)
            {
                MagCursors[i] = new CursorAnimator((Grp)mpq.GetResource(magcursornames[i]),
                                                   effectpal.Palette);
                MagCursors[i].SetHotSpot(60, 60);
            }

            // load the targeting cursors
            string[] targetcursornames = new string[] {
                "cursor\\TargG.grp",
                "cursor\\TargY.grp",
                "cursor\\TargR.grp"
            };
            TargetCursors = new CursorAnimator [targetcursornames.Length];
            for (int i = 0; i < targetcursornames.Length; i++)
            {
                TargetCursors[i] = new CursorAnimator((Grp)mpq.GetResource(targetcursornames[i]),
                                                      effectpal.Palette);
                TargetCursors[i].SetHotSpot(60, 60);
            }

            /* the following could be made global to speed up the entry to the game screen.. */
            statTxt = (Tbl)mpq.GetResource("rez\\stat_txt.tbl");

            // load the wireframe image info
            wireframe = (Grp)mpq.GetResource("unit\\wirefram\\wirefram.grp");

            // load the command icons
            cmdicons = (Grp)mpq.GetResource("unit\\cmdbtns\\cmdicons.grp");
            pcx      = new Pcx();
            pcx.ReadFromStream((Stream)mpq.GetResource("unit\\cmdbtns\\ticon.pcx"), 0, 0);
            cmdicon_palette = pcx.Palette;

            // create the wireframe display element
            wireframeElement         = new GrpElement(this, wireframe, cmdicon_palette, 170, 390);
            wireframeElement.Visible = false;
            Elements.Add(wireframeElement);

            labelElements = new LabelElement [(int)HudLabels.Count];

            labelElements[(int)HudLabels.UnitName] = new LabelElement(this, fontpal.Palette,
                                                                      GuiUtil.GetFonts(Mpq)[1],
                                                                      254, 390);
            labelElements[(int)HudLabels.ResourceUsed] = new LabelElement(this, fontpal.Palette,
                                                                          GuiUtil.GetFonts(Mpq)[0],
                                                                          292, 420);
            labelElements[(int)HudLabels.ResourceProvided] = new LabelElement(this, fontpal.Palette,
                                                                              GuiUtil.GetFonts(Mpq)[0],
                                                                              292, 434);
            labelElements[(int)HudLabels.ResourceTotal] = new LabelElement(this, fontpal.Palette,
                                                                           GuiUtil.GetFonts(Mpq)[0],
                                                                           292, 448);
            labelElements[(int)HudLabels.ResourceMax] = new LabelElement(this, fontpal.Palette,
                                                                         GuiUtil.GetFonts(Mpq)[0],
                                                                         292, 462);

            for (int i = 0; i < labelElements.Length; i++)
            {
                Elements.Add(labelElements[i]);
            }

            cmdButtonElements = new GrpButtonElement[9];
            int x = 0;
            int y = 0;

            for (int i = 0; i < cmdButtonElements.Length; i++)
            {
                cmdButtonElements[i] = new GrpButtonElement(this, cmdicons, cmdicon_palette, button_xs[x], button_ys[y]);
                x++;
                if (x == 3)
                {
                    x = 0;
                    y++;
                }
                cmdButtonElements[i].Visible = false;
                Elements.Add(cmdButtonElements[i]);
            }

            PlaceInitialUnits();

            Events.Tick += ScrollTick;
        }
        public bool readItem()
        {
            int wireTag;
            int wireType;
            int wireFieldNumber;
            Grp group = null;
            Itm item = null;

            if (scannedField == null)
            {
                scannedField = new Fld();
            }

            do
            {
                scannedField.clear();

                if (this.eos)
                {
                    return false;
                }

                wireTag = read_rawvarint32();
                if (wireTag == 0)
                {
                    return false;
                }
                wireType = wireTag & TAG_TYPE_MASK;
                //wireFieldNumber = wireTag >>> TAG_TYPE_BITS;
                wireFieldNumber = (int)((uint)wireTag >> TAG_TYPE_BITS);

                item = null;

                switch (wireType)
                {
                    case RAW_TYPE_END_GROUP:
                        {
                            item = stack.Pop();
                            scannedField.name = item.name;
                            scannedField.level = stack.Count;
                            scannedField.index = item.id;
                            scannedField.isa_name = item.isa.name;
                            scannedField.type_name = "end_group";
                            scannedField.is_end = true;
                        }
                        break;
                    case RAW_TYPE_FIXED32:
                        {
                            item = peekIsa(false).indexedItems[wireFieldNumber];
                            scannedField.name = item.name;
                            scannedField.level = stack.Count;
                            scannedField.index = item.id;
                            switch (item.type)
                            {
                                case ITM_TYPE_FIXED32:
                                    scannedField.type_name = "fixed32";
                                    scannedField.value = read_rawlittleendian32();
                                    break;
                                case ITM_TYPE_SINGLE:
                                    scannedField.type_name = "single";
                                    //scannedField.value = Float.intBitsToFloat(read_rawlittleendian32());
                                    scannedField.value = BitConverter.ToSingle(BitConverter.GetBytes(read_rawlittleendian32()), 0);
                                    break;
                                default:
                                    throw new Exception("bad type for fixed32");
                            }
                        }
                        break;
                    case RAW_TYPE_FIXED64:
                        {
                            item = peekIsa(false).indexedItems[wireFieldNumber];
                            scannedField.name = item.name;
                            scannedField.level = stack.Count;
                            scannedField.index = item.id;
                            switch (item.type)
                            {
                                case ITM_TYPE_FIXED64:
                                    scannedField.type_name = "fixed64";
                                    scannedField.value = read_rawlittleendian64();
                                    break;
                                case ITM_TYPE_DOUBLE:
                                    scannedField.type_name = "double";
                                    //scannedField.value = Double.longBitsToDouble(read_rawlittleendian64());
                                    scannedField.value = BitConverter.Int64BitsToDouble(read_rawlittleendian64());
                                    break;
                                default:
                                    throw new Exception("bad type for fixed64");
                            }
                        }
                        break;
                    case RAW_TYPE_LENGTH_DELIMITED:
                        {
                            item = peekIsa(false).indexedItems[wireFieldNumber];
                            scannedField.name = item.name;
                            scannedField.level = stack.Count;
                            scannedField.index = item.id;
                            switch (item.type)
                            {
                                case ITM_TYPE_STRING:
                                {
                                    scannedField.type_name = "string";
                                    scannedField.value = read_rawstring() ;
                                }
                                    break;
                                case ITM_TYPE_BYTES:
                                {
                                    scannedField.type_name = "bytes";
                                    int size = read_rawvarint32();
                                    byte[] bytes = read_rawbytes(size);
                                    scannedField.value = bytes;
                                }
                                    break;
                                default:
                                    throw new Exception("bad type for length delimited");
                            }
                        }
                        break;
                    case RAW_TYPE_SCHEMA:
                        switch (wireFieldNumber)
                        {
                            case 1:
                                {
                                    group = new Grp();
                                    group.type = (byte)read_rawbyte();
                                    group.name = read_rawstring() ;
                                    namedGroups.Add(group.name, group);
                                    if (version == null)
                                    {
                                        version = group;
                                    }
                                }
                                break;
                            case 2:
                                {
                                    item = new Itm();
                                    item.type = (byte)read_rawbyte();
                                    item.name = read_rawstring() ;
                                    group = namedGroups[read_rawstring()] ;
                                    item.id = ++group.count;
                                    group.namedItems.Add(item.name, item);
                                    group.indexedItems.Add(item.id, item);
                                }
                                break;
                            case 3:
                                {
                                    item = new Itm();
                                    item.type = (byte)read_rawbyte();
                                    item.name = read_rawstring() ;
                                    group = namedGroups[read_rawstring()] ;
                                    item.id = ++group.count;
                                    item.isa = namedGroups[read_rawstring()];
                                    group.namedItems.Add(item.name, item);
                                    group.indexedItems.Add(item.id, item);
                                }
                                break;
                            default:
                                throw new Exception("bad field number for reserved");

                        }
                        break;
                    case RAW_TYPE_START_GROUP:
                        {
                            item = peekIsa(false).indexedItems[wireFieldNumber];
                            scannedField.name = item.name;
                            scannedField.index = item.id;
                            scannedField.level = stack.Count;
                            scannedField.type_name = "start_group";
                            scannedField.is_start = true;
                            stack.Push(item);
                        }
                        break;
                    case RAW_TYPE_VARINT:
                        {
                            item = peekIsa(false).indexedItems[wireFieldNumber];
                            scannedField.name = item.name;
                            scannedField.level = stack.Count;
                            scannedField.index = item.id;
                            switch (item.type)
                            {
                                case ITM_TYPE_BOOLEAN:
                                    scannedField.type_name = "bool";
                                    scannedField.value = read_rawvarint32() != 0;
                                    break;
                                case ITM_TYPE_ENUM:
                                    scannedField.type_name = "enum";
                                    scannedField.isa_name = item.isa.name;
                                    scannedField.value = item.isa.indexedItems[read_rawvarint32()].name;
                                    break;
                                case ITM_TYPE_UINT32:
                                    scannedField.type_name = "uint32";
                                    scannedField.value = read_rawvarint32();
                                    break;
                                case ITM_TYPE_UINT64:
                                    scannedField.type_name = "uint64";
                                    scannedField.value = read_rawvarint64();
                                    break;
                                case ITM_TYPE_SINT32:
                                    scannedField.type_name = "sint32";
                                    {
                                        int n = read_rawvarint32();
                                        scannedField.value = ((int)((uint)n >> 1)) ^ -(n & 1);
                                    }
                                    break;
                                case ITM_TYPE_SINT64:
                                    scannedField.type_name = "sint64";
                                    {
                                        long n = read_rawvarint64();
                                        scannedField.value = ((long)((ulong)n >> 1)) ^ -(n & 1); 
                                    }
                                    break;
                                default:
                                    throw new Exception("bad type for readVarint");
                            }
                        }
                        break;
                    default:
                        throw new Exception("invalidwiretype");
                }
            } while (wireType == RAW_TYPE_SCHEMA);

            return true;
        }
 private Grp ensureGroup( bool write,  string groupName,  byte groupType)
 {
     Grp g = null;
     if (namedGroups.ContainsKey(groupName))
     {
         g = namedGroups[groupName];
         if (g.type != groupType) {
     	    throw new Exception ("bad group type") ;
         }
     }
     else
     {
         g = new Grp();
         write_raw_varint32((1 << TAG_TYPE_BITS) | RAW_TYPE_SCHEMA);
         write_rawbyte(groupType);
         write_rawstring(groupName) ;
         g.type = groupType;
         g.name = groupName;
         namedGroups.Add(g.name, g);
     }
     if (version == null)
     {
         version = g;
     }
     return g;
 }
        private Itm ensureItem( bool write,  Grp parent,  string itemName,  byte itemType,  string isaName,  byte isaType)
        {
            Grp isa = null;

            if (!string.IsNullOrEmpty(isaName))
            {
                isa = ensureGroup(write, isaName, isaType);
            }
            return ensureItem(write, parent, itemName, itemType, isa);
        }
        private Itm ensureItem( bool write,  Grp parent,  string itemName,  byte itemType,  Grp isa)
        {
            Itm item = null;

            if (parent.namedItems.ContainsKey(itemName))
            {
                item = parent.namedItems[itemName];
                if (itemType != item.type)
                {
                    throw new Exception("itemtypemismatch");
                }
            }
            else
            {
                item = new Itm();
                item.id = ++parent.count;
                item.name = itemName;
                item.type = itemType;
                item.isa = isa;
                parent.namedItems.Add(item.name, item);
                parent.indexedItems.Add(item.id, item);
                {
                    if (item.isa == null) {
                        write_raw_varint32((2 << TAG_TYPE_BITS) | RAW_TYPE_SCHEMA);
                    }
                    else {
                        write_raw_varint32((3 << TAG_TYPE_BITS) | RAW_TYPE_SCHEMA);
                    }
                    write_rawbyte(item.type);
                    write_rawstring(item.name); 
                    write_rawstring(parent.name); 
                    if (item.isa != null) {
                	    write_rawstring(item.isa.name); 
                    }
                }
            }
            return item;
        }
コード例 #32
0
ファイル: Sprite.cs プロジェクト: carriercomm/scsharp
		public Sprite (Sprite parentSprite, ushort images_entry, byte[] palette)
		{
			this.parent_sprite = parentSprite;
			this.mpq = parentSprite.mpq;
			this.palette = palette;
			this.images_entry = images_entry;

			uint grp_index = GlobalResources.Instance.ImagesDat.GrpIndexes [images_entry];

			grp_path = GlobalResources.Instance.ImagesTbl[(int)grp_index-1];

			grp = (Grp)mpq.GetResource ("unit\\" + grp_path);

			this.buf = GlobalResources.Instance.IScriptBin.Contents;
			iscript_entry = GlobalResources.Instance.ImagesDat.IScriptIndexes [images_entry];

			script_entry_offset = GlobalResources.Instance.IScriptBin.GetScriptEntryOffset (iscript_entry);

			Console.WriteLine ("new dependent sprite: unit\\{0} (image {1}, iscript id {2}, script_entry_offset {3:X})",
					   grp_path, images_entry, iscript_entry, script_entry_offset);

			/* make sure the offset points to "SCEP" */
			if (Util.ReadDWord (buf, script_entry_offset) != 0x45504353)
				Console.WriteLine ("invalid script_entry_offset");

			int x, y;
			parentSprite.GetPosition (out x, out y);
			SetPosition (x,y);
		}
コード例 #33
0
ファイル: Sprite.cs プロジェクト: carriercomm/scsharp
		public Sprite (Mpq mpq, int sprite_entry, byte[] palette, int x, int y)
		{
			this.mpq = mpq;
			this.palette = palette;

			images_entry = GlobalResources.Instance.SpritesDat.ImagesDatEntries [sprite_entry];
			//			Console.WriteLine ("image_dat_entry == {0}", images_entry);

			uint grp_index = GlobalResources.Instance.ImagesDat.GrpIndexes [images_entry];
			//			Console.WriteLine ("grp_index = {0}", grp_index);
			grp_path = GlobalResources.Instance.ImagesTbl[(int)grp_index-1];
			//			Console.WriteLine ("grp_path = {0}", grp_path);

			grp = (Grp)mpq.GetResource ("unit\\" + grp_path);

			iscript_entry = GlobalResources.Instance.ImagesDat.IScriptIndexes [images_entry];
			script_entry_offset = GlobalResources.Instance.IScriptBin.GetScriptEntryOffset (iscript_entry);

			Console.WriteLine ("new sprite: unit\\{0} @ {1}x{2} (image {3}, iscript id {4}, script_entry_offset {5:X})",
					   grp_path, x, y, images_entry, iscript_entry, script_entry_offset);

			this.buf = GlobalResources.Instance.IScriptBin.Contents;

			/* make sure the offset points to "SCPE" */
			if (Util.ReadDWord (buf, script_entry_offset) != 0x45504353)
				Console.WriteLine ("invalid script_entry_offset");

			SetPosition (x,y);
		}
コード例 #34
0
        public PagedList <CustomerOrderInfoExt> GetCustomerOrderInfoList(CustomerOrderParam param, int maxCustomerOrderId = 0)
        {
            var ctx = this.UnitOfWork as LMS_DbContext;

            Check.Argument.IsNotNull(ctx, "数据库对象");
            IQueryable <CustomerOrderInfoExt> list;
            int deleteSatus = CustomerOrder.StatusEnum.Delete.GetStatusValue();
            Expression <Func <CustomerOrderInfo, bool> > filter        = o => true;
            Expression <Func <WayBillInfo, bool> >       filterWayBill = o => true;

            filter = filter.AndIf(o => o.IsHold == param.IsHold.Value, param.IsHold.HasValue)
                     .AndIf(o => o.CustomerCode == param.CustomerCode, !param.CustomerCode.IsNullOrWhiteSpace())
                     .AndIf(o => o.Status == param.Status.Value, param.Status.HasValue)
                     .AndIf(o => o.Status != deleteSatus, !param.Status.HasValue)
                     .AndIf(o => o.CustomerOrderID <= maxCustomerOrderId, maxCustomerOrderId > 0)
            ;
            //Expression<Func<InStorageInfo, bool>> filterInStorage = o => true;
            //Expression<Func<OutStorageInfo, bool>> filterOutStorage = o => true;
            //Func<IQueryable<WayBillInfo>, IOrderedQueryable<WayBillInfo>> orderFunc;
            if (!string.IsNullOrWhiteSpace(param.SearchContext))
            {
                var numberList =
                    param.SearchContext.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
                    .ToList();
                if (param.SearchWhere.HasValue && numberList.Count > 0)
                {
                    switch (WayBill.ParseToSearchFilter(param.SearchWhere.Value))
                    {
                    case WayBill.SearchFilterEnum.WayBillNumber:
                        filterWayBill = filterWayBill.And(p => numberList.Contains(p.WayBillNumber));
                        break;

                    case WayBill.SearchFilterEnum.TrackingNumber:
                        filter = filter.And(p => numberList.Contains(p.TrackingNumber));
                        break;

                    case WayBill.SearchFilterEnum.CustomerOrderNumber:
                        filter = filter.And(p => numberList.Contains(p.CustomerOrderNumber));
                        break;
                    }
                }
            }
            else if (!param.CustomerOrderNumber.IsNullOrWhiteSpace())
            {
                var numberList =
                    param.CustomerOrderNumber.Split(Environment.NewLine.ToCharArray(),
                                                    StringSplitOptions.RemoveEmptyEntries)
                    .ToList();

                if (numberList.Count > 0)
                {
                    string number = numberList[0];
                    filter = numberList.Count == 1
                                 ? filter.And(o => o.CustomerOrderNumber == number)
                                 : filter.And(o => numberList.Contains(o.CustomerOrderNumber));
                }
            }

            if (param.IsReceived)
            {
                filterWayBill = filterWayBill
                                .AndIf(o => o.InStorageCreatedOn >= param.CreatedOnFrom.Value, param.CreatedOnFrom.HasValue)
                                .AndIf(o => o.InStorageCreatedOn <= param.CreatedOnTo.Value, param.CreatedOnTo.HasValue);
            }
            else if (param.IsDeliver)
            {
                filterWayBill = filterWayBill
                                .AndIf(o => o.OutStorageCreatedOn >= param.CreatedOnFrom.Value, param.CreatedOnFrom.HasValue)
                                .AndIf(o => o.OutStorageCreatedOn <= param.CreatedOnTo.Value, param.CreatedOnTo.HasValue);
            }
            else
            {
                filter = filter
                         .AndIf(o => o.CreatedOn >= param.CreatedOnFrom.Value, param.CreatedOnFrom.HasValue)
                         .AndIf(o => o.CreatedOn <= param.CreatedOnTo.Value, param.CreatedOnTo.HasValue);
            }

            filter = filter
                     .AndIf(o => o.ShippingMethodId == param.ShippingMethodId.Value, param.ShippingMethodId.HasValue)
                     .AndIf(o => o.ShippingInfo.CountryCode == param.CountryCode, !param.CountryCode.IsNullOrWhiteSpace())
                     .AndIf(o => o.IsPrinted == param.IsPrinted.Value, param.IsPrinted.HasValue);
            //}



            if (param.SearchWhere.HasValue && !string.IsNullOrWhiteSpace(param.SearchContext))
            {
                if (param.IsDeliver)
                {
                    list = from w in ctx.WayBillInfos.Where(filterWayBill)
                           join o in ctx.CustomerOrderInfos.Where(filter) on w.CustomerOrderID equals o.CustomerOrderID
                           orderby w.OutStorageCreatedOn descending
                           select new CustomerOrderInfoExt
                    {
                        CustomerCode        = o.CustomerCode,
                        CustomerOrderID     = o.CustomerOrderID,
                        CustomerOrderNumber = o.CustomerOrderNumber,
                        WayBillNumber       = w.WayBillNumber,
                        Status             = o.Status,
                        TrackingNumber     = o.TrackingNumber,
                        RawTrackingNumber  = w.RawTrackingNumber,
                        CountryCode        = w.CountryCode,
                        Weight             = w.Weight ?? 0,
                        SettleWeight       = w.SettleWeight,
                        Width              = w.Width ?? 0,
                        Height             = w.Height ?? 0,
                        Length             = w.Length ?? 0,
                        ShippingMethodId   = w.InShippingMethodID,
                        ShippingMethodName = w.InShippingMethodName,
                        CreatedOn          = w.OutStorageCreatedOn ?? DateTime.Now,
                        TransferOrderDate  = w.TransferOrderDate,
                    };
                }
                else if (param.IsReceived)
                {
                    list = from w in ctx.WayBillInfos.Where(filterWayBill)
                           //join i in ctx.InStorageInfos.Where(filterInStorage) on w.InStorageID equals i.InStorageID
                           join o in ctx.CustomerOrderInfos.Where(filter) on w.CustomerOrderID equals o.CustomerOrderID
                           orderby w.InStorageCreatedOn descending
                           select new CustomerOrderInfoExt
                    {
                        CustomerCode        = o.CustomerCode,
                        CustomerOrderID     = o.CustomerOrderID,
                        CustomerOrderNumber = o.CustomerOrderNumber,
                        WayBillNumber       = w.WayBillNumber,
                        Status             = o.Status,
                        TrackingNumber     = o.TrackingNumber,
                        RawTrackingNumber  = w.RawTrackingNumber,
                        CountryCode        = w.CountryCode,
                        Weight             = w.Weight ?? 0,
                        SettleWeight       = w.SettleWeight,
                        Width              = w.Width ?? 0,
                        Height             = w.Height ?? 0,
                        Length             = w.Length ?? 0,
                        ShippingMethodId   = w.InShippingMethodID,
                        ShippingMethodName = w.InShippingMethodName,
                        CreatedOn          = w.InStorageCreatedOn ?? DateTime.Now,
                        TransferOrderDate  = w.TransferOrderDate,
                    };
                }
                else
                {
                    list = from w in ctx.WayBillInfos.Where(filterWayBill)
                           join o in ctx.CustomerOrderInfos.Where(filter) on w.CustomerOrderID equals o.CustomerOrderID
                           orderby o.CreatedOn descending
                           select new CustomerOrderInfoExt
                    {
                        CustomerCode        = o.CustomerCode,
                        CustomerOrderID     = o.CustomerOrderID,
                        CustomerOrderNumber = o.CustomerOrderNumber,
                        WayBillNumber       = w.WayBillNumber,
                        Status             = o.Status,
                        TrackingNumber     = o.TrackingNumber,
                        RawTrackingNumber  = w.RawTrackingNumber,
                        CountryCode        = w.CountryCode,
                        Weight             = w.Weight ?? 0,
                        SettleWeight       = w.SettleWeight,
                        Width              = w.Width ?? 0,
                        Height             = w.Height ?? 0,
                        Length             = w.Length ?? 0,
                        ShippingMethodId   = w.InShippingMethodID,
                        ShippingMethodName = w.InShippingMethodName,
                        CreatedOn          = o.CreatedOn,
                        TransferOrderDate  = w.TransferOrderDate,
                        Remark             = o.Remark,
                    };
                }
            }
            else
            {
                //if (param.IsDeliver)
                //{
                //    list = from o in ctx.CustomerOrderInfos.Where(filter)
                //           join w in ctx.WayBillInfos.Where(filterWayBill) on o.CustomerOrderID equals w.CustomerOrderID
                //           into Grp
                //           from grp in Grp.DefaultIfEmpty()
                //           orderby grp.TransferOrderDate descending, grp.CreatedOn descending
                //           select new CustomerOrderInfoExt
                //           {
                //               CustomerCode = o.CustomerCode,
                //               CustomerOrderID = o.CustomerOrderID,
                //               CustomerOrderNumber = o.CustomerOrderNumber,
                //               WayBillNumber = grp.WayBillNumber,
                //               Status = o.Status,
                //               TrackingNumber = o.TrackingNumber,
                //               RawTrackingNumber = grp.RawTrackingNumber,
                //               CountryCode = o.ShippingInfo.CountryCode,
                //               Weight = grp.Weight ?? 0,
                //               SettleWeight = grp.SettleWeight,
                //               Width = grp.Width ?? 0,
                //               Height = grp.Height ?? 0,
                //               Length = grp.Length ?? 0,
                //               ShippingMethodId = o.ShippingMethodId,
                //               ShippingMethodName = o.ShippingMethodName,
                //               CreatedOn = grp.CreatedOn,
                //               TransferOrderDate = grp.TransferOrderDate,
                //           };
                //}else if (param.IsReceived)
                //{
                //    list = from o in ctx.CustomerOrderInfos.Where(filter)
                //           join w in ctx.WayBillInfos.Where(filterWayBill) on o.CustomerOrderID equals w.CustomerOrderID
                //           join i in ctx.InStorageInfos.Where(filterInStorage) on w.InStorageID equals i.InStorageID into Grp
                //           from grp in Grp.DefaultIfEmpty()
                //           orderby w.TransferOrderDate descending, grp.CreatedOn descending
                //           select new CustomerOrderInfoExt
                //           {
                //               CustomerCode = o.CustomerCode,
                //               CustomerOrderID = o.CustomerOrderID,
                //               CustomerOrderNumber = o.CustomerOrderNumber,
                //               WayBillNumber = w.WayBillNumber,
                //               Status = o.Status,
                //               TrackingNumber = o.TrackingNumber,
                //               RawTrackingNumber = w.RawTrackingNumber,
                //               CountryCode = o.ShippingInfo.CountryCode,
                //               Weight = w.Weight ?? 0,
                //               SettleWeight = w.SettleWeight,
                //               Width = w.Width ?? 0,
                //               Height = w.Height ?? 0,
                //               Length = w.Length ?? 0,
                //               ShippingMethodId = o.ShippingMethodId,
                //               ShippingMethodName = o.ShippingMethodName,
                //               CreatedOn = grp.CreatedOn,
                //               TransferOrderDate = w.TransferOrderDate,
                //           };
                //}
                //else
                //{
                if (param.Status.HasValue)
                {
                    switch (CustomerOrder.ParseToStatus(param.Status.Value))
                    {
                    case CustomerOrder.StatusEnum.None:
                    case CustomerOrder.StatusEnum.OK:
                    case CustomerOrder.StatusEnum.SubmitFail:
                        list = from o in ctx.CustomerOrderInfos.Where(filter)
                               orderby o.CreatedOn descending
                               select new CustomerOrderInfoExt
                        {
                            CustomerCode        = o.CustomerCode,
                            CustomerOrderID     = o.CustomerOrderID,
                            CustomerOrderNumber = o.CustomerOrderNumber,
                            WayBillNumber       = "",
                            Status             = o.Status,
                            TrackingNumber     = o.TrackingNumber,
                            RawTrackingNumber  = "",
                            CountryCode        = "",
                            Weight             = o.Weight,
                            SettleWeight       = 0,
                            Width              = o.Width,
                            Height             = o.Height,
                            Length             = o.Length,
                            ShippingMethodId   = o.ShippingMethodId,
                            ShippingMethodName = o.ShippingMethodName,
                            CreatedOn          = o.CreatedOn,
                            TransferOrderDate  = null,
                            Remark             = o.Remark,
                        };
                        break;

                    default:
                        list = from o in ctx.CustomerOrderInfos.Where(filter)
                               join w in ctx.WayBillInfos.Where(filterWayBill) on o.CustomerOrderID equals w.CustomerOrderID
                               into Grp
                               from grp in Grp.DefaultIfEmpty()
                               orderby grp.TransferOrderDate descending, o.CreatedOn descending, grp.WayBillNumber descending
                        select new CustomerOrderInfoExt
                        {
                            CustomerCode        = o.CustomerCode,
                            CustomerOrderID     = o.CustomerOrderID,
                            CustomerOrderNumber = o.CustomerOrderNumber,
                            WayBillNumber       = grp.WayBillNumber,
                            Status             = o.Status,
                            TrackingNumber     = o.TrackingNumber,
                            RawTrackingNumber  = grp.RawTrackingNumber,
                            CountryCode        = grp.CountryCode,
                            Weight             = grp.Weight ?? 0,
                            SettleWeight       = grp.SettleWeight,
                            Width              = grp.Width ?? 0,
                            Height             = grp.Height ?? 0,
                            Length             = grp.Length ?? 0,
                            ShippingMethodId   = o.ShippingMethodId,
                            ShippingMethodName = o.ShippingMethodName,
                            CreatedOn          = o.CreatedOn,
                            TransferOrderDate  = grp.TransferOrderDate,
                            Remark             = o.Remark,
                        };
                        break;
                    }
                }
                else
                {
                    list = from o in ctx.CustomerOrderInfos.Where(filter)
                           join w in ctx.WayBillInfos.Where(filterWayBill) on o.CustomerOrderID equals w.CustomerOrderID
                           into Grp
                           from grp in Grp.DefaultIfEmpty()
                           orderby grp.TransferOrderDate descending, o.CreatedOn descending, grp.WayBillNumber descending
                    select new CustomerOrderInfoExt
                    {
                        CustomerCode        = o.CustomerCode,
                        CustomerOrderID     = o.CustomerOrderID,
                        CustomerOrderNumber = o.CustomerOrderNumber,
                        WayBillNumber       = grp.WayBillNumber,
                        Status             = o.Status,
                        TrackingNumber     = o.TrackingNumber,
                        RawTrackingNumber  = grp.RawTrackingNumber,
                        CountryCode        = grp.CountryCode,
                        Weight             = grp.Weight ?? 0,
                        SettleWeight       = grp.SettleWeight,
                        Width              = grp.Width ?? 0,
                        Height             = grp.Height ?? 0,
                        Length             = grp.Length ?? 0,
                        ShippingMethodId   = o.ShippingMethodId,
                        ShippingMethodName = o.ShippingMethodName,
                        CreatedOn          = o.CreatedOn,
                        TransferOrderDate  = grp.TransferOrderDate,
                        Remark             = o.Remark,
                    };
                }
                //}
            }

            return(list.ToPagedList(param.Page, param.PageSize));
        }
コード例 #35
0
		protected virtual void ResourceLoader ()
		{
			Stream s;

			fontpal = null;
			effectpal = null;

			if (fontpal_path != null) {
				Console.WriteLine ("loading font palette");
				s = (Stream)mpq.GetResource (fontpal_path);
				if (s != null) {
					fontpal = new Pcx ();
					fontpal.ReadFromStream (s, -1, -1);
				}
			}
			if (effectpal_path != null) {
				Console.WriteLine ("loading cursor palette");
				s = (Stream)mpq.GetResource (effectpal_path);
				if (s != null) {
					effectpal = new Pcx ();
					effectpal.ReadFromStream (s, -1, -1);
				}
				if (effectpal != null && arrowgrp_path != null) {
					Console.WriteLine ("loading arrow cursor");
					Grp arrowgrp = (Grp)mpq.GetResource (arrowgrp_path);
					if (arrowgrp != null) {
						Cursor = new CursorAnimator (arrowgrp, effectpal.Palette);
						Cursor.SetHotSpot (64, 64);
					}
				}
			}

			if (background_path != null) {
				Console.WriteLine ("loading background");
				background = GuiUtil.SurfaceFromStream ((Stream)mpq.GetResource (background_path),
									background_translucent, background_transparent);
			}

			Elements = new List<UIElement> ();
			if (binFile != null) {
				Console.WriteLine ("loading ui elements");
				Bin = (Bin)mpq.GetResource (binFile);

				if (Bin == null)
					throw new Exception (String.Format ("specified file '{0}' does not exist",
									    binFile));

				/* convert all the BinElements to UIElements for our subclasses to use */
				foreach (BinElement el in Bin.Elements) {
					//					Console.WriteLine ("{0}: {1}", el.text, el.flags);

					UIElement ui_el = null;
					switch (el.type) {
					case ElementType.DialogBox:
						ui_el = new DialogBoxElement (this, el, fontpal.RgbData);
						break;
					case ElementType.Image:
						ui_el = new ImageElement (this, el, fontpal.RgbData, translucentIndex);
						break;
					case ElementType.TextBox:
						ui_el = new TextBoxElement (this, el, fontpal.RgbData);
						break;
					case ElementType.ListBox:
						ui_el = new ListBoxElement (this, el, fontpal.RgbData);
						break;
					case ElementType.ComboBox:
						ui_el = new ComboBoxElement (this, el, fontpal.RgbData);
						break;
					case ElementType.LabelLeftAlign:
					case ElementType.LabelCenterAlign:
					case ElementType.LabelRightAlign:
						ui_el = new LabelElement (this, el, fontpal.RgbData);
						break;
					case ElementType.Button:
					case ElementType.DefaultButton:
					case ElementType.ButtonWithoutBorder:
						ui_el = new ButtonElement(this, el, fontpal.RgbData);
						break;
					case ElementType.Slider:
					case ElementType.OptionButton:
					case ElementType.CheckBox:
						ui_el = new UIElement (this, el, fontpal.RgbData);
						break;
					default:
						Console.WriteLine ("unhandled case {0}", el.type);
						ui_el = new UIElement (this, el, fontpal.RgbData);
						break;
					}

					Elements.Add (ui_el);
				}
			}

			UIPainter = new UIPainter (Elements);
		}
コード例 #36
0
ファイル: GameScreen.cs プロジェクト: carriercomm/scsharp
		protected override void ResourceLoader ()
		{
			base.ResourceLoader ();

			/* create the element corresponding to the hud */
			hudElement = new ImageElement (this, 0, 0, 640, 480, TranslucentIndex);
			hudElement.Text = String.Format (Builtins.Game_ConsolePcx, Util.RaceCharLower[(int)Game.Instance.Race]);
			hudElement.Visible = true;
			Elements.Add (hudElement);

			/* create the portrait playing area */
			portraitElement = new MovieElement (this, 415, 415, 48, 48, false);
			portraitElement.Visible = true;
			Elements.Add (portraitElement);
			
			Pcx pcx = new Pcx ();
			pcx.ReadFromStream ((Stream)mpq.GetResource ("game\\tunit.pcx"), -1, -1);
			//unit_palette = pcx.Palette;

			pcx = new Pcx ();
			pcx.ReadFromStream ((Stream)mpq.GetResource ("tileset\\badlands\\dark.pcx"), 0, 0);
			tileset_palette = pcx.Palette;

			if (scenario.Tileset == Tileset.Platform) {
				Spk starfield = (Spk)mpq.GetResource ("parallax\\star.spk");

				starfield_layers = new Surface [starfield.Layers.Length];
				for (int i = 0; i < starfield_layers.Length; i ++) {
					starfield_layers[i] = new Surface (Painter.SCREEN_RES_X, Painter.SCREEN_RES_Y);

					starfield_layers[i].TransparentColor = Color.Black;

					for (int o = 0; o < starfield.Layers[i].Objects.Length; o ++) {
						ParallaxObject obj = starfield.Layers[i].Objects[o];

						starfield_layers[i].Fill (new Rectangle (new Point (obj.X, obj.Y), new Size (2,2)),
									  Color.White);
					}
				}
			}

			mapRenderer = new MapRenderer (mpq, scenario, Painter.SCREEN_RES_X, Painter.SCREEN_RES_Y);
			
			// load the cursors we'll show when scrolling with the mouse
			string[] cursornames = new string[] {
				"cursor\\ScrollUL.grp",
				"cursor\\ScrollU.grp",
				"cursor\\ScrollUR.grp",
				"cursor\\ScrollR.grp",
				"cursor\\ScrollDR.grp",
				"cursor\\ScrollD.grp",
				"cursor\\ScrollDL.grp",
				"cursor\\ScrollL.grp",
			};
			ScrollCursors = new CursorAnimator [cursornames.Length];
			for (int i = 0; i < cursornames.Length; i ++) {
				ScrollCursors[i] = new CursorAnimator ((Grp)mpq.GetResource (cursornames[i]),
								       effectpal.Palette);
				ScrollCursors[i].SetHotSpot (60, 60);
			}

			// load the mag cursors
			string[] magcursornames = new string[] {
				"cursor\\MagG.grp",
				"cursor\\MagY.grp",
				"cursor\\MagR.grp"
			};
			MagCursors = new CursorAnimator [magcursornames.Length];
			for (int i = 0; i < magcursornames.Length; i ++) {
				MagCursors[i] = new CursorAnimator ((Grp)mpq.GetResource (magcursornames[i]),
								    effectpal.Palette);
				MagCursors[i].SetHotSpot (60, 60);
			}

			// load the targeting cursors
			string[] targetcursornames = new string[] {
				"cursor\\TargG.grp",
				"cursor\\TargY.grp",
				"cursor\\TargR.grp"
			};
			TargetCursors = new CursorAnimator [targetcursornames.Length];
			for (int i = 0; i < targetcursornames.Length; i ++) {
				TargetCursors[i] = new CursorAnimator ((Grp)mpq.GetResource (targetcursornames[i]),
								       effectpal.Palette);
				TargetCursors[i].SetHotSpot (60, 60);
			}

			/* the following could be made global to speed up the entry to the game screen.. */
			statTxt = (Tbl)mpq.GetResource ("rez\\stat_txt.tbl");

			// load the wireframe image info
			wireframe = (Grp)mpq.GetResource ("unit\\wirefram\\wirefram.grp");

			// load the command icons
			cmdicons = (Grp)mpq.GetResource ("unit\\cmdbtns\\cmdicons.grp");
			pcx = new Pcx ();
			pcx.ReadFromStream ((Stream)mpq.GetResource ("unit\\cmdbtns\\ticon.pcx"), 0, 0);
			cmdicon_palette = pcx.Palette;

			// create the wireframe display element
			wireframeElement = new GrpElement (this, wireframe, cmdicon_palette, 170, 390);
			wireframeElement.Visible = false;
			Elements.Add (wireframeElement);

			labelElements = new LabelElement [(int)HudLabels.Count];

			labelElements[(int)HudLabels.UnitName] = new LabelElement (this, fontpal.Palette,
										   GuiUtil.GetFonts (Mpq)[1],
										   254, 390);
			labelElements[(int)HudLabels.ResourceUsed] = new LabelElement (this, fontpal.Palette,
										       GuiUtil.GetFonts (Mpq)[0],
										       292, 420);
			labelElements[(int)HudLabels.ResourceProvided] = new LabelElement (this, fontpal.Palette,
											   GuiUtil.GetFonts (Mpq)[0],
											   292, 434);
			labelElements[(int)HudLabels.ResourceTotal] = new LabelElement (this, fontpal.Palette,
											GuiUtil.GetFonts (Mpq)[0],
											292, 448);
			labelElements[(int)HudLabels.ResourceMax] = new LabelElement (this, fontpal.Palette,
										      GuiUtil.GetFonts (Mpq)[0],
										      292, 462);

			for (int i = 0; i < labelElements.Length; i ++)
				Elements.Add (labelElements[i]);

			cmdButtonElements = new GrpButtonElement[9];
			int x = 0;
			int y = 0;
			for (int i = 0; i < cmdButtonElements.Length; i ++) {
				cmdButtonElements[i] = new GrpButtonElement (this, cmdicons, cmdicon_palette, button_xs[x], button_ys[y]);
				x++;
				if (x == 3) {
					x = 0;
					y++;
				}
				cmdButtonElements[i].Visible = false;
				Elements.Add (cmdButtonElements[i]);
			}

			PlaceInitialUnits ();

			Events.Tick += ScrollTick;
		}
コード例 #37
0
ファイル: DialogBoxElement.cs プロジェクト: directhex/scsharp
 public DialogBoxElement(UIScreen screen, BinElement el, byte[] palette)
     : base(screen, el, palette)
 {
     tileGrp = (Grp)Mpq.GetResource ("dlgs\\tile.grp");
 }
コード例 #38
0
 public GrpButtonElement(UIScreen screen, Grp grp, byte[] palette, ushort x, ushort y)
     : base(screen, grp, palette, x, y)
 {
 }