public void Invalidate_Should_Invalidate_All_Layers() { var target = new Class1(); var layer1 = LayerContainer.Create("Layer1", target); var layer2 = LayerContainer.Create("Layer2", target); target.Layers = target.Layers.Add(layer1); target.Layers = target.Layers.Add(layer2); var workingLayer = LayerContainer.Create("WorkingLayer", target); var helperLayer = LayerContainer.Create("HelperLayer", target); target.WorkingLayer = workingLayer; target.HelperLayer = helperLayer; int count = 0; layer1.InvalidateLayer += (sender, e) => count++; layer2.InvalidateLayer += (sender, e) => count++; workingLayer.InvalidateLayer += (sender, e) => count++; helperLayer.InvalidateLayer += (sender, e) => count++; target.Invalidate(); Assert.Equal(4, count); }
/// <summary> /// Initialize new instance of <see cref="ToolRectangleSelection"/> class. /// </summary> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> /// <param name="point">The selection point shape.</param> public ToolRectangleSelection(LayerContainer layer, RectangleShape shape, ShapeStyle style, BaseShape point) { _layer = layer; _rectangle = shape; _style = style; _point = point; }
/// <summary> /// Initialize new instance of <see cref="ToolQuadraticBezierSelection"/> class. /// </summary> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> /// <param name="point">The selection point shape.</param> public ToolQuadraticBezierSelection(LayerContainer layer, IQuadraticBezier shape, ShapeStyle style, BaseShape point) { _layer = layer; _quadraticBezier = shape; _style = style; _point = point; }
public override void Initialize() { LayerContainer.AddAsChild(this); AddToPanel(AxisPanel); InvalidateVisual(); OnLoaded(); }
/// <summary> /// Initialize new instance of <see cref="ToolLineSelection"/> class. /// </summary> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> /// <param name="point">The selection point shape.</param> public ToolLineSelection(LayerContainer layer, ILine shape, ShapeStyle style, BaseShape point) { _layer = layer; _line = shape; _style = style; _point = point; }
/// <summary> /// Initialize new instance of <see cref="ToolArcSelection"/> class. /// </summary> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> /// <param name="point">The selection point shape.</param> public ToolArcSelection(LayerContainer layer, IArc shape, ShapeStyle style, BaseShape point) { _layer = layer; _arc = shape; _style = style; _point = point; }
public void SetSelected_Container() { var target = new ProjectContainer(); var document = DocumentContainer.Create(); target.Documents = target.Documents.Add(document); var page = PageContainer.CreatePage(); document.Pages = document.Pages.Add(page); var layer = LayerContainer.Create("Layer1", page); page.Layers = page.Layers.Add(layer); bool raised = false; layer.InvalidateLayer += (sender, e) => { raised = true; }; target.SetSelected(page); Assert.Equal(document, target.CurrentDocument); Assert.Equal(page, target.CurrentContainer); Assert.True(raised); }
public FCSuperResolution() { superres_enc_front = InputLayer.Create(StartSide, 3); superres_enc_back = ActivationLayer.Create <LeakyReLU>(); superres_enc_front.Append( FCLayer.Create(16, 16).Append( ActivationLayer.Create <LeakyReLU>().Append( FCLayer.Create(8, 8).Append( ActivationLayer.Create <LeakyReLU>().Append( FCLayer.Create(4, 4).Append( superres_enc_back )))))); superres_dec_front = InputLayer.Create(4, 4); superres_dec_back = ActivationLayer.Create <Tanh>(); superres_dec_front.Append( FCLayer.Create(8, 8).Append( ActivationLayer.Create <LeakyReLU>().Append( FCLayer.Create(16, 8).Append( ActivationLayer.Create <LeakyReLU>().Append( FCLayer.Create(32, 3).Append( superres_dec_back )))))); superres_enc_back.Append(superres_dec_front); //Initialize Weights superres_enc_front.SetupInternalState(); superres_enc_front.InitializeWeights(new UniformWeightInitializer(0, 0.001f)); }
private void RemoveControl() { LayerContainer.Focus(); LayerContainer.PreventMouseEvent(null); if (Popup) { _control.SaftyInvoke <Popup>(p => p.IsOpen = false); } else { if (_control == null) { return; } var panel = this.FindAncestor <Panel>(); if (panel == null || !panel.Children.Contains(_control)) { return; } panel.Children.Remove(_control); _control = null; } this.FindAncestor <Panel>().ReleaseMouseCapture(); }
/// <summary> /// Initialize new instance of <see cref="ToolEllipseSelection"/> class. /// </summary> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> /// <param name="point">The selection point shape.</param> public ToolEllipseSelection(LayerContainer layer, EllipseShape shape, ShapeStyle style, BaseShape point) { _layer = layer; _ellipse = shape; _style = style; _point = point; }
public void CreateDemoContainer(LayerContainerViewModel vm) { var container = new LayerContainer() { Width = 720, Height = 630, PrintBackground = new ArgbColor(0, 255, 255, 255), WorkBackground = new ArgbColor(255, 128, 128, 128), InputBackground = new ArgbColor(255, 211, 211, 211) }; var workingContainer = new LayerContainer(); var style = new ShapeStyle(new ArgbColor(255, 0, 255, 0), new ArgbColor(80, 0, 255, 0), 2.0, true, true); var pointShape = new EllipseShape(new PointShape(-4, -4, null), new PointShape(4, 4, null)) { Style = new ShapeStyle(new ArgbColor(0, 0, 0, 0), new ArgbColor(255, 255, 255, 0), 2.0, true, true) }; var guideTool = vm.Tools.FirstOrDefault(t => t.Title == "Guide") as GuideTool; container.Styles.Add(guideTool.Settings.GuideStyle); container.Styles.Add(pointShape.Style); container.Styles.Add(style); vm.CurrentContainer = container; vm.WorkingContainer = workingContainer; vm.CurrentStyle = style; vm.PointShape = pointShape; }
/// <summary> /// Initialize new instance of <see cref="ToolImageSelection"/> class. /// </summary> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> /// <param name="point">The selection point shape.</param> public ToolImageSelection(LayerContainer layer, ImageShape shape, ShapeStyle style, BaseShape point) { _layer = layer; _image = shape; _style = style; _point = point; }
/// <summary> /// Initialize new instance of <see cref="ToolTextSelection"/> class. /// </summary> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> /// <param name="point">The selection point shape.</param> public ToolTextSelection(LayerContainer layer, TextShape shape, ShapeStyle style, BaseShape point) { _layer = layer; _text = shape; _style = style; _point = point; }
private void load(DrawableHitObject drawableObject, ISkinSource skin, IScrollingInfo scrollingInfo) { InternalChildren = new[] { background = createLayer("Background layer", skin, LegacyKaraokeSkinNoteLayer.Background), foreground = createLayer("Foreground layer", skin, LegacyKaraokeSkinNoteLayer.Foreground), border = createLayer("Border layer", skin, LegacyKaraokeSkinNoteLayer.Border) }; direction.BindTo(scrollingInfo.Direction); direction.BindValueChanged(OnDirectionChanged, true); if (drawableObject != null) { var holdNote = (DrawableNote)drawableObject; isHitting.BindTo(holdNote.IsHitting); display.BindTo(holdNote.DisplayBindable); singer.BindTo(holdNote.SingersBindable); } AccentColour.BindValueChanged(onAccentChanged); HitColour.BindValueChanged(onAccentChanged); isHitting.BindValueChanged(onIsHittingChanged, true); display.BindValueChanged(_ => onAccentChanged(), true); singer.BindValueChanged(value => applySingerStyle(skin, value.NewValue), true); }
private void TraceCurrentMousePoint(MouseEventArgs e) { var currentPoint = LayerContainer.GetMousePosition(true); // 防止 currentPoint 不让其超出控件 renderSize 范围 var x = Math.Max(currentPoint.X, 0); var y = Math.Max(currentPoint.Y, 0); var startAutoScrollTimer = false; if (_autoScrollTimer == null || !_autoScrollTimer.IsEnabled) { startAutoScrollTimer = AutoScroll(); } if (startAutoScrollTimer) { _autoScrollTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.3) }; _autoScrollTimer.Tick += delegate { if (e.LeftButton == MouseButtonState.Pressed && AutoScroll()) { SetCurrentMousePoint(e); MeasureDragingArea(_screenDataRowIndex); return; } LayerContainer.ReleaseMouseCapture(); _autoScrollTimer.Stop(); }; _autoScrollTimer.Start(); } _currentPoint = new Point(x, y); }
public DGAN() { discriminator = InputLayer.Create(StartSide, 1); discriminator_back = ActivationLayer.Create <Sigmoid>(); discriminator.Append( FCLayer.Create(1, 256).Append( ActivationLayer.Create <LeakyReLU>().Append( FCLayer.Create(1, 1).Append( discriminator_back )))); generator = InputLayer.Create(1, LatentSize); generator_back = ActivationLayer.Create <Tanh>(); generator.Append( FCLayer.Create(1, 256).Append( ActivationLayer.Create <LeakyReLU>().Append( DropoutLayer.Create(0.5f).Append( FCLayer.Create(1, 512).Append( ActivationLayer.Create <LeakyReLU>().Append( DropoutLayer.Create(0.5f).Append( FCLayer.Create(1, OutputSize).Append( generator_back )))))))); //Initialize Weights discriminator.SetupInternalState(); discriminator.InitializeWeights(new UniformWeightInitializer(3, 0)); generator.SetupInternalState(); generator.InitializeWeights(new UniformWeightInitializer(1, 0)); }
protected override void OnParentMouseUp(object sender, MouseButtonEventArgs e) { if (_isMouseMove || IsDraging) { //do nothing } //else if (ClickCount < 2) // don't remove 这会影响EditControlLayer double click 编辑弹出框 //{ SetCurrentMousePoint(e); if (LayerContainer.HeaderIsHitted()) // Column 全選 IsHeader(e.Source) { _screenDataRowIndex = 0; _startPoint = new Point(LayerContainer.GetMousePosition(true).X, 0); _currentPoint = new Point(_startPoint.X, GetItemsSourceCount() * Interval); SetInitalDrawLocation(); } MeasureDragingArea(_screenDataRowIndex); e.Handled = true; InvalidateVisual(); //} IsDraging = false; _isMouseMove = false; //xe.Handled = !AxisYConverter.IsInViewRagne(_currentPoint.Y); OnRangeSelected(); }
protected override void OnParentMouseDown(object sender, MouseButtonEventArgs e) { if (e.Source.IsNot <Rectangle>() && e.Source.IsNot <BlockGrid>()) { return; } _screenDataRowIndex = AxisPanel.GetScreenTopRowIndex(); if (Keyboard.Modifiers == ModifierKeys.Shift && _startPoint != _unsetPoint && _currentPoint != _unsetPoint) { //只有一个选中 //if (_startPoint == _currentPoint) //{ _currentPoint = LayerContainer.GetMousePosition(true); //} //else //已经选中多个 //{ //_startPoint = _currentPoint; //} } else { _startPoint = LayerContainer.GetMousePosition(true); _currentPoint = _startPoint; } //ClickCount = e.ClickCount; SetInitalDrawLocation(); }
/// <summary> /// Initialize new instance of <see cref="ToolPathSelection"/> class. /// </summary> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> /// <param name="point">The selection point shape.</param> public ToolPathSelection(LayerContainer layer, PathShape shape, ShapeStyle style, BaseShape point) { _layer = layer; _path = shape; _style = style; _point = point; }
protected override void OnParentMouseUp(object sender, MouseButtonEventArgs e) { //当Popup点中ListBox选项代表结束编辑,保存 if (Popup && !EditControlIsClosed() && e.Source == _control.SaftyGetProperty <UIElement, Popup>(o => o.Child, () => _control)) { e.Handled = TryEndEdit(Key.Enter); //为了不让其选中其他Cell必须在此跳出 return; } if (!Popup && _control != null && _editCell != InitalDrawLocation) { //int32EditBox进入编辑状态, 鼠标点其他Cell , 必须执行修改动作 TryEndEdit(Key.Enter); } base.OnParentMouseUp(sender, e); if (Popup && _editCell != InitalDrawLocation && _editCell != null) { //因为双击事件会导致重新进入OnParentMouseUp, 所以需要识别InitalDrawLocation是不是点中一样的Cell, 如果点到其他Cell, 必须将Popup关闭 RemoveControl(); _editCell = null; } if (_editCell != InitalDrawLocation && EditControlIsClosed()) // 为了让键盘事件能够捕捉,必须LayerContainer设为焦点 { LayerContainer.Focus(); } }
private void DeInitialize() { if (_layer != null) { _layer.InvalidateLayer -= Invalidate; _layer = default(LayerContainer); } }
public ConvSuperResolution() { superres_enc_front = InputLayer.Create(StartSide, 3); superres_enc_back = ActivationLayer.Create <ReLU>(); var pooling_0 = PoolingLayer.Create(2, 2); var pooling_1 = PoolingLayer.Create(2, 2); var pooling_2 = PoolingLayer.Create(2, 2); var pooling_3 = PoolingLayer.Create(2, 2); superres_enc_front.Append( ConvLayer.Create(5, 128, 2).Append( //o = 96 ActivationLayer.Create <ReLU>().Append( pooling_0.Append( //o = 48 ConvLayer.Create(3, 128, 1).Append( //o = 48 ActivationLayer.Create <ReLU>().Append( pooling_1.Append( //o = 24 ConvLayer.Create(3, 64, 1).Append( //o = 24 ActivationLayer.Create <ReLU>().Append( pooling_2.Append( //o = 12 ConvLayer.Create(3, 32, 1).Append( //o = 12 ActivationLayer.Create <ReLU>().Append( pooling_3.Append( //o = 6 ConvLayer.Create(3, 32, 1).Append( //o = 6 superres_enc_back )))))))))))))); superres_dec_front = InputLayer.Create(6, 32); superres_dec_back = ActivationLayer.Create <Tanh>(); superres_dec_front.Append( ConvLayer.Create(3, 32, 1).Append( //o = 6 ActivationLayer.Create <ReLU>().Append( UnpoolingLayer.Create(pooling_3).Append( //o = 12 ConvLayer.Create(3, 64, 1).Append( //o = 12 ActivationLayer.Create <ReLU>().Append( UnpoolingLayer.Create(pooling_2).Append( //o = 24 ConvLayer.Create(3, 128, 1).Append( //o = 24 ActivationLayer.Create <ReLU>().Append( UnpoolingLayer.Create(pooling_1).Append( //o = 48 ConvLayer.Create(3, 128, 1).Append( //o = 48 ActivationLayer.Create <ReLU>().Append( UnpoolingLayer.Create(pooling_0).Append( //o = 96 ConvLayer.Create(5, 3, 2).Append( //o = 96 superres_dec_back )))))))))))))); superres_enc_back.Append(superres_dec_front); //TODO: come up with an approach that saves the convolution/multiplication indexes and rearranges the weights etc so they fit into cache better //TODO: unpooling layer tied to pooling layers //Initialize Weights superres_enc_front.SetupInternalState(); superres_enc_front.InitializeWeights(new UniformWeightInitializer(0, 0.001f)); }
/// <summary> /// Clear layer. /// </summary> /// <param name="project">The project instance.</param> /// <param name="layer">The layer instance.</param> public static void ClearLayer(this ProjectContainer project, LayerContainer layer) { if (layer != null) { var previous = layer.Shapes; var next = ImmutableArray.Create <BaseShape>(); project?.History?.Snapshot(previous, next, (p) => layer.Shapes = p); layer.Shapes = next; } }
/// <summary> /// Add shape at specified index. /// </summary> /// <param name="project">The project instance.</param> /// <param name="layer">The layer instance.</param> /// <param name="shape">The shape instance.</param> /// <param name="index">The shape index.</param> public static void AddShapeAt(this ProjectContainer project, LayerContainer layer, BaseShape shape, int index) { if (layer?.Shapes != null && shape != null) { var previous = layer.Shapes; var next = layer.Shapes.Insert(index, shape); project?.History?.Snapshot(previous, next, (p) => layer.Shapes = p); layer.Shapes = next; } }
/// <summary> /// Remove shape. /// </summary> /// <param name="project">The project instance.</param> /// <param name="layer">The layer instance.</param> /// <param name="shape">The shape instance.</param> public static void RemoveShape(this ProjectContainer project, LayerContainer layer, BaseShape shape) { if (layer?.Shapes != null && shape != null) { var previous = layer.Shapes; var next = layer.Shapes.Remove(shape); project?.History?.Snapshot(previous, next, (p) => layer.Shapes = p); layer.Shapes = next; } }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } DrawSpace.Dispose(); LayerContainer.Dispose(); History.Dispose(); base.Dispose(disposing); }
protected override void OnParentKeyUp(object sender, KeyEventArgs e) { if (_spaceKeyPressed) { LayerContainer.PreventMouseEvent(null); _spaceKeyPressed = false; Cursor = Cursors.Arrow; Mouse.OverrideCursor = Cursors.Arrow; ReleaseMouseCapture(); } }
public static LayerContainer Create(LayerContainer pooling) { if (pooling.CurrentLayer is PoolingLayer) { return(new LayerContainer(new UnpoolingLayer((pooling.CurrentLayer as PoolingLayer).stride, (pooling.CurrentLayer as PoolingLayer).filter_side, (pooling.CurrentLayer as PoolingLayer)))); } else { throw new ArgumentException("Argument must be a PoolingLayer"); } }
public void SetSelected_Layer() { var target = new ProjectContainer(); var page = new PageContainer(); var layer = LayerContainer.Create("Layer1", page); target.SetSelected(layer); Assert.Equal(layer, page.CurrentLayer); }
protected override void OnParentMouseMove(object sender, MouseEventArgs e) { if (_canMove && e.LeftButton == MouseButtonState.Pressed && PointOutBlock != null) //Henry modified: e.LeftButton == MouseButtonState.Pressed { MouseMoving(e.GetPosition(this)); InvalidateVisual(); e.Handled = true; LayerContainer.Focus(); } }
public static void Main() { HostWindow window = new HostWindow(delegate { // Create a layer container LayerContainer lc = new LayerContainer(); // Create a form with many buttons { FlowContainer flow = new FlowContainer(10.0, Axis.Vertical); for (int t = 0; t < 40; t++) { int i = t + 1; Button b = new Button("Button #" + i.ToString()); flow.AddChild(b, 30.0); b.Click += delegate { MessageBox.ShowOKCancel(lc, "Button Clicked!", "You have clicked button #" + i.ToString() + ".", null); }; } Point targetflowsize = new Point(120.0, flow.SuggestLength); MarginContainer margin = flow.WithMargin(10.0); Point targetmarginsize = margin.GetSize(targetflowsize); WindowContainer win = new WindowContainer(margin); SunkenContainer sunken = new SunkenContainer(win); ScrollContainer scroll = new ScrollContainer(win, sunken.WithBorder(1.0, 1.0, 0.0, 1.0)); scroll.ClientHeight = targetmarginsize.Y; Form form = new Form(scroll, "Lots of buttons"); form.ClientSize = new Point(targetmarginsize.X + 20.0, 200.0); lc.AddControl(form, new Point(30.0, 30.0)); } // Popup test { Label label = new Label("Right click for popup", Color.RGB(0.0, 0.3, 0.0), new LabelStyle() { HorizontalAlign = TextAlign.Center, VerticalAlign = TextAlign.Center, Wrap = TextWrap.Ellipsis }); PopupContainer pc = new PopupContainer(label); pc.ShowOnRightClick = true; pc.Items = new MenuItem[] { MenuItem.Create("Do nothing", delegate { }), MenuItem.Create("Remain inert", delegate { }), MenuItem.Create("Make a message box", delegate { MessageBox.ShowOKCancel(lc, "Message Box", "Done", null); }), MenuItem.Seperator, MenuItem.Create("Mouseover me!", new MenuItem[] { MenuItem.Create("Some", delegate { }), MenuItem.Create("Items", delegate { }), MenuItem.Create("Spawn", delegate { }), MenuItem.Create("Another", delegate { }), MenuItem.Create("Popup", delegate { }), }), MenuItem.Seperator, MenuItem.Create("Try", delegate { }), MenuItem.Create("The", delegate { }), MenuItem.Create("Keyboard", delegate { }), }; Form form = new Form(pc.WithAlign(label.SuggestSize, Align.Center, Align.Center).WithBorder(1.0), "Popup Test"); form.ClientSize = new Point(200.0, 50.0); lc.AddControl(form, new Point(230.0, 30.0)); form.AddCloseButton(); } // Timers and progress bars { FlowContainer flow = new FlowContainer(10.0, Axis.Vertical); Button addbutton = new Button("Add Some"); Button resetbutton = new Button("Reset"); Progressbar bar = new Progressbar(); flow.AddChild(addbutton, 30.0); flow.AddChild(resetbutton, 30.0); flow.AddChild(bar, 30.0); addbutton.Click += delegate { bar.Value = bar.Value + 0.05; }; resetbutton.Click += delegate { bar.Value = 0.0; }; MarginContainer margin = flow.WithMargin(20.0); Form form = new Form(margin.WithBorder(1.0), "Progress bars!"); form.ClientSize = margin.GetSize(new Point(200.0, flow.SuggestLength)) + new Point(4, 4); lc.AddControl(form, new Point(230.0, 150.0)); form.AddCloseButton(); } // Textbox { Textbox tb = new Textbox(); MarginContainer margin = tb.WithMargin(20.0); Form form = new Form(margin.WithBorder(1.0), "Change the title of this form!"); form.ClientSize = margin.GetSize(new Point(400.0, 32.0)); lc.AddControl(form, new Point(30.0, 360.0)); tb.TextChanged += delegate(string Text) { form.Text = Text; }; } return lc; }, "Lots of controls"); window.Run(); }