windows [window].OnKeyDown (new KeyEventArgs (key, scanCode, modifiers));
};
static CharDelegate HandleCharDelegate = (IntPtr window, CodePoint codepoint) => {
- Console.WriteLine ($"Char: cp:{codepoint.Value} -> '{codepoint}'");
+ //Console.WriteLine ($"Char: cp:{codepoint.Value} -> '{codepoint}'");
windows [window].OnKeyPress (codepoint.ToChar());
};
static WindowSizeDelegate HandleWindowSizeDelegate = (IntPtr window, int Width, int Height) => {
/// </summary>
public void Update(IContext ctx = null){
- CrowThread[] tmpThreads;
+ /*CrowThread[] tmpThreads;
lock (CrowThreads) {
tmpThreads = new CrowThread[CrowThreads.Count];
Array.Copy (CrowThreads.ToArray (), tmpThreads, CrowThreads.Count);
}
for (int i = 0; i < tmpThreads.Length; i++)
- tmpThreads [i].CheckState ();
+ tmpThreads [i].CheckState ();*/
if (lastMouseDownEvent != null) {
if (mouseRepeatTimer.ElapsedMilliseconds > DEVICE_REPEAT_INTERVAL) {
}
void resetTooltip ()
{
- lock (tooltipMutex) {
+ lock (tooltipMutex) {//TODO:deadlock
if (tooltipVisible) {
ToolTipContainer.LayoutChanged -= ToolTipContainer_LayoutChanged;
ToolTipContainer.DataSource = null;
public override void onMouseClick (object sender, MouseButtonEventArgs e)
{
- IsChecked = !IsChecked;
- e.Handled = true;
+ if (Focusable) {
+ IsChecked = !IsChecked;
+ e.Handled = true;
+ }
base.onMouseClick (sender, e);
}
}
/// </remarks>
public class Image : Scalable
{
+ static readonly byte[] pngMagic = new byte[] {0x89, 0x50 ,0x4e ,0x47 ,0x0d ,0x0a};
Picture _pic;
string _svgSub;
/// Initializes a new instance of the <see cref="Crow.Image"/> class from code
/// </summary>
/// <param name="iface">interface to bound to</param>
- public Image (Interface iface) : base(iface)
- {
- }
+ public Image (Interface iface, string style = null) : base(iface, style) { }
#endregion
#region Image Loading
if (getcontenttype.Wait(HTTP_DOWNLOAD_TIMEOUT_MS) && getcontenttype.IsCompletedSuccessfully) {
if (!getcontenttype.Result.Content.Headers.TryGetValues("content-Type", out IEnumerable<string> contents))
return;
- string[] type = contents.FirstOrDefault().Split('/');
- if (!string.Equals(type[0], "image", StringComparison.Ordinal))
+ string[] type = contents.FirstOrDefault().Split('/');
+ if (string.Equals(contents.FirstOrDefault(), "application/octet-stream")) {
+ if (task.Wait(HTTP_DOWNLOAD_TIMEOUT_MS) && task.IsCompletedSuccessfully) {
+ MemoryStream dataCopy = new MemoryStream();
+ task.Result.CopyTo(dataCopy);
+ dataCopy.Position = 0;
+ Span<byte> magic = stackalloc byte[6];
+ dataCopy.Read(magic);
+ if (magic.SequenceEqual(pngMagic)) {
+ dataCopy.Position = 0;
+ pic = new BmpPicture(uri.AbsoluteUri);
+ } else
+ return;
+ pic.LoadFromStream(IFace, dataCopy);
+ pic.Scaled = scaled;
+ pic.KeepProportions = keepProps;
+ lock(IFace.UpdateMutex)
+ Picture = pic;
+ }
+ return;
+ } else if (!string.Equals(type[0], "image", StringComparison.Ordinal))
return;
if (string.Equals(type[1], "svg", StringComparison.Ordinal))
pic = new SvgPicture(uri.AbsoluteUri);
lock(IFace.UpdateMutex)
Picture = pic;
}
+ } else {
+ Debug.WriteLine("image downloadThread: get content failed");
}
}
Rectangle r = ClientRectangle;
+ gr.Operator = Operator.Over;
+
if (Foreground != null) {//TODO:test if null should be removed
Foreground.SetAsSource (IFace, gr, r);
CairoHelpers.CairoRectangle (gr, r, CornerRadius);
--- /dev/null
+<ColorPicker Height="Fit" Width="Fit">
+ <Template>
+ <VerticalStack >
+ <HorizontalStack Height="Fit" Margin="0">
+ <Label2 Text="{../svs.V}" Foreground="White"/>
+ <Label2 Text="{../svs.S}" Foreground="White"/>
+ </HorizontalStack>
+ <HorizontalStack Height="200" Margin="0">
+ <SaturationValueSelector Name="svs" V="10" S="0" Width="200" Height="200" Margin="0"
+Foreground="RebeccaPurple" Background="Transparent"/>
+ <HueSelector Orientation="Vertical" Width="20" Margin="0"/>
+ </HorizontalStack>
+ </VerticalStack>
+ </Template>
+</ColorPicker>
\ No newline at end of file
</HorizontalStack>
</Template>
</CheckBox>
- <CheckBox Background="Jet" Height="30" Width="60"
+ <CheckBox Background="Jet" Height="30" Width="60" IsChecked="{²BoolVal}"
Checked="{sh.HorizontalAlignment=Right};{Background=SeaGreen}"
Unchecked="{sh.HorizontalAlignment=Left};{Background=Jet}">
<Template>
</Group>
</Template>
</CheckBox>
-
+ <CheckBox Caption="Ok" Background="Transparent" Height="30" Width="30" IsChecked="{²BoolVal}" CornerRadius="10"
+ Checked="{Background=SeaGreen}"
+ Unchecked="{Background=Red}">
+ <Template>
+ <Label2 Background="{./Background}" Text="{./Caption}" Margin="5" CornerRadius="{./CornerRadius}"/>
+ </Template>
+ </CheckBox>
</VerticalStack>