Example #1
0
    static public ShapeTemplate GetShapeTemplate(ModelStencil stencil)
    {
      int i;

      if (stencil != null)
      {
        ElementTemplate[] elementTemplate = new ElementTemplate[stencil.Elements.Count];
        i = 0;

        foreach (Element element in stencil.Elements)
        {
          elementTemplate[i] = Element(element);
          i++;
        }

        ElementTemplate[] decorationTemplate = new ElementTemplate[stencil.Decorations.Count];
        i = 0;

        foreach (Element decoration in stencil.Decorations)
        {
          decorationTemplate[i] = Element(decoration);
          i++;
        }

        return (new ShapeTemplate(elementTemplate, decorationTemplate, null, stencil.FillMode, stencil.Tag));
      }

      else
        return null;
    }
Example #2
0
        private ShapeTemplate GetShapeTemplate(SysCAD.Protocol.ModelStencil stencil)
        {
            int i;

            if (stencil != null)
            {
                ElementTemplate[] elementTemplate = new ElementTemplate[stencil.Elements.Count];
                i = 0;

                foreach (Element element in stencil.Elements)
                {
                    elementTemplate[i] = Element(element);
                    i++;
                }

                ElementTemplate[] decorationTemplate = new ElementTemplate[stencil.Decorations.Count];
                i = 0;

                foreach (Element decoration in stencil.Decorations)
                {
                    decorationTemplate[i] = Element(decoration);
                    i++;
                }

                return(new ShapeTemplate(elementTemplate, decorationTemplate, null, System.Drawing.Drawing2D.FillMode.Alternate, stencil.Tag));
            }

            else
            {
                return(null);
            }
        }
Example #3
0
        public object SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
        {
            ModelStencil modelStencil = (ModelStencil)obj;

            try
            {
                modelStencil.Groups = (ArrayList)info.GetValue("groups", typeof(ArrayList));
            }
            catch
            {
                modelStencil.Groups = new ArrayList();
                modelStencil.Groups.Add((String)info.GetValue("groupName", typeof(String)));
            }
            modelStencil.Anchors     = (ArrayList)info.GetValue("anchors", typeof(ArrayList));
            modelStencil.Decorations = (ArrayList)info.GetValue("decorations", typeof(ArrayList));
            modelStencil.Elements    = (ArrayList)info.GetValue("elements", typeof(ArrayList));
            modelStencil.Tag         = (String)info.GetValue("tag", typeof(String));
            try
            {
                modelStencil.DefaultSize = (Size)info.GetValue("defaultSize", typeof(String));
            }
            catch
            {
                modelStencil.DefaultSize = new Size(10.0, 10.0);
            }
            return(modelStencil);
        }
Example #4
0
        public static void Serialize(string path, ModelStencil modelStencil)
        {
            SoapFormatter sf           = new SoapFormatter();
            StreamWriter  streamWriter = new StreamWriter(path);
            Stream        stream       = streamWriter.BaseStream;

            SurrogateSelector ss = new SurrogateSelector();

            ss.AddSurrogate(typeof(ModelStencil), new StreamingContext(StreamingContextStates.All), new ModelStencilSerializationSurrogate());
            sf.SurrogateSelector = ss;

            sf.Serialize(stream, modelStencil);
            stream.Close();
        }
Example #5
0
  void TrimAnchorPoints(ModelStencil modelStencil)
  {
    ArrayList anchors = modelStencil.Anchors;
    ArrayList validAnchors = new ArrayList();
    for (int i=0; i<anchors.Count; i++)
    {
      Anchor anchor = (Anchor)(anchors[i]);
      if (ValidAnchor(anchor)) 
      {
        validAnchors.Add(anchor);
      }
    }

    modelStencil.Anchors = validAnchors;
  }
Example #6
0
        void TrimAnchorPoints(ModelStencil modelStencil)
        {
            ArrayList anchors      = modelStencil.Anchors;
            ArrayList validAnchors = new ArrayList();

            for (int i = 0; i < anchors.Count; i++)
            {
                Anchor anchor = (Anchor)(anchors[i]);
                if (ValidAnchor(anchor))
                {
                    validAnchors.Add(anchor);
                }
            }

            modelStencil.Anchors = validAnchors;
        }
