Пример #1
0
        private float zoomRate = 0; // current rate of zoom

        #endregion Fields

        #region Constructors

        public LabPanel(Lab owner)
            : base()
        {
            // Record my owner for callbacks etc.
            this.owner = owner;

            // Create fonts
            // KLUDGE: When lcdFont is different from msgFont, there's an odd bug:
            // if I create a creature, anything using lcdFont fails to draw (the EditBox and the LCD text)
            // but if I type into the EditBox before creating a creature, everything is ok.
            // Equally, if I make the cell selector use lcdFont instead of msgFont then all objects using lcdFont work ok.
            // So there's something in the EditBox and cell selector code that "fixes" lcdFont. Can't figure this out,
            // so for now I'll just use the one font for everthing and wait until inspiration strikes!!!!
            msgFont = new System.Drawing.Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold, GraphicsUnit.Pixel);
            //lcdFont = new System.Drawing.Font(FontFamily.GenericSansSerif, 14, FontStyle.Regular, GraphicsUnit.Pixel);
            lcdFont = msgFont;	// Temp: let lcdFont share msgFont

            // writeable onscreen display (behind screen so that raster lines show)
            widgetList.Add(osd = new Widget("LabOSD", true, 256, 64, 210, 64));

            // Edit box for typing species name
            editSpecies = new EditBox("LCDEditBox", 128, 16, 210, 48, 54, 0, lcdFont, Brushes.Green, "Species:");
            widgetList.Add(editSpecies);
            editSpecies.OnChange += new ChangeEventHandler(editSpeciesChanged);

            // Backdrop
            widgetList.Add(new Widget("LabBkgnd", false, 1024, 768, 0, 0));

            // Display panels for showing the currently selected cell group & type
            dispCellGroup = new Widget("LCDLine", true, 100, 20, 416, 675);
            widgetList.Add(dispCellGroup);
            dispCellType = new Widget("LCDLine", true, 100, 20, 416, 695);
            widgetList.Add(dispCellType);
            dispCellVariant = new Widget("LCDLine", true, 100, 20, 416, 715);
            widgetList.Add(dispCellVariant);

            // Button: Start building a new creature
            SafetyButton btnNew = new SafetyButton("SafetySwitch", 80, 92, 18, 16, Keys.None, 0.3f);
            widgetList.Add(btnNew);
            btnNew.OnChange += new ChangeEventHandler(btnNewChanged);

            // Button: Release creature from clamp
            SafetyButton btnRelease = new SafetyButton("SafetySwitch", 80, 92, 18, 154, Keys.None, 0.3f);
            widgetList.Add(btnRelease);
            btnRelease.OnChange += new ChangeEventHandler(btnReleaseChanged);

            // Button: Activate the tractor beam
            Button btnTractor = new Button("PushButtonSmall", 40, 40, 37, 320, Keys.T, false);
            widgetList.Add(btnTractor);
            btnTractor.OnChange += new ChangeEventHandler(btnTractorChanged);
            // LED to show when tractor beam is active
            lampTractor = new Lamp("LED", 24, 24, 45, 292);
            widgetList.Add(lampTractor);

            // Button: Delete selected cells
            Button btnDelete = new Button("PushButtonSmall", 40, 40, 300, 686, Keys.Back, false);
            widgetList.Add(btnDelete);
            btnDelete.OnChange += new ChangeEventHandler(btnDeleteChanged);

            // Button: Add a new cell (INSERT)
            Button btnAdd = new Button("PushButtonSmall", 40, 40, 593, 698, Keys.Insert, false);
            widgetList.Add(btnAdd);
            btnAdd.OnChange += new ChangeEventHandler(btnAddChanged);

            // Button: Preview a potential new cell (SPACE)
            Button btnPreview = new Button("BtnRect", 64, 24, 580,670, Keys.Space, false);
            widgetList.Add(btnPreview);
            btnPreview.OnChange += new ChangeEventHandler(btnPreviewChanged);

            // These buttons change the selected celltype by mimicking those in the secondary panel
            // Button: cell group selection up
            Button btnGroupUp = new Button("BtnRectSmallLeft", 32, 24, 363, 670, Keys.Insert, true);
            widgetList.Add(btnGroupUp);
            btnGroupUp.OnChange += new ChangeEventHandler(btnGroupUpChanged);
            // Button: cell group selection down
            Button btnGroupDn = new Button("BtnRectSmallRight", 32, 24, 536, 670, Keys.Delete, true);
            widgetList.Add(btnGroupDn);
            btnGroupDn.OnChange += new ChangeEventHandler(btnGroupDnChanged);
            // Button: cell type selection up
            Button btnTypeUp = new Button("BtnRectSmallLeft", 32, 24, 363, 694, Keys.Home, true);
            widgetList.Add(btnTypeUp);
            btnTypeUp.OnChange += new ChangeEventHandler(btnTypeUpChanged);
            // Button: cell type selection down
            Button btnTypeDn = new Button("BtnRectSmallRight", 32, 24, 536, 694, Keys.End, true);
            widgetList.Add(btnTypeDn);
            btnTypeDn.OnChange += new ChangeEventHandler(btnTypeDnChanged);
            // Button: cell variant selection up
            Button btnVariantUp = new Button("BtnRectSmallLeft", 32, 24, 363, 718, Keys.PageUp, true);
            widgetList.Add(btnVariantUp);
            btnVariantUp.OnChange += new ChangeEventHandler(btnVariantUpChanged);
            // Button: cell variant selection down
            Button btnVariantDn = new Button("BtnRectSmallRight", 32, 24, 536, 718, Keys.PageDown, true);
            widgetList.Add(btnVariantDn);
            btnVariantDn.OnChange += new ChangeEventHandler(btnVariantDnChanged);

            // Buttons for navigating/selecting cells and sockets
            // Button: up in cell tree
            Button btnCellUp = new Button("BtnRectUp", 64, 24, 16, 664, Keys.Up, false);
            widgetList.Add(btnCellUp);
            btnCellUp.OnChange += new ChangeEventHandler(btnCellUpChanged);
            // Button: down in cell tree
            Button btnCellDn = new Button("BtnRectDn", 64, 24, 16, 712, Keys.Down, false);
            widgetList.Add(btnCellDn);
            btnCellDn.OnChange += new ChangeEventHandler(btnCellDnChanged);
            // Button: next sibling in cell tree
            Button btnCellNext = new Button("BtnRectSmallRight", 32, 24, 48, 688, Keys.Right, false);
            widgetList.Add(btnCellNext);
            btnCellNext.OnChange += new ChangeEventHandler(btnCellNextChanged);
            // Button: prev sibling in cell tree
            Button btnCellPrev = new Button("BtnRectSmallLeft", 32, 24, 16, 688, Keys.Left, false);
            widgetList.Add(btnCellPrev);
            btnCellPrev.OnChange += new ChangeEventHandler(btnCellPrevChanged);
            // Button: next socket
            Button btnSktNext = new Button("PushbuttonSmall", 40, 40, 123, 686, Keys.Enter, false);
            widgetList.Add(btnSktNext);
            btnSktNext.OnChange += new ChangeEventHandler(btnSktNextChanged);

            // Knob: rotates selected cell
            wheelRotate = new Wheel("Knob", 48, 56, 34, 578, 24f, 24f, Keys.None, Keys.None);
            widgetList.Add(wheelRotate);
            wheelRotate.OnChange += new ChangeEventHandler(knobRotateChanged);
            // Button: rotates selected cell in 45-degree increments
            Button btnRotate = new Button("PushbuttonSmall", 40, 40, 37, 511, Keys.R, true);
            widgetList.Add(btnRotate);
            btnRotate.OnChange += new ChangeEventHandler(btnRotateChanged);

            // Multiswitch selects mode: cell-edit, channel-edit or chemoscan
            modeSwitch = new MultiSwitch("knobMedium", 64, 75, 930, 317, 32f, 32f, Keys.None, Keys.None, 4, (float)(Math.PI * 0.5));
            widgetList.Add(modeSwitch);
            modeSwitch.OnChange += new ChangeEventHandler(ModeSwitchChanged);
            modeSwitch.Value = (int)Camera.ScannerModes.Cell;									// default mode is cell-edit mode

            // Buttons for navigating/modifying chemical channels
            // Button: previous channel
            Button btnChannelUp = new Button("BtnRectUp", 64, 24, 205, 684, Keys.None, false);
            widgetList.Add(btnChannelUp);
            btnChannelUp.OnChange += new ChangeEventHandler(btnChannelUpChanged);
            // Button: next channel
            Button btnChannelDn = new Button("BtnRectDn", 64, 24, 205, 708, Keys.None, false);
            widgetList.Add(btnChannelDn);
            btnChannelDn.OnChange += new ChangeEventHandler(btnChannelDnChanged);
            // Button: change channel to use previous chemical
            Button btnChemUp = new Button("BtnRectUp", 64, 24, 677, 684, Keys.None, false);
            widgetList.Add(btnChemUp);
            btnChemUp.OnChange += new ChangeEventHandler(btnChemUpChanged);
            // Button: change channel to use next chemical
            Button btnChemDn = new Button("BtnRectDn", 64, 24, 677, 708, Keys.None, false);
            widgetList.Add(btnChemDn);
            btnChemDn.OnChange += new ChangeEventHandler(btnChemDnChanged);

            // Buttons for steering & zooming camera
            Button btnCamUp = new Button("BtnRectUp", 64, 24, 930, 440, Keys.NumPad8, false);
            widgetList.Add(btnCamUp);
            btnCamUp.OnChange += new ChangeEventHandler(btnCamUpChanged);
            Button btnCamDn = new Button("BtnRectDn", 64, 24, 930, 488, Keys.NumPad2, false);
            widgetList.Add(btnCamDn);
            btnCamDn.OnChange += new ChangeEventHandler(btnCamDnChanged);
            Button btnCamLeft = new Button("BtnRectSmallRight", 32, 24, 962, 464, Keys.NumPad6, false);
            widgetList.Add(btnCamLeft);
            btnCamLeft.OnChange += new ChangeEventHandler(btnCamLeftChanged);
            Button btnCamRight = new Button("BtnRectSmallLeft", 32, 24, 930, 464, Keys.NumPad4, false);
            widgetList.Add(btnCamRight);
            btnCamRight.OnChange += new ChangeEventHandler(btnCamRightChanged);
            Button btnCamZoomIn = new Button("BtnRectUp", 64, 24, 930, 548, Keys.NumPad9, true);
            widgetList.Add(btnCamZoomIn);
            btnCamZoomIn.OnChange += new ChangeEventHandler(btnCamZoomInChanged);
            Button btnCamZoomOut = new Button("BtnRectDn", 64, 24, 930, 572, Keys.NumPad3, true);
            widgetList.Add(btnCamZoomOut);
            btnCamZoomOut.OnChange += new ChangeEventHandler(btnCamZoomOutChanged);

            // Knob: adjusts channel constants
            wheelConst = new Wheel("Knob", 48, 56, 785, 689, 24f, 24f, Keys.None, Keys.None);
            widgetList.Add(wheelConst);
            wheelConst.OnChange += new ChangeEventHandler(wheelConstChanged);
            // Meter: shows channel constant
            meterConst = new Meter("LabNeedle", 8, 48, 898, 710, 0.87f, 4, 40, -3, 3, true);
            widgetList.Add(meterConst);
            // LED to show when a constant is applicable (i.e. chemical selectivity is set to none)
            lampConst = new Lamp("LED", 24, 24, 796, 662);
            widgetList.Add(lampConst);

            // transparent reflection on LCD glass (printed on top of LCD contents)
            widgetList.Add(labReflection = new Widget("LabReflection", false, 620, 112, 416, 675));
        }
