Ejemplo n.º 1
0
        private bool _OpenProject(string filename)
        {
            if (OpenedProject != null && !CloseProject())
            {
                return(false);
            }
            string path = filename;

            if (!IsValidFilePath(path))
            {
                OpenFileDialog dialog = MakeOpenFileDialog(FileType.Project);
                if (dialog.ShowDialog(MainForm) == DialogResult.OK)
                {
                    path = dialog.FileName;
                }
                if (!IsValidFilePath(path))
                {
                    return(false);
                }
            }
            try
            {
                OpenedProject         = WaveguideDesignerProjectData.ReadProjectFile(path);
                OpenedProjectFilePath = path;
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary></summary>
        /// <returns>ファイルの作成が完了したらtrue。キャンセルされたり、失敗したらfalse。</returns>
        public bool CreateProject()
        {
            LogMethodStart();

            bool res;

            if (!CloseProject())
            {
                res = false;
            }
            else
            {
                res           = true;
                OpenedProject = new WaveguideDesignerProjectData();
            }

            LogMethodEnd();
            return(res);
        }
Ejemplo n.º 3
0
        private void DeleteLayer(LayerData layer)
        {
            string notice = CurrentLanguage.StandardFunction.Delete_UserNotice;

            if (MessageBox.Show(notice, "", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) != DialogResult.OK)
            {
                return;
            }

            WaveguideDesignerProjectData parent = layer.Parent as WaveguideDesignerProjectData;
            int    index = parent.Layers.IndexOf(layer);
            Action undo  = () => { parent.Layers.Insert(index, layer); };
            Action redo  = () => { parent.Layers.Remove(layer); };

            parent.Layers.Remove(layer);
            Selection = parent;

            UndoRedoPair urPair = new UndoRedoPair(new UndoRedoPairString(CurrentLanguage.StandardFunction.Delete + " : Layer[" + layer.Name + "]", ""), undo, redo);

            AddUndoRedoPair(urPair);
        }
Ejemplo n.º 4
0
        public void WriteProject(WaveguideDesignerProjectData project)
        {
            if (project == null)
            {
                return;
            }

            Type         type;
            EntityObject obj = null;
            DxfDocument  doc = new DxfDocument();

            doc.Name = project.Name;

            Layer     dxfLayer;
            LayerData layerData;

            foreach (VirtualLayer vLayer in project.VirtualGraphics.Layers)
            {
                layerData = null;
                foreach (LayerData tmp in project.Layers)
                {
                    if (tmp.VirtualLayer == vLayer)
                    {
                        layerData = tmp;
                        break;
                    }
                }
                if (layerData == null)
                {
                    continue;
                }
                dxfLayer             = new Layer(layerData.Name);
                dxfLayer.Color.Index = (short)layerData.LayerNumber;
                doc.Layers.Add(dxfLayer);

                foreach (VirtualShapeBase vShape in vLayer.Shapes)
                {
                    type = vShape.GetType();
                    if (type == typeof(VirtualRectangle))
                    {
                        VirtualRectangle rect    = (VirtualRectangle)vShape;
                        Polyline         dxfrect = new Polyline();
                        obj = new Polyline();
                        dxfrect.IsClosed = true;
                        dxfrect.Vertexes.Add(new PolylineVertex(rect.Location.X, rect.Location.Y, 0));
                        dxfrect.Vertexes.Add(new PolylineVertex(rect.Location.X + rect.Size.W, rect.Location.Y, 0));
                        dxfrect.Vertexes.Add(new PolylineVertex(rect.Location.X + rect.Size.W, rect.Location.Y + rect.Size.H, 0));
                        dxfrect.Vertexes.Add(new PolylineVertex(rect.Location.X, rect.Location.Y + rect.Size.H, 0));
                        dxfrect.Vertexes.Add(new PolylineVertex(rect.Location.X, rect.Location.Y, 0));
                        obj = dxfrect;
                    }
                    else if (type == typeof(VirtualPolygon))
                    {
                        VirtualPolygon poly    = (VirtualPolygon)vShape;
                        Polyline       dxfpoly = new Polyline();
                        dxfpoly.IsClosed = true;
                        foreach (PointD p in poly.Vertices)
                        {
                            dxfpoly.Vertexes.Add(conv(p));
                        }
                        dxfpoly.Vertexes.Add(conv(poly.Vertices[0]));
                        obj = dxfpoly;
                    }
                    else if (type == typeof(VirtualEllipse))
                    {
                        VirtualEllipse elli    = (VirtualEllipse)vShape;
                        Ellipse        dxfelli = new Ellipse();
                        dxfelli.Center     = new netDxf.Vector3(elli.Center.X, elli.Center.Y, 0);
                        dxfelli.StartAngle = 0;
                        dxfelli.EndAngle   = 360;
                        dxfelli.MajorAxis  = Math.Max(elli.Radius.W, elli.Radius.H);
                        dxfelli.MinorAxis  = Math.Min(elli.Radius.W, elli.Radius.H);
                        dxfelli.Rotation   = elli.Radius.W >= elli.Radius.H ? 0 : 90;
                        obj = dxfelli;
                    }
                    else if (type == typeof(VirtualPie))
                    {
                        VirtualPie pie     = (VirtualPie)vShape;
                        Ellipse    dxfelli = new Ellipse();
                        dxfelli.Center     = new netDxf.Vector3(pie.Center.X, pie.Center.Y, 0);
                        dxfelli.StartAngle = pie.StartAngle;
                        dxfelli.EndAngle   = pie.EndAngle;
                        dxfelli.MajorAxis  = Math.Max(pie.Radius.W, pie.Radius.H);
                        dxfelli.MinorAxis  = Math.Min(pie.Radius.W, pie.Radius.H);
                        dxfelli.Rotation   = pie.Radius.W >= pie.Radius.H ? 0 : 90;
                        obj = dxfelli;
                    }
                    else
                    {
                        obj = null;
                    }

                    if (obj == null)
                    {
                        continue;
                    }
                    obj.Layer = dxfLayer;
                    doc.AddEntity(obj);
                }
            }

            doc.Save(FileName);
        }
Ejemplo n.º 5
0
 public OpenedProjectChangedEventArgs(WaveguideDesignerProjectData oldItem, WaveguideDesignerProjectData newItem)
 {
     OldItem = oldItem;
     NewItem = newItem;
 }