/// <summary> /// Initializes a new instance of the <see cref="PathOperation"/> class /// using the data read from persistent storage. /// </summary> /// <param name="editDeserializer">The mechanism for reading back content.</param> internal PathOperation(EditDeserializer editDeserializer) : base(editDeserializer) { //try //{ m_From = editDeserializer.ReadFeatureRef <PointFeature>(DataField.From); m_To = editDeserializer.ReadFeatureRef <PointFeature>(DataField.To); m_EntryString = editDeserializer.ReadString(DataField.EntryString); m_DefaultEntryUnit = editDeserializer.ReadDistanceUnit(DataField.DefaultEntryUnit); Leg[] legs = PathParser.CreateLegs(m_EntryString, m_DefaultEntryUnit); PrepareLegs(this.EditSequence, legs); m_Legs = new List <Leg>(legs); Project p = editDeserializer.Project; IEntity pointType = editDeserializer.ReadEntity(DataField.PointType); IEntity lineType = editDeserializer.ReadEntity(DataField.LineType); // Pick up any alternate faces (these may be defined ONLY when dealing with // data files that were derived from old CEdit files). The deserializaing // constructor will connect the alternate faces to the legs we've just // created. if (editDeserializer.IsNextField(DataField.AlternateFaces)) { editDeserializer.ReadPersistentArray <LegFace>(DataField.AlternateFaces); } // Create stubs for everything that we could conceivably create (including // any alternate faces). FeatureStub[] stubs = CreateStubs(p, pointType, lineType); var result = new DeserializationFactory(this, stubs); result.PointType = pointType; result.LineType = lineType; // Create feature objects ProcessFeatures(result); // Apply any IDs if (editDeserializer.IsNextField(DataField.Ids)) { editDeserializer.ReadIdMappings(DataField.Ids); } //} //catch (Exception ex) //{ // throw ex; //} }
private void previewTimer_Tick(object sender, EventArgs e) { // Stop the timer - the user has to make a further change to the entered path // in order to rework the auto-preview previewTimer.Stop(); okButton.Enabled = false; // If there's any problem working out the preview, we won't draw the path m_DrawPath = false; try { // Don't use ParsePath, as that may display a message box string str = GetEnteredPath(); m_Items = PathParser.GetPathItems(str, EditingController.Current.EntryUnit); if (m_Items.Length > 0) { Leg[] legs = PathParser.CreateLegs(m_Items); m_PathData = new PathInfo(m_From, m_To, legs); double prec = m_PathData.Precision; if (Math.Abs(prec) < MathConstants.TINY) { previewLabel.Text = "Exact fit"; } else { previewLabel.Text = String.Format("1:{0}", (uint)prec); } m_DrawPath = true; m_Command.ErasePainting(); okButton.Enabled = true; } } // Indicate that the path cannot be parsed (in the case of an ApplicationException, assume // the exception message is informational). catch (ApplicationException ae) { previewLabel.Text = ae.Message; } catch (Exception) { previewLabel.Text = "Cannot generate preview"; } }
/// <summary> /// Initializes a new instance of the <see cref="PathOperation"/> class /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="entryString"></param> internal PathOperation(PointFeature from, PointFeature to, string entryString, DistanceUnit defaultEntryUnit) : base() { m_From = from; m_To = to; m_EntryString = entryString; m_DefaultEntryUnit = defaultEntryUnit; Leg[] legs = PathParser.CreateLegs(m_EntryString, m_DefaultEntryUnit); uint lastId = PrepareLegs(this.EditSequence, legs); EditingController.Current.Project.SetLastItem(lastId); m_Legs = new List <Leg>(legs); }
/// <summary> /// Initializes a new instance of the <see cref="UpdatePathForm"/> class. /// </summary> /// <param name="update">The update command that's driving things (not null).</param> /// <exception cref="ArgumentNullException">If the supplied update command is null.</exception> internal UpdatePathForm(UpdateUI update) { InitializeComponent(); Owner = EditingController.Current.MainForm; if (update == null) { throw new ArgumentNullException(); } m_UpdCmd = update; m_CurFaceIndex = -1; m_pop = null; // Get the object that was selected for update. m_pop = (m_UpdCmd.GetOp() as PathOperation); if (m_pop == null) { throw new ArgumentException("Cannot obtain original connection path for update"); } // Get a working copy of the connection path legs // TODO - This will not be suitable in a situation where staggered legs have been created Leg[] legs = PathParser.CreateLegs(m_pop.EntryString, m_pop.EntryUnit); m_Faces = new List <LegFace>(); foreach (Leg leg in legs) { m_Faces.Add(leg.PrimaryFace); if (leg.AlternateFace != null) { m_Faces.Add(leg.AlternateFace); } } m_Edits = new PathEditor(legs); }