Beispiel #1
0
        private void DataFill()
        {
            var       tuple       = new Tuple <string, string>("扫码下线", "A_fa_cube");
            FontIcons icon1       = (FontIcons)Enum.Parse(typeof(FontIcons), tuple.Item2);
            var       pictureBox1 = new PictureBox
            {
                AutoSize  = false,
                Size      = new Size(40, 40),
                ForeColor = Color.FromArgb(255, 77, 59),
                Image     = FontImages.GetImage(icon1, 40, Color.FromArgb(255, 77, 59)),
                Location  = new Point(this.Size.Width / 2 - 20, 15)
            };

            panel3.Controls.Add(pictureBox1);

            using (var context = new Model())
            {
                var cProductProcessing = context.C_ProductProcessing.First(s => s.ProductBornCode == _productBornCode);
                BeginInvoke(new Action(() =>
                {
                    ProductIDTxt.Text       = _productBornCode;
                    ProductIDTxt.ReadOnly   = true;
                    ProductNameTxt.Text     = cProductProcessing.ProductName;
                    ProductNameTxt.ReadOnly = true;
                }));
            }
        }
Beispiel #2
0
        private void DataFill()
        {
            var       tuple       = new Tuple <string, string>("工量具", "E_icon_tools");
            var       tuple1      = new Tuple <string, string>("货架", "E_icon_house");
            FontIcons icon1       = (FontIcons)Enum.Parse(typeof(FontIcons), tuple1.Item2);
            FontIcons icon2       = (FontIcons)Enum.Parse(typeof(FontIcons), tuple.Item2);
            var       pictureBox1 = new PictureBox
            {
                AutoSize  = false,
                Size      = new Size(40, 40),
                ForeColor = Color.FromArgb(255, 77, 59),
                Image     = FontImages.GetImage(icon1, 40, Color.FromArgb(255, 77, 59)),
                Location  = new Point(this.Size.Width / 4 - 20, 15)
            };

            panel3.Controls.Add(pictureBox1);

            var pictureBox2 = new PictureBox
            {
                AutoSize  = false,
                Size      = new Size(40, 40),
                ForeColor = Color.FromArgb(255, 77, 59),
                Image     = FontImages.GetImage(icon2, 36, Color.FromArgb(255, 77, 59)),
                Location  = new Point(this.Size.Width / 4 * 3 - 20, 15)
            };

            panel3.Controls.Add(pictureBox2);
        }
Beispiel #3
0
        private void ThridTitle_Load(object sender, EventArgs e)
        {
            string strIcon = "E_icon_star";

            pictureBox1.ForeColor = Color.FromArgb(255, 77, 59);
            FontIcons icon1 = (FontIcons)Enum.Parse(typeof(FontIcons), strIcon);

            pictureBox1.Image = FontImages.GetImage(icon1, 32, Color.FromArgb(255, 77, 59));
            pictureBox2.Image = FontImages.GetImage(icon1, 32, Color.FromArgb(255, 77, 59));
            pictureBox3.Image = FontImages.GetImage(icon1, 32, Color.FromArgb(255, 77, 59));
            pictureBox4.Image = FontImages.GetImage(icon1, 32, Color.FromArgb(255, 77, 59));
        }
 public void SetBindSource(object obj)
 {
     if (obj is TestGridModel)
     {
         m_object = (TestGridModel)obj;
         string strIcon = "E_icon_star";
         ForeColor = Color.FromArgb(255, 77, 59);
         FontIcons icon1 = (FontIcons)Enum.Parse(typeof(FontIcons), strIcon);
         // Image = FontImages.GetImage(icon1, 32, Color.FromArgb(255, 77, 59));
         this.BackgroundImage = FontImages.GetImage(icon1, 32, Color.FromArgb(255, 77, 59));
         // this.BackgroundImage = Properties.Resources.rowicon;
     }
 }
Beispiel #5
0
 public static void Init()
 {
     FontIcons.Install("fas", FontAwesome5FreeSolid.FontFamily, typeof(FontAwesome5FreeSolid.IconNames));
 }
 /// <summary>
 /// Initialises a new instance of <see cref="DisplayIconAttribute"/>
 /// </summary>
 /// <param name="faviconIcon"></param>
 public DisplayIconAttribute(FontIcons faviconIcon)
 {
     this.Icon = faviconIcon.ToString();
 }
