/// <summary> /// このクラスのインスタンスの複製を生成する /// </summary> /// <returns> /// このクラスのインスタンスのコピーである新しいインスタンス /// </returns> public CursorInfo DeepCopy() { return(new CursorInfo( cursorImage: (Image)CursorImage.Clone(), screenPoint: new Point(ScreenPoint.X, ScreenPoint.Y), imagePoint: new Point(ImagePoint.X, ImagePoint.Y))); }
public MainWindow(string[]?args) { InitializeComponent(); Closing += MainWindow_Closing; SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.UserMouse, true); VerticalScroll.Enabled = false; HorizontalScroll.Enabled = false; //DefaultLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Slick"); _defaultLocation = "C:\\Temp"; // For testing PanScrollReceiver.Initialise(this); //RescaleScreen(); // get a reliable DPI figure (DeviceDpi is nonsense) var initialFile = (args?.Length > 0) ? args[0] : Path.Combine(_defaultLocation, "default.slick"); _canvas = new EndlessCanvas(Width, Height, Dpi, initialFile, CanvasChanged); _scale = 1; if (floatingText1 != null) { floatingText1.CanvasTarget = _canvas; floatingText1.Visible = false; } if (saveFileDialog != null) { saveFileDialog.InitialDirectory = _defaultLocation; } _inkCrosshairLoDpi = CursorImage.MakeCrosshair(1); _inkCrosshairHiDpi = CursorImage.MakeCrosshair(2); _moveCursorLoDpi = CursorImage.MakeMove(1); _moveCursorHiDpi = CursorImage.MakeMove(2); SetCursorForState(); UpdateWindowAndStatus(); _stylusInput = new RealTimeStylus(this, true) { MultiTouchEnabled = true, AllTouchEnabled = true }; // Async calls get triggered on the UI thread, so we use this to trigger updates to WinForms visuals. _stylusInput.AsyncPluginCollection?.Add(new DataTriggerStylusPlugin(this)); AddInputPlugin(_stylusInput, new CanvasDrawingPlugin(this, _canvas, new WinFormsKeyboard())); _stylusInput.Enabled = true; }
/// <summary> /// リソースを解放する /// </summary> /// <param name="disposing"> /// マネージドオブジェクトを解放するかのフラグ /// 下記の用途で使い分ける /// ・True:<see cref="Dispose()"/> メソッドからの呼び出し /// ・False:デストラクタからの呼び出し /// </param> protected virtual void Dispose(bool disposing) { if (!isDisposed) { if (disposing) { // マネージドオブジェクトの解放 // 背景画像の解放 CursorImage?.Dispose(); } // アンマネージドオブジェクトの解放 // 大きなフィールドの解放(NULLの設定) // Dispose済みのフラグを立てる isDisposed = true; } }
private void InitFromStream (Stream stream) { ushort entry_count; CursorEntry ce; uint largest; //read the cursor header if (stream == null || stream.Length == 0) throw new ArgumentException ("The argument 'stream' must be a picture that can be used as a cursor", "stream"); BinaryReader reader = new BinaryReader (stream); cursor_dir = new CursorDir (); cursor_dir.idReserved = reader.ReadUInt16(); cursor_dir.idType = reader.ReadUInt16(); if (cursor_dir.idReserved != 0 || !(cursor_dir.idType == 2 || cursor_dir.idType == 1)) throw new ArgumentException ("Invalid Argument, format error", "stream"); entry_count = reader.ReadUInt16(); cursor_dir.idCount = entry_count; cursor_dir.idEntries = new CursorEntry[entry_count]; cursor_data = new CursorImage[entry_count]; //now read in the CursorEntry structures for (int i=0; i < entry_count; i++){ ce = new CursorEntry(); ce.width = reader.ReadByte(); ce.height = reader.ReadByte(); ce.colorCount = reader.ReadByte(); ce.reserved = reader.ReadByte(); ce.xHotspot = reader.ReadUInt16(); ce.yHotspot = reader.ReadUInt16(); if (cursor_dir.idType == 1) { ce.xHotspot = (ushort)(ce.width / 2); ce.yHotspot = (ushort)(ce.height / 2); } ce.sizeInBytes = reader.ReadUInt32(); ce.fileOffset = reader.ReadUInt32(); cursor_dir.idEntries[i] = ce; } // If we have more than one pick the largest cursor largest = 0; for (int j = 0; j < entry_count; j++){ if (cursor_dir.idEntries[j].sizeInBytes >= largest) { largest = cursor_dir.idEntries[j].sizeInBytes; this.id = (ushort)j; this.size.Height = cursor_dir.idEntries[j].height; this.size.Width = cursor_dir.idEntries[j].width; } } //now read in the cursor data for (int j = 0; j < entry_count; j++) { CursorImage curdata; CursorInfoHeader cih; byte[] buffer; BinaryReader cih_reader; int num_colors; int cursor_height; int bytes_per_line; int xor_size; int and_size; curdata = new CursorImage(); cih = new CursorInfoHeader(); stream.Seek (cursor_dir.idEntries[j].fileOffset, SeekOrigin.Begin); buffer = new byte [cursor_dir.idEntries[j].sizeInBytes]; stream.Read (buffer, 0, buffer.Length); cih_reader = new BinaryReader(new MemoryStream(buffer)); cih.biSize = cih_reader.ReadUInt32 (); if (cih.biSize != 40) { throw new ArgumentException ("Invalid cursor file", "stream"); } cih.biWidth = cih_reader.ReadInt32 (); cih.biHeight = cih_reader.ReadInt32 (); cih.biPlanes = cih_reader.ReadUInt16 (); cih.biBitCount = cih_reader.ReadUInt16 (); cih.biCompression = cih_reader.ReadUInt32 (); cih.biSizeImage = cih_reader.ReadUInt32 (); cih.biXPelsPerMeter = cih_reader.ReadInt32 (); cih.biYPelsPerMeter = cih_reader.ReadInt32 (); cih.biClrUsed = cih_reader.ReadUInt32 (); cih.biClrImportant = cih_reader.ReadUInt32 (); curdata.cursorHeader = cih; //Read the number of colors used and corresponding memory occupied by //color table. Fill this memory chunk into rgbquad[] switch (cih.biBitCount){ case 1: num_colors = 2; break; case 4: num_colors = 16; break; case 8: num_colors = 256; break; default: num_colors = 0; break; } curdata.cursorColors = new uint[num_colors]; for (int i = 0; i < num_colors; i++) { curdata.cursorColors[i] = cih_reader.ReadUInt32 (); } //XOR mask is immediately after ColorTable and its size is //icon height* no. of bytes per line //cursor height is half of BITMAPINFOHEADER.biHeight, since it contains //both XOR as well as AND mask bytes cursor_height = cih.biHeight/2; //bytes per line should should be uint aligned bytes_per_line = ((((cih.biWidth * cih.biPlanes * cih.biBitCount)+ 31)>>5)<<2); //Determine the XOR array Size xor_size = bytes_per_line * cursor_height; curdata.cursorXOR = new byte[xor_size]; for (int i = 0; i < xor_size; i++) { curdata.cursorXOR[i] = cih_reader.ReadByte(); } //Determine the AND array size and_size = (int)(cih_reader.BaseStream.Length - cih_reader.BaseStream.Position); curdata.cursorAND = new byte[and_size]; for (int i = 0; i < and_size; i++) { curdata.cursorAND[i] = cih_reader.ReadByte(); } cursor_data[j] = curdata; cih_reader.Close(); } reader.Close(); }
private void InitFromStream(Stream stream) { ushort entry_count; CursorEntry ce; uint largest; //read the cursor header if (stream == null || stream.Length == 0) { throw new ArgumentException("The argument 'stream' must be a picture that can be used as a cursor", "stream"); } BinaryReader reader = new BinaryReader(stream); cursor_dir = new CursorDir(); cursor_dir.idReserved = reader.ReadUInt16(); cursor_dir.idType = reader.ReadUInt16(); if (cursor_dir.idReserved != 0 || !(cursor_dir.idType == 2 || cursor_dir.idType == 1)) { throw new ArgumentException("Invalid Argument, format error", "stream"); } entry_count = reader.ReadUInt16(); cursor_dir.idCount = entry_count; cursor_dir.idEntries = new CursorEntry[entry_count]; cursor_data = new CursorImage[entry_count]; //now read in the CursorEntry structures for (int i = 0; i < entry_count; i++) { ce = new CursorEntry(); ce.width = reader.ReadByte(); ce.height = reader.ReadByte(); ce.colorCount = reader.ReadByte(); ce.reserved = reader.ReadByte(); ce.xHotspot = reader.ReadUInt16(); ce.yHotspot = reader.ReadUInt16(); if (cursor_dir.idType == 1) { ce.xHotspot = (ushort)(ce.width / 2); ce.yHotspot = (ushort)(ce.height / 2); } ce.sizeInBytes = reader.ReadUInt32(); ce.fileOffset = reader.ReadUInt32(); cursor_dir.idEntries[i] = ce; } // If we have more than one pick the largest cursor largest = 0; for (int j = 0; j < entry_count; j++) { if (cursor_dir.idEntries[j].sizeInBytes >= largest) { largest = cursor_dir.idEntries[j].sizeInBytes; this.id = (ushort)j; this.size.Height = cursor_dir.idEntries[j].height; this.size.Width = cursor_dir.idEntries[j].width; } } //now read in the cursor data for (int j = 0; j < entry_count; j++) { CursorImage curdata; CursorInfoHeader cih; byte[] buffer; BinaryReader cih_reader; int num_colors; int cursor_height; int bytes_per_line; int xor_size; int and_size; curdata = new CursorImage(); cih = new CursorInfoHeader(); stream.Seek(cursor_dir.idEntries[j].fileOffset, SeekOrigin.Begin); buffer = new byte [cursor_dir.idEntries[j].sizeInBytes]; stream.Read(buffer, 0, buffer.Length); cih_reader = new BinaryReader(new MemoryStream(buffer)); cih.biSize = cih_reader.ReadUInt32(); if (cih.biSize != 40) { throw new ArgumentException("Invalid cursor file", "stream"); } cih.biWidth = cih_reader.ReadInt32(); cih.biHeight = cih_reader.ReadInt32(); cih.biPlanes = cih_reader.ReadUInt16(); cih.biBitCount = cih_reader.ReadUInt16(); cih.biCompression = cih_reader.ReadUInt32(); cih.biSizeImage = cih_reader.ReadUInt32(); cih.biXPelsPerMeter = cih_reader.ReadInt32(); cih.biYPelsPerMeter = cih_reader.ReadInt32(); cih.biClrUsed = cih_reader.ReadUInt32(); cih.biClrImportant = cih_reader.ReadUInt32(); curdata.cursorHeader = cih; //Read the number of colors used and corresponding memory occupied by //color table. Fill this memory chunk into rgbquad[] switch (cih.biBitCount) { case 1: num_colors = 2; break; case 4: num_colors = 16; break; case 8: num_colors = 256; break; default: num_colors = 0; break; } curdata.cursorColors = new uint[num_colors]; for (int i = 0; i < num_colors; i++) { curdata.cursorColors[i] = cih_reader.ReadUInt32(); } //XOR mask is immediately after ColorTable and its size is //icon height* no. of bytes per line //cursor height is half of BITMAPINFOHEADER.biHeight, since it contains //both XOR as well as AND mask bytes cursor_height = cih.biHeight / 2; //bytes per line should should be uint aligned bytes_per_line = ((((cih.biWidth * cih.biPlanes * cih.biBitCount) + 31) >> 5) << 2); //Determine the XOR array Size xor_size = bytes_per_line * cursor_height; curdata.cursorXOR = new byte[xor_size]; for (int i = 0; i < xor_size; i++) { curdata.cursorXOR[i] = cih_reader.ReadByte(); } //Determine the AND array size and_size = (int)(cih_reader.BaseStream.Length - cih_reader.BaseStream.Position); curdata.cursorAND = new byte[and_size]; for (int i = 0; i < and_size; i++) { curdata.cursorAND[i] = cih_reader.ReadByte(); } cursor_data[j] = curdata; cih_reader.Close(); } reader.Close(); }
void Start() { cursor = Camera.main.GetComponent <CursorImage>(); }
public override void Draw(SpriteBatch spriteBatch) { ScreenService.Instance.GraphicsDevice.Viewport = ScreenService.Instance.DefaultScreenCamera.CurrentViewport; spriteBatch.Begin( SpriteSortMode.FrontToBack, // this is also the order for building the screen. null, SamplerState.PointClamp, null, null, null, ScreenService.Instance.DefaultScreenCamera.TransformMatrix); base.Draw(spriteBatch); if (!Images.Any()) { Messages.Add("no image received from server"); } foreach (var img in Images.ToList()) { img.Draw(spriteBatch); } if (!InventoryImages.Any()) { Messages.Add("no inventory image received from server"); } foreach (var img in InventoryImages.ToList()) { img.Draw(spriteBatch); } MultiplayerText.Draw(spriteBatch); HealthImage.Draw(spriteBatch); SpeedImage.Draw(spriteBatch); StrenghImage.Draw(spriteBatch); DialogImage.Draw(spriteBatch); CursorImage.Draw(spriteBatch); //LerpMouseImage.Draw(spriteBatch); if (InfoWindow?.IsVisible == true) { InfoWindow?.Draw(spriteBatch); } if (DialogWindow?.IsVisible == true) { DialogWindow?.Draw(spriteBatch); } if (InventoryWindow?.IsVisible == true) { InventoryWindow.Draw(spriteBatch); } if (CharacterWindow?.IsVisible == true) { MoneyCount.Draw(spriteBatch); CharacterWindow?.Draw(spriteBatch); } if (CharacterWindow?.IsVisible == true) { CharacterWindow?.Draw(spriteBatch); } if (ChatWindow?.IsVisible == true) { ChatWindow?.Draw(spriteBatch); } spriteBatch.End(); }