Пример #2
0
        private Pen vduPen = null; // foreground pen for lines etc. (same colour as .brush)

        #endregion Fields

        #region Constructors

        public LabPanel2(Lab owner)
            : base()
        {
            // Store the camera ship for callbacks etc.
            this.owner = owner;

            // Create the fonts, brushes and pens
            vduFont = new System.Drawing.Font(FontFamily.GenericMonospace, 12, FontStyle.Bold);
            vduBrush = new SolidBrush(Color.FromArgb(150, Color.LightGreen));
            vduFill = new SolidBrush(Color.FromArgb(64, Color.LightGreen));
            vduPen = new Pen(vduBrush, 2);

            // Depth of one line of text
            vduLine = vduFont.Height;

            // Create the backdrop and widgets...
            // For now, use a single-piece backdrop and superimpose smaller bitmaps for the writeable widgets
            // such as selectors. Later it might be sensible to cut up the backdrop so as not to duplicate
            // these regions
            widgetList.Add(new Widget("LabPanel2", false, 1024, 768, 0, 0));

            // cell group list on VDU
            groupSelector = new Selector("LabVduGroup", 160, 128, 192, 98, vduFont, vduBrush, vduFill);
            widgetList.Add(groupSelector);
            groupSelector.OnChange += new ChangeEventHandler(groupSelectorChanged);
            // cell type list on VDU
            typeSelector = new Selector("LabVduType", 160, 128, 192, 256, vduFont, vduBrush, vduFill);
            widgetList.Add(typeSelector);
            typeSelector.OnChange += new ChangeEventHandler(typeSelectorChanged);
            // cell variant list on VDU
            variantSelector = new Selector("LabVduVariant", 160, 96, 192, 415, vduFont, vduBrush, vduFill);
            widgetList.Add(variantSelector);
            variantSelector.OnChange += new ChangeEventHandler(variantSelectorChanged);

            // Button: cell group selection up
            Button btnGroupUp = new Button("BtnRectUp", 64, 24, 8, 64, Keys.None, true);
            widgetList.Add(btnGroupUp);
            btnGroupUp.OnChange += new ChangeEventHandler(btnGroupUpChanged);
            // Button: cell group selection down
            Button btnGroupDn = new Button("BtnRectDn", 64, 24, 8, 128, Keys.None, true);
            widgetList.Add(btnGroupDn);
            btnGroupDn.OnChange += new ChangeEventHandler(btnGroupDnChanged);
            // Button: cell type selection up
            Button btnTypeUp = new Button("BtnRectUp", 64, 24, 8, 192, Keys.None, true);
            widgetList.Add(btnTypeUp);
            btnTypeUp.OnChange += new ChangeEventHandler(btnTypeUpChanged);
            // Button: cell type selection down
            Button btnTypeDn = new Button("BtnRectDn", 64, 24, 8, 256, Keys.None, true);
            widgetList.Add(btnTypeDn);
            btnTypeDn.OnChange += new ChangeEventHandler(btnTypeDnChanged);
            // Button: cell variant selection up
            Button btnVariantUp = new Button("BtnRectUp", 64, 24, 8, 320, Keys.None, true);
            widgetList.Add(btnVariantUp);
            btnVariantUp.OnChange += new ChangeEventHandler(btnVariantUpChanged);
            // Button: cell variant selection down
            Button btnVariantDn = new Button("BtnRectDn", 64, 24, 8, 384, Keys.None, true);
            widgetList.Add(btnVariantDn);
            btnVariantDn.OnChange += new ChangeEventHandler(btnVariantDnChanged);

            // Carousel for displaying information about the selected cell type
            infoPanel = new Carousel("LabVduInfoPanel", 512, 400, 400, 105);

            // Space for writing information about the creature being built (total mass, etc.)
            totalsPanel = new Widget("LabVduTotalsPanel", true, 740, 64, 192, 530);
            widgetList.Add(totalsPanel);

            // fill the selectors with the cell groups, types and variants available on this system
            groupSelector.SetList(GroupTypeVariant.GetGroups());
            typeSelector.SetList(GroupTypeVariant.GetTypes(0));
            variantSelector.SetList(GroupTypeVariant.GetVariants(0,0));
        }
Пример #3
0
        /// <summary>
        /// Create the list of camera ships, once the Device has been set up
        /// </summary>
        public static void OnDeviceCreated()
        {
            // Create the organisms that will act as camera platforms
            cameraShip = new CameraShip[2];													// EXTEND THIS when more platforms are added
            cameraShip[0] = new SubCam();
            cameraShip[1] = new Lab();
            //cameraShip[2] = new SurveyCam();

            SwitchCameraShip(0);															// start with camera on the sub
        }