Example #1
0
        private void LengthButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Dna.Application.ActiveModel?.SelectedObjects((objects) =>
            {
                // Get the newest dimension
                var lastDimension = objects.LastOrDefault(f => f.IsDimension);

                // Double check we have one
                if (lastDimension == null)
                {
                    return;
                }

                var dimensionSelectionName = string.Empty;

                // Get the dimension name
                lastDimension.AsDimension((dimension) => dimensionSelectionName = dimension.SelectionName);

                // Set the length button text
                ThreadHelpers.RunOnUIThread(() =>
                {
                    SheetMetalLengthText.Text = $"\"{dimensionSelectionName}\"";
                });
            });
        }
Example #2
0
        private void buttonFindSense_Click(object sender, EventArgs e)
        {
            var senseFindBitmaps  = this.screenShotsManager.LoadAllBitmapsFromDirectory(Settings.Default.ClickSenseFindDir);
            var senseCloseBitmaps = this.screenShotsManager.LoadAllBitmapsFromDirectory(Settings.Default.ClickSenseCloseDir);

            this.catBitmaps           = this.screenShotsManager.LoadAllBitmapsFromDirectoryAsDictionary(@".\\Cats\\");
            this.clixSenseAdProcessor = new ClixSenseAdProcessor(
                this.screenShotsManager,
                senseFindBitmaps,
                this.catBitmaps,
                senseCloseBitmaps,
                Settings.Default.ClickSenseScreenIndex,
                Settings.Default.ScreenZoomFactorX,
                Settings.Default.ScreenZoomFactorY,
                this.checkBoxFakeMoves.Checked,
                Dispatcher.CurrentDispatcher);

            try
            {
                var senseTask = Task.Run(
                    () =>
                {
                    this.clixSenseAdProcessor.DoAdProcessing();
                    ThreadHelpers.ShowThreadInformation($"Main Task(Task #{Task.CurrentId})");
                });
            }
            catch (OperationCanceledException exception)
            {
                Logger.Info($" Operation was cancelled. {exception.Message}");
            }
            catch (Exception exception)
            {
                Logger.Info(exception);
            }
        }
Example #3
0
 /// <summary>
 /// Checks for change in model selection
 /// Currently unused, but can be used to determine what the user is clicking on (feature, face, drawing, dimension, etc)
 /// </summary>
 private void Model_SelectionChanged()
 {
     SolidWorksEnvironment.Application.ActiveModel?.SelectedObjects((objects) =>
     {
         ThreadHelpers.RunOnUIThread(() =>
         {
         });
     });
 }
 public void Stop()
 {
     if (!running)
     {
         return;
     }
     running = false;
     ThreadHelpers.CancelSynchronousIo(loopThreadId);
     messageThread.Join();
 }
Example #5
0
        private void SetLengthButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            // Get the active model
            var model = Application.ActiveModel;

            ThreadHelpers.RunOnUIThread(() =>
            {
                model.SetCustomProperty("D1@Sketch8", "105");
            });
        }
Example #6
0
 /// <summary>
 /// When selecting something, check if it is a dimension and enable the Get Dimension button
 /// </summary>
 private void Model_SelectionChanged()
 {
     Application?.ActiveModel?.SelectedObjects((objects) =>
     {
         ThreadHelpers.RunOnUIThread(() =>
         {
             LengthButton.IsEnabled = objects.Any(f => f.IsDimension);
         });
     });
 }
Example #7
0
        private void Model_SelectionChanged()
        {
            Dna.Application.ActiveModel?.SelectedObjects((objects) =>
            {
                var haveDimension = objects.Any(f => f.IsDimension);

                ThreadHelpers.RunOnUIThread(() =>
                {
                    this.LengthButton.IsEnabled = haveDimension;
                });
            });
        }
Example #8
0
        public void InvokeTest()
        {
            var number = 0;

            ThreadHelpers.InvokeWithExtendedMaxStackSize(() => number = 1);
            Assert.Equal(1, number);
            ThreadHelpers.InvokeWithExtendedMaxStackSize(2, (param) => number = (int)param);
            Assert.Equal(2, number);
            ThreadHelpers.InvokeWithModifiedMaxStackSize(() => number = 1, maxStackSize: 512);
            Assert.Equal(1, number);
            ThreadHelpers.InvokeWithModifiedMaxStackSize(2, (param) => number = (int)param, maxStackSize: 512);
            Assert.Equal(2, number);
        }
