Skip to content

Instantly share code, notes, and snippets.

@SpacePurr
SpacePurr / .cs
Created February 14, 2020 07:27
CancellationToken
public class MainViewModel : BaseViewModel
{
private CancellationTokenSource cancellation;
#region mvvm
private string _text;
public string Text
{
get => _text;
set
@SpacePurr
SpacePurr / .xaml
Created January 28, 2020 17:53
Xaml. ToggleButton Transparent Style
<Style x:Key="TransparentStyleToggle" TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton" >
<Border Background="Transparent" Name="Border" >
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Border" Property="Background" Value="#FF8CB3EE"/>
@SpacePurr
SpacePurr / .xaml
Created January 28, 2020 17:43
Xaml. Button Transparent Style
<Style x:Key="TransparentStyle" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button" >
<Border Background="Transparent" Name="Border" >
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Border" Property="Background" Value="#FF8CB3EE"/>
@SpacePurr
SpacePurr / .cs
Last active January 28, 2020 11:24
Stopwatch
var startTime = System.Diagnostics.Stopwatch.StartNew();
//Выполняемый код
startTime.Stop();
var resultTime = startTime.Elapsed;
var elapsedTime = $"{resultTime.Hours:00}:{resultTime.Minutes:00}:{resultTime.Seconds:00}.{resultTime.Milliseconds:000}";
@SpacePurr
SpacePurr / .cs
Last active January 21, 2020 14:42
ColorBox
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using TDMS3DControl.Commands;
using TDMS3DControl.Models;
using TDMS3DControl.Views;
namespace TDMS3DControl.ViewModels
@SpacePurr
SpacePurr / .cs
Last active January 21, 2020 14:40
Покраска цвета Xbim 3D Control
//Покрасить элеменет
public void ChangeColorInIfc(string currentColor, IfcProduct ifcProd)
{
int entityLabel = ifcProd.EntityLabel;
//Метод сохранения
//Передаваться будет только выбранный цвет из Dictionary StatusColors
using (var txn = Model.BeginTransaction("Set Style"))
{
//Получаем сет CSoft_Colors