Example #1
0
        public MainWindow()
        {
            InitializeComponent();

            _viewer3DVM          = new Viewer3DViewModel();
            Viewer3D.DataContext = _viewer3DVM;

            _textEditorVM          = new TextEditorViewModel(TextEditor, _viewer3DVM);
            TextEditor.DataContext = _textEditorVM;

            Statusbar.DataContext = new StatusBarViewModel(_textEditorVM);

            string filePath = @"STL-Files\xyz-calibrationCube.stl";
            var    stlFile  = new STLFile(filePath);

            var meshes = stlFile.LoadMeshes();

            // cutting meshes
            var cutMeshes = meshes[0].Cut(new Vector3d(1, 1, 10), new Vector3d(0, 0, 1));

            _viewer3DVM.Add(new Wireframe(cutMeshes.BaseMesh, Color.Yellow, Color.DarkSlateGray));
            _viewer3DVM.Add(new Wireframe(cutMeshes.CutOffMesh, Color.GreenYellow));

            //stlFile.SaveMeshes(new List<Mesh> { cutMeshes.BaseMesh });
        }
Example #2
0
        private async Task <ITextDocumentTabViewModel> OpenDocumentAsync(ISourceFile file)
        {
            var shell = IoC.Get <IShell>();

            var currentTab = shell.Documents.OfType <ITextDocumentTabViewModel>().FirstOrDefault(t => t.SourceFile?.FilePath == file.FilePath);

            if (currentTab == null)
            {
                var provider = IoC.Get <IStudio>().EditorProviders.FirstOrDefault(p => p.Value.CanEdit(file))?.Value;

                if (provider != null)
                {
                    currentTab = await provider.CreateViewModel(file);
                }
                else
                {
                    var document = await AvalonStudioTextDocument.CreateAsync(file);

                    currentTab = new TextEditorViewModel(document, file);
                }
            }

            shell.AddOrSelectDocument(currentTab);

            return(currentTab);
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StoreViewModel"/> class.
 /// </summary>
 public StoreViewModel(IRuntimeService runtime)
 {
     Runtime     = runtime;
     DisplayName = string.Format("{0:D} - {0}", Protocols.Store);
     Data        = new TextEditorViewModel(runtime, "XML")
     {
         IsPrettyPrintAllowed = true
     };
     Data.Document.Changed += OnDataObjectChanged;
     ResetDataEditorBorderColor();
 }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResultViewModel" /> class.
        /// </summary>
        /// <param name="runtime">The runtime service.</param>
        /// <param name="queryResults">The query results.</param>
        /// <param name="messages">The WITSML messages.</param>
        /// <param name="soapMessages">The SOAP messages.</param>
        public ResultViewModel(IRuntimeService runtime, TextEditorViewModel queryResults, TextDocument messages, TextDocument soapMessages)
        {
            _log.Debug("Creating view model instance");
            Runtime          = runtime;
            ObjectData       = new DataGridViewModel(runtime);
            ObjectProperties = new PropertyGridViewModel(runtime, ObjectData);

            QueryResults = queryResults;

            Messages = new TextEditorViewModel(runtime, "XML", true)
            {
                Document = messages
            };
            SoapMessages = new TextEditorViewModel(runtime, "XML", true)
            {
                Document = soapMessages
            };
        }
Example #5
0
        internal void Save(TextEditorViewModel fileToSave, bool saveAsFlag = false)
        {
            if (string.IsNullOrEmpty(fileToSave.FilePath) || saveAsFlag)
            {
                var saveFileService = GetService <ISaveFileService>();

                var defExtentsion = Path.GetExtension(fileToSave.FilePath);
                saveFileService.FileName = fileToSave.FileName.TrimEnd('*');
                saveFileService.Filter   = string.Format("*{0}|*{0}", defExtentsion);

                if (!saveFileService.DetermineFile())
                {
                    return;
                }

                fileToSave.FilePath = saveFileService.FileName;
            }


            File.WriteAllText(fileToSave.FilePath, fileToSave.Document.Text);
            //fileToSave.IsDirty = false;

            Log.Info("File saved : " + fileToSave.FilePath);
        }
Example #6
0
 internal void Close(TextEditorViewModel fileToClose)
 {
     //Removes the file from the collection of Documents
     _files.Remove(fileToClose);
     Log.Info("File closed and removed from collection " + fileToClose.FileName);
 }