if (item != null
&& item.GetType().GetInterfaces().Any(
i => i.IsGenericType
&& i.GetGenericTypeDefinition() == typeof(IEnumerable<>))
)
{
IEnumerable<object> collection = (IEnumerable<object>)item;
} public class MyForm : Form
{
protected override void WndProc(ref Message m)
{
if(m.Msg == WM_MOUSEWHEEL)
{
// ...
return;
};
base.WndProc(ref m);
}
} Zenject зачем добавлять к SceneLoader наследование от ISceneLoader
чтобы потом указывать ISceneLoader как тип
хотя если указать просто SceneLoader как тип ничего не изменится
public interface IFoo
{
public string Name { get; set; }
}
public class Bar1(string name) : IFoo
{
public string Name { get; set; } = name;
}
public class Bar2(string name) : IFoo
{
public string Name { get; set; } = name;
}List<IFoo> list = [
new Bar1("Bar 1"),
new Bar2("Bar 2")
];
foreach (IFoo foo in list)
{
Console.WriteLine(foo.Name);
}Bar 1
Bar 2public System.Windows.Media.ImageSource Source { get; set; }TestImage2.Source = new BitmapImage(LoadedUri);Uri, а в тип BitmapImage. Ну или просто завести сразу свойство нужного типа.var LoadedUri = (Uri)stringToUriConverter.Convert(a, typeof(BitmapImage), null, CultureInfo.CurrentCulture);Grid с добавленными свойствами шаблонов для заголовков и ячеек, а так же своим движком для рендернинга таблицы (строк, столбцы, заголовки). Main поймать нельзя.Exception и указывая параметры исключений /// <summary>
/// Localized exception
/// </summary>
/// <param name="stringId">i18n string Id</param>
/// <param name="args">String arguments for format</param>
public class I18nException(string stringId, object[] args)
: Exception(
string.Format(
I18n($"{ExceptionId} {stringId}"),
args))
{
public readonly object[] Args = args;
public readonly string StringId = stringId;
private const string ExceptionId = "Exception";
}I18n(string str) - функция для получения локализованной строки для текущего языка приложения. public class ElementNotFoundException(Type type, string name)
: I18nException(
"Element not found",
[type.FullName, name]
)
{
public readonly string ElementName = name;
public readonly Type ElementType = type;
}(тыц). перевод игры лежит в отдельном файле(например json и хранит в себе каждую строчку текста, которая применяется в игре), и потом в коде запрашивать нужную строку из файла и брать от туда значение текста для последующего применения на сцене
или есть способы попроще
public static class Native
{
[DllImport("user32.dll")]
private static extern bool GetWindowRect(IntPtr hwnd, ref RECT rectangle);
[DllImport("user32.dll")]
private static extern bool GetClientRect(IntPtr hwnd, ref RECT rectangle);
public RECT GetWindowPos(IntPtr hwnd)
{
var r = new RECT();
GetWindowRect(hwnd, ref r);
return r;
}
public RECT GetClientPos(IntPtr hwnd)
{
var r = new RECT();
GetClientRect(hwnd, ref r);
return r;
}
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct RECT(int left, int top, int right, int bottom)
{
public int Left = left;
public int Top = top;
public int Right = right;
public int Bottom = bottom;
public readonly int Width => Right - Left;
public readonly int Height => Bottom - Top;
}
}RenderSize и ActualWidth/ActualHeight будут после вычисления положения самого элемента. Скорее всего вы слишком рано пытаетесь получить к ним доступ. Запустите ваше приложение и в отладчике посмотрите в дереве окон значения.public class MyControl : Control
{
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
// Размеры и позиция элемента вычислены и он готов к работе
}
}