예제 #1
0
        private void AddShipToCompare(Ship findShip, ShipBuild build = null)
        {
            CompareShip childForm = new CompareShip();

            if (this.MdiChildren.Length == 0)
            {
                childForm.IsFirstChild = true;
                FirstChild             = childForm;
            }

            childForm.MdiParent = this;
            string selection = findShip.Name;

            TableLayoutPanel  tl        = childForm.Controls.Find("ShipMetricsTable", true).FirstOrDefault() as TableLayoutPanel;
            MetricsExctractor Extractor = new MetricsExctractor(findShip);
            MetricsDrawer     Drawer    = new MetricsDrawer(tl);

            MetricsTableComposer.DrawTable(Extractor, Drawer);

            if (build != null)
            {
                selection += "**PB**";
                BuildManagerHandler bmHandler = new BuildManagerHandler(tl, Extractor.GetMetrics());
                bmHandler.PerformAnimation(false);
                bmHandler.KeepBackgroundTransparent(true);
                bmHandler.ApplyAll(build.Flags);
                bmHandler.ApplyAll(build.Skills);
                bmHandler.ApplyAll(build.Upgrades);
            }

            childForm.Text = selection;

            childForm.StartPosition = FormStartPosition.Manual;
            int   positionX = (this.MdiChildren.Length - 1) * 252;
            Point point     = new Point(positionX, 0);

            childForm.Location = point;

            if (childForm.IsFirstChild == false)
            {
                MetricsCompare.DoCompare(childForm.Controls.Find("ShipMetricsTable", true).FirstOrDefault() as TableLayoutPanel, FirstChild.Controls.Find("ShipMetricsTable", true).FirstOrDefault() as TableLayoutPanel);
            }
            childForm.Show();
            toolStripStatusLabel.Text = "Added '" + selection + "' to compare.";
            statusStrip.Refresh();
        }
예제 #2
0
        private void LoadShipMetrics()
        {
            if (RandomizedShip == null)
            {
                return;
            }
            LOG.Debug("Loading ship metrics");
            MetricsExctractor Extractor = new MetricsExctractor(RandomizedShip);
            MetricsDrawer     Drawer    = new MetricsDrawer(ShipMetricsTable);

            MetricsTableComposer.DrawTable(Extractor, Drawer);

            try
            {
                Settings settings = Commons.GetSettings();
                string   fileName = settings.SaveLocation;
                if (!fileName.EndsWith("\\"))
                {
                    fileName += @"\";
                }
                fileName += RandomizedShip.Name + ".bld";

                ShipBuild build = null;
                if (File.Exists(fileName))
                {
                    build = BinarySerialize.ReadFromBinaryFile <ShipBuild>(fileName);
                }

                if (build != null)
                {
                    BuildManagerHandler bmHandler = new BuildManagerHandler(ShipMetricsTable, Extractor.GetMetrics());
                    bmHandler.PerformAnimation(false);
                    bmHandler.KeepBackgroundTransparent(false);
                    bmHandler.ApplyAll(build.Flags);
                    bmHandler.ApplyAll(build.Skills);
                    bmHandler.ApplyAll(build.Upgrades);
                }
            }
            catch (Exception) { }
        }