Example #9
0
        public void ReceiveOrSend_GivenThereIsASenderEventually_ReturnsAReceivedMessage()
        {
            // Arrange
            const int message = 118722;

            ThreadHelpers.RunInThread(() =>
            {
                Thread.Sleep(500);
                var receiver = valvedPipe.FindReceiver(valvedPipe.Inlet);
                receiver(message);
            });

            // Act
            var result = valvedPipe.Valve.ReceiveOrSend("Not getting sent");

            Thread.Sleep(500);

            // Assert
            result.MessageReceived.Should().BeTrue();
            result.GetReceivedMessage().Should().Be(message);
        }
Example #10
0
        public void ReceiveOrSend_GivenThereIsAReceiverEventually_ReturnsTheMessageWasSent()
        {
            // Arrange
            const string message = "This is confusing...";

            var receivedMessage = "";

            ThreadHelpers.RunInThread(() =>
            {
                Thread.Sleep(500);
                var sender      = valvedPipe.FindSender(valvedPipe.Outlet);
                receivedMessage = sender();
            });

            // Act
            var result = valvedPipe.Valve.ReceiveOrSend(message);

            Thread.Sleep(500);

            // Assert
            result.MessageSent.Should().BeTrue();
            receivedMessage.Should().Be(message);
        }
Example #11
0
        public void ReceiveOrSend_GivenThereIsNeitherASenderNorAReceiver_BlocksIndefinitely()
        {
            // Act
            ThreadInterruptedException exception = null;
            var thread = ThreadHelpers.RunInThread(() =>
            {
                try
                {
                    valvedPipe.Valve.ReceiveOrSend("Hello");
                }
                catch (ThreadInterruptedException e)
                {
                    exception = e;
                }
            });

            Thread.Sleep(1000);
            thread.Interrupt();
            Thread.Sleep(500);

            // Assert
            exception.Should().NotBeNull();
        }
Example #12
0
        /// <summary>
        /// Reads all the details from the active SolidWorks model
        /// </summary>
        private void ReadDetails()
        {
            ThreadHelpers.RunOnUIThread(() =>
            {
                // Get the active model
                var model = Application.ActiveModel;

                // If we have no model, or the model is not a part
                // then show the No Part screen and return
                if (model == null || (!model.IsPart && !model.IsAssembly))
                {
                    // Show No Part screen
                    NoPartContent.Visibility = System.Windows.Visibility.Visible;
                    MainContent.Visibility   = System.Windows.Visibility.Hidden;
                    return;
                }

                // If we got here, we have a valid model

                // Listen out for selection changes
                model.SelectionChanged += Model_SelectionChanged;

                // Show the main sidepanel content
                NoPartContent.Visibility = System.Windows.Visibility.Hidden;
                MainContent.Visibility   = System.Windows.Visibility.Visible;

                // Description
                DescriptionText.Text = model.GetCustomProperty(CustomPropertyDescription);

                // Dimension
                SheetMetalLengthText.Text          = model.GetCustomProperty(CustomPropertyLength);
                SheetMetalLengthEvaluatedText.Text = model.GetCustomProperty(CustomPropertyLength, resolved: true);

                // Notes
                NoteText.Text = model.GetCustomProperty(CustomPropertyNote);
            });
        }
        public void Dispose()
        {
            try
            {
                if (IsConnected)
                {
                    pipeStream.Disconnect();
                    IsConnected = false;
                }

                if (waitThreadId != 0)
                {
                    waiterRunning = false;
                    ThreadHelpers.CancelSynchronousIo(waitThreadId);
                    waitForConnectionThread.Join();
                    waitThreadId = 0;
                }

                Debugger.Debug(LogLevel.Info, "Closing Event Emitter...");
                pipeStream.Close();
                Debugger.Debug(LogLevel.Info, "Closed Event Emitter!");
            }
            catch (Exception) { }
        }
        private void RunWaitForConnection()
        {
            waitThreadId = ThreadHelpers.GetCurrentThreadId();
            Debugger.Debug(LogLevel.Info, $"Wait Thread ID: {waitThreadId}");

            while (waiterRunning)
            {
                waitForConnectionEvent.WaitOne();
                Debugger.WriteLine(LogLevel.Info, "EventEmitter: Waiting for connection");
                try
                {
                    pipeStream.WaitForConnection();
                    IsConnected = true;
                    Debugger.WriteLine(LogLevel.Info, "EventEmitter: Connected!");
                }
                catch (Exception)
                {
                    Debugger.WriteLine(LogLevel.Info, "EventServer: Waiting aborted! Closing...");
                    waiterRunning = false;
                    IsConnected   = false;
                    return;
                }
            }
        }
