添加项目文件。

This commit is contained in:
GG Z
2026-02-23 14:58:05 +08:00
parent ce96926220
commit 771d780d6c
342 changed files with 33470 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{08A1DF27-BE0B-4018-9453-CD393961E50B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EncapsulationProgressBar</RootNamespace>
<AssemblyName>EncapsulationProgressBar</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="AdWindows, Version=2018.11.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\AdWindows.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="RevitAddInUtility, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\RevitAddInUtility.dll</HintPath>
</Reference>
<Reference Include="RevitAPI, Version=20.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\RevitAPI.dll</HintPath>
</Reference>
<Reference Include="RevitAPIUI, Version=20.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\RevitAPIUI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UIFramework, Version=20.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\UIFramework.dll</HintPath>
</Reference>
<Reference Include="UIFrameworkServices, Version=20.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Revit_API_x64.2020.0.0\lib\NET470\UIFrameworkServices.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="ProgressMonitorViewModel.cs" />
<Compile Include="ProgressMonitorView.xaml.cs">
<DependentUpon>ProgressMonitorView.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ExcuteCmd.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="ProgressMonitorView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,50 @@
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.Attributes;
using EncapsulationProgressBar.ViewModels;
using static UIFramework.WorksharingNotificationWindow;
namespace WPFMonitorProgress.Commands
{
[Transaction(TransactionMode.Manual)]
class ExcuteCmd : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
int count = 5;
try
{
System.Action<int> action = Method;
ProgressMonitorViewModel viewModel = new ProgressMonitorViewModel(doc)
{
ProcessTitle = "处理墙体",
MaxValue= count,
Action= action,
};
viewModel.ProgressModal();
}
catch (Exception e)
{
if (!(e is Autodesk.Revit.Exceptions.OperationCanceledException))
{
message = e.Message;
return Result.Failed;
}
}
return Result.Succeeded;
}
private void Method(int i)
{
//TaskDialog.Show("提示", "执行了");
}
}
}

View File

@@ -0,0 +1,24 @@
<Window x:Class="EncapsulationProgressBar.Views.ProgressMonitorView"
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:EncapsulationProgressBar.Views"
mc:Ignorable="d"
Title="{Binding ProcessTitle}" ResizeMode="NoResize" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen">
<Window.Resources>
<Style TargetType="Separator">
<Setter Property="Height" Value="5"/>
<Setter Property="Background" Value="Transparent"/>
</Style>
</Window.Resources>
<StackPanel Margin="10">
<TextBlock Text="{Binding CurrentContext}"/>
<Separator/>
<ProgressBar Height="23" Width="300" Value="{Binding CurrentValue}" Maximum="{Binding MaxValue}"/>
<Separator/>
<Button x:Name="btnCancel" Content="取消" Width="50" HorizontalAlignment="Right" IsCancel="True"/>
</StackPanel>
</Window>

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace EncapsulationProgressBar.Views
{
/// <summary>
/// Interaction logic for ProgressMonitorView.xaml
/// </summary>
public partial class ProgressMonitorView : Window
{
public ProgressMonitorView()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,113 @@
using Autodesk.Revit.DB;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EncapsulationProgressBar.ViewModels
{
internal class ProgressMonitorViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private bool Cancel { get; set; }
public string ProcessTitle { get; set; }
public int MaxValue { get; set; } = 10;
public int CurrentValue { get; set; } = 0;
public string CurrentContext { get; set; } = string.Empty;
private Views.ProgressMonitorView ProgressView { get; set; }
private delegate void ProgressBarDelegate();
public Action<int> Action { get; set; }
private Document doc;
public ProgressMonitorViewModel(Document doc )
{
this.doc = doc;
}
public void ProgressModal()
{
ProgressView = new Views.ProgressMonitorView();
ProgressView.DataContext = this;
ProgressView.Closed += CurrentUI_Closed;
ProgressView.ContentRendered += ProgressEvent;
ProgressView.ShowDialog();
}
private void ProgressEvent(object sender, EventArgs e)
{
ProgressView.ContentRendered -= ProgressEvent;
#region
//Parameter parameter = CurrentWall.get_Parameter(BuiltInParameter.DOOR_NUMBER);
//if (parameter.IsReadOnly)
//{
// CloseWindow();
// throw new Exception("Mark parameter is read only");
//}
#endregion
#region
using (Transaction t = new Transaction(doc, ProcessTitle))
{
t.Start();
for (CurrentValue = 0; CurrentValue <= MaxValue; ++CurrentValue)
{
if (Cancel)
break;
CurrentContext = string.Format("正在处理 {0} of {1} ", CurrentValue+1, MaxValue);
ProgressView.Dispatcher.Invoke(new ProgressBarDelegate(NotifyUI), System.Windows.Threading.DispatcherPriority.Background);
#region DoSomething
try
{
Action(CurrentValue);
//parameter.Set(CurrentViewModel.CurrentValue.ToString());
}
catch
{
CloseWindow();
throw new Exception("处理失败");
}
System.Threading.Thread.Sleep(50);
#endregion DoSomething
//CurrentContext = string.Format("处理完成 {0} of {1} ", CurrentValue, MaxValue);
//ProgressView.Dispatcher.Invoke(new ProgressBarDelegate(NotifyUI), System.Windows.Threading.DispatcherPriority.Background);
}
t.Commit();
}
#endregion
CloseWindow();
}
public void NotifyUI()
{
Type classType = this.GetType();
if (classType != null)
{
System.Reflection.PropertyInfo[] currentProperties = classType.GetProperties();
foreach (System.Reflection.PropertyInfo currentProperty in currentProperties)
OnPropertyChanged(currentProperty.Name);
}
}
private void OnPropertyChanged(string targetProperty)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(targetProperty));
}
private void CloseWindow()
{
ProgressView.Closed -= CurrentUI_Closed;
ProgressView.Close();
}
private void CurrentUI_Closed(object sender, EventArgs e)
{
Cancel = true;
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("EncapsulationProgressBar")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EncapsulationProgressBar")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("08a1df27-be0b-4018-9453-cd393961e50b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Revit_API_x64" version="2020.0.0" targetFramework="net472" />
</packages>