// GET: Movie/Edit/5 public ActionResult Edit(int id) { if (Authenticate.IsAuthenticated()) { ViewBag.Title = "Edit"; MovieGenresDirectorsRatingsFormats mgdrf = new MovieGenresDirectorsRatingsFormats(); mgdrf.Movie = MovieManager.LoadByID(id); mgdrf.Directors = DirectorManager.Load(); mgdrf.Genres = GenreManager.Load(); mgdrf.Ratings = RatingManager.Load(); mgdrf.Formats = FormatManager.Load(); IEnumerable <int> existingGenreIds = new List <int>(); mgdrf.Movie.Genres = MovieManager.LoadGenres(id); mgdrf.GenreIds = mgdrf.Movie.Genres.Select(a => a.Id); //put genres in session Session["genreids"] = mgdrf.GenreIds; return(View(mgdrf)); } else { return(RedirectToAction("Login", "User", new { returnurl = HttpContext.Request.Url })); } }
//Form method that runs when refresh is called. Also provies the graphic object that is //used to draw on the form private void GameForm_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; if (gameObjects != null) { foreach (GameObject gameObject in gameObjects) { if (gameObject is Player temp) { temp = (Player)gameObject; temp.Draw(g, temp.AdjustForXOffset(camera.GetXOffset()), temp.AdjustForYOffset(camera.GetYOffset()), currentPlayer); } else { gameObject.Draw(g, gameObject.AdjustForXOffset(camera.GetXOffset()), gameObject.AdjustForYOffset(camera.GetYOffset())); if (clickedObject is IClickToDrawText clickToDrawText) { g.DrawString(clickToDrawText.TextToDraw(), FormatManager.GetPlayerFont(), new SolidBrush(Color.Black), new PointF(0, windowHeight - FormatManager.GetPlayerFont().Height)); } } } } }
// GET: Movie/Edit/5 public ActionResult Edit(int id) { if (Authenticate.IsAuthenticated()) { MovieGenresDirectorsRatingsFormats mgdrf = new MovieGenresDirectorsRatingsFormats(); mgdrf.Movie = MovieManager.LoadById(id); mgdrf.DirectorList = DirectorManager.Load(); mgdrf.RatingList = RatingManager.Load(); mgdrf.FormatList = FormatManager.Load(); mgdrf.Genres = GenreManager.Load(); // Load them all // Deal with the selected ones mgdrf.Movie.Genres = MovieManager.LoadGenres(id); mgdrf.GenreIds = mgdrf.Movie.Genres.Select(a => a.Id); // Select the ids // Put them into session Session["genreids"] = mgdrf.GenreIds; return(View(mgdrf)); } else { return(RedirectToAction("Login", "User", new { returnurl = HttpContext.Request.Url })); } }
private void mnuFileOpen_Click(object sender, EventArgs e) { if (ofdOpenFile.ShowDialog() == DialogResult.OK) { foreach (String filepath in ofdOpenFile.FileNames) { frmMDIChild form = FormatManager.CreateWindow(filepath); String filename = Path.GetFileName(filepath); form.MdiParent = this; form.Text = filename; form.tbcMDIControl = tbcMDIChildren; TabPage tab = new TabPage(filename); tab.Parent = tbcMDIChildren; tab.Tag = form; tab.MouseClick += new MouseEventHandler(tab_MouseClick); tab.Show(); form.tabMDITab = tab; form.Show(); } } }
/// <summary>Load content from the game folder or mod folder (if not already cached), and return it. When loading a <c>.png</c> file, this must be called outside the game's draw loop.</summary> /// <typeparam name="T">The expected data type. The main supported types are <see cref="Map"/>, <see cref="Texture2D"/>, and dictionaries; other types may be supported by the game's content pipeline.</typeparam> /// <param name="key">The asset key to fetch (if the <paramref name="source"/> is <see cref="ContentSource.GameContent"/>), or the local path to a content file relative to the mod folder.</param> /// <param name="source">Where to search for a matching content asset.</param> /// <exception cref="ArgumentException">The <paramref name="key"/> is empty or contains invalid characters.</exception> /// <exception cref="ContentLoadException">The content asset couldn't be loaded (e.g. because it doesn't exist).</exception> public T Load <T>(string key, ContentSource source = ContentSource.ModFolder) { SContentLoadException GetContentError(string reasonPhrase) => new SContentLoadException($"{this.ModName} failed loading content asset '{key}' from {source}: {reasonPhrase}."); try { this.AssertValidAssetKeyFormat(key); switch (source) { case ContentSource.GameContent: return(this.ContentManager.Load <T>(key)); case ContentSource.ModFolder: // get file FileInfo file = this.GetModFile(key); if (!file.Exists) { throw GetContentError($"there's no matching file at path '{file.FullName}'."); } // get asset path string assetName = this.ContentCore.GetAssetNameFromFilePath(file.FullName); // try cache if (this.ContentCore.IsLoaded(assetName)) { return(this.ContentManager.Load <T>(assetName)); } // fix map tilesheets if (file.Extension.ToLower() == ".tbin") { // validate if (typeof(T) != typeof(Map)) { throw GetContentError($"can't read file with extension '{file.Extension}' as type '{typeof(T)}'; must be type '{typeof(Map)}'."); } // fetch & cache FormatManager formatManager = FormatManager.Instance; Map map = formatManager.LoadMap(file.FullName); this.FixCustomTilesheetPaths(map, key); // inject map this.ContentManager.Inject(assetName, map); return((T)(object)map); } // load through content manager return(this.ContentManager.Load <T>(assetName)); default: throw GetContentError($"unknown content source '{source}'."); } } catch (Exception ex) when(!(ex is SContentLoadException)) { throw new SContentLoadException($"{this.ModName} failed loading content asset '{key}' from {source}.", ex); } }
protected void btnUpdate_Click(object sender, EventArgs e) { try { //get the selected degreetype object that i want to use item = items[ddlExisting.SelectedIndex]; //update degreeType Description item.Description = txtDescription.Text; //delete it from the database int results = FormatManager.Update(item); //update the list with new description items[ddlExisting.SelectedIndex] = item; //rebind Rebind(); Response.Write("Updated " + results + " rows..."); } catch (Exception ex) { Response.Write(ex.Message); } }
//Overides parent's class method since text is render in the lower rectangle. //Draws text based on on the space's rotate orientation. public new void RotateDrawText(Graphics g, string str, Rectangle rectangle, Font font, SolidBrush brush, StringFormat format) { Matrix m = new Matrix(); //g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; g.SmoothingMode = SmoothingMode.HighQuality; m.RotateAt((int)rotateOrientation, new PointF(rectangle.X + rectangle.Width / 2, rectangle.Y + rectangle.Height / 2)); g.Transform = m; if (font == null) { font = FormatManager.GetGeneralFont(); } if (rotateOrientation == RotateEnum.Rotate270 || rotateOrientation == RotateEnum.Rotate90) { Rectangle temp = new Rectangle(rectangle.X, rectangle.Y + 25, rectangle.Width, (int)(rectangle.Height * 0.75)); g.DrawString(str, font, brush, temp, format); } else { Rectangle temp = new Rectangle(rectangle.X, rectangle.Y, rectangle.Width, (int)(rectangle.Height * 1)); g.DrawString(str, font, brush, temp, format); } g.ResetTransform(); m.Dispose(); }
protected override void ProcessRecord() { Collection <FormatData> data; if (InputObject.BaseObject is FormatData) { data = new Collection <FormatData>(); data.Add((FormatData)InputObject.BaseObject); } else { if (_formatManager == null) { _formatManager = new FormatManager(FormatShape.Undefined, ExecutionContext); } data = _formatManager.Process(InputObject); } // although we might have multiple FormatData objects, they are all derived from a single data object // so all should be formatted in the same shape var processor = FormatProcessor.Get(OutputWriter, data[0].Shape); foreach (var curData in data) { processor.ProcessPayload(curData); } }
public void InsertTest() { Format format = new Format(); format.Description = "Bananas"; Assert.IsTrue(FormatManager.Insert(format) > 0); }
public ActionResult Edit(int id) { Movie movie = new Movie(); using (manager = new MovieManager()) { movie = manager.GetById(id); } if (movie == null) { return(HttpNotFound()); } else { MovieViewModel vm = new MovieViewModel(); using (GenreManager genreManager = new GenreManager()) { vm.PossibleGenres = genreManager.GetAll(); } using (RatingManager ratingManager = new RatingManager()) { vm.PossibleRatings = ratingManager.GetAll(); } using (DirectorManager directorManager = new DirectorManager()) { vm.PossibleDirectors = directorManager.GetAll(); } using (FormatManager formatManager = new FormatManager()) { vm.PossibleFormats = formatManager.GetAll(); } //vm.MovieId = movie.Id; vm.Movie = movie; vm.MovieDescription = movie.Description; vm.MovieCost = movie.Cost; vm.MovieTitle = movie.Title; vm.ImagePath = movie.ImagePath; vm.CurrentGenres = new List <int>(); foreach (var a in movie.Genres) { vm.CurrentGenres.Add(a.Id); } return(View(vm)); } }
// GET: Movie/Edit/5 public ActionResult Edit(int id) { if (Authenticate.IsAuthenticated()) { ViewBag.Title = "Edit"; MovieGenresDirectorsRatingsFormats mgdrf = new MovieGenresDirectorsRatingsFormats(); mgdrf.Movie = MovieManager.LoadById(id); mgdrf.RatingList = RatingManager.Load(); mgdrf.FormatList = FormatManager.Load(); mgdrf.GenreList = GenreManager.Load(); mgdrf.DirectorList = DirectorManager.Load(); mgdrf.Movie.Genres = MovieManager.LoadGenres(id); mgdrf.GenreIds = mgdrf.Movie.Genres.Select(g => g.Id); Session["genreids"] = mgdrf.GenreIds; return(View(mgdrf)); } else { return(RedirectToAction("Login", "User", new { returnurl = HttpContext.Request.Url })); } }
public void InsertTest() { Format format = new Format { Description = "JKFL" }; Assert.AreNotEqual(0, FormatManager.Insert(format)); }
internal static void Normalize(Form1 form) { XtraTabControl pagesTabControl = form.pagesTabControl; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); pageTextBox.SelectAll(); pageTextBox.SelectedText = FormatManager.EncodeHTMLTagsForXMLValidation(pageTextBox.Text); TextManager.RefreshUndoRedoExternal(form); }
public void Test_GetFormatHandler() { var handler = new OpenChartFormatHandler(); var manager = new FormatManager(); Assert.Null(manager.GetFormatHandler(handler.FileExtension)); manager.AddFormat(handler); Assert.AreSame(handler, manager.GetFormatHandler(handler.FileExtension)); }
public void LoadTest() { List <Format> formats = new List <Format>(); formats = FormatManager.Load(); int expected = 3; Assert.AreEqual(expected, formats.Count); }
/// <summary> /// Parses this instance. /// </summary> /// <typeparam name="TFile">The type of the file object expected.</typeparam> /// <returns>The parsed file</returns> /// <exception cref="ArgumentException"> /// Could not find file format that returns the specified object type /// </exception> public async Task <TFile> ParseAsync <TFile>() where TFile : IGenericFile { if (!(FormatManager?.FindFormat(FullName, Credentials) is IFormat <TFile> Format)) { throw new ArgumentException("Could not find file format that returns the specified object type"); } using var TempStream = new MemoryStream(await ReadBinaryAsync().ConfigureAwait(false)); return(await Format.ReadAsync(TempStream).ConfigureAwait(false)); }
public LaneSpace(int spaceId, int x, int y, Color color, RotateEnum rotate) : base(spaceId, x, y, color, rotate) { double sizeMultiplier = FormatManager.GetSizeMultiplier(); int CornerWidth = (int)(150 * sizeMultiplier); int CornerHeight = (int)(150 * sizeMultiplier); int LaneWidth = (int)(100 * sizeMultiplier); int LaneHeight = (int)(150 * sizeMultiplier); size = new Size(LaneWidth, LaneHeight); }
/// <summary> /// Parses this instance. /// </summary> /// <typeparam name="TFile">The type of the file object expected.</typeparam> /// <returns>The parsed file</returns> /// <exception cref="ArgumentException"> /// Could not find file format that returns the specified object type /// </exception> public TFile Parse <TFile>() where TFile : IGenericFile { if (!(FormatManager?.FindFormat(FullName, Credentials) is IFormat <TFile> Format)) { throw new ArgumentException("Could not find file format that returns the specified object type"); } using var TempStream = new MemoryStream(ReadBinary()); return(Format.Read(TempStream)); }
//Collections of methods related to setting up components of the game. //Setups format manager that is used to store how text should be drawn. //SetupBoard used to creating the game board and spaces. //Setups a timer that checks for refresh messagse from the server. private void SetupGame(SizeEnum size) { FormatManager.SetupFormatManager(size); SetupBoard(size); timer.SetupGameTimer(UpdateFromServer); GetSpacesFromServer(); CreatePlayer(); GetCurrentPlayer(); players = GetPlayersFromServer(); camera.centerOnGameObject(board.GetStartingSpace()); }
public void InsertTest() { Format format = new Format(); format.Description = "Cartrivision"; bool result = FormatManager.Insert(format); Assert.IsTrue(result); }
/// <summary> /// Parses this instance. /// </summary> /// <returns>The parsed file</returns> /// <exception cref="ArgumentException"> /// Could not find file format that returns the specified object type /// </exception> public async Task <IGenericFile> ParseAsync() { var Format = FormatManager?.FindFormat(FullName, Credentials); if (Format is null) { throw new ArgumentException("Could not find file format that returns the specified object type"); } using var TempStream = new MemoryStream(await ReadBinaryAsync().ConfigureAwait(false)); return(await Format.ReadBaseAsync(TempStream).ConfigureAwait(false)); }
/// <summary> /// Parses this instance. /// </summary> /// <returns>The parsed file</returns> /// <exception cref="ArgumentException"> /// Could not find file format that returns the specified object type /// </exception> public IGenericFile Parse() { var Format = FormatManager?.FindFormat(FullName, Credentials); if (Format is null) { throw new ArgumentException("Could not find file format that returns the specified object type"); } using var TempStream = new MemoryStream(ReadBinary()); return(Format.ReadBase(TempStream)); }
// GET: Format #region "Pre-WebAPI" public ActionResult Index() { if (Authenticate.IsAuthenticated()) { formats = FormatManager.Load(); return(View(formats)); } else { return(RedirectToAction("Login", "User", new { returnurl = HttpContext.Request.Url })); } }
// GET: Format/Edit/5 public ActionResult Edit(int id) { if (Authenticate.IsAuthenticated()) { Format format = FormatManager.LoadById(id); return(View(format)); } else { return(RedirectToAction("Login", "User", new { returnurl = HttpContext.Request.Url })); } }
protected override TaskOutput Execute(TaskInput input, ITaskContext context) { foreach (var file in input.Files) { Rectangle cropRectangle; bool cropped = false; if (TryGetCropRectangle(file, out cropRectangle)) { try { using (var readStream = new FileStream(file.Path, FileMode.Open)) { using (var reader = FormatManager.CreateFormatReader(readStream)) { using (var frame = reader.LoadFrame(0)) { if ((cropRectangle.X > 0 || cropRectangle.Y > 0) && (cropRectangle.Width < frame.Width || cropRectangle.Height < frame.Height)) { using (var resultBitmap = new Bitmap(frame.Width, frame.Height, Aurigma.GraphicsMill.PixelFormat.Format32bppArgb)) { frame.GetBitmap(resultBitmap); resultBitmap.Transforms.Crop(cropRectangle); if (reader.MediaFormat == FormatManager.JpegFormat) { resultBitmap.Save(file.Path + ".tmp", new JpegEncoderOptions(95, false)); } else { resultBitmap.Save(file.Path + ".tmp", FormatManager.CreateEncoderOptions(reader.MediaFormat)); } } cropped = true; } } } } if (cropped) { File.Delete(file.Path); File.Move(file.Path + ".tmp", file.Path); } } catch (Exception ex) { Logger.ErrorException(string.Format("Error acquired while cropping file {0}", file.Path), ex); } } } return(new TaskOutput(input.Files, input.Params)); }
public ActionResult Edit(int id, Format format) { try { // TODO: Add update logic here FormatManager.Update(format); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(Format format) { try { // TODO: Add insert logic here FormatManager.Insert(format); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, Format format) { try { // TODO: Add delete logic here FormatManager.Delete(id); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Format/Details/5 public ActionResult Details(int id) { if (Authenticate.IsAuthenticated()) { ViewBag.Title = "Details"; var format = FormatManager.LoadByID(id); return(View(format)); } else { return(RedirectToAction("Login", "User", new { returnurl = HttpContext.Request.Url })); } }
/// <summary> /// Writes the specified data. /// </summary> /// <param name="data">The data.</param> /// <param name="mode">The mode.</param> /// <returns>True if it was written successfully, false otherwise.</returns> public bool Write(IGenericFile data, FileMode mode = FileMode.Create) { var Format = FormatManager?.FindFormat(FullName, Credentials); if (Format is null) { return(false); } using var TempStream = new MemoryStream(); var Success = Format.Write(TempStream, data); Write(TempStream.ReadAllBinary(), mode); return(Success); }
private static void Main(string[] args) { string inputFileName = args.Length > 0 ? args[0] : "input.txt"; string outputFileName = Path.ChangeExtension(inputFileName, "log"); FormatManager formatManager = new FormatManager() .AddFormatter<SautReadyA>(f => string.Format("Переключение САУТ: {0}", f.Track)) .AddFormatter<InputData>(f => f.Index == 1 ? string.Format("Запрос на переключение пути: {0}", GetTrackName(f.Data)) : null) .AddFormatter<SysData>(f => f.Index == 1 ? string.Format("Подтверждение переключения пути: {0}", GetTrackName(f.Data)) : null) .AddFormatter<SautPtkReady2A1>( f => string.Format("[Кабина 1] {0} перегон; генератор: {1} ({2}); маршрут: {3}", f.SpanNumber, f.GeneratorNumber, f.GeneratorKind, f.RouteNumber)) .AddFormatter<SautPtkReady2A2>( f => string.Format("[Кабина 2] {0} перегон; генератор: {1} ({2}); маршрут: {3}", f.SpanNumber, f.GeneratorNumber, f.GeneratorKind, f.RouteNumber)); DateTime date = DateTime.MinValue; ICanLogSource logSource = new TextCanLogSource(inputFileName); using (var tw = File.CreateText(outputFileName)) { foreach (CanFrame frame in logSource.ReadFrames()) { try { BlokFrame blokFrame = BlokFrame.GetBlokFrame(frame); if (blokFrame is IpdDate) date = ((IpdDate)blokFrame).Time; if (date != DateTime.MinValue) { string s = formatManager.FormatString(blokFrame); if (s != null) { Console.WriteLine("{0:T} {1}", date, s); tw.WriteLine("{0:T} {1}", date, s); } } } catch (ApplicationException) { } } } Console.ReadLine(); }