private void ApplyNewConstraintValue() { double value; try { value = BooEval.GetDouble(valueTextBox.Text); } catch (FormatException) { NaroMessage.Show(ExtensionsResources.Invalid_number_format); return; } if (!AcceptZero() && value < 0.001) { NaroMessage.Show(ExtensionsResources.ConstraintShapeDialog_Value_Bigger_Than_Zero); return; } var constraintDesc = (ConstraintListItem)listConstraints.SelectedItem; constraintDesc.GenerateBuilder(); var builder = constraintDesc.Builder; builder[1].Real = value; builder.ExecuteFunction(); RefreshList(); }
/// <summary> /// Receives click events. Called at mouse down and at mouse up. /// </summary> /// <param name = "mouseData"></param> protected override void OnMouseClick3DAction(Mouse3DPosition mouseData) { //TODO: we have bogus logic that is possible to have enabled command line //We need to fix it if (_metaAction == null) { return; } if (!mouseData.MouseDown) { return; } try { if (Dependency.StepName == InterpreterNames.Reference) { if (Dependency.Steps[Dependency.StepIndex].Data == null) { ProposeSelectedReferenceShape(null); } } PushValue(mouseData); } catch (Exception ex) { NaroMessage.Show(@"Exception on mouse click: " + ex.Message); } }
private void ExecuteBooScript(string script) { var isScript = _isScriptCheckBox.IsChecked ?? false; var context = BooUtil.GetCompilerContext(script, isScript); foreach (var error in context.Errors) { NaroMessage.Show(error.ToString()); } if (context.Errors.Count != 0) { return; } var assembly = context.GeneratedAssembly; Ensure.IsNotNull(assembly); var currentGraph = GetCurrentActionGraph(_actionsGraph); if (!isScript) { BooUtil.ExecuteBooProgram("Script", context, currentGraph); } else { BooUtil.ExecuteBooScript("Script", context, currentGraph); currentGraph[InputNames.View].Send(NotificationNames.RefreshView); currentGraph[InputNames.UiElementsItem].Send(NotificationNames.RebuildTreeView); } }
private bool CopyModifiersToShape(Node sourceShape, Node destinationShape) { var root = Document.Root; var impactedValues = ComputeImpactedValues(sourceShape, root); if (impactedValues.Count != 0) { NaroMessage.Show("You should apply a list of tools without branches"); return(false); } if (_listTools.Count == 0) { NaroMessage.Show("No tool to apply!"); return(false); } foreach (var tool in _listTools) { var generatedTool = NodeUtils.ApplyToolOnOtherShape(Document, tool, destinationShape); if (!generatedTool.LastExecute) { NaroMessage.Show("Error on generating tool chain. Quitting..."); return(false); } destinationShape = generatedTool.Node; } return(true); }
internal static void Main(string[] args) { #if !DEBUG WpfSplash.Instance.Show(); #endif CoreGlobalPreferencesSingleton.Instance.StartTime = Environment.TickCount; XmlConfigurator.Configure(); DefaultInterpreters.Setup(); var app = new App(); NaroMessage.SetFactory(new MessageBoxMessage()); NaroStartInfo.Instance.Arguments = args; Application.EnableVisualStyles(); WindowsFormsHost.EnableWindowsFormsInterop(); Log.Info("-------------------------- Started " + NaroAppConstantNames.AppName + " " + NaroAppConstantNames.Version + " session ---------------------------"); var optionsPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\NaroCAD\options.nxml"; if (!File.Exists(optionsPath)) { File.Copy(Directory.GetCurrentDirectory() + @"\options.nxml", optionsPath); } AppDomain.CurrentDomain.UnhandledException += HandleException; var shellWindow = new ShellWindow(); shellWindow.SetActionGraph(); app.Run(shellWindow); File.Delete(NaroAppConstantNames.GuardFileName); //MemMapper.DisplayLeaks(); }
private bool SaveFileIfNeeded() { var shouldExit = false; var madeChanges = Document.HistoryCount > 0; if (madeChanges) { var result = NaroMessage.Show( "You made changes. Do you want to save them?", "NaroCAD", MessageBoxButtons.YesNoCancel); if (result == DialogResult.Cancel) { shouldExit = true; } if (result == DialogResult.Yes) { Inputs[InputNames.FileSaveDialog].Send(NotificationNames.SetFilter, FilterNaroXml); var dialogResult = Inputs[InputNames.FileSaveDialog].GetData(NotificationNames.ShowSaveAs).Get <DialogResult>(); if (dialogResult == DialogResult.OK) { var fileName = Inputs[InputNames.FileSaveDialog].GetData(NotificationNames.GetFile).Text; SaveCommonCodes.SaveToFile(fileName, Document); } } } return(shouldExit); }
public override void OnActivate() { base.OnActivate(); if (Document.HistoryCount == 0) { ExitFromApplication(); } var result = NaroMessage.Show("Do you want to save your work?", "Exiting NaroCAD", MessageBoxButtons.YesNoCancel); bool saveFileResult = true; switch (result) { case DialogResult.Yes: saveFileResult = SaveFile(); break; case DialogResult.Cancel: BackToNeutralModifier(); return; } if (saveFileResult) { ExitFromApplication(); } }
public override void OnActivate() { base.OnActivate(); if (Document.HistoryCount <= 0) { LoadDefaultTemplate(); return; } var result = NaroMessage.Show( @"Do you want to save your work?", @"NaroCAD", MessageBoxButtons.YesNoCancel); if (result == DialogResult.Cancel) { BackToNeutralModifier(); return; } if (result == DialogResult.No) { LoadDefaultTemplate(); return; } const string inputName = InputNames.FileSaveDialog; Send(inputName, NotificationNames.SetFilter, "Naro Xml Document (*.naroxml)|*.naroxml|STEP Files|*.step"); Send(inputName, NotificationNames.ShowSaveAs); var fileName = GetData(inputName, NotificationNames.GetFile); SaveCommonCodes.SaveToFile(fileName, Document); LoadDefaultTemplate(); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); NaroMessage.SetFactory(new MessageBoxMessage()); var pluginManagerWindow = new ManagementPluginWindow(); pluginManagerWindow.ShowDialog(); }
private void OnCandidateUpdate(bool updateShape) { if (Dependency.StepIndex == 0) { return; } if (Dependency.StepIndex == 20 && !_multiplePointsWarningShown) { _multiplePointsWarningShown = true; NaroMessage.Show( "The count of points of your spline is big. You can draw more points but some visualisation problems may occur!"); } Dependency.AnimationNodeBuilder = new NodeBuilder(Dependency.AnimationDocument, FunctionNames.Spline); var nb = Dependency.AnimationNodeBuilder.Node.Get <FunctionInterpreter>(); var dnb = Dependency.DocumentNodeBuilder.Node.Get <FunctionInterpreter>(); foreach (var step in Dependency.Steps) { var data = step.Get <Point3D?>(); if (data == null) { continue; } nb.Dependency.AddAttributeType(InterpreterNames.Point3D); dnb.Dependency.AddAttributeType(InterpreterNames.Point3D); var pos = nb.Dependency.Count - 1; nb.Dependency.Children[pos].TransformedPoint3D = (Point3D)data; dnb.Dependency.Children[pos].TransformedPoint3D = (Point3D)data; } var animationBuilder = Dependency.AnimationNodeBuilder; animationBuilder.Color = Color.Red; animationBuilder.Transparency = 0.2; nb.Execute(); if (Dependency.StepIndex == _solvedSteps) { return; } _solvedSteps = Dependency.StepIndex; Dependency.AddStepByName(InterpreterNames.Point3D); var index = Dependency.StepIndex - 1; UnregisterUpdate(index); index = Dependency.StepIndex + 1; RegisterUpdate(index); Dependency.Steps[Dependency.StepIndex + 1].HintText = ModelingResources.SplineStep2; if (!_multiplePointsWarningShown || Dependency.StepIndex != 25) { return; } _multiplePointsWarningShown = false; NaroMessage.Show( "Maximum spline point count exceeded. Spline shape will be stopped. Please start another spline."); }
public override void OnActivate() { base.OnActivate(); GetOptions(); _view = null; _index = -1; InitSession(); var firstPoint = new SortedDictionary <int, Point3D>(); var secondPoint = new SortedDictionary <int, Point3D>(); var root = Document.Root; var shapeIndexes = root.Get <DocumentContextInterpreter>().ShapeManager.ShapeIndexes; foreach (var shapeIndex in shapeIndexes) { var builder = new NodeBuilder(root[shapeIndex]); if (builder.FunctionName != FunctionNames.LineTwoPoints) { continue; } firstPoint[shapeIndex] = builder[0].RefTransformedPoint3D; secondPoint[shapeIndex] = builder[1].RefTransformedPoint3D; } InitSession(); var list = new List <int>(); list.AddRange(firstPoint.Keys); _listCommonPoints = new List <CombinedLinesClassInfo>(); for (var i = 0; i < list.Count - 1; i++) { for (var j = i + 1; j < list.Count; j++) { var commonPoint = CommonLinePoint(firstPoint, secondPoint, list[i], list[j]); if (commonPoint == null) { continue; } DrawPreviewPoint((Point3D)commonPoint); var commonInfo = new CombinedLinesClassInfo((Point3D)commonPoint, new NodeBuilder(root[list[i]]), new NodeBuilder(root[list[j]])); _listCommonPoints.Add(commonInfo); } } if (_listCommonPoints.Count != 0) { return; } NaroMessage.Show("There are no lines with common points! Exiting"); BackToNeutralModifier(); }
public override void OnActivate() { base.OnActivate(); _fileDialog = new SaveFileDialog { Filter = @"NaroXml file(*.naroxml)|*.naroxml|All files (*.*)|*.*" }; var result = _fileDialog.ShowDialog(); if (result == DialogResult.Cancel) { BackToNeutralModifier(); return; } var entities = Inputs[InputNames.SelectionContainerPipe].GetData(NotificationNames.GetEntities).Get <List <SceneSelectedEntity> >(); if (entities.Count == 0) { NaroMessage.Show("You should select a shape or more before exporting!"); BackToNeutralModifier(); return; } var nodes = new List <Node>(); foreach (var entity in entities) { nodes.Add(entity.Node); } var existingShapes = new SortedDictionary <int, int>(); foreach (var node in nodes) { existingShapes[node.Index] = 1; } Document.Transact(); var toRemoveList = new List <Node>(Document.Root.Children.Values); foreach (var node in toRemoveList) { if (!existingShapes.ContainsKey(node.Index)) { NodeBuilderUtils.DeleteNode(node, Document); } } Document.OptimizeData(); Document.Commit("Imported file: " + _fileDialog.FileName); Document.SaveToXml(_fileDialog.FileName); Document.Undo(); BackToNeutralModifier(); }
protected override void OnNotification(string name, DataPackage dataPackage) { switch (name) { case NotificationNames.Suspend: if (_lockedPlane) { return; } if (_facePickerSuspended) { return; } if (!_facePickerSuspended) { _context.CloseAllContexts(true); } _facePickerSuspended = true; Log.Info("FacePickerPlane - suspended"); break; case NotificationNames.LockPlane: Send(NotificationNames.Suspend); Face = dataPackage.Get <TopoDSFace>(); _lockedPlane = true; break; case NotificationNames.Resume: if (_lockedPlane) { return; } if (!_facePickerSuspended) { return; } _facePickerSuspended = false; Face = null; Log.Info("FacePickerPlane - resumed"); break; case NotificationNames.Cleanup: break; default: NaroMessage.Show(@"Object name: " + name + @" is not handled in input notification"); break; } }
protected override void OnMouseClick3DAction(Mouse3DPosition mouseData) { if (!mouseData.MouseDown) { return; } if (_stage >= Stages.SecondShape) { return; } if (_selectedNode == null) { return; } if (_entities.Count != 0 && _selectedNode.ShapeCount == _entities[0].ShapeCount) { return; } _entities.Add(_selectedNode); NextStage(); if (_stage != Stages.SecondShape) { return; } if (_sizeWindow != null) { return; } var referenceShapeDirection = GeomUtils.ExtractDirection(_entities[1].TargetShape()); if (referenceShapeDirection == null) { NaroMessage.Show("Invalid face selected!"); return; } _axis.Direction = referenceShapeDirection; ActionsGraph[InputNames.FacePickerPlane].Send(NotificationNames.Suspend); ActionsGraph[InputNames.SelectionContainerPipe].Send(NotificationNames.SwitchSelectionMode, TopAbsShapeEnum.TopAbs_SOLID); //_sizeWindow = new ToolRangeValuesWindow(-Math.PI/2, Math.PI/2, "Angle Draft"); _sizeWindow = new ToolRangeValuesWindow(-90, 90, "Angle Draft"); _sizeWindow.OnValueChange += PreviwFillet; _sizeWindow.OnDialogClosed += OnClosed; _sizeWindow.Show(); }
public bool RegisterPlugin(string assemblyName, bool onDocumentStartup) { Assembly assembly; try { assembly = Assembly.Load(assemblyName); } catch (Exception) { NaroMessage.Show(@"Plugin cannot be loaded"); return(false); } return(PluginModifierRegister(assembly, onDocumentStartup)); }
public override void OnActivate() { base.OnActivate(); Inputs[InputNames.GeometricSolverPipe].Send(NotificationNames.DisableAll); BuildSelectionList(); if (_selectedShapes.Count != 2) { NaroMessage.Show("You should select a point and an edge before using this tool!"); BackToNeutralModifier(); return; } _sourceSelectedEntity = _selectedShapes[0]; _destinationSelectedEntity = _selectedShapes[1]; BuildConstraint(); }
private void SetScaleValue(object data) { var value = (double)data; if (value < 0.0001) { NaroMessage.Show("You should input a value greater than zero"); return; } BeginUpdate(); var interpreter = Parent.Set <TransformationInterpreter>(); interpreter.Scale = value; EndVisualUpdate("Scale object"); }
private void InitialDialogSetup() { try { var fileNames = Directory.GetFiles(NaroAppConstantNames.ShadersFolder, "*.shd"); comboBox1.Items.Clear(); foreach (var fileName in fileNames) { comboBox1.Items.Add(ExtractShaderName(fileName)); } } catch (Exception ex) { NaroMessage.Show(ex.Message); } }
public static void LoadStepFile(string fileName, Document document) { try { document.Transact(); var aReader = new STEPControlReader(); aReader.ReadFile(fileName); aReader.WS().MapReader().TraceLevel = 2; // increase default trace level aReader.PrintCheckLoad(false, IFSelectPrintCount.IFSelect_ItemsByEntity); // Root transfers var nbr = aReader.NbRootsForTransfer; aReader.PrintCheckTransfer(false, IFSelectPrintCount.IFSelect_ItemsByEntity); for (var n = 1; n <= nbr; n++) { aReader.TransferRoot(n); } var nbs = aReader.NbShapes; var aSequence = new TopToolsHSequenceOfShape(); for (var i = 1; i <= nbs; i++) { aSequence.Append(aReader.Shape(i)); } for (var i = 1; i <= aSequence.Length; i++) { var aisShape = aSequence.Value(i); var builder = new NodeBuilder(document, FunctionNames.Mesh); builder[0].Shape = aisShape; builder.ExecuteFunction(); } document.Commit("Added to scene filename: " + fileName); } catch { document.Revert(); NaroMessage.Show("Exception on loading file: " + fileName); } }
private void ContextualOnClick(string shape) { string metaActionName; if (!_shapesActionMapping.TryGetValue(shape, out metaActionName)) { NaroMessage.Show(@"Shape_mapping_not_found " + shape); return; } var activeNode = _lastSelectedNode; SwitchUserAction(metaActionName); if (activeNode == null) { return; } }
private static void AutoLoadPlugins(ActionsGraph childActionGraph) { var listPluginFiles = PluginUtil.AutoLoadPlugins(); foreach (var pluginFile in listPluginFiles) { if (!pluginFile.Value) { continue; } var pluginLoader = new BooPluginLoader(childActionGraph); var result = pluginLoader.RegisterPlugin(pluginFile.Key, true); if (!result) { NaroMessage.Show("Cannot load plugin: " + pluginFile.Key); } } }
private static bool NewerVersion(string newerVersionName) { try { if (newerVersionName.Length == lengthOfStableVersion) { if (Int64.Parse(newerVersionName) > Int64.Parse(_fullNumericVersion.Substring(0, lengthOfStableVersion))) { return(true); } else { } } else if (newerVersionName.Length == lengthOfNightlyVersion) { if (_fullNumericVersion.Length == lengthOfNightlyVersion) { if (Int64.Parse(newerVersionName) > Int64.Parse(_fullNumericVersion)) { return(true); } else { } } else if (_fullNumericVersion.Length == lengthOfStableVersion) { if (Int64.Parse(newerVersionName.Substring(0, lengthOfStableVersion)) >= Int64.Parse(_fullNumericVersion)) { return(true); } } } return(false); } catch { NaroMessage.Show("The new versioning file was modified unexpectedly."); return(false); } }
public static bool SendBugReport(ReportingForm form) { var sent = true; form.FileNames.Add(NaroAppConstantNames.LogFileName); form.FileNames.Add(NaroAppConstantNames.AutoSaveFileName); form.TopMost = true; //Application.Run(form); if (form.ShowDialog() == DialogResult.OK) { sent = SendReportToSf(form, form.FileNames); if (!sent) { NaroMessage.Show(ErrorReportCommonResources.StarterUtils_Internet_problems); } } return(sent); }
/// <summary> /// Save a file from a specific location as XML content /// </summary> /// <param name = "fileName">Filename location</param> public bool LoadFromXml(string fileName) { try { var oldTree = _treeMirror; _treeMirror = XmlHelper.LoadFromXml(fileName); if (_treeMirror == null) { _treeMirror = oldTree; NaroMessage.Show("Invalid NaroXML file. NaroCAD cannot open this file"); return(false); } Transact(); var undo = new NodeDiff(null); var redo = new NodeDiff(null); var currentTreeMirror = ReflectTreeMirror(Root); NodeDiff.ComputeDiff(currentTreeMirror, _treeMirror, undo, redo); try { NodeDiff.ApplyDiff(Root, redo); } catch (Exception ex) { Log.Info(string.Format("Exception loading file: {0} with message: {1} with stack: {2}", fileName, ex.Message, ex.StackTrace)); NaroMessage.Show(string.Format("Cannot load file {0}", fileName)); var brokenTreeMirror = ReflectTreeMirror(Root); NodeDiff.ComputeDiff(brokenTreeMirror, currentTreeMirror, undo, redo); NodeDiff.ApplyDiff(Root, undo); } Commit("Loaded file: " + fileName); return(true); } catch (Exception e) { Revert(); Log.Info("Error on loading xml: " + e.Message + Environment.NewLine + "Stack: " + e.StackTrace); return(false); } }
public static NodeBuilder ApplyToolOnOtherShape(Document document, Node sourceTool, Node destinationShape) { var oldTool = new NodeBuilder(sourceTool); var newTool = new NodeBuilder(document, sourceTool.Get <FunctionInterpreter>().Name); if (oldTool[0].Name != InterpreterNames.Reference && oldTool[0].Name != InterpreterNames.ReferenceList) { NaroMessage.Show("You should pick a tool as source selection"); return(new NodeBuilder(null)); } newTool[0].ReferenceData = new SceneSelectedEntity { Node = destinationShape, ShapeCount = oldTool[0].ReferenceData.ShapeCount, ShapeType = oldTool[0].ReferenceData.ShapeType }; var result = SyncronizeNodeFunctions(sourceTool, ref newTool); return(result ? newTool : new NodeBuilder(null)); }
private void ButtonClick(object sender, RoutedEventArgs e) { Log.Info("After confirming the name of the new layer"); var newLayerName = _addNewLayerTextBox.Text; if (_container.LayerNames.Contains(newLayerName)) { NaroMessage.Show("Layer name already exist, please pick another!"); Log.Info("The new layer cannot be added because of duplicate names"); return; } DialogResult = true; if (_updateValue) { _container.LayerNames[_index] = newLayerName; Log.Info("Layer " + newLayerName + "added"); _container.LayerColors[_index] = ShapeUtils.FromWpfColor(LayerColor); } Close(); }
public static void SaveShapeToStep(IEnumerable <TopoDSShape> shapes, string fileName) { var aWriter = new STEPControlWriter(); foreach (var shape in shapes) { if (shape != null) { aWriter.Transfer(shape, STEPControlStepModelType.STEPControl_ShellBasedSurfaceModel, true); } } var status = aWriter.Write(fileName); if (status == IFSelectReturnStatus.IFSelect_RetError || status == IFSelectReturnStatus.IFSelect_RetFail) { NaroMessage.Show("Error has occured while saving to STEP format"); } }
public void PushValue(object data) { if (data == null) { return; } // Try to propose to the meta action the parameter value var dependency = _metaAction.Dependency; //Dependency.Inputs.Inputs[InputNames.FacePickerPlane].Send(NotificationNames.Resume); InitAnimateSession(); if (!BridgedProposeDependency(data, dependency)) { return; } var documentNodeBuilder = dependency.DocumentNodeBuilder; if (documentNodeBuilder != null && documentNodeBuilder.LastExecute && dependency.StepName == InterpreterNames.Reference) { var dependencyNode = dependency.DocumentNodeBuilder[dependency.StepIndex]; var step = dependency.Steps[dependency.StepIndex]; dependencyNode.ReferenceData = step.Get <SceneSelectedEntity>(); if (!dependencyNode.IsValid) { NaroMessage.Show(@"Tool does not work with this shape"); return; } } if (data is Mouse3DPosition) { Inputs[InputNames.CoordinateParser].Send(NotificationNames.SetLastPoint, (data as Mouse3DPosition).Point); } dependency.PushCandidate(); UpdateParserAndView(dependency); }
public override void OnActivate() { base.OnActivate(); //if (Document.HistoryCount == 0) // ExitFromApplication(); var result = NaroMessage.Show("NaroCAD can now attempt to update. Do you want to save your work?", "Restarting NaroCAD", MessageBoxButtons.YesNoCancel); switch (result) { case DialogResult.Yes: SaveFile(); break; case DialogResult.Cancel: BackToNeutralModifier(); return; } RestartApplication(); }
private void InstallPluginClicked(object sender, RoutedEventArgs e) { var fileOpenDialog = new OpenFileDialog { Filter = "Naro Plugin Assembly (*.dll)|*.dll" }; var result = fileOpenDialog.ShowDialog(); if ((bool)(!result)) { return; } var fileName = fileOpenDialog.FileName; if (!PluginUtil.IsNaroPlugin(fileName)) { NaroMessage.Show("You should select a NaroCAD plugin!"); return; } File.Copy(fileName, AppSettings.Instance.StartFolder); UpdatePluginList(); }