コード例 #1
0
ファイル: WindowsPrincipale.cs プロジェクト: hysmun/csharp
 private void SupprimerCartoObj()
 {
     if (propertyGrid.SelectedObject != null)
     {
         if (propertyGrid.SelectedObject is POI)
         {
             foreach (Polyline tmpPolyline in listePolyline)
             {
                 foreach (POI tmpPoi in tmpPolyline.LPOI)
                 {
                     if (tmpPoi.Id == (propertyGrid.SelectedObject as POI).Id)
                     {
                         tmpPolyline.LPOI.Remove(tmpPoi);
                         break;
                     }
                 }
             }
             listePOI.Remove(propertyGrid.SelectedObject as POI);
         }
         if (propertyGrid.SelectedObject is Polyline)
         {
             listePolyline.Remove(propertyGrid.SelectedObject as Polyline);
         }
         if (propertyGrid.SelectedObject is Polygon)
         {
             listePolygon.Remove(propertyGrid.SelectedObject as Polygon);
         }
         propertyGrid.SelectedObject = null;
         MainPictureBox.Invalidate();
     }
 }
コード例 #2
0
        public Form1()
        {
            InitializeComponent();

            MainPictureBox.Paint += MainPictureBox_Paint;

            MainPictureBox.Refresh();

            hScrollBar1.Maximum = (GalaxyGenerator.galaxySize * renderer.cellSize);
            vScrollBar1.Maximum = (GalaxyGenerator.galaxySize * renderer.cellSize);

            vScrollBar1.Scroll += (sender, e) => { MainPictureBox.Invalidate(); };
            hScrollBar1.Scroll += (sender, e) => { MainPictureBox.Invalidate(); };

            KeyPress += Form1_KeyPress;

            MainPictureBox.MouseClick += View_MouseClick;
            MainPictureBox.MouseDown  += View_MouseDown;
            MainPictureBox.MouseUp    += View_MouseUp;
            MainPictureBox.MouseMove  += View_MouseMove;
            MainPictureBox.MouseWheel += View_MouseWheel;


            Rand64     rand  = new Rand64((ulong)new Random().Next());
            int        cellX = rand.Range(0, GalaxyGenerator.galaxySize);
            int        cellY = rand.Range(0, GalaxyGenerator.galaxySize);
            GalaxyCell cell  = galaxyGenerator.GetCell(cellX, cellY);

            if (cell != null)
            {
                StarSystem chosenSystem = cell.starSystems[rand.Range(0, cell.starSystems.Count)];
                SelectSystem(chosenSystem);
                CenterOnSystem(chosenSystem);
            }
        }
コード例 #3
0
 protected void OnMultiValueChanged(object sender, EventArgs e)
 {
     if (QuickMode)
     {
         ImageGraphics.Save();
         MainPictureBox.Invalidate();
     }
 }
コード例 #4
0
 protected void OnSingleValueChanged(object sender, ProtoIntegerEditor.ProtoIntegerEditorValueChangedEventArgs e)
 {
     DrawSingleTextNew(e.Index);
     if (!QuickMode)
     {
         ImageGraphics.Save();
         MainPictureBox.Invalidate();
     }
 }
コード例 #5
0
ファイル: WindowsPrincipale.cs プロジェクト: hysmun/csharp
        private void WindowPrincipale_KeyDown(object sender, KeyEventArgs e)
        {
            if (descriptionInUse == true)
            {
                return;
            }
            else
            {
                switch (e.KeyCode)
                {
                    #region key Delete
                case Keys.Delete:
                {
                    SupprimerCartoObj();
                    break;
                }

                    #endregion
                    #region key &
                case Keys.D1:
                {
                    POIButton_Click(this, new EventArgs());
                    break;
                }

                    #endregion
                    #region key é
                case Keys.D2:
                {
                    PolylineButton_Click(this, new EventArgs());
                    break;
                }

                    #endregion
                    #region key &
                case Keys.D3:
                {
                    PolygonButton_Click(this, new EventArgs());
                    break;
                }

                    #endregion
                    #region key enter
                case Keys.Space:
                {
                    DescriptionTB.Focus();
                    break;
                }
                    #endregion
                }
            }
            MainPictureBox.Invalidate();
        }