Beispiel #7
0
        /// <summary>
        /// Gets the size of the icon.
        /// </summary>
        /// <param name="iconText">The icon text.</param>
        /// <param name="graphics">The graphics.</param>
        /// <param name="font">The font.</param>
        /// <returns>Size.</returns>
        private static Size GetIconSize(FontIcons iconText, Graphics graphics, Font font)
        {
            string text = char.ConvertFromUtf32((int)iconText);

            return(graphics.MeasureString(text, font).ToSize());
        }
Beispiel #8
0
        /// <summary>
        /// 获取图标.
        /// </summary>
        /// <param name="iconText">图标名称.</param>
        /// <param name="imageSize">图标大小.</param>
        /// <param name="foreColor">前景色</param>
        /// <param name="backColor">背景色.</param>
        /// <returns>Bitmap.</returns>
        /// <exception cref="FileNotFoundException">Font file not found</exception>
        public static Bitmap GetImage(FontIcons iconText, int imageSize = 32, Color?foreColor = null, Color?backColor = null)
        {
            Dictionary <string, Font> _fs;

            if (iconText.ToString().StartsWith("A_"))
            {
                _fs = m_fontsAwesome;
            }
            else
            {
                if (m_fontsElegant.Count <= 0)
                {
                    lock (m_fontsElegant)
                    {
                        if (m_fontsElegant.Count <= 0)
                        {
                            string strPath = System.Reflection.Assembly.GetExecutingAssembly().CodeBase.ToLower().Replace("file:///", "");
                            string strDir  = System.IO.Path.GetDirectoryName(strPath);
                            if (!Directory.Exists(Path.Combine(strDir, "IconFont")))
                            {
                                Directory.CreateDirectory(Path.Combine(strDir, "IconFont"));
                            }
                            string strFile = Path.Combine(strDir, "IconFont\\ElegantIcons.ttf");
                            if (!File.Exists(strFile))
                            {
                                var        fs = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("HZH_Controls.IconFont.ElegantIcons.ttf");
                                FileStream sw = new FileStream(strFile, FileMode.Create, FileAccess.Write);
                                fs.CopyTo(sw);
                                sw.Close();
                                fs.Close();
                            }
                            m_fontCollection.AddFontFile(strFile);

                            float size = MinFontSize;
                            for (int i = 0; i <= (MaxFontSize - MinFontSize) * 2; i++)
                            {
                                m_fontsElegant.Add(size.ToString("F2"), new Font(m_fontCollection.Families[0], size, FontStyle.Regular, GraphicsUnit.Point));
                                size += 0.5f;
                            }
                        }
                    }
                }
                _fs = m_fontsElegant;
            }

            if (!foreColor.HasValue)
            {
                foreColor = Color.Black;
            }
            Font  imageFont = _fs[MinFontSize.ToString("F2")];
            SizeF textSize  = new SizeF(imageSize, imageSize);

            using (Bitmap bitmap = new Bitmap(48, 48))
                using (Graphics graphics = Graphics.FromImage(bitmap))
                {
                    //float size = MaxFontSize;
                    float fltMaxSize = MaxFontSize;
                    if (m_cacheMaxSize.ContainsKey(imageSize))
                    {
                        fltMaxSize = Math.Max(MaxFontSize, m_cacheMaxSize[imageSize] + 5);
                    }
                    while (fltMaxSize >= MinFontSize)
                    {
                        Font  font = _fs[fltMaxSize.ToString("F2")];
                        SizeF sf   = GetIconSize(iconText, graphics, font);
                        if (sf.Width < imageSize && sf.Height < imageSize)
                        {
                            imageFont = font;
                            textSize  = sf;
                            break;
                        }

                        fltMaxSize -= 0.5f;
                    }

                    if (!m_cacheMaxSize.ContainsKey(imageSize) || (m_cacheMaxSize.ContainsKey(imageSize) && m_cacheMaxSize[imageSize] < fltMaxSize))
                    {
                        m_cacheMaxSize[imageSize] = fltMaxSize;
                    }
                }

            Bitmap srcImage = new Bitmap(imageSize, imageSize);

            using (Graphics graphics = Graphics.FromImage(srcImage))
            {
                if (backColor.HasValue && backColor.Value != Color.Empty && backColor.Value != Color.Transparent)
                {
                    graphics.Clear(backColor.Value);
                }
                string s = char.ConvertFromUtf32((int)iconText);
                graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
                graphics.SetGDIHigh();
                using (Brush brush2 = new SolidBrush(foreColor.Value))
                {
                    graphics.DrawString(s, imageFont, brush2, new PointF((imageSize - textSize.Width) / 2.0f + 1, (imageSize - textSize.Height) / 2.0f + 1));
                }
            }

            return(srcImage);
        }
