コード例 #1
0
ファイル: SubPanel.cs プロジェクト: JamesTryand/simergy
        private Meter trkMeter = null; // tracked object's bearing

        #endregion Fields

        #region Constructors

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

            // Create the backdrop and widgets
            widgetList.Add(new Widget("SubPanel", false, 1024, 768, 0, 0));						// top panel
            //widgetList.Add(new Widget("SubBot", true, 1024, 168, 0, 768 - 168));				// bottom panel (and radar)
            //widgetList.Add(new Widget("SubLeft", false, 128, 500, 0, 100));						// left panel
            //widgetList.Add(new Widget("SubRight", false, 50, 500, 1024 - 50, 100));				// right panel

            // Spotlight switch
            Switch switch1 = new Switch("toggleswitch", 48, 67, 860, 30, Keys.L);
            widgetList.Add(switch1);
            switch1.OnChange += new ChangeEventHandler(owner.Switch1Changed);

            // Depth meter
            depthMeter = new Meter("LabNeedle", 8, 48, 90, 58, (float)Math.PI * 0.75f, 4, 40, -4, 4, false);
            widgetList.Add(depthMeter);

            // Compass bearing
            hdgMeter = new Meter("CompassRose", 104, 104, 42, 646, (float)Math.PI, 52, 52, 0, 0, false); // no shadow; don't slew, or it'll spin when wrapping
            widgetList.Add(hdgMeter);

            // Bearing to tracked object
            trkMeter = new Meter("LabNeedle", 8, 48, 90, 674, (float)Math.PI, 4, 40, -4, 4, false);
            widgetList.Add(trkMeter);

            // Bearing to lab ship
            labMeter = new Meter("SmallNeedle", 8, 32, 90, 682, (float)Math.PI, 4, 25, -4, 4, false);
            widgetList.Add(labMeter);

            bouyancy = new Knob("KnobMedium", 64, 75, 950, 170, 32F, 32F, Keys.PageUp, Keys.PageDown, (float)(Math.PI * 0.5));
            bouyancy.Value = 0.5f;
            bouyancy.OnChange += new ChangeEventHandler(bouyancy_OnChange);
            widgetList.Add(bouyancy);

            hatch = new SafetyButton("SafetySwitch", 80, 92, 940, 265, Keys.None, 0.3f);
            hatch.OnChange += new ChangeEventHandler(hatch_OnChange);
            widgetList.Add(hatch);

            // Set up the Display widget for the navigation display
            SetupNavDisplay();
        }
コード例 #2
0
ファイル: LabPanel.cs プロジェクト: JamesTryand/simergy
        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));
        }