示例#1
0
 private void lDesignNewBtn_Click(object sender, EventArgs e)
 {
     lDesignFilePath    = "";
     lDesignObject      = new DesignObject();
     lDesignObject.Name = "";
     lDesignCtrl.SetDesignObject(lDesignObject);
     lDesignCtrl.ShowAxes = lAppPrefs.ShowAxes;
     lPartsLvw.Items.Clear();
 }
示例#2
0
 public GraphicsElementGeometric3D(DesignObject design, int width, int height, double phi, double theta, bool showaxes)
 {
     lInitializeVariables();
     Design = design;
     Width  = width;
     Height = height;
     lPhi   = phi;
     lTheta = theta;
 }
示例#3
0
 public GraphicsElementGeometric3D(DesignObject design, int width, int height, int offsetx, int offsety, double phi, double theta)
 {
     lInitializeVariables();
     Design  = design;
     Width   = width;
     Height  = height;
     OffsetX = offsetx;
     OffsetY = offsety;
     lPhi    = phi;
     lTheta  = theta;
 }
示例#4
0
 public GraphicsElementGeometric3D(DesignObject design, Graphics gfx, int width, int height, double phi, double theta, bool showaxes, bool showlabels)
 {
     lInitializeVariables();
     Design      = design;
     Width       = width;
     Height      = height;
     lPhi        = phi;
     lTheta      = theta;
     lShowAxes   = showaxes;
     lShowLabels = showlabels;
     ScaleToElementSize(gfx);
 }
示例#5
0
 private static void lUpdateAttachmentPoints(DesignObject dobj, DesignElement delem)
 {
     if (delem.AttachmentPoint != null)
     {
         if (delem.AttachmentPoint.Attachment == null)
         {
             delem.AttachmentPoint.Attachment = dobj.GetDesignElementByName(delem.AttachmentPoint.AttachmentName);
             lUpdateAttachmentPoints(dobj, delem.AttachmentPoint.Attachment);
             delem.UpdatePoints();
         }
     }
 }
示例#6
0
        private void lDesignLoad()
        {
            bool uiupdate = lChangingFromControl;

            lChangingFromControl  = true;
            lTSDesignFileCbx.Text = "";
            lChangingFromControl  = uiupdate;

            if ((lDesignFilePath.Length > 0) && File.Exists(lDesignFilePath))
            {
                lDesignObject = DesignObject.LoadDesignObject(lDesignFilePath);

                if (lDesignObject != null)
                {
                    lDesignCtrl.SetDesignObject(lDesignObject);
                    lDesignCtrl.ShowAxes = lAppPrefs.ShowAxes;
                    lDesignCtrl.ResetPosition();

                    lTSThetaLbl.Text   = lDesignCtrl.Theta.ToString("0.000");
                    lTSPhiLbl.Text     = lDesignCtrl.Phi.ToString("0.000");
                    lTSScalingCbx.Text = lDesignCtrl.Scaling.ToString("0.000");

                    lPartsLvw.BeginUpdate();
                    lPartsLvw.Items.Clear();

                    lPrimaryAttachmentCbx.BeginUpdate();
                    lPrimaryAttachmentCbx.Items.Clear();

                    // fill in parts list view
                    if (lDesignObject.Elements.Count > 0)
                    {
                        foreach (DesignElement tmpelem in lDesignObject.Elements)
                        {
                            DesignElementRect tmpelemr = (DesignElementRect)tmpelem;
                            lAddDesignElement(tmpelemr);
                        }
                    }

                    lPrimaryAttachmentCbx.EndUpdate();

                    lPartsLvw.EndUpdate();

                    StringHandler.AddStringToStartOfList(lAppPrefs.LastFiles, lDesignFilePath, 10);
                    lPopulateLastFilesListFromPrefs();

                    lChangingFromControl  = true;
                    lTSDesignFileCbx.Text = Path.GetFileName(lDesignFilePath);
                    lChangingFromControl  = uiupdate;
                }
            }
        }
