Пример #1
0
        internal void Init(AreaMapComponent inAreaMapComponent, GenerationData inGenData)
        {
            genData          = inGenData;
            areaMapComponent = inAreaMapComponent;

            FillList();
        }
Пример #2
0
        private void rerange01To0515ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <Area> sel = AreaMapComponent.GetEditSelection();

            foreach (Area area in sel)
            {
                if (area.ValueMinY == 0 && area.ValueMaxY == 1)
                {
                    area.ValueMinY = -0.5f;
                    area.ValueMaxY = 1.5f;

                    area.ValueSuggestedMinY = 0f;
                    area.ValueSuggestedMaxY = 1f;

                    area.ValueMultiplyY = .5f;


                    //Here, 15f is set because the original height of the control is 60px, must be relative...
                    area.ImgPosition = new Vector2(area.ImgPosition.X, area.ImgPosition.Y + 15f);

                    area.RefCenter = new Vector2(area.RefCenter.X, area.RefCenter.Y - 15f);

                    area.Reset();
                }
            }

            AreaMapComponent.Invalidate();
        }
Пример #3
0
        private void shapeRemoveBT_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItems.Count > 0)
            {
                string areaText = "";

                List <Area> selectedAreas = new List <Area>();
                foreach (object areaObj in listBox1.SelectedItems)
                {
                    Area area = areaObj as Area;
                    if (!area.IsSubComponent)
                    {
                        selectedAreas.Add(area);
                        areaText += areaObj.ToString() + ",";
                    }
                }

                if (MessageBox.Show("Are you sure you want to remove " + areaText.Substring(0, areaText.Length - 1) + " ?", "Remove shapes", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    AreaMapComponent.RemoveAreas(selectedAreas);
                    RefreshListBox();
                }
                else
                {
                    MessageBox.Show("Nothing to remove, please select some items!");
                }
            }
        }
Пример #4
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            RefreshPropGrid();
            if (listBox1.SelectedItems.Count > 0)
            {
                metaDataTB.Enabled = true;

                _muteEvents     = true;
                metaDataTB.Text = (listBox1.SelectedItems[0] as Area).MetaData;
                _muteEvents     = false;
            }
            else
            {
                metaDataTB.Enabled = false;
            }

            if (SyncSelection && !_muteEvents)
            {
                _muteEvents = true;

                AreaMapComponent.DeselectAll();
                foreach (Area area in listBox1.SelectedItems)
                {
                    AreaMapComponent.AddToSelection(area);
                }

                _muteEvents = false;
            }
        }
Пример #5
0
 private void resetAllToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!AreaMapComponent.IsEditing)
     {
         AreaMapComponent.ResetAll();
     }
 }
Пример #6
0
        public AreaMapComponent GetLibrary()
        {
            AreaMapComponent comp = new AreaMapComponent();

            comp.Load(LibraryPath);

            return(comp);
        }
Пример #7
0
 private void centerYNUD_ValueChanged(object sender, EventArgs e)
 {
     if (!_muteEvents)
     {
         AreaMapComponent.Center = new Vector2(AreaMapComponent.Center.X, (float)centerYNUD.Value);
         AreaMapComponent.Invalidate();
     }
 }
Пример #8
0
 private void groupsGridView_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (groupsGridView.SelectedRows.Count == 1 && groupsGridView.SelectedRows[0].Index == e.RowIndex)
     {
         AreaMapComponent.SelectGroups(new List <AreaGroup> {
             AreaMapComponent.Groups[groupsGridView.SelectedRows[0].Index]
         });
     }
 }
Пример #9
0
        void AddBT_Click(object sender, EventArgs e)
        {
            List <string> sel = editor.GetSelection();

            List <Area> areas = new List <Area>();

            float minX = float.MaxValue;
            float maxX = float.MinValue;

            float minY = float.MaxValue;
            float maxY = float.MinValue;

            foreach (string selItem in sel)
            {
                RigElement elem             = editor.GenData.RealNamesControls[selItem];
                Area       oscarControlArea = AreaMapComponent.AddOscarControl(selItem, elem, editor.GenData.CtrlsInfos[elem.FullName], editor.Projection);

                Vector2 corner      = oscarControlArea.Corner;
                Vector2 otherCorner = oscarControlArea.Shape.LowerRightCorner;

                if (maxX < otherCorner.X)
                {
                    maxX = otherCorner.X;
                }
                if (minX > corner.X)
                {
                    minX = corner.X;
                }

                if (maxY < otherCorner.Y)
                {
                    maxY = otherCorner.Y;
                }
                if (minY > corner.Y)
                {
                    minY = corner.Y;
                }

                areas.Add(oscarControlArea);
            }

            float Yextension = maxY - minY;
            float Xextension = maxX - minX;

            float scale = Math.Min(AreaMapComponent.Width / Xextension, AreaMapComponent.Height / Yextension);

            foreach (Area area in areas)
            {
                area.Center *= new Vector2(1.0f, -1.0f);
                area.Center += new Vector2(-minX, maxY);
                area.Scale(new Vector2(scale, scale), new Vector2(0f, 0f));
            }

            AreaMapComponent.Invalidate();
            RefreshListBox();
        }
