Exemplo n.º 1
0
        public SystemGenAndDisplay()
        {
            // Create Panels:
            m_oDataPanel     = new Panels.SGaD_DataPanel();
            m_oControlsPanel = new Panels.SGaD_Controls();

            // setup view model:
            VM = new StarSystemViewModel();

            // bind System Selection combo box:
            m_oControlsPanel.SystemSelectionComboBox.DataSource = VM.StarSystems;
            m_oControlsPanel.SystemSelectionComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentStarSystem, DataSourceUpdateMode.OnPropertyChanged);
            m_oControlsPanel.SystemSelectionComboBox.DisplayMember = "Name";

            m_oControlsPanel.SystemSelectionComboBox.SelectedIndexChanged += (s, args) => m_oControlsPanel.SystemSelectionComboBox.DataBindings["SelectedItem"].WriteValue();

            // bind text boxes:
            m_oControlsPanel.AgeTextBox.Bind(c => c.Text, VM, d => d.CurrentStarSystemAge);
            m_oControlsPanel.SeedTextBox.Bind(c => c.Text, VM, d => d.Seed);

            // Setup the stars Grid
            m_oDataPanel.StarDataGrid.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
            m_oDataPanel.StarDataGrid.RowHeadersVisible   = false;
            m_oDataPanel.StarDataGrid.AutoGenerateColumns = false;
            m_oDataPanel.StarDataGrid.Bind(c => c.AllowUserToAddRows, VM, d => d.isSM);
            m_oDataPanel.StarDataGrid.Bind(c => c.AllowUserToDeleteRows, VM, d => d.isSM);
            m_oDataPanel.StarDataGrid.Bind(c => c.ReadOnly, VM, d => d.isNotSM);

            AddColumnsToStarDataGrid();

            m_oDataPanel.StarDataGrid.DataSource        = VM.StarsSource;
            m_oDataPanel.StarDataGrid.SelectionChanged += new EventHandler(StarsDataGrid_SelectionChanged);

            // Setup the SystemBody Data Grid
            m_oDataPanel.PlanetsDataGrid.AutoGenerateColumns       = false;
            m_oDataPanel.PlanetsDataGrid.RowHeadersVisible         = false;
            m_oDataPanel.PlanetsDataGrid.SelectionMode             = DataGridViewSelectionMode.CellSelect;
            m_oDataPanel.PlanetsDataGrid.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            m_oDataPanel.PlanetsDataGrid.AutoSizeRowsMode          = DataGridViewAutoSizeRowsMode.DisplayedCells;
            m_oDataPanel.PlanetsDataGrid.Bind(c => c.AllowUserToAddRows, VM, d => d.isSM);
            m_oDataPanel.PlanetsDataGrid.Bind(c => c.AllowUserToDeleteRows, VM, d => d.isSM);
            m_oDataPanel.PlanetsDataGrid.Bind(c => c.ReadOnly, VM, d => d.isNotSM);
            AddColumnsToPlanetDataGrid();

            m_oDataPanel.PlanetsDataGrid.DataSource        = VM.PlanetSource;
            m_oDataPanel.PlanetsDataGrid.SelectionChanged += new EventHandler(PlanetsDataGrid_SelectionChanged);
            m_oDataPanel.PlanetsDataGrid.CellDoubleClick  += new DataGridViewCellEventHandler(PlanetDataGrid_CellDoubleClick);

            // Setup Event handlers for Controls panel buttons:
            m_oControlsPanel.GenSystemButton.Click    += new EventHandler(GenSystemButton_Click);
            m_oControlsPanel.GenGalaxyButton.Click    += new EventHandler(GenGalaxyButton_Click);
            m_oControlsPanel.DeleteSystemButton.Click += new EventHandler(DeleteSystemButton_Click);
            m_oControlsPanel.AutoRenameButton.Click   += new EventHandler(AutoRenameButton_Click);
            m_oControlsPanel.AddColonyButton.Click    += new EventHandler(AddColonyButton_Click);
            m_oControlsPanel.ExportButton.Click       += new EventHandler(ExportButton_Click);
        }
Exemplo n.º 2
0
 public static StarSystem ObjectToMessage(StarSystemViewModel ssvm)
 {
     var ss = new StarSystem
     {
         Id = ssvm.Id,
         Name = ssvm.Name,
         Uploader = ssvm.Uploader
     };
     return ss;
 }
Exemplo n.º 3
0
 public static StarSystemViewModel MessageToObject(StarSystem starSystem)
 {
     var ssvm = new StarSystemViewModel
     {
         Id = starSystem.Id,
         Name = starSystem.Name,
         Uploader =  starSystem.Uploader
     };
     return ssvm;
 }
