private void Browse(object obj) { System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog(); ofd.Filter = "Button Image|*.png"; ofd.ShowDialog(); Vehicle.ImageSource = Imaging.FileToImage(ofd.FileName); }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { try { using (SqlConnection conn = new SqlConnection(GlobalClass.TConnectionString)) { _MenuList = conn.Query <TMenu>("SELECT M.MID, MENUNAME, PARENT, FORMPATH, IMAGEPATH FROM MENU M JOIN UserRight UR ON M.MID = UR.MID WHERE UR.UID = '" + GlobalClass.User.UID + "' AND [OPEN] = 1"); } foreach (TMenu child in _MenuList.Where(x => x.PARENT == 0)) { MenuItem mi = new MenuItem(); mi.Tag = child; mi.Header = child.MENUNAME; if (!string.IsNullOrEmpty(child.IMAGEPATH)) { Image icon = new Image(); icon.Source = Imaging.FileToImage(child.IMAGEPATH); mi.Icon = icon; } mi.Click += mi_Click; LoadMenu(mi, child.MID); MainMenu.Items.Add(mi); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Load Menu", MessageBoxButton.OK, MessageBoxImage.Information); } }
public LoginFullScreen() { try { InitializeComponent(); //this.WindowStyle = WindowStyle.None; //this.ResizeMode = ResizeMode.NoResize; if (System.IO.File.Exists(Environment.CurrentDirectory + "\\Background.jpg")) { this.imgBackground.Source = Imaging.FileToImage(Environment.CurrentDirectory + "\\Background.jpg"); } } catch (Exception ex) { MessageBox.Show(ex.GetBaseException().Message, "IMS - Ticketing Software", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void LoadMenu(MenuItem mi, int parent) { foreach (TMenu child in _MenuList.Where(x => x.PARENT == parent)) { MenuItem chMenu = new MenuItem(); chMenu.Tag = child; chMenu.Header = child.MENUNAME; if (!string.IsNullOrEmpty(child.IMAGEPATH)) { Image icon = new Image(); icon.Source = Imaging.FileToImage(child.IMAGEPATH); chMenu.Icon = icon; } chMenu.Click += mi_Click; LoadMenu(chMenu, child.MID); mi.Items.Add(chMenu); } }