Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have created this xaml for progress bar for tasks which takes time.
but when i load my dll containg this xaml and run it it minimizes.
<Window x:Class="SolarInfraCADAutomate.UI.ProgressBarWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SolarInfraCADAutomate.UI"
mc:Ignorable="d"
Title="ProgressBarWindow" Height="200" Width="400"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
Background="Transparent"
>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*" />
<RowDefinition Height="0.5*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="10" VerticalAlignment="Center" HorizontalAlignment="Center">
<Label FontSize="32" FontWeight="Bold" Foreground="Beige">Loading ...</Label>
</StackPanel>
<StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center">
<ProgressBar Minimum="0" Maximum="100" Name="pbStatus" IsIndeterminate="True" Height="32" />
</StackPanel>
</Grid>
</Window>and implementation is like this
[assembly: CommandClass(typeof(SolarInfraCADAutomate.Piling.PilePlacement))]
namespace SolarInfraCADAutomate.Piling
{
/// <summary>
/// Class <c>PilePlacement</c> Places specific piles on user selected tables.
/// </summary>
internal class PilePlacement
{
private static Document doc;
private static Editor ed;
private static Database db;
// Progress bar window.
private static ProgressBarWindow progressBarWindow;
// Member variable to check whether the type of table is fixtilt or tracker.
public static bool isFixTilt = false;
/// <summary>
/// Method <b>PlacePiles</b> Places specific piles on user selected tables.
/// </summary>
public static void PlacePiles()
{
doc = Application.DocumentManager.MdiActiveDocument;
UtilityFunctions.UnlockAllLayers(doc, doc.Editor, doc.Database, false);
LayerOperations.HideTables();
Log.Logger.Log("Initialized the document in PlacePiles funtion");
Log.Logger.Log("Calling PilePlacement command");
doc.SendStringToExecute("PilePlacement ", true, false, false);
// Show progress bar window on the UI thread
Dispatcher.CurrentDispatcher.Invoke(() => {
progressBarWindow = new ProgressBarWindow();
progressBarWindow.Show();
});
}
[CommandMethod("PilePlacement")]
public static void Main()
{
doc = Application.DocumentManager.MdiActiveDocument;
ed = doc.Editor;
db = doc.Database;
try
{
List<string> tableNames = MMSData.tables;
MMSData.tablePiling = true;
Dictionary <string, List < BlockReference >> allBlockReferences = MMSData.mmsTablesDict;
Log.Logger.Log("Get list of table names and dictionary of table name and blocks from MMSData");
//iterate through all the tables selected by user
//string[] tableNames = { "MMS Table (32.2920 x 4.5760)", "MMS Table (128.58 x 2.278)" };
Log.Logger.Log("iterate through all the tables selected by user");
foreach (string tableName in tableNames)
{
string currTable = tableName;
if(currTable.Contains("(Ext)")) currTable = currTable.Replace("(Ext)", "");
AddPileDrawingToDB(tableName, allBlockReferences[currTable][0]);
}
ChangeVisibility();
// Close the progress bar window on the UI thread
Dispatcher.CurrentDispatcher.Invoke(() => {
progressBarWindow.Close();
});
MessageBox.Show("Piles placed successfully !!", "Piling Automation", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
Log.Logger.LogException(ex);
}
catch (System.Exception ex)
{
Log.Logger.LogException(ex);
}
}
Solved! Go to Solution.