Beispiel #9
0
        /// <summary>
        /// 获取图标
        /// </summary>
        /// <param name="iconText">图标名称</param>
        /// <param name="imageSize">图标大小</param>
        /// <param name="foreColor">前景色</param>
        /// <param name="backColor">背景色</param>
        /// <returns>图标</returns>
        public static Icon GetIcon(FontIcons iconText, int imageSize = 32, Color?foreColor = null, Color?backColor = null)
        {
            Bitmap image = GetImage(iconText, imageSize, foreColor, backColor);

            return(image != null?ToIcon(image, imageSize) : null);
        }
Beispiel #10
0
        /*
         * public static void initVLC()
         * {
         *  if (Environment.Is64BitOperatingSystem)
         *  {
         *      // Set libvlc.dll and libvlccore.dll directory path
         *      VlcContext.LibVlcDllsPath = @"VLC\";
         *
         *      // Set the vlc plugins directory path
         *      VlcContext.LibVlcPluginsPath = @"VLC\plugins";
         *  }
         *  else
         *  {
         *      // Set libvlc.dll and libvlccore.dll directory path
         *      VlcContext.LibVlcDllsPath = @"VLC\";
         *
         *      // Set the vlc plugins directory path
         *      VlcContext.LibVlcPluginsPath = @"VLC\plugins";
         *  }
         *
         *  // Ignore the VLC configuration file
         *  VlcContext.StartupOptions.IgnoreConfig = true;
         #if DEBUG
         *  // Enable file based logging
         *  VlcContext.StartupOptions.LogOptions.LogInFile = true;
         *
         *  // Shows the VLC log console (in addition to the applications window)
         *  VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = true;
         #else
         *  VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = false;
         *  VlcContext.StartupOptions.LogOptions.LogInFile = false;
         #endif
         *  // Set the log level for the VLC instance
         *  VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Debug;
         *  VlcContext.StartupOptions.AddOption("--ffmpeg-hw");
         *  // Disable showing the movie file name as an overlay
         *  VlcContext.StartupOptions.AddOption("--no-video-title-show");
         *  VlcContext.StartupOptions.AddOption("--rtsp-tcp");
         *  VlcContext.StartupOptions.AddOption("--rtsp-mcast");
         *  // VlcContext.StartupOptions.AddOption("--rtsp-host=192.168.10.35");
         *  // VlcContext.StartupOptions.AddOption("--sap-addr=192.168.10.35");
         *  VlcContext.StartupOptions.AddOption("--rtsp-port=8554");
         *  VlcContext.StartupOptions.AddOption("--rtp-client-port=8554");
         *  VlcContext.StartupOptions.AddOption("--sout-rtp-rtcp-mux");
         *  VlcContext.StartupOptions.AddOption("--rtsp-wmserver");
         *
         *
         *  VlcContext.StartupOptions.AddOption("--file-caching=18000");
         *  VlcContext.StartupOptions.AddOption("--sout-rtp-caching=18000");
         *  VlcContext.StartupOptions.AddOption("--sout-rtp-port=8554");
         *  VlcContext.StartupOptions.AddOption("--sout-rtp-proto=tcp");
         *  VlcContext.StartupOptions.AddOption("--network-caching=1000");
         *
         *  VlcContext.StartupOptions.AddOption("--vout-filter=wall");
         *  VlcContext.StartupOptions.AddOption("--wall-cols=2");
         *  VlcContext.StartupOptions.AddOption("--wall-rows=2");
         *
         *  // Pauses the playback of a movie on the last frame
         *  VlcContext.StartupOptions.AddOption("--play-and-pause");
         *  VlcContext.CloseAll();
         *  // Initialize the VlcContext
         *  VlcContext.Initialize();
         * }
         */

        private void Application_Startup(object sender, StartupEventArgs e)
        {
            bool login = true;

            Rows       = new List <CsvRow>();
            RowsSend   = new List <CsvRow>();
            Fonts      = ExCss.ReadFile(@"Asset\Fonts\font-awesome.min.css");
            Timethread = new Thread(CheckTimeFunctionThread);
            Timethread.IsBackground = true;
            listSerialPort          = new List <SerialPort>();
            QueueCMD   = new Queue <string>();
            m_bInitSDK = CHCNetSDK.NET_DVR_Init();
            if (m_bInitSDK == false)
            {
                MessageBox.Show("NET_DVR_Init error!");
                return;
            }
            if (!File.Exists(_FILE_CSV_COMMAND))
            {
                File.Create(_FILE_CSV_COMMAND);
            }
            if (!File.Exists(_FILE_Send_COMMAND))
            {
                File.Create(_FILE_Send_COMMAND);
            }
            //  initVLC();
            DefineCommand = CommandDefine.Read(_FILE_DEFINE_COMMAND);
            setting       = Config.Read(_FILE_Config);
            if (!Directory.Exists("Data"))
            {
                DirectoryInfo di = Directory.CreateDirectory("Data");
                di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
            }
            if (!Directory.Exists(setting.Folder))
            {
                Directory.CreateDirectory(setting.Folder);
            }
            curDate = DateTime.Now;
            Timethread.Start();
            curFolder = System.IO.Path.Combine(setting.Folder, this.curDate.ToString("dd-MM-yyyy"));
            if (!Directory.Exists(curFolder))
            {
                Directory.CreateDirectory(curFolder);
            }
            DataUser = Users.read(@"Data\User.mtc");
            if (DataUser == null)
            {
                DataUser = new Users();
                User root = new User("root", 1);
                root.Pass     = "******".toMD5();
                root.type     = 0;
                root.FullName = "Root";
                DataUser.Add(root);
                Users.write(_FILE_User_Data, DataUser);
            }
            DataCamera             = Cameras.Read(_FILE_Camera_Data);
            DataPreset             = Presets.Read(_FILE_PRESET_DATA);
            DataAlarm              = Alarms.Read(_FILE_Alarm_Data);
            this.checkFile         = new Thread(checkFileFunctionThread);
            checkFile.IsBackground = true;
            this.checkFile.Start();
#if DEBUG
            if (DataCamera.Count == 0)
            {
                Camera camera = new Camera("192.168.10.199");
                camera.name    = "Camera Demo";
                camera.channel = 1;
                camera.port    = 8000;
                camera.admin   = "admin";
                camera.pass    = "******";
                camera.icon    = "fa-video-camera";
                DataCamera.Add(camera);
            }

            if (DataUser.Datas.Count < 2)
            {
                User root = new User("admin", 2);
                root.Pass     = "******".toMD5();
                root.type     = 1;
                root.FullName = "Admin";
                DataUser.Add(root);

                User root2 = new User("htdm", 3);
                root2.Pass     = "******".toMD5();
                root2.type     = 2;
                root2.FullName = "Camera";
                DataUser.Add(root2);
                Users.write(_FILE_User_Data, DataUser);
            }
#endif
            var listCom = getListCOM();
            if (listCom.Length > 0)
            {
                foreach (string i in listCom)
                {
                    try
                    {
                        SerialPort serialPort = new SerialPort();
                        serialPort = new SerialPort();
                        serialPort.openCOM(i, BAUDRATE, DATABITS, StopBits.One);
                        serialPort.DataReceived += serialPort_DataReceived;
                        serialPort.sendCommand("#0$");
                        listSerialPort.Add(serialPort);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            Map = Map.Read(_FILE_Map_Data);
            for (int i = 0; i != e.Args.Length; i += 2)
            {
                if (e.Args[i] == "-u")
                {
                    string hash = e.Args[i + 1];
                    User   u    = App.DataUser.Login(hash);
                    if (u != null)
                    {
                        login    = false;
                        App.User = u;
                    }
                }
                else if (e.Args[i] == "-mode")
                {
                    Mode = (Camera_Final.Mode) int.Parse(e.Args[i + 1]);
                }
            }
            if (login)
            {
                this.MainWindow = new Login();
            }
            else
            {
                this.MainWindow = new MainWindow();
            }
            this.MainWindow.Show();
        }