Пример #1
0
        public void LoadServiceData(string serviceName = null)
        {
            MenuUserControl menuUserControl = new MenuUserControl();

            string[] lines = new string[3];
            menuUserControl.SelectedTab = serviceName;

            menuUserControl.CheckForConfigFile();

            rootPath = AppDomain.CurrentDomain.BaseDirectory;
            string serviceFolder = string.Empty;

            serviceFolder = "SerialReaderService\\emViewService" + serviceName;
            string interimConfigFilePath = string.Empty;

            interimConfigFilePath = Path.Combine(rootPath, serviceFolder);
            serviceConfigFilePath = Path.Combine(interimConfigFilePath, configFileName);
            lines = File.ReadAllLines(serviceConfigFilePath);
            this.mainPanel.Controls.Clear();
            menuUserControl.ParentForm                 = this;
            menuUserControl.lblData.Text               = $"COM Port: {lines[0]}   Baud Rate: {lines[1]}   Refresh Time: {(Convert.ToInt32(lines[2]) / 60000)}m ";
            menuUserControl.Anchor                     = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
            menuUserControl.cmbAvailablePorts.Text     = lines[0];
            menuUserControl.cmbAvailableBaudRates.Text = lines[1];
            menuUserControl.cmbSites.Text              = lines[3];
            menuUserControl.cmbRefreshTime.Text        = (Convert.ToInt32(lines[2]) / 60000).ToString();
            this.mainPanel.Controls.Add(menuUserControl);
        }
Пример #2
0

        
Пример #3
0
        public void SwitchScene(Scene scene, object par)
        {
            BaseUserControl ctrl = null;

            switch (scene)
            {
            case Scene.Autorization:
            {
                ctrl = new AutorizationUserControl();
                break;
            }

            case Scene.Combat:
            {
                ctrl = new CombatUserControl(par);
                break;
            }

            case Scene.Menu:
            {
                ctrl = new MenuUserControl(par);
                break;
            }

            case Scene.PlayerCreation:
            {
                ctrl = new PlayerCreationUserControl();
                break;
            }

            case Scene.RecordTable:
            {
                ctrl = new RecordTableUserControl(par);
                break;
            }

            case Scene.SecondPlayerLoad:
            {
                ctrl = new SecondPlayerLoadUserControl(par);
                break;
            }

            default:
            {
                break;
            }
            }
            if (ctrl != null)
            {
                //this.Height = ctrl.Height + 20;
                //this.Width = ctrl.Width + 15;
                this.MinimumSize = new Size(ctrl.Width + 15, ctrl.Height + 20);
                this.MaximumSize = new Size(ctrl.Width + 15, ctrl.Height + 20);
                //mainPanel.Height = ctrl.Height + 20;
                //mainPanel.Width = ctrl.Width + 15;
                this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width / 2 - this.Width / 2, Screen.PrimaryScreen.WorkingArea.Height / 2 - this.Height / 2);
                ctrl.Dock     = DockStyle.Fill;
                mainPanel.Controls.Clear();
                mainPanel.Controls.Add(ctrl);
            }
        }
Пример #4
0
        public GameForm()
        {
            this.Name = MyName;

            InitializeComponent();

            tblGameScreen      = new TableLayoutPanel();
            tblGameScreen.Size = new Size();

            var singleMsgConsole = new SingleMessageLogUserControl();
            var backpackControl  = new BackpackUserControl(tblGameScreen);
            var spellbookControl = new SpellbookUserControl(tblGameScreen);
            var mapViewControl   = new MapUserControl(this,
                                                      backpackControl,
                                                      spellbookControl,
                                                      singleMsgConsole);
            var characterSheet = new CharacterSheetUserControl();
            var logConsole     = new LogUserControl();

            var merchantControl = new MerchantUserControl(tblGameScreen);

            tblGameScreen.Dock = DockStyle.Fill;

            tblGameScreen.RowStyles.Clear();
            tblGameScreen.RowStyles.Add(new RowStyle(SizeType.Percent, 0.75F));
            tblGameScreen.RowStyles.Add(new RowStyle(SizeType.Absolute, 30.0f));
            tblGameScreen.RowStyles.Add(new RowStyle(SizeType.Percent, 0.25F));
            tblGameScreen.BackColor   = Color.Beige;
            tblGameScreen.MinimumSize = new Size();

            var tblMapAndSheet = new TableLayoutPanel();

            tblMapAndSheet.Size = new Size();
            tblMapAndSheet.ColumnStyles.Clear();
            tblMapAndSheet.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 0.40F));
            tblMapAndSheet.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 0.60F));
            tblMapAndSheet.BackColor   = Color.Beige;
            tblMapAndSheet.Margin      = new Padding(0);
            tblMapAndSheet.MinimumSize = new Size();

            tblMapAndSheet.Controls.Add(mapViewControl, 0, 0);
            mapViewControl.Dock = DockStyle.Fill;
            tblMapAndSheet.Controls.Add(characterSheet, 1, 0);
            characterSheet.Dock = DockStyle.Fill;
            //var cellPos = tblMapAndSheet.GetCellPosition(mapViewControl);
            //int width = tblMapAndSheet.GetColumnWidths()[cellPos.Column];
            //mapViewControl.Size = new Size(20, 20);

            tblGameScreen.Controls.Add(tblMapAndSheet, 0, 0);
            tblMapAndSheet.Dock = DockStyle.Fill;

            tblGameScreen.Controls.Add(singleMsgConsole, 0, 1);
            singleMsgConsole.Dock = DockStyle.Fill;

            tblGameScreen.Controls.Add(logConsole, 0, 2);
            logConsole.Dock = DockStyle.Fill;

            backpackControl.Hide();
            spellbookControl.Hide();
            merchantControl.Hide();

            this.Controls.Add(tblGameScreen);
            this.Controls.Add(backpackControl);
            this.Controls.Add(spellbookControl);
            this.Controls.Add(merchantControl);

            this.Text = GameName;

            mainMenuViewer = new MenuUserControl();
            this.Controls.Add(mainMenuViewer);

            this.Size = InitSize;

            Game.Current.Init(pgController: mapViewControl,
                              aiController: mapViewControl,
                              merchantController: merchantControl,
                              mapViewer: mapViewControl,
                              singleMsgListener: singleMsgConsole,
                              animationViewer: mapViewControl,
                              pgViewers: new List <IPgViewer>()
            {
                mapViewControl
            },
                              atomListeners: new List <IAtomListener> {
                logConsole
            },
                              sheetViews: new List <ISheetViewer> {
                characterSheet
            },
                              backpackViewers: new List <IBackpackViewer> {
                backpackControl
            },
                              spellbookViewers: new List <ISpellbookViewer> {
                spellbookControl
            },
                              secondarySpellsViewers: new List <IAtomListener> {
                singleMsgConsole
            },
                              merchantViewers: new List <IMerchantViewer> {
                merchantControl
            },
                              mainMenuViewer: mainMenuViewer,
                              mainMenuController: mainMenuViewer);
        }