コード例 #6
0
ファイル: WindowsPrincipale.cs プロジェクト: hysmun/csharp
 private void PolygonLB_SelectedIndexChanged(object sender, EventArgs e)
 {
     //if (propertyGrid.SelectedObject != null)
     //(propertyGrid.SelectedObject as CartoObj).Largeur = largeurGlobal;
     if (PolygonLB.SelectedItem != null)
     {
         unselectLB(3);
         propertyGrid.SelectedObject = PolygonLB.SelectedItem;
         //(propertyGrid.SelectedObject as CartoObj).Largeur += 5;
     }
     MainPictureBox.Invalidate();
 }
コード例 #7
0
 private void easyTrackBar1_ValueChanged(EasyTrackBarValueChangedArgs e)
 {
     if (e.OldValue != e.NewValue)
     {
         Global.GridSizeNum      = e.NewValue;
         tsslStatusGridSize.Text = CommonLib.GetLocalString("status_grid_size", e.NewValue.ToString());
         if (Global.GridStyle.ShowGrid)
         {
             MainPictureBox.Invalidate();
         }
     }
 }
コード例 #8
0
ファイル: Animationlist.cs プロジェクト: m309/fiddler-plus
        private void AnimTick(object sender, EventArgs e)
        {
            ++m_FrameIndex;

            if (m_FrameIndex == m_Animation.Length)
            {
                m_FrameIndex = 0;
            }

            m_ImageInvalidated = true;
            MainPictureBox.Invalidate();
        }
コード例 #9
0
ファイル: WindowsPrincipale.cs プロジェクト: hysmun/csharp
 private void POILB_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (propertyGrid.SelectedObject != null)
     {
         (propertyGrid.SelectedObject as CartoObj).Largeur = largeurGlobal;
     }
     if (POILB.SelectedItem != null)
     {
         unselectLB(1);
         propertyGrid.SelectedObject = POILB.SelectedItem;
         (propertyGrid.SelectedObject as CartoObj).Largeur += 5;
     }
     MainPictureBox.Invalidate();
 }
コード例 #10
0
        private void DisplayBitBoards(params ulong[] bitboards)
        {
            var cells = bitboards.Select(x => BitboardToCells(x).ToList()).ToList();

            var bmp = new Bitmap(MainPictureBox.Width, MainPictureBox.Height);

            var textBrush  = new SolidBrush(Color.FromArgb(255, 255, 255));
            var cellWidth  = bmp.Width / 8;
            var cellHeight = bmp.Height / 8;

            var font = new Font(Font, FontStyle.Bold);

            var borderIncrement = (cellWidth / 2 - 5) / BitboardsTextBoxes.Count;

            using (var graphics = Graphics.FromImage(bmp))
            {
                for (var i = 0; i < 64; i++)
                {
                    var cellX = 7 - (i / 8);
                    var cellY = i % 8;

                    graphics.FillRectangle(EmptyBrush, cellY * cellWidth, cellX * cellHeight, cellWidth, cellHeight);

                    var borderWidth = 0;
                    for (var j = 0; j < cells.Count; j++)
                    {
                        if (cells[j][i])
                        {
                            graphics.FillRectangle(Brushes[j], cellY * cellWidth + borderWidth + 1, cellX * cellHeight + borderWidth + 1, cellWidth - 2 * borderWidth - 1, cellHeight - 2 * borderWidth - 1);
                            borderWidth += borderIncrement;
                        }
                    }

                    var text = (char)(65 + (cellY)) + (8 - cellX).ToString();
                    graphics.DrawString(text, font, textBrush, cellY * cellWidth + cellWidth / 2 - 8, cellX * cellHeight + cellHeight / 2 - 10);
                    graphics.DrawString(i.ToString().PadLeft(2, '0'), font, textBrush, cellY * cellWidth + cellWidth / 2 - 8, cellX * cellHeight + cellHeight / 2 + 2);
                }

                for (var i = 0; i < 9; i++)
                {
                    graphics.DrawLine(Pens.Black, cellWidth * i, 0, cellWidth * i, bmp.Height);
                    graphics.DrawLine(Pens.Black, 0, cellHeight * i, bmp.Width, cellHeight * i);
                }
            }

            MainPictureBox.Image = bmp;
            MainPictureBox.Invalidate();
        }