Exemplo n.º 4
0
        public ActionResult Create(StarSystemViewModel ssvm)
        {
            try
            {

                IStarSystemRepo ssr = new StarSystemRepo();
                ssr.Create(ssvm);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 5
0
        public ActionResult ImportFiles()
        {
            IFileSystemRepo fsr = new FileSystemRepo();
            IStarSystemRepo ssr = new StarSystemRepo();
            var files = Request.Files.AllKeys.Select(fileName => Request.Files[fileName]).Where(file => file.ContentLength > 0).ToList();
            List<string> pathNames = new List<string>();
            foreach (var file in files)
            {
                var fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
                var virtualPath = "~/Content/netlogs/" + DateTime.Today.ToString("MMddyyyy");
                var subPath = Server.MapPath(virtualPath);
                if (!Directory.Exists(subPath))
                {
                    Directory.CreateDirectory(subPath);
                }
                var path = Path.Combine(subPath, fileName);
                try
                {
                    file.SaveAs(path);
                }
                catch (Exception e)
                {
                    continue;
                }

                fsr.SaveFileData(Path.Combine(virtualPath.Replace("~/", "/").Replace("\\", "/"), fileName), fileName);
                pathNames.Add(path);
            }
            foreach (var path in pathNames)
            {
                List<NetLog> nlList =
                    NetLogTranslator.RawNetLogToNetLogs(path)
                        .GroupBy(nl => nl.SystemName)
                        .Select(lst => lst.First()).ToList();
                foreach (var nl in nlList)
                {
                    var ssvm = new StarSystemViewModel
                    {
                        Name = nl.SystemName,
                        Uploader = User.Identity.Name
                    };
                    ssr.Create(ssvm);
                }
            }
            return Json(new { Message = string.Empty });
        }
Exemplo n.º 6
0
        public SystemGenAndDisplay()
        {
            InitializeComponent();

            VM = new StarSystemViewModel();

            NameComboBox.DataSource = VM.StarSystems;
            NameComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentStarSystem, DataSourceUpdateMode.OnPropertyChanged);
            NameComboBox.DisplayMember = "Name";

            NameComboBox.SelectedIndexChanged += (s, args) => NameComboBox.DataBindings["SelectedItem"].WriteValue();

            AgetextBox.Bind(c => c.Text, VM, d => d.CurrentStarSystemAge);

            // Setup the stars Grid
            StarsDataGridView.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
            StarsDataGridView.RowHeadersVisible   = false;
            StarsDataGridView.AutoGenerateColumns = false;
            StarsDataGridView.Bind(c => c.AllowUserToAddRows, VM, d => d.isSM);
            StarsDataGridView.Bind(c => c.AllowUserToDeleteRows, VM, d => d.isSM);
            StarsDataGridView.Bind(c => c.ReadOnly, VM, d => d.isNotSM);

            AddColumnsToStarDataGrid();

            StarsDataGridView.DataSource        = VM.StarsSource;
            StarsDataGridView.SelectionChanged += new EventHandler(StarsDataGridView_SelectionChanged);

            // Setup the Planet Data Grid
            PlanetsDataGridView.AutoGenerateColumns = false;
            PlanetsDataGridView.RowHeadersVisible   = false;
            PlanetsDataGridView.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
            PlanetsDataGridView.Bind(c => c.AllowUserToAddRows, VM, d => d.isSM);
            PlanetsDataGridView.Bind(c => c.AllowUserToDeleteRows, VM, d => d.isSM);
            PlanetsDataGridView.Bind(c => c.ReadOnly, VM, d => d.isNotSM);
            AddColumnsToPlanetDataGrid();

            PlanetsDataGridView.DataSource        = VM.PlanetSource;
            PlanetsDataGridView.SelectionChanged += new EventHandler(StarADataGridView_SelectionChanged);
        }
Exemplo n.º 7
0
    private void _loadsystem(Vector2Int starSystem)
    {
        var newStarSystem = StarSystems[starSystem];

        var oldSystem = StarSystemViewModel;

        var newObject = new GameObject();

        newObject.name             = newStarSystem.Name;
        newObject.transform.parent = transform;
        var starviewmodel = newObject.AddComponent <StarSystemViewModel>();

        starviewmodel.LoadStarSystem(newStarSystem);
        StarSystemViewModel = starviewmodel;
        GameController.Game.Player?.SetLocation(newStarSystem.JumpPoint);

        //destroy the old star system.
        if (oldSystem != null)
        {
            Destroy(oldSystem.gameObject);
        }
    }
Exemplo n.º 8
0
 public void Update(StarSystemViewModel ssvm)
 {
     var message = StarSystemTranslator.ObjectToMessage(ssvm);
     StarSystem.SystemInsertRow(message.Name, message.Uploader);
 }
Exemplo n.º 9
0
 public int Create(StarSystemViewModel ssvm)
 {
     var message = StarSystemTranslator.ObjectToMessage(ssvm);
     return StarSystem.SystemInsertRow(message.Name, message.Uploader);
 }