添加项目文件。
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Szmedi.RevitToolkit.Approval.Converters
|
||||
{
|
||||
class ElementToElementTypeNameConverter : IValueConverter
|
||||
{
|
||||
public static readonly ElementToElementTypeNameConverter Instance = new ElementToElementTypeNameConverter();
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is Element element)
|
||||
{
|
||||
if (element.GetTypeId() != ElementId.InvalidElementId)
|
||||
{
|
||||
var type = element.Document.GetElement(element.GetTypeId()) as ElementType;
|
||||
return type.FamilyName;
|
||||
}
|
||||
}
|
||||
return System.Windows.Data.Binding.DoNothing; // 如果不是Element类型或没有类型ID,则返回Binding.DoNothing
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Szmedi.RevitToolkit.Approval.Converters
|
||||
{
|
||||
public class IntToBooleanConverter : IValueConverter
|
||||
{
|
||||
public static IntToBooleanConverter Instance { get; } = new IntToBooleanConverter();
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return System.Convert.ToBoolean(value);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Szmedi.RevitToolkit.Approval.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for the converters controlling the visibility and enabled state of window caption buttons.
|
||||
/// </summary>
|
||||
public abstract class WindowCaptionButtonBaseConverter : IMultiValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifier for the minimize caption button.
|
||||
/// </summary>
|
||||
public string MinimizeButtonName => "minimizeButton";
|
||||
|
||||
/// <summary>
|
||||
/// Identifier for the maximize/restore caption button.
|
||||
/// </summary>
|
||||
public string MaximizeRestoreButtonName => "maximizeRestoreButton";
|
||||
|
||||
/// <summary>
|
||||
/// Identifier for the close caption button.
|
||||
/// </summary>
|
||||
public string CloseButtonName => "closeButton";
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="WindowCaptionButtonBaseConverter" />.
|
||||
/// </summary>
|
||||
public WindowCaptionButtonBaseConverter() { }
|
||||
|
||||
public abstract object Convert(object[] values, Type targetType, object parameter, CultureInfo culture);
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Szmedi.RevitToolkit.Approval.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a <see cref="ResizeMode" /> of a window into an enabled state of an according caption button.
|
||||
/// </summary>
|
||||
public class WindowCaptionButtonEnabledConverter : WindowCaptionButtonBaseConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="WindowCaptionButtonEnabledConverter" />.
|
||||
/// </summary>
|
||||
public WindowCaptionButtonEnabledConverter() : base() { }
|
||||
|
||||
public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (values != null && values.Length == 2)
|
||||
{
|
||||
string buttonName = (string)values[0];
|
||||
ResizeMode resizeMode = (ResizeMode)values[1];
|
||||
|
||||
if (buttonName == CloseButtonName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (buttonName == MinimizeButtonName)
|
||||
{
|
||||
return resizeMode != ResizeMode.NoResize;
|
||||
}
|
||||
else if (buttonName == MaximizeRestoreButtonName)
|
||||
{
|
||||
return resizeMode != ResizeMode.NoResize && resizeMode != ResizeMode.CanMinimize;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// use the default return value below
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Szmedi.RevitToolkit.Approval.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a <see cref="WindowStyle" /> and a <see cref="ResizeMode" /> of a window into a <see cref="Visibility" /> of an according caption button.
|
||||
/// </summary>
|
||||
public class WindowCaptionButtonVisibilityConverter : WindowCaptionButtonBaseConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="WindowCaptionButtonVisibilityConverter" />.
|
||||
/// </summary>
|
||||
public WindowCaptionButtonVisibilityConverter() : base() { }
|
||||
|
||||
public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (values != null && values.Length == 3)
|
||||
{
|
||||
string buttonName = (string)values[0];
|
||||
WindowStyle windowStyle = (WindowStyle)values[1];
|
||||
ResizeMode resizeMode = (ResizeMode)values[2];
|
||||
|
||||
if (buttonName == CloseButtonName)
|
||||
{
|
||||
if (windowStyle != WindowStyle.None)
|
||||
{
|
||||
return Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (resizeMode != ResizeMode.NoResize
|
||||
&& (windowStyle == WindowStyle.SingleBorderWindow || windowStyle == WindowStyle.ThreeDBorderWindow))
|
||||
{
|
||||
return Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// use the default return value below
|
||||
}
|
||||
|
||||
return Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Szmedi.RevitToolkit.Approval.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a <see cref="WindowStyle" /> and icon of a window into a <see cref="Visibility" /> for the icon.
|
||||
/// </summary>
|
||||
public class WindowTitleBarIconVisibilityConverter : IMultiValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="WindowTitleBarIconVisibilityConverter" />.
|
||||
/// </summary>
|
||||
public WindowTitleBarIconVisibilityConverter() { }
|
||||
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (values != null && values.Length == 2)
|
||||
{
|
||||
object icon = values[0];
|
||||
WindowStyle windowStyle = (WindowStyle)values[1];
|
||||
|
||||
if (icon != null && (windowStyle == WindowStyle.SingleBorderWindow || windowStyle == WindowStyle.ThreeDBorderWindow))
|
||||
{
|
||||
return Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// use the default return value below
|
||||
}
|
||||
|
||||
return Visibility.Visible;
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Szmedi.RevitToolkit.Approval.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a <see cref="WindowStyle" /> of a window into a <see cref="Visibility" /> of the whole title bar.
|
||||
/// </summary>
|
||||
public class WindowTitleVisibilityConverter : IMultiValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="WindowTitleVisibilityConverter" />.
|
||||
/// </summary>
|
||||
public WindowTitleVisibilityConverter() { }
|
||||
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (values != null && values.Length >= 1)
|
||||
{
|
||||
WindowStyle windowStyle = (WindowStyle)values[0];
|
||||
|
||||
if (windowStyle != WindowStyle.None)
|
||||
{
|
||||
return Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// use the default return value below
|
||||
}
|
||||
|
||||
return Visibility.Visible;
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user