Пример #10
0
        private void areaMap1_DragDrop(object sender, DragEventArgs e)
        {
            Shape2 shape = null;
            Area   area  = null;

            if (e.Data.GetDataPresent(typeof(Polygon2)))
            {
                shape = (Polygon2)e.Data.GetData(typeof(Polygon2));
            }
            else
            {
                if (e.Data.GetDataPresent(typeof(Area)))
                {
                    area = (Area)e.Data.GetData(typeof(Area));
                }
                else
                {
                    shape = (Circle)e.Data.GetData(typeof(Circle));
                }
            }

            Point mapDropPoint = AreaMapComponent.PointToClient(new Point(e.X, e.Y));

            mapDropPoint.Offset(GeoConverter.ConvertRound(AreaMapComponent.Offset * -1));

            if (shape != null)
            {
                shape.Offset((new Vector2(mapDropPoint.X, mapDropPoint.Y)) * (1f / AreaMapComponent.Scaling));
                shape.Clamp(0, AreaMapComponent.Dimensions.Width, 0, AreaMapComponent.Dimensions.Height);
                AreaMapComponent.AddShape(shape);
                RefreshListBox();
            }
            else if (area != null)
            {
                //Has a picture with path relative to library
                if (area.ImgPath != "" && area.ImgPath != libraryUCtrl1.AreaMapComp.CurrentAreaMap.GetAbsolutePath(area.ImgPath))
                {
                    if (AreaMapComponent.CurrentAreaMap.Path != "")
                    {
                        area.Map = libraryUCtrl1.AreaMapComp.CurrentAreaMap;
                        AreaMapComponent.Migrate(area, PathHelper.GetFolderPath(AreaMapComponent.CurrentAreaMap.Path));
                    }
                    else
                    {
                        MessageBox.Show("You must save your AreaMap to be able to use library items with relative pictures !", "File not saved");
                        return;
                    }
                }

                area.Center = (new Vector2(mapDropPoint.X, mapDropPoint.Y)) * (1f / AreaMapComponent.Scaling);
                area.Clamp(0, AreaMapComponent.Dimensions.Width, 0, AreaMapComponent.Dimensions.Height);
                area.SetRefCenter();
                AreaMapComponent.AddArea(area);
                RefreshListBox();
            }
        }
Пример #11
0
        private void groupRemoveShapesBT_Click(object sender, EventArgs e)
        {
            if (groupsGridView.SelectedCells.Count > 0)
            {
                int row = groupsGridView.SelectedCells[0].RowIndex;

                AreaMapComponent.RemoveShapesFromGroup(row);
                AreaMapComponent.ApplyGroupValues();
                RefreshGroups();
            }
        }
Пример #12
0
        private void sendToBackToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <Area> areas = AreaMapComponent.GetEditSelection();

            foreach (Area area in areas)
            {
                AreaMapComponent.CurrentAreaMap.Areas.Remove(area);
                AreaMapComponent.CurrentAreaMap.Areas.Add(area);
            }

            RefreshListBox();
        }
Пример #13
0
        private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            if (e.ChangedItem.Label == "MetaData")
            {
                _muteEvents     = true;
                metaDataTB.Text = (string)e.ChangedItem.Value;
                _muteEvents     = false;
            }

            RefreshListBox();
            AreaMapComponent.Invalidate();
        }
Пример #14
0
        private void loadPictureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "Picture files (*.jpg,*.png,*.gif,*.bmp)|*.jpg;*.png;*.gif;*.bmp";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                AreaMapComponent.SetPicture(openFileDialog1.FileName);

                centerXNUD.Value = (decimal)AreaMapComponent.Center.X;
                centerXNUD.Value = (decimal)AreaMapComponent.Center.X;
            }
        }
Пример #15
0
        private void groupsGridView_SelectionChanged(object sender, EventArgs e)
        {
            List <AreaGroup> selectedGroups = new List <AreaGroup>();

            foreach (DataGridViewRow rows in groupsGridView.SelectedRows)
            {
                selectedGroups.Add(AreaMapComponent.Groups[rows.Index]);
            }

            if (selectedGroups.Count > 0)
            {
                AreaMapComponent.SelectGroups(selectedGroups);
            }
        }
