public long UpdateGroup(GroupObject group) { try { if (group == null) { return(-2); } var groupEntity = ModelMapper.Map <GroupObject, Group>(group); if (groupEntity == null || groupEntity.Id < 1) { return(-2); } using (var db = new ImportPermitEntities()) { db.Groups.Attach(groupEntity); db.Entry(groupEntity).State = EntityState.Modified; db.SaveChanges(); return(group.Id); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public long AddGroup(GroupObject group) { try { if (group == null) { return(-2); } var groupEntity = ModelMapper.Map <GroupObject, Group>(group); if (groupEntity == null || string.IsNullOrEmpty(groupEntity.Name)) { return(-2); } using (var db = new ImportPermitEntities()) { var returnStatus = db.Groups.Add(groupEntity); db.SaveChanges(); return(returnStatus.Id); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
private void btSave_Click(object sender, EventArgs e) { GroupObject selectedGroup = ((GroupObject)cBoxGroups.SelectedItem); TmpLogObject.Fav = cBoxFav.Checked; TmpLogObject.Index = selectedGroup.IndexDef; TmpLogObject.IndexAz = selectedGroup.IndexAz; TmpLogObject.GroupName = selectedGroup.Name; TmpLogObject.Name = tBoxName.Text; TmpLogObject.Website = tBoxWebs.Text; TmpLogObject.Mail = tBoxMail.Text; TmpLogObject.Username = tBoxUser.Text; TmpLogObject.Password = tBoxPw.Text; TmpLogObject.Memo = richTextBoxMemo.Text; if (editLog) { //saveEdit -> Eintrag überschreiben int index = infos.LoginList.FindIndex(x => x.ID == TmpLogObject.ID); TmpLogObject.ChangeDate = DateTime.Today; infos.LoginList[index] = TmpLogObject; } else { infos.LoginList.Add(TmpLogObject); } this.DialogResult = DialogResult.OK; this.Close(); }
private void btnCreate_Click(object sender, RoutedEventArgs e) { if (this.txtRN.Text.Trim().Length > 0 && this.txtMNM.Text.Length > 0 && this.lstUrls.Items.Count > 0) { this.GRP = new GroupObject(); this.GRP.RN = this.txtRN.Text; this.GRP.MNM = this.txtMNM.Text; List <string> lstNus = new List <string>(); for (int i = 0; i < this.lstUrls.Items.Count; i++) { lstNus.Add((this.lstUrls.Items[i] as ListBoxItem).Content.ToString()); } this.GRP.MID = lstNus.ToArray(); this.DialogResult = true; this.Close(); } else { MessageBox.Show("Please input the necessary information for Group", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private static void DistressMethod1() { VectorDesign design = VectorDesign.Load(@"DistressDesign.PV", VectorDesignFileTypes.Pv); design.Render(@"DistressDesign-Method1-Original.PNG", RenderFormats.Png, 96, design.ColourContext, new RGBColour(1.0, 1.0, 1.0), 1.0); // Adding distress to a design is simply the following: // 1. Create a distress pattern. This can be a bitmap or vector design. // It is simply white "random" objects on a transparent background. // 2. Merge the distress pattern into your existing design. // Some scaling of the distress pattern may be necessary to make it look good. // 3. Rendering the merged design. // // Assumption: the distress pattern is white. This assumes that it will be placed on a white background. // If this is not the case, then you should colourize the distress to match the background or use a different distress // pattern. var designBounds = design.GetBounds(); { VectorDesign distress = VectorDesign.Load(@"DistressPattern.PV", VectorDesignFileTypes.Pv); var distressBounds = distress.GetBounds(); // Move the distress so it's center is at the same location as the design's center var translate = Matrix3x2.Translate(designBounds.Center.X - distressBounds.Center.X, designBounds.Center.Y - distressBounds.Center.Y); distress.ApplyTransform(translate); // Depending on the distress, you may need to scale it. // Calculate an appropriate scaling factor based on your use case. //var scale = Matrix3x2.Scale(...); //distress.ApplyTransform(scale); var distressFirstPage = distress.Pages.First(); var distressFirstLayer = distressFirstPage.Layers.First(); // Create a new group object for the distress pattern so we can clip it GroupObject distressGroup = new GroupObject(); foreach (var obj in distressFirstLayer.Objects) { distressGroup.AddObject(obj); } // Optional: Clip the distress to the bounding box of the design ClipObjectTo(distressGroup, designBounds); // Create a new layer for the distress and add the group object to it. // Finally, add that new layer to the first page of our design. Layer distressLayer = new Layer() { Name = "Distress" // Not required }; distressLayer.AddObject(distressGroup); design.Pages.First().AddLayer(distressLayer); } // Render on a white background design.Render(@"DistressDesign-Method1-Final.PNG", RenderFormats.Png, 96, design.ColourContext, new RGBColour(1.0, 1.0, 1.0), 1.0); }
public ActionResult EditGroup(GroupObject group) { var gVal = new GenericValidator(); try { //if (!ModelState.IsValid) //{ // gVal.Code = -1; // gVal.Error = "Plese provide all required fields and try again."; // return Json(gVal, JsonRequestBehavior.AllowGet); //} if (string.IsNullOrEmpty(group.Name.Trim())) { gVal.Code = -1; gVal.Error = "Please provide Group."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } if (Session["_group"] == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var oldgroup = Session["_group"] as GroupObject; if (oldgroup == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } oldgroup.Name = group.Name.Trim(); var docStatus = new GroupServices().UpdateGroup(oldgroup); if (docStatus < 1) { gVal.Code = -1; gVal.Error = "Group information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = oldgroup.Id; gVal.Error = "Group information was successfully updated"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Code = -1; gVal.Error = "Group information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public void UpdateChildHP(int uID, float atk) { GroupObject script = listChildObj[uID].GetComponent <GroupObject>(); if (script) { script.hp += atk; script.OnSetIdle(); } }
/// <summary> /// Handles plugin initialization. /// Fired when the server is started and the plugin is being loaded. /// You may register hooks, perform loading procedures etc here. /// </summary> public override void Initialize() { // Create a Folder // Create a file List <string> data = new List <string>(); data.Add("default"); data.Add("255,255,255"); data.Add("tshock.canchat"); data.Add("tshock.account.login"); if (!Directory.Exists(GroupDirectory)) { Directory.CreateDirectory(GroupDirectory); Console.WriteLine("Directory Created"); if (!File.Exists(file)) { CreateFile.DoCreateFile(file, data); Console.WriteLine("File Created"); } } // Read contents of a file and create groups based on them. foreach (string dir in Directory.GetFiles(GroupDirectory)) { Console.WriteLine(dir); string thing = Path.GetFullPath(dir); Console.WriteLine(thing); GroupObject bleh = new GroupObject(thing); //if the group doesn't exist, and the parent does, execute. Console.WriteLine("Adding Group: " + bleh.Name + " with parent: " + bleh.parent); string parent = Path.GetFullPath(bleh.parent); if (!TShock.Groups.GroupExists(bleh.Name)) { // check if parent group exists if (TShock.Groups.GroupExists(bleh.parent.ToString())) { AddGroupFromFile(bleh); } // if parent doesn't exists, but file for it does else if (File.Exists(parent.ToString())) { GroupObject Parent = new GroupObject(parent); AddGroupFromFile(Parent); AddGroupFromFile(bleh); } // TO DO: Make this recursive else { Console.WriteLine(bleh.Name + "has failed to load because it's parent Group " + parent + ", parent's doesn't exist. Also, creator of this plugin needs to learn how to handle this scenario."); } } } }
/// <summary> /// /// </summary> /// <param name="mesh"></param> /// <param name="orientedPosition"></param> private void AddRowToChartMesh(double[,] data, int rowIndex, double orientedPosition, double depth) { if (((IInternalBarData)Data).InternalDataSource == null) { return; } int columnCount = data.GetLength(1); double barFullSize = BarSeperationLink.Breadth; double totalSize = ((columnCount - 1) * (barFullSize)); double totalDepth = columnCount * BarSeperationLink.Depth; double start = orientedPosition - totalSize * 0.5f; double min = ((IInternalBarData)Data).GetMinValue(); double max = ((IInternalBarData)Data).GetMaxValue(); double total = max - min; string group = ((IInternalBarData)Data).InternalDataSource.Rows[rowIndex].Name; if (mGroupLabels != null && mGroupLabels.isActiveAndEnabled && (mGroupLabels.Alignment != GroupLabelAlignment.BarBottom && mGroupLabels.Alignment != GroupLabelAlignment.BarTop)) { GroupObject groupObj = new GroupObject(); groupObj.start = (float)start; groupObj.depth = (float)depth; groupObj.totalSize = (float)totalSize; groupObj.totalDepth = (float)totalDepth; groupObj.rowIndex = rowIndex; Vector3 position = AlignGroupLabel(groupObj); string toSet = mGroupLabels.TextFormat.Format(group, "", ""); float angle = 45f; // if(mGroupLabels.Alignment == GroupLabelAlignment.) BillboardText billboard = ChartCommon.CreateBillboardText(null, mGroupLabels.TextPrefab, transform, toSet, position.x, position.y, position.z, angle, null, hideHierarchy, mGroupLabels.FontSize, mGroupLabels.FontSharpness); billboard.UserData = new LabelPositionInfo(mGroupLabels, groupObj); TextController.AddText(billboard); } for (int i = 0; i < columnCount; i++) { string category = ((IInternalBarData)Data).InternalDataSource.Columns[i].Name; double rowInterp = (((float)i) / ((float)columnCount - 1)); if (double.IsInfinity(rowInterp) || double.IsNaN(rowInterp)) // calculate limit for 0/0 { rowInterp = 0.0; } double pos = rowInterp * totalSize; double finalDepth = depth + rowInterp * totalDepth; pos += start;// - barFullSize * 0.5f; double amount = data[rowIndex, i]; double interp = (amount - min) / total; interp = Math.Max(0, Math.Min(1, interp)); // clamp to [0,1] AddBarToChart(finalDepth, amount, pos, interp, category, group, rowIndex, i); } }
void OnTriggerEnterAXE(Collider other) { GroupObject obj = other.GetComponent <GroupObject>(); if (obj && obj.tag == "tree") { FBParticleManager.PlayEffect(FBParticleManager.HIT_ANIMAL, 2, other.ClosestPoint(this.transform.position)); FBSoundManager.Play(FBSoundManager.HIT_SOFT); obj.UpdateHP(-AXE_DAMAGE); } }
private static string getGroupAttributes(GroupObject groupObject, GraphicInformation graphicInfo) { string[] groupAttribute = new string[] { "none=", "PenColor=", "PenWidth=", "Layer=", "Tile=", "Type=" }; // check public enum GroupOptions string groupVal1 = string.Format(" {0}\"{1}\"", groupAttribute[(int)graphicInfo.GroupOption], groupObject.key); string groupVal2 = string.Format(" ToolNr=\"{0}\"", groupObject.toolNr); string groupVal3 = string.Format(" ToolName=\"{0}\"", groupObject.toolName); string groupVal4 = string.Format(" PathLength=\"{0:0.0}\"", groupObject.pathLength); string groupVal5 = string.Format(" PathArea=\"{0:0.0}\"", groupObject.pathArea); return(string.Format("{0}{1}{2}{3}{4}", groupVal1, groupVal2, groupVal3, groupVal4, groupVal5)); }
public void TestGroupObjectFindAllWithFilter() { var groupObjects = GroupObject.FindAll(this.ADOperator, new Is(AttributeNames.CN, this.GroupCn)); foreach (GroupObject groupObject in groupObjects) { using (groupObject) { Assert.AreEqual(this.GroupCn, groupObject.CN); } } }
public long UpdateGroup(GroupObject group) { try { return(_groupManager.UpdateGroup(group)); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public void TestGroupObjectFindAll() { var groupObjects = GroupObject.FindAll(this.ADOperator); Assert.AreNotEqual(0, groupObjects.Count); foreach (GroupObject groupObject in groupObjects) { using (groupObject) { Console.WriteLine(groupObject.Path); } } }
public void OnTriggerEnterGunBullet(Collider other) { //check collide with animal group Object GroupObject obj = other.GetComponent <GroupObject>(); if (obj && obj.tag == "animal") { FBSoundManager.Play(FBSoundManager.HIT_SOFT); obj.UpdateHP(-BULLET_DAMAGE); } else if (obj) { PopupManager.ShowWrongSignal(this.transform.position); } FBPoolManager.instance.returnObjectToPool(this.gameObject); }
//TODO: При добавлении новой группы не обновляется список групп (а надо ли это, ведь он считывается заново при каждом вызове комманд?) /// <summary> /// Добавляет группу к объекту /// </summary> /// <param name="objectid">id объекта для добавления группы</param> /// <param name="group">имя группы для добавления</param> public void AppendGroupToObject(ObjectId objectid, string group) { GroupObject groupObj = new GroupObject(objectid, transaction); int index = groupObjects.IndexOf(groupObj); if (index == -1) { groupObj.AddGroup(group); groupObjects.Add(groupObj); index = groupObjects.Count-1; } else { groupObjects[index].AddGroup(group); } groupObjects[index].WriteGroups(); }
void CheckLocalAndReturnReward(int uID, float atk) { GroupObject script = listChildObj[uID].GetComponent <GroupObject>(); if (script && (script.hp + atk <= 0)) { //return reward here GameObject obj = FBPoolManager.instance.getPoolObject(this.receiveItemName); obj.transform.position = script.gameObject.transform.position; obj.SetActive(true); //do animation fly FBUtils.DoAnimJumpOut(obj); } }
public GroupObject(GroupObject tmp) { key = tmp.key; toolNr = tmp.toolNr; toolName = tmp.toolName; groupRelatedGCode = tmp.groupRelatedGCode; pathDimension = new Dimensions(); pathDimension.addDimensionXY(tmp.pathDimension); groupId = tmp.groupId; groupPath = new List <PathObject>(); foreach (PathObject tmpPath in tmp.groupPath) { groupPath.Add(tmpPath); } }
public ActionResult AddGroup(GroupObject group) { var gVal = new GenericValidator(); try { //if (!ModelState.IsValid) //{ // gVal.Code = -1; // gVal.Error = "Plese provide all required fields and try again."; // return Json(gVal, JsonRequestBehavior.AllowGet); //} var importerInfo = GetLoggedOnUserInfo(); if (importerInfo.Id < 1) { gVal.Error = "Your session has timed out"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var validationResult = ValidateGroup(group); if (validationResult.Code == 1) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } var appStatus = new GroupServices().AddGroup(group); if (appStatus < 1) { validationResult.Code = -1; validationResult.Error = appStatus == -2 ? "Group upload failed. Please try again." : "The Group Information already exists"; return(Json(validationResult, JsonRequestBehavior.AllowGet)); } gVal.Code = appStatus; gVal.Error = "Group was successfully added."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Error = "Group processing failed. Please try again later"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Advances the enumerator to the next element of the collection. /// </summary> /// <returns>true if the enumerator was successfully advanced to the next element; false if /// the enumerator has passed the end of the collection.</returns> /// <exception cref="InvalidOperationException">The collection was modified after the enumerator was created.</exception> public async Task <bool> MoveNextAsync() { if (!await this.e.MoveNextAsync()) { return(false); } this.current = this.e.Current; if (this.objectVariables is null) { this.objectVariables = new ObjectProperties(this.current, this.variables); } else { this.objectVariables.Object = e.Current; } if (this.current is GenericObject GenObj) { foreach (KeyValuePair <string, ScriptNode> P in this.additionalFields) { GenObj[P.Key] = P.Value.Evaluate(this.objectVariables); } } else if (this.current is GroupObject GroupObj) { foreach (KeyValuePair <string, ScriptNode> P in this.additionalFields) { GroupObj[P.Key] = P.Value.Evaluate(this.objectVariables); } } else { GroupObject Obj = new GroupObject(new object[] { this.current }, new object[0], new ScriptNode[0], this.objectVariables); foreach (KeyValuePair <string, ScriptNode> P in this.additionalFields) { Obj[P.Key] = P.Value.Evaluate(this.objectVariables); } this.current = Obj; } return(true); }
public override void KeyDown(object sender, KeyEventArgs e, Panel panel1) { //System.Diagnostics.Debug.WriteLine(e.KeyCode.ToString() + " Pencet."); if (e.KeyCode == Keys.Delete && objectSelected != null) { ParentForm.Remove_Object(objectSelected); objectSelected = null; //System.Diagnostics.Debug.WriteLine(e.KeyCode.ToString() + " Oke."); } else if (e.Control && e.KeyCode == Keys.G && ObjectGroup.Any() && banyakObject() > 1) { GroupObject groupObject = new GroupObject(); groupObject.setGraphics(panel1.CreateGraphics()); groupObject.AddChild(ObjectGroup); foreach (AObject aObject in ObjectGroup) { aObject.Deselect(); ParentForm.Remove_Object(aObject); } groupObject.Deselect(); ParentForm.Add_Object(groupObject); ObjectGroup = new LinkedList <AObject>(); controlClick = false; //groupObject.Draw(); //panel1.Invalidate(); //panel1.Refresh(); } else if (e.Control && e.Shift && e.KeyCode == Keys.G && objectSelected != null) { LinkedList <AObject> child = objectSelected.RemoveChild(); ParentForm.Remove_Object(objectSelected); foreach (AObject aObject in child) { ParentForm.Add_Object(aObject); } objectSelected = null; panel1.Refresh(); panel1.Invalidate(); } else if (e.Control) { //System.Diagnostics.Debug.WriteLine(e.KeyCode.ToString() + " Control Saja."); controlClick = true; } }
/// <summary> /// The create user. /// </summary> /// <param name="value"> /// The value. /// </param> public void CreateUser(ADUserViewModel value) { using (var ou = OrganizationalUnitObject.FindOneByOU(this.ADOperator, "VPN_List")) { var group = GroupObject.FindOneByCN(ADOperator, "FortiVPN"); using (var addUserObject = ou.AddUser(value.Account)) { addUserObject.SAMAccountName = value.Account; addUserObject.ResetPassword(value.Password); addUserObject.DisplayName = value.DisplayName; group.Members.Add(addUserObject.SAMAccountName); addUserObject.IsEnabled = true; addUserObject.SetAttributeValue("userAccountControl", 66048); addUserObject.Save(); group.Save(); } } }
//// POST api/<controller> //public void Post([FromBody]string value) //{ //} //// PUT api/<controller>/5 //public void Put(int id, [FromBody]string value) //{ //} //// DELETE api/<controller>/5 //public void Delete(int id) //{ //} private GroupObject GetConfigValues() { var twitterSection = ConfigurationManager.GetSection("SocialMedia.Twitter.Settings") as NameValueCollection; var groupSection = new GroupObject { GroupActionText = twitterSection["GroupActionText"], GroupHeaderText = twitterSection["GroupHeaderText"], GroupActionUrl = twitterSection["GroupActionUrl"], CacheKey = twitterSection["CacheKey"], CacheTimeInSeconds = twitterSection["CacheTimeInSeconds"], TwitterProfileBaseUrl = twitterSection["TwitterProfileBaseUrl"], TwitterConsumerKey = twitterSection["TwitterConsumerKey"], TwitterConsumerSecret = twitterSection["TwitterConsumerSecret"], TwitterTokenKey = twitterSection["TwitterTokenKey"], TwitterTokenSecret = twitterSection["TwitterTokenSecret"], Username = twitterSection["TwitterUsername"] }; return(groupSection); }
void InitChilds() { for (int i = 0; i < transform.childCount; i++) { GameObject tmp = transform.GetChild(i).gameObject; //Rigidbody Rigidbody rb = tmp.addMissingComponent <Rigidbody>(); rb.isKinematic = true; //Collider if (groupType != TYPE.MOVEABLE) { //MeshCollider mCollider = tmp.addMissingComponent<MeshCollider>(); // mCollider.convex = true; // mCollider.isTrigger = true; } //script GroupObject script = tmp.addMissingComponent <GroupObject>(); script.uID = i; script.parent = this; listChildObj.Add(tmp); } }
public async Task <ObservableCollection <GroupObject> > GetGroupObject() { ObservableCollection <GroupObject> result = new ObservableCollection <GroupObject>(); GroupObject group = new GroupObject(); var from = await this.GetListAsync(); if (from == null) { return(result); } foreach (var item in from) { group.Add(item); } result.Add(group); return(result); }
public void TestGroupObjectFindOne() { using (var groupObject = GroupObject.FindOneBySid(this.ADOperator, this.GroupSid)) { Assert.AreEqual(this.GroupSAMAccountName, groupObject.SAMAccountName); Assert.AreEqual(this.GroupEmail, groupObject.Email); Assert.AreEqual(this.GroupNotes, groupObject.Notes); Assert.NotNull(groupObject.GroupSids); Assert.GreaterOrEqual(groupObject.GroupSids.Count, 1); Assert.AreEqual(this.GroupTokenGroupSid, groupObject.GroupSids[0]); Assert.NotNull(groupObject.Members); Assert.GreaterOrEqual(groupObject.Members.Count, 1); Assert.AreEqual(this.GroupMember, groupObject.Members[0]); Assert.AreEqual(this.GroupType, groupObject.GroupType.ToString()); Assert.AreEqual(this.GroupScope, groupObject.GroupScopeType.ToString()); } using (var adObject = ADObject.FindOneByObjectGUID(this.ADOperator, this.GroupGuid)) { var groupObject = adObject as GroupObject; Assert.NotNull(groupObject); Assert.AreEqual(this.GroupSid, groupObject.ObjectSid); } }
private Vector3 AlignGroupLabel(GroupObject obj) { float alignPos = 0f; float seperation = mGroupLabels.Seperation; alignPos += HeightRatio; float pos = obj.start; float posDepth = obj.depth; float addBreadth = mGroupLabels.Location.Breadth; float addDepth = mGroupLabels.Location.Depth; if (mGroupLabels.Alignment == GroupLabelAlignment.AlternateSides) { if (obj.rowIndex % 2 != 0) { pos += obj.totalSize; posDepth += obj.totalDepth; } else { addBreadth = -addBreadth; addDepth = -addDepth; } } else if (mGroupLabels.Alignment == GroupLabelAlignment.EndOfGroup) { pos += (obj.totalSize); posDepth += (obj.totalDepth); } else if (mGroupLabels.Alignment == GroupLabelAlignment.Center) { pos += (obj.totalSize) * 0.5f; posDepth += (obj.totalDepth) * 0.5f; } return(new Vector3(pos + addBreadth, alignPos + seperation, (float)(posDepth) + addDepth)); }
static void ClipObjectTo(GroupObject groupObject, Bounds boundingBox) { List<PathTriple> triples = new List<PathTriple>() { new PathTriple(boundingBox.TopLeft), new PathTriple(boundingBox.TopRight), new PathTriple(boundingBox.BottomRight), new PathTriple(boundingBox.BottomLeft) }; PathShape clipPathShape = new PathShape(); clipPathShape.AddPath(new Path(triples) { IsClosed = true }); // clipPathShape is now a rectangle with coordinates matching our bounding box. // We turn that into a ShapeObject ShapeObject clipShape = new ShapeObject(); clipShape.Shape = clipPathShape; // Add it to the group object and turn on clipping. groupObject.IsClipped = true; groupObject.AddObject(clipShape); }
private GenericValidator ValidateGroup(GroupObject group) { var gVal = new GenericValidator(); try { if (string.IsNullOrEmpty(group.Name)) { gVal.Code = -1; gVal.Error = "Please select provide Group."; return(gVal); } gVal.Code = 5; return(gVal); } catch (Exception) { gVal.Code = -1; gVal.Error = "Group Validation failed. Please provide all required fields and try again."; return(gVal); } }
static void Main(string[] args) { string mainDesign = "BANNER HORNETS_withmascot.pv"; string mascotDesign = "BANNER HORNET_HEAD_SIDE_HAPPY.pv"; VectorDesign design = VectorDesign.Load(mainDesign, VectorDesignFileTypes.Pv); // Replace a group object with objects from another PV file // VectorDesign.ProcessObjects with iterate through all objects of an entire design // calling the supplied delegate passing each object as the single parameter. // The return value is the new (or old) object to use to replace the pre-existing one. design.ProcessObjects((obj) => { if (obj is GroupObject) { GroupObject g = (GroupObject)obj; if (g.Name == "mascot") { // Get the current bounding box of this object (we'll want it later) var oldBounds = g.GetBounds(design.Context); VectorDesign design2 = VectorDesign.Load(mascotDesign, VectorDesignFileTypes.Pv); g = new GroupObject(); g.Name = "mascot"; // Copy all objects from page 1 of design2 to the new object // Assumes a page exists, which may not be the case. var page = design2.Pages.First(); foreach (var layer in page.Layers) { // Copy all the objects from the layer to our new group object // Note that this is a shallow copy, so the objects // technically exist in both designs. g.AddObjects(layer.Objects); } // Copy design resources (such as bitmaps used by the objects) var resourceManager2 = design2.ResourceManager; resourceManager2.CopyContentsTo(design.ResourceManager); // Get the bounding box of the new object var newBounds = g.GetBounds(design.Context); // Move the new object so that it's center is where the center // of the old object was // If we know the design name is NEW_MASCOT.pv // Then we can add or subtract POINTS to the newBounds.Center.X and/or the newBounds.Center.Y // double adjustednewCenterX = newBounds.Center.X; // double adjustednewCentery = newBounds.Center.Y; double adjustednewCenterX = newBounds.Center.X; double adjustednewCenterY = newBounds.Center.Y; if (mascotDesign == "BANNER HORNET_HEAD_SIDE_HAPPY.pv") { adjustednewCenterX = newBounds.Center.X + 10.0; adjustednewCenterY = newBounds.Center.Y - 10.0; } var transform = Matrix3x2.Translate(oldBounds.Center.X - adjustednewCenterX, oldBounds.Center.Y - adjustednewCenterY); g.ApplyTransform(transform); // Scale the new mascot so that the new mascot fits completely inside // the bounding box of the original mascot // Start by scaling in the Y direction so the height of the // new mascot will be the same as the height of the old mascot double scale = oldBounds.Height / newBounds.Height; // But will the new mascot fit in the X direction too? if (newBounds.Width * scale > oldBounds.Width) { // No it would not, so scale by the X direction instead. // This should make the width of the new mascot smaller than // the width of the old mascot scale = oldBounds.Width / newBounds.Width; System.Diagnostics.Debug.Assert(newBounds.Height * scale <= oldBounds.Height); } transform = Matrix3x2.Scale(scale, scale, oldBounds.Center); g.ApplyTransform(transform); // Verification newBounds = g.GetBounds(design.Context); //System.Diagnostics.Debug.Assert(newBounds.Center.X == oldBounds.Center.X); //System.Diagnostics.Debug.Assert(newBounds.Center.Y == oldBounds.Center.Y); //System.Diagnostics.Debug.Assert(newBounds.Width <= oldBounds.Width); //System.Diagnostics.Debug.Assert(newBounds.Height <= oldBounds.Height); // We want to replace the old object with our new one obj = g; } } return obj; }); design.Render(@"ReplaceMascot.PNG", RenderFormats.Png, 200, design.ColourContext); }
/// <summary> /// Переименование группы объекта /// </summary> /// <param name="objectid">id объекта для переименования</param> /// <param name="previousName">Первоначальное имя группы</param> /// <param name="newName">Новое имя группы</param> public void RenameGroupOfObject(ObjectId objectid, string previousName, string newName) { GroupObject groupObj = new GroupObject(objectid, transaction); if (groupObj.IsBelongToGroup(previousName)) { int index = groupObjects.IndexOf(groupObj); groupObjects[index].ChangeGroup(previousName, newName); groupObjects[index].WriteGroups(); } }
/// <summary> /// Возвращает группы объекта /// </summary> /// <param name="objectid">id объекта для получения информации</param> /// <returns>список групп объекта</returns> public List<string> GetGroupsOfObject(ObjectId objectid) { if (objectid!=null) { GroupObject groupObj = new GroupObject(objectid, transaction); int index = groupObjects.IndexOf(groupObj); if (index!=-1) { return groupObjects[index].GetGroups(); } } return null; }
/// <summary> /// Удаление группы из объекта /// </summary> /// <param name="objectid">id объекта для удаления группы</param> /// <param name="group">имя группы для удаления</param> public void DeleteGroupFromObject(ObjectId objectid, string group) { GroupObject groupObj = new GroupObject(objectid, transaction); int index = groupObjects.IndexOf(groupObj); if (index != -1) { groupObjects[index].DeleteGroup(group); groupObjects[index].WriteGroups(); if (!groupObjects[index].HasGroup) { groupObjects.RemoveAt(index); } } }
/// <summary> /// Итерирует чертеж и собирает информацию по группам /// </summary> void GetGroupsInformation() { BlockTable bt = (BlockTable)transaction.GetObject( currentDatabase.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)transaction.GetObject( bt[BlockTableRecord.ModelSpace], OpenMode.ForRead); var entities = from ObjectId entity in btr where transaction.GetObject(entity, OpenMode.ForRead, false) is Entity select entity; foreach (ObjectId entity in entities) { GroupObject groupObj = new GroupObject(entity, transaction); if (groupObj.HasGroup) { groupObjects.Add(groupObj); foreach (string group in groupObj.GetGroups()) { if (!groupList.Contains(group)) { groupList.Add(group); } } } } groupList.Sort(); }
public LabelPositionInfo(ItemLabelsBase options, GroupObject group) { Options = options; Group = group; }
private static void DistressMethod2() { VectorDesign design = VectorDesign.Load(@"DistressDesign.PV", VectorDesignFileTypes.Pv); design.Render(@"DistressDesign-Method2-Original.PNG", RenderFormats.Png, 300, design.ColourContext); // Distress method #2 is similar to method #1, // however, in this case: // 1. Create a distress pattern. This must be a vector design. // It is simply white "random" objects on a transparent background. // 2. Combine the distress objects with a bounding rectangle to "invert" them from // a bunch of filled objects, to a bunch of holes in a rectangle. // 3. Use the new distress object as a clipping mask over the design. // Some scaling of the distress pattern may be necessary to make it look good. // 4. Rendering the merged design. // // Unlike method #1, this method will work when rendering onto a transparent background. var designBounds = design.GetBounds(); VectorDesign distress = VectorDesign.Load(@"DistressPattern.PV", VectorDesignFileTypes.Pv); var distressBounds = distress.GetBounds(); // Create a new rectangle shape into which we'll add the distress shapes as "holes". Path rectangle = new Path(); rectangle.Triples.Add(new PathTriple(distressBounds.TopLeft)); rectangle.Triples.Add(new PathTriple(distressBounds.TopRight)); rectangle.Triples.Add(new PathTriple(distressBounds.BottomRight)); rectangle.Triples.Add(new PathTriple(distressBounds.BottomLeft)); rectangle.IsClosed = true; var distressShape = new PathShape(); distressShape.AddPath(rectangle); // Take all the objects from the distress design // and copy them to our PathShape instead. var distressFirstPage = distress.Pages.First(); var distressFirstLayer = distressFirstPage.Layers.First(); foreach (var shapeObject in distress.ShapeObjects) { PathShape pathShape = shapeObject.Shape as PathShape; if (pathShape != null) { distressShape.AddPaths(pathShape.Paths); } } // At this point, distressShape should be a rectangle with a bunch of "holes" in it. // Move the distress so it's center is at the same location as the design's center var translate = Matrix3x2.Translate(designBounds.Center.X - distressBounds.Center.X, designBounds.Center.Y - distressBounds.Center.Y); distressShape.ApplyTransform(translate); // Depending on the distress, you may need to scale it. // Calculate an appropriate scaling factor based on your use case. //var scale = Matrix3x2.Scale(...); //distressShape.ApplyTransform(scale); // This will be our clipping mask ShapeObject distressObject = new ShapeObject(); distressObject.Shape = distressShape; //distressObject.Fill = new SolidFill(new RGBColour(0, 0, 0)); // Create a new design to act as our resulting "distressed" design VectorDesign result = new VectorDesign(); result.ColourContext = design.ColourContext; design.ResourceManager.CopyContentsTo(result.ResourceManager); var resultPage = result.NewPage(); var resultLayer = resultPage.NewLayer(); // Copy all items from the source design to our new group object GroupObject newGroup = new GroupObject(); design.ProcessObjects(obj => { newGroup.AddObject(obj); return obj; }); // Add the clipping mask to the group as our clipping mask newGroup.AddObject(distressObject); newGroup.IsClipped = true; resultLayer.AddObject(newGroup); // Render on a white background result.Render(@"DistressDesign-Method2-Final.PNG", RenderFormats.Png, 300, design.ColourContext); }
public void SendMoveTo(float x, float y, float z, float duration, int childIndex) { GroupObject script = listChildObj[childIndex].GetComponent <GroupObject>(); script.MoveTo(new Vector3(x, y, z), duration); }
public void SendChangeAnim(GroupObject.ACTION action, int childIndex) { GroupObject script = listChildObj[childIndex].GetComponent <GroupObject>(); script.ChangeAnim(action); }
public GroupNode(GroupObject o) : base(o) { }