Exemple #1
0
        public static bool Return(ObjectModule.Local.Binning gb, ObjectModule.Local.Tracking gt)
        {
            List <SqlCommand> list = new List <SqlCommand>();

            try
            {
                if (gt.STATUS == "REUSE")
                {
                    SqlCommand cmd_Binning = Binning.Update(gb);
                    list.Add(cmd_Binning);
                    SqlCommand cmd_Tracking = Tracking.Update(gt);
                    list.Add(cmd_Tracking);
                }
                else
                {
                    SqlCommand cmd_Tracing = Tracking.Delete(gt.PART_ID);
                    list.Add(cmd_Tracing);
                }

                SqlCommand cmd_History = History.Insert(gt);
                list.Add(cmd_History);
                return(Common.DB.SqlDB.SetData_Rollback(list, StaticRes.Local));
            }
            catch
            {
                return(false);
            }
        }
Exemple #2
0
        private static void Regenerate()
        {
            var r = new List <Rectangle>();

            for (var i = 0; i < 20; i++)
            {
                int width  = Helpers.GenerateRandomNumber(1, 80);
                int height = Helpers.GenerateRandomNumber(1, 180);
                r.Add(new Rectangle(0, 0, width, height));
            }

            _rects        = r.ToArray();
            _boundingRect = new Rectangle(0, 0, Binning.FitRectangles(_rects));
        }
Exemple #3
0
        public static void BinCount(string[] args)
        {
            var fileName = args.Length < 2 ? "data/xResult" : args[1];
            var binning  = args.Length < 3 ? 2 : Int32.Parse(args[2]);

            string[] lines = File.ReadAllLines(String.Format("{0}.txt", fileName));
            var      data  = lines.Aggregate(new List <int>(), (p, c) =>
            {
                var value = Int32.Parse(c.Split(' ')[1]);
                p.Add(value);
                return(p);
            }).ToArray();

            Binning.Count(data, fileName, binning);

            return;
        }
Exemple #4
0
        public static bool Spool_Missing(ObjectModule.Local.Tracking gt, ObjectModule.Local.Binning gb)
        {
            List <SqlCommand> list = new List <SqlCommand>();

            try
            {
                SqlCommand cmd_GEMS_Binning = Binning.Update(gb);
                list.Add(cmd_GEMS_Binning);
                SqlCommand cmd_GEMS_Tracking = Tracking.Delete(gt.PART_ID);
                list.Add(cmd_GEMS_Tracking);
                SqlCommand cmd_GEMS_History = History.Insert(gt);
                list.Add(cmd_GEMS_History);
                return(Common.DB.SqlDB.SetData_Rollback(list, StaticRes.Local));
            }
            catch
            {
                return(false);
            }
        }
Exemple #5
0
        public static bool Unload(ObjectModule.Local.Binning gb, ObjectModule.Local.Tracking gt)
        {
            List <SqlCommand> list = new List <SqlCommand>();

            try
            {
                SqlCommand cmd_Binning = Binning.Update(gb);
                list.Add(cmd_Binning);
                SqlCommand cmd_Tracking = Tracking.Update(gt);
                list.Add(cmd_Tracking);
                SqlCommand cmd_History = History.Insert(gt);
                list.Add(cmd_History);
                return(Common.DB.SqlDB.SetData_Rollback(list, StaticRes.Local));
            }
            catch
            {
                return(false);
            }
        }
Exemple #6
0
        private void RenderSaveSection(RenderComposer composer)
        {
            // Saving
            ImGui.InputText("Name", ref _saveName, 100);
            ImGui.SameLine();
            if (string.IsNullOrEmpty(_saveName))
            {
                ImGui.TextDisabled("Save");
                ImGui.SameLine();
                ImGui.TextDisabled("SaveToFile");
            }
            else
            {
                ImGui.SameLine();
                if (ImGui.Button("SaveToFile"))
                {
                    string saveName = _saveName.ToLower();
                    if (!saveName.Contains(".anim")) saveName += ".anim";

                    // Fixups
                    if (AnimController?.MirrorXAnchors != null)
                    {
                        var emptyMirrorAnchors = true;
                        for (var i = 0; i < AnimController.MirrorXAnchors.Length; i++)
                        {
                            if (AnimController.MirrorXAnchors[i] == Vector2.Zero) continue;
                            emptyMirrorAnchors = false;
                            break;
                        }

                        if (emptyMirrorAnchors) AnimController.MirrorXAnchors = null;
                    }

                    try
                    {
                        string saveData;
                        // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
                        if (AnimController != null)
                            saveData = XMLFormat.To(AnimController);
                        else
                            saveData = XMLFormat.To(Animation);

                        Engine.AssetLoader.Save(Encoding.UTF8.GetBytes(saveData), saveName);
                    }
                    catch (Exception ex)
                    {
                        Engine.Log.Error(ex);
                    }
                }

                if (ImGui.Button("Save Packed Texture"))
                {
                    string saveName = _saveName.ToLower();
                    if (!saveName.Contains(".png")) saveName += ".png";
                    Rectangle[] frames = AnimController != null ? AnimController.AnimTex.Frames : Animation.Frames;
                    var preBinnedFrames = new Rectangle[frames.Length];
                    Array.Copy(frames, preBinnedFrames, frames.Length);
                    Texture spriteSheetTexture = Animation.Texture;

                    var spacing = 2;
                    for (var i = 0; i < frames.Length; i++)
                    {
                        Rectangle frame = frames[i];
                        frames[i] = frame.Inflate(spacing, spacing);
                    }

                    Vector2 totalSize = Binning.FitRectangles(frames, true);
                    FrameBuffer texture = new FrameBuffer(totalSize).WithColor();
                    composer.RenderTo(texture);
                    for (var i = 0; i < frames.Length; i++)
                    {
                        composer.RenderSprite(frames[i].Deflate(spacing, spacing), Color.White, spriteSheetTexture, preBinnedFrames[i]);
                    }

                    composer.RenderTo(null);

                    byte[] pixelsDownload = texture.Sample(new Rectangle(0, 0, totalSize), PixelFormat.Rgba);
                    ImageUtil.FlipImageY(pixelsDownload, (int) totalSize.Y);
                    byte[] pngFile = PngFormat.Encode(pixelsDownload, totalSize, PixelFormat.Rgba);
                    Engine.AssetLoader.Save(pngFile, saveName);
                }
            }
        }