Exemple #1
0
        private void checkIfChanged()
        {
            DataTable secT   = sectors.getSectorTable();
            DataTable sysT   = systems.getSystemTable();
            DataTable secObT = null;


            bool changed = false;

            foreach (DataRow dt in secT.Rows)
            {
                if (dt.RowState != DataRowState.Unchanged)
                {
                    changed = true;
                }
            }
            foreach (DataRow dt2 in sysT.Rows)
            {
                if (dt2.RowState != DataRowState.Unchanged)
                {
                    changed = true;
                }
            }
            if (sectorWindow != null)
            {
                secObT = sectorWindow.getSectorObjectsSQL().getSectorObject();

                foreach (DataRow secObRow in secObT.Rows)
                {
                    if (secObRow.RowState == DataRowState.Unchanged)
                    {
                        changed = true;
                    }
                }
            }

            if (changed == true)
            {
                DialogResult dr = MessageBox.Show("All your changes will be lost, Do want to save your changes before switching?",
                                                  "Loss of Information Warning", MessageBoxButtons.YesNo);
                switch (dr)
                {
                case DialogResult.Yes:
                    save_Click(null, null);
                    break;

                case DialogResult.No:
                    break;
                }
            }
        }
Exemple #2
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            checkIfChanged();

            SectorTab.Text = e.Node.Text;
            String selName = e.Node.Text.ToString();

            pCanvas1.Dispose();

            this.pCanvas1 = new UMD.HCIL.Piccolo.PCanvas();
            this.SectorTab.Controls.Add(this.pCanvas1);
            this.pCanvas1.AllowDrop        = true;
            this.pCanvas1.BackColor        = System.Drawing.Color.White;
            this.pCanvas1.Dock             = System.Windows.Forms.DockStyle.Fill;
            this.pCanvas1.GridFitText      = false;
            this.pCanvas1.Location         = new System.Drawing.Point(0, 0);
            this.pCanvas1.Name             = "pCanvas1";
            this.pCanvas1.RegionManagement = true;
            this.pCanvas1.Size             = new System.Drawing.Size(554, 438);
            this.pCanvas1.TabIndex         = 0;
            this.pCanvas1.Text             = "pCanvas1";

            if (e.Node.Level == 0)
            {
                if (e.Node.Nodes.Count > 0)
                {
                    DataRow[] systemRow = systems.findRowsByName(selName);
                    String    systemID  = systemRow[0]["system_id"].ToString();
                    selectedSystemRow = systemRow[0];

                    //Populate Properties
                    SystemProps sp = new SystemProps();
                    sp.Name = selName;

                    int   R     = int.Parse(systemRow[0]["color_r"].ToString());
                    int   G     = int.Parse(systemRow[0]["color_g"].ToString());
                    int   B     = int.Parse(systemRow[0]["color_b"].ToString());
                    Color color = Color.FromArgb(R, G, B);
                    sp.Color = color;

                    sp.GalaxyX = float.Parse(systemRow[0]["galaxy_x"].ToString());
                    sp.GalaxyY = float.Parse(systemRow[0]["galaxy_y"].ToString());
                    sp.GalaxyZ = float.Parse(systemRow[0]["galaxy_z"].ToString());
                    sp.Notes   = systemRow[0]["notes"].ToString();

                    DataRow[] sectorTable = sectors.getRowsBySystemID(systemID);

                    createPropertyGrid();
                    propertyGrid1.SelectedObject = sp;

                    systemWindow = new SystemWindow(pCanvas1, selName, sectorTable, propertyGrid1, selectedSystemRow);
                    propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(systemWindow.pg_PropertyValueChanged);
                }
                else
                {
                    MessageBox.Show("Sorry, There are no sector's to display in the selected system! \n Please add a new sector to it, or select another system.");
                }
            }
            else if (e.Node.Level == 1)
            {
                DataRow[] sectorRow = sectors.findRowsByName(selName);
                sectorID = int.Parse(sectorRow[0]["sector_id"].ToString());
                createPropertyGrid();
                sectorWindow = new SectorWindow(pCanvas1, sectorRow, propertyGrid1, dataGridView1);
                createOptions(sectorWindow);
                sectorObjects = sectorWindow.getSectorObjectsSQL();
                propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(sectorWindow.PropertyGrid1_PropertyValueChanged);

                dataGridView1.Rows.Clear();
                DataTable secObjects = sectorObjects.getSectorObject();
                object[]  dataSource = new object[4];
                foreach (DataRow dr in secObjects.Rows)
                {
                    int    id   = int.Parse(dr["sector_object_id"].ToString());
                    String name = dr["name"].ToString();
                    int    baID = int.Parse(dr["base_asset_id"].ToString());
                    int    type = int.Parse(dr["type"].ToString());

                    dataSource[0] = id;
                    dataSource[1] = name;
                    dataSource[2] = baID;
                    dataSource[3] = type;

                    dataGridView1.Rows.Add(dataSource);
                }
            }
        }