Example #15
0
 static public void Recreate()
 {
     ThreadHelpers.SyncInvokeWithExtendedStack(() => Link.Delete(ref Net.IsA));
     CharacterHelpers.Recreate();
     Create();
 }
Example #16
0
        /// <summary>
        /// Reads all the details from the active SolidWorks model
        /// </summary>
        private void ReadDetails()
        {
            ThreadHelpers.RunOnUIThread(() =>
            {
                // Get the active model
                var model = Dna.Application.ActiveModel;

                // If we have no model, or the model is not a part
                // then show the No Part screen and return
                if (model == null || (!model.IsPart && !model.IsAssembly))
                {
                    // Show No Part screen
                    NoPartContent.Visibility = System.Windows.Visibility.Visible;
                    MainContent.Visibility   = System.Windows.Visibility.Hidden;

                    return;
                }

                // If we got here, we have a part

                // Listen out for selection changes
                model.SelectionChanged += Model_SelectionChanged;

                // Show the main content
                NoPartContent.Visibility = System.Windows.Visibility.Hidden;
                MainContent.Visibility   = System.Windows.Visibility.Visible;

                // Get custom properties
                // Description
                DescriptionText.Text = model.GetCustomProperty(CustomPropertyDescription);

                // Status
                StatusText.Text = model.GetCustomProperty(CustomPropertyStatus, resolved: true);

                // Revision
                RevisionText.Text = model.GetCustomProperty(CustomPropertyRevision, resolved: true);

                // Part Number
                PartNumberText.Text = model.GetCustomProperty(CustomPropertyPartNumber, resolved: true);

                // Manufacturing Information

                // Clear previous checks
                MaterialWeldCheck.IsChecked         = MaterialAssemblyCheck.IsChecked = MaterialPlasmaCheck.IsChecked =
                    MaterialPurchaseCheck.IsChecked = MaterialLatheCheck.IsChecked = MaterialLaserCheck.IsChecked = MaterialDrillCheck.IsChecked =
                        MaterialFoldCheck.IsChecked = MaterialRollCheck.IsChecked = MaterialSawCheck.IsChecked = false;

                // Read in value
                var manufacturingInfo = model.GetCustomProperty(CustomPropertyManufacturingInformation);

                // If we have some property, parse it
                if (!string.IsNullOrWhiteSpace(manufacturingInfo))
                {
                    // Remove whitespaces, capitalize and split by ,
                    foreach (var part in manufacturingInfo.Replace(" ", "").ToUpper().Split(','))
                    {
                        switch (part)
                        {
                        case ManufacturingWeld:
                            MaterialWeldCheck.IsChecked = true;
                            break;

                        case ManufacturingAssembly:
                            MaterialAssemblyCheck.IsChecked = true;
                            break;

                        case ManufacturingPlasma:
                            MaterialPlasmaCheck.IsChecked = true;
                            break;

                        case ManufacturingLaser:
                            MaterialLaserCheck.IsChecked = true;
                            break;

                        case ManufacturingPurchase:
                            MaterialPurchaseCheck.IsChecked = true;
                            break;

                        case ManufacturingLathe:
                            MaterialLatheCheck.IsChecked = true;
                            break;

                        case ManufacturingDrill:
                            MaterialDrillCheck.IsChecked = true;
                            break;

                        case ManufacturingFold:
                            MaterialFoldCheck.IsChecked = true;
                            break;

                        case ManufacturingRoll:
                            MaterialRollCheck.IsChecked = true;
                            break;

                        case ManufacturingSaw:
                            MaterialSawCheck.IsChecked = true;
                            break;
                        }
                    }
                }


                // Length
                SheetMetalLengthText.Text          = model.GetCustomProperty(CustomPropertyLength);
                SheetMetalLengthEvaluatedText.Text = model.GetCustomProperty(CustomPropertyLength, resolved: true);

                // Finish
                var finish = model.GetCustomProperty(CustomPropertyFinish);

                // Clear the selection first
                FinishList.SelectedIndex = -1;

                // Try and find matching item
                foreach (var item in FinishList.Items)
                {
                    // Check if the combo box item has the same name
                    if ((string)((ComboBoxItem)item).Content == finish)
                    {
                        // If so select it
                        FinishList.SelectedItem = item;
                        break;
                    }
                }

                // Purchase Information
                var purchaseInfo = model.GetCustomProperty(CustomPropertyPurchaseInformation);

                // Clear the selection first
                PurchaseInformationList.SelectedIndex = -1;

                // Try and find matching item
                foreach (var item in PurchaseInformationList.Items)
                {
                    // Check if the combo box item has the same name
                    if ((string)((ComboBoxItem)item).Content == purchaseInfo)
                    {
                        // If so select it
                        PurchaseInformationList.SelectedItem = item;
                        break;
                    }
                }

                // Supplier Name
                SupplierNameText.Text = model.GetCustomProperty(CustomPropertySupplierName);

                // Supplier Code
                SupplierCodeText.Text = model.GetCustomProperty(CustomPropertySupplierCode);

                // Note
                NoteText.Text = model.GetCustomProperty(CustomPropertyNote);

                // Mass
                MassText.Text = model.MassProperties?.MassInMetric();

                // Get all materials
                var materials = Dna.Application.GetMaterials();
                materials.Insert(0, new Material {
                    Name = "Remove Material", Classification = "Not specified", DatabaseFileFound = false
                });

                RawMaterialList.ItemsSource       = materials;
                RawMaterialList.DisplayMemberPath = "DisplayName";

                // Clear selection
                RawMaterialList.SelectedIndex = -1;

                // Select existing material
                var existingMaterial = model.GetMaterial();

                // If we have a material
                if (existingMaterial != null)
                {
                    RawMaterialList.SelectedItem = materials?.FirstOrDefault(f => f.Database == existingMaterial.Database && f.Name == existingMaterial.Name);
                }
            });
        }
