public void TestTileConnectorOnRod() { // create various points for tests below Point3D v1 = new Point3D(0, 0, 0); // vertexes v1 and v2 for tile (rod) Point3D v2 = new Point3D(2, 0, 0); List <Point3D> points = new List <Point3D> { v1, v2 }; // vertexes for our tile (rod) Glue glue = new Glue("g1"); Angle angle = new Angle(); // connector (point) at v1 List <Connector> connectors = new List <Connector> { new Connector("cn1", new List <Point3D> { v1 }, glue, angle, 0) }; Tile fo = new Tile("fo", points, connectors, glue, null, Color.Black); // connector (point) at v2 connectors = new List <Connector> { new Connector("cn1", new List <Point3D> { v2 }, glue, angle, 0) }; fo = new Tile("fo", points, connectors, glue, null, Color.Black); }
public void TestTileValidProteins() { // create various points for tests below Point3D v1 = new Point3D(0, 0, 0); // vertexes v1, v2, and v3 for tile (polygon -> triangle) Point3D v2 = new Point3D(2, 0, 0); Point3D v3 = new Point3D(0, 3, 0); Point3D c1Pos = new Point3D(1, 0, 0); // between v1 and v2 Point3D c3Pos = new Point3D(1, 1, 0); // inside polygon List <Point3D> points = new List <Point3D> { v1, v2, v3 }; // vertexes for our Tile (polygon) Glue glue = new Glue("g1"); // proteins at valid positions List <ProteinOnTile> proteins = new List <ProteinOnTile> { new ProteinOnTile("p1", v1), // at v1 new ProteinOnTile("p2", v2), // at v2 new ProteinOnTile("p3", v3), // at v3 new ProteinOnTile("p4", c1Pos), // on edge v1 - v2 new ProteinOnTile("p5", c3Pos) // inside polygon }; Tile fo = new Tile("fo", points, null, glue, proteins, Color.Black); CollectionAssert.AreEquivalent(proteins, fo.Proteins); }
public static Glue Parse(SqlString s) { if (s.IsNull) { return(Null); } else { string[] values = s.Value.Split(@"/".ToCharArray()); Glue glue = new Glue(); glue.m_Price = Double.Parse(values[0]); glue.m_Radius = int.Parse(values[1]); glue.m_Height = int.Parse(values[2]); if (!glue.Validate()) { throw new ArgumentException("Invalid values!"); } return(glue); } }
protected void ButtonLogin_Click(object sender, EventArgs e) { // Glue Login call here. string authToken = Glue.Login(TextBoxUserName.Text, TextBoxPassword.Text); bool authenticated = !string.IsNullOrEmpty(authToken); if (authenticated) { // Save authToken for this session Session["authToken"] = authToken; TextBoxResponse.Text = authToken; ButtonLogin.Enabled = false; // Initialize indices of project and model index Session["projectIndex"] = 0; Session["projectId"] = ""; Session["modelIndex"] = 0; Session["modelId"] = ""; } // Show the request and response in the form. // This is for learning purpose. IRestResponse response = Glue.m_lastResponse; TextBoxRequest.Text = response.ResponseUri.AbsoluteUri; TextBoxResponse.Text = response.Content; }
protected override CallSlot DoSendRequest(ClientEndPoint endpoint, RequestMsg request, CallOptions options) { request.__setServerTransport(findServerTransport(endpoint)); //notice: no serialization because we are in the same address space ResponseMsg response; try { response = Glue.ServerHandleRequest(request); } catch (Exception e) { response = Glue.ServerHandleRequestFailure(request.RequestID, request.OneWay, e, request.BindingSpecificContext); } if (request.OneWay) { return(new CallSlot(endpoint, this, request, CallStatus.Dispatched, options.TimeoutMs)); } var result = new CallSlot(endpoint, this, request, CallStatus.ResponseOK); result.DeliverResponse(response); return(result); }
/// <summary> /// Handles request synchronously in the context of the calling thread. Returns NULL for one-way calls /// </summary> public ResponseMsg HandleRequestSynchronously(RequestMsg request) { try { return(inspectAndHandleRequest(request)); } catch (Exception error) //nothing may leak { if (request.OneWay) { //because it is one-way, the caller will never know about it this.WriteLog(LogSrc.Server, MessageType.Error, string.Format(StringConsts.GLUE_SERVER_ONE_WAY_CALL_ERROR + error.ToMessageWithType()), from: "SrvrHndlr.HandleRequestSynchronously(ReqMsg)", exception: error ); return(null); } else { //call goes via Glue because there may be some global event handlers var response = Glue.ServerHandleRequestFailure(request.RequestID, request.OneWay, error, request.BindingSpecificContext); return(response); } } finally { NFX.ApplicationModel.ExecutionContext.__SetThreadLevelContext(null, null, null); } }
protected void ButtonModel_Click(object sender, EventArgs e) { string authToken = HttpContext.Current.Session["authToken"] as string; string project_id = HttpContext.Current.Session["projectId"] as string; List <ModelInfo> model_list = Glue.ModelList(authToken, project_id); // Show the request and response in the form. // This is for learning purpose. IRestResponse response = Glue.m_lastResponse; TextBoxRequest.Text = response.ResponseUri.AbsoluteUri; TextBoxResponse.Text = response.Content; // We want to get hold of one model. // For simplicity, just pick up arbitrary one. int model_index = Convert.ToInt32(HttpContext.Current.Session["modelIndex"]); model_index %= model_list.Count; ModelInfo model = model_list[model_index++]; string model_id = model.model_id; string model_name = model.model_name; Session["modelIndex"] = model_index; Session["modelId"] = model_id; TextBoxModelName.Text = model_name + " (" + model_index.ToString() + "/" + model_list.Count.ToString() + ")"; // No model in a viewer, yet. iframeGlue.Src = ""; }
public static void DefineScript() { sap.ui.define(new string[] { "sap/ui/Device", "jquery.sap.global", "sap/ui/core/Fragment", "sap/ui/core/mvc/Controller", "sap/ui/model/json/JSONModel", "sap/m/ResponsivePopover", "sap/m/MessagePopover", "sap/m/ActionSheet", "sap/m/Button", "sap/m/Link", "sap/m/Bar", "sap/ui/layout/VerticalLayout", "sap/m/NotificationListItem", "sap/m/MessagePopoverItem", "sap/ui/core/CustomData", "sap/m/MessageToast" }, new Func <sap.ui.Device, object>( (Device) => { AppController newObj = Glue.CreateRawClassObject <AppController>(); newObj._bExpanded = true; newObj.Device = Device; return(BaseController.extend(nameof(AppController), newObj)); } ) ); }
public void TestNewRuleReturnsCorrectNonMetabolicRule() { Glue glue = new Glue("pa"); FloatingObject floatingObject = new FloatingObject("a", 1, 1); List <ISimulationObject> leftSide = new List <ISimulationObject> { glue, glue, floatingObject, floatingObject }; List <ISimulationObject> rightSide = new List <ISimulationObject> { glue, glue }; EvoNonMetabolicRule divideRule = TypeUtil.Cast <EvoNonMetabolicRule>(EvolutionRule.NewRule("Divide", 1, leftSide, rightSide, 0)); Assert.AreEqual(1, divideRule.Priority); Assert.AreEqual(EvolutionRule.RuleType.Divide, divideRule.Type); Assert.AreEqual(4, divideRule.LeftSideObjects.Count); Assert.AreEqual("pa", divideRule.LeftSideObjects[0].Name); Assert.AreEqual("pa", divideRule.LeftSideObjects[1].Name); Assert.AreEqual("a", divideRule.LeftSideObjects[2].Name); Assert.AreEqual("a", divideRule.LeftSideObjects[3].Name); Assert.AreEqual(2, divideRule.RightSideObjects.Count); Assert.AreEqual("pa", divideRule.RightSideObjects[0].Name); Assert.AreEqual("pa", divideRule.RightSideObjects[1].Name); Assert.AreEqual(2, divideRule.MLeftSideFloatingNames.Count); Assert.AreEqual(2, divideRule.MLeftSideFloatingNames.ToDictionary()["a"]); Assert.AreEqual(0, divideRule.MRightSideFloatingNames.Count); }
public Copier(string binaryValue, string signal) { this.binaryValue = binaryValue; this.signal = signal; tiles = new List <Tile>(); startGlue = GlueFactory.LeftHook(); }
protected void ButtonProject_Click(object sender, EventArgs e) { string authToken = HttpContext.Current.Session["authToken"] as string; List <Project> proj_list = Glue.ProjectList(authToken); // Show the request and response in the form. // This is for learning purpose. IRestResponse response = Glue.m_lastResponse; TextBoxRequest.Text = response.ResponseUri.AbsoluteUri; TextBoxResponse.Text = response.Content; // We want to get hold of one project. // For simplicity, just pick up arbitrary one. int proj_index = Convert.ToInt32(HttpContext.Current.Session["projectIndex"]); proj_index %= proj_list.Count; Project proj = proj_list[proj_index++]; string project_id = proj.project_id; string project_name = proj.project_name; Session["projectIndex"] = proj_index; Session["projectId"] = project_id; TextBoxProjectName.Text = project_name + " (" + proj_index.ToString() + "/" + proj_list.Count.ToString() + ")"; // No model in a viewer, yet. iframeGlue.Src = ""; }
/// <summary> /// Provides a test tile - a square tile. /// </summary> /// <param name="name">Name of the tile.</param> private static Tile CreateSquareTile(string name) { var GlueA = new Glue("GlueA"); Point3D v1 = new Point3D(5, 5, 0); Point3D v2 = new Point3D(5, -5, 0); Point3D v3 = new Point3D(-5, -5, 0); Point3D v4 = new Point3D(-5, 5, 0); return(new Tile(name, new List <Point3D> { v1, v2, v3, v4 }, new List <Connector> { new Connector("c1", new List <Point3D> { v1, v2 }, GlueA, Angle.FromDegrees(90), 0), new Connector("c2", new List <Point3D> { v2, v3 }, GlueA, Angle.FromDegrees(90), 0), new Connector("cp", new List <Point3D> { Point3D.Origin }, GlueA, Angle.FromDegrees(90), 0) }, null, null, Color.FromArgb(64, Color.DarkBlue))); }
protected void UpdateToolbox() { Gtk.TreeStore store = treeView.Model as Gtk.TreeStore; //if (store == null) store = new Gtk.TreeStore(typeof(string), typeof(Tool<Gdk.Event, Cairo.Context, Model>), typeof(Shape)); IServiceContainer plugins = solidIDE.GetServiceContainer(); IDesigner designer = plugins.GetService <IDesigner>(); //TODO: Scan for Shape types var model = (designer.CurrentSheet as Sheet <Gdk.Event, Cairo.Context, Model>).Model; var view = (designer.CurrentSheet as Sheet <Gdk.Event, Cairo.Context, Model>).View; ITool <Gdk.Event, Cairo.Context, Model> tool; // tool = new Tool <Gdk.Event, Cairo.Context, Model>(new FocusRectangleController(model, view), new AddNewShapeCommand(designer, null)); (tool.Controller() as FocusRectangleController).FocusedRectangleFinish += HandleFocusedRectangleFinish; store.AppendValues("Rectangle", tool, new RectangleShape(new Rectangle(0, 0, 100, 50))); // tool = new Tool <Gdk.Event, Cairo.Context, Model>(new FocusRectangleController(model, view), new AddNewShapeCommand(designer, null)); (tool.Controller() as FocusRectangleController).FocusedRectangleFinish += HandleFocusedRectangleFinish; store.AppendValues("Ellipse", tool, new EllipseShape(new Rectangle(0, 0, 50, 100))); // Shape Nowhere = new Glue(new Rectangle(0, 0, 0, 0)); tool = new Tool <Gdk.Event, Cairo.Context, Model>(null, new AddNewBinaryRelationCommand(designer, new ArrowShape(Nowhere, Nowhere))); store.AppendValues("Arrow Connector", tool, new ArrowShape(Nowhere, Nowhere)); }
public IHttpActionResult PutGlue(int id, Glue glue) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != glue.Id) { return(BadRequest()); } db.Entry(glue).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GlueExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Deserialize given XML list of glues. /// </summary> /// <param name="glues">XML element list of glues.</param> /// <returns>Dictionary of glues.</returns> /// <exception cref="MissingXmlAttribute">If some attribute of glue is missing.</exception> /// <exception cref="MissingXmlElement">If some element of glue is missing.</exception> private void DeserializeGlues(List <XElement> glues) { foreach (XElement glue in glues) { string glueName = Xmlizer.GetAttributeValueWithException(glue, "glue", "name"); Glues[glueName] = new Glue(glueName); } }
internal static bool __Init() { bool b = Glue.__InitGlfw(); GLFWMonitor.Init(); IsInitialized = true; return(b); }
protected Provider(IGlueImplementation glue, string name = null) : base(glue, name) { if (string.IsNullOrWhiteSpace(Name)) { throw new GlueException(StringConsts.CONFIGURATION_ENTITY_NAME_ERROR + this.GetType().FullName); } Glue.RegisterProvider(this); }
public MainWindow() { InitializeComponent(); listBox = MyListBox; Reset(); Closing += (object sender, CancelEventArgs e) => Glue.Save(); }
public Writer(string binaryValue, string signal, int stoppingValue) { this.stoppingValue = stoppingValue; this.binaryValue = binaryValue; this.signal = signal; tiles = new List <Tile>(); startGlue = GlueFactory.Writer(binaryValue, signal); }
public ActionResult DeleteConfirmed(int id) { Glue glue = db.Glues.Find(id); db.Glues.Remove(glue); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Initialize() { v_Points = new List <Point3D> { new Point3D(1, 0, 0), new Point3D(0, 1, 0) }; v_TestGlue = new Glue("TestGlue"); v_TestConnector = new Connector("TestConnector", v_Points, v_TestGlue, default(Angle), 0); }
private void __ctor() { if (string.IsNullOrWhiteSpace(Name)) { throw new GlueException(StringConsts.CONFIGURATION_ENTITY_NAME_ERROR + this.GetType().FullName); } Glue.RegisterProvider(this); }
public ActionResult Edit([Bind(Include = "Id,MaterialType,MaterialAmount,Price")] Glue glue) { if (ModelState.IsValid) { db.Entry(glue).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(glue)); }
//called asynchronously to deliver data from server private void receiveAction(MpxSocket <MpxClientTransport> socket, WireMsg wm) { if (!Running) { return; } var response = deserialize(ref wm); Glue.ClientDeliverAsyncResponse(response); }
public static void Script() { sap.ui.define(new string[] { "sap/ui/core/util/MockServer" }, new Func <MockServer>(() => { var newObj = Glue.CreateRawClassObject <MockServer>(); return(newObj); }) ); }
public static void Reset() { var temp = Glue.GetData(); listBox.Items.Clear(); foreach (var item in temp) { listBox.Items.Add(item); } }
public static void Script() { sap.ui.define(new string[] { }, new Func <object>( () => { return(Glue.CreateRawClassObject <Formatter>()); } )); }
public CounterWrite1(string name, Glue input, Glue output) { Tiles = Create(); Tiles.RenameWithIndex(name); Input = Tiles.First(); Input.South = input; Output = Tiles.Last(); Output.North = output; }
private bool sendResponse(ResponseMsg response) { try { MpxServerSocket socket = getSocket(response); if (socket == null || !socket.Active) { return(false); } try { sendSocketResponse(socket, response); } catch (Exception err1) { var commError = err1 is SocketException || err1 is System.IO.IOException || (err1 is ProtocolException && ((ProtocolException)err1).CloseChannel); stat_Errors(); if (commError) { throw; //do nothing - just close the channel } if (response != null) { try { var response2 = Glue.ServerHandleRequestFailure(response.RequestID, false, err1, response.BindingSpecificContext); sendSocketResponse(socket, response2); } catch (Exception e) { Binding.WriteLog( LogSrc.Server, Log.MessageType.Warning, StringConsts.GLUE_CLIENT_THREAD_ERROR + "couldn't deliver response to client's request: " + e.Message, relatedTo: response.RequestID.ToGuid(), from: "MpxServerTransport.sendResponse", exception: e); } } } return(true); } catch (Exception error) { Binding.WriteLog(LogSrc.Server, Log.MessageType.Error, error.ToMessageWithType(), "MpxServerTransport.sendResponse()", error); if (error is MessageSizeException) { return(true); } return(false); } }
public NextReadDigit3Seed(string name, Glue input, Glue output) { Tiles = Create(); Tiles.RenameWithIndex(name); Input = Tiles.First(); Input.North = input; Output = Tiles.Last(); Output.North = output; }
/// <summary> /// Returns an existing server node or creates a new one /// </summary> public ServerNode this[Glue.Node node] { get { EnsureObjectNotDisposed(); return m_Servers.GetOrRegister(node.Name, (n) => new ServerNode(this, n), node); } }
private void SetPositionValuesOn(Glue.SaveClasses.NamedObjectSave nos, InstanceSave instance) { RecursiveVariableFinder rvf = new RecursiveVariableFinder(instance, instance.ParentContainer); float x = rvf.GetValue<float>("X"); float y = rvf.GetValue<float>("Y"); #region Adjust values according to object origin float effectiveWidth = GetEffectiveWidth(instance); float effectiveHeight = GetEffectiveHeight(instance); HorizontalAlignment horizontalOrigin = rvf.GetValue<HorizontalAlignment>("X Origin"); VerticalAlignment verticalOrigin = rvf.GetValue<VerticalAlignment>("Y Origin"); switch (horizontalOrigin) { case HorizontalAlignment.Left: x += effectiveWidth / 2.0f; break; case HorizontalAlignment.Right: x -= effectiveWidth / 2.0f; break; } switch (verticalOrigin) { case VerticalAlignment.Top: y += effectiveHeight / 2.0f; break; case VerticalAlignment.Bottom: y -= effectiveHeight / 2.0f; break; } #endregion #region Adjust values according to alignment float parentWidth = GetParentWidth(instance); float parentHeight = GetParentHeight(instance); PositionUnitType xUnits = rvf.GetValue<PositionUnitType>("X Units"); PositionUnitType yUnits = rvf.GetValue<PositionUnitType>("Y Units"); switch (xUnits) { case PositionUnitType.PixelsFromLeft: x -= parentWidth / 2.0f; break; case PositionUnitType.PixelsFromCenterX: // do nothing break; default: throw new NotImplementedException(); break; } switch (yUnits) { case PositionUnitType.PixelsFromTop: y -= parentHeight / 2.0f; break; case PositionUnitType.PixelsFromCenterY: // do nothing break; default: break; } #endregion nos.SetPropertyValue("X", x); // Invert Y because FRB uses positive Y is up nos.SetPropertyValue("Y", -y); }