private void BtnDeleteClick(object sender, RoutedEventArgs e) { var selectedObject = ObjectListDG.SelectedItems.Cast <Models.Object>().ToList(); MessageBoxResult messageBoxResult = MessageBox.Show($"Удалить {selectedObject.Count()} записей???", "Удаление", MessageBoxButton.OKCancel, MessageBoxImage.Question); if (messageBoxResult == MessageBoxResult.OK) { try { Models.Object x = selectedObject[0]; if (x.Comments.Count > 0) { throw new Exception("Есть связанные записи c ключами"); } if (x.Events.Count > 0) { throw new Exception("Есть связанные записи c акциями"); } TatarCulturDbEntities.GetContext().Objects.Remove(x); TatarCulturDbEntities.GetContext().SaveChanges(); MessageBox.Show("Записи удалены"); List <Event> events = TatarCulturDbEntities.GetContext().Events.OrderBy(p => p.Name).ToList(); ObjectListDG.ItemsSource = null; ObjectListDG.ItemsSource = events; } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } }
public CommentObjectPage(Models.Object tatObject) { InitializeComponent(); LoadData(tatObject); _itemcount = CommentListDG.Items.Count; TextBlockCount.Text = $"Результат запроса: {_itemcount-1} записей из {_itemcount-1}"; }
public PageObject(Models.Object tatObject) { InitializeComponent(); if (tatObject != null) { _currentObject = tatObject; object1 = tatObject; } this.DataContext = _currentObject; ListBoxComment.ItemsSource = TatarCulturDbEntities.GetContext().Comments.Where(p => p.IdObject == tatObject.IdObject).OrderBy(p => p.IdComment).ToList(); List <Comment> comments = TatarCulturDbEntities.GetContext().Comments.ToList(); Manager.idObject = _currentObject.IdObject; if (Manager.idUser == 0) { BtnComment.IsEnabled = false; labelAttention.Visibility = Visibility.Visible; } else { BtnComment.IsEnabled = true; labelAttention.Visibility = Visibility.Collapsed; } }
private void Answer(Models.Object message) { api.Messages.Send(new MessagesSendParams { Message = $"Вы написали: {message.Body}", UserId = message.User_Id }); }
public async Task SaveAsync(T objectModel, long userId, long?targetObjectId, long houseId) { var objectTypeName = objectModel.GetType().Name; var objectTypeId = context.Set <ObjectType>().Where(x => x.Name == objectTypeName).FirstOrDefault().Id; var _object = new Models.Object() { CreatedById = userId, ModifiedById = userId, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, ObjectTypeId = objectTypeId }; await context.AddAsync(_object); await context.SaveChangesAsync(); historyContext.PopulateHistory((int)HistoryFunctionTypes.Create, objectModel, _object, userId, targetObjectId, houseId); objectModel.ObjectId = _object.ObjectId; await context.AddAsync <T>(objectModel); await context.SaveChangesAsync(); }
public ActionResult CreateAlbum(AlbumModel model) { if (ModelState.IsValid) { try { Entities dbContext = new Entities(); Models.Object obj = new Models.Object(); obj.EntityName = "Album"; dbContext.Objects.AddObject(obj); dbContext.SaveChanges(); Album album = new Album(); album.Id = obj.Id; album.UserId = new Guid(UserHelper.getLoggedInUserId()); album.Name = model.Name; album.Description = model.Description; album.CreatedAt = DateTime.Now; dbContext.Albums.AddObject(album); dbContext.SaveChanges(); return RedirectToAction("Upload", "Photo"); }catch(Exception ex) { ModelState.AddModelError("", ex.Message); } } return View(model); }
private async void CreateObjectAsync() { if (CreatedObject == null) { CreatedObject = new Models.Object(); } CreatedObject.Name = ObjectName; var updatedNodeList = new List <Node>(); foreach (var item in ObjectNodes) { updatedNodeList.Add(item.GroupKey); } CreatedObject.Nodes = updatedNodeList; if (IsEditMode) { await UpdateObjectAsync(); } else { await SendNewObjectAsync(); } }
public Models.Object readObject(Guid id) { var retList = new List <Models.Object>(); var retVal = new Models.Object(); try { using (var context = new ArchaeologyContext()) { retList = context.Object .Include(obj => obj.GeospatialData) .Include(obj => obj.Locus) .ThenInclude(locus => locus.Square) .ThenInclude(square => square.Supervisor) .Where(obj => obj.Id == id) .ToList(); } } catch (Exception ex) { throw new Exception(ex.Message, ex.InnerException); } if (retList.Count > 0) { retVal = retList[0]; } return(retVal); }
public ObjectPlusPageModel(IObjectStorageService objectStorage) { _objectStorage = objectStorage; CreatedObject = new Models.Object { Nodes = new List <Node>() }; ObjectNodes = new ObservableCollection <Grouping <Node, Material> >(); }
public MessageHandler(Models.Object message) { _message = message; api.Authorize(new ApiAuthParams { AccessToken = "04d112136aa78135884c9e42cc97c5306b33b8d678fd53fb21375f44961b9ee2d4489b87447b6e1763cd9" }); Answer(_message); }
private void DeleteObjectMetadataSubObjects(Models.Object @object) { if (@object.ObjectTypeId == (long)ObjectTypes.House) { var currentHouseId = context.Set <House>().Where(x => x.ObjectId == @object.ObjectId).FirstOrDefault().Id; var hasAnyHouseStatuses = context.HouseStatuses.Any(x => x.HouseId == currentHouseId); var hasAnyHouseSettings = context.HouseSettings.Any(x => x.HouseId == currentHouseId); if (hasAnyHouseStatuses) { var houseStatuses = context.HouseStatuses.Where(x => x.HouseId == currentHouseId); foreach (var houseStatus in houseStatuses) { context.Remove(houseStatus); } } if (hasAnyHouseSettings) { var houseSettings = context.HouseSettings.Where(x => x.HouseId == currentHouseId); foreach (var houseSetting in houseSettings) { context.Remove(houseSetting); } } } else if (@object.ObjectTypeId == (long)ObjectTypes.Inventory || @object.ObjectTypeId == (long)ObjectTypes.Hygiene || @object.ObjectTypeId == (long)ObjectTypes.Issue) { var hasAnyComments = context.Comments.Any(x => x.TargetId == @object.ObjectId); var hasAnyImages = context.Images.Any(x => x.TargetId == @object.ObjectId); if (hasAnyComments) { var comments = context.Comments.Where(x => x.TargetId == @object.ObjectId); foreach (var comment in comments) { context.Remove(comment); } } if (hasAnyImages) { var images = context.Images.Where(x => x.TargetId == @object.ObjectId); foreach (var image in images) { context.Remove(image); } } } }
public DetectBoxViewModel(float scale, Models.Object obj) { this.X = (int)obj.Rect.X; this.Y = (int)obj.Rect.Y; this.Width = (int)obj.Rect.Width; this.Height = (int)obj.Rect.Height; this.Label = "test"; this.Prob = obj.Prob; this.Bounds = new Rectangle(obj.Rect.X * scale, obj.Rect.Y * scale, obj.Rect.Width * scale, obj.Rect.Height * scale); }
public async Task <bool> UpdateObjectAsync(Models.Object CreatedObject) { if (IsThereInternet() == false) { return(false); } if (!AuthenticationHeaderIsSet) { SetAuthenticationHeader(); } string restMethod = "entity/" + CreatedObject.uuid; System.Uri uri = new System.Uri(string.Format(Constants.RestUrl, restMethod)); try { string jmessage = JsonConvert.SerializeObject(CreatedObject, Formatting.Indented); HttpMethod method = new HttpMethod("PATCH"); HttpRequestMessage request = new HttpRequestMessage(method, uri) { Content = new StringContent(jmessage, System.Text.Encoding.UTF8, "application/json") }; HttpResponseMessage response = null; response = await client.SendAsync(request); if (response.IsSuccessStatusCode) { string responseMessage = await response.Content.ReadAsStringAsync(); return(true); } else { string errorInfo = await response.Content.ReadAsStringAsync(); string errorMessage = ParseErrorMessage(errorInfo); Xamarin.Forms.Device.BeginInvokeOnMainThread(async() => { await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Не выполнено", errorMessage, "OK"); }); return(false); } } catch (HttpRequestException e) { await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Не выполнено", e.InnerException.Message, "OK"); return(false); } }
public void ValidateObject(Models.Object obj) { if (obj.Width <= 0) { obj.Width = 100; } if (obj.Height <= 0) { obj.Height = 100; } }
public async Task <bool> SendNewObjectAsync(Models.Object CreatedObject) { if (IsThereInternet() == false) { return(false); } if (!AuthenticationHeaderIsSet) { SetAuthenticationHeader(); } string restMethod = "entity"; System.Uri uri = new System.Uri(string.Format(Constants.RestUrl, restMethod)); try { string jmessage = JsonConvert.SerializeObject(CreatedObject, Formatting.Indented); StringContent content = new StringContent(jmessage, System.Text.Encoding.UTF8, "application/json"); HttpResponseMessage response = null; response = client.PostAsync(uri, content).Result; if (response.IsSuccessStatusCode) { string responseMessage = await response.Content.ReadAsStringAsync(); return(true); } else { string errorInfo = await response.Content.ReadAsStringAsync(); string errorMessage = ParseErrorMessage(errorInfo); Xamarin.Forms.Device.BeginInvokeOnMainThread(async() => { await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Не выполнено", errorMessage, "OK"); }); return(false); } } catch (System.Exception ex) { System.Console.WriteLine("An exception ({0}) occurred.", ex.GetType().Name); System.Console.WriteLine("Message:\n {0}\n", ex.Message); System.Console.WriteLine("Stack Trace:\n {0}\n", ex.StackTrace); await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Не выполнено", ex.GetType().Name + "\n" + ex.Message + "\n" + ex.StackTrace, "OK"); return(false); } }
public bool deleteObject(Models.Object obj) { try { using (var context = new ArchaeologyContext()) { context.Remove(obj); context.SaveChanges(); } } catch (Exception ex) { throw new Exception(ex.Message, ex.InnerException); } return(true); }
private async System.Threading.Tasks.Task InitializeObjectToEditAsync() { Models.Object objectInfo = await _objectStorage.GetObjectFullInfo(CreatedObject.uuid); ObjectName = objectInfo.Name; foreach (var item in objectInfo.Nodes) { var group = new Grouping <Node, Material>(item, item.Materials); ObjectNodes.Add(group); } }
private async void DeleteUserObjectsAsync(Models.Object objectToDelete) { var response = await _objectStorage.DeleteUserObjectsAsync(objectToDelete); if (response == true) { Xamarin.Forms.Device.BeginInvokeOnMainThread(async() => { await CoreMethods.DisplayAlert("Выполнено", "Объект удален", "Ок"); await CreateListsAsync(); }); } }
// Functionality implemented through another logic/code. public async Task PostObjectAsync(Models.Object obj) { var client = new HttpClient(); var json = JsonConvert.SerializeObject(obj); HttpContent content = new StringContent(json); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); content.Headers.Add("ZUMO-API-VERSION", "2.0.0"); var response = await client.PostAsync(Constants.BaseApiAddress + "tables/object", content); //Debug.WriteLine(response.Content); }
public AddObjectPage(Models.Object tatObject) { InitializeComponent(); if (tatObject != null) { _currentObject = tatObject; _filePath = _currentDirectory + _currentObject.ObjectPhoto; _fileCompare = _filePath; Title = "Редактироване информации об объекте"; } _filePath = _currentDirectory + _currentObject.ObjectPhoto; DataContext = _currentObject; _photoName = _currentObject.ObjectPhoto; cmbType.ItemsSource = TatarCulturDbEntities.GetContext().Types.ToList(); }
private bool DetermineIfCurrentObjectIsSubObject(Models.Object @object) { var result = false; result = @object.ObjectTypeId switch { 4 => true, // HouseSettings 9 => true, // Comment 10 => true, // Image 11 => true, // History _ => false, }; return(result); }
public bool EvaluateCombination(Models.Object o) // check according to the condition { if (o.Condition != null) { var storedItem = DataLayer.DB.Inventory.Find(i => i.Name == o.Condition.Item); if (storedItem != null) { if (storedItem.Had & o.Condition.Value) { return(true); } } return(false); } return(true); }
public bool UpdateObject(Models.Object obj) { using (var entityConntext = new GeoViewerEntities()) { SecurityBLL.Current.CheckPermissionThrowException(new string[] { SecurityBLL.ROLE_VIEWS_EDIT, SecurityBLL.ROLE_VIEWS_MANAGE }); ValidateObject(obj); obj.LastEditedDate = DateTime.Now; obj.LastEditedUser = AppContext.Current.LogedInUser.Username; entityConntext.AttachUpdatedObject(obj); return(entityConntext.SaveChanges() > 0); } }
public static List <Models.Relationship> GetRelationships(Models.Object type) { var Related = Relationships.Distinct().ToList(); Relationships.Clear(); Related.ForEach((r) => { if (r.PrincipalObject == null) { r.PrincipalObject = type; } Console.WriteLine(r.PrincipalObject.Name + r.Type.GetArrow() + r.AncillaryObject.Name); }); return(Related); }
public override void Init(object initData) { base.Init(initData); Models.Object passedObject = (Models.Object)initData; if (passedObject != null) { IsEditMode = true; CreatedObject = passedObject; CurrentPage.Title = CreatedObject.Name; SaveButtonText = "Cохранить"; InitializeObjectToEditAsync(); } else { IsEditMode = false; } }
private void SetObjectsOnDay(Day day) { Models.Object first = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.FirstObj); Models.Object second = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.SecondObj); Models.Object third = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.ThirdObj); Models.Object fourth = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.FourthObj); Models.Object fifth = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.FifthObj); Models.Object sixth = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.SixthObj); Models.Object seventh = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.SeventhObj); Models.Object eighth = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.EighthObj); day.AddObject(first); day.AddObject(second); day.AddObject(third); day.AddObject(fourth); day.AddObject(fifth); day.AddObject(sixth); day.AddObject(seventh); day.AddObject(eighth); }
public void SaveHistory(History objectModel, long userId) { var objectTypeName = objectModel.GetType().Name; var objectTypeId = context.Set <ObjectType>().Where(x => x.Name == objectTypeName).FirstOrDefault().Id; var _object = new Models.Object() { CreatedById = userId, ModifiedById = userId, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, ObjectTypeId = objectTypeId }; context.Add(_object); context.SaveChanges(); context.Add <History>(objectModel); context.SaveChanges(); }
private void ReplaceObjectsOnDay(Day day) { Models.Object first = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.FirstObj); Models.Object second = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.SecondObj); Models.Object third = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.ThirdObj); Models.Object fourth = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.FourthObj); Models.Object fifth = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.FifthObj); Models.Object sixth = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.SixthObj); Models.Object seventh = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.SeventhObj); Models.Object eighth = db.Objects.FirstOrDefault(o => o.ObjectName == NewDay.EighthObj); day.AddChange(1, first); day.AddChange(2, second); day.AddChange(3, third); day.AddChange(4, fourth); day.AddChange(5, fifth); day.AddChange(6, sixth); day.AddChange(7, seventh); day.AddChange(8, eighth); }
/// <summary> /// Check the sensor corressponding to picture view object has running alarm? /// </summary> /// <param name="obj"></param> /// <returns></returns> public bool CheckAlarmRunning(Models.Object obj) { using (var entityContext = new GeoViewerEntities()) { if (obj.Type == OBJECT_TYPE_IMAGE) { return(false); } if (obj.Type != OBJECT_TYPE_GROUP_INDICATOR) { // Parameters contain id of sensor which will be displayed int sensorID = obj.Parameters.ToInt32TryParse(); var sensor = entityContext.Sensors.SingleOrDefault(ent => ent.SensorID == sensorID); if (sensor == null) { return(false); } return(sensor.AlarmEnabled && sensor.AlarmFlag); } // Get picture view corressponding to this object (type OBJECT_TYPE_GROUP_INDICATOR) int pictureID = obj.Parameters.ToInt32TryParse(); var pictureView = entityContext.PictureViews.SingleOrDefault(ent => ent.PictureViewID == pictureID); if (pictureView != null) { foreach (var viewObject in pictureView.Objects) { // Fix circle recursive if (viewObject.ObjectID == obj.ObjectID) { return(false); } if (CheckAlarmRunning(viewObject)) { return(true); } } } return(false); } }
public bool InsertObject(Models.Object obj) { bool result = false; using (var entityConntext = new GeoViewerEntities()) { SecurityBLL.Current.CheckPermissionThrowException(SecurityBLL.ROLE_VIEWS_MANAGE); ValidateObject(obj); obj.CreatedDate = obj.LastEditedDate = DateTime.Now; obj.CreatedUser = obj.LastEditedUser = AppContext.Current.LogedInUser.Username; entityConntext.Objects.AddObject(obj); result = entityConntext.SaveChanges() > 0; } if (obj.Type == OBJECT_TYPE_IMAGE && obj.ObjectID > 0) { string imagePath = PictureViewBLL.Current.CopyImageFile(obj.Parameters, obj.ObjectID); obj.Parameters = imagePath; UpdateObject(obj); } return(result); }
public async Task <ActionResult> Edit(ViewModels.EditObjectViewModel viewModel) { try { await this.ShowUser(userManager); var model = new Models.Object { Id = viewModel.Id, Address = viewModel.Address, Name = viewModel.Name }; context.Entry(model); context.Update(model); await context.SaveChangesAsync(); } catch { } return(View(viewModel)); }
public ActionResult Create(PostModel model) { string returnUrl = HttpContext.Request.Params["returnUrl"].Length > 0 ? HttpContext.Request.Params["returnUrl"] : HttpContext.Request.UrlReferrer.ToString(); if(ModelState.IsValid) { try { Entities dbContext = new Entities(); Models.Object obj = new Models.Object(); obj.EntityName = "Post"; dbContext.Objects.AddObject(obj); dbContext.SaveChanges(); Post post = new Post(); post.Id = obj.Id; post.UserId = new Guid(UserHelper.getLoggedInUserId()); post.PersonId = new Guid(HttpContext.Request.Params["personId"].Length > 0 ? HttpContext.Request.Params["personId"] : UserHelper.getLoggedInUserId()); post.Content = model.Content; post.CreatedAt = DateTime.Now; post.UpdatedAt = DateTime.Now; dbContext.Posts.AddObject(post); dbContext.SaveChanges(); return Redirect(returnUrl); }catch(Exception ex) { ModelState.AddModelError("", ex.Message); } } return View(model); }
public ActionResult Upload(string var = "") { int viewPhotoId = 0; try { foreach (string photoFile in Request.Files) { HttpPostedFileBase file = Request.Files[photoFile]; if (!(file.ContentLength > 0)) { throw new Exception("File is not a valid image."); } string fileExtension = Path.GetExtension(Path.GetFileName(file.FileName)); string fileName = UserHelper.getLoggedInUserId() + "_" + DateTime.Now.Ticks.ToString() + fileExtension; string filePath = Path.Combine(HttpContext.Server.MapPath("~/Uploads"), fileName); file.SaveAs(filePath); int albumId; if(!int.TryParse(HttpContext.Request.Params["albumId"], out albumId)) { throw new Exception("The requested album id is not a valid integer."); } Entities dbContext = new Entities(); var album = dbContext.Albums.SingleOrDefault(a => a.Id == albumId); Guid userGuid = new Guid(UserHelper.getLoggedInUserId()); if(album == null || album.UserId != userGuid) { throw new Exception("The album you are trying to upload the photo to is not available."); } Models.Object obj = new Models.Object(); obj.EntityName = "Photo"; dbContext.Objects.AddObject(obj); dbContext.SaveChanges(); Photo photo = new Photo(); photo.Id = obj.Id; photo.AlbumId = album.Id; photo.UserId = userGuid; photo.FilePath = fileName; photo.Caption = HttpContext.Request.Params["caption"]; photo.CreatedAt = DateTime.Now; dbContext.Photos.AddObject(photo); dbContext.SaveChanges(); viewPhotoId = photo.Id; } return RedirectToAction("ViewPhoto", "Photo", new { photoId = viewPhotoId }); }catch(Exception ex) { return Content(ex.Message); } }
// // Menu Edit -> Edit Information // //private void editInformationToolStripMenuItem_Click(object sender, EventArgs e) //{ // try // { // //using (PictureInformationForm f = new PictureInformationForm(_pictureView.Name, _pictureView.Description)) // //{ // // f.ShowDialog(); // // if (f.Submitted) // // { // // _pictureView.Name = f.PictureName; // // _pictureView.Description = f.PictureDescription; // // PictureViewBLL.Current.Update(_pictureView); // // this.Text = f.PictureName; // // } // //} // } // catch (Exception exception) // { // ShowErrorMessage(exception.Message); // } //} // // Menu Edit -> Add... // private void imageToolStripMenuItem_Click(object sender, EventArgs e) { try { if (openFileDialog.ShowDialog() == DialogResult.OK) { System.Windows.Forms.PictureBox newpicture = new System.Windows.Forms.PictureBox(); System.Drawing.Image image = System.Drawing.Image.FromFile(openFileDialog.FileName); GeoViewer.Models.Object obj = new Models.Object(); obj.PictureViewID = _pictureView.PictureViewID; obj.Type = 3; obj.X = 50; obj.Y = 50; obj.Width = image.Size.Width; obj.Height = image.Size.Height; obj.Parameters = openFileDialog.FileName; obj.Z_Index = 1; if (entityConntext.Objects. Where(ent => ent.PictureViewID == _pictureView.PictureViewID).OrderByDescending(ent => ent.Z_Index).Count() > 0) { var topObject = entityConntext.Objects. Where(ent => ent.PictureViewID == _pictureView.PictureViewID).OrderByDescending(ent => ent.Z_Index).First(); obj.Z_Index = topObject.Z_Index + 1; } obj.CreatedDate = DateTime.Now; obj.CreatedUser = AppContext.Current.LogedInUser.ToString(); if (PictureViewBLL.Current.InsertObject(obj)) { //Console.WriteLine("Insert Object Success, ID: " + obj.ObjectID); //PictureViewBLL.Current.Update(_pictureView); newpicture.Location = new System.Drawing.Point(50, 50); newpicture.ImageLocation = openFileDialog.FileName; newpicture.SizeMode = PictureBoxSizeMode.StretchImage; newpicture.Size = image.Size; newpicture.AccessibleName = obj.ObjectID.ToString(); newpicture.AccessibleDescription = "3"; this.panel.Controls.Add(newpicture); newpicture.BringToFront(); ControlMouseMoveEventRegister(newpicture); pb.WireControl(newpicture); // Edited by binhpro 22/11/2012 //string imagePath = PictureViewBLL.Current.CopyImageFile(openFileDialog.FileName, obj.ObjectID); //obj.Parameters = imagePath; //PictureViewBLL.Current.UpdateObject(obj); } } } catch (Exception exception) { ShowErrorMessage(exception.Message); } }
private void horizontalBarToolStripMenuItem_Click(object sender, EventArgs e) { try { GeoViewer.Models.Object obj = new Models.Object(); obj.PictureViewID = _pictureView.PictureViewID; obj.Type = 6; obj.X = 50; obj.Y = 50; obj.Width = 400; obj.Height = 100; obj.Parameters = "0"; obj.Z_Index = 1; if (entityConntext.Objects. Where(ent => ent.PictureViewID == _pictureView.PictureViewID).OrderByDescending(ent => ent.Z_Index).Count() > 0) { var topObject = entityConntext.Objects. Where(ent => ent.PictureViewID == _pictureView.PictureViewID).OrderByDescending(ent => ent.Z_Index).First(); obj.Z_Index = topObject.Z_Index + 1; } obj.CreatedDate = DateTime.Now; obj.CreatedUser = AppContext.Current.LogedInUser.ToString(); if (PictureViewBLL.Current.InsertObject(obj)) { Console.WriteLine("Insert Object Success, ID: " + obj.ObjectID); PictureViewBLL.Current.Update(_pictureView); Dundas.Gauges.WinControl.LinearGauge linearGauge1 = new Dundas.Gauges.WinControl.LinearGauge(); Dundas.Gauges.WinControl.LinearPointer linearPointer1 = new Dundas.Gauges.WinControl.LinearPointer(); Dundas.Gauges.WinControl.LinearScale linearScale1 = new Dundas.Gauges.WinControl.LinearScale(); Dundas.Gauges.WinControl.InputValue inputValue1 = new Dundas.Gauges.WinControl.InputValue(); Dundas.Gauges.WinControl.GaugeContainer gaugeContainer1 = new Dundas.Gauges.WinControl.GaugeContainer(); Dundas.Gauges.WinControl.GaugeLabel gaugeLabel1 = new Dundas.Gauges.WinControl.GaugeLabel(); gaugeContainer1.BackFrame.BackColor = System.Drawing.Color.White; gaugeContainer1.BackFrame.BackGradientEndColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(59)))), ((int)(((byte)(105))))); gaugeContainer1.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None; gaugeContainer1.BackFrame.FrameGradientEndColor = System.Drawing.Color.DimGray; gaugeContainer1.BackFrame.FrameGradientType = Dundas.Gauges.WinControl.GradientType.None; gaugeContainer1.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.Rectangular; gaugeContainer1.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.None; gaugeContainer1.BackFrame.FrameWidth = 2F; gaugeContainer1.InternalBackgroundPaint = false; gaugeContainer1.LinearGauges.Add(linearGauge1); gaugeLabel1.BackColor = System.Drawing.Color.Empty; gaugeLabel1.BackGradientEndColor = System.Drawing.Color.Empty; gaugeLabel1.Location.X = 32F; gaugeLabel1.Location.Y = 62F; gaugeLabel1.Name = "Default"; gaugeLabel1.Parent = "LinearGauges.Default"; gaugeLabel1.Size.Height = 34F; gaugeLabel1.Size.Width = 39F; gaugeLabel1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; gaugeLabel1.Text = ""; gaugeContainer1.Labels.Add(gaugeLabel1); linearGauge1.BackFrame.BackColor = System.Drawing.Color.White; linearGauge1.BackFrame.BackGradientEndColor = System.Drawing.Color.DimGray; linearGauge1.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None; linearGauge1.BackFrame.FrameColor = System.Drawing.Color.Silver; linearGauge1.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.Rectangular; linearGauge1.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.Edged; linearGauge1.BackFrame.FrameWidth = 2F; linearGauge1.Location.X = 0F; linearGauge1.Location.Y = 0F; linearGauge1.Name = "Default"; linearGauge1.Orientation = Dundas.Gauges.WinControl.GaugeOrientation.Horizontal; linearPointer1.BorderWidth = 0; linearPointer1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(156)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); System.Drawing.ColorConverter cv = new System.Drawing.ColorConverter(); linearPointer1.BorderWidth = 0; linearPointer1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(188)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); linearPointer1.FillGradientEndColor = System.Drawing.Color.FromArgb(((int)(((byte)(182)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); linearPointer1.FillGradientType = Dundas.Gauges.WinControl.GradientType.None; linearPointer1.Name = "Default"; linearPointer1.ShadowOffset = 0F; linearPointer1.ThermometerBackColor = System.Drawing.Color.Empty; linearPointer1.ThermometerBackGradientEndColor = System.Drawing.Color.Empty; linearPointer1.Type = Dundas.Gauges.WinControl.LinearPointerType.Bar; linearPointer1.Placement = Dundas.Gauges.WinControl.Placement.Cross; linearPointer1.Width = 15F; linearGauge1.Pointers.Add(linearPointer1); linearScale1.Minimum = 0D; linearScale1.Maximum = 100D; linearScale1.EndMargin = 5F; linearScale1.FillColor = System.Drawing.Color.Black; linearScale1.LabelStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 16.30189F); linearScale1.MajorTickMark.BorderWidth = 0; linearScale1.MajorTickMark.FillColor = System.Drawing.Color.Black; linearScale1.MajorTickMark.Length = 20F; linearScale1.MajorTickMark.Width = 2F; linearScale1.MinorTickMark.BorderWidth = 0; linearScale1.MinorTickMark.FillColor = System.Drawing.Color.Black; linearScale1.MinorTickMark.Length = 12F; linearScale1.MinorTickMark.Width = 1.5F; linearScale1.Name = "Default"; linearScale1.Position = 45F; linearScale1.ShadowOffset = 0F; linearScale1.StartMargin = 5F; linearScale1.Width = 0F; linearGauge1.Scales.Add(linearScale1); linearGauge1.Size.Height = 100F; linearGauge1.Size.Width = 100F; gaugeContainer1.Location = new System.Drawing.Point(50, 50); gaugeContainer1.Size = new System.Drawing.Size(300, 100); gaugeContainer1.TabIndex = 0; this.Controls.Add(gaugeContainer1); gaugeContainer1.BringToFront(); gaugeContainer1.LinearGauges["Default"].Pointers["Default"].Value = 0; gaugeContainer1.Name = obj.ObjectID.ToString(); gaugeContainer1.Location = new System.Drawing.Point(50, 50); gaugeContainer1.Size = new System.Drawing.Size(400, 100); gaugeContainer1.AccessibleName = obj.ObjectID.ToString(); gaugeContainer1.AccessibleDescription = "6"; this.panel.Controls.Add(gaugeContainer1); gaugeContainer1.BringToFront(); ControlMouseMoveEventRegister(gaugeContainer1); pb.WireControl(gaugeContainer1); } } catch (Exception exception) { ShowErrorMessage(exception.Message); } }
private void groupIndicatorToolStripMenuItem_Click(object sender, EventArgs e) { try { GeoViewer.Models.Object obj = new Models.Object(); obj.PictureViewID = _pictureView.PictureViewID; obj.Type = 2; obj.X = 50; obj.Y = 50; obj.Width = 20; obj.Height = 20; obj.Parameters = "0"; obj.Z_Index = 1; if (entityConntext.Objects. Where(ent => ent.PictureViewID == _pictureView.PictureViewID).OrderByDescending(ent => ent.Z_Index).Count() > 0) { var topObject = entityConntext.Objects. Where(ent => ent.PictureViewID == _pictureView.PictureViewID).OrderByDescending(ent => ent.Z_Index).First(); obj.Z_Index = topObject.Z_Index + 1; } obj.CreatedDate = DateTime.Now; obj.CreatedUser = AppContext.Current.LogedInUser.ToString(); if (PictureViewBLL.Current.InsertObject(obj)) { Console.WriteLine("Insert Object Success, ID: " + obj.ObjectID); PictureViewBLL.Current.Update(_pictureView); groupIndicator i = new groupIndicator(); i.Location = new Point(50, 50); i.FillColor = Color.Lime; i.BackColor = Color.Transparent; i.Size = new Size(20, 20); i.AccessibleName = obj.ObjectID.ToString(); i.AccessibleDescription = "2"; this.panel.Controls.Add(i); i.BringToFront(); ControlMouseMoveEventRegister(i); pb.WireControl(i); } } catch (Exception exception) { ShowErrorMessage(exception.Message); } }
private void gaugeToolStripMenuItem_Click(object sender, EventArgs e) { try { GeoViewer.Models.Object obj = new Models.Object(); obj.PictureViewID = _pictureView.PictureViewID; obj.Type = 4; obj.X = 50; obj.Y = 50; obj.Width = 100; obj.Height = 100; obj.Parameters = "0"; obj.Z_Index = 1; if (entityConntext.Objects. Where(ent => ent.PictureViewID == _pictureView.PictureViewID).OrderByDescending(ent => ent.Z_Index).Count() > 0) { var topObject = entityConntext.Objects. Where(ent => ent.PictureViewID == _pictureView.PictureViewID).OrderByDescending(ent => ent.Z_Index).First(); obj.Z_Index = topObject.Z_Index + 1; } obj.CreatedDate = DateTime.Now; obj.CreatedUser = AppContext.Current.LogedInUser.ToString(); if (PictureViewBLL.Current.InsertObject(obj)) { Console.WriteLine("Insert Object Success, ID: " + obj.ObjectID); PictureViewBLL.Current.Update(_pictureView); Dundas.Gauges.WinControl.GaugeContainer gaugeContainer = new Dundas.Gauges.WinControl.GaugeContainer(); Dundas.Gauges.WinControl.CircularGauge circularGauge = new Dundas.Gauges.WinControl.CircularGauge(); Dundas.Gauges.WinControl.CircularPointer circularPointer = new Dundas.Gauges.WinControl.CircularPointer(); Dundas.Gauges.WinControl.CircularScale circularScale = new Dundas.Gauges.WinControl.CircularScale(); Dundas.Gauges.WinControl.GaugeLabel gaugeLabel = new Dundas.Gauges.WinControl.GaugeLabel(); gaugeContainer.BackFrame.BackColor = System.Drawing.Color.Transparent; gaugeContainer.BackFrame.BackGradientEndColor = System.Drawing.Color.Transparent; gaugeContainer.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None; gaugeContainer.BackFrame.FrameColor = System.Drawing.Color.Transparent; gaugeContainer.BackFrame.FrameGradientEndColor = System.Drawing.Color.Transparent; gaugeContainer.BackFrame.FrameGradientType = Dundas.Gauges.WinControl.GradientType.None; gaugeContainer.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.AutoShape; gaugeContainer.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.Edged; gaugeContainer.BackFrame.FrameWidth = 0F; circularGauge.BackFrame.BackColor = System.Drawing.Color.White; circularGauge.BackFrame.BackGradientEndColor = System.Drawing.Color.White; circularGauge.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None; circularGauge.BackFrame.BorderColor = System.Drawing.Color.Gray; circularGauge.BackFrame.BorderWidth = 2; circularGauge.BackFrame.FrameColor = System.Drawing.Color.Transparent; circularGauge.BackFrame.FrameGradientEndColor = System.Drawing.Color.Transparent; circularGauge.BackFrame.FrameGradientType = Dundas.Gauges.WinControl.GradientType.None; circularGauge.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.Rectangular; circularGauge.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.Simple; circularGauge.BackFrame.FrameWidth = 0F; circularGauge.Location.X = 0F; circularGauge.Location.Y = 0F; circularGauge.Name = "Default"; circularGauge.PivotPoint.X = 50F; circularGauge.PivotPoint.Y = 45F; circularPointer.BorderStyle = Dundas.Gauges.WinControl.GaugeDashStyle.Solid; circularPointer.BorderWidth = 0; circularPointer.CapFillColor = System.Drawing.Color.DimGray; circularPointer.CapFillGradientType = Dundas.Gauges.WinControl.GradientType.None; circularPointer.CapWidth = 24F; circularPointer.FillColor = System.Drawing.Color.Lime; circularPointer.FillGradientEndColor = System.Drawing.Color.LightGray; circularPointer.FillGradientType = Dundas.Gauges.WinControl.GradientType.None; circularPointer.Name = "Default"; circularPointer.NeedleStyle = Dundas.Gauges.WinControl.NeedleStyle.NeedleStyle11; circularPointer.ShadowOffset = 0F; circularPointer.Width = 10F; circularPointer.Value = 0; circularGauge.Pointers.Add(circularPointer); circularScale.BorderColor = System.Drawing.Color.White; circularScale.BorderWidth = 1; circularScale.FillColor = System.Drawing.Color.Black; circularScale.LabelStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 16.30189F); circularScale.LabelStyle.RotateLabels = false; circularScale.MajorTickMark.BorderWidth = 0; circularScale.MajorTickMark.FillColor = System.Drawing.Color.Black; circularScale.MajorTickMark.Shape = Dundas.Gauges.WinControl.MarkerStyle.Rectangle; circularScale.MajorTickMark.Width = 2F; circularScale.MinorTickMark.BorderWidth = 0; circularScale.MinorTickMark.FillColor = System.Drawing.Color.Black; circularScale.MinorTickMark.Width = 1.5F; circularScale.Minimum = 0D; circularScale.Maximum = 100D; circularScale.Name = "Default"; circularScale.Radius = 44F; circularScale.ShadowOffset = 0F; circularScale.StartAngle = 30F; circularScale.SweepAngle = 300F; circularScale.Width = 0F; circularGauge.Scales.Add(circularScale); circularGauge.Size.Height = 100F; circularGauge.Size.Width = 100F; gaugeContainer.CircularGauges.Add(circularGauge); gaugeContainer.InternalBackgroundPaint = false; gaugeLabel.BackColor = System.Drawing.Color.Empty; gaugeLabel.BackGradientEndColor = System.Drawing.Color.Empty; gaugeLabel.Location.X = 19F; gaugeLabel.Location.Y = 80F; gaugeLabel.Name = "Default"; gaugeLabel.Parent = "CircularGauges.Default"; gaugeLabel.Size.Height = 18F; gaugeLabel.Size.Width = 66F; gaugeLabel.Text = ""; gaugeLabel.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; gaugeContainer.Labels.Add(gaugeLabel); gaugeContainer.Location = new System.Drawing.Point(50, 50); gaugeContainer.Name = obj.ObjectID.ToString(); gaugeContainer.Size = new System.Drawing.Size(100, 100); gaugeContainer.TabIndex = 0; gaugeContainer.Location = new System.Drawing.Point(50, 50); gaugeContainer.Size = new Size(100, 100); gaugeContainer.AccessibleName = obj.ObjectID.ToString(); gaugeContainer.AccessibleDescription = "4"; this.panel.Controls.Add(gaugeContainer); gaugeContainer.BringToFront(); ControlMouseMoveEventRegister(gaugeContainer); pb.WireControl(gaugeContainer); } } catch (Exception exception) { ShowErrorMessage(exception.Message); } }
private void numericIndicatorToolStripMenuItem_Click(object sender, EventArgs e) { try { GeoViewer.Models.Object obj = new Models.Object(); obj.PictureViewID = _pictureView.PictureViewID; obj.Type = 8; obj.X = 50; obj.Y = 50; obj.Width = 300; obj.Height = 80; obj.Parameters = "0"; obj.Z_Index = 1; if (entityConntext.Objects. Where(ent => ent.PictureViewID == _pictureView.PictureViewID).OrderByDescending(ent => ent.Z_Index).Count() > 0) { var topObject = entityConntext.Objects. Where(ent => ent.PictureViewID == _pictureView.PictureViewID).OrderByDescending(ent => ent.Z_Index).First(); obj.Z_Index = topObject.Z_Index + 1; } obj.CreatedDate = DateTime.Now; obj.CreatedUser = AppContext.Current.LogedInUser.ToString(); if (PictureViewBLL.Current.InsertObject(obj)) { Console.WriteLine("Insert Object Success, ID: " + obj.ObjectID); PictureViewBLL.Current.Update(_pictureView); Dundas.Gauges.WinControl.GaugeContainer gaugeContainer2 = new Dundas.Gauges.WinControl.GaugeContainer(); Dundas.Gauges.WinControl.GaugeLabel gaugeLabel2 = new Dundas.Gauges.WinControl.GaugeLabel(); Dundas.Gauges.WinControl.NumericIndicator numericIndicator = new Dundas.Gauges.WinControl.NumericIndicator(); gaugeContainer2.BackFrame.BackColor = System.Drawing.Color.White; gaugeContainer2.BackFrame.BackGradientEndColor = System.Drawing.Color.White; gaugeContainer2.BackFrame.BackGradientType = Dundas.Gauges.WinControl.GradientType.None; gaugeContainer2.BackFrame.BorderWidth = 2; gaugeContainer2.BackFrame.FrameGradientEndColor = System.Drawing.Color.DimGray; gaugeContainer2.BackFrame.FrameGradientType = Dundas.Gauges.WinControl.GradientType.None; gaugeContainer2.BackFrame.FrameShape = Dundas.Gauges.WinControl.BackFrameShape.Rectangular; gaugeContainer2.BackFrame.FrameStyle = Dundas.Gauges.WinControl.BackFrameStyle.Simple; gaugeContainer2.BackFrame.FrameWidth = 0F; gaugeContainer2.InternalBackgroundPaint = false; gaugeContainer2.NumericIndicators.Add(numericIndicator); numericIndicator.BackColor = System.Drawing.Color.Transparent; numericIndicator.BackGradientType = Dundas.Gauges.WinControl.GradientType.None; numericIndicator.BorderColor = System.Drawing.Color.Black; numericIndicator.BorderWidth = 0; numericIndicator.DecimalColor = System.Drawing.Color.Black; numericIndicator.Decimals = 2; numericIndicator.DigitColor = System.Drawing.Color.Black; numericIndicator.IndicatorStyle = Dundas.Gauges.WinControl.NumericIndicatorStyle.Digital7Segment; numericIndicator.LedDimColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); numericIndicator.Location.X = 0F; numericIndicator.Location.Y = -20F; numericIndicator.Name = "Default"; numericIndicator.Parent = ""; numericIndicator.ShowDecimalPoint = true; numericIndicator.Size.Height = 99F; numericIndicator.Size.Width = 99F; numericIndicator.Value = 367.12D; numericIndicator.Digits = 6; gaugeLabel2.BackColor = System.Drawing.Color.Empty; gaugeLabel2.BackGradientEndColor = System.Drawing.Color.Empty; gaugeLabel2.Location.X = 26F; gaugeLabel2.Location.Y = 75F; gaugeLabel2.Name = "Default"; gaugeLabel2.Parent = "NumericIndicators.Default"; gaugeLabel2.Size.Height = 50F; gaugeLabel2.Size.Width = 51F; gaugeLabel2.Text = ""; gaugeLabel2.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; gaugeContainer2.Labels.Add(gaugeLabel2); gaugeContainer2.Location = new System.Drawing.Point(50, 50); gaugeContainer2.Name = obj.ObjectID.ToString(); gaugeContainer2.Size = new System.Drawing.Size(200, 100); gaugeContainer2.TabIndex = 0; gaugeContainer2.NumericIndicators["Default"].Value = 0; gaugeContainer2.Location = new System.Drawing.Point(50, 50); gaugeContainer2.Size = new Size(300, 80); gaugeContainer2.AccessibleName = obj.ObjectID.ToString(); gaugeContainer2.AccessibleDescription = "8"; this.panel.Controls.Add(gaugeContainer2); gaugeContainer2.BringToFront(); ControlMouseMoveEventRegister(gaugeContainer2); pb.WireControl(gaugeContainer2); } } catch (Exception exception) { ShowErrorMessage(exception.Message); } }