コード例 #11
0
        private void UpdateImageBox(bool resetZoom, bool resetCamera)
        {
            // If no file is loaded, leave
            if (m_parent.ActiveFile == null || m_selectedMap == null)
            {
                return;
            }

            EditorMapPart part = GetSelectedPart();

            // If we're displaying the graphic map
            if (BottomBarGfxCombo.SelectedIndex == 0)
            {
                m_gridFactor = 8;

                if (m_selectedMap is EditorMapPart)
                {
                    part.UpdateLayerImage();
                }
                else if (m_selectedMap is EditorMapLayer)
                {
                    part.UpdateLayerImage(new List <EditorMapLayer> {
                        (EditorMapLayer)m_selectedMap
                    });
                }

                MainPictureBox.SetImage(part.GraphicsMap, resetZoom, resetCamera, m_gridFactor);
            }

            // If we're displaying the colour map
            else if (BottomBarGfxCombo.SelectedIndex == 1)
            {
                m_gridFactor = 1;

                if (m_selectedMap is EditorMapPart)
                {
                    MainPictureBox.SetImage(part.ColourMap, resetZoom, resetCamera, m_gridFactor);
                }
                else if (m_selectedMap is EditorMapLayer)
                {
                    MainPictureBox.SetImage(GetSelectedLayer().ColourMap, resetZoom, resetCamera, m_gridFactor);
                }
            }

            MainPictureBox.Invalidate();
        }
コード例 #12
0
ファイル: WindowsPrincipale.cs プロジェクト: hysmun/csharp
 private void FiniToolStripButton_Click(object sender, EventArgs e)
 {
     if (PolylineButton.Checked == true && tmpCreationPolyline != null)
     {
         //on fini la polyline
         listePolyline.Add(tmpCreationPolyline);
         tmpCreationPolyline = null;
         DescriptionTB.Text  = "";
     }
     if (PolygonButton.Checked == true && tmpCreationPolygon != null)
     {
         //on fini la polygon
         listePolygon.Add(tmpCreationPolygon);
         tmpCreationPolygon = null;
         DescriptionTB.Text = "";
     }
     MainPictureBox.Invalidate();
 }
コード例 #13
0
        private void DrawBars()
        {
            this.MainDrawer.Clear(Color.Transparent);

            foreach (ContestBar cb in ContestBarList)
            {
                cb.Draw(MainDrawer);
            }

            foreach (PointBar pb in PointBarList)
            {
                pb.Draw(MainDrawer);
            }

            JuryBarList[currentJury].Draw(MainDrawer);

            MainPictureBox.Invalidate();
        }
コード例 #14
0
ファイル: WindowsPrincipale.cs プロジェクト: hysmun/csharp
 private void propertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
 {
     MainPictureBox.Invalidate();
 }