Example #17
0
        /// <summary>
        /// Reads all the details from the active model
        /// </summary>
        private void ReadDetails()
        {
            ThreadHelpers.RunOnUIThread(() =>
            {
                // Get the active model
                var model = SolidWorksEnvironment.Application.ActiveModel;

                // If we have no model, or the model is not a part or assembly
                // then we show the No Part screen and return
                if (model == null || (!model.IsPart && !model.IsAssembly))
                {
                    // Show No Part screen
                    NoPartContent.Visibility = Visible;
                    MainContent.Visibility   = Hidden;
                    return;
                }

                // If we got here, we have a part
                var filePath = model.FilePath.Split(new string[] { "\\" }, StringSplitOptions.None);
                var fileName = filePath[filePath.Count() - 1];

                // Listen out for selection changes
                model.SelectionChanged += Model_SelectionChanged;

                // Show the main content
                NoPartContent.Visibility    = Hidden;
                MainContent.Visibility      = Visible;
                DesignCheckButton.IsEnabled = true;

                // Query all custom properties
                model.CustomProperties((properties) =>
                {
                    // Clear the NoteGrid, which is the grid of user defined Notes
                    // See the design of UI_SolidWorks_SideBar_PlugIn.xaml
                    NoteGrid.Children.Clear();

                    // Find all the properties saved onto the part (onto the .SLDPRT)
                    // whose name includes the public member CustomPropertyNote = "Note"
                    List <CustomProperty> noteFound = properties.FindAll(property => property.Name.Contains(CustomPropertyNote));

                    // Add each of the properties into the NoteGrid
                    // This way, if a part is opened having many Note custom properties,
                    // then we load them in properly
                    foreach (CustomProperty note in noteFound)
                    {
                        AddNewNote(note.Value);
                    }
                });

                // Mass
                MassText.Text = model.MassProperties?.MassInMetric();

                // Clear material selection
                List <Material> FilteredMaterials = GetMaterialList();
                RawMaterialList.ItemsSource       = FilteredMaterials;
                RawMaterialList.DisplayMemberPath = "DisplayName";
                RawMaterialList.SelectedIndex     = -1;

                // Select existing material
                var existingMaterial = model.GetMaterial();

                // If we have a material
                if (existingMaterial != null)
                {
                    RawMaterialList.SelectedItem = FilteredMaterials?.FirstOrDefault(f => f.Database == existingMaterial.Database && f.Name == existingMaterial.Name);
                }
            });
        }
