本文整理汇总了C#中Styles类的典型用法代码示例。如果您正苦于以下问题:C# Styles类的具体用法?C# Styles怎么用?C# Styles使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Styles类属于命名空间,在下文中一共展示了Styles类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Later_Styles_Should_Override_Earlier
public void Later_Styles_Should_Override_Earlier()
{
Styles styles = new Styles
{
new Style(x => x.OfType<Class1>().Class("foo"))
{
Setters = new[]
{
new Setter(Class1.FooProperty, "Foo"),
},
},
new Style(x => x.OfType<Class1>().Class("foo"))
{
Setters = new[]
{
new Setter(Class1.FooProperty, "Bar"),
},
}
};
var target = new Class1();
List<string> values = new List<string>();
target.GetObservable(Class1.FooProperty).Subscribe(x => values.Add(x));
styles.Attach(target);
target.Classes.Add("foo");
target.Classes.Remove("foo");
Assert.Equal(new[] { "foodefault", "Foo", "Bar", "foodefault" }, values);
}
示例2: DrawLabel
/// <summary>
/// Renders a label to the map.
/// </summary>
/// <param name="graphics">Graphics reference</param>
/// <param name="labelPoint">Label placement</param>
/// <param name="offset">Offset of label in screen coordinates</param>
/// <param name="font">Font used for rendering</param>
/// <param name="forecolor">Font forecolor</param>
/// <param name="backcolor">Background color</param>
/// <param name="halo">Color of halo</param>
/// <param name="rotation">Text rotation in degrees</param>
/// <param name="text">Text to render</param>
/// <param name="viewport"></param>
public static void DrawLabel(Graphics graphics, Point labelPoint, Offset offset, Styles.Font font, Styles.Color forecolor, Styles.Brush backcolor, Styles.Pen halo, double rotation, string text, IViewport viewport, StyleContext context)
{
SizeF fontSize = graphics.MeasureString(text, font.ToGdi(context)); //Calculate the size of the text
labelPoint.X += offset.X; labelPoint.Y += offset.Y; //add label offset
if (Math.Abs(rotation) > Constants.Epsilon && !double.IsNaN(rotation))
{
graphics.TranslateTransform((float)labelPoint.X, (float)labelPoint.Y);
graphics.RotateTransform((float)rotation);
graphics.TranslateTransform(-fontSize.Width / 2, -fontSize.Height / 2);
if (backcolor != null && backcolor.ToGdi(context) != Brushes.Transparent)
graphics.FillRectangle(backcolor.ToGdi(context), 0, 0, fontSize.Width * 0.74f + 1f, fontSize.Height * 0.74f);
var path = new GraphicsPath();
path.AddString(text, new FontFamily(font.FontFamily), (int)font.ToGdi(context).Style, font.ToGdi(context).Size, new System.Drawing.Point(0, 0), null);
if (halo != null)
graphics.DrawPath(halo.ToGdi(context), path);
graphics.FillPath(new SolidBrush(forecolor.ToGdi()), path);
//g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), 0, 0);
}
else
{
if (backcolor != null && backcolor.ToGdi(context) != Brushes.Transparent)
graphics.FillRectangle(backcolor.ToGdi(context), (float)labelPoint.X, (float)labelPoint.Y, fontSize.Width * 0.74f + 1, fontSize.Height * 0.74f);
var path = new GraphicsPath();
//Arial hack
path.AddString(text, new FontFamily("Arial"), (int)font.ToGdi(context).Style, (float)font.Size, new System.Drawing.Point((int)labelPoint.X, (int)labelPoint.Y), null);
if (halo != null)
graphics.DrawPath(halo.ToGdi(context), path);
graphics.FillPath(new SolidBrush(forecolor.ToGdi()), path);
//g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), LabelPoint.X, LabelPoint.Y);
}
}
示例3: Maps
public void Maps()
{
if (s_Styles == null)
{
s_Styles = new Styles();
}
GUI.changed = false;
if (Lightmapping.giWorkflowMode == Lightmapping.GIWorkflowMode.OnDemand)
{
SerializedObject obj2 = new SerializedObject(LightmapEditorSettings.GetLightmapSettings());
EditorGUILayout.PropertyField(obj2.FindProperty("m_LightingDataAsset"), s_Styles.LightingDataAsset, new GUILayoutOption[0]);
obj2.ApplyModifiedProperties();
}
GUILayout.Space(10f);
LightmapData[] lightmaps = LightmapSettings.lightmaps;
this.m_ScrollPositionMaps = GUILayout.BeginScrollView(this.m_ScrollPositionMaps, new GUILayoutOption[0]);
using (new EditorGUI.DisabledScope(true))
{
for (int i = 0; i < lightmaps.Length; i++)
{
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
GUILayout.FlexibleSpace();
GUILayout.Label(i.ToString(), new GUILayoutOption[0]);
GUILayout.Space(5f);
lightmaps[i].lightmapLight = this.LightmapField(lightmaps[i].lightmapLight, i);
GUILayout.Space(10f);
lightmaps[i].lightmapDir = this.LightmapField(lightmaps[i].lightmapDir, i);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
}
GUILayout.EndScrollView();
}
示例4: OnGUI
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
if (s_Styles == null)
{
s_Styles = new Styles();
}
Rect position = pos;
position.height = EditorGUIUtility.singleLineHeight;
SerializedProperty navigation = prop.FindPropertyRelative("m_Mode");
Navigation.Mode navigationMode = GetNavigationMode(navigation);
EditorGUI.PropertyField(position, navigation, s_Styles.navigationContent);
EditorGUI.indentLevel++;
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (navigationMode == Navigation.Mode.Explicit)
{
SerializedProperty property = prop.FindPropertyRelative("m_SelectOnUp");
SerializedProperty property3 = prop.FindPropertyRelative("m_SelectOnDown");
SerializedProperty property4 = prop.FindPropertyRelative("m_SelectOnLeft");
SerializedProperty property5 = prop.FindPropertyRelative("m_SelectOnRight");
EditorGUI.PropertyField(position, property);
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(position, property3);
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(position, property4);
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(position, property5);
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
EditorGUI.indentLevel--;
}
示例5: MapsuiBrushToXaml
public static XamlBrush MapsuiBrushToXaml(Styles.Brush brush, BrushCache brushCache = null)
{
if (brush == null) return null;
switch (brush.FillStyle)
{
case FillStyle.Cross:
return CreateHatchBrush(brush, 12, 10, new List<Geometry> { Geometry.Parse("M 0 0 l 10 10"), Geometry.Parse("M 0 10 l 10 -10") });
case FillStyle.BackwardDiagonal:
return CreateHatchBrush(brush, 10, 10, new List<Geometry> { Geometry.Parse("M 0 10 l 10 -10"), Geometry.Parse("M -0.5 0.5 l 10 -10"), Geometry.Parse("M 8 12 l 10 -10") });
case FillStyle.Bitmap:
return CreateImageBrush(brush, brushCache);
case FillStyle.Dotted:
return DottedBrush(brush);
case FillStyle.DiagonalCross:
return CreateHatchBrush(brush, 10, 10, new List<Geometry> { Geometry.Parse("M 0 0 l 10 10"), Geometry.Parse("M 0 10 l 10 -10") });
case FillStyle.ForwardDiagonal:
return CreateHatchBrush(brush, 10, 10, new List<Geometry> { Geometry.Parse("M -1 9 l 10 10"), Geometry.Parse("M 0 0 l 10 10"), Geometry.Parse("M 9 -1 l 10 10") });
case FillStyle.Hollow:
return new SolidColorBrush(Colors.Transparent);
case FillStyle.Horizontal:
return CreateHatchBrush(brush, 10, 10, new List<Geometry> { Geometry.Parse("M 0 5 h 10") });
case FillStyle.Solid:
return new SolidColorBrush(brush.Color != null ? brush.Color.ToXaml() : brush.Background != null ? brush.Color.ToXaml() : Colors.Transparent);
case FillStyle.Vertical:
return CreateHatchBrush(brush, 10, 10, new List<Geometry> { Geometry.Parse("M 5 0 l 0 10") });
default:
return (brush.Color != null) ? new SolidColorBrush(brush.Color.ToXaml()) : null;
}
}
示例6: OnGUI
private void OnGUI()
{
if (s_Styles == null)
{
s_Styles = new Styles();
base.minSize = new Vector2(450f, 300f);
base.position = new Rect(base.position.x, base.position.y, base.minSize.x, base.minSize.y);
}
GUILayout.Space(10f);
GUILayout.Label("#pragma implicit and #pragma downcast need to be added to following files\nfor backwards compatibility", new GUILayoutOption[0]);
GUILayout.Space(10f);
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
GUILayout.Space(10f);
IEnumerator enumerator = ListViewGUILayout.ListView(this.m_LV, s_Styles.box, new GUILayoutOption[0]).GetEnumerator();
try
{
while (enumerator.MoveNext())
{
ListViewElement current = (ListViewElement) enumerator.Current;
if ((current.row == this.m_LV.row) && (Event.current.type == EventType.Repaint))
{
s_Styles.selected.Draw(current.position, false, false, false, false);
}
GUILayout.Label(this.m_Paths[current.row], new GUILayoutOption[0]);
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable == null)
{
}
disposable.Dispose();
}
GUILayout.Space(10f);
GUILayout.EndHorizontal();
GUILayout.Space(10f);
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
GUILayout.FlexibleSpace();
if (GUILayout.Button("Fix now", s_Styles.button, new GUILayoutOption[0]))
{
base.Close();
PragmaFixing30.FixFiles(this.m_Paths);
GUIUtility.ExitGUI();
}
if (GUILayout.Button("Ignore", s_Styles.button, new GUILayoutOption[0]))
{
base.Close();
GUIUtility.ExitGUI();
}
if (GUILayout.Button("Quit", s_Styles.button, new GUILayoutOption[0]))
{
EditorApplication.Exit(0);
GUIUtility.ExitGUI();
}
GUILayout.Space(10f);
GUILayout.EndHorizontal();
GUILayout.Space(10f);
}
示例7: InitIfNeeded
void InitIfNeeded()
{
if (s_Styles == null)
s_Styles = new Styles();
if (_navigateToItemProvider == null)
_navigateToItemProvider = UnityEditorCompositionContainer.GetExportedValue<INavigateToItemProviderAggregator>();
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-CodeEditor-Unity-Technologies,代码行数:8,代码来源:NavigatorWindow.cs
示例8: Init
private void Init()
{
if (styles == null)
{
styles = new Styles();
}
this.InitShowOptions();
}
示例9: DrawRectangle
private static void DrawRectangle(Canvas canvas, RectF destination, Styles.Color outlineColor)
{
var paint = new Paint();
paint.SetStyle(Paint.Style.Stroke);
paint.Color = new AndroidColor(outlineColor.R, outlineColor.G, outlineColor.B, outlineColor.A);
paint.StrokeWidth = 4;
canvas.DrawRect(destination, paint);
}
示例10: VideoSettings
public VideoSettings()
{
WindowStyle = Styles.Default; // Titlebar + Resize + Close
WindowSettings = VideoMode.DesktopMode;
OpenGLSettings = new ContextSettings();
RefreshRate = 30;
}
示例11: OnPreviewGUI
public override void OnPreviewGUI(Rect r, GUIStyle background)
{
if (Event.current.type != EventType.Repaint)
return;
if (m_Styles == null)
m_Styles = new Styles();
GameObject go = target as GameObject;
RectTransform rect = go.transform as RectTransform;
if (rect == null)
return;
// Apply padding
RectOffset previewPadding = new RectOffset(-5, -5, -5, -5);
r = previewPadding.Add(r);
// Prepare rects for columns
r.height = EditorGUIUtility.singleLineHeight;
Rect labelRect = r;
Rect valueRect = r;
Rect sourceRect = r;
labelRect.width = kLabelWidth;
valueRect.xMin += kLabelWidth;
valueRect.width = kValueWidth;
sourceRect.xMin += kLabelWidth + kValueWidth;
// Headers
GUI.Label(labelRect, "Property", m_Styles.headerStyle);
GUI.Label(valueRect, "Value", m_Styles.headerStyle);
GUI.Label(sourceRect, "Source", m_Styles.headerStyle);
labelRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
valueRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
sourceRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
// Prepare reusable variable for out argument
ILayoutElement source = null;
// Show properties
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Width", LayoutUtility.GetLayoutProperty(rect, e => e.minWidth, 0, out source).ToString(), source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Height", LayoutUtility.GetLayoutProperty(rect, e => e.minHeight, 0, out source).ToString(), source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Width", LayoutUtility.GetLayoutProperty(rect, e => e.preferredWidth, 0, out source).ToString(), source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Height", LayoutUtility.GetLayoutProperty(rect, e => e.preferredHeight, 0, out source).ToString(), source);
float flexible = 0;
flexible = LayoutUtility.GetLayoutProperty(rect, e => e.flexibleWidth, 0, out source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Width", flexible > 0 ? ("enabled (" + flexible.ToString() + ")") : "disabled", source);
flexible = LayoutUtility.GetLayoutProperty(rect, e => e.flexibleHeight, 0, out source);
ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Height", flexible > 0 ? ("enabled (" + flexible.ToString() + ")") : "disabled", source);
if (!rect.GetComponent<LayoutElement>())
{
Rect noteRect = new Rect(labelRect.x, labelRect.y + 10, r.width, EditorGUIUtility.singleLineHeight);
GUI.Label(noteRect, "Add a LayoutElement to override values.", m_Styles.labelStyle);
}
}
示例12: GetBrush
/// <summary>
/// Gets the GDI brush.
/// </summary>
/// <param name="brush">The GDI brush.</param>
/// <returns></returns>
public System.Drawing.Brush GetBrush(Styles.Brush brush)
{
System.Drawing.Brush gdiBrush;
if (!brushes.TryGetValue(brush, out gdiBrush))
{
gdiBrush = new System.Drawing.SolidBrush(brush.Color.ToGdi());
}
return gdiBrush;
}
示例13: CreateBackground
private static Rectangle CreateBackground(Styles.Color color, int size)
{
return new Rectangle
{
Fill = color == null ? new SolidColorBrush(Colors.Transparent) : new SolidColorBrush(GetColor(color)),
Width = size,
Height = size
};
}
示例14: Game
public Game()
{
videoMode = new VideoMode(960, 540);
title = "SFML Game Window";
style = Styles.Close;
context = new ContextSettings();
ScreenManager = new ScreenManager();
}
示例15: Style
public Style(Styles style)
{
switch (style)
{
case Styles.MonoBlack:
CreateMonoBlack();
break;
}
}