コード例 #15
0
ファイル: WindowsPrincipale.cs プロジェクト: hysmun/csharp
        private void MainPictureBox_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                #region Creation Nouveau item
                if (CreationModeItem.Checked == true)
                {
                    #region Nouveau POI
                    if (POIButton.Checked == true)
                    {
                        // nouveau POI
                        POI newPOI = new POI(e.X, e.Y, DescriptionTB.Text, ColorButtonToolStrip.BackColor, largeurGlobal);
                        listePOI.Add(newPOI);
                        DescriptionTB.Text = "";
                    }
                    #endregion

                    #region Nouveau Polyline
                    if (PolylineButton.Checked == true)
                    {
                        // nouveau Polyline
                        if (tmpCreationPolyline == null)
                        {
                            tmpCreationPolyline = new Polyline(DescriptionTB.Text, ColorButtonToolStrip.BackColor, largeurGlobal);
                        }
                        bool poiProche = false;
                        int  i;
                        for (i = 0; i < listePOI.Count && poiProche == false; i++)
                        {
                            if (listePOI[i].IsPointClose(e.X, e.Y, precisionGlobal) == true)
                            {
                                poiProche = true;
                            }
                        }
                        if (poiProche == true)
                        {
                            //on rajoute le point a l'indice i -1
                            tmpCreationPolyline.LPOI.Add(listePOI[i - 1]);
                        }
                        else
                        {
                            //on cree un nouveau point
                            POI newPOI = new POI(e.X, e.Y, DescriptionTB.Text, ColorButtonToolStrip.BackColor, largeurGlobal);
                            tmpCreationPolyline.LPOI.Add(newPOI);
                            listePOI.Add(newPOI);
                        }
                    }
                    #endregion

                    #region Nouveau Polygon
                    if (PolygonButton.Checked == true)
                    {
                        // nouveau Polygon
                        if (tmpCreationPolygon == null)
                        {
                            tmpCreationPolygon = new Polygon(DescriptionTB.Text, ColorButtonToolStrip.BackColor, largeurGlobal);
                        }
                        bool polylineProche = false;
                        int  i;
                        for (i = 0; i < listePolyline.Count && polylineProche == false; i++)
                        {
                            if (listePolyline[i].IsPointClose(e.X, e.Y, precisionGlobal) == true)
                            {
                                polylineProche = true;
                            }
                        }
                        if (polylineProche == true)
                        {
                            //on rajoute la Polyline l'indice i-1
                            bool add = true;
                            foreach (Polyline tmpPolyline in tmpCreationPolygon.LPolyline)
                            {
                                if (tmpPolyline.Id == listePolyline[i - 1].Id)
                                {
                                    add = false;
                                }
                            }
                            if (add == true)
                            {
                                tmpCreationPolygon.LPolyline.Add(listePolyline[i - 1]);
                            }
                        }
                        else
                        {
                            //on cree une nouvelle polyline
                        }
                        #endregion
                    }
                }
                #endregion

                #region Selection mode item
                if (SelectionModeItem.Checked == true)
                {
                    //
                    int  i;
                    bool cartoObjProche = false;
                    for (i = 0; i < listePOI.Count && cartoObjProche == false; i++)
                    {
                        if (listePOI[i].IsPointClose(e.X, e.Y, precisionGlobal) == true)
                        {
                            cartoObjProche = true;
                        }
                    }
                    if (cartoObjProche == true)
                    {
                        if (propertyGrid.SelectedObject != null)
                        {
                            (propertyGrid.SelectedObject as CartoObj).Largeur = largeurGlobal;
                        }
                        propertyGrid.SelectedObject = listePOI[i - 1];
                        (propertyGrid.SelectedObject as CartoObj).Largeur += 5;
                    }
                    else
                    {
                        //faut verifier les polyline et polygon avant

                        cartoObjProche = false;
                        for (i = 0; i < listePolyline.Count && cartoObjProche == false; i++)
                        {
                            if (listePolyline[i].IsPointClose(e.X, e.Y, precisionGlobal) == true)
                            {
                                cartoObjProche = true;
                            }
                        }
                        if (cartoObjProche == true)
                        {
                            if (propertyGrid.SelectedObject != null)
                            {
                                (propertyGrid.SelectedObject as CartoObj).Largeur = largeurGlobal;
                            }
                            propertyGrid.SelectedObject = listePolyline[i - 1];
                            (propertyGrid.SelectedObject as CartoObj).Largeur += 5;
                            precX = e.X;
                            precY = e.Y;
                        }
                        else
                        {
                            //faut verifier les polygon mtn
                            cartoObjProche = false;
                            for (i = 0; i < listePolygon.Count && cartoObjProche == false; i++)
                            {
                                if (listePolygon[i].IsPointClose(e.X, e.Y, precisionGlobal) == true)
                                {
                                    cartoObjProche = true;
                                }
                            }
                            if (cartoObjProche == true)
                            {
                                if (propertyGrid.SelectedObject != null)
                                {
                                    (propertyGrid.SelectedObject as CartoObj).Largeur = largeurGlobal;
                                }
                                propertyGrid.SelectedObject = listePolygon[i - 1];
                                (propertyGrid.SelectedObject as CartoObj).Largeur += 5;
                            }
                            else
                            {
                                (propertyGrid.SelectedObject as CartoObj).Largeur -= 5;
                                propertyGrid.SelectedObject = null;
                            }
                        }
                    }
                }
                #endregion

                #region Deplacement mode item
                if (DeplacementModeItem.Checked == true)
                {
                    if (propertyGrid.SelectedObject != null)
                    {
                        if (propertyGrid.SelectedObject is POI)
                        {
                            (propertyGrid.SelectedObject as POI).Lat       = e.X;
                            (propertyGrid.SelectedObject as POI).Longitude = e.Y;
                        }
                        if (propertyGrid.SelectedObject is Polyline)
                        {
                            // calcule delta
                            foreach (POI tmpPOI in (propertyGrid.SelectedObject as Polyline).LPOI)
                            {
                                tmpPOI.Lat       = tmpPOI.Lat - (precX - e.X);
                                tmpPOI.Longitude = tmpPOI.Longitude - (precY - e.Y);
                            }
                            precX = e.X;
                            precY = e.Y;
                        }
                    }
                }
                #endregion

                unselectLB(0);
                MainPictureBox.Invalidate();
            }
            catch (Exception eE)
            {
                MessageBox.Show("Erreur dessin !!!\n" + eE.Message);
            }
        }