Example #18
0
        private static void UpdatesInLongWindingProcess()
        {
            var cancellationTokenTimeout  = poolTimeout;
            var cancellationTokenInstance = new CancellationTokenSource();

            ServiceController[] services = ServiceController.GetServices();
            var po = new ParallelOptions {
                CancellationToken = cancellationTokenInstance.Token, MaxDegreeOfParallelism = Environment.ProcessorCount
            };

            // The delegate to be executed when/if the CancellationToken is canceled.
            cancellationTokenInstance.Token.Register(
                (object state) =>
            {
                // action if a cancellation on token occurs
                TotalCancelations++;
                var token = (CancellationToken)state;
                if (token.IsCancellationRequested)
                {
                    Debug.WriteLine("!!! Cancellation Event in UpdatesInLongWindingProcess timeout of " + cancellationTokenTimeout);
                    Debug.WriteLine("!!! UpdatesInLongWindingProcess() Cancellation Event triggered after elapsed time, TotalCancellations={0}", TotalCancelations);
                }
            },
                cancellationTokenInstance.Token);

            var signledDone = (ManualResetEvent)cancellationTokenInstance.Token.WaitHandle;
            var sw          = new Stopwatch();

            sw.Start();
            try
            {
                Thread.CurrentThread.Name = "UpdatesInLongWindingProcess";
                // ThreadHelpers.DisplayThreadPoolInfo(Thread.CurrentThread.Name);

                // The countdown for the millisecondsDelay starts during this call.
                // When the millisecondsDelay expires, this CancellationTokenSource is canceled, if it has not been canceled already.
                if (cancellationTokenTimeout > 0)
                {
                    // schedule a cancel operation on the source
                    cancellationTokenInstance.CancelAfter(cancellationTokenTimeout + 1000); // 30000 ms

                    // start a thread to monitor the Parallel Loop process to verify it gets to the end.
                    // That Loop should signal when done
                    Task.Factory.StartNew(
                        (object state) =>
                    {
                        Thread.CurrentThread.Name = "Monitor UpdatesInLongWindingProcess Thread";
                        var token = state as CancellationTokenSource;
                        if (signledDone.WaitOne(cancellationTokenTimeout))
                        {
                            TotalCancelations = 0;
                        }
                        else
                        {
                            Debug.WriteLine(":( Watchdog Thread timeout. UpdatePredictionTime process Failed to Signal finish of Bus Updates in time, Cancellation expected. TotalCancelations={0}", TotalCancelations);
                            if (token != null && !token.IsCancellationRequested)
                            {
                                token.Cancel();
                                Debug.WriteLine("Invoked Token.Cancel()...");
                            }
                        }
                    },
                        cancellationTokenInstance);
                }

                Parallel.ForEach(
                    services,
                    po,
                    service =>
                {
                    var cancellationToken = po.CancellationToken;
                    var swForEach         = new Stopwatch();
                    swForEach.Start();

                    // check if canceled, if true throw exception and trap below
#pragma warning disable RECS0065 // Expression is always 'true' or always 'false'
                    if (cancellationToken != null)
#pragma warning restore RECS0065 // Expression is always 'true' or always 'false'
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                    }

                    Task.Factory.StartNew(
                        (object state) =>
                    {
                        Thread.CurrentThread.Name = $"Thread " + service.ServiceName;
                        //    ThreadHelpers.DisplayMemory(Thread.CurrentThread.Name);
                        int sleepThreadFor = random.Next(1000);
                        Thread.Sleep(sleepThreadFor);         // each thread can take 30 seconds
                        LongWindingParentProcess(sleepThreadFor);
                        //Debug.WriteLine($"Threads Count: {Process.GetCurrentProcess().Threads.Count}, ThreadId:{Thread.CurrentThread.ManagedThreadId } - Service {service.ServiceName} - Sleep For {sleepThreadFor} ms" );
                    },
                        service);
                });
            }
            catch (OperationCanceledException operationCanceledException)
            {
                Debug.WriteLine(operationCanceledException.Message);
            }
            catch (CommunicationException communicationException)
            {
                Debug.WriteLine(communicationException.Message);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                try
                {
                    // Signal we are done
                    Debug.WriteLine($" Elapsed Time {sw.ElapsedMilliseconds}");
                    sw.Restart();
                    signledDone.Set();
                    cancellationTokenInstance.Dispose();
                    ThreadHelpers.DisplayMemory("-----Finalaly ----");
                    ThreadHelpers.DisplayThreadPoolInfo("-------------Finally--------");
                }
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
                catch
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
                {
                }
            }
        }
