public async Task <bool> EditOtterAsync(Otter otter, string UserID) { string[] data; data = otter.PlaceName.Split(';'); Otter = new Otter() { TattooID = otter.TattooID, Name = otter.Name, Color = otter.Color, MotherId = otter.MotherId, PlaceName = data[0], LocationId = int.Parse(data[1]), founderID = otter.founderID }; _context.Attach(Otter).State = EntityState.Modified; try { await _context.SaveChangesAsync(); return(true); } catch (DbUpdateConcurrencyException) { throw; } }
public IActionResult Register(Otter newbie) { if (ModelState.IsValid) { // this will return a boolean if (_context.Otters.Any(o => o.Name == newbie.Name)) { ModelState.AddModelError("Name", "Choose anotter name!!!"); ViewBag.Otters = _context.Otters.ToList(); //important to have return(View("Index")); } else { _context.Otters.Add(newbie); _context.SaveChanges(); HttpContext.Session.SetInt32("OtterId", newbie.OtterId); return(Redirect($"/dashboard/{newbie.OtterId}")); } } else { ViewBag.Otters = _context.Otters.ToList(); //very important to have in all where it is index return(View("Index")); } }
static void Main(string[] args) { //abstract /*Animal animal; * * animal = new Kucing(); * animal.karakteristik(); * * Console.WriteLine(); * animal = new Otter(); * animal.karakteristik();*/ //interface IAnimal animal; animal = new Kucing(); animal.karakteristik(); Console.WriteLine(); animal = new Otter(); animal.karakteristik(); Console.ReadKey(); }
public async Task <IActionResult> OnGetAsync(int?id) { Otter = await _context.Otters .Include(o => o.Founder) .Include(o => o.Mother) .Include(o => o.Place.Location) .Include(o => o.Place).FirstOrDefaultAsync(m => m.TattooID == id); return(Page()); }
public async Task <IActionResult> OnPostAsync() { /*if (!ModelState.IsValid) * { * return Page(); * }*/ Otter = await _otterservice.CreateOtterAsync(Otter, GetUserId()); return(RedirectToPage("./Index")); }
/// <summary> /// Adds a message to the datagrid /// </summary> /// <param name="message"></param> private void AddMessageToDataGrid(Otter.UI.Message message) { int index = mMessagesDataGrid.Rows.Add(); // Prepare the Character Code cell DataGridViewTextBoxCell textCell = mMessagesDataGrid.Rows[index].Cells[0] as DataGridViewTextBoxCell; DataGridViewTextBoxCell descCell = mMessagesDataGrid.Rows[index].Cells[1] as DataGridViewTextBoxCell; textCell.Value = message.Text; descCell.Value = message.Description; // Finalize the row mMessagesDataGrid.Rows[index].Tag = message; }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Otter = await _otterservice.GetFullOtterAsync(id); if (Otter == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { Otter = _context.Otters.Find(id); if (GetUserId() == Otter.FounderId) { if (Otter != null) { _context.Otters.Remove(Otter); await _context.SaveChangesAsync(); } return(RedirectToPage("../Index")); } else { return(RedirectToPage("./Denied")); } }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Otter = await _context.Otters.FindAsync(id); if (Otter != null) { _context.Otters.Remove(Otter); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Otter = await _otterservice.GetFullOtterAsync(id); if (Otter == null) { return(NotFound()); } if (Otter.founderID == GetUserId() || User.IsInRole("Administrator")) { return(Page()); } return(LocalRedirect("~/Identity/Account/AccessDenied")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Otter = await _context.Otters .Include(o => o.Founder) .Include(o => o.Mother) .Include(o => o.Place).FirstOrDefaultAsync(m => m.TattooID == id); if (Otter == null) { return(NotFound()); } return(Page()); }
public async Task <Otter> CreateOtterAsync(Otter otter, string UserID) { string[] data; data = otter.PlaceName.Split(';'); Otter = new Otter() { Name = otter.Name, Color = otter.Color, MotherId = otter.MotherId, PlaceName = data[0], LocationId = int.Parse(data[1]), founderID = UserID }; _context.Otters.Add(Otter); await _context.SaveChangesAsync(); return(Otter); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Otter = await _context.Otters .Include(o => o.Founder) .Include(o => o.Mother) .Include(o => o.Place).FirstOrDefaultAsync(m => m.TattooID == id); if (Otter == null) { return(NotFound()); } ViewData["FounderId"] = new SelectList(_context.Users, "Id", "Id"); ViewData["MotherId"] = new SelectList(_context.Otters, "TattooID", "TattooID"); ViewData["PlaceName"] = new SelectList(_context.Places, "Name", "Name"); return(Page()); }
public IActionResult Dashboard(int otterId) { if (HttpContext.Session.GetInt32("OtterId") == null) { return(RedirectToAction("Logout")); } Otter otterInDb = _context.Otters .Include(o => o.PlannedVacations) .FirstOrDefault(o => o.OtterId == otterId); ViewBag.myVacays = otterInDb.PlannedVacations .OrderBy(v => v.StartDate).ToList(); ViewBag.Otter = otterInDb; List <Vacation> AllTrip = _context.Vacations .Include(v => v.GroupMembers) .ThenInclude(a => a.Traveller) .Include(v => v.Planner) .ToList(); return(View(AllTrip)); }
public IActionResult Dashboard(int otterId) { if (HttpContext.Session.GetInt32("OtterId") == null) { return(RedirectToAction("Logout")); //this checks if there is a user in session and if not, redirects to logging out method. } Otter otterInDb = _context.Otters .Include(o => o.PlannedVacations) .FirstOrDefault(o => o.OtterId == otterId); ViewBag.myVacays = otterInDb.PlannedVacations .OrderBy(v => v.StartDate).ToList(); ViewBag.Otter = otterInDb; List <Vacation> AllTrips = _context.Vacations .Include(v => v.GroupMembers) .ThenInclude(a => a.Traveller) //you need to switch from v to a because you are now switching to a different model .Include(v => v.Planner) .ToList(); return(View(AllTrips)); }
/// <summary> /// Draws the table /// </summary> /// <param name="graphics"></param> public override void Draw(Otter.Interface.Graphics graphics) { int rowIndex = 0; int colEven = Color.FromArgb(200, Color.Gainsboro).ToArgb(); int colOdd = Color.FromArgb(200, Color.WhiteSmoke).ToArgb(); for (float y = 0; y < Layout.Size.Height; y += (float)(DefaultRowHeight + RowSpacing)) { float height = (Layout.Size.Height - y) > DefaultRowHeight ? DefaultRowHeight : (Layout.Size.Height - y); int col = (rowIndex == 0) ? colEven : colOdd; graphics.DrawRectangle(-1, 0.0f, y, Layout.Size.Width, height, col); rowIndex = (++rowIndex) % 2; } }
/// <summary> /// Exports the table /// </summary> /// <param name="bw"></param> public override void Export(Otter.Export.PlatformBinaryWriter bw) { FourCCStack fourCCStack = new FourCCStack(bw); fourCCStack.Push("GTBL"); { base.Export(bw); bw.Write(DefaultRowHeight); bw.Write(RowSpacing); } fourCCStack.Pop(); }
/// <summary> /// Exports the Circle /// </summary> /// <param name="bw"></param> public override void Export(Otter.Export.PlatformBinaryWriter bw) { FourCCStack fourCCStack = new FourCCStack(bw); fourCCStack.Push("CIRC"); { base.Export(bw); bw.Write((UInt32)Segments); bw.Write((UInt32)Radius); bw.Write((UInt32)Width); bw.Write((UInt32)this.Color.ToArgb()); } fourCCStack.Pop(); }
/// <summary> /// Draws the Circle. /// </summary> /// <param name="graphics"></param> public override void Draw(Otter.Interface.Graphics graphics) { // Do not draw if there are less than 3 segments in the circle if(Segments <= 2) return; Triangle[] triangles = new Triangle[Segments * 2]; double x = 1.0f; double y = 0.0f; float radius = ((CircleLayout)Layout).Radius; uint halfWidth = ((CircleLayout)Layout).Width / 2; Color color = ((CircleLayout)Layout).Color; PointF center = new PointF(Layout.Size.Width / 2.0f, Layout.Size.Height / 2.0f); // For each segment create two triangles for (int i = 0; i < Segments; i++) { double angle1 = (i / (double)Segments) * Math.PI * 2; double angle2 = ((i + 1) / (double)Segments) * Math.PI * 2; float rx1 = (float)(x * Math.Cos(angle1) - y * Math.Sin(angle1)); float ry1 = (float)(x * Math.Sin(angle1) + y * Math.Cos(angle1)); float rx2 = (float)(x * Math.Cos(angle2) - y * Math.Sin(angle2)); float ry2 = (float)(x * Math.Sin(angle2) + y * Math.Cos(angle2)); triangles[i * 2 + 0] = new Triangle(); triangles[i * 2 + 0].SetVertex(0, center.X + rx1 * (radius + halfWidth), center.Y + ry1 * (radius + halfWidth), 0.0f, 0.0f, 0.0f, color.ToArgb()); triangles[i * 2 + 0].SetVertex(1, center.X + rx2 * (radius + halfWidth), center.Y + ry2 * (radius + halfWidth), 0.0f, 0.0f, 0.0f, color.ToArgb()); triangles[i * 2 + 0].SetVertex(2, center.X + rx1 * (radius - halfWidth), center.Y + ry1 * (radius - halfWidth), 0.0f, 0.0f, 0.0f, color.ToArgb()); triangles[i * 2 + 1] = new Triangle(); triangles[i * 2 + 1].SetVertex(0, center.X + rx1 * (radius - halfWidth), center.Y + ry1 * (radius - halfWidth), 0.0f, 0.0f, 0.0f, color.ToArgb()); triangles[i * 2 + 1].SetVertex(1, center.X + rx2 * (radius + halfWidth), center.Y + ry2 * (radius + halfWidth), 0.0f, 0.0f, 0.0f, color.ToArgb()); triangles[i * 2 + 1].SetVertex(2, center.X + rx2 * (radius - halfWidth), center.Y + ry2 * (radius - halfWidth), 0.0f, 0.0f, 0.0f, color.ToArgb()); } graphics.DrawTriangles(-1, triangles); }
/// <summary> /// Draws the Slider /// </summary> public override void Draw(Otter.Interface.Graphics graphics) { TextureInfo info = null; info = Scene.GetTextureInfo(mStartTextureID); int startTexID = (info != null) ? info.TextureID : -1; info = Scene.GetTextureInfo(mMiddleTextureID); int middleTexID = (info != null) ? info.TextureID : -1; info = Scene.GetTextureInfo(mEndTextureID); int endTexID = (info != null) ? info.TextureID : -1; info = Scene.GetTextureInfo(mThumbTextureID); int thumbTexID = (info != null) ? info.TextureID : -1; float x = 0.0f; float y = Layout.Size.Height / 2.0f - ThumbHeight / 2.0f; float midWidth = Math.Max(0.0f, Layout.Size.Width - ThumbWidth * 2.0f); int col = ((SliderLayout)Layout).Color.ToArgb(); graphics.DrawRectangle(startTexID, x, y, ThumbWidth, ThumbHeight, col); x += ThumbWidth; graphics.DrawRectangle(middleTexID, x, y, midWidth, ThumbHeight, col); x += midWidth; graphics.DrawRectangle(endTexID, x, y, ThumbWidth, ThumbHeight, col); x = ThumbWidth + midWidth / 2.0f - ThumbWidth / 2.0f; graphics.DrawRectangle(thumbTexID, x, y, ThumbWidth, ThumbHeight, col); }
/// <summary> /// Draws the mask /// </summary> public override void Draw(Otter.Interface.Graphics graphics) { if (Hidden) return; //draw a placeholder sprite to show the mask's position TextureInfo info = Scene.GetTextureInfo(mTextureID); int texID = (info != null) ? info.TextureID : -1; switch (Flip) { case GUISprite.FlipType.None: { graphics.DrawRectangle(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 0.0f, 0.0f, 1.0f, 1.0f, Color.ToArgb(), Skew, -1); break; } case GUISprite.FlipType.Vertical: { graphics.DrawRectangle(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 0.0f, 1.0f, 1.0f, 0.0f, Color.ToArgb(), Skew, -1); break; } case GUISprite.FlipType.Horizontal: { graphics.DrawRectangle(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 1.0f, 0.0f, 0.0f, 1.0f, Color.ToArgb(), -Skew, -1); break; } } }
/// <summary> /// Updates the texture information /// </summary> /// <param name="info"></param> private void UpdateInfo(Otter.UI.Resources.SoundInfo info) { if (info == null) { mDetailsGroupBox.Enabled = false; mReferencesListView.Groups.Clear(); mReferencesListView.Items.Clear(); mSizeTextBox.Text = ""; mFilenameTextBox.Text = ""; return; } mDetailsGroupBox.Enabled = true; System.IO.FileInfo fileInfo = new System.IO.FileInfo(GUIProject.CurrentProject.ProjectDirectory + "/" + info.Filename); mSizeTextBox.Text = fileInfo.Exists ? fileInfo.Length.ToString() : "(file not found)"; mFilenameTextBox.Text = info.Filename; mReferencesListView.Groups.Clear(); mReferencesListView.Items.Clear(); Reference[] references = GetReferences(info); foreach (Reference reference in references) { ListViewGroup group = new ListViewGroup(reference.View.Name); group.Tag = reference.View; mReferencesListView.Groups.Add(group); foreach (GUIAnimation animation in reference.Animations) { ListViewItem item = new ListViewItem(animation.Name); item.Tag = animation; item.Group = group; mReferencesListView.Items.Add(item); } } mPlayButton.Enabled = info.IsPlayable(); mRemoveButton.Enabled = (mReferencesListView.Groups.Count == 0); }
/// <summary> /// Called when the selected texture has changed /// </summary> /// <param name="sender"></param> /// <param name="info"></param> private void mTextureList_SelectedTextureChanged(object sender, Otter.UI.Resources.TextureInfo info) { mDetailsGroupBox.Enabled = (info != null); mReferencesListView.Groups.Clear(); mReferencesListView.Items.Clear(); mFilenameTextBox.Text = ""; mRefreshButton.Enabled = (info != null); if (info != null) { if (info.TextureID != -1) { mWidthTextBox.Text = info.Width.ToString(); mHeightTextBox.Text = info.Height.ToString(); } else { mWidthTextBox.Text = "(unknown)"; mHeightTextBox.Text = "(unknown)"; } UpdateInfo(info); } }
/// <summary> /// Updates the texture information /// </summary> /// <param name="info"></param> private void UpdateInfo(Otter.UI.Resources.TextureInfo info) { if (info == null) { mDetailsGroupBox.Enabled = false; mAtlasCheckbox.Checked = false; return; } System.IO.FileInfo fileInfo = new System.IO.FileInfo(GUIProject.CurrentProject.ProjectDirectory + "/" + info.Filename); mSizeTextBox.Text = fileInfo.Exists ? String.Format("{0:N0}", fileInfo.Length) : "(file not found)"; mFilenameTextBox.Text = info.Filename; mPopulatingInfo = true; { mAtlasCheckbox.Checked = !info.NoAtlas; mOverrideNumericUpDown.Value = (info.AtlasPadding >= 0) ? info.AtlasPadding : 0; mOverrideCheckbox.Checked = info.AtlasPadding >= 0; mPaddingTypeComboBox.SelectedItem = info.AtlasBorderType; mOverrideNumericUpDown.Enabled = mAtlasCheckbox.Checked && mOverrideCheckbox.Checked; mOverrideCheckbox.Enabled = mAtlasCheckbox.Checked; mPaddingTypeComboBox.Enabled = mAtlasCheckbox.Checked; mPaddingTypeLabel.Enabled = mAtlasCheckbox.Checked; Reference[] references = GetReferences(info); foreach (Reference reference in references) { ListViewGroup group = new ListViewGroup(reference.View.Name); group.Tag = reference.View; mReferencesListView.Groups.Add(group); foreach (UI.GUIControl control in reference.Controls) { ListViewItem item = new ListViewItem(control.Name); item.Tag = control; item.Group = group; mReferencesListView.Items.Add(item); } } mRemoveButton.Enabled = (references.Length == 0); } mPopulatingInfo = false; }
/// <summary> /// Draws the button /// </summary> public override void Draw(Otter.Interface.Graphics graphics) { TextureInfo info = Scene.GetTextureInfo(mCurrentState == ButtonState.Default ? mDefaultTextureID : mDownTextureID); Color color = mCurrentState == ButtonState.Default ? mDefaultColor : mDownColor; int texID = (info != null) ? info.TextureID : -1; graphics.DrawRectangle(texID, 0.0f, 0.0f, this.Size.Width, this.Size.Height, color.ToArgb()); if (mLabel.Text != "") { GUIFont font = GUIProject.CurrentProject.GetFont(mLabel.FontID); if (font != null) { ButtonLayout layout = Layout as ButtonLayout; font.Draw(mLabel.Text, 0, 0, layout.Size.Width, layout.Size.Height, layout.TextColor, layout.TextScale, HorizontalAlignment, VerticalAlignment); } } }
/// <summary> /// Draws the group /// </summary> public override void Draw(Otter.Interface.Graphics graphics) { graphics.DrawRectangle(-1, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, mColor.ToArgb()); base.Draw(graphics); }
/// <summary> /// Draws the Toggle /// </summary> /// <param name="graphics"></param> public override void Draw(Otter.Interface.Graphics graphics) { TextureInfo info = Scene.GetTextureInfo(DefaultState == ToggleState.On ? OnTexture : OffTexture); int texID = (info != null) ? info.TextureID : -1; graphics.DrawRectangle(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, ((ToggleLayout)Layout).Color.ToArgb()); }
public void DrawMask(Otter.Interface.Graphics graphics) { //set our stored matrix as the stencil matrix graphics.SetStencilMatrix(this.FullTransform.Entries); TextureInfo info = Scene.GetTextureInfo(mTextureID); int texID = (info != null) ? info.TextureID : -1; switch (Flip) { case GUISprite.FlipType.None: { graphics.DrawRectangleStencil(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 0.0f, 0.0f, 1.0f, 1.0f, Color.White.ToArgb(), Skew, ID); break; } case GUISprite.FlipType.Vertical: { graphics.DrawRectangleStencil(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 0.0f, 1.0f, 1.0f, 0.0f, Color.White.ToArgb(), Skew, ID); break; } case GUISprite.FlipType.Horizontal: { graphics.DrawRectangleStencil(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 1.0f, 0.0f, 0.0f, 1.0f, Color.White.ToArgb(), -Skew, ID); break; } } }
/// <summary> /// Draws the sprite /// </summary> public override void Draw(Otter.Interface.Graphics graphics) { TextureInfo info = Scene.GetTextureInfo(mTextureID); int texID = (info != null) ? info.TextureID : -1; switch(Flip) { case FlipType.None: { graphics.DrawRectangle(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 0.0f, 0.0f, 1.0f, 1.0f, ((SpriteLayout)Layout).Color.ToArgb(), Skew, InheritedMask); break; } case FlipType.Vertical: { graphics.DrawRectangle(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 0.0f, 1.0f, 1.0f, 0.0f, ((SpriteLayout)Layout).Color.ToArgb(), Skew, InheritedMask); break; } case FlipType.Horizontal: { graphics.DrawRectangle(texID, 0.0f, 0.0f, Layout.Size.Width, Layout.Size.Height, 1.0f, 0.0f, 0.0f, 1.0f, ((SpriteLayout)Layout).Color.ToArgb(), -Skew, InheritedMask); break; } } base.Draw(graphics); }
/// <summary> /// Draws the label /// </summary> public override void Draw(Otter.Interface.Graphics graphics) { if(mText == "" || mText == null) return; if (mFont == null) return; LabelLayout layout = Layout as LabelLayout; mFont.Draw(mText, 0, 0, layout.Size.Width, layout.Size.Height, layout.Color, layout.Scale, HorizontalAlignment, VerticalAlignment, mLeading, mTracking, Skew, mTextFit, DropShadow, InheritedMask); }
/// <summary> /// Exports the Toggle /// </summary> /// <param name="bw"></param> public override void Export(Otter.Export.PlatformBinaryWriter bw) { FourCCStack fourCCStack = new FourCCStack(bw); fourCCStack.Push("GTGL"); { base.Export(bw); bw.Write(Scene.GetUniqueTextureID(OnTexture)); bw.Write(Scene.GetUniqueTextureID(OffTexture)); bw.Write(Color.White.ToArgb()); } fourCCStack.Pop(); }