private void showNow(GetProgrammesCompletedEventArgs b) { programmes.Children.Clear(); programmes.Orientation = Orientation.Vertical; foreach (Programme prg in b.Result.programmes.OrderBy(x => FixToNum(x.channel))) { MyProgramme myp = Translate(prg); if (myp.start <= DateTime.Now && DateTime.Now < myp.stop) { StackPanel sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; sp.Margin = new Thickness(0); Image img = new Image(); ImageSourceConverter isc = new ImageSourceConverter(); ImageSource imagesource = isc.ConvertFromString("images/" + prg.channel + ".png") as ImageSource; img.Source = imagesource; img.MaxHeight = 44; Border boimg = inBorder(img); boimg.MinWidth = 44; sp.Children.Add(boimg); /* * Border bochn = inBorder(new TextBlock() { Text = myp.channelname, Width = 100 }); * sp.Children.Add(bochn); */ TextBlock tb = new TextBlock() { Text = myp.start.ToString("HH:mm") + "-" + myp.stop.ToString("HH:mm") + " " + myp.title, Width = 400, FontSize = 9, Tag = myp }; myp.Parent = tb; Border bo = inBorder(tb); if (myp.stop < DateTime.Now) { bo.Style = sOld; } tb.MouseLeave += (x, z) => { if (myp.stop < DateTime.Now) { bo.Style = sOld; } else { bo.Style = sOrg; } }; tb.MouseEnter += (x, z) => { bo.Style = sAlt; canvas.Visibility = Visibility.Collapsed; showCanvas(z.GetPosition(LayoutRoot)); info.Text = myp.start.ToString("yyyy-MM-dd HH:mm") + "-" + myp.stop.ToString("HH:mm") + "\r" + myp.title + (!string.IsNullOrEmpty(myp.subtitle) ? " - " + myp.subtitle : "") + "\r" + myp.desc; }; sp.Children.Add(bo); programmes.Children.Add(sp); } } }
private void ex_MouseDown(object sender, MouseButtonEventArgs e) { ImageSourceConverter imgs = new ImageSourceConverter(); ex.Source = (ImageSource)imgs.ConvertFromString("pack://application:,,,/Imgs/buttons/x/x_click.png"); }
private void ChartComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { ChartGrid.ColumnDefinitions.Clear(); ChartGrid.RowDefinitions.Clear(); foreach (UIElement uiElement in ChartGrid.Children) { if (uiElement is Button) { ((Button)uiElement).Click -= MainWindowClick; } } ChartGrid.Children.Clear(); //MainCanvas.Children.Clear(); DamageChartImage dci = ChartComboBox.SelectedItem as DamageChartImage; if (dci == null || dci.ImagePath == null || dci.CountColumns <= 0 || dci.CountRows <= 0) { return; } try { ImageSourceConverter converter = new ImageSourceConverter(); string path = $@"{(System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location))}\{dci.ImagePath}"; ImageSource imageSource = (ImageSource)converter.ConvertFromString(path); this.Width = imageSource.Width; this.Height = imageSource.Height; ChartGrid.Background = new ImageBrush(imageSource); } catch (Exception ex) { MessageBox.Show(ex.Message); } for (int i = 0; i < dci.CountColumns; i++) { ChartGrid.ColumnDefinitions.Add(new ColumnDefinition()); } for (int i = 0; i < dci.CountRows; i++) { ChartGrid.RowDefinitions.Add(new RowDefinition()); } //Grid.SetRowSpan(MainCanvas, ChartGrid.RowDefinitions.Count); //Grid.SetColumnSpan(MainCanvas, ChartGrid.ColumnDefinitions.Count); for (int i = 0; i < ChartGrid.ColumnDefinitions.Count; i++) { for (int j = 0; j < ChartGrid.RowDefinitions.Count; j++) { ToggleButton newButton = new ToggleButton { Content = "X", VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, }; //newButton.Click += MainWindow_Click; Grid.SetColumn(newButton, i); Grid.SetRow(newButton, j); ChartGrid.Children.Add(newButton); } } }
/// <summary> /// Sets the settings correct for the user to navigate trough /// Loads in all the themes /// </summary> public InstellingenPage() { InitializeComponent(); //Laad alle settings in vanuit de opgeslagen settings. ToggleSwitchMusic.IsChecked = (bool)Settings.Default["Music"]; ToggleSwitchSound.IsChecked = (bool)Settings.Default["Sound"]; lblActiveTheme.Content = (string)Settings.Default["ThemeName"]; // If saved theme doesn't exist load the "Sport" theme try { imgTheme.Source = (ImageSource)converter.ConvertFromString((string)Settings.Default["Theme"]); } catch { Settings.Default["ThemeName"] = "Sport"; Settings.Default["Theme"] = "pack://application:,,,/Memory;component/Resources/themes/Sport/achterkant.png"; Settings.Default.Save(); imgTheme.Source = (ImageSource)converter.ConvertFromString((string)Settings.Default["Theme"]); } imgTheme.Source = (ImageSource)converter.ConvertFromString((string)Settings.Default["Theme"]); //Gets the project path needed for getting the themes var projectPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName; string baseFolder = Path.Combine(projectPath, "Resources\\themes"); List <string> themeList = new List <string>(); List <string> namesList = new List <string>(); //Fills the themeList string[] employeeFolders = Directory.GetDirectories(baseFolder); string imgName = "achterkant.png"; foreach (var folderName in employeeFolders) { var path = System.IO.Path.Combine(folderName, imgName); if (File.Exists(path)) { themeList.Add(path); } } //Fills the namesList foreach (var folderName in employeeFolders) { var path = System.IO.Path.Combine(folderName); if (Directory.Exists(path)) { string input = path; int index = input.IndexOf("themes\\"); if (index > 0) { input = input.Substring(index + 7); } namesList.Add(input); } } theme = themeList.ToArray(); themeNames = namesList.ToArray(); }
// Switcher.Switch(new MainMenu()); private void UserControl_Loaded(object sender, RoutedEventArgs e) { lblFilmTitle.Content = GlobalVariables.FilmTitle; ImageSourceConverter converter = new ImageSourceConverter(); var imageSource = (ImageSource)converter.ConvertFromString(GlobalVariables.AgeRatingSource); imgAgeRating.Source = imageSource; imageSource = (ImageSource)converter.ConvertFromString(GlobalVariables.UserRatingSource); //imgUserRating.Source = imageSource; lblUserRating.Content = GlobalVariables.UserRating; // Setting up film screenshots and banner imageSource = (ImageSource)converter.ConvertFromString(GlobalVariables.BannerImageSource); imgBanner.Source = imageSource; imageSource = (ImageSource)converter.ConvertFromString(GlobalVariables.ScreenshotOneSource); imgFilmScreenshotOne.Source = imageSource; imageSource = (ImageSource)converter.ConvertFromString(GlobalVariables.ScreenshotTwoSource); imgFilmScreenshotTwo.Source = imageSource; imageSource = (ImageSource)converter.ConvertFromString(GlobalVariables.ScreenshotThreeSource); imgFilmScreenshotThree.Source = imageSource; imageSource = (ImageSource)converter.ConvertFromString(GlobalVariables.ScreenshotFourSource); imgFilmScreenshotFour.Source = imageSource; txtBlockDescription.Text = GlobalVariables.Description; // Setting up automated dates for tickets #region firstDay lblCurrentDayName.Content = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(DateTime.Today.DayOfWeek).ToString() + ","; lblCurrentDay.Content = DateTime.Today.Day.ToString(); switch (DateTime.Today.Day) { case 1: case 21: case 31: lblCurrentDayEnding.Content = "st"; break; case 2: case 22: lblCurrentDayEnding.Content = "nd"; break; case 3: case 23: lblCurrentDayEnding.Content = "rd"; break; default: lblCurrentDayEnding.Content = "th"; break; } lblCurrentMonth.Content = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(DateTime.Today.Month).ToString(); #endregion #region SecondDay lblCurrentDayNameTwo.Content = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(DateTime.Today.AddDays(1).DayOfWeek).ToString() + ","; lblCurrentDayTwo.Content = DateTime.Today.AddDays(1).Day.ToString(); switch (DateTime.Today.AddDays(1).Day) { case 1: case 21: case 31: lblCurrentDayEndingTwo.Content = "st"; break; case 2: case 22: lblCurrentDayEndingTwo.Content = "nd"; break; case 3: case 23: lblCurrentDayEndingTwo.Content = "rd"; break; default: lblCurrentDayEndingTwo.Content = "th"; break; } lblCurrentMonthTwo.Content = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(DateTime.Today.AddDays(1).Month).ToString(); #endregion #region ThirdDay lblCurrentDayNameThree.Content = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(DateTime.Today.AddDays(2).DayOfWeek).ToString() + ","; lblCurrentDayThree.Content = DateTime.Today.AddDays(2).Day.ToString(); switch (DateTime.Today.AddDays(2).Day) { case 1: case 21: case 31: lblCurrentDayEndingThree.Content = "st"; break; case 2: case 22: lblCurrentDayEndingThree.Content = "nd"; break; case 3: case 23: lblCurrentDayEndingThree.Content = "rd"; break; default: lblCurrentDayEndingThree.Content = "th"; break; } lblCurrentMonthThree.Content = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(DateTime.Today.AddDays(2).Month).ToString(); #endregion #region FourthDay lblCurrentDayNameFour.Content = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(DateTime.Today.AddDays(3).DayOfWeek).ToString() + ","; lblCurrentDayFour.Content = DateTime.Today.AddDays(3).Day.ToString(); switch (DateTime.Today.AddDays(3).Day) { case 1: case 21: case 31: lblCurrentDayEndingFour.Content = "st"; break; case 2: case 22: lblCurrentDayEndingFour.Content = "nd"; break; case 3: case 23: lblCurrentDayEndingFour.Content = "rd"; break; default: lblCurrentDayEndingFour.Content = "th"; break; } lblCurrentMonthFour.Content = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(DateTime.Today.AddDays(3).Month).ToString(); #endregion #region FifthhDay //DateTime day = DateTime.Now.Day + 4; lblCurrentDayNameFive.Content = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(DateTime.Today.AddDays(4).DayOfWeek).ToString() + ","; lblCurrentDayFive.Content = DateTime.Today.AddDays(4).Day.ToString(); switch (DateTime.Today.AddDays(4).Day) { case 1: case 21: case 31: lblCurrentDayEndingFive.Content = "st"; break; case 2: case 22: lblCurrentDayEndingFive.Content = "nd"; break; case 3: case 23: lblCurrentDayEndingFive.Content = "rd"; break; default: lblCurrentDayEndingFive.Content = "th"; break; } lblCurrentMonthFive.Content = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(DateTime.Today.AddDays(4).Month).ToString(); #endregion #region SixthhDay lblCurrentDayNameSix.Content = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(DateTime.Today.AddDays(5).DayOfWeek).ToString() + ","; lblCurrentDaySix.Content = DateTime.Today.AddDays(5).Day.ToString(); switch (DateTime.Today.AddDays(5).Day) { case 1: case 21: case 31: lblCurrentDayEndingSix.Content = "st"; break; case 2: case 22: lblCurrentDayEndingSix.Content = "nd"; break; case 3: case 23: lblCurrentDayEndingSix.Content = "rd"; break; default: lblCurrentDayEndingSix.Content = "th"; break; } lblCurrentMonthSix.Content = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(DateTime.Today.AddDays(5).Month).ToString(); #endregion #region SeventhDay lblCurrentDayNameSeven.Content = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(DateTime.Today.AddDays(6).DayOfWeek).ToString() + ","; lblCurrentDaySeven.Content = DateTime.Today.AddDays(6).Day.ToString(); switch (DateTime.Today.AddDays(6).Day) { case 1: case 21: case 31: lblCurrentDayEndingSeven.Content = "st"; break; case 2: case 22: lblCurrentDayEndingSeven.Content = "nd"; break; case 3: case 23: lblCurrentDayEndingSeven.Content = "rd"; break; default: lblCurrentDayEndingSeven.Content = "th"; break; } lblCurrentMonthSeven.Content = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(DateTime.Today.AddDays(6).Month).ToString(); #endregion }
private void canvasMapa_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent("myFormat")) { Dogadjaj sp = e.Data.GetData("myFormat") as Dogadjaj; foreach (Tip t in Tipovi.listaTipova) { foreach (Dogadjaj dog in t.DogadjajiTipa) { if (dog.Equals(sp)) { t.DogadjajiTipa.Remove(dog); break; } } } Image ikonica = new Image(); ikonica.Height = 20; ikonica.Width = 20; ikonica.Name = sp.Oznaka; ImageSourceConverter imgConv = new ImageSourceConverter(); string path = sp.Ikona; ImageSource imageSource = (ImageSource)imgConv.ConvertFromString(path); ikonica.Source = imageSource; ikonica.ToolTip = "Oznaka: " + sp.Oznaka + "\nIme: " + sp.Ime + "\nTip: " + sp.Tip; if (!promena) { this.canvasMapa.Children.Add(ikonica); Point p = e.GetPosition(this.canvasMapa); Ikonica saCanvasa = new Ikonica(e.GetPosition(this.canvasMapa).X, e.GetPosition(this.canvasMapa).Y, sp); if (CanDrop(e.GetPosition(this.canvasMapa).X, e.GetPosition(this.canvasMapa).Y, saCanvasa)) { Canvas.SetLeft(ikonica, p.X); Canvas.SetTop(ikonica, p.Y); Ikonica icon = new Ikonica(p.X, p.Y, sp); mapaIkonica.Add(icon); } else { foreach (Tip t in Tipovi.listaTipova) { if (t.Oznaka.Equals(sp.Tip)) { t.DogadjajiTipa.Add(sp); } } this.canvasMapa.Children.Remove(ikonica); MessageBox.Show("Izaberite drugu lokaciju."); } } else { Point p = e.GetPosition(this.canvasMapa); for (int i = 0; i < mapaIkonica.Count; i++) { if (mapaIkonica[i].Do.Oznaka.Equals(sp.Oznaka)) { Ikonica saCanvasa = mapaIkonica[i]; canvasMapa.Children.RemoveAt(i); canvasMapa.Children.Insert(i, ikonica); int flagg = 0; if (!CanDrop(e.GetPosition(this.canvasMapa).X, e.GetPosition(this.canvasMapa).Y, saCanvasa)) { p.X = saCanvasa.X; p.Y = saCanvasa.Y; flagg = 1; } Canvas.SetLeft(ikonica, p.X); Canvas.SetTop(ikonica, p.Y); mapaIkonica[i].X = p.X; mapaIkonica[i].Y = p.Y; if (flagg == 1) { MessageBox.Show("Izaberite drugu lokaciju."); } break; } } } } }
private void InitializeEvent() { ControlTemplate mainWindowTemplate = this.Template; Button minBtn = (Button)mainWindowTemplate.FindName("btnMin", this); ButtonUserControl maxBtn = (ButtonUserControl)mainWindowTemplate.FindName("btnMax", this); Button closeBtn = (Button)mainWindowTemplate.FindName("btnClose", this); Button skinBtn = (Button)mainWindowTemplate.FindName("btnSkin", this); Button menuBtn = (Button)mainWindowTemplate.FindName("btnMenu", this); minBtn.Click += delegate { oldRect = new Rect(this.Left, this.Top, this.Width, this.Height); this.WindowState = WindowState.Minimized; }; maxBtn.Click += delegate { ImageSourceConverter imgConv = new ImageSourceConverter(); if (this.WindowState == WindowState.Normal) { oldRect = new Rect(this.Left, this.Top, this.Width, this.Height); this.WindowState = WindowState.Maximized; maxBtn.ImgSource = (ImageSource)imgConv.ConvertFromString("pack://application:,,,/FYJ.Winui;component/Resources/btn_restore_normal.png"); maxBtn.MouseEnterImgSource = (ImageSource)imgConv.ConvertFromString("pack://application:,,,/FYJ.Winui;component/Resources/btn_restore_highlight.png"); maxBtn.ToolTip = "向下还原"; } else { this.WindowState = WindowState.Normal; maxBtn.ImgSource = (ImageSource)imgConv.ConvertFromString("pack://application:,,,/FYJ.Winui;component/Resources/btn_max_normal.png"); maxBtn.MouseEnterImgSource = (ImageSource)imgConv.ConvertFromString("pack://application:,,,/FYJ.Winui;component/Resources/btn_max_highlight.png"); maxBtn.ToolTip = "最大化"; } }; closeBtn.Click += delegate { this.Close(); //接下来的在Closed事件里处理 }; menuBtn.Click += delegate { if (this.TitleContextMenu != null) { this.TitleContextMenu.IsOpen = true; } }; //Border borderTitle = (Border)mainWindowTemplate.FindName("borderTitle", this); //borderTitle.MouseMove += delegate(object sender, MouseEventArgs e) //{ // if (e.LeftButton == MouseButtonState.Pressed) // { // this.DragMove(); // } //}; //borderTitle.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e) //{ // if (e.ClickCount >= 2) // { // maxBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); // } //}; skinBtn.Click += delegate { pickerWindow.WindowStartupLocation = WindowStartupLocation.Manual; pickerWindow.Top = this.Top + 18; pickerWindow.Left = this.Left + this.Width - 138 - pickerWindow.Width; pickerWindow.Show(); }; }
public Poster(string imgSource, string title, int mediaId, bool isFolder, int categId) { InitializeComponent(); this.Width = 120; this.Orientation = Orientation.Vertical; b = new Border(); button = new Button(); b.Height = 100; b.Width = 100; button.BorderThickness = new Thickness(0); BrushConverter bc = new BrushConverter(); b.BorderBrush = (Brush)bc.ConvertFrom("#FF5A7DF5"); b.BorderThickness = new Thickness(0); b.CornerRadius = new CornerRadius(4); // b.Visibility = Visibility.Hidden; ImageBrush ib = new ImageBrush(); ImageSourceConverter isc = new ImageSourceConverter(); BitmapImage bmi; if (!File.Exists(imgSource)) { if (isFolder) { bmi = new BitmapImage(new Uri("pack://application:,,,/Resources/folder.ico")); } else { bmi = new BitmapImage(new Uri("pack://application:,,,/Resources/movie.ico")); } ib.ImageSource = bmi; } else { ib.ImageSource = (ImageSource)isc.ConvertFromString(imgSource); } button.Background = ib; button.Cursor = AppMAnager.HAND_CURSOR; button.MouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(DobleClick); button.Click += new RoutedEventHandler(click); textblock = new TextBlock(); textblock.Text = title; textblock.TextWrapping = System.Windows.TextWrapping.Wrap; textblock.TextAlignment = TextAlignment.Center; b.Child = button; this.Children.Add(b); this.Children.Add(textblock); this.Margin = new System.Windows.Thickness(10, 10, 10, 10); this.mediaId = mediaId; this.isFolder = isFolder; this.categId = categId; this.MinHeight = 120; this.MaxHeight = 150; this.ToolTip = title; this.selected = false; }
protected ImageSource GetImageFromResources(string path) { var uri = string.Format("pack://application:,,,/JiraAssistant;component/{0}", path.TrimStart('/')); return(_imageSourceConverter.ConvertFromString(uri) as ImageSource); }
public static List <Answer> GetAnswers() { Tasks buff = ViewModel.TasksViewModel.CurrentTask; string connectString = "provider=Microsoft.ACE.Oledb.12.0;Data Source= " + System.AppDomain.CurrentDomain.BaseDirectory + "\\AducationBase.accdb;"; OleDbConnection connection = new OleDbConnection(connectString); string query = "SELECT Ответы.ID, Ответы.ЗаданиеID, Ответы.УчительID, Ответы.УченикID, Ответы.Дата, Ответы.ТекстОтвета, Ответы.ДопФайлы, Ответы.Оценка, Ответы.Комментарий" + " FROM Ответы WHERE( ((Ответы.ЗаданиеID) = " + buff.ID + " ) AND((Ответы.УчительID) = " + Data.TeacherUsr.ID + " ) );"; OleDbCommand command = new OleDbCommand(query, connection); connection.Open(); OleDbDataReader dataReader = command.ExecuteReader(); List <Answer> result = new List <Answer>(); System.IO.Directory.CreateDirectory("ImageBuffFolder"); while (dataReader.Read()) { try { Answer buffAnswer = new Answer(); buffAnswer.ID = (int)dataReader["ID"]; buffAnswer.TeacherID = (int)dataReader["УчительID"]; buffAnswer.StudentID = (int)dataReader["УченикID"]; buffAnswer.TaskID = (int)dataReader["ЗаданиеID"]; buffAnswer.Date = (DateTime)dataReader["Дата"]; buffAnswer.DateStr = ((DateTime)(dataReader["Дата"])).ToLongDateString(); buffAnswer.AnswerText = (string)dataReader["ТекстОтвета"]; try { buffAnswer.Mark = (string)dataReader["Оценка"]; } catch { buffAnswer.Mark = "Не оценено"; } try { buffAnswer.Comment = (string)dataReader["Комментарий"]; } catch { buffAnswer.Comment = ""; } buffAnswer.GetFIO(); try { System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); memoryStream.Write((byte[])dataReader["ДопФайлы"], 0, ((byte[])dataReader["ДопФайлы"]).Length); System.Drawing.Image image = System.Drawing.Image.FromStream(memoryStream); image.Save(@"ImageBuffFolder\" + buffAnswer.ID + "answ.BMP"); memoryStream.Dispose(); ImageSourceConverter imageSourceConverter = new ImageSourceConverter(); buffAnswer.AnswerImage = new Image(); buffAnswer.AnswerImage.SetValue(System.Windows.Controls.Image.SourceProperty, imageSourceConverter.ConvertFromString(@"ImageBuffFolder\" + buffAnswer.ID + "answ.BMP")); buffAnswer.IMGS = buffAnswer.AnswerImage.Source; } catch { } result.Add(buffAnswer); } catch { } } try { NewTaskAnswer.TaskID = result[0].ID; } catch { NewTaskAnswer.TaskID = -1; } return(result); }
public static List <Tasks> GetTasks() { string connectString = "provider=Microsoft.ACE.Oledb.12.0;Data Source= " + System.AppDomain.CurrentDomain.BaseDirectory + "\\AducationBase.accdb;"; OleDbConnection connection = new OleDbConnection(connectString); string query = "SELECT Задания.ID, Задания.Преподаватель, Задания.Тема, Задания.[Дата выдачи], Задания.[Дата сдачи], Задания.Школа, Задания.Класс, Задания.Предмет, Задания.[Текст задания], Задания.ДопФайлы FROM Задания ORDER BY Задания.[Дата выдачи] DESC ;"; OleDbCommand comand = new OleDbCommand(query, connection); connection.Open(); OleDbDataReader dataReader = comand.ExecuteReader(); List <Tasks> result = new List <Tasks>(); System.IO.Directory.CreateDirectory("ImageBuffFolder"); while (dataReader.Read()) { try { result.Add (new Tasks { ID = (int)dataReader["ID"], TeacherID = (int)dataReader["Преподаватель"], Title = (string)dataReader["Тема"], DateBegin = (DateTime)dataReader["Дата выдачи"], DateEnd = (DateTime)dataReader["Дата сдачи"], DateBeginStr = ((DateTime)(dataReader["Дата выдачи"])).ToLongDateString(), DateEndStr = ((DateTime)dataReader["Дата сдачи"]).ToLongDateString(), SchoolID = (int)dataReader["Школа"], KlassID = (int)dataReader["Класс"], Klass = StartWindow.Data.TeacherUsr.GetTextWithID("Учебная программа", "Класс", (int)dataReader["Класс"]), SubjectID = (int)dataReader["Предмет"], Subject = StartWindow.Data.TeacherUsr.GetTextWithID("Список предметов", "Предмет", (int)dataReader["Предмет"]), TaskText = (string)dataReader["Текст задания"], }); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); memoryStream.Write((byte[])dataReader["ДопФайлы"], 0, ((byte[])dataReader["ДопФайлы"]).Length); System.Drawing.Image image = System.Drawing.Image.FromStream(memoryStream); image.Save(@"ImageBuffFolder\" + result[result.Count - 1].ID + ".BMP"); memoryStream.Dispose(); ImageSourceConverter imageSourceConverter = new ImageSourceConverter(); result[result.Count - 1].TaskImage = new Image(); result[result.Count - 1].TaskImage.SetValue(System.Windows.Controls.Image.SourceProperty, imageSourceConverter.ConvertFromString(@"ImageBuffFolder\" + result[result.Count - 1].ID + ".BMP")); result[result.Count - 1].IMGS = result[result.Count - 1].TaskImage.Source; } catch { } } try { NewTaskAnswer.TaskID = result[0].ID; } catch { NewTaskAnswer.TaskID = -1; } return(result); }
private void loadImageAs(string path, System.Windows.Controls.Image elem) { ImageSourceConverter imgs = new ImageSourceConverter(); elem.SetValue(Image.SourceProperty, imgs.ConvertFromString(path)); }
private void GetImageListKey(TblAuthPermissionViewModel tblAuthPermission, string permissionType) { if (tblAuthPermission.Iserial == 569) { } const string src = "/CCWFM;component/Images/ImageListIcons/"; var converter = new ImageSourceConverter(); var iconKey = ""; switch (permissionType.ToUpper().Trim()) { case "F": iconKey = "FormIcon"; break; case "FU": iconKey = "DetailsIcon"; break; case "FD": iconKey = "TransIcon"; break; case "C": iconKey = "ChildIcon"; break; case "M": iconKey = "MenuIcon"; break; case "R": iconKey = "ReportIcon"; break; } tblAuthPermission.ImageKey = iconKey; switch (iconKey) { case "MenuIcon": tblAuthPermission.SelectedImage = (ImageSource)converter.ConvertFromString(src + "Menu.png"); break; case "FormIcon": tblAuthPermission.SelectedImage = (ImageSource)converter.ConvertFromString(src + "Form.png"); //CCWFM;component/Images/ImageListIcons/Form.png tblAuthPermission.SubPermissionsList.Add(new TblAuthPermissionViewModel { Ename = "Add", ImageKey = "Add", SelectedImage = (ImageSource)converter.ConvertFromString(src + "Add.png") }); tblAuthPermission.SubPermissionsList.Add(new TblAuthPermissionViewModel { Ename = "Update", ImageKey = "Update", SelectedImage = (ImageSource)converter.ConvertFromString(src + "Update.png") }); tblAuthPermission.SubPermissionsList.Add(new TblAuthPermissionViewModel { Ename = "Delete", ImageKey = "Delete", SelectedImage = (ImageSource)converter.ConvertFromString(src + "Delete.png") }); break; case "DetailsIcon": tblAuthPermission.SubPermissionsList.Add(new TblAuthPermissionViewModel { Ename = "Update", ImageKey = "Update", SelectedImage = (ImageSource)converter.ConvertFromString(src + "Update.png") }); break; case "TransIcon": tblAuthPermission.SubPermissionsList.Add(new TblAuthPermissionViewModel { Ename = "Add", ImageKey = "Add", SelectedImage = (ImageSource)converter.ConvertFromString(src + "Add.png") }); tblAuthPermission.SubPermissionsList.Add(new TblAuthPermissionViewModel { Ename = "Update", ImageKey = "Update", SelectedImage = (ImageSource)converter.ConvertFromString(src + "Update.png") }); break; } }
private void showMain(GetProgrammesCompletedEventArgs b) { programmes.Children.Clear(); programmes.Orientation = Orientation.Horizontal; int imin = 9999; /* * foreach (string chn in b.Result.programmes.Select(x=>x.channel).Distinct()) * { * int l = b.Result.programmes.Count(x => x.channel == chn); * imin = Math.Min(imin, l); * } */ List <StackPanel> sps = new List <StackPanel>(); foreach (string chn in b.Result.programmes.OrderBy(x => FixToNum(x.channel)).Select(x => x.channel).Distinct()) { StackPanel sp = new StackPanel(); sp.Orientation = Orientation.Vertical; sp.Margin = new Thickness(10); Image img = new Image(); ImageSourceConverter isc = new ImageSourceConverter(); ImageSource imagesource = isc.ConvertFromString("images/" + chn + ".png") as ImageSource; img.Source = imagesource; img.HorizontalAlignment = HorizontalAlignment.Left; img.MaxHeight = 44; Border bimg = inBorder(img); bimg.BorderThickness = new Thickness(1); sp.Children.Add(bimg); var list = b.Result.programmes.Where(x => x.channel.Equals(chn)).OrderBy(x => x.start); int icnt = 0; foreach (Programme prg in list.Where(x => !x.title.Contains("Sändningsuppehåll"))) { MyProgramme myp = Translate(prg); TextBlock tb = new TextBlock() { Text = myp.start.ToString("HH:mm") + " " + myp.title, Width = 200, FontFamily = new FontFamily("Verdana"), FontSize = 12, Tag = myp }; myp.Parent = tb; Border bo = inBorder(tb); bo.BorderThickness = new Thickness(1, 0, 1, 1); if (myp.start <= DateTime.Now && DateTime.Now < myp.stop) { tb.FontWeight = FontWeights.Bold; } if (myp.stop < DateTime.Now) { bo.Style = sOld; } tb.MouseLeave += (x, z) => { if (myp.stop < DateTime.Now) { bo.Style = sOld; } else { bo.Style = sOrg; } }; tb.MouseEnter += (x, z) => { bo.Style = sAlt; canvas.Visibility = Visibility.Collapsed; showCanvas(z.GetPosition(LayoutRoot)); info.Text = myp.start.ToString("yyyy-MM-dd HH:mm") + "-" + myp.stop.ToString("HH:mm") + "\r" + myp.title + (!string.IsNullOrEmpty(myp.subtitle) ? " - " + myp.subtitle : "") + "\r" + myp.desc; }; icnt++; if (icnt == list.Count() || icnt == imin) { bo.BorderThickness = new Thickness(1, 0, 1, 1); } AddToSp(sp, bo); if (icnt == imin) { break; } } sps.Add(sp); } programmes.Orientation = Orientation.Vertical; List <StackPanel> spvs = new List <StackPanel>(); string strPerRow = (programmes.ActualWidth / 220).ToString(); int numperrows = int.Parse(strPerRow.Contains(",")?strPerRow.Substring(0, strPerRow.IndexOf(",")):strPerRow.Contains(".")?strPerRow.Substring(0, strPerRow.IndexOf(".")):strPerRow); double cnt = sps.Count; //int sqrt = int.Parse(Math.Round((Math.Sqrt(cnt)+1), 0).ToString()); int sqrt = int.Parse(Math.Round((cnt / numperrows), 0).ToString()); for (int ix = 0; ix < sqrt; ix++) { StackPanel sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; sp.Margin = new Thickness(0); spvs.Add(sp); } int ispicnt = 0; int ispvcnt = 0; foreach (StackPanel spi in sps) { if (ispicnt > 0 && ispicnt >= numperrows) //ispicnt % sqrt == 0) { ispicnt = 0; ispvcnt++; } StackPanel spv = spvs[ispvcnt]; spv.Children.Add(spi); ispicnt++; } foreach (StackPanel spv in spvs) { programmes.Children.Add(spv); } programmes.HorizontalAlignment = HorizontalAlignment.Stretch; programmes.VerticalAlignment = VerticalAlignment.Stretch; }
/// <summary> /// Gets the protocols default icon. /// </summary> /// <param name="type">The desired icon quality. If the sspecified size is not available we will try it with a smaller image</param> /// <exception> /// <cref>ProtocolInvalidIconException</cref> /// </exception> public ImageSource GetProtocolIcon(IconType type) { if (iconCache.ContainsKey(GetProtocolIconCacheKey(type))) { return(iconCache[GetProtocolIconCacheKey(type)]); } var filename = "{0}{1}." + GetSetting(IniSection.INFORMATION, IniKey.PROTOCOL_ICON_EXTENSION); FileInfo IconFile = null; switch (type) { case IconType.SMALL: filename = String.Format(filename, GetSetting(IniSection.INFORMATION, IniKey.PROTOCOL_ICON_PREFIX), "16"); break; case IconType.MEDIUM: filename = String.Format(filename, GetSetting(IniSection.INFORMATION, IniKey.PROTOCOL_ICON_PREFIX), "32"); break; case IconType.LARGE: filename = String.Format(filename, GetSetting(IniSection.INFORMATION, IniKey.PROTOCOL_ICON_PREFIX), "64"); break; case IconType.HIGHDEF: filename = String.Format(filename, GetSetting(IniSection.INFORMATION, IniKey.PROTOCOL_ICON_PREFIX), "128"); break; } IconFile = new FileInfo(Config.GetDirectory() + "\\res\\" + filename); Logger.Log(LogEntryType.Verbose, String.Format("Trying to load {0} from path: {1}", filename, IconFile.FullName), loggerContext); if (IconFile.Exists) { var imsc = new ImageSourceConverter(); try { ImageSource ims = null; Application.Current.Dispatcher.Invoke(() => { ims = (ImageSource)imsc.ConvertFromString(IconFile.FullName); Logger.Log(LogEntryType.Verbose, String.Format("Protocol icon loaded and converted, returning it now..."), loggerContext); if (ims == null) { return; } //Required for Multithreaded processing where this icon is used ims.Freeze(); //Check again, if Icon really not exists if (!iconCache.ContainsKey(GetProtocolIconCacheKey(type))) { iconCache.Add(GetProtocolIconCacheKey(type), ims); } }); return(ims); } catch (Exception ex) { throw new ProtocolConfigurationException(beRemoteExInfoPackage.SignificantInformationPackage, "Error while loading image: " + IconFile.Name, ex); } } else { Logger.Log(LogEntryType.Verbose, "The given icon type(" + type + ") could not be loaded. Trying it with lower resolution", loggerContext); var returnIcon = GetProtocolIcon_LowerType(type); //Required for Multithreaded processing where this icon is used returnIcon.Freeze(); return(returnIcon); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { ImageSourceConverter im = new ImageSourceConverter(); image.Source = (ImageSource)(im.ConvertFromString(Settings.icon_name)); }
void AllLoad(string name, int h, int m, int low, int hours, int minutes) { namef = name; priceHight = h; priceMiddle = m; priceLow = low; HOUR = hours; MIN = minutes; sizeroom = 10; sizerow = 7; room = new Sofa[sizerow][]; label1.Content = priceLow + " грн"; label2.Content = priceMiddle + " грн"; label3.Content = priceHight + " грн"; mytimer.Tick += new EventHandler(mytimer_Tick); mytimer.Interval = new TimeSpan(0, 0, 1); mytimer.Start(); for (int i = 0; i < sizerow; i++) { room[i] = new Sofa[sizeroom]; for (int j = 0; j < sizeroom; j++) { if (j == 0) { Label l = new Label(); l.Width = 20; l.Height = 25; l.BorderThickness = new Thickness(1); l.Content = sizerow - i; kino.Children.Add(l); continue; } room[i][j] = new Sofa(); GetStyle(i, j); room[i][j].butt.Click += new RoutedEventHandler(butt_Click); ToolTip tt = new System.Windows.Controls.ToolTip(); tt.Content = (sizerow - i) + " ряд " + (j) + " место " + " цена " + room[i][j].Cost + " грн"; room[i][j].butt.ToolTip = tt; kino.Children.Add(room[i][j].butt); } } string tmp = ""; using (StreamReader file = File.OpenText(@"../films/" + namef + ".txt")) { while (file.Peek() >= 0) { tmp += file.ReadLine(); } } Info.Text = tmp; ImageSourceConverter imgs = new ImageSourceConverter(); FAce.SetValue(Image.SourceProperty, imgs.ConvertFromString(@"../films/" + namef + ".jpg")); screen.SetValue(Image.SourceProperty, imgs.ConvertFromString(@"../timer/im.png")); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { ImageSourceConverter imageSourceConverter = new ImageSourceConverter(); return(imageSourceConverter.ConvertFromString("collapse.gif")); }
public MainViewModel() { ImageSourceConverter isc = new ImageSourceConverter(); this.Header = "MyComputer"; this.Items = new ObservableCollection <ExplorerItem>(); ExplorerItem personalInfo = new ExplorerItem() { Header = "Personal Folders", IconPath = (ImageSource)isc.ConvertFromString("Images/1PersonalFolders.png"), Path = "PersonalFolders" }; this.Items.Add(personalInfo); ExplorerItem programFiles = new ExplorerItem() { Header = "Program Files", IconPath = (ImageSource)isc.ConvertFromString("Images/folder2.png"), Path = "ProgramFiles" }; this.Items.Add(programFiles); ExplorerItem programFiles86 = new ExplorerItem() { Header = "Program Files(86)", IconPath = (ImageSource)isc.ConvertFromString("Images/folder2.png"), Path = "ProgramFiles(86)" }; this.Items.Add(programFiles86); ExplorerItem downloads = new ExplorerItem() { Header = "Downloads", IconPath = (ImageSource)isc.ConvertFromString("Images/folder2.png"), Path = "Downloads" }; this.Items.Add(downloads); ExplorerItem localHard = new ExplorerItem() { Header = "Local Disk (C:)", Path = "LocalDisk(C:)", IconPath = (ImageSource)isc.ConvertFromString("Images/HardDrive16.png") }; this.Items.Add(localHard); ExplorerItem localHard2 = new ExplorerItem() { Header = "Local Disk (D:)", Path = "LocalDisk(D:)", IconPath = (ImageSource)isc.ConvertFromString("Images/HardDrive16.png") }; this.Items.Add(localHard2); ExplorerItem desktop = new ExplorerItem() { Header = "Desktop", Path = "Desktop", IconPath = (ImageSource)isc.ConvertFromString("Images/Desktop.png") }; this.Items.Add(desktop); }
private static ImageSource FromString(string value) { return((ImageSource)Converter.ConvertFromString(value)); }
public BaseWindow() { this.AllowDrop = true; //this.Style = (Style)App.Current.Resources["MainWindowStyle"]; this.SourceInitialized += delegate(object sender, EventArgs e) { this.hwndSource = PresentationSource.FromVisual((Visual)sender) as HwndSource; this.hwndSource.AddHook(Win32.WindowProc); }; this.Loaded += delegate { try { //ControlTemplate mainWindowTemplate = (ControlTemplate)App.Current.Resources["BaseWindowControlTemplate"]; ControlTemplate mainWindowTemplate = this.Template; ButtonUserControl btnMenu = (ButtonUserControl)mainWindowTemplate.FindName("btnMenu", this); ButtonUserControl btnSkin = (ButtonUserControl)mainWindowTemplate.FindName("btnSkin", this); ButtonUserControl btnMin = (ButtonUserControl)mainWindowTemplate.FindName("btnMin", this); ButtonUserControl btnMax = (ButtonUserControl)mainWindowTemplate.FindName("btnMax", this); if (!IsShowMenuButton) { btnMenu.Visibility = Visibility.Collapsed; } if (IsShowSkinButton) { pickerWindow = new ColorPickerWindow(); ChangeColor(Color.FromArgb(pickerWindow.CurrentColor.A, pickerWindow.CurrentColor.R, pickerWindow.CurrentColor.G, pickerWindow.CurrentColor.B)); pickerWindow.ColorChanged += delegate(System.Windows.Media.Color c) { ChangeColor(c); }; pickerWindow.SkinChanged += delegate(BitmapSource bitmapSource) { ChangeSkin(bitmapSource); }; pickerWindow.OpacityChanged += delegate(int value) { this.Opacity = Math.Round(value / 100.0, 2); }; } else { //2015-7-13 System.Drawing.Color _currentColor = System.Drawing.Color.FromArgb(21, 160, 253); ChangeColor(Color.FromArgb(_currentColor.A, _currentColor.R, _currentColor.G, _currentColor.B)); btnSkin.Visibility = Visibility.Collapsed; } if (this.ResizeMode == ResizeMode.NoResize) { btnMax.Visibility = Visibility.Collapsed; btnMin.Visibility = Visibility.Collapsed; } if (this.ResizeMode == ResizeMode.CanMinimize) { btnMax.IsEnabled = false; } if (this.ResizeMode == ResizeMode.CanResize || this.ResizeMode == ResizeMode.CanResizeWithGrip) { ImageSourceConverter imgConv = new ImageSourceConverter(); if (this.WindowState == WindowState.Normal) { btnMax.ImgSource = (ImageSource)imgConv.ConvertFromString("pack://application:,,,/FYJ.Winui;component/Resources/btn_max_normal.png"); btnMax.MouseEnterImgSource = (ImageSource)imgConv.ConvertFromString("pack://application:,,,/FYJ.Winui;component/Resources/btn_max_highlight.png"); btnMax.ToolTip = "最大化"; } else { btnMax.ImgSource = (ImageSource)imgConv.ConvertFromString("pack://application:,,,/FYJ.Winui;component/Resources/btn_restore_normal.png"); btnMax.MouseEnterImgSource = (ImageSource)imgConv.ConvertFromString("pack://application:,,,/FYJ.Winui;component/Resources/btn_restore_highlight.png"); btnMax.ToolTip = "向下还原"; } } InitializeEvent(); } catch (Exception ex) { MessageBox.Show("加载失败:" + ex.Message); } }; this.StateChanged += delegate { if (this.WindowState == WindowState.Maximized) { System.Drawing.Size size = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size; this.Width = size.Width; this.Height = size.Height; } else { if (oldRect.Width != 0) { this.Width = oldRect.Width; this.Height = oldRect.Height; this.Top = oldRect.Top; this.Left = oldRect.Left; } } }; this.Closed += delegate { if (pickerWindow != null) { pickerWindow.Close(); } if (IsCloseApplication) { Application.Current.Shutdown(); Environment.Exit(0); } }; }
private void image_product_MouseDown(object sender, MouseButtonEventArgs e) { try { FileDialog filedlg = new OpenFileDialog(); filedlg.Filter = "Image File (*.jpg;*.bmp;*.gif)| *.jpg; *.bmp; *.gif"; filedlg.ShowDialog(); { strName = filedlg.SafeFileName; imageName = filedlg.FileName; if (imageName != "") { ImageSourceConverter isc = new ImageSourceConverter(); image_product.SetValue(System.Windows.Controls.Image.SourceProperty, isc.ConvertFromString(imageName)); } } filedlg = null; } catch { MessageBox.Show("خطایی رخ داده است"); } }
private ImageSource GetGlobalMapImagefFromSti(string aFileName) { string _path = Path.Combine(this.FGlobalMapsFolder, aFileName); IStci _sti = null; if (File.Exists(_path)) { using (FileStream input = new FileStream(_path, FileMode.Open, FileAccess.Read)) _sti = StciLoader.LoadStci(input); } else { if (this.SlfFile != null) { SlfFile.Record _record = this.SlfFile.Records .SingleOrDefault(x => x.FileName.ToUpperInvariant() == aFileName.ToUpperInvariant()); if (_record != null) { using (MemoryStream input = new MemoryStream(_record.Data)) _sti = StciLoader.LoadStci(input); } } } if (_sti == null) { ImageSourceConverter _isc = new ImageSourceConverter(); ImageSource _is = (ImageSource)_isc.ConvertFromString("MAP_STUB.bmp"); return(_is); } else if (_sti is StciIndexed) { StciIndexed _stciIndexed = (StciIndexed)_sti; List <Color> _palette = _stciIndexed.ColorPalette .Select(x => new Color() { A = 255, R = x.Red, G = x.Green, B = x.Blue }) .ToList(); StciSubImage _subImage = _stciIndexed.Images[0]; StructureImage _image = new StructureImage(_subImage, _palette); BitmapPalette _pb = new BitmapPalette(_palette); PixelFormat _pf = PixelFormats.Indexed8; BitmapSource _bitmap = BitmapSource.Create( _subImage.Header.Width, _subImage.Header.Height, 96, 96, _pf, _pb, _subImage.ImageData, _subImage.Header.Width * _pf.BitsPerPixel / 8); return(_bitmap); } else if (_sti is StciRgb) { StciRgb _stciRgb = (StciRgb)_sti; PixelFormat _pf = PixelFormats.Bgr565; BitmapSource _bitmap = BitmapSource.Create( _stciRgb.Header.ImageWidth, _stciRgb.Header.ImageHeight, 96, 96, _pf, null, _stciRgb.ImageData, _stciRgb.Header.ImageWidth * _pf.BitsPerPixel / 8); return(_bitmap); } return(null); }
private void SetSource(Image image, string path) { image.Source = (ImageSource)ISC.ConvertFromString(path); }
private void ChoicePicture_Click(object sender, RoutedEventArgs e) { try { OpenFileDialog dialog = new OpenFileDialog { CheckFileExists = true, Multiselect = false, Filter = "Images (*.jpg,*.png)|*.jpg;*.png|All Files(*.*)|*.*" }; dialog.ShowDialog(); { StrName = dialog.SafeFileName; ImageName = dialog.FileName; ImageSourceConverter isc = new ImageSourceConverter(); if (ImageName != "") { MyImage.SetValue(System.Windows.Controls.Image.SourceProperty, isc.ConvertFromString(ImageName)); // ImagePath.Text = ImageName.ToString(); } } } catch { ErrorPage Er = new ErrorPage(); Er.Show(); Er.Error_Lable.Content = "مشکلی در سیستم به وجود آمده است"; } }
private void SetDungeonMap_Click(object sender, RoutedEventArgs e) { OpenFileDialog FD = new OpenFileDialog(); if (FD.ShowDialog() == true) { ImageSourceConverter imsc = new ImageSourceConverter(); try { DungeonMap.SetValue(System.Windows.Controls.Image.SourceProperty, imsc.ConvertFromString(FD.FileName)); GetBitmap(FD.FileName); NewDungeon.ImageSourse = FD.FileName; } catch (System.InvalidOperationException) { MessageBox.Show("Что-то пошло не так. Говорят, должна быть выбрана именно картинка"); } } }
private void min_MouseLeave(object sender, MouseEventArgs e) { ImageSourceConverter imgs = new ImageSourceConverter(); min.Source = (ImageSource)imgs.ConvertFromString("pack://application:,,,/Imgs/buttons/min/min_steady.png"); }
private void Test_Click(object sender, RoutedEventArgs e) { OpenFileDialog FD = new OpenFileDialog(); if (FD.ShowDialog() == true) { try { Converter c = new Converter(); NewDungeon = c.Loader(FD.FileName); DungeonName.Content = NewDungeon.Name; foreach (Encounter enc in NewDungeon.GetEncounters) { EncounterList.Items.Add(enc.Name); } NewDungeon.map.Save(System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory) + "\\DungeonCreator\\test111.png"); FD.FileName = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory) + "\\DungeonCreator\\test111.png"; ImageSourceConverter imsc = new ImageSourceConverter(); DungeonMap.SetValue(System.Windows.Controls.Image.SourceProperty, imsc.ConvertFromString(FD.FileName)); NewDungeon.ImageSourse = FD.FileName; } catch (System.InvalidOperationException) { MessageBox.Show("Что-то пошло не так"); } } // File.Delete(FD.FileName); }
public ArtistasOuvidos() { InitializeComponent(); artistas = Global.sql.GetArtistasOuvidos(LoginInfo.id); int i = artistas.Count; switch (i) { case 1: var converter = new ImageSourceConverter(); Image_1.Source = (ImageSource)converter.ConvertFromString(artistas[0].Img); Label_1.Content = artistas[0].Nome; break; case 2: converter = new ImageSourceConverter(); Image_1.Source = (ImageSource)converter.ConvertFromString(artistas[0].Img); Label_1.Content = artistas[0].Nome; converter = new ImageSourceConverter(); Image_2.Source = (ImageSource)converter.ConvertFromString(artistas[1].Img); Label_2.Content = artistas[1].Nome; break; case 3: converter = new ImageSourceConverter(); Image_1.Source = (ImageSource)converter.ConvertFromString(artistas[0].Img); Label_1.Content = artistas[0].Nome; converter = new ImageSourceConverter(); Image_2.Source = (ImageSource)converter.ConvertFromString(artistas[1].Img); Label_2.Content = artistas[1].Nome; converter = new ImageSourceConverter(); Image_3.Source = (ImageSource)converter.ConvertFromString(artistas[2].Img); Label_3.Content = artistas[2].Nome; break; case 4: converter = new ImageSourceConverter(); Image_1.Source = (ImageSource)converter.ConvertFromString(artistas[0].Img); Label_1.Content = artistas[0].Nome; converter = new ImageSourceConverter(); Image_2.Source = (ImageSource)converter.ConvertFromString(artistas[1].Img); Label_2.Content = artistas[1].Nome; converter = new ImageSourceConverter(); Image_3.Source = (ImageSource)converter.ConvertFromString(artistas[2].Img); Label_3.Content = artistas[2].Nome; converter = new ImageSourceConverter(); Image_4.Source = (ImageSource)converter.ConvertFromString(artistas[3].Img); Label_4.Content = artistas[3].Nome; break; case 5: converter = new ImageSourceConverter(); Image_1.Source = (ImageSource)converter.ConvertFromString(artistas[0].Img); Label_1.Content = artistas[0].Nome; converter = new ImageSourceConverter(); Image_2.Source = (ImageSource)converter.ConvertFromString(artistas[1].Img); Label_2.Content = artistas[1].Nome; converter = new ImageSourceConverter(); Image_3.Source = (ImageSource)converter.ConvertFromString(artistas[2].Img); Label_3.Content = artistas[2].Nome; converter = new ImageSourceConverter(); Image_4.Source = (ImageSource)converter.ConvertFromString(artistas[3].Img); Label_4.Content = artistas[3].Nome; converter = new ImageSourceConverter(); Image_5.Source = (ImageSource)converter.ConvertFromString(artistas[4].Img); Label_5.Content = artistas[4].Nome; break; case 6: converter = new ImageSourceConverter(); Image_1.Source = (ImageSource)converter.ConvertFromString(artistas[0].Img); Label_1.Content = artistas[0].Nome; converter = new ImageSourceConverter(); Image_2.Source = (ImageSource)converter.ConvertFromString(artistas[1].Img); Label_2.Content = artistas[1].Nome; converter = new ImageSourceConverter(); Image_3.Source = (ImageSource)converter.ConvertFromString(artistas[2].Img); Label_3.Content = artistas[2].Nome; converter = new ImageSourceConverter(); Image_4.Source = (ImageSource)converter.ConvertFromString(artistas[3].Img); Label_4.Content = artistas[3].Nome; converter = new ImageSourceConverter(); Image_5.Source = (ImageSource)converter.ConvertFromString(artistas[4].Img); Label_5.Content = artistas[4].Nome; converter = new ImageSourceConverter(); Image_6.Source = (ImageSource)converter.ConvertFromString(artistas[5].Img); Label_6.Content = artistas[5].Nome; break; default: converter = new ImageSourceConverter(); Image_1.Source = (ImageSource)converter.ConvertFromString(artistas[0].Img); Label_1.Content = artistas[0].Nome; converter = new ImageSourceConverter(); Image_2.Source = (ImageSource)converter.ConvertFromString(artistas[1].Img); Label_2.Content = artistas[1].Nome; converter = new ImageSourceConverter(); Image_3.Source = (ImageSource)converter.ConvertFromString(artistas[2].Img); Label_3.Content = artistas[2].Nome; converter = new ImageSourceConverter(); Image_4.Source = (ImageSource)converter.ConvertFromString(artistas[3].Img); Label_4.Content = artistas[3].Nome; converter = new ImageSourceConverter(); Image_5.Source = (ImageSource)converter.ConvertFromString(artistas[4].Img); Label_5.Content = artistas[4].Nome; converter = new ImageSourceConverter(); Image_6.Source = (ImageSource)converter.ConvertFromString(artistas[5].Img); Label_6.Content = artistas[5].Nome; break; } }
private void showMatrix(GetProgrammesCompletedEventArgs b) { programmes.Children.Clear(); programmes.Orientation = Orientation.Vertical; StackPanel sptime = new StackPanel(); sptime.Orientation = Orientation.Horizontal; DateTime dtNow = DateTime.Now; TextBlock tblog = new TextBlock(); tblog.Width = 44; tblog.Margin = new Thickness(0); tblog.Padding = tblog.Margin; sptime.Children.Add(tblog); DateTime dtMax = b.Result.programmes.Max(x => x.stop); while (dtNow < dtMax) { TextBlock tbtim = new TextBlock(); tbtim.Margin = new Thickness(0); tbtim.Padding = tbtim.Margin; tbtim.Width = 6; tbtim.FontSize = 9; tbtim.TextAlignment = TextAlignment.Center; if (dtNow.Minute == 27 || dtNow.Minute == 57) { dtNow = dtNow.AddMinutes(3); tbtim.Text = dtNow.ToString("HH:mm"); tbtim.Width = 36; dtNow = dtNow.AddMinutes(2); } dtNow = dtNow.AddMinutes(1); Border bor = inBorder(tbtim); bor.BorderThickness = new Thickness(0, 0, 0, 1); sptime.Children.Add(bor); } programmes.Children.Add(sptime); foreach (string chn in b.Result.programmes.OrderBy(x => FixToNum(x.channel)).Select(x => x.channel).Distinct()) { StackPanel sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; sp.Margin = new Thickness(0); Image img = new Image(); ImageSourceConverter isc = new ImageSourceConverter(); ImageSource imagesource = isc.ConvertFromString("images/" + chn + ".png") as ImageSource; img.Source = imagesource; img.MaxHeight = 44; sp.Children.Add(inBorder(img)); Programme lastprg = new Programme(); foreach (Programme prg in b.Result.programmes.Where(x => x.channel.Equals(chn)).OrderBy(x => x.start)) { if (prg.stop > DateTime.Now) { if (DateTime.Now < prg.start && sp.Children.Count == 1) { Programme pause = new Programme() { start = DateTime.Now, stop = prg.start, title = "Sändningsuppehåll", desc = "Uppehåll i sändning", channel = prg.channel }; Border bp = NewProg(pause); AddToSp(sp, bp); } Border bo = NewProg(prg); AddToSp(sp, bo); lastprg = prg; } } if (lastprg.stop < dtMax) { Programme pause = new Programme() { start = lastprg.stop, stop = dtMax, title = "Sändningsuppehåll", desc = "Uppehåll i sändning", channel = lastprg.channel }; Border bp = NewProg(pause); AddToSp(sp, bp); } programmes.Children.Add(sp); } }