Example #19
0
 public static void Recreate()
 {
     ThreadHelpers.InvokeWithExtendedMaxStackSize(() => Link.Delete(IsA));
     CharacterHelpers.Recreate();
     Create();
 }
        public void Test()
        {
            const int numberOfMessages = 1000;

            var basicPipe        = PipeBuilder.New.BasicPipe <IReadOnlyList <int> >().Build();
            var eitherOutletPipe = PipeBuilder.New.EitherOutletPipe <int>().Build();
            var valvedPipe       = PipeBuilder.New.ValvedPipe <int, int>().WithRandomisingTieBreaker().Build();

            valvedPipe.Inlet.ConnectTo(eitherOutletPipe.RightOutlet);

            // Sender
            ThreadHelpers.RunInThread(() =>
            {
                for (var i = 0; i < numberOfMessages; i++)
                {
                    eitherOutletPipe.Inlet.Send(i);
                }
            });

            // Receiver
            ThreadHelpers.RunInThread(() =>
            {
                var receivedMessages = new List <int>();
                for (var i = 0; i < numberOfMessages; i++)
                {
                    var message = valvedPipe.Outlet.Receive();
                    receivedMessages.Add(message);
                }
                basicPipe.Inlet.Send(receivedMessages);
            });

            // Man in the middle
            ThreadHelpers.RunInThread(() =>
            {
                var messageQueue         = new Queue <int>();
                var numberOfMessagesSent = 0;
                while (numberOfMessagesSent != numberOfMessages)
                {
                    if (messageQueue.Count == 0)
                    {
                        var message = eitherOutletPipe.LeftOutlet.Receive();
                        messageQueue.Enqueue(message);
                    }
                    else
                    {
                        var result = valvedPipe.Valve.ReceiveOrSend(messageQueue.Peek());
                        if (result.MessageReceived)
                        {
                            messageQueue.Enqueue(result.GetReceivedMessage());
                        }
                        else
                        {
                            numberOfMessagesSent++;
                            messageQueue.Dequeue();
                        }
                    }
                }
            });

            var allMessages = basicPipe.Outlet.Receive();

            allMessages.Should().HaveCount(numberOfMessages);
            for (var i = 0; i < numberOfMessages; i++)
            {
                allMessages[i].Should().Be(i);
            }
        }
