Exemple #1
0
        public void OpenWorkSpace()
        {
            if (DiscardChanges())
            {
                OpenFileDialog open = new OpenFileDialog();
                open.DefaultExt = ".scumle";
                open.Filter     = "(.scumle)|*.scumle";
                List <ModelBase> loadedModelsList = new List <ModelBase>();

                // Show open file dialog box
                bool?result = open.ShowDialog();

                // Process open file dialog box results
                if (result == true)
                {
                    LoadThread loadThread = new LoadThread(Shapes, Lines, Path.GetFullPath(open.FileName));
                    loadThread.Start();
                    Shapes.Clear();
                    Lines.Clear();
                    UndoRedo.clear();
                    UndoRedo.ChangeSinceSave = false;
                    _currentFilePath         = Path.GetFullPath(open.FileName);
                }
            }
        }
 private void OnOpenImage(object p)
 {
     try
     {
         OpenFileDialog openFileDialog = new OpenFileDialog();
         openFileDialog.Filter = "Изображение (*.png)|*.png|(*.jpg)|*.jpg|(*.bmp)|*.bmp";
         if (openFileDialog.ShowDialog() == true)
         {
             FilteringColor = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(FillSet);
             if (Shapes.Count > 0)
             {
                 Shapes.Clear();
                 if (Points.Count > 0)
                 {
                     Points.Clear();
                 }
             }
             Bitmap bitmap  = new Bitmap(openFileDialog.FileName);
             Uri    fileUri = new Uri(openFileDialog.FileName);
             var    outFile = new BitmapImage(fileUri);
             GetPixelsArray(bitmap);
             ImageOut     = outFile;
             CanvasHeight = bitmap.Height;
             CanvasWidth  = bitmap.Width;
             Start();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ошибка: " + ex.Message, "Exception Sample", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Exemple #3
0
 /// <summary>
 /// Clears the simulation of every object, only returning memory to the pool that would be returned by sequential removes.
 /// Other persistent allocations, like those in the Bodies set, will remain.
 /// </summary>
 public void Clear()
 {
     Solver.Clear();
     Bodies.Clear();
     Statics.Clear();
     Shapes.Clear();
     BroadPhase.Clear();
 }
Exemple #4
0
 public void Restart()
 {
     Shapes.Clear();
     _undoneShapes.Clear();
     _currentlyDrawnShape = null;
     UpdateUndoRedo();
     Invalidate();
 }
Exemple #5
0
 private void btnClear_Click(object sender, EventArgs e)
 {
     if (Shapes.Count > 0)
     {
         Shapes.Clear();
         listBox1.Items.Clear();
     }
     Redraw();
 }
Exemple #6
0
 public void NewWorkSpace()
 {
     if (DiscardChanges())
     {
         _currentFilePath = null;
         Shapes.Clear();
         Lines.Clear();
         UndoRedo.clear();
     }
 }
        protected override void Execute()
        {
            if (m_formerSpace != Target.Space)
            {
                m_formerSpace = Target.Space;

                Shapes.Clear();
                Shapes.Add(new MyWorldShape(Target.Space));
            }
        }
Exemple #8
0
        private void DeleteAllShapes()
        {
            foreach (BaseShape shape in Shapes)
            {
                shape.Dispose();
            }

            Shapes.Clear();
            DeselectCurrentShape();
        }
        /// <summary>
        /// Resets routing.
        /// </summary>
        public void Reset()
        {
            Shapes.Clear();

            stops = new List <Stop> {
                null, null
            };
            routes = new List <Route> {
                new Route(this)
            };
        }
Exemple #10
0
        public void GetShapes(string fileName)
        {
            filePath = fileName;
            ObservableCollection <ShapeBase> observableCollection = shapesDAO.getShapes(fileName);

            Shapes.Clear();
            foreach (var item in observableCollection)
            {
                Shapes.Add(item);
            }
            ChoosenShapeIndex = -1;
        }
        /// <summary>
        /// Updates the collision shapes which are shown at the scene (at <see cref="SceneScreen"/>).
        /// </summary>
        protected void UpdateShapes()
        {
            // clear old shapes
            Shapes.Clear();

            // update all shapes
            if (Actor.Shapes != null)
            {
                foreach (Shape shape in Actor.Shapes)
                {
                    Shape newShape = shape.Clone();

                    newShape.Move(Position);
                    newShape.Scale(ScaleFactor, Position);
                    newShape.Rotate(Angle, Position);

                    Shapes.Add(newShape);
                }
            }

            containsShapes = Shapes.Count != 0;

            // no shape
            if (Shapes.Count == 0)
            {
                // set rectangle to border texture
                if (sceneDrawable != null)
                {
                    Polygon textureRectangle = sceneDrawable.GetBounds(Position);
                    if (textureRectangle != null)
                    {
                        textureRectangle.Scale(ScaleFactor, Position);
                        textureRectangle.Rotate(Angle, Position);

                        Shapes.Add(textureRectangle);
                    }
                }

                // set some shape otherwise the actor cannot be selected
                if (Shapes.Count == 0)
                {
                    float   defaultShapeSize = 50f;
                    Polygon defaultRectangle = Polygon.CreateAsRectangle(Position - new Vector2(defaultShapeSize / 2f, defaultShapeSize / 2f), defaultShapeSize, defaultShapeSize);
                    defaultRectangle.Scale(ScaleFactor, Position);
                    defaultRectangle.Rotate(Angle, Position);

                    Shapes.Add(defaultRectangle);
                }
            }

            // update AABB rectangle
            UpdateRectangle();
        }
Exemple #12
0
 public void ReadShapes()
 {
     Shapes.Clear();
     var eShapes = Slide.Shapes.GetEnumerator();
     while (eShapes.MoveNext())
     {
         Shape shape = (Shape)eShapes.Current;
         if (shape.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
         {
             Shapes.Add(shape);
         }
     }
 }
        public void Load(XmlReader reader)
        {
            var dat = new XmlSerializer(typeof(SaveContainer)).Deserialize(reader) as SaveContainer;

            cam = dat.camera;
            VisualizeCamera();
            Shapes.Clear();
            foreach (var e in dat.shapes)
            {
                Shapes.Add(e);
            }
            Lbshapes.SelectedIndex = 0;
            AlertChanges();
        }
Exemple #14
0
        private void NewGame(object o)
        {
            int size = int.Parse((String)o);

            FieldSize = size;
            PlayerOne.Player.Points = 0;
            PlayerTwo.Player.Points = 0;
            OnPropertyChanged("PlayerOne");
            OnPropertyChanged("PlayerTwo");
            model           = new SquaresGameModel(FieldSize, PlayerOne.Player, PlayerTwo.Player, persistence);
            model.UpdateUI += UpdateUI;
            model.EndGame  += PlayerWon;
            Shapes.Clear();
            InitDots(FieldSize);
        }
Exemple #15
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            try
            {
                using (var d = new OpenFileDialog())
                {
                    d.Filter = "Text file|*.txt";
                    if (d.ShowDialog() == DialogResult.OK)
                    {
                        var text = File.ReadAllText(d.FileName);

                        var plugin = SingleSerializationPluginDecorator.SerializationPlugins.FirstOrDefault();
                        if (plugin != null && plugin.Enabled)
                        {
                            text = plugin.OnBeforeDeserialize(text);
                        }
                        string[] lines = text.Split(
                            new[] { Environment.NewLine },
                            StringSplitOptions.RemoveEmptyEntries
                            );
                        var shapes = Serializer.Deserialize(lines);


                        Shapes.Clear();
                        listBox1.Items.Clear();

                        foreach (var shape in shapes)
                        {
                            Shapes.Push(shape);
                            listBox1.Items.Add(shape);
                        }
                        Redraw();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Invalid data format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #16
0
        public void DefaultShape()
        {
            Shapes.Clear();
            PolyLine S1 = new PolyLine(State.LastShapeID++);

            S1.Add(0, 10);
            S1.Add(20, 10);
            S1.Add(20, 20);
            S1.Add(0, 20);
            S1.Add(0, 10);
            Shapes.Add(S1);
            PolyLine S2 = new PolyLine(State.LastShapeID++);

            for (int i = 0; i < 101; i++)
            {
                double p = (double)i * 0.06283f;
                S2.Add(10.0f + (double)Math.Sin(p) * 5.0f, 15.0f - (double)Math.Cos(p) * 5.0f);
            }
            Shapes.Add(S2);

            BuildBoundary();
        }
        /// <summary>
        /// Метод сохраненной сети Петри
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Open_Click(object sender, EventArgs e)
        {
            OpenFileDialog op = new OpenFileDialog();

            op.Filter     = "dat файл (*.dat)|*.dat|Все файлы (*.*)|*.*";
            op.DefaultExt = "*.dat";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Shapes.Clear();

                string          FileName  = openFileDialog1.FileName;
                BinaryFormatter binFormat = new BinaryFormatter();
                using (FileStream fs = new FileStream(FileName, FileMode.OpenOrCreate))
                {
                    List <IShape> Fig = (List <IShape>)binFormat.Deserialize(fs);
                    foreach (IShape f in Fig)
                    {
                        Shapes.Add(f);
                    }
                    fs.Close();
                }
            }
            Refresh();
        }
 public static void Clear()
 {
     Shapes.Clear();
 }
Exemple #19
0
 private void ResetApplicationState()
 {
     Lines.Clear();
     Shapes.Clear();
 }
Exemple #20
0
 //создаем новый документ
 //очищаем список объектов на форме
 //очищаем стэки Undo и Redo
 private void toolStripButtonNewdoc_Click(object sender, EventArgs e)
 {
     Sh.Clear();
     panel2.Invalidate();
 }
Exemple #21
0
 public void Remove()
 {
     GetShaess.Clear();
     Shapes.Clear();
 }
Exemple #22
0
        public void UpdateFrame(uint simulationStep)
        {
            SimulationStep = simulationStep;

            if (m_userResetNeeded)
            {
                m_userResetNeeded = false;

                Shapes.Clear();

                Reset();

                if (Shapes.Count == 0)
                {
                    Shapes.Add(new MyDefaultShape());
                }

                foreach (MyShape shape in Shapes)
                {
                    shape.Observer = this;
                }
            }

            if (m_textureResetNeeded)
            {
                m_textureResetNeeded = false;

                TextureSize = TextureWidth * TextureHeight;

                DeleteTextureVBO();
                CreateTextureVBO();
                TriggerViewReset();
            }

            if (m_verticesResetNeeded)
            {
                m_verticesResetNeeded = false;
                DeleteVertexVBO();
                CreateVertexVBO();
            }

            if (m_cudaTextureSource != null)
            {
                m_cudaTextureSource.Map();
            }

            if (m_cudaVertexSource != null)
            {
                m_cudaVertexSource.Map();
            }

            Execute();

            if (m_cudaTextureSource != null)
            {
                m_cudaTextureSource.UnMap();
            }

            if (m_cudaVertexSource != null)
            {
                m_cudaVertexSource.UnMap();
            }
        }
Exemple #23
0
        public void UpdateFrame(uint simulationStep)
        {
            SimulationStep = simulationStep;

            if (m_userResetNeeded)
            {
                m_userResetNeeded = false;

                Shapes.Clear();

                Reset();

                if (Shapes.Count == 0)
                {
                    Shapes.Add(new MyDefaultShape());
                }

                foreach (MyShape shape in Shapes)
                {
                    shape.Observer = this;
                }
            }

            if (m_textureResetNeeded)
            {
                m_textureResetNeeded = false;

                TextureSize = TextureWidth * TextureHeight;

                DeleteTextureVBO();
                CreateTextureVBO();
                TriggerViewReset();
            }

            if (m_verticesResetNeeded)
            {
                m_verticesResetNeeded = false;
                DeleteVertexVBO();
                CreateVertexVBO();
            }

            m_cudaTextureSource?.Map();
            m_cudaVertexSource?.Map();

            try
            {
                PrepareExecution();

                if (IsTargetReady)
                {
                    Execute();
                }
            }
            finally
            {
                if (m_cudaTextureSource != null)
                {
                    m_cudaTextureSource.UnMap();
                }
                else if (m_cudaTextureVar != null)
                {
                    CopyCudaVariableToHost(m_cudaTextureVar, BufferTarget.PixelUnpackBuffer, m_textureVBO);
                }

                if (m_cudaVertexSource != null)
                {
                    m_cudaVertexSource.UnMap();
                }
                else if (m_cudaVertexVar != null)
                {
                    CopyCudaVariableToHost(m_cudaVertexVar, BufferTarget.ArrayBuffer, m_vertexVBO);
                }
            }
        }
Exemple #24
0
 public override void Create()
 {
     Shapes.Clear();
     Shapes.Add(Primitives.Rectangle(Size));
 }
Exemple #25
0
 public void NewCanvas()
 {
     Shapes.Clear();
     filePath    = "";
     isNewCanvas = true;
 }
Exemple #26
0
        public void Generate()
        {
            Shapes.Clear();
            Shapes.Add(_site.GetShape());
            Shapes.Add(_obstacle.GetShape());

            int maxY = Convert.ToInt32(_site.GetMaxCoordinate("y"));
            int minY = Convert.ToInt32(_site.GetMinCoordinate("y"));
            int maxX = Convert.ToInt32(_site.GetMaxCoordinate("x"));
            int minX = Convert.ToInt32(_site.GetMinCoordinate("x"));


            /*
             * This is a matric of usable points, down the line I start to populate
             * it by placing cells (solar panels) and booking required area + spacing
             * in positinve x and y directions. Matrix size is layout widest part x layout highest part.
             */
            bool[,] matrix = new bool[maxX - minX, maxY - minY];
            for (int x = 0; x < maxX - minX; x++)
            {
                for (int y = 0; y < maxY - minY; y++)
                {
                    matrix[x, y] = true;
                }
            }
            matrix = InitialiseMatrix(matrix, maxY, minY, maxX, minX);
            for (int y = 0; y < maxY - minY; y++)
            {
                for (int x = 0; x < maxX - minX; x++)
                {
                    if (matrix[x, y] == true)
                    {
                        bool book = true;
                        for (int xcell = 0; xcell < _cell.Length; xcell++)
                        {
                            if (book == true)
                            {
                                for (int ycell = 0; ycell < _cell.EffectiveWidth; ycell++)
                                {
                                    if ((x + xcell >= maxX - minX) || (y + ycell >= maxY - minY) ||
                                        matrix[x + xcell, y + ycell] == false)
                                    {
                                        book = false;
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        if (book == true)
                        {
                            int lenghtToBook = _cell.Length + _site.ColumnSpacing;
                            int widthToBook  = _cell.EffectiveWidth + _site.RowSpacing;
                            for (int xcell = 0; xcell <= lenghtToBook; xcell++)
                            {
                                for (int ycell = 0; ycell <= widthToBook; ycell++)
                                {
                                    if ((x + xcell < maxX - minX) && (y + ycell < maxY - minY))
                                    {
                                        matrix[x + xcell, y + ycell] = false;
                                    }
                                }
                            }

                            Shapes.Add(DrawCell(x + minX, y + minY));
                            //OnPropertyChanged("Shapes");
                        }
                    }
                }
            }
        }
Exemple #27
0
 private void ClearAll()
 {
     Shapes.Clear();
     DeselectShape();
 }
Exemple #28
0
 //==================================================
 //==================================================
 private void ClearButton_Click(object sender, EventArgs e)
 {
     g.Clear(Color.White);
     PictureBox.Invalidate();
     Shapes.Clear();
 }