public void showPadNumberOnMonitor(Point ScreenSize) { //Show number on monitor double dpi = DpiInfo.GetDpi(); double imgWidth = m_img.Width * ScreenSize.X; BitmapSource bmps = (BitmapSource)m_img.Source; double realHeight = null != bmps ? bmps.PixelHeight : 0; double imgHeight = m_img.Height * ScreenSize.Y; if (realHeight != 0) { imgHeight = realHeight * ScreenSize.Y; } m_text.Text = "" + m_num; m_text.FontSize = (double)new FontSizeConverter().ConvertFrom(imgHeight * 0.8f + "pt"); Size sizes = TextHelper.MeasureString(m_text); double x = (imgWidth - sizes.Width) / 2; double y = (imgHeight - sizes.Height) / 2; addx = x; addy = y; Canvas.SetLeft(m_text, m_xpos + m_borderThickness + offset_x * m_img.Width + addx); Canvas.SetTop(m_text, m_ypos + offset_y * realHeight + addy + (m_height - realHeight) / 2); IdentifyState = true; m_text.InvalidateVisual(); }
private void loadBitmaps() { BitmapResource bres; BitmapImage bpic; bpic = new BitmapImage(); int decodeWidth = (int)((PadPixelWidth - 2 * m_selectThickness) * DpiInfo.GetDpi()); bpic.BeginInit(); bpic.UriSource = new Uri(@"pictures/STU-300.png", UriKind.Relative); bpic.DecodePixelWidth = decodeWidth; bpic.EndInit(); bres = new BitmapResource(bpic, new UIPadScreen(new Point(0.18666, 0.29707), new Point(0.6333, 0.2008))); m_bitmapRes.Add(bres); bpic = new BitmapImage(); bpic.BeginInit(); bpic.UriSource = new Uri(@"pictures/STU-430.png", UriKind.Relative); bpic.DecodePixelWidth = decodeWidth; bpic.EndInit(); bres = new BitmapResource(bpic, new UIPadScreen(new Point(0.20333, 0.22876), new Point(0.59, 0.3398))); m_bitmapRes.Add(bres); bpic = new BitmapImage(); bpic.BeginInit(); bpic.UriSource = new Uri(@"pictures/STU-500.png", UriKind.Relative); bpic.DecodePixelWidth = decodeWidth; bpic.EndInit(); bres = new BitmapResource(bpic, new UIPadScreen(new Point(0.18666, 0.22287), new Point(0.63, 0.4047))); m_bitmapRes.Add(bres); bpic = new BitmapImage(); bpic.BeginInit(); bpic.UriSource = new Uri(@"pictures/STU-520.png", UriKind.Relative); bpic.DecodePixelWidth = decodeWidth; bpic.EndInit(); bres = new BitmapResource(bpic, new UIPadScreen(new Point(0.17333, 0.21511), new Point(0.6566, 0.3372))); m_bitmapRes.Add(bres); bpic = new BitmapImage(); bpic.BeginInit(); bpic.UriSource = new Uri(@"pictures/STU-530.png", UriKind.Relative); bpic.DecodePixelWidth = decodeWidth; bpic.EndInit(); bres = new BitmapResource(bpic, new UIPadScreen(new Point(0.16333, 0.20779), new Point(0.6733, 0.3766))); m_bitmapRes.Add(bres); m_warning = new BitmapImage(); m_warning.BeginInit(); m_warning.UriSource = new Uri(@"pictures/warning.png", UriKind.Relative); m_warning.DecodePixelWidth = (int)(20.0f * DpiInfo.GetDpi()); m_warning.DecodePixelHeight = (int)(17.0f * DpiInfo.GetDpi()); m_warning.EndInit(); }
private bool showPadNumberOnPad(int i) { bool ret = false; //return false means everything went OK //Show number on the Pad try { if (isConnected()) { //Create bitmap wgssSTU.ICapability m_capability = m_tablet.getCapability(); wgssSTU.ProtocolHelper protocolHelper = new wgssSTU.ProtocolHelper(); System.Drawing.Bitmap m_bitmap = new System.Drawing.Bitmap(m_capability.screenWidth, m_capability.screenHeight); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(m_bitmap); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; g.FillRectangle(System.Drawing.Brushes.White, 0, 0, m_bitmap.Width, m_bitmap.Height); System.Drawing.StringFormat strFormat = new System.Drawing.StringFormat(); strFormat.Alignment = System.Drawing.StringAlignment.Center; strFormat.LineAlignment = System.Drawing.StringAlignment.Center; double dpi = DpiInfo.GetDpi(); g.DrawString("" + i, new System.Drawing.Font("Tahoma", (int)(m_bitmap.Height / (1.2 * dpi))), System.Drawing.Brushes.Black, new System.Drawing.RectangleF(0, 0, m_bitmap.Width, m_bitmap.Height), strFormat); g.Dispose(); //Convert bitmap to device-native format System.IO.MemoryStream stream = new System.IO.MemoryStream(); m_bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png); byte[] m_bitmapData = (byte[])protocolHelper.resizeAndFlatten(stream.ToArray(), 0, 0, (uint)m_bitmap.Width, (uint)m_bitmap.Height, m_capability.screenWidth, m_capability.screenHeight, (byte)m_encodingMode, wgssSTU.Scale.Scale_Fit, 0, 0); // Write image. note: There is no need to clear the tablet screen prior to writing an image. ret = writeImageB(i, (byte)m_encodingMode, m_bitmapData); protocolHelper = null; stream.Dispose(); } } catch (Exception) { ret = false; } return(ret); }
private void MainWindow_OnContentRendered(object sender, EventArgs e) { DPI = DpiInfo.GetDpi(); DPI = 1.0f; timer = new DispatcherTimer(); timer.IsEnabled = false; timer.Interval = TimeSpan.FromMilliseconds(350); timer.Tick += OnEndResize; m_usbDevices = new wgssSTU.UsbDevices(); m_padGui = new UIPadsController(m_usbDevices, canvas, LayoutRoot, tbar, config, this); m_padGui.setMinSizesCanvas(); }