Example #21
0
        /// <summary>
        /// Reads all details from the active SolidWorks model
        /// </summary>
        private void ReadDetails()
        {
            ThreadHelpers.RunOnUIThread(() =>
            {
                // Get the active model
                var model = Application.ActiveModel;

                // if we have no model, or the model is not a part
                // then show the No Part screen and return
                if (model == null || (!model.IsPart && !model.IsAssembly))
                {
                    // Show no part screen
                    NoPartContent.Visibility = System.Windows.Visibility.Visible;
                    MainContent.Visibility   = System.Windows.Visibility.Hidden;

                    return;
                }

                // if we got here we have a part

                // SHow the main content
                NoPartContent.Visibility = System.Windows.Visibility.Hidden;
                MainContent.Visibility   = System.Windows.Visibility.Visible;

                // Get custom properties
                // Description
                DescriptionText.Text = model.GetCustomProperty(CustomPropertyDescription);

                // Status
                StatusText.Text = model.GetCustomProperty(CustomPropertyStatus, resolved: true);

                // Revision
                RevisionText.Text = model.GetCustomProperty(CustomPropertyRevision, resolved: true);

                // Part Number
                PartNumberText.Text = model.GetCustomProperty(CustomPropertyPartNumber, resolved: true);

                // Manufacturing Information

                // Molding

                // Folding

                // Cutting

                // Milling

                // Drilling

                // Welding

                // Lathe



                // Clear previous checks
                WeldCheckBox.IsChecked = AssemblyCheckBox.IsChecked = PlasmaCheckBox.IsChecked = PurchaseCheckBox.IsChecked
                                                                                                     = DrillCheckBox.IsChecked = LatheCheckBox.IsChecked = LaserCheckBox.IsChecked = FoldCheckBox.IsChecked
                                                                                                                                                                                         = RollCheckBox.IsChecked = SawCheckBox.IsChecked = false;

                // Read in value
                var manufacturingInfo = model.GetCustomProperty(CustomPropertyManufacturingInformation);

                // if we have some properties parse it
                if (!string.IsNullOrWhiteSpace(manufacturingInfo))
                {
                    foreach (var part in manufacturingInfo.Replace(" ", "").ToUpper().Split(','))
                    {
                        switch (part)
                        {
                        case ManufacturingWeld:
                            WeldCheckBox.IsChecked = true;
                            break;

                        case ManufacturingAssembly:
                            AssemblyCheckBox.IsChecked = true;
                            break;

                        case ManufacturingPlasma:
                            PlasmaCheckBox.IsChecked = true;
                            break;

                        case ManufacturingLaser:
                            LaserCheckBox.IsChecked = true;
                            break;

                        case ManufacturingPurchase:
                            PurchaseCheckBox.IsChecked = true;
                            break;

                        case ManufacturingLathe:
                            LatheCheckBox.IsChecked = true;
                            break;

                        case ManufacturingDrill:
                            DrillCheckBox.IsChecked = true;
                            break;

                        case ManufacturingFold:
                            FoldCheckBox.IsChecked = true;
                            break;

                        case ManufacturingRoll:
                            RollCheckBox.IsChecked = true;
                            break;

                        case ManufacturingSaw:
                            SawCheckBox.IsChecked = true;
                            break;
                        }
                    }
                }


                //############
                // Ideally rewrite as generalized function
                //############

                // Finish
                var finish = model.GetCustomProperty(CustomPropertyFinish);

                // Clear the selection first
                FinishList.SelectedIndex = -1;

                // Try and find matching item
                foreach (var item in FinishList.Items)
                {
                    if ((string)((ComboBoxItem)item).Content == finish)
                    {
                        // If so select it
                        FinishList.SelectedItem = item;
                        break;
                    }
                }

                // Supplier Name
                SupplierNameText.Text = model.GetCustomProperty(CustomPropertySupplierName);

                // Supplier Code
                SupplierCodeText.Text = model.GetCustomProperty(CustomPropertySupplierCode);

                // Note
                NoteText.Text = model.GetCustomProperty(CustomPropertyNote);

                // Mass
                MassText.Text = model.MassProperties?.MassInMetric();

                // Get all materials
                var materials = Application.GetMaterials();
                materials.Insert(0, new Material {
                    Name = "Remove Material", Classification = "Not specified", DatabaseFileFound = false
                });

                MaterialList.ItemsSource       = materials;
                MaterialList.DisplayMemberPath = "DisplayName";

                // Clear Selection
                MaterialList.SelectedIndex = -1;

                // Select existing material
                var existingMaterial = model.GetMaterial();

                // if we have a materials
                if (existingMaterial != null)
                {
                    MaterialList.SelectedItem = materials?.FirstOrDefault(f => f.Database == existingMaterial.Database && f.Name == existingMaterial.Name);
                }
            }
                                        );
        }