Пример #16
0
        private void metaDataTB_TextChanged(object sender, EventArgs e)
        {
            if (!_muteEvents)
            {
                _muteEvents = true;
                List <Area> areas = AreaMapComponent.GetEditSelection();
                foreach (Area area in areas)
                {
                    area.MetaData = metaDataTB.Text;
                }

                RefreshPropGrid();
                _muteEvents = false;
            }
        }
Пример #17
0
        private void exportAsAnimPickerFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (saveFileDialog2.ShowDialog() == DialogResult.OK)
            {
                if (AreaMapComponent.IsEditing)
                {
                    AreaMapComponent.StopEdit();
                }
                string error = AreaMapComponent.ExportAsPicker(AreaMapComponent.CurrentAreaMap, saveFileDialog2.FileName, false, 1.5);

                if (!string.IsNullOrEmpty(error))
                {
                    MessageBox.Show(error);
                }
            }
        }
Пример #18
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if (AreaMapComponent.IsEditing)
                {
                    AreaMapComponent.StopEdit();
                }
                string error = AreaMapComponent.Save(AreaMapComponent.CurrentAreaMap, saveFileDialog1.FileName, true);

                if (!string.IsNullOrEmpty(error))
                {
                    MessageBox.Show(error);
                }
            }
        }
Пример #19
0
        private void shapeSymYBT_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItems.Count > 0)
            {
                string areaText = "";

                List <Area> selectedAreas = new List <Area>();
                foreach (object areaObj in listBox1.SelectedItems)
                {
                    Area area = areaObj as Area;
                    if (!area.IsSubComponent)
                    {
                        area = area.Clone();
                        AreaMapComponent.AddArea(area);
                        AreaMapComponent.SymmetrizeY(area);

                        //Search if Area already exists
                        int  index        = 0;
                        Area existingArea = null;
                        foreach (Area oldArea in AreaMapComponent.CurrentAreaMap.Areas)
                        {
                            if (oldArea.Name == area.Name && area != oldArea)
                            {
                                existingArea = oldArea;
                                break;
                            }
                            index++;
                        }

                        if (existingArea != null)
                        {
                            AreaMapComponent.RemoveAreas(new List <Area> {
                                existingArea
                            });

                            if (index < AreaMapComponent.CurrentAreaMap.Areas.Count - 1)
                            {
                                AreaMapComponent.CurrentAreaMap.Areas.Remove(area);
                                AreaMapComponent.CurrentAreaMap.Areas.Insert(index, area);
                            }
                        }
                    }
                }

                RefreshListBox();
            }
        }
Пример #20
0
        private void shapeMirrorYBT_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItems.Count > 0)
            {
                string areaText = "";

                List <Area> selectedAreas = new List <Area>();
                foreach (object areaObj in listBox1.SelectedItems)
                {
                    Area area = areaObj as Area;
                    if (!area.IsSubComponent)
                    {
                        AreaMapComponent.MirrorY(area);
                    }
                }
            }
        }
Пример #21
0
        public void SetSelectionFromMetaData(List <string> inSelectionList)
        {
            _areaMapComponent.DeselectAll(false);
            List <Area> areas = new List <Area>();

            foreach (string item in inSelectionList)
            {
                List <Area> found = AreaMapComponent.FindAreaFromMetaData(item);
                if (found != null && found.Count > 0)
                {
                    areas.AddRange(found);
                }
            }

            if (areas.Count > 0)
            {
                _areaMapComponent.AddToSelection(areas, false);
            }

            _areaMapComponent.Invalidate();
        }
Пример #22
0
 public void Initialize(AreaMapComponent inComponent)
 {
     _areaMapComponent = inComponent;
     ResetAreaMaps();
 }
Пример #23
0
 internal void Clear()
 {
     AreaMapComponent.Clear();
     ResetAreaMaps();
 }
Пример #24
0
 private void stopEditingToolStripMenuItem_Click(object sender, EventArgs e)
 {
     AreaMapComponent.StopEdit();
     RefreshListBox();
 }
Пример #25
0
 private void addRectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     AreaMapComponent.AddRectangle(new Vector2(50, 50), 120f, 80f);
     RefreshListBox();
 }
Пример #26
0
 private void groupAddBT_Click(object sender, EventArgs e)
 {
     AreaMapComponent.CreateGroupFromSelection("NewGroup");
     AreaMapComponent.ApplyGroupValues();
     RefreshGroups();
 }
Пример #27
0
 private void groupsGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     AreaMapComponent.ApplyGroupValues();
 }