示例#7
0
 public GraphicsElementGeometric3D(DesignObject design, string element, Graphics gfx, int width, int height, int offsetx, int offsety, double phi, double theta, bool showaxes, bool showlabels)
 {
     lInitializeVariables();
     Design         = design;
     lSingleElement = element;
     Width          = width;
     Height         = height;
     OffsetX        = offsetx;
     OffsetY        = offsety;
     lPhi           = phi;
     lTheta         = theta;
     lShowAxes      = showaxes;
     lShowLabels    = showlabels;
     ScaleToElementSize(gfx);
 }
示例#8
0
 public GraphicsElementGeometric3D(DesignObject design)
 {
     lInitializeVariables();
     Design = design;
 }
示例#9
0
 public void SetDesignObject(DesignObject dobj)
 {
     lDOGraphics.Design = dobj;
     Invalidate();
 }
示例#10
0
 public void SetDesignObject(DesignObject design)
 {
     lDesign = design;
     UpdateDocument();
 }
示例#11
0
 public void SetDesignObject(DesignObject designobject)
 {
     lDesignObject = designobject;
     lDesignOutputCtrl.SetDesignObject(designobject);
 }
示例#12
0
        public static DesignObject LoadDesignObject(string filename)
        {
            DesignObject dobj = null;

            string[] filetext = FileHandler.LoadFile(filename);

            if ((filetext != null) && (filetext.Length > 0))
            {
                char[]        eqdelim     = new char[] { '=' };
                char[]        commadelim  = new char[] { ',' };
                char[]        quotedelim  = new char[] { '"' };
                bool          error       = false;
                DesignElement currelement = null;
                int           posndx      = 0;

                dobj = new DesignObject();

                foreach (string fileline in filetext)
                {
                    string linetrim = fileline.Trim();

                    if ((linetrim.Length > 0) && (linetrim[0] != ';'))
                    {
                        string[] linetokens = linetrim.Split(eqdelim);

                        if (linetokens.Length == 2)
                        {
                            string varname = linetokens[0].ToLower();

                            if (currelement != null)
                            {
                                if (varname.Equals("name"))
                                {
                                    currelement.Name = linetokens[1];
                                }
                                else if (varname.Equals("objectend"))
                                {
                                    currelement = null;
                                }
                                else if (currelement.ElementType == DesignElement.ElementTypes.Rect)
                                {
                                    DesignElementRect rectelem = (DesignElementRect)currelement;

                                    if (varname.Equals("dimensions"))
                                    {
                                        string[] dimstrs = linetokens[1].Split(commadelim);

                                        if (dimstrs.Length == 3)
                                        {
                                            try
                                            {
                                                rectelem.DimensionX = Convert.ToDouble(dimstrs[0]);
                                                rectelem.DimensionY = Convert.ToDouble(dimstrs[1]);
                                                rectelem.DimensionZ = Convert.ToDouble(dimstrs[2]);
                                                rectelem.UpdatePoints();
                                            }
                                            catch (System.FormatException /*fex*/)
                                            {
                                                error = true;
                                            }
                                        }
                                        else
                                        {
                                            error = true;
                                        }
                                    }
                                    else if (varname.Equals("attach"))
                                    {
                                        string[] namestrs = linetokens[1].Split(quotedelim);

                                        if (namestrs.Length == 3)
                                        {
                                            string[] ownstrs  = namestrs[0].Split(commadelim, StringSplitOptions.RemoveEmptyEntries);
                                            string[] attrstrs = namestrs[2].Split(commadelim, StringSplitOptions.RemoveEmptyEntries);

                                            if ((ownstrs.Length == 3) && (attrstrs.Length == 3))
                                            {
                                                DesignAttachmentParameters dattach = new DesignAttachmentParameters(namestrs[1]);

                                                if (!dattach.SetAttachmentParametersFromStrings(attrstrs))
                                                {
                                                    error = true;
                                                }
                                                else if (!dattach.SetOwnParametersFromStrings(ownstrs))
                                                {
                                                    error = true;
                                                }

                                                rectelem.AttachmentPoint = dattach;
                                            }
                                            else
                                            {
                                                error = true;
                                            }
                                        }
                                        else
                                        {
                                            error = true;
                                        }
                                    }
                                    else if (varname.Equals("midpoint"))
                                    {
                                        string[] midstrs = linetokens[1].Split(commadelim);

                                        if (midstrs.Length == 3)
                                        {
                                            try
                                            {
                                                double midx = Convert.ToDouble(midstrs[0]);
                                                double midy = Convert.ToDouble(midstrs[1]);
                                                double midz = Convert.ToDouble(midstrs[2]);

                                                rectelem.Midpoint.SetPoint(midx, midy, midz);
                                                rectelem.UpdatePoints();
                                            }
                                            catch (System.FormatException /*fex*/)
                                            {
                                                error = true;
                                            }
                                        }
                                        else
                                        {
                                            error = true;
                                        }
                                    }
                                    else if (varname.Equals("position"))
                                    {
                                        string[] posstrs = linetokens[1].Split(commadelim);

                                        if ((posstrs.Length == 3) && (posndx < rectelem.Points.Length))
                                        {
                                            try
                                            {
                                                double midx = Convert.ToDouble(posstrs[0]);
                                                double midy = Convert.ToDouble(posstrs[1]);
                                                double midz = Convert.ToDouble(posstrs[2]);

                                                rectelem.Points[posndx].SetPoint(midx, midy, midz);
                                                posndx++;
                                            }
                                            catch (System.FormatException /*fex*/)
                                            {
                                                error = true;
                                            }
                                        }
                                        else
                                        {
                                            error = true;
                                        }
                                    }
                                    else
                                    {
                                        error = true;
                                    }
                                }
                                else
                                {
                                    error = true;
                                }
                            }
                            else if (varname.Equals("objectname"))
                            {
                                dobj.Name = linetokens[1];
                            }
                            else if (varname.Equals("measure"))
                            {
                                Units unitval;

                                if (Enum.TryParse(linetokens[1], true, out unitval) && Enum.IsDefined(typeof(Units), unitval))
                                {
                                    dobj.UnitType = unitval;
                                }
                                else
                                {
                                    error = true;
                                }
                            }
                            else if (varname.Equals("objectstart"))
                            {
                                if (currelement == null)
                                {
                                    DesignElement.ElementTypes etype;

                                    if (Enum.TryParse(linetokens[1], true, out etype) && Enum.IsDefined(typeof(DesignElement.ElementTypes), etype))
                                    {
                                        switch (etype)
                                        {
                                        case DesignElement.ElementTypes.Rect:
                                            currelement = new DesignElementRect();
                                            break;

                                        default:
                                            error = true;
                                            break;
                                        }

                                        if (currelement != null)
                                        {
                                            dobj.Elements.Add(currelement);
                                            posndx = 0;
                                        }
                                    }
                                    else
                                    {
                                        error = true;
                                    }
                                }
                                else
                                {
                                    error = true;
                                }
                            }
                        }
                        else
                        {
                            error = true;
                        }
                    }

                    if (error)
                    {
                        break;
                    }
                }

                if (error)
                {
                    dobj = null;
                }
                else
                {
                    // fill in any relative attachment point classes
                    if (dobj.Elements.Count > 0)
                    {
                        List <DesignElement> attelems = new List <DesignElement>();

                        // make a list of all elements that have a primary attachment
                        foreach (DesignElement tmpdelem in dobj.Elements)
                        {
                            lUpdateAttachmentPoints(dobj, tmpdelem);
                        }
                    }
                }
            }

            return(dobj);
        }