//public static Widget DropDown(IEnumerable<string> items, PopInOut pop_in_out_behavior = null) //{ // WidgetList widgets = new WidgetList(); // foreach (string item in items) widgets.Add(new Widget().WithAddedBehavior(new DrawText() { Text = item, ConstrainAreaToText = true })); // return DropDown(widgets, pop_in_out_behavior); //} public static Widget DropDown( IEnumerable <Widget> widgets, PopInOut pop_in_out_behavior = null ) { var widgets_ = widgets.ToList(); var dropdown = new Widget(); dropdown.VisualSettings.VisualRole = VisualRoleType.pop_up; dropdown.Behaviors.GroupBehaviors.AcceptancePolicy += GroupBehaviorAcceptancePolicy.NoUserScrolling; dropdown.MinimumSize = new Point2(1f, 1f); dropdown.AddRange(widgets_); dropdown.Behaviors.Add(new GridFormat(1, widgets_.Count)); dropdown.Behaviors.Add( pop_in_out_behavior ?? new PopInOut( RectanglePart.Uniform(0.95f, Directions2D.DLR), RectanglePart.Uniform(0f, Directions2D.D, 1f) ) { OpeningMotion = InterpolationSettings.Fast, ClosingMotion = InterpolationSettings.Faster } ); return(dropdown); }
internal override void MouseClick(PointF location) { switch (m_ClickNumber) { case 0: { m_FirstClick = location; } break; case 1: { if (OnNewSymbolPart != null) { //GraphicsPath path = new GraphicsPath(); //path.AddRectangle(new RectangleF(m_FirstClick.X, m_FirstClick.Y, // location.X - m_FirstClick.X, location.Y - m_FirstClick.Y)); SymbolPart part = new RectanglePart(m_FirstClick.X, m_FirstClick.Y, location.X, location.Y); OnNewSymbolPart(this, new NewSymbolPartEventArgs(part)); } } break; default: break; } m_ClickNumber = ++m_ClickNumber % 2; }
public void GetEnumerator_ReturnsEnumeratorForAllItemsInRound() { // arrange var basicArray = new[, ] { { 01, 02, 03, 04, 05, 06 }, { 11, 12, 13, 14, 15, 16 }, { 21, 22, 23, 24, 25, 26 }, { 31, 32, 33, 34, 35, 36 }, { 41, 42, 43, 44, 45, 46 }, { 51, 52, 53, 54, 55, 56 }, }; var rectangle = new RectanglePart <int>( basicArray, new Vector(0, 1), new Vector(3, 3)); // act var collection = rectangle.ToArray(); // assert var expectation = new[] { 02, 03, 04, 12, 13, 14, 22, 23, 24, 32, 33, 34 }; Assert.True(expectation.All(n => collection.Contains(n))); Assert.Equal(expectation.Length, collection.Length); }
public object Clone() { RectanglePart c = new RectanglePart(); c.Indents = (GenericDirections2D <float>)Indents.Clone(); return(c); }
private SymbolPartData ConvertSymbolPart(SymbolPart symbolPart) { if (symbolPart is LinePart) { LinePart linePart = (LinePart)symbolPart; PointF p1 = linePart.GetPoint(0); PointF p2 = linePart.GetPoint(1); return(new SymbolLineData(p1.X, p1.Y, p2.X, p2.Y)); } if (symbolPart is RectanglePart) { RectanglePart rectPart = (RectanglePart)symbolPart; return(new SymbolRectData(rectPart.Location.X, rectPart.Location.Y, rectPart.Width, rectPart.Height)); } if (symbolPart is TextPart) { TextPart textPart = (TextPart)symbolPart; return(new SymbolTextData(textPart.Location.X, textPart.Location.Y, textPart.Text)); } if (symbolPart is PortPart) { PortPart portPart = (PortPart)symbolPart; return(new SymbolPortData(portPart.Location.X, portPart.Location.Y, portPart.Angle, portPart.Direction, portPart.Name)); } return(null); }
public PopInOut( RectanglePart opening_indent, RectanglePart closing_indent = null ) { OpeningIndent = (RectanglePart)opening_indent.Clone(); ClosingIndent = closing_indent != null ? (RectanglePart)closing_indent.Clone() : (RectanglePart)opening_indent.Clone(); Mode = PopInOutModeType.use_indent; }
public static RectangleF ResizedBy( this RectangleF me, RectanglePart part ) { var resize = new BorderSize( me.Height * -(1f - part.Indents.Up), me.Height * -(1f - part.Indents.Down), me.Width * -(1f - part.Indents.Left), me.Width * -(1f - part.Indents.Right) ); return(me.ResizedBy(resize)); }
private void CombineTest2() { var source1 = new List <RectanglePart>() { new RectanglePart("r1", 8, 3), new RectanglePart("r2", 2, 3), new RectanglePart("r3", 6, 3), }; var target = new RectanglePart("rt", 10, 6); var factory = new RectanglePartCombineFactory(); factory.Combine(source1, target); }
public void CombineTest1() { var source1 = new List <RectanglePart>() { new RectanglePart("r1", 8, 3), new RectanglePart("r2", 2, 3), new RectanglePart("r3", 6, 3), new RectanglePart("r4", 4, 3), }; var target = new RectanglePart("rt", 10, 6); var factory = new RectanglePartCombineFactory(); factory.Combine(source1, target); //is correct result //Combined result //Name: r1 X:0 Y: 0 Width: 8 Height: 3 //Name: r3 X:0 Y: 3 Width: 6 Height: 3 //Name: r4 X:6 Y: 3 Width: 4 Height: 3 //Name: r2 X:8 Y: 0 Width: 2 Height: 3 var r1 = factory.SourceList.Where(h => h.Name == "r1").SingleOrDefault(); var r2 = factory.SourceList.Where(h => h.Name == "r2").SingleOrDefault(); var r3 = factory.SourceList.Where(h => h.Name == "r3").SingleOrDefault(); var r4 = factory.SourceList.Where(h => h.Name == "r4").FirstOrDefault(); if ( r1 != null && r1.X == 0 && r1.Y == 0 && r2 != null && r2.X == 8 && r2.Y == 0 && r3 != null && r3.X == 0 && r3.Y == 3 && r4 != null && r4.X == 6 && r4.Y == 3 ) { Console.WriteLine("correct result"); } else { Assert.Fail("error result"); } }
public static Widget LoginWindow( Action <LoginSignal> confirm_handle, Action <CreateAccountSignal> handle_account_creation = null ) { const int login_create_spacing = 8 / 2; var window = new Widget { Size = new Point2(400, 300), Name = "Login Window" }; window.VisualSettings.VisualRole = GeneralVisualSettings.VisualRoleType.pop_up; window.Behaviors.Add(new CenterContent()); window.Behaviors.Add(new PinWidget { Pin = InnerWidgetLocation.Centered }); window.Behaviors.Add(new PopInOut(RectanglePart.Uniform(0.975f), RectanglePart.Uniform(0.5f)) { OpeningMotion = InterpolationSettings.Fast, ClosingMotion = InterpolationSettings.Fast }); var username_entry = CommonWidgets.SingleLineTextEntry("", DrawText.XTextPositioningPolicy.left, DrawText.YTextPositioningPolicy.center, 8f); var password_entry = CommonWidgets.SingleLineTextEntry("", DrawText.XTextPositioningPolicy.left, DrawText.YTextPositioningPolicy.center, 8f); username_entry.Area = new RectangleF(100, 0, 150, 40); password_entry.Area = new RectangleF(100, 60, 150, 40); var username_label = CommonWidgets.Label("Username:"******"Password:"******"Login"); login_button.Area = handle_account_creation != null ? new RectangleF(125 + login_create_spacing, 120, 125 - login_create_spacing, 40) : new RectangleF(100, 120, 150, 40); window.Add(username_label); window.Add(password_label); window.Add(username_entry); window.Add(password_entry); window.Add(login_button); void handleResponse(WidgetResponse response) { if (response.Reply != WidgetResponse.ResponseType.reject) { return; } window.ParentDWindow.ShowPopUpMessage("Could not log in.\n\nError: " + response.Message); } login_button.OnClick += (s, a) => confirm_handle.Invoke(new LoginSignal( username_entry.Behaviors.Common.DrawText.Text, password_entry.Behaviors.Common.DrawText.Text, handleResponse )); if (handle_account_creation == null) { return(window); } var create_account_button = CommonWidgets.Button("Create Account"); create_account_button.Area = new RectangleF(0, 120, 125 - login_create_spacing, 40); void handleCreationResponse(WidgetResponse r) { if (r.Reply != WidgetResponse.ResponseType.reject) { return; } window.ParentDWindow.ShowPopUpMessage("Error creating account: " + r.Message); } create_account_button.OnClick += (s, a) => handle_account_creation.Invoke( new CreateAccountSignal( username_entry.Behaviors.Common.DrawText.Text, password_entry.Behaviors.Common.DrawText.Text, "", handleCreationResponse ) ); window.Add(create_account_button); return(window); }