Example #7
0
        public void GetObjectData(Object obj, SerializationInfo info, StreamingContext context)
        {
            ModelStencil modelStencil = (ModelStencil)obj;

            info.AddValue("groups", modelStencil.Groups);
            info.AddValue("anchors", modelStencil.Anchors);
            info.AddValue("decorations", modelStencil.Decorations);
            info.AddValue("elements", modelStencil.Elements);
            info.AddValue("tag", modelStencil.Tag);
            if (modelStencil.DefaultSize != null)
            {
                info.AddValue("defaultSize", modelStencil.DefaultSize);
            }
            else
            {
                info.AddValue("defaultSize", new Size(10.0, 10.0));
            }
        }
Example #8
0
    public static void Serialize(string path, ModelStencil modelStencil)
    {
      SoapFormatter sf = new SoapFormatter();
      StreamWriter streamWriter = new StreamWriter(path);
      Stream stream = streamWriter.BaseStream;

      SurrogateSelector ss = new SurrogateSelector();
      ss.AddSurrogate(typeof(ModelStencil), new StreamingContext(StreamingContextStates.All), new ModelStencilSerializationSurrogate());
      sf.SurrogateSelector = ss;

      sf.Serialize(stream, modelStencil);
      stream.Close();
    }
Example #9
0
 bool ConfirmModelStencil(ModelStencil modelstencil)
 {
   // TODO: check whether this stencil is to be included in the project.
   return true;
 }
Example #10
0
 bool ConfirmModelStencil(ModelStencil modelstencil)
 {
     // TODO: check whether this stencil is to be included in the project.
     return(true);
 }
Example #11
0
    private void SetStencil(ModelStencil modelStencil)
    {
      toolStripStatusLabel1.Text = "";

      modelBox.Shape = GetShapeTemplate(modelStencil);
      modelBox.Visible = true;

      foreach (Preview preview in previews)
        preview.SetStencil(GetShapeTemplate(modelStencil));

      flowChart1.Enabled = true;
    }
Example #12
0
    private void openToolStripMenuItem_Click(object sender, EventArgs e)
    {
      OpenFileDialog openFileDialog = new OpenFileDialog();
      openFileDialog.AddExtension = true;
      openFileDialog.CheckFileExists = true;
      openFileDialog.CheckPathExists = true;
      openFileDialog.DefaultExt = "ModelStencil";
      openFileDialog.Filter = "ModelStencils|*.ModelStencil";
      openFileDialog.Multiselect = false;
      openFileDialog.ShowHelp = false;
      openFileDialog.ShowReadOnly = false;
      openFileDialog.SupportMultiDottedExtensions = true;
      openFileDialog.FileName = System.IO.Path.GetFileName(path);
      openFileDialog.Title = "Open ModelStencil";

      openFileDialog.InitialDirectory = System.IO.Path.GetFullPath(path);

      if (openFileDialog.ShowDialog(this) == DialogResult.OK)
      {
        modelStencil = OpenModelStencil(openFileDialog.FileName);

        editPropertiesToolStripMenuItem.Enabled = true;
        saveToolStripMenuItem.Enabled = true;

        ResetFlowChart(true);
        SetStencil(modelStencil);
        SetControls(modelStencil);
      }
      path = openFileDialog.FileName;
    }
Example #13
0
    private void UpdateStencil(ModelStencil modelStencil)
    {
      double minX = float.MaxValue;
      double maxX = float.MinValue;
      double minY = float.MaxValue;
      double maxY = float.MinValue;

      UpdateStencil(modelStencil.Elements, ref minX, ref minY, ref maxX, ref maxY);
      UpdateStencil(modelStencil.Decorations, ref minX, ref minY, ref maxX, ref maxY);

      double anchorMinX = minX;
      double anchorMaxX = maxX;
      double anchorMinY = minY;
      double anchorMaxY = maxY;

      UpdateStencil(modelStencil.Anchors, ref anchorMinX, ref anchorMinY, ref anchorMaxX, ref anchorMaxY);

      ScaleStencil(modelStencil.Elements, minX, minY, maxX, maxY);
      ScaleStencil(modelStencil.Decorations, minX, minY, maxX, maxY);

      ScaleStencil(modelStencil.Anchors, minX, minY, maxX, maxY);

      double scale = 1000.0F / Math.Max((maxX - minX), (maxY - minY));

      SysCAD.Protocol.Rectangle rect = new SysCAD.Protocol.Rectangle(minX * scale, minY * scale, (maxX - minX) * scale, (maxY - minY) * scale);

      box2.BoundingRect = rect;
      {
        int i;

        ModelStencil stencil = modelStencil;
        bool mirrorX = false;
        bool mirrorY = false;

        ElementTemplate[] elementTemplate = new ElementTemplate[stencil.Elements.Count];
        i = 0;
        foreach (Element element in stencil.Elements)
        {
          if (element is Arc)
          {
            Arc arc = element as Arc;
            elementTemplate[i] = new ArcTemplate((float)arc.x, (float)arc.y, (float)arc.w, (float)arc.h, (float)arc.a, (float)arc.s);
          }
          if (element is Line)
          {
            Line line = element as Line;
            double x1, y1, x2, y2;

            if (mirrorX)
              x1 = 100.0 - line.x1;
            else
              x1 = line.x1;

            if (mirrorY)
              y1 = 100.0 - line.y1;
            else
              y1 = line.y1;

            if (mirrorX)
              x2 = 100.0F - line.x2;
            else
              x2 = line.x2;

            if (mirrorY)
              y2 = 100.0 - line.y2;
            else
              y2 = line.y2;

            elementTemplate[i] = new LineTemplate((float)x1, (float)y1, (float)x2, (float)y2);
          }
          if (element is Bezier)
          {
            Bezier bezier = element as Bezier;
            double x1, y1, x2, y2, x3, y3, x4, y4;

            if (mirrorX)
              x1 = 100.0 - bezier.x1;
            else
              x1 = bezier.x1;

            if (mirrorY)
              y1 = 100.0 - bezier.y1;
            else
              y1 = bezier.y1;

            if (mirrorX)
              x2 = 100.0 - bezier.x2;
            else
              x2 = bezier.x2;

            if (mirrorY)
              y2 = 100.0 - bezier.y2;
            else
              y2 = bezier.y2;

            if (mirrorX)
              x3 = 100.0 - bezier.x3;
            else
              x3 = bezier.x3;

            if (mirrorY)
              y3 = 100.0 - bezier.y3;
            else
              y3 = bezier.y3;

            if (mirrorX)
              x4 = 100.0 - bezier.x4;
            else
              x4 = bezier.x4;

            if (mirrorY)
              y4 = 100.0 - bezier.y4;
            else
              y4 = bezier.y4;

            elementTemplate[i] = new BezierTemplate((float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3, (float)x4, (float)y4);
          }
          i++;
        }

        ElementTemplate[] decorationTemplate = new ElementTemplate[stencil.Decorations.Count];
        i = 0;
        foreach (Element decoration in stencil.Decorations)
        {
          if (decoration is Arc)
          {
            Arc arc = decoration as Arc;
            decorationTemplate[i] = new ArcTemplate((float)arc.x, (float)arc.y, (float)arc.w, (float)arc.h, (float)arc.a, (float)arc.s);
          }
          if (decoration is Line)
          {
            Line line = decoration as Line;
            double x1, y1, x2, y2;

            if (mirrorX)
              x1 = 100.0 - line.x1;
            else
              x1 = line.x1;

            if (mirrorY)
              y1 = 100.0 - line.y1;
            else
              y1 = line.y1;

            if (mirrorX)
              x2 = 100.0 - line.x2;
            else
              x2 = line.x2;

            if (mirrorY)
              y2 = 100.0 - line.y2;
            else
              y2 = line.y2;

            decorationTemplate[i] = new LineTemplate((float)x1, (float)y1, (float)x2, (float)y2);
          }
          if (decoration is Bezier)
          {
            Bezier bezier = decoration as Bezier;
            double x1, y1, x2, y2, x3, y3, x4, y4;

            if (mirrorX)
              x1 = 100.0 - bezier.x1;
            else
              x1 = bezier.x1;

            if (mirrorY)
              y1 = 100.0 - bezier.y1;
            else
              y1 = bezier.y1;

            if (mirrorX)
              x2 = 100.0 - bezier.x2;
            else
              x2 = bezier.x2;

            if (mirrorY)
              y2 = 100.0 - bezier.y2;
            else
              y2 = bezier.y2;

            if (mirrorX)
              x3 = 100.0 - bezier.x3;
            else
              x3 = bezier.x3;

            if (mirrorY)
              y3 = 100.0 - bezier.y3;
            else
              y3 = bezier.y3;

            if (mirrorX)
              x4 = 100.0 - bezier.x4;
            else
              x4 = bezier.x4;

            if (mirrorY)
              y4 = 100.0 - bezier.y4;
            else
              y4 = bezier.y4;

            decorationTemplate[i] = new BezierTemplate((float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3, (float)x4, (float)y4);
          }
          i++;
        }

        box2.Shape = (new ShapeTemplate(elementTemplate, decorationTemplate, null, stencil.FillMode, stencil.Tag));
      }


      SysCAD.Protocol.Rectangle anchorRect = new SysCAD.Protocol.Rectangle(anchorMinX * scale, anchorMinY * scale, (anchorMaxX - anchorMinX) * scale, (anchorMaxY - anchorMinY) * scale);

      foreach (Box box in anchorPointBoxes)
        flowChart2.DeleteObject(box);

      anchorPointBoxes.Clear();

      foreach (Anchor anchor in modelStencil.Anchors)
      {
        RectangleF displayRect = new RectangleF((float)(((anchor.Positions[0] as SysCAD.Protocol.Point).X / 100.0F * (maxX - minX) + minX) * scale),
                                                (float)(((anchor.Positions[0] as SysCAD.Protocol.Point).Y / 100.0F * (maxY - minY) + minY) * scale),
                                                0.0F, 0.0F);
        displayRect.Inflate(20.0F, 20.0F);
        Box box = flowChart2.CreateBox(displayRect.X, displayRect.Y, displayRect.Width, displayRect.Height);
        anchorPointBoxes.Add(box);
        box.Style = BoxStyle.Ellipse;
        box.ZTop();
        box.FillColor = Color.Red;
        box.FillColor = Color.FromArgb(100, box.FillColor);
      }

      anchorRect.Inflate((maxX - minX) * scale / 10.0F, (maxY - minY) * scale / 10.0F);
      flowChart2.DocExtents = anchorRect;
      flowChart2.ZoomToRect(anchorRect);
    }
Example #14
0
    static public ShapeTemplate GetShapeTemplate(ModelStencil stencil, bool mirrorX, bool mirrorY)
    {
      int i;

      if (stencil != null)
      {
        ElementTemplate[] elementTemplate = new ElementTemplate[stencil.Elements.Count];
        i = 0;

        foreach (Element element in stencil.Elements)
        {
          elementTemplate[i] = MirroredElement(element, mirrorX, mirrorY);
          i++;
        }

        ElementTemplate[] decorationTemplate = new ElementTemplate[stencil.Decorations.Count];
        i = 0;

        foreach (Element decoration in stencil.Decorations)
        {
          decorationTemplate[i] = MirroredElement(decoration, mirrorX, mirrorY);
          i++;
        }

        return (new ShapeTemplate(elementTemplate, decorationTemplate, null, FillMode.Alternate, stencil.Tag));
      }

      else
        return null;
    }
Example #15
0
    static public AnchorPattern GetAnchorPattern(ModelStencil modelStencil, EditorNode item)
    {
      AnchorPointCollection anchorPointCollection = new AnchorPointCollection();

      if ((modelStencil != null) && (modelStencil.Anchors != null))
      {
        item.anchorIntToTag.Clear();
        item.anchorTagToInt.Clear();
        int anchorInt = 0;

        foreach (Anchor anchor in modelStencil.Anchors)
        {
          int anchorPtInt = 0;
          foreach (SysCAD.Protocol.Point point in anchor.Positions)
          {
            Double x = point.X;
            if (item.MirrorX)
              x = 100.0 - x;
            Double y = point.Y;
            if (item.MirrorY)
              y = 100.0 - y;

            MarkStyle markStyle = MarkStyle.Circle; // Use circle in any other case.
            switch (anchor.Look)
            {
              case 0: markStyle = MarkStyle.Circle; break;
              case 1: markStyle = MarkStyle.Cross; break;
              case 2: markStyle = MarkStyle.Rectangle; break;
              case 3: markStyle = MarkStyle.X; break;
            }
            AnchorPoint anchorPoint = new AnchorPoint((short)x, (short)y, true, true, markStyle, System.Drawing.Color.Green);
            anchorPoint.Tag = anchor;
            anchorPointCollection.Add(anchorPoint);

            item.anchorIntToTag.Add(anchorInt, anchor.Tag + anchorPtInt.ToString());
            item.anchorTagToInt.Add(anchor.Tag + anchorPtInt.ToString(), anchorInt);

            anchorInt++;
            anchorPtInt++;
          }
        }
      }
      return new AnchorPattern(anchorPointCollection);
    }
Example #16
0
    private static void ProcessModelStencil(String upgradeSymbolPath, String path)
    {
      ModelStencil modelStencil;
      try
      {
        modelStencil = ModelStencil.Deserialize(upgradeSymbolPath + "\\" + Path.GetFileNameWithoutExtension(path).Split("().".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[1].Replace('_', ' ') + ".ModelStencil");
      }
      catch
      {
        modelStencil = new ModelStencil();

        modelStencil.Elements = new ArrayList();
        modelStencil.Decorations = new ArrayList();
        modelStencil.DefaultSize = new Size(0.0, 0.0);
        modelStencil.Groups = new ArrayList();
        modelStencil.Anchors = new ArrayList();

        Double xMin = 0.0;
        Double xMax = 0.0;
        Double yMin = 0.0;
        Double yMax = 0.0;

        // Extract min/max's for scaling on-the-fly.
        foreach (String line in (new StreamReader(path)).ReadToEnd().Split("\n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
        {
          string[] words = line.Split(" ,".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
          if (words.Length > 0)
          {
            switch (words[0])
            {
              case "XMin":
                xMin = Double.Parse(words[1]);
                break;

              case "XMax":
                xMax = Double.Parse(words[1]);
                break;

              case "YMin":
                yMax = -Double.Parse(words[1]);
                break;

              case "YMax":
                yMin = -Double.Parse(words[1]);
                break;

              case "Group":
                modelStencil.Groups.Add(words[1]);
                break;

              case "Symbol":
                modelStencil.Tag = words[1];
                break;
            }
          }
        }

        if (File.Exists(Path.GetDirectoryName(path) + "\\" + modelStencil.Tag.Replace('*', '_') + ".TxTMdl"))
        {

          // Populate graphicStencil.
          Point oldPt = new Point(Double.NaN, Double.NaN);
          foreach (String line in (new StreamReader(path)).ReadToEnd().Split("\n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
          {
            string[] words = line.Split(" ,".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (words.Length > 0)
            {
              ArrayList pCurvePts = new ArrayList();
              switch (words[0])
              {
                case "MDrw_Poly":
                  int i = 1;
                  while (i + 3 < words.Length)
                  {
                    modelStencil.Decorations.Add(
                      new Line(
                        (Double.Parse(words[i]) - xMin) / (xMax - xMin) * 100.0,
                        (-Double.Parse(words[i + 1]) - yMin) / (yMax - yMin) * 100.0,
                        (Double.Parse(words[i + 2]) - xMin) / (xMax - xMin) * 100.0,
                        (-Double.Parse(words[i + 3]) - yMin) / (yMax - yMin) * 100.0
                      )
                    );
                    i += 2;
                  }
                  break;

                case "MDrw_Arc":
                  {
                    Double xc = Double.Parse(words[1]);
                    Double yc = Double.Parse(words[2]);
                    Double r = Double.Parse(words[3]);
                    Double s = Double.Parse(words[4]);
                    Double x1 = Double.Parse(words[5]);
                    Double y1 = Double.Parse(words[6]);
                    Double a = Math.Atan2(y1 - yc, x1 - xc);


                    if (s > 1.95 * Math.PI)
                    {
                      modelStencil.Decorations.Add(
                        new Arc(
                          ((xc - r) - xMin) / (xMax - xMin) * 100.0,
                          ((-yc - r) - yMin) / (yMax - yMin) * 100.0,
                          (2.0 * r) / (xMax - xMin) * 100.0,
                          (2.0 * r) / (yMax - yMin) * 100.0,
                          0.0,
                          360.0
                        )
                      );
                    }
                    else
                    {
                      Bezier bezier = new Bezier();
                      bezier.x1 = x1;
                      bezier.y1 = y1;
                      bezier.x2 = xc + r * Math.Cos(a + s / 3.0);
                      bezier.y2 = yc + r * Math.Sin(a + s / 3.0);
                      bezier.x3 = xc + r * Math.Cos(a + 2.0 * s / 3.0);
                      bezier.y3 = yc + r * Math.Sin(a + 2.0 * s / 3.0);
                      bezier.x4 = xc + r * Math.Cos(a + s);
                      bezier.y4 = yc + r * Math.Sin(a + s);

                      bezier.x1 = (bezier.x1 - xMin) / (xMax - xMin) * 100.0;
                      bezier.y1 = (-bezier.y1 - yMin) / (yMax - yMin) * 100.0;
                      bezier.x2 = (bezier.x2 - xMin) / (xMax - xMin) * 100.0;
                      bezier.y2 = (-bezier.y2 - yMin) / (yMax - yMin) * 100.0;
                      bezier.x3 = (bezier.x3 - xMin) / (xMax - xMin) * 100.0;
                      bezier.y3 = (-bezier.y3 - yMin) / (yMax - yMin) * 100.0;
                      bezier.x4 = (bezier.x4 - xMin) / (xMax - xMin) * 100.0;
                      bezier.y4 = (-bezier.y4 - yMin) / (yMax - yMin) * 100.0;

                      modelStencil.Decorations.Add(bezier);
                    }
                  }
                  break;

                case "MDrw_Arc3":
                  modelStencil.Decorations.Add(
                    Arc3(
                    Double.Parse(words[1]), -Double.Parse(words[2]),
                    Double.Parse(words[3]), -Double.Parse(words[4]),
                    Double.Parse(words[5]), -Double.Parse(words[6]),
                    xMin, xMax, yMin, yMax)
                  );
                  break;

                case "MDrw_PCurve":
                  switch (words[1])
                  {
                    case "S":
                      pCurvePts.Clear();
                      oldPt = new Point(Double.Parse(words[3]), -Double.Parse(words[4]));
                      break;

                    case "P":
                      modelStencil.Decorations.Add(
                        new Line(
                          (oldPt.X - xMin) / (xMax - xMin) * 100.0,
                          (oldPt.Y - yMin) / (yMax - yMin) * 100.0,
                          (Double.Parse(words[3]) - xMin) / (xMax - xMin) * 100.0,
                          (-Double.Parse(words[4]) - yMin) / (yMax - yMin) * 100.0
                        )
                      );
                      oldPt = new Point(Double.Parse(words[3]), -Double.Parse(words[4]));
                      break;

                    case "A":
                      Double x2 = Double.Parse(words[3]);
                      Double y2 = -Double.Parse(words[4]);
                      Double xc = Double.Parse(words[5]);
                      Double yc = -Double.Parse(words[6]);
                      Double r = Double.Parse(words[7]);


                      modelStencil.Decorations.Add(
                        Arc3(
                        oldPt.X, oldPt.Y,
                        x2, y2,
                        xc, yc, r,
                        xMin, xMax, yMin, yMax)
                      );
                      break;

                    default:
                      Message("Unknown MDrw_PCurve option", upgradeSymbolPath, path + "\\" + Path.GetFileNameWithoutExtension(path).Split("().".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[1] + ".GraphicStencil", line);
                      break;
                  }
                  break;

                case "Width":
                  modelStencil.DefaultSize.Width = Double.Parse(words[1]);
                  break;

                case "Height":
                  modelStencil.DefaultSize.Height = Double.Parse(words[1]);
                  break;

                // Already handled.
                case "XMin":
                case "XMax":
                case "YMin":
                case "YMax":
                case "Group":
                  break;

                // Ignore.
                case "Insert":
                case "TextArea":
                case "Symbol":
                case "MDrw_TagPos":
                case "MDrw_End":
                case "InsertX":
                case "InsertY":
                  break;

                default:
                  Message("Unknown command", upgradeSymbolPath, path + "\\" + Path.GetFileNameWithoutExtension(path).Split("().".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[1] + ".GraphicStencil", line);
                  break;
              }
            }
          }

          foreach (String line in (new StreamReader(Path.GetDirectoryName(path) + "\\" + modelStencil.Tag.Replace('*', '_') + ".TxTMdl")).ReadToEnd().Split("\n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
          {
            string[] words = line.Split(" ,".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (words.Length > 0)
            {
              switch (words[0])
              {
                case "XMin":
                  xMin = Double.Parse(words[1]);
                  break;

                case "XMax":
                  xMax = Double.Parse(words[1]);
                  break;

                case "YMin":
                  yMax = -Double.Parse(words[1]);
                  break;

                case "YMax":
                  yMin = -Double.Parse(words[1]);
                  break;

                case "Group":
                  modelStencil.Groups.Add(words[1]);
                  break;

                case "Symbol":
                  modelStencil.Tag = words[1];
                  break;
              }
            }
          }

          // Populate graphicStencil.
          oldPt = new Point(Double.NaN, Double.NaN);
          foreach (String line in (new StreamReader(Path.GetDirectoryName(path) + "\\" + modelStencil.Tag + ".TxTMdl")).ReadToEnd().Split("\n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
          {
            if (!line.StartsWith(";"))
            {
              string[] words = line.Split(" ,".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
              if (words.Length > 0)
              {
                switch (words[0])
                {
                  case "Port0":
                  case "Port1":
                  case "Port2":
                  case "Port3":
                  case "Port4":
                  case "Port5":
                  case "Port6":
                  case "Port7":
                  case "Port8":
                  case "Port9":
                  case "Port10":
                  case "Port11":
                  case "Port12":
                  case "Port13":
                  case "Port14":
                  case "Port15":
                  case "Port16":
                  case "Port17":
                  case "Port18":
                  case "Port19":
                  case "Port20":
                  case "Port21":
                  case "Port22":
                  case "Port23":
                  case "Port24":
                  case "Port25":
                  case "Port26":
                  case "Port27":
                  case "Port28":
                  case "Port29":
                  case "Port30":
                  case "Port31":
                  case "Port32":
                  case "Port33":
                  case "Port34":
                  case "Port35":
                  case "Port36":
                  case "Port37":
                  case "Port38":
                  case "Port39":
                  case "Port40":
                  case "Port41":
                  case "Port42":
                  case "Port43":
                  case "Port44":
                  case "Port45":
                  case "Port46":
                  case "Port47":
                  case "Port48":
                  case "Port49":
                  case "Port50":
                  case "Port51":
                  case "Port52":
                  case "Port53":
                  case "Port54":
                  case "Port55":
                  case "Port56":
                  case "Port57":
                  case "Port58":
                  case "Port59":
                    {
                      //;Port,  Id, Name, Dirn, Type, IORqd, IOMax, Hgt,  Desc
                      // Port0, 0,  In,   0x30, 0x80, 1,     1,     0.00, Input
                      int id = -1;
                      string name = "";
                      int direction = -1;
                      int type = -1;
                      int ioRequired = -1;
                      int ioMax = -1;
                      double height = -1.0;
                      string description = "";

                      id = int.Parse(words[1]);
                      name = words[2];
                      direction = int.Parse(words[3].Remove(0, 2), NumberStyles.HexNumber);
                      type = int.Parse(words[4].Remove(0, 2), NumberStyles.HexNumber);
                      ioRequired = int.Parse(words[5]);
                      ioMax = int.Parse(words[6]);
                      height = double.Parse(words[7]);
                      description = "";
                      if (words.Length > 8)
                        description = words[8];
                      AnchorType anchorType = AnchorType.Process;
                      modelStencil.Anchors.Add(new Anchor(name, anchorType, 0));
                    }
                    break;

                  case "ClassName":
                  case "ClassId":
                  case "CategoryGrp":
                  case "CategoryMdl":
                  case "ProgID":
                  case "ShortDesc":
                  case "Desc":
                  case "Symbol":
                  case "Group":
                    break;

                  default:
                    Message("Unknown command", upgradeSymbolPath, path + "\\" + Path.GetFileNameWithoutExtension(path).Split("().".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[1] + ".GraphicStencil", line);
                    break;
                }
              }
            }
          }

          ModelStencil.Serialize(upgradeSymbolPath + "\\" + ((String)(modelStencil.Tag)).Replace('/', '_').ToLower().Replace(' ', '_') + ".ModelStencil", modelStencil);

          //Console.WriteLine(upgradeSymbolPath + "\\" + ((String)(graphicStencil.Tags[0])).Replace('/', '_').ToLower().Replace(' ', '_') + ".GraphicStencil");

          if (xMin == xMax)
            Message("Zero width", upgradeSymbolPath, path + "\\" + Path.GetFileNameWithoutExtension(path).Split("().".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[1] + ".GraphicStencil", "");

          if (yMin == yMax)
            Message("Zero height", upgradeSymbolPath, path + "\\" + Path.GetFileNameWithoutExtension(path).Split("().".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[1] + ".GraphicStencil", "");
        }
      }
    }
Example #17
0
 private void SaveModelStencil(string fullpath, ModelStencil modelStencil)
 {
   SoapFormatter sf = new SoapFormatter();
   StreamWriter streamWriter = new StreamWriter(fullpath);
   Stream stream = streamWriter.BaseStream;
   sf.Serialize(stream, modelStencil);
   stream.Close();
 }
Example #18
0
        public void Setup(string stencilPath, Config.AddProjectHandler addProject, Config.AddProjectAnywayHandler addProjectAnyway)
        {
            this.addProject       = addProject;
            this.addProjectAnyway = addProjectAnyway;

            {
                //int iStencil = 0;
                //LogNote("Srvr : 0 : ModelStencils:");
                String[] files = Directory.GetFiles(stencilPath, "*.modelstencil");
                for (int i = 0; i < files.GetLength(0); i++)
                {
                    String fullpath = files[i];

                    //try
                    //{
                    ModelStencil modelStencil = ModelStencil.Deserialize(fullpath);

                    if (ConfirmModelStencil(modelStencil))
                    {
                        TrimAnchorPoints(modelStencil);
                        ModelStencils.Add(modelStencil.Tag, modelStencil);
                    }

                    //Console.WriteLine("  {0}] {1}", iStencil++, Path.GetFileNameWithoutExtension(fullpath));
                    //LogNote("Srvr : 0 : " + iStencil++ + " : " + System.IO.Path.GetFileNameWithoutExtension(fullpath));
                    //}
                    //catch (Exception)
                    //{
                    //  int asdf = 0;
                    //  //Message("Error '" + e.Message + "' loading ModelStencil: " + fullpath, MessageType.Error);
                    //}
                }

                Console.WriteLine("\n");
            }

            {
                //int iStencil = 0;
                //LogNote("Srvr : 0 : GraphicStencils:");
                String[] files = Directory.GetFiles(stencilPath, "*.graphicstencil");
                for (int i = 0; i < files.GetLength(0); i++)
                {
                    String fullpath = files[i];

                    //try
                    //{
                    GraphicStencil graphicStencil = GraphicStencil.Deserialize(fullpath);

                    foreach (String tag in graphicStencil.Tags)
                    {
                        GraphicStencils.Add(tag, graphicStencil);
                    }
                    //}
                    //catch
                    //{
                    //  int adsf = 0;
                    //  //logNote("Config : Error loading GraphicStencil " + fullpath);
                    //}
                }
            }
        }
Example #19
0
    private void SetControls(ModelStencil modelStencil)
    {
      foreach (Element element in modelStencil.Decorations)
      {
        if (element is Line)
        {
          Line line = element as Line;
          Arrow arrow = flowChart1.CreateArrow(GridFix(line.pointF1), GridFix(line.pointF2));
          arrow.FrameColor = Color.LightSkyBlue;
          arrow.ZTop();
          arrow.Tag = line;
        }

        if (element is Bezier)
        {
          Bezier bezier = element as Bezier;
          Arrow arrow = flowChart1.CreateArrow(bezier.pointF1, bezier.pointF4);
          arrow.FrameColor = Color.LightSkyBlue;
          arrow.SegmentCount = 3;
          arrow.ControlPoints[0] = GridFix(bezier.pointF1);
          arrow.ControlPoints[1] = GridFix(bezier.pointF2);
          arrow.ControlPoints[2] = GridFix(bezier.pointF3);
          arrow.ControlPoints[3] = GridFix(bezier.pointF4);
          arrow.ZTop();
          arrow.Tag = bezier;
        }

        if (element is Arc)
        {
          Arc arc = element as Arc;
          Box box = flowChart1.CreateBox(GridFix(arc.x), GridFix(arc.y), (float)arc.w, (float)arc.h);
          box.Style = BoxStyle.Ellipse;
          box.FillColor = Color.Transparent;
          box.FrameColor = Color.LightSkyBlue;
          box.ZBottom();
          box.Tag = arc;
        }
      }

      foreach (Element element in modelStencil.Elements)
      {
        if (element is Line)
        {
          Line line = element as Line;
          Arrow arrow = flowChart1.CreateArrow(GridFix(line.pointF1), GridFix(line.pointF2));
          arrow.FrameColor = Color.LightGreen;
          arrow.ZTop();
          arrow.Tag = line;
        }

        if (element is Bezier)
        {
          Bezier bezier = element as Bezier;
          Arrow arrow = flowChart1.CreateArrow(bezier.pointF1, bezier.pointF4);
          arrow.FrameColor = Color.LightGreen;
          arrow.SegmentCount = 3;
          arrow.ControlPoints[0] = GridFix(bezier.pointF1);
          arrow.ControlPoints[1] = GridFix(bezier.pointF2);
          arrow.ControlPoints[2] = GridFix(bezier.pointF3);
          arrow.ControlPoints[3] = GridFix(bezier.pointF4);
          arrow.ZTop();
          arrow.Tag = bezier;
        }

        if (element is Arc)
        {
          Arc arc = element as Arc;
          Box box = flowChart1.CreateBox(GridFix(arc.x), GridFix(arc.y), (float)arc.w, (float)arc.h);
          box.Style = BoxStyle.Ellipse;
          box.FillColor = Color.Transparent;
          box.FrameColor = Color.LightGreen;
          box.ZBottom();
          box.Tag = arc;
        }
      }

      foreach (Anchor anchor in modelStencil.Anchors)
      {
        foreach (SysCAD.Protocol.Point point in anchor.Positions)
        {
          Box box = flowChart1.CreateBox(
            GridFix(point.X) - 1.0F, GridFix(point.Y) - 1.0F, 2.0F, 2.0F);
          box.Style = BoxStyle.Rhombus;
          box.FillColor = Color.LightSalmon;
          box.FrameColor = Color.Salmon;
          box.HandlesStyle = HandlesStyle.MoveOnly;
          box.ToolTip = anchor.Tag + " : " + anchor.Look;
          box.ZTop();
          box.Tag = point;
        }
      }
    }