public override void OnApplyTemplate() #endif { base.OnApplyTemplate(); if (_website != null) _website.ManipulationCompleted -= websiteClick_ManipulationCompleted; if (_emailAddress != null) _emailAddress.ManipulationCompleted -= email_ManipulationCompleted; _emailAddress = GetTemplateChild(EmailAddressName) as TextBlock; _website = GetTemplateChild(WebsiteName) as TextBlock; _author = GetTemplateChild(AuthorTxtBlockName) as TextBlock; SetVisibility(_emailAddress); SetVisibility(_website); SetVisibility(_author); if (_emailAddress != null) _emailAddress.ManipulationCompleted += email_ManipulationCompleted; if (_website != null) _website.ManipulationCompleted += websiteClick_ManipulationCompleted; }
// if you want to rotate any text block .... public void Rotate(TextBlock textBlock, int rotationAngleDegrees) { RotateTransform rTransform = new RotateTransform(); rTransform.Angle = rotationAngleDegrees; textBlock.RenderTransformOrigin = new Point(0.5, 0.5); textBlock.RenderTransform = rTransform; }
public bool Execute() { Uri uri = _uriString.ToUri("The from URI was invalid"); IInboundTransport fromTransport = Program.Transports.GetTransport(uri); var text = new TextBlock() .BeginBlock("Peek URI: " + uri, ""); int peekCount = 0; fromTransport.Receive(receiveContext => { if (peekCount >= _count) return null; var body = Encoding.UTF8.GetString(receiveContext.BodyStream.ReadToEnd()); text.BeginBlock("MessageId: " + receiveContext.MessageId ?? "", peekCount) .Body(body) .EndBlock(); peekCount++; return null; }, TimeSpan.Zero); _log.Info(text.ToString()); return true; }
/// <summary> /// Called when this page is navigated to. /// Fills out form fields with recognition results. /// </summary> /// <param name="e"></param> protected override void OnNavigatedTo(NavigationEventArgs e) { // call default behaviour base.OnNavigatedTo(e); // clear form fields mContent.Children.Clear(); // if results have been passed copy them to form fields if (results != null) { StackPanel typePanel = new StackPanel() { HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, Margin = new Thickness(0, 0, 0, 40) }; TextBlock typeLabel = new TextBlock() { Text = "Result Type: " + resultsType, HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, TextWrapping = TextWrapping.Wrap, FontSize = 27 }; typePanel.Children.Add(typeLabel); mContent.Children.Add(typePanel); foreach (var key in results.Keys) { if (key != null && results[key] != null) { StackPanel panel = new StackPanel() { HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, Margin = new Thickness(0, 0, 0, 20) }; TextBlock label = new TextBlock() { Text = key, HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, TextWrapping = TextWrapping.Wrap }; TextBox textbox = new TextBox() { Text = results[key].ToString(), HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, TextWrapping = TextWrapping.Wrap }; panel.Children.Add(label); panel.Children.Add(textbox); mContent.Children.Add(panel); } } } else { StackPanel typePanel = new StackPanel() { HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, Margin = new Thickness(0, 0, 0, 40) }; TextBlock typeLabel = new TextBlock() { Text = "No results found", HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, TextWrapping = TextWrapping.Wrap, FontSize = 27 }; typePanel.Children.Add(typeLabel); mContent.Children.Add(typePanel); } }
public bool Execute() { Uri fromUri = _fromUriString.ToUri("The from URI was invalid"); Uri toUri = _toUriString.ToUri("The to URI was invalid"); IInboundTransport fromTransport = Program.Transports.GetTransport(fromUri); IOutboundTransport toTransport = Program.Transports.GetTransport(toUri); ITextBlock text = new TextBlock() .BeginBlock("Move messages from " + fromUri + " to " + toUri, ""); int moveCount = 0; for (int i = 0; i < _count; i++) { fromTransport.Receive(receiveContext => { return context => { var moveContext = new MoveMessageSendContext(context); toTransport.Send(moveContext); text.BodyFormat("Message-Id: {0}", context.MessageId); moveCount++; }; }, TimeSpan.Zero); } _log.Info(text); _log.InfoFormat("{0} message{1} moved from {2} to {3}", moveCount, moveCount == 1 ? "" : "s", fromUri, toUri); return true; }
protected override void OnSave( TextBlock block ) { base.OnSave( block ); if( !string.IsNullOrEmpty( diffuseMap ) ) block.SetAttribute( "diffuseMap", diffuseMap ); }
public btch_item(stat_home m, int i, String btch_name) { main = m; item = new Grid(); this.btch_name = btch_name; item.Height = 60; item.Width = 456; item.HorizontalAlignment = HorizontalAlignment.Left; item.VerticalAlignment = VerticalAlignment.Top; item.Margin = new Thickness(10, 10 + i * 90, 0, 0); name = new TextBlock(); item.Children.Add(name); name.Height = 60; name.Width = 456; name.TextWrapping = TextWrapping.NoWrap; name.FontSize = 40; name.Margin = new Thickness(0, 0, 0, 0); name.Foreground = new SolidColorBrush(Colors.White); name.HorizontalAlignment = HorizontalAlignment.Left; name.VerticalAlignment = VerticalAlignment.Top; name.MouseLeftButtonDown += new MouseButtonEventHandler(expand); name.Text = btch_name; }
public UpdateCell(TextBlock tb, Storyboard sbUp, Storyboard sbDown, Storyboard sbSame) { this.tb = tb; this.sbUp = sbUp; this.sbDown = sbDown; this.sbSame = sbSame; }
// 构造函数 public MainPage() { InitializeComponent(); app.str_Uri = null; #region 计时 txtb_Time = new TextBlock(); Canvas.SetLeft(txtb_Time, 350); Canvas.SetTop(txtb_Time, 0); Carrier.Children.Add(txtb_Time); this.txtb_Time.Text = count.ToString();//开始时为00:00:00 this.timer.Tick += Timer_Tick;//时间控件timer,事件Tick,类似线程 this.timer.Interval = TimeSpan.FromMilliseconds(100);//每100毫秒变化一次 StartTime = DateTime.UtcNow; this.timer.Start();//控件timer开始计时,类似线程开始 #endregion #region 判断是否游戏结束 dispatcherTimerChecked = new DispatcherTimer(); dispatcherTimerChecked.Tick += new EventHandler(dispatcherTimerChecked_Tick); dispatcherTimerChecked.Interval = TimeSpan.FromMilliseconds(50); dispatcherTimerChecked.Start(); #endregion }
public bool Execute() { Uri uri = _uriString.ToUri("The URI was invalid"); IDuplexTransport transport = Program.Transports.GetTransport(uri); ITextBlock text = new TextBlock() .BeginBlock("Requeue messages to " + uri, ""); int requeueCount = 0; for (int i = 0; i < _count; i++) { transport.Receive(receiveContext => { return context => { var moveContext = new MoveMessageSendContext(context); transport.Send(moveContext); text.BodyFormat("Message-Id: {0}", context.MessageId); requeueCount++; }; }, TimeSpan.Zero); } _log.Info(text); _log.InfoFormat("{0} message{1} requeued to {2}", requeueCount, requeueCount == 1 ? "" : "s", uri); return true; }
private static UIElement e_23_Col3_ct_dtMethod(UIElement parent) { // e_25 element StackPanel e_25 = new StackPanel(); e_25.Parent = parent; e_25.Name = "e_25"; // e_26 element TextBlock e_26 = new TextBlock(); e_25.Children.Add(e_26); e_26.Name = "e_26"; Binding binding_e_26_Text = new Binding("Text"); e_26.SetBinding(TextBlock.TextProperty, binding_e_26_Text); // e_27 element StackPanel e_27 = new StackPanel(); e_25.Children.Add(e_27); e_27.Name = "e_27"; e_27.Orientation = Orientation.Horizontal; // e_28 element TextBlock e_28 = new TextBlock(); e_27.Children.Add(e_28); e_28.Name = "e_28"; Binding binding_e_28_Text = new Binding("Boolean"); e_28.SetBinding(TextBlock.TextProperty, binding_e_28_Text); // e_29 element TextBlock e_29 = new TextBlock(); e_27.Children.Add(e_29); e_29.Name = "e_29"; Binding binding_e_29_Text = new Binding("Number"); e_29.SetBinding(TextBlock.TextProperty, binding_e_29_Text); return e_25; }
private void fachpicker_SelectionChanged(object sender, SelectionChangedEventArgs e) { Fach f = fachpicker.SelectedItem as Fach; if (f.lektion == Lektion.Anderes && f.customfach == null) { if (fächeradded) { } else { //benutzerdefiniertes Fach fächer = new TextBlock() { Text = "Fach: ", FontSize = 34, Margin = new Thickness(7,0,0,0) }; fächer.SetValue(Grid.RowProperty, 1); fächer2 = new TextBox(); fächer2.SetValue(Grid.RowProperty, 1); fächer2.SetValue(Grid.ColumnProperty, 1); ContentPanel.Children.Add(fächer); ContentPanel.Children.Add(fächer2); fächeradded = true; } } else { Lehrperson.Text = f.Lehrer; Farbe.SelectedIndex = f.color; if (fächeradded) { ContentPanel.Children.Remove(fächer); ContentPanel.Children.Remove(fächer2); fächeradded = false; } } }
private static UIElement e_28_Col3_ct_dtMethod(UIElement parent) { // e_30 element StackPanel e_30 = new StackPanel(); e_30.Parent = parent; e_30.Name = "e_30"; // e_31 element TextBlock e_31 = new TextBlock(); e_30.Children.Add(e_31); e_31.Name = "e_31"; Binding binding_e_31_Text = new Binding("Text"); e_31.SetBinding(TextBlock.TextProperty, binding_e_31_Text); // e_32 element StackPanel e_32 = new StackPanel(); e_30.Children.Add(e_32); e_32.Name = "e_32"; e_32.Orientation = Orientation.Horizontal; // e_33 element TextBlock e_33 = new TextBlock(); e_32.Children.Add(e_33); e_33.Name = "e_33"; Binding binding_e_33_Text = new Binding("Boolean"); e_33.SetBinding(TextBlock.TextProperty, binding_e_33_Text); // e_34 element TextBlock e_34 = new TextBlock(); e_32.Children.Add(e_34); e_34.Name = "e_34"; Binding binding_e_34_Text = new Binding("Number"); e_34.SetBinding(TextBlock.TextProperty, binding_e_34_Text); return e_30; }
private Grid BuildAddButton() { Grid g = new Grid(); g.Width = 120; g.Height = 120; g.Margin = new Thickness(0, 0, 10, 10); Rectangle r = new Rectangle(); r.Fill = new SolidColorBrush(Color.FromArgb(0x33, 0xFF, 0xFF, 0xFF)); g.Children.Add(r); TextBlock t = new TextBlock(); t.Text = "+"; t.VerticalAlignment = VerticalAlignment.Center; t.HorizontalAlignment = HorizontalAlignment.Center; t.TextAlignment = TextAlignment.Center; t.FontSize = 60; t.Margin = new Thickness(0, -15, 0, 0); g.Children.Add(t); Ellipse e = new Ellipse(); e.Stroke = new SolidColorBrush(Colors.White); e.Fill = new SolidColorBrush(Colors.Transparent); e.StrokeThickness = 3; e.Margin = new Thickness(30); g.Children.Add(e); return g; }
private void CreateAndShowMainWindow() { // Create the application's main window mainWindow = new Window(); // Create a canvas sized to fill the window canvas = new Canvas(); canvas.Background = Brushes.LightSteelBlue; // Add a "Hello World!" text element to the Canvas TextBlock txt = new TextBlock(); txt.FontSize = 30; txt.TextContent = "Hello World!"; Canvas.SetTop(txt, 100); Canvas.SetLeft(txt, 100); canvas.Children.Add(txt); Button btn = new Button(); btn.FontSize = 30; btn.Content = "Run Script"; btn.Click += new RoutedEventHandler(btn_Click); Canvas.SetTop(btn, 20); Canvas.SetLeft(btn, 100); canvas.Children.Add(btn); mainWindow.Content = canvas; mainWindow.Show(); }
// Load data for the ViewModel Items protected override void OnNavigatedTo(NavigationEventArgs e) { //removes back form, used for when navigating from Create NewList.xaml NavigationService.RemoveBackEntry(); if (!App.ViewModel.IsDataLoaded) { App.ViewModel.LoadData(); } //Runs everytime program loads, if (myGlobals.ListofItems.Count == 0) { } else { //Remove Past TextBlocks ListNamePanel.Children.Clear(); //Add TextBlocks to ListColumn // for (int x = 0; x < (myGlobals.ListofItems.Count); x++) foreach(KeyValuePair<string,List<ListObject>> list in myGlobals.ListofItems) { TextBlock ListColumn = new TextBlock(); { ListColumn.FontSize = 30; ListColumn.Name = list.Key.ToString(); ListColumn.Text = list.Key; }; ListNamePanel.Children.Add(ListColumn); ListColumn.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(HandleTap); } } }
private async void InitApartments() { var apartments = await App.MobileService.GetTable<Apartment>().Where(a => a.Published == true).ToListAsync(); listApartments.ItemsSource = apartments; mapApartments.Layers.Clear(); MapLayer layer = new MapLayer(); foreach (Apartment apartment in apartments) { MapOverlay overlay = new MapOverlay(); overlay.GeoCoordinate = new GeoCoordinate(apartment.Latitude, apartment.Longitude); overlay.PositionOrigin = new Point(0, 0); Grid grid = new Grid { Height = 40, Width = 25, Background = new SolidColorBrush(Colors.Red) }; TextBlock text = new TextBlock { Text = apartment.Bedrooms.ToString(), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; grid.Children.Add(text); overlay.Content = grid; grid.Tap += (s, e) => { MessageBox.Show( "Address: " + apartment.Address + Environment.NewLine + apartment.Bedrooms + " bedrooms", "Apartment", MessageBoxButton.OK); mapApartments.SetView(overlay.GeoCoordinate, 15, MapAnimationKind.Parabolic); }; layer.Add(overlay); } mapApartments.Layers.Add(layer); }
private async void pageItemDetail_Loaded(object sender, RoutedEventArgs e) { if (!carregada) { ItemDto item = await new ItemDto().SearchItemByIDAllData(Convert.ToInt16(NavigationContext.QueryString["id"])); imageItem.Source = await item.GetImage(); textBlockNameItem.Text = item.Name; textBlockGoldItem.Text = item.Gold.Total.ToString() + " gold"; textBlockItemEffect.Text = Code.HtmlRemoval.StripTagsCharArray(item.Description); ListBoxReceita.Items.Clear(); if (item.From != null) { foreach (string id in item.From) { ItemSelect itemSelect = new ItemSelect(); itemSelect.Item = await new ItemDto().SearchItemLowData(Convert.ToInt16(id)); itemSelect.Tap += ItemSelect_Tap; ListBoxReceita.Items.Add(itemSelect); } } else { TextBlock tb = new TextBlock(); tb.FontSize = 30; tb.Text = "Este item não possui receita."; ListBoxReceita.Items.Add(tb); } carregada = true; } }
public static string CreateTileBackground(this Project project) { Grid grid = new Grid(); Rectangle rect = new Rectangle(); rect.Width = 173; rect.Height = 173; rect.Fill = new SolidColorBrush(project.Color.ToColor()); TextBlock text = new TextBlock(); text.Text = "TASK"; text.Foreground = new SolidColorBrush(Colors.White); text.FontSize = 32; grid.Children.Add(rect); grid.Children.Add(text); grid.Arrange(new Rect(0d, 0d, 173d, 173d)); WriteableBitmap wbmp = new WriteableBitmap(grid, null); string tiledirectory = "tiles"; string fullPath = tiledirectory + @"/" + project.Name + ".jpg"; using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { if (!store.DirectoryExists(tiledirectory)) { store.CreateDirectory(tiledirectory); } using (var stream = store.OpenFile(fullPath, System.IO.FileMode.OpenOrCreate)) { wbmp.SaveJpeg(stream, 173, 173, 0, 100); } } return "isostore:/" + fullPath; }
private void buttonSearch_Click(object sender, RoutedEventArgs e) { StackPanel containingStackPanel = new StackPanel(); containingStackPanel.Margin = new Thickness(10, 0, 0, 20); int i = 0; foreach (RSSFeedItemDetail issue in App.ViewModel.DashboardModelView.GetIssuesBySearchTerm(SearchTerm.Text.Trim())) { i++; TextBlock textblockissueTitle = new TextBlock(); textblockissueTitle.Text = i.ToString() + " " + issue.Title; textblockissueTitle.TextWrapping = TextWrapping.Wrap; textblockissueTitle.Style = Resources["PhoneTextNormalStyle"] as Style; containingStackPanel.Children.Add(textblockissueTitle); TextBlock textblockissueDescription = new TextBlock(); textblockissueDescription.Text = issue.Description + "\n\n"; textblockissueDescription.TextWrapping = TextWrapping.Wrap; textblockissueDescription.Style = Resources["PhoneTextNormalStyle"] as Style; //textblockissuePubDate.Foreground = Resources["PhoneSubtleBrush"] as Brush; containingStackPanel.Children.Add(textblockissueDescription); } ScrollerViewerList.Content = containingStackPanel; }
public MarkdownList(bool numbered, IEnumerable<UIElement> elements) { InitializeComponent(); int number = 1; int rowCount = 0; foreach (var element in elements) { theGrid.RowDefinitions.Add(new RowDefinition()); var text = new TextBlock { TextWrapping = System.Windows.TextWrapping.Wrap, Margin = new Thickness(5, 0, 15, 0), Text = numbered ? (number++).ToString() + "." : "\u25CF" }; text.SetValue(Grid.RowProperty, rowCount); text.SetValue(Grid.ColumnProperty, 0); element.SetValue(Grid.RowProperty, rowCount++); element.SetValue(Grid.ColumnProperty, 1); if (element is RichTextBox) { element.SetValue(FrameworkElement.MarginProperty, new Thickness(-8, 0, 0, 0)); } else { element.SetValue(FrameworkElement.MarginProperty, new Thickness(4, 0, 0, 0)); } theGrid.Children.Add(text); theGrid.Children.Add(element); } }
public CategoryDetailPage() { InitializeComponent(); var textblock = new TextBlock { Text = "header 1", FontSize = 36 }; var pivotItem = new PivotItem() { Header = textblock }; var grid = new Grid(); var listBox = new ListBox() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Margin = new Thickness(0) }; for (int i = 0; i < 10; i++) { var newsTitle = new NewsTitleControl(); listBox.Items.Add(newsTitle); } grid.Children.Add(listBox); pivotItem.Content = grid; PivotContainer.Items.Add(pivotItem); var textblock2 = new TextBlock { Text = "header 2", FontSize = 36 }; var pivotItem2 = new PivotItem() { Header = textblock2 }; PivotContainer.Items.Add(pivotItem2); }
public void OnDisconnect() { Deployment.Current.Dispatcher.BeginInvoke(() => { Progress.Visibility = Visibility.Collapsed; if (_connection == null || !_connection._isConnectedFirstTime) { ContentPanel.Children.Clear(); TextBlock textBlock = new TextBlock() { Text = "Connection failed", Margin = new Thickness(10, 2, 10, 2), FontSize = 20 }; Button reconnect = new Button() { Content = "Reconnect" }; reconnect.BorderThickness = new Thickness(0); reconnect.Foreground = new SolidColorBrush(Colors.Black); reconnect.Background = new SolidColorBrush(Colors.LightGray); reconnect.Click += new RoutedEventHandler(Reconnect_Click); ContentPanel.Children.Add(textBlock); ContentPanel.Children.Add(reconnect); } }); }
void GetGroupTopicCompleted(object s, DoubanSearchCompletedEventArgs args) { App.GroupTopicViewModel.GetGroupTopicCompleted -= GetGroupTopicCompleted; Deployment.Current.Dispatcher.BeginInvoke(() => { base.SetProgressIndicator(false); if (args.IsSuccess) { contentContainer.Visibility = Visibility.Visible; contentContainer.IsEnabled = true; foreach (var content in App.GroupTopicViewModel.TopicContentList) { TextBlock tb = new TextBlock(); //tb.Width = 445; tb.TextWrapping = TextWrapping.Wrap; tb.Foreground = new SolidColorBrush(Colors.Black); tb.FontSize = (double)App.Current.Resources["PhoneFontSizeMedium"]; tb.Text = content; spContent.Children.Add(tb); } contentContainer.ScrollToVerticalOffset(0); } else { ToastPrompt toast = new ToastPrompt(); toast.Message = args.Message; toast.Show(); } } ); }
void LoadNations() { int LanguageIndex = edtContentLang.SelectedIndex; spNations.Children.Clear(); nations = MythDB.Instance.Database.Nations.ToList(); checkBoxes = new List<CheckBox>(); foreach (Nation n in nations) { StackPanel sp = new StackPanel(); sp.Orientation = System.Windows.Controls.Orientation.Horizontal; sp.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; sp.VerticalAlignment = System.Windows.VerticalAlignment.Center; TextBlock tb = new TextBlock(); tb.Text = "[" + n.I18nNations[LanguageIndex].ShortName + "] " + n.I18nNations[LanguageIndex].Name; tb.FontSize = 20; tb.Width = 350; tb.VerticalAlignment = System.Windows.VerticalAlignment.Center; sp.Children.Add(tb); CheckBox cb = new CheckBox(); cb.IsChecked = n.IsActive; cb.VerticalAlignment = System.Windows.VerticalAlignment.Center; sp.Children.Add(cb); checkBoxes.Add(cb); spNations.Children.Add(sp); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); // We are ready to retreive controls from the template this.listBox = this.GetTemplateChild("listBox") as ListBox; listBox.ItemsSource = ItemSource; this.titleTextBlock = this.GetTemplateChild("DialogTitle") as TextBlock; // Assign the values this.ItemSource = itemSource; this.Title = title; if (this.ItemSource != null) { SelectedIndex = selectedIndex; if (listBox.SelectedItem != null) listBox.SetVerticalScrollOffset(SelectedIndex); } listBox.Opacity = 0; // Hook up into listbox's events this.listBox.SelectionChanged += new SelectionChangedEventHandler(listBox_SelectionChanged); this.listBox.Loaded += new RoutedEventHandler(listBox_Loaded); this.listBox.SelectionMode = SelectionMode.Multiple; }
public static void SetupZoomableText(TextBlock zoomableText) { zoomableText.Text = @"<<MainPage.cs>> namespace SilverlightRunSample.VM { public class MainPage : SilverlightRun.ViewModel.ColdViewModel<MainPage> { [SilverlightRun.Tombstoning.SurvivesTombstoning] public string Word1 { get; set; } [SilverlightRun.Tombstoning.SurvivesRestart] public string Word2 { get; set; } public MainPage() { } } } <<ViewModelCenter.cs>> using SilverlightRun.DI; namespace SilverlightRunSample.VM { public class ViewModelCenter : SilverlightRun.PhoneSpecific.PhoneTypeCenter { protected override void ContainerSetup(GenericSimpleContainer container) { container.DeclareSingleton<VM.MainPage, VM.MainPage>(); } } } "; }
private void ShowBody(Note note) { this.body.Children.Clear(); foreach (NoteDetail dett in note.Body) { if (!string.IsNullOrEmpty(dett.Text)) { TextBlock block2 = new TextBlock { TextWrapping = TextWrapping.Wrap, FontSize = 40, Foreground = new SolidColorBrush(Colors.Black), Text = dett.Text }; TextBlock block = block2; this.body.Children.Add(block); } else if ((dett.ListPageDraw != null) && (dett.ListPageDraw.Count > 0)) { ShowDrawingsControl drawings2 = new ShowDrawingsControl { HorizontalAlignment = HorizontalAlignment.Stretch, DataSource = dett.ListPageDraw }; ShowDrawingsControl drawings = drawings2; this.body.Children.Add(drawings); } } }
// Load data from footfall manager private void AllRunsPage_Loaded(object sender, RoutedEventArgs e) { AllPastRuns.Children.Clear(); foreach (Activity activity in footfallManager.previousRuns) { StackPanel mainSP = new StackPanel() { Tag = activity, Orientation = System.Windows.Controls.Orientation.Horizontal, Margin = new Thickness(0, 0, 0, 12) }; mainSP.Tap += new EventHandler<GestureEventArgs>(ViewRun_Tap); Image i = new Image() { Height = 99, Source = (ImageSource)(new ImageSourceConverter().ConvertFromString("MapPics/Map1.png")) }; StackPanel sp = new StackPanel() { Width = 296, Margin = new Thickness(0, 0, 0, 0) }; TextBlock title = new TextBlock() { Text = activity.title, Style = (Style)App.Current.Resources["PhoneTextLargeStyle"], TextWrapping = TextWrapping.NoWrap }; TextBlock lineTwo = new TextBlock() { Text = activity.GetLineTwoText(), Style = (Style)App.Current.Resources["PhoneTextNormalStyle"], TextWrapping = TextWrapping.NoWrap }; TextBlock lineThree = new TextBlock() { Text = activity.GetLineThreeText(), Style = (Style)App.Current.Resources["PhoneTextNormalStyle"], TextWrapping = TextWrapping.NoWrap }; sp.Children.Add(title); sp.Children.Add(lineTwo); sp.Children.Add(lineThree); mainSP.Children.Add(i); mainSP.Children.Add(sp); AllPastRuns.Children.Add(mainSP); } }
private static UIElement r_11_dtMethod(UIElement parent) { // e_69 element Border e_69 = new Border(); e_69.Parent = parent; e_69.Name = "e_69"; e_69.Background = new SolidColorBrush(new ColorW(0, 0, 255, 255)); // e_70 element StackPanel e_70 = new StackPanel(); e_69.Child = e_70; e_70.Name = "e_70"; // e_71 element TextBlock e_71 = new TextBlock(); e_70.Children.Add(e_71); e_71.Name = "e_71"; e_71.HorizontalAlignment = HorizontalAlignment.Center; e_71.VerticalAlignment = VerticalAlignment.Center; Binding binding_e_71_Text = new Binding("TextData"); e_71.SetBinding(TextBlock.TextProperty, binding_e_71_Text); // e_72 element Button e_72 = new Button(); e_70.Children.Add(e_72); e_72.Name = "e_72"; e_72.Content = "Hide Window"; Binding binding_e_72_Command = new Binding("HideCommand"); e_72.SetBinding(Button.CommandProperty, binding_e_72_Command); return e_69; }
private async Task AddSubscriptionPanel(Subscription sub) { var channel = await sub.GetChannel(); _ = Dispatcher.InvokeAsync(() => { int row = SubscriptionsGrid.RowDefinitions.Count; RowDefinition rowDefinition = new RowDefinition { Height = GridLength.Auto, }; SubscriptionsGrid.RowDefinitions.Add(rowDefinition); Image logo = new Image { MaxWidth = 120, MaxHeight = 120, Width = 98, Height = 98, Margin = new Thickness(2), Source = new BitmapImage(new Uri(channel.LogoUrl)), VerticalAlignment = VerticalAlignment.Top }; Grid.SetColumn(logo, 0); Grid.SetRow(logo, row); SubscriptionsGrid.Children.Add(logo); TextBlock description = new TextBlock { Height = 40, Width = double.NaN, FontSize = 14, VerticalAlignment = VerticalAlignment.Top }; description.Inlines.Add(string.Concat(FindResource("PlaylistTitle"), channel.Title, "\n")); description.Inlines.Add(string.Concat(FindResource("LastVideoDownloadDate"), sub.LatestVideoDownloaded.ToLocalTime().ToShortDateString())); Grid.SetColumn(description, 1); Grid.SetRow(description, row); SubscriptionsGrid.Children.Add(description); StackPanel buttonsPanel = new StackPanel { VerticalAlignment = VerticalAlignment.Center }; Grid.SetColumn(buttonsPanel, 2); Grid.SetRow(buttonsPanel, row); SubscriptionsGrid.Children.Add(buttonsPanel); Tile settingsButton = new Tile { Height = double.NaN, Width = double.NaN, Margin = new Thickness(2.5), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }, removeButton = new Tile { Height = double.NaN, Width = double.NaN, Margin = new Thickness(2.5), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; removeButton.Click += (s, e) => { rowDefinition.Height = new GridLength(0); Subscriptions.Remove(Subscriptions.FirstOrDefault(x => x.ChannelId.Equals(sub.ChannelId))); }; settingsButton.Click += (s, e) => { GlobalConsts.LoadFlyoutPage(new SubscriptionSettings(sub)); }; buttonsPanel.Children.Add(settingsButton); buttonsPanel.Children.Add(removeButton); WrapPanel settingsButtonWrapPanel = new WrapPanel(), removeButtonWrapPanel = new WrapPanel(); //Settings button PackIconModern settingsButtonIcon = new PackIconModern { Kind = PackIconModernKind.Cogs, Width = 35, Height = 35, Margin = new Thickness(5) }; TextBlock settingsButtonTextBlock = new TextBlock { Text = $"{FindResource("Settings")}", VerticalAlignment = VerticalAlignment.Center, FontSize = 16, Margin = new Thickness(2.5, 5, 7.5, 5) }; settingsButtonWrapPanel.Children.Add(settingsButtonIcon); settingsButtonWrapPanel.Children.Add(settingsButtonTextBlock); settingsButton.Content = settingsButtonWrapPanel; //Remove button PackIconModern removeButtonIcon = new PackIconModern { Kind = PackIconModernKind.Close, Width = 35, Height = 35, Margin = new Thickness(5) }; TextBlock removeButtonTextBlock = new TextBlock { Text = $"{FindResource("Remove")}", VerticalAlignment = VerticalAlignment.Center, FontSize = 16, Margin = new Thickness(2.5, 5, 7.5, 5) }; removeButtonWrapPanel.Children.Add(removeButtonIcon); removeButtonWrapPanel.Children.Add(removeButtonTextBlock); removeButton.Content = removeButtonWrapPanel; GridScrollViewer.Height = GlobalConsts.Current.ActualHeight - 300; GridScrollViewer.UpdateLayout(); }); }
public static TextBlock AddInlines(this TextBlock text_block, String obj) { text_block.Inlines.Add(obj); return(text_block); }
protected override void OnApplyTemplate() { this.Presenter = GetTemplateChild(nameof(Presenter)) as TextBlock; reload(); }
private void SaveExelButton_Click(object sender, RoutedEventArgs e) { List <Items> wrList = (List <Items>)lessonGrid.ItemsSource; Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application(); excel.Visible = true; Microsoft.Office.Interop.Excel.Workbook workbook = excel.Workbooks.Add(System.Reflection.Missing.Value); Microsoft.Office.Interop.Excel.Worksheet sheet1 = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets[1]; for (int j = 0; j < lessonGrid.Columns.Count; j++) { Microsoft.Office.Interop.Excel.Range myRange = (Microsoft.Office.Interop.Excel.Range)sheet1.Cells[1, j + 1]; sheet1.Cells[1, j + 1].Font.Bold = true; sheet1.Columns[j + 1].ColumnWidth = 15; myRange.Value2 = lessonGrid.Columns[j].Header; } for (int i = 0; i < lessonGrid.Columns.Count; i++) { DateTime dt; ConcertEvent concEvent = new ConcertEvent(); LessonEvent lsnEvent = new LessonEvent(); if (i != 0 && i != lessonGrid.Columns.Count && i != lessonGrid.Columns.Count - 1) { dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, i); concEvent = new ConcertEvent(); if (concertRepository.IsExist(p => dt >= p.BeginningDate && dt <= p.EndDate)) { concEvent = concertRepository.GetListFromCache().Where(p => dt >= p.BeginningDate && dt <= p.EndDate).First(); } lsnEvent = lessonRepository.GetAllFromCache().Where(d => d.Date == dt).First(); } for (int j = 0; j < lessonGrid.Items.Count; j++) { int wrId = wrList[j].wrk.ID; DataGridRow r = lessonGrid.GetRow(j); TextBlock b = lessonGrid.Columns[i].GetCellContent(lessonGrid.Items[j]) as TextBlock; Microsoft.Office.Interop.Excel.Range myRange = (Microsoft.Office.Interop.Excel.Range)sheet1.Cells[j + 2, i + 1]; if (lessonMarkRepository.IsExist(p => p.LessonEventID == lsnEvent.ID && p.IsVisited == true && p.WorkerID == wrId)) { lessonGrid.GetCell(r, i).Background = new SolidColorBrush(Colors.Red); myRange.Value2 = 1.ToString(); } else if (concertMarkRepository.IsExist(p => p.ConcertEventID == concEvent.ID && p.WorkerID == wrId)) { lessonGrid.GetCell(r, i).Background = new SolidColorBrush(Colors.Green); double mark = concertMarkRepository.Get(p => p.ConcertEventID == concEvent.ID && p.WorkerID == wrId).First().NumOfMarks; TimeSpan d1 = concEvent.EndDate.Value - concEvent.BeginningDate.Value; myRange.Value2 = "(концерт)" + Math.Round((mark / (double)d1.Days), 2).ToString(); } else { myRange.Value2 = b.Text; } } } workbook.SaveAs("отчёт за " + DateTime.Now.Month + " месяц"); excel.Quit(); }
// this is a mess // this is manual wpf code, it basically just sets the options for the indivdual tools with some fancy linq expressions for changing values // most of these tools are instrinsicly named // it also updates the colours on what tool we are using private void interpretTooling() { pan_selector.Background = activeTool == 0 ? Brushes.LightGray : Brushes.DarkGray; shape_selector.Background = activeTool == 1 ? Brushes.LightGray : Brushes.DarkGray; line_selector.Background = activeTool == 2 ? Brushes.LightGray : Brushes.DarkGray; text_selector.Background = activeTool == 3 ? Brushes.LightGray : Brushes.DarkGray; transform_selector.Background = activeTool == 4 ? Brushes.LightGray : Brushes.DarkGray; tool_options_container.Children.RemoveRange(0, tool_options_container.Children.Count); if (activeTool == 1 || activeTool == 2) // line or shape { TextBlock strokeLabel = new TextBlock(); strokeLabel.Height = 24; strokeLabel.Text = "Stroke Thickness:"; strokeLabel.Margin = new Thickness(5, 5, 5, 5); tool_options_container.Children.Add(strokeLabel); ComboBox strokeSelector = new ComboBox(); strokeSelector.Height = 24; //shapeSelector.HorizontalAlignment = HorizontalAlignment.Left; strokeSelector.Items.Add(1f); strokeSelector.Items.Add(2f); strokeSelector.Items.Add(3f); strokeSelector.Items.Add(4f); strokeSelector.Items.Add(5f); strokeSelector.Items.Add(6f); strokeSelector.Items.Add(7f); strokeSelector.Items.Add(8f); strokeSelector.Items.Add(9f); strokeSelector.Items.Add(10f); strokeSelector.SelectedItem = screen.stroke_thickness; strokeSelector.SelectionChanged += (_o, _e) => screen.stroke_thickness = (float)strokeSelector.SelectedItem; tool_options_container.Children.Add(strokeSelector); } if (activeTool == 1) // shape { TextBlock shapeLabel = new TextBlock(); shapeLabel.Height = 24; shapeLabel.Text = "Shape:"; shapeLabel.Margin = new Thickness(5, 5, 5, 5); tool_options_container.Children.Add(shapeLabel); ComboBox shapeSelector = new ComboBox(); shapeSelector.Height = 24; //shapeSelector.HorizontalAlignment = HorizontalAlignment.Left; shapeSelector.Items.Add("box"); shapeSelector.Items.Add("ellipse"); shapeSelector.SelectedItem = current_shape; shapeSelector.SelectionChanged += (_o, _e) => current_shape = (string)shapeSelector.SelectedItem; tool_options_container.Children.Add(shapeSelector); CheckBox fillin_check = new CheckBox(); fillin_check.Margin = new Thickness(5, 5, 5, 5); //fillin_check.HorizontalAlignment = HorizontalAlignment.Left; fillin_check.Content = "fill in"; fillin_check.IsChecked = !screen.current_fill_in; fillin_check.Unchecked += (_o, _e) => screen.current_fill_in = true; fillin_check.Checked += (_o, _e) => screen.current_fill_in = false; tool_options_container.Children.Add(fillin_check); } if (activeTool == 3) // text { TextBlock sizeLabel = new TextBlock(); sizeLabel.Height = 24; sizeLabel.Text = "Font Size:"; sizeLabel.Margin = new Thickness(5, 5, 5, 5); tool_options_container.Children.Add(sizeLabel); ComboBox sizeSelector = new ComboBox(); sizeSelector.Height = 24; sizeSelector.Focusable = false; //shapeSelector.HorizontalAlignment = HorizontalAlignment.Left; sizeSelector.Items.Add(8f); sizeSelector.Items.Add(9f); sizeSelector.Items.Add(10f); sizeSelector.Items.Add(11f); sizeSelector.Items.Add(12f); sizeSelector.Items.Add(24f); sizeSelector.Items.Add(32f); sizeSelector.Items.Add(48f); sizeSelector.Items.Add(56f); sizeSelector.Items.Add(78f); sizeSelector.SelectedItem = screen.font_size; sizeSelector.SelectionChanged += (_o, _e) => screen.font_size = (float)sizeSelector.SelectedItem; tool_options_container.Children.Add(sizeSelector); } }
public TextBlockWriter(SynchronizationContext context, TextBlock text) { _context = context; _text = text; }
private UIElement GetMessage(DiscordMessage message) { bool bold = false; bool italic = false; bool underline = false; bool strike = false; var result = new Grid(); result.Children.Add(new Image { Source = FindUserAvatar(message.Author), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Width = 48, Height = 48 }); result.Children.Add(new Label { Content = GetMemberName(message.Channel.Guild.GetMemberAsync(message.Author.Id).Result), Margin = new Thickness(55, 10, 0, 0), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }); var content = new TextBlock { Margin = new Thickness(0, 55, 0, 25), TextWrapping = TextWrapping.Wrap, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; var currentLine = ""; Inline format(string text) { Inline res = new Run { Text = text }; if (underline) { res.TextDecorations.Add(TextDecorations.Underline); } if (bold) { res = new Bold(res); } if (strike) { res.TextDecorations.Add(TextDecorations.Strikethrough); } if (italic) { res = new Italic(res); } return(res); } for (int i = 0; i < message.Content.Length; i++) { char c = message.Content[i]; if (message.Content.Length > i + 2 && message.Content.Substring(i, 2) == "**") { content.Inlines.Add(format(currentLine)); currentLine = ""; bold = !bold; i++; } else if (message.Content.Length > i + 2 && message.Content.Substring(i, 2) == "__") { content.Inlines.Add(format(currentLine)); currentLine = ""; underline = !underline; i++; } else if (message.Content.Length > i + 2 && message.Content.Substring(i, 2) == "~~") { content.Inlines.Add(format(currentLine)); currentLine = ""; strike = !strike; i++; } else if (c == '*' || c == '_') { content.Inlines.Add(format(currentLine)); currentLine = ""; italic = !italic; } else if (c == '<') { content.Inlines.Add(format(currentLine)); currentLine = ""; if (message.Content.Length > i + 3 && message.Content[i..(i + 3)] == "<@!") { var id = ""; i += 3; while (message.Content[i] != '>') { id += message.Content[i++]; } content.Inlines.Add(new Run { Text = $"@{GetMemberName(currentChannel.Guild.GetMemberAsync(ulong.Parse(id)).Result)}", Foreground = new SolidColorBrush(Color.FromArgb(255, 20, 100, 255)) }); } else if (message.Content.Length > i + 3 && message.Content.Substring(i, 3) == "<@&") { var id = ""; i += 3; while (message.Content[i] != '>') { id += message.Content[i++]; } var role = currentChannel.Guild.GetRole(ulong.Parse(id)); content.Inlines.Add(new Run { Text = $"@{role.Name}", Foreground = new SolidColorBrush(Color.FromArgb(255, role.Color.R, role.Color.G, role.Color.B)) }); } else if (message.Content.Length > i + 2 && message.Content.Substring(i, 2) == "<:") { var emojicode = ""; i++; while (message.Content[i] != '>') { emojicode += message.Content[i++]; } var id = emojicode.Split(':').Last(); content.Inlines.Add(new InlineUIContainer { Child = new Image { Width = 32, Height = 32, Source = FindCustomEmoji(ulong.Parse(id)) } }); } else { currentLine += '<'; } }
private void Canvas_MouseUP(object sender, MouseButtonEventArgs e) { if (isDrawing) { switch (Instruments) { case 1: { Point lineEnd = e.GetPosition(myCanvas); Line l = new Line(); l.X1 = lineStartPoint.X; l.Y1 = lineStartPoint.Y; l.X2 = lineEnd.X; l.Y2 = lineEnd.Y; l.Stroke = brush; l.StrokeThickness = StrokeThickness; myCanvas.Children.Add(l); lineStartPoint = lineEnd; } break; case 3: { Point lineEnd = e.GetPosition(myCanvas); Rectangle l = new Rectangle(); Point hz = new Point(); if (lineEnd.X < lineStartPoint.X) { hz.X = lineEnd.X; } else { hz.X = lineStartPoint.X; } if (lineEnd.Y < lineStartPoint.Y) { hz.Y = lineEnd.Y; } else { hz.Y = lineStartPoint.Y; } l.Width = Math.Abs(lineEnd.X - lineStartPoint.X); l.Height = Math.Abs(lineEnd.Y - lineStartPoint.Y); l.Stroke = brush; l.StrokeThickness = StrokeThickness; l.Fill = background; Canvas.SetTop(l, hz.Y); Canvas.SetLeft(l, hz.X); myCanvas.Children.Add(l); lineStartPoint = lineEnd; } break; case 4: { Point lineEnd = e.GetPosition(myCanvas); Ellipse l = new Ellipse(); Point hz = new Point(); if (lineEnd.X < lineStartPoint.X) { hz.X = lineEnd.X; } else { hz.X = lineStartPoint.X; } if (lineEnd.Y < lineStartPoint.Y) { hz.Y = lineEnd.Y; } else { hz.Y = lineStartPoint.Y; } l.Width = Math.Abs(lineEnd.X - lineStartPoint.X); l.Height = Math.Abs(lineEnd.Y - lineStartPoint.Y); l.Stroke = brush; l.Fill = background; l.StrokeThickness = StrokeThickness; Canvas.SetTop(l, hz.Y); Canvas.SetLeft(l, hz.X); myCanvas.Children.Add(l); lineStartPoint = lineEnd; } break; case 6: { Point point = new Point(); point = e.GetPosition(myCanvas); TextBlock textBlock = new TextBlock(); textBlock.Text = textBox.Text; Canvas.SetLeft(textBlock, point.X); Canvas.SetTop(textBlock, point.Y); myCanvas.Children.Add(textBlock); } break; default: break; } } isDrawing = false; }
private void CreateAndShowMainWindow() { // Create the application's main window mainWindow = new Window(); mainWindow.Title = "PNG Imaging Sample"; ScrollViewer mySV = new ScrollViewer(); //<Snippet4> int width = 128; int height = 128; int stride = width; byte[] pixels = new byte[height * stride]; // Define the image palette BitmapPalette myPalette = BitmapPalettes.Halftone256; // Creates a new empty image with the pre-defined palette //<SnippetPngEncoder> //<Snippet2> BitmapSource image = BitmapSource.Create( width, height, 96, 96, PixelFormats.Indexed8, myPalette, pixels, stride); //</Snippet2> //<Snippet3> FileStream stream = new FileStream("new.png", FileMode.Create); PngBitmapEncoder encoder = new PngBitmapEncoder(); TextBlock myTextBlock = new TextBlock(); myTextBlock.Text = "Codec Author is: " + encoder.CodecInfo.Author.ToString(); encoder.Interlace = PngInterlaceOption.On; encoder.Frames.Add(BitmapFrame.Create(image)); encoder.Save(stream); //</Snippet3> //</SnippetPngEncoder> //</Snippet4> //<Snippet1> // Open a Stream and decode a PNG image Stream imageStreamSource = new FileStream("smiley.png", FileMode.Open, FileAccess.Read, FileShare.Read); PngBitmapDecoder decoder = new PngBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); BitmapSource bitmapSource = decoder.Frames[0]; // Draw the Image Image myImage = new Image(); myImage.Source = bitmapSource; myImage.Stretch = Stretch.None; myImage.Margin = new Thickness(20); //</Snippet1> //<Snippet5> // Open a Uri and decode a PNG image Uri myUri = new Uri("smiley.png", UriKind.RelativeOrAbsolute); PngBitmapDecoder decoder2 = new PngBitmapDecoder(myUri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); BitmapSource bitmapSource2 = decoder2.Frames[0]; // Draw the Image Image myImage2 = new Image(); myImage2.Source = bitmapSource2; myImage2.Stretch = Stretch.None; myImage2.Margin = new Thickness(20); //</Snippet5> // Define a StackPanel to host the decoded PNG images StackPanel myStackPanel = new StackPanel(); myStackPanel.Orientation = Orientation.Vertical; myStackPanel.VerticalAlignment = VerticalAlignment.Stretch; myStackPanel.HorizontalAlignment = HorizontalAlignment.Stretch; // Add the Image and TextBlock to the parent Grid myStackPanel.Children.Add(myImage); myStackPanel.Children.Add(myImage2); myStackPanel.Children.Add(myTextBlock); // Add the StackPanel as the Content of the Parent Window Object mySV.Content = myStackPanel; mainWindow.Content = mySV; mainWindow.Show(); }
private List <TextBlock> DoLineBreak(Paragraph paragraph, Formatter formatter, int width, int tolerance) { m_Paragraph = paragraph; m_TotalWidth = width; m_Tolerance = tolerance; m_Nodes = formatter.FormatParagraph(paragraph); m_Sum = new Sum(0, 0, 0); m_ActiveNodes.Clear(); m_ActiveNodes.AddLast(new BreakPoint(0, 0, 0, 0, 0, new Sum(0, 0, 0), null)); for (int index = 0; index < m_Nodes.Count; index++) { Node node = m_Nodes[index]; if (node.Type == NodeType.Box) { m_Sum.Width += node.Width; } else if (node.Type == NodeType.Glue) { if (index > 0 && m_Nodes[index - 1].Type == NodeType.Box) { MainLoop(index); } m_Sum.Width += node.Width; m_Sum.Stretch += ((GlueNode)node).Stretch; m_Sum.Shrink += ((GlueNode)node).Shrink; } else if (node.Type == NodeType.Penalty && ((PenaltyNode)node).Penalty != Infinity) { MainLoop(index); } } if (m_ActiveNodes.Count != 0) { LinkedListNode <BreakPoint> node = m_ActiveNodes.First; LinkedListNode <BreakPoint> tmp = null; while (node != null) { if (tmp == null || node.Value.Demerits < tmp.Value.Demerits) { tmp = node; } node = node.Next; } List <Break> breaks = new List <Break>(); while (tmp != null) { breaks.Add(new Break(tmp.Value.Position, tmp.Value.Ratio)); tmp = tmp.Value.Previous; } // breaks.Reverse(); int lineStart = 0; int y = 0; int x = 0; StringBuilder str = new StringBuilder(1000); List <TextBlock> textBlocks = new List <TextBlock>(); for (int i = breaks.Count - 2; i >= 0; i--) { int position = breaks[i].Position; float r = breaks[i].Ratio; for (int j = lineStart; j < m_Nodes.Count; j++) { if (m_Nodes[j].Type == NodeType.Box || (m_Nodes[j].Type == NodeType.Penalty && ((PenaltyNode)m_Nodes[j]).Penalty == -Infinity)) { lineStart = j; break; } } int height = 0; int baseline = 0; for (int nodeIndex = lineStart; nodeIndex <= position; nodeIndex++) { if (m_Nodes[nodeIndex].Type == NodeType.Box) { height = Math.Max(height, ((BoxNode)m_Nodes[nodeIndex]).Height); baseline = Math.Max(baseline, (int)((TextPart)((BoxNode)m_Nodes[nodeIndex]).Part).Font.FontMetrics.Baseline); } } Part part = ((BoxNode)m_Nodes[lineStart]).Part; int blockStart = lineStart; for (int nodeIndex = lineStart; nodeIndex <= position; nodeIndex++) { if ((m_Nodes[nodeIndex].Type == NodeType.Box && ((BoxNode)m_Nodes[nodeIndex]).Part != part) || nodeIndex == position) { TextBlock textBlock = new TextBlock(); textBlock.Part = part; str.Clear(); for (int k = blockStart; k < (nodeIndex - 1); k++) { if (m_Nodes[k].Type == NodeType.Glue) { if (m_Nodes[k].Width > 0) { str.Append(' '); } } else if (m_Nodes[k].Type == NodeType.Box) { str.Append(((BoxNode)m_Nodes[k]).Value); } } textBlock.Position = new Point(x, y + baseline - (int)((TextPart)part).Font.FontMetrics.Baseline); textBlock.Text = str.ToString(); textBlock.Size = new Size(formatter.MeasureText(((TextPart)part).Font, textBlock.Text).Width, height); x += textBlock.Size.Width; textBlocks.Add(textBlock); if (m_Nodes[nodeIndex].Type == NodeType.Box) { part = ((BoxNode)m_Nodes[nodeIndex]).Part; } blockStart = nodeIndex; } } x = 0; y += height; lineStart = position; } return(textBlocks); } return(null); }
public Grid calendarBuild(int Day, int Month, int Year) { Grid XXcalendar = new Grid(); DateTime CurrTime = DateTime.Now; String CurrDay = CurrTime.Day.ToString("d"); int day = Day; int month = Month; int year = Year; int DaysInMonth = DateTime.DaysInMonth(year, month); //lblDate.Content = CurrTime.ToString("dddddd d MMMMMMMM yyyy"); //lblDate.Content = CurrTime.ToString("dddddddd"); XXcalendar.Width = 611; XXcalendar.Height = 477; XXcalendar.HorizontalAlignment = HorizontalAlignment.Center; XXcalendar.VerticalAlignment = VerticalAlignment.Center; XXcalendar.ShowGridLines = true; // Define the Columns ColumnDefinition colDef1 = new ColumnDefinition(); ColumnDefinition colDef2 = new ColumnDefinition(); ColumnDefinition colDef3 = new ColumnDefinition(); ColumnDefinition colDef4 = new ColumnDefinition(); ColumnDefinition colDef5 = new ColumnDefinition(); ColumnDefinition colDef6 = new ColumnDefinition(); ColumnDefinition colDef7 = new ColumnDefinition(); XXcalendar.ColumnDefinitions.Add(colDef1); XXcalendar.ColumnDefinitions.Add(colDef2); XXcalendar.ColumnDefinitions.Add(colDef3); XXcalendar.ColumnDefinitions.Add(colDef4); XXcalendar.ColumnDefinitions.Add(colDef5); XXcalendar.ColumnDefinitions.Add(colDef6); XXcalendar.ColumnDefinitions.Add(colDef7); // Define the Rows RowDefinition rowDef1 = new RowDefinition(); RowDefinition rowDef2 = new RowDefinition(); RowDefinition rowDef3 = new RowDefinition(); RowDefinition rowDef4 = new RowDefinition(); RowDefinition rowDef5 = new RowDefinition(); XXcalendar.RowDefinitions.Add(rowDef1); XXcalendar.RowDefinitions.Add(rowDef2); XXcalendar.RowDefinitions.Add(rowDef3); XXcalendar.RowDefinitions.Add(rowDef4); XXcalendar.RowDefinitions.Add(rowDef5); int row = 0; int col = 0; Brush brushRed = new SolidColorBrush(Colors.Red); Brush brushGreen = new SolidColorBrush(Colors.Green); Brush brushBlue = new SolidColorBrush(Colors.LightSteelBlue); Brush brushOtherRed = new SolidColorBrush(Colors.Maroon); for (int i = 1; i <= DaysInMonth; i++) { TextBlock txt = new TextBlock(); DateTime CurrentDay = new DateTime(year, month, i); txt.Text = "Dag: " + i + " "; txt.Text += CurrentDay.ToString("ddddd"); txt.FontSize = 10; txt.Background = brushBlue; Grid.SetColumn(txt, col); Grid.SetRow(txt, row); col++; switch (CurrentDay.ToString("dddddd")) { case "lørdag": txt.Background = brushOtherRed; break; case "søndag": txt.Background = brushRed; break; default: txt.Background = brushBlue; break; } switch (i) { case 0: row = 0; col = 0; break; case 7: Grid.SetRow(txt, 0); row = 1; col = 0; break; case 14: Grid.SetRow(txt, 1); row = 2; col = 0; break; case 21: Grid.SetRow(txt, 2); row = 3; col = 0; break; case 28: Grid.SetRow(txt, 3); row = 4; col = 0; break; } if (day == i) { txt.Background = brushGreen; } XXcalendar.Children.Add(txt); } return(XXcalendar); //CalendarPanel.Children.Add(XXcalendar); }
private void ChildWindow_Loaded(object sender, RoutedEventArgs e) { int lCount = 0; Grid lPage = null; int lPageNumber = 1; int lTotalPage = m_ReportParame.Values.Count / 28 + 1; foreach (List <String> lValues in m_ReportParame.Values) { if (lCount == 0) { Border lPageBorder = new Border(); lPageBorder.Margin = new System.Windows.Thickness(15, 15, 15, 0); lPageBorder.BorderThickness = new System.Windows.Thickness(1, 1, 1, 1); lPageBorder.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); lPageBorder.Background = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)); Grid lPagePointer = new Grid(); Grid lPageContion = new Grid(); lPageContion.HorizontalAlignment = HorizontalAlignment.Center; lPageContion.Margin = new System.Windows.Thickness(35, 30, 35, 0); lPageBorder.Child = lPagePointer; //lPageContion.HorizontalAlignment = HorizontalAlignment.Stretch; lPagePointer.Children.Add(lPageContion); RowDefinition lHeader = new RowDefinition(); lPageContion.RowDefinitions.Add(lHeader); RowDefinition lContext = new RowDefinition(); //lContext.MinHeight = 650; lPageContion.RowDefinitions.Add(lContext); RowDefinition lFooder = new RowDefinition(); lPageContion.RowDefinitions.Add(lFooder); Border lHeaderBorder = new Border(); lHeaderBorder.BorderThickness = new System.Windows.Thickness(0, 0, 0, 1); lHeaderBorder.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); StackPanel lStackPanel = new StackPanel(); lStackPanel.Orientation = Orientation.Vertical; TextBlock lHeaderText = new TextBlock(); lHeaderText.Text = m_ReportParame.ReportTitle; lHeaderText.HorizontalAlignment = HorizontalAlignment.Center; lHeaderText.FontSize = 21; //lHeaderText.SetValue(TextBlock.FontWeightProperty, "Bold"); lHeaderText.Margin = new System.Windows.Thickness(0, 10, 0, 15); lHeaderText.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); //lHeaderBorder.Child = lHeaderText; lStackPanel.Children.Add(lHeaderText); TextBlock lHeaderTextName = new TextBlock(); lHeaderTextName.Text = "制表人:" + m_Name + " 日期:" + DateTime.Now.ToShortDateString(); lHeaderTextName.HorizontalAlignment = HorizontalAlignment.Center; //lHeaderTextName.FontSize = 21; lHeaderTextName.Margin = new System.Windows.Thickness(0, 10, 0, 10); lHeaderTextName.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); lStackPanel.Children.Add(lHeaderTextName); Border lFooderBorder = new Border(); lFooderBorder.BorderThickness = new System.Windows.Thickness(0, 1, 0, 0); lFooderBorder.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); TextBlock lFooderText = new TextBlock(); lFooderText.Text = "- 第 " + lPageNumber + " 页,共 " + lTotalPage + " 页 -"; lFooderText.Margin = new System.Windows.Thickness(0, 10, 0, 10); lFooderText.HorizontalAlignment = HorizontalAlignment.Center; lFooderText.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); //lFooderBorder.Child = lFooderText; lPageContion.Children.Add(lStackPanel); lHeaderText.SetValue(Grid.RowProperty, 0); lPageContion.Children.Add(lFooderText); lFooderText.SetValue(Grid.RowProperty, 2); Border lPageContextBorder = new Border(); lPageContextBorder.BorderThickness = new System.Windows.Thickness(1, 1, 1, 1); lPageContextBorder.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); lPageContextBorder.VerticalAlignment = VerticalAlignment.Top; //lPageContextBorder.Margin = new System.Windows.Thickness(0, 5, 0, 0); lPage = new Grid(); lPage.Margin = new System.Windows.Thickness(0, 0, 0, 0); lPage.VerticalAlignment = VerticalAlignment.Top; //for (int i = 0; i < m_ReportParame.Title.Count(); i++) foreach (int lWidth in m_ReportParame.TitleWidth) { ColumnDefinition lColumnDefinition = new ColumnDefinition(); lColumnDefinition.MinWidth = lWidth; lPage.ColumnDefinitions.Add(lColumnDefinition); } //{ // ColumnDefinition lColumnDefinition = new ColumnDefinition(); // lPage.ColumnDefinitions.Add(lColumnDefinition); //} lPageContextBorder.Child = lPage; lPageContion.Children.Add(lPageContextBorder); lPageContextBorder.SetValue(Grid.RowProperty, 1); //define header RowDefinition lHeaderRow = new RowDefinition(); lPage.RowDefinitions.Add(lHeaderRow); int lIndex = 0; foreach (String lName in m_ReportParame.Title) { Border lHeaderTextBorder0 = new Border(); if (lIndex < m_ReportParame.Title.Count() - 1) { lHeaderTextBorder0.BorderThickness = new System.Windows.Thickness(0, 0, 1, 0); } else { lHeaderTextBorder0.BorderThickness = new System.Windows.Thickness(0, 0, 0, 0); } //lHeaderTextBorder0.BorderThickness = new System.Windows.Thickness(1, 1, 1, 1); lHeaderTextBorder0.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); lHeaderTextBorder0.Background = new SolidColorBrush(Color.FromArgb(255, 230, 230, 230)); TextBlock lHeaderText0 = new TextBlock(); lHeaderText0.Text = lName; lHeaderText0.FontSize = 14; lHeaderText0.HorizontalAlignment = HorizontalAlignment.Center; lHeaderText0.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); lHeaderText0.Margin = new System.Windows.Thickness(5, 2, 0, 2); lHeaderTextBorder0.Child = lHeaderText0; lPage.Children.Add(lHeaderTextBorder0); lHeaderTextBorder0.SetValue(Grid.RowProperty, 0); lHeaderTextBorder0.SetValue(Grid.ColumnProperty, lIndex); lIndex++; } PintConter.Children.Add(lPageBorder); lPageNumber++; m_PageList.Add(lPagePointer); } lCount++; RowDefinition lValueRow = new RowDefinition(); lPage.RowDefinitions.Add(lValueRow); int lColIndex = 0; foreach (String lName in lValues) { Border lHeaderTextBorder0 = new Border(); if (lColIndex < lValues.Count() - 1) { lHeaderTextBorder0.BorderThickness = new System.Windows.Thickness(0, 1, 1, 0); } else { lHeaderTextBorder0.BorderThickness = new System.Windows.Thickness(0, 1, 0, 0); } //lHeaderTextBorder0.BorderThickness = new System.Windows.Thickness(1, 1, 1, 1); lHeaderTextBorder0.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); TextBlock lHeaderText0 = new TextBlock(); lHeaderText0.Text = lName; lHeaderText0.Margin = new System.Windows.Thickness(5, 2, 0, 2); lHeaderText0.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); lHeaderTextBorder0.Child = lHeaderText0; lPage.Children.Add(lHeaderTextBorder0); lHeaderTextBorder0.SetValue(Grid.RowProperty, lCount); lHeaderTextBorder0.SetValue(Grid.ColumnProperty, lColIndex); lColIndex++; } if (lCount == 28) { lCount = 0; } } }
private static void FillFifthLine(STabCard sTabCard) { #region Основная панель var FifthDockPanel = new DockPanel { Margin = new Thickness(5, 0, 5, 10) }; sTabCard.DockPanels.Add(CardViewStruct.FifthDockPanel, FifthDockPanel); sTabCard.StackPanels[CardViewStruct.MainStackPanel].Children.Add(FifthDockPanel); #endregion #region Контрол Файлы //Border файл var FilesBorder = new Border { CornerRadius = new CornerRadius(6), BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(2), HorizontalAlignment = HorizontalAlignment.Left }; sTabCard.Borders.Add(CardViewStruct.FilesBorder, FilesBorder); sTabCard.DockPanels[CardViewStruct.FifthDockPanel].Children.Add(FilesBorder); //Вспомогательная панель даты var FileStackPanel = new StackPanel(); sTabCard.StackPanels.Add(CardViewStruct.FileStackPanel, FileStackPanel); sTabCard.Borders[CardViewStruct.FilesBorder].Child = FileStackPanel; //Текстовый блок var FileTextBlock = new TextBlock { Text = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_Files"), VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, HorizontalAlignment = HorizontalAlignment.Left, Width = 75, FontSize = 14, Margin = new Thickness(5, 0, 0, 0) }; sTabCard.TextBlocks.Add(CardViewStruct.FileTextBlock, FileTextBlock); sTabCard.StackPanels[CardViewStruct.FileStackPanel].Children.Add(FileTextBlock); //Лист view var FileListView = new ListView() { Height = 120, MinWidth = 300, MaxWidth = 400, Margin = new Thickness(5) }; sTabCard.ListViews.Add(CardViewStruct.FileListView, FileListView); sTabCard.StackPanels[CardViewStruct.FileStackPanel].Children.Add(FileListView); //Файлы if (sTabCard.Card.Files.HasValue) { foreach (var item in sTabCard.Card.Files.FileDic) { var temp = new FileControl { ID = item.Key, DockPanel = new DockPanel(), Button = new Button { FontSize = 14, Margin = new Thickness(0, 0, 5, 0), Content = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_Delete"), IsEnabled = (sTabCard.Card.Task.StateID == new Guid("6a52791d-7e42-42d6-a521-4252f276bb6c") && !sTabCard.Card.Task.isEditingNow) }, TextBlock = new TextBlock { FontSize = 14, VerticalAlignment = VerticalAlignment.Center, Text = item.Value } }; temp.Button.Click += (sender, args) => { MessageBoxResult dialogResult = MessageBox.Show((string)SystemSingleton.Configuration.mainWindow.FindResource("m_MakeSureDeletingFile"), (string)SystemSingleton.Configuration.mainWindow.FindResource("m_AttentionHeader"), MessageBoxButton.YesNo); if (dialogResult == MessageBoxResult.Yes) { sTabCard.ListViews[CardViewStruct.FileListView].Items.Remove(sTabCard.Card.FilesControls[item.Key].DockPanel); sTabCard.FileDelete(item.Key); } }; temp.TextBlock.MouseLeftButtonDown += (sender, args) => { try { Process.Start(SystemSingleton.Configuration.FilesPath + item.Key + "\\" + item.Value); } catch { EnvironmentHelper.SendDialogBox((string)SystemSingleton.Configuration.mainWindow.FindResource("m_FileNotFoundInDirectory"), "Directory Error"); } }; sTabCard.Card.FilesControls.Add(item.Key, temp); temp.DockPanel.Children.Add(temp.Button); temp.DockPanel.Children.Add(temp.TextBlock); sTabCard.ListViews[CardViewStruct.FileListView].Items.Add(temp.DockPanel); } } if (sTabCard.Card.Task.StateID == new Guid("6a52791d-7e42-42d6-a521-4252f276bb6c") && !sTabCard.Card.Task.isEditingNow) { //Кнопка добавить var FileButton = new Button { Content = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_AddFile"), HorizontalAlignment = HorizontalAlignment.Left, Width = 145, Height = 25, FontSize = 14, Margin = new Thickness(5) }; FileButton.Click += (senderadd, argsadd) => { var dlg = new OpenFileDialog(); dlg.FileName = "Document"; dlg.DefaultExt = ".pdf"; dlg.Filter = "PDF documents (.pdf)|*.pdf"; dlg.Multiselect = false; var result = dlg.ShowDialog(); if (result != null && result.Value) { FileBase newFile = new FileBase(dlg.SafeFileName, dlg.FileName, Guid.NewGuid()); var filename = newFile.Name; var temp = new FileControl { ID = newFile.FileID, DockPanel = new DockPanel(), Button = new Button { FontSize = 14, Margin = new Thickness(0, 0, 5, 0), Content = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_Delete"), IsEnabled = true }, TextBlock = new TextBlock { FontSize = 14, VerticalAlignment = VerticalAlignment.Center, Text = filename } }; temp.Button.Click += (sender, args) => { MessageBoxResult dialogResult = MessageBox.Show((string)SystemSingleton.Configuration.mainWindow.FindResource("m_MakeSureDeletingFile"), (string)SystemSingleton.Configuration.mainWindow.FindResource("m_AttentionHeader"), MessageBoxButton.YesNo); if (dialogResult == MessageBoxResult.Yes) { sTabCard.ListViews[CardViewStruct.FileListView].Items.Remove(sTabCard.NewFileControls[newFile.FileID].DockPanel); sTabCard.FileDelete(newFile.FileID); } }; temp.TextBlock.MouseLeftButtonDown += (sender, args) => { try { Process.Start(SystemSingleton.Configuration.FilesPath + temp.ID.Value + "\\" + filename); } catch { EnvironmentHelper.SendDialogBox((string)SystemSingleton.Configuration.mainWindow.FindResource("m_FileNotFoundInDirectory"), "Directory Error"); } }; sTabCard.FileAdded(newFile); sTabCard.NewFileControls.Add(temp.ID.Value, temp); temp.DockPanel.Children.Add(temp.Button); temp.DockPanel.Children.Add(temp.TextBlock); sTabCard.ListViews[CardViewStruct.FileListView].Items.Add(temp.DockPanel); } }; sTabCard.Buttons.Add(CardViewStruct.FileButton, FileButton); sTabCard.StackPanels[CardViewStruct.FileStackPanel].Children.Add(FileButton); } #endregion #region Контрол информации о выполнении if (sTabCard.Card.Task.CompletedByID.HasValue) { //Border инфо var CompletedBorder = new Border { CornerRadius = new CornerRadius(6), BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(2), HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(10, 0, 10, 0), VerticalAlignment = VerticalAlignment.Bottom }; sTabCard.Borders.Add(CardViewStruct.CompletedBorder, CompletedBorder); sTabCard.DockPanels[CardViewStruct.FifthDockPanel].Children.Add(CompletedBorder); //Вспомогательная панель var CompletedStackPanel = new StackPanel(); sTabCard.StackPanels.Add(CardViewStruct.CompletedStackPanel, CompletedStackPanel); sTabCard.Borders[CardViewStruct.CompletedBorder].Child = CompletedStackPanel; //Вспомогательная панель var CompleteDateDockPanel = new DockPanel(); sTabCard.DockPanels.Add(CardViewStruct.CompleteDateDockPanel, CompleteDateDockPanel); sTabCard.StackPanels[CardViewStruct.CompletedStackPanel].Children.Add(CompleteDateDockPanel); //Текстовый блок Дата выполнения var CompletedDateTextBlock = new TextBlock { Text = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_CompletedDate"), VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, Width = 125, FontSize = 14, Margin = new Thickness(5, 0, 0, 0) }; sTabCard.TextBlocks.Add(CardViewStruct.CompletedDateTextBlock, CompletedDateTextBlock); sTabCard.DockPanels[CardViewStruct.CompleteDateDockPanel].Children.Add(CompletedDateTextBlock); //Контрол блока даты выполнения var CompletedDateTextBox = new TextBox { Text = sTabCard.Card.Task.CompletedDate.Value.ToString("G"), VerticalContentAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, MinWidth = 100, MaxWidth = 200, FontSize = 14, Height = 40, IsReadOnly = true }; sTabCard.TextBoxes.Add(CardViewStruct.CompletedDateTextBox, CompletedDateTextBox); sTabCard.DockPanels[CardViewStruct.CompleteDateDockPanel].Children.Add(CompletedDateTextBox); //Вспомогательная панель var CompleteByDockPanel = new DockPanel(); sTabCard.DockPanels.Add(CardViewStruct.CompleteByDockPanel, CompleteByDockPanel); sTabCard.StackPanels[CardViewStruct.CompletedStackPanel].Children.Add(CompleteByDockPanel); //Текстовый блок Дата выполнения var CompletedByTextBlock = new TextBlock { Text = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_CompletedBy"), VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, Width = 125, FontSize = 14, Margin = new Thickness(5, 0, 0, 0) }; sTabCard.TextBlocks.Add(CardViewStruct.CompletedByTextBlock, CompletedByTextBlock); sTabCard.DockPanels[CardViewStruct.CompleteByDockPanel].Children.Add(CompletedByTextBlock); //Контрол блока даты выполнения var CompletedByTextBox = new TextBox { Text = sTabCard.Card.CompletedBy.FullName, VerticalContentAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, MinWidth = 100, MaxWidth = 200, FontSize = 14, Height = 40, IsReadOnly = true }; sTabCard.TextBoxes.Add(CardViewStruct.CompletedByTextBox, CompletedByTextBox); sTabCard.DockPanels[CardViewStruct.CompleteByDockPanel].Children.Add(CompletedByTextBox); } #endregion #region Контрол кнопок //Border var ButtonsBorder = new Border { CornerRadius = new CornerRadius(6), BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(2), HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(10, 0, 0, 0), VerticalAlignment = VerticalAlignment.Bottom }; sTabCard.Borders.Add(CardViewStruct.ButtonsBorder, ButtonsBorder); sTabCard.DockPanels[CardViewStruct.FifthDockPanel].Children.Add(ButtonsBorder); //Вспомогательная панель var ButtonsStackPanel = new StackPanel(); sTabCard.StackPanels.Add(CardViewStruct.ButtonsStackPanel, ButtonsStackPanel); sTabCard.Borders[CardViewStruct.ButtonsBorder].Child = ButtonsStackPanel; if (sTabCard.Card.State.ID.Value == new Guid("6a52791d-7e42-42d6-a521-4252f276bb6c") && !sTabCard.Card.Task.isEditingNow) { //Кнопка сохранить var ButtonsSaveButton = new Button { Content = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_SaveCard"), Width = 145, Height = 25, FontSize = 14, Margin = new Thickness(5) }; ButtonsSaveButton.Click += (sender, args) => { sTabCard.SaveUpdatedCard(); }; sTabCard.Buttons.Add(CardViewStruct.ButtonsSaveButton, ButtonsSaveButton); sTabCard.StackPanels[CardViewStruct.ButtonsStackPanel].Children.Add(ButtonsSaveButton); } else { foreach (Role item in SystemSingleton.CurrentSession.UserRoles) { if (item.ID == new Guid("9efcd5cd-bf54-47f3-95e3-2953cb235941") && (sTabCard.Card.Task.ToRoleID != SystemSingleton.CurrentSession.ID || new PersonalRole(SystemSingleton.CurrentSession.ID).isAdmin) && !sTabCard.Card.Task.isEditingNow) { //Кнопка delete var ButtonsDeleteButton = new Button { Content = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_DeleteCard"), Width = 145, Height = 25, FontSize = 14, Margin = new Thickness(5) }; ButtonsDeleteButton.Click += (sender, args) => { var dialogResult = MessageBox.Show((string)SystemSingleton.Configuration.mainWindow.FindResource("m_DeleteTaskQ"), (string)SystemSingleton.Configuration.mainWindow.FindResource("m_AttentionHeader"), MessageBoxButton.YesNo); if (dialogResult == MessageBoxResult.Yes) { try { using (var con = new SqlConnection(SystemSingleton.Configuration.ConnectionString)) { SystemSingleton.Configuration.SqlConnections.Add(con); using (var command = new SqlCommand(SqlCommands.DeleteTaskAndStaff, con)) { command.Parameters.Add("@TaskID", SqlDbType.UniqueIdentifier); command.Parameters["@TaskID"].Value = sTabCard.Card.Task.ID.Value; EnvironmentHelper.SendLogSQL(command.CommandText); con.Open(); int colms = command.ExecuteNonQuery(); con.Close(); if (colms == 0) { EnvironmentHelper.SendDialogBox( (string)SystemSingleton.Configuration.mainWindow.FindResource( "m_CantDeleteTask") + "\n\n" + sTabCard.Card.Task.ID.Value.ToString(), "SQL Error" ); } } } foreach (var fileID in sTabCard.Card.Files.FileDic.Keys) { sTabCard.RemoveFileFromHardLite(fileID); } } catch (Exception ex) { EnvironmentHelper.SendErrorDialogBox(ex.Message, "SQL Error", ex.StackTrace); } SystemSingleton.Configuration.tabControl.Items.Remove(sTabCard.TabItem); SystemSingleton.CurrentSession.TabCards.Remove(sTabCard.Card.Task.Number); EnvironmentHelper.UpdateView(); } }; sTabCard.Buttons.Add(CardViewStruct.ButtonsDeleteButton, ButtonsDeleteButton); sTabCard.StackPanels[CardViewStruct.ButtonsStackPanel].Children.Add(ButtonsDeleteButton); break; } } } //Кнопка закрыть var ButtonsCloseButton = new Button { Content = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_CloseCard"), Width = 145, Height = 25, FontSize = 14, Margin = new Thickness(5) }; ButtonsCloseButton.Click += (sender, args) => { MessageBoxResult dialogResult = MessageBoxResult.No; if (sTabCard.ChangesFile || sTabCard.ChangesRespond || sTabCard.ChangesState) { dialogResult = MessageBox.Show((string)SystemSingleton.Configuration.mainWindow.FindResource("m_MakeSureClosingCard"), (string)SystemSingleton.Configuration.mainWindow.FindResource("m_AttentionHeader"), MessageBoxButton.YesNo); } if (dialogResult == MessageBoxResult.Yes || (!sTabCard.ChangesFile && !sTabCard.ChangesRespond && !sTabCard.ChangesState)) { SystemSingleton.Configuration.tabControl.Items.Remove(sTabCard.TabItem); SystemSingleton.CurrentSession.TabCards.Remove(sTabCard.Card.Task.Number); } if (!sTabCard.Card.Task.isEditingNow && sTabCard.Card.Task.StateID == new Guid("6a52791d-7e42-42d6-a521-4252f276bb6c")) { try { using (var con = new SqlConnection(SystemSingleton.Configuration.ConnectionString)) { SystemSingleton.Configuration.SqlConnections.Add(con); using (var command = new SqlCommand(SqlCommands.SetStopEditingToTask, con)) { command.Parameters.Add("@TaskID", SqlDbType.UniqueIdentifier); command.Parameters["@TaskID"].Value = sTabCard.Card.Task.ID.Value; EnvironmentHelper.SendLogSQL(command.CommandText); con.Open(); int colms = command.ExecuteNonQuery(); con.Close(); if (colms == 0) { EnvironmentHelper.SendDialogBox( (string)SystemSingleton.Configuration.mainWindow.FindResource( "m_CantSetEditing") + "\n\n" + sTabCard.Card.Task.ID.Value.ToString(), "SQL Error" ); } } } } catch (Exception ex) { EnvironmentHelper.SendErrorDialogBox(ex.Message, "SQL Error", ex.StackTrace); } } }; sTabCard.Buttons.Add(CardViewStruct.ButtonsCloseButton, ButtonsCloseButton); sTabCard.StackPanels[CardViewStruct.ButtonsStackPanel].Children.Add(ButtonsCloseButton); #endregion }
public TextBlockWithDataItemControlTypeAutomationPeer(TextBlock owner) : base(owner) { }
public object GetView(string extension, Stream stream) { string tempFile = Path.GetTempFileName(); using (FileStream fileStream = File.OpenWrite(tempFile)) { stream.CopyTo(fileStream); } try { IDictionary <string, string> assemblyData = RemoteCodeExecutor.GetAssemblyMetadata(tempFile); var grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); if (assemblyData != null) { foreach (var data in assemblyData.OrderBy(d => d.Key)) { var label = new TextBlock { Text = data.Key + ':', FontWeight = FontWeights.SemiBold, Margin = new Thickness(3, 3, 10, 0) }; Grid.SetRow(label, grid.RowDefinitions.Count); Grid.SetColumn(label, 0); var value = new TextBlock { Text = data.Value, Margin = new Thickness(0, 3, 3, 0) }; Grid.SetRow(value, grid.RowDefinitions.Count); Grid.SetColumn(value, 1); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grid.Children.Add(label); grid.Children.Add(value); } } return(grid); } finally { if (File.Exists(tempFile)) { try { File.Delete(tempFile); } catch { } } } }
private static void FillFirstLine(STabCard sTabCard) { #region Основная панель var FirstLineDockPanel = new DockPanel { Margin = new Thickness(5, 0, 5, 10) }; sTabCard.DockPanels.Add(CardViewStruct.FirstLineDockPanel, FirstLineDockPanel); sTabCard.StackPanels[CardViewStruct.MainStackPanel].Children.Add(FirstLineDockPanel); #endregion #region Контрол даты //Border data var CreatedDateBorder = new Border { CornerRadius = new CornerRadius(6), BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(2), Margin = new Thickness(0, 0, 5, 0), HorizontalAlignment = HorizontalAlignment.Left }; sTabCard.Borders.Add(CardViewStruct.CreatedDateBorder, CreatedDateBorder); sTabCard.DockPanels[CardViewStruct.FirstLineDockPanel].Children.Add(CreatedDateBorder); //Вспомогательная панель даты var CreatedDateDockPanel = new DockPanel(); sTabCard.DockPanels.Add(CardViewStruct.CreatedDateDockPanel, CreatedDateDockPanel); sTabCard.Borders[CardViewStruct.CreatedDateBorder].Child = CreatedDateDockPanel; //Текстовый блок Дата var CreatedDateTextBlock = new TextBlock { Text = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_CreationDate"), VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, Width = 100, FontSize = 14, Margin = new Thickness(5, 0, 0, 0) }; sTabCard.TextBlocks.Add(CardViewStruct.CreatedDateTextBlock, CreatedDateTextBlock); sTabCard.DockPanels[CardViewStruct.CreatedDateDockPanel].Children.Add(CreatedDateTextBlock); //Контрол блока даты var CreatedDateTextBox = new TextBox { Text = sTabCard.Card.Task.Date.ToString("G"), VerticalContentAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, MinWidth = 100, MaxWidth = 200, FontSize = 14, Height = 40, IsReadOnly = true }; sTabCard.TextBoxes.Add(CardViewStruct.CreatedDateTextBox, CreatedDateTextBox); sTabCard.DockPanels[CardViewStruct.CreatedDateDockPanel].Children.Add(CreatedDateTextBox); #endregion #region Контрол типа документа //Border DocType var DocTypeBorder = new Border { CornerRadius = new CornerRadius(6), BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(2), Margin = new Thickness(5, 0, 5, 0), HorizontalAlignment = HorizontalAlignment.Left }; sTabCard.Borders.Add(CardViewStruct.DocTypeBorder, DocTypeBorder); sTabCard.DockPanels[CardViewStruct.FirstLineDockPanel].Children.Add(DocTypeBorder); //Вспомогательная панель типа документа var DocTypeDockPanel = new DockPanel(); sTabCard.DockPanels.Add(CardViewStruct.DocTypeDockPanel, DocTypeDockPanel); sTabCard.Borders[CardViewStruct.DocTypeBorder].Child = DocTypeDockPanel; //Текстовый блок типа документа var DocTypeTextBlock = new TextBlock { Text = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_DocType"), VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, Width = 100, FontSize = 14, Margin = new Thickness(5, 0, 0, 0) }; sTabCard.TextBlocks.Add(CardViewStruct.DocTypeTextBlock, DocTypeTextBlock); sTabCard.DockPanels[CardViewStruct.DocTypeDockPanel].Children.Add(DocTypeTextBlock); //Контрол блока даты var DocTypeTextBox = new TextBox { Text = sTabCard.Card.DocType.Caption, VerticalContentAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, MinWidth = 150, MaxWidth = 300, FontSize = 14, Height = 40, IsReadOnly = true }; sTabCard.TextBoxes.Add(CardViewStruct.DocTypeTextBox, DocTypeTextBox); sTabCard.DockPanels[CardViewStruct.DocTypeDockPanel].Children.Add(DocTypeTextBox); #endregion #region Контрол состояния карточки //Border State var StateBorder = new Border { CornerRadius = new CornerRadius(6), BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(2), Margin = new Thickness(5, 0, 0, 0), HorizontalAlignment = HorizontalAlignment.Right }; sTabCard.Borders.Add(CardViewStruct.StateBorder, StateBorder); sTabCard.DockPanels[CardViewStruct.FirstLineDockPanel].Children.Add(StateBorder); //Вспомогательная панель состояния var StateDockPanel = new DockPanel(); sTabCard.DockPanels.Add(CardViewStruct.StateDockPanel, StateDockPanel); sTabCard.Borders[CardViewStruct.StateBorder].Child = StateDockPanel; //Текстовый блок состояния var StateTextBlock = new TextBlock { Text = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_State"), VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, Width = 75, FontSize = 14, Margin = new Thickness(5, 0, 0, 0) }; sTabCard.TextBlocks.Add(CardViewStruct.StateTextBlock, StateTextBlock); sTabCard.DockPanels[CardViewStruct.StateDockPanel].Children.Add(StateTextBlock); //Контрол блока состояния var StateTextBox = new TextBox { Text = (string)SystemSingleton.Configuration.mainWindow.FindResource(sTabCard.Card.State.Caption), VerticalContentAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, Width = 120, FontSize = 14, Height = 40, IsReadOnly = true }; sTabCard.TextBoxes.Add(CardViewStruct.StateTextBox, StateTextBox); sTabCard.DockPanels[CardViewStruct.StateDockPanel].Children.Add(StateTextBox); #endregion }
public MainPage() { this.Title = "User Dialogs"; this.lblResult = new Label(); this.Content = new ScrollView { Orientation = ScrollOrientation.Vertical, Content = new StackLayout { Children = { this.lblResult, Btn("Alert", this.Alert), Btn("ActionSheet", this.ActionSheet), Btn("ActionSheet (async)", this.ActionSheetAsync), Btn("Confirm", this.Confirm), Btn("Login", this.Login), Btn("Manual Loading", this.ManualLoading), Btn("Prompt", this.Prompt), Btn("Prompt /w Text/No Cancel", this.PromptWithTextAndNoCancel), Btn("Progress", this.Progress), Btn("Progress (No Cancel)", this.ProgressNoCancel), Btn("Loading (Black - Default)",() => this.Loading(MaskType.Black)), Btn("Loading (Clear)", () => this.Loading(MaskType.Clear)), Btn("Loading (Gradient iOS)", () => this.Loading(MaskType.Gradient)), Btn("Loading (None)", () => this.Loading(MaskType.Black)), Btn("Loading (No Cancel)", this.LoadingNoCancel), Btn("Error", () => UserDialogs.Instance.ShowError("ERROR!")), Btn("Success", () => UserDialogs.Instance.ShowSuccess("ERROR!")), Btn("Toast (Success)", () => this.Toast(ToastEvent.Success)), Btn("Toast (Info)", () => this.Toast(ToastEvent.Info)), Btn("Toast (Warning)", () => this.Toast(ToastEvent.Warn)), Btn("Toast (Error)", () => this.Toast(ToastEvent.Error)), Btn("Change Default Settings", () => { // CANCEL ActionSheetConfig.DefaultCancelText = ConfirmConfig.DefaultCancelText = LoginConfig.DefaultCancelText = PromptConfig.DefaultCancelText = ProgressDialogConfig.DefaultCancelText = "NO WAY"; // OK AlertConfig.DefaultOkText = ConfirmConfig.DefaultOkText = LoginConfig.DefaultOkText = PromptConfig.DefaultOkText = "Sure"; // CUSTOM ActionSheetConfig.DefaultDestructiveText = "BOOM!"; ConfirmConfig.DefaultYes = "SIGN LIFE AWAY"; ConfirmConfig.DefaultNo = "NO WAY"; LoginConfig.DefaultTitle = "HIGH SECURITY"; LoginConfig.DefaultLoginPlaceholder = "WHO ARE YOU?"; LoginConfig.DefaultPasswordPlaceholder = "SUPER SECRET PASSWORD"; ProgressDialogConfig.DefaultTitle = "WAIT A MINUTE"; // TOAST ToastConfig.DefaultDuration = TimeSpan.FromSeconds(5); ToastConfig.InfoBackgroundColor = System.Drawing.Color.Aqua; ToastConfig.SuccessBackgroundColor = System.Drawing.Color.BurlyWood; ToastConfig.WarnBackgroundColor = System.Drawing.Color.BlueViolet; ToastConfig.ErrorBackgroundColor = System.Drawing.Color.DeepPink; UserDialogs.Instance.Alert("Default Settings Updated - Now run samples"); }), Btn("Reset Default Settings", () => { // CANCEL ActionSheetConfig.DefaultCancelText = ConfirmConfig.DefaultCancelText = LoginConfig.DefaultCancelText = PromptConfig.DefaultCancelText = ProgressDialogConfig.DefaultCancelText = "Cancel"; // OK AlertConfig.DefaultOkText = ConfirmConfig.DefaultOkText = LoginConfig.DefaultOkText = PromptConfig.DefaultOkText = "Ok"; // CUSTOM ActionSheetConfig.DefaultDestructiveText = "Remove"; ConfirmConfig.DefaultYes = "Yes"; ConfirmConfig.DefaultNo = "No"; LoginConfig.DefaultTitle = "Login"; LoginConfig.DefaultLoginPlaceholder = "User Name"; LoginConfig.DefaultPasswordPlaceholder = "Password"; ProgressDialogConfig.DefaultTitle = "Loading"; ToastConfig.DefaultDuration = TimeSpan.FromSeconds(3); UserDialogs.Instance.Alert("Default Settings Restored"); // TODO: toast defaults }) } } }; }
private static void FillSecondLine(STabCard sTabCard) { #region Основная панель var SecondLineDockPanel = new DockPanel { Margin = new Thickness(5, 0, 5, 10) }; sTabCard.DockPanels.Add(CardViewStruct.SecondLineDockPanel, SecondLineDockPanel); sTabCard.StackPanels[CardViewStruct.MainStackPanel].Children.Add(SecondLineDockPanel); #endregion #region Контрол Фамилия //Border lastname var LastNameBorder = new Border { CornerRadius = new CornerRadius(6), BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(2), Margin = new Thickness(0, 0, 5, 0), HorizontalAlignment = HorizontalAlignment.Left }; sTabCard.Borders.Add(CardViewStruct.LastNameBorder, LastNameBorder); sTabCard.DockPanels[CardViewStruct.SecondLineDockPanel].Children.Add(LastNameBorder); //Вспомогательная панель фамилии var LastNameDockPanel = new DockPanel(); sTabCard.DockPanels.Add(CardViewStruct.LastNameDockPanel, LastNameDockPanel); sTabCard.Borders[CardViewStruct.LastNameBorder].Child = LastNameDockPanel; //Текстовый блок фамилии var LastNameTextBlock = new TextBlock { Text = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_LastName"), VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, Width = 75, FontSize = 14, Margin = new Thickness(5, 0, 0, 0) }; sTabCard.TextBlocks.Add(CardViewStruct.LastNameTextBlock, LastNameTextBlock); sTabCard.DockPanels[CardViewStruct.LastNameDockPanel].Children.Add(LastNameTextBlock); //Контрол блока фамилии var LastNameTextBox = new TextBox { Text = sTabCard.Card.From.LastName, VerticalContentAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, MinWidth = 50, MaxWidth = 200, FontSize = 14, Height = 40, IsReadOnly = true }; sTabCard.TextBoxes.Add(CardViewStruct.LastNameTextBox, LastNameTextBox); sTabCard.DockPanels[CardViewStruct.LastNameDockPanel].Children.Add(LastNameTextBox); #endregion #region Контрол Имя //Border имя var FirstNameBorder = new Border { CornerRadius = new CornerRadius(6), BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(2), Margin = new Thickness(5, 0, 0, 0), HorizontalAlignment = HorizontalAlignment.Left }; sTabCard.Borders.Add(CardViewStruct.FirstNameBorder, FirstNameBorder); sTabCard.DockPanels[CardViewStruct.SecondLineDockPanel].Children.Add(FirstNameBorder); //Вспомогательная панель имени var FirstNameDockPanel = new DockPanel(); sTabCard.DockPanels.Add(CardViewStruct.FirstNameDockPanel, FirstNameDockPanel); sTabCard.Borders[CardViewStruct.FirstNameBorder].Child = FirstNameDockPanel; //Текстовый блок имени var FirstNameTextBlock = new TextBlock { Text = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_FirstName"), VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, Width = 75, FontSize = 14, Margin = new Thickness(5, 0, 0, 0) }; sTabCard.TextBlocks.Add(CardViewStruct.FirstNameTextBlock, FirstNameTextBlock); sTabCard.DockPanels[CardViewStruct.FirstNameDockPanel].Children.Add(FirstNameTextBlock); //Контрол блока имени var FirstNameTextBox = new TextBox { Text = sTabCard.Card.From.FirstName, VerticalContentAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, MinWidth = 50, MaxWidth = 200, FontSize = 14, Height = 40, IsReadOnly = true }; sTabCard.TextBoxes.Add(CardViewStruct.FirstNameTextBox, FirstNameTextBox); sTabCard.DockPanels[CardViewStruct.FirstNameDockPanel].Children.Add(FirstNameTextBox); #endregion #region Контрол нового состояния if (sTabCard.Card.State.ID == new Guid("6a52791d-7e42-42d6-a521-4252f276bb6c") && !sTabCard.Card.Task.isEditingNow) { //Border newState var NewStateBorder = new Border { CornerRadius = new CornerRadius(6), BorderBrush = new SolidColorBrush(Colors.LightGray), BorderThickness = new Thickness(2), Margin = new Thickness(5, 0, 0, 0), HorizontalAlignment = HorizontalAlignment.Right }; sTabCard.Borders.Add(CardViewStruct.NewStateBorder, NewStateBorder); sTabCard.DockPanels[CardViewStruct.SecondLineDockPanel].Children.Add(NewStateBorder); //Вспомогательная панель нового состояния var NewStateDockPanel = new DockPanel(); sTabCard.DockPanels.Add(CardViewStruct.NewStateDockPanel, NewStateDockPanel); sTabCard.Borders[CardViewStruct.NewStateBorder].Child = NewStateDockPanel; //Текстовый блок нового состояния var NewStateTextBlock = new TextBlock { Text = (string)SystemSingleton.Configuration.mainWindow.FindResource("c_NewState"), VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, Width = 120, FontSize = 14, Margin = new Thickness(5, 0, 0, 0) }; sTabCard.TextBlocks.Add(CardViewStruct.NewStateTextBlock, NewStateTextBlock); sTabCard.DockPanels[CardViewStruct.NewStateDockPanel].Children.Add(NewStateTextBlock); //Контрол блока нового состояния var NewStateComboBox = new ComboBox() { HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center, Width = 120, FontSize = 14, Height = 40 }; NewStateComboBox.SelectionChanged += (sender, args) => { foreach (var st in sTabCard.Card.AllStates.States) { if (("States" + st.Name) == ((TextBlock)NewStateComboBox.SelectedItem).Name) { sTabCard.StateChanged(st); break; } } }; sTabCard.ComboBoxes.Add(CardViewStruct.NewStateComboBox, NewStateComboBox); sTabCard.DockPanels[CardViewStruct.NewStateDockPanel].Children.Add(NewStateComboBox); //Вкладки для комбобокса foreach (var item in sTabCard.Card.AllStates.States) { sTabCard.TextBlocks.Add("States" + item.Name, new TextBlock { VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Left, FontSize = 14, Text = (string)SystemSingleton.Configuration.mainWindow.FindResource(item.Caption), Name = "States" + item.Name }); sTabCard.ComboBoxes[CardViewStruct.NewStateComboBox].Items.Add(sTabCard.TextBlocks["States" + item.Name]); if (item.ID == new Guid("6a52791d-7e42-42d6-a521-4252f276bb6c")) { NewStateComboBox.SelectedItem = sTabCard.TextBlocks["States" + item.Name]; } } } #endregion }
internal static void PopulatePanelWithCitations(StackPanel panel, Library library, PDFDocument pdf_document_parent, List <Citation> citations, Feature feature, string prefix = "", bool should_add_none_indicator = true) { string fingerprint_parent = pdf_document_parent.Fingerprint; panel.Children.Clear(); List <PDFDocument> pdf_documents = new List <PDFDocument>(); foreach (var citation in citations) { string fingerprint = null; if (0 != fingerprint_parent.CompareTo(citation.fingerprint_inbound)) { fingerprint = citation.fingerprint_inbound; } if (0 != fingerprint_parent.CompareTo(citation.fingerprint_outbound)) { fingerprint = citation.fingerprint_outbound; } if (null == fingerprint) { continue; } PDFDocument pdf_document = library.GetDocumentByFingerprint(fingerprint); if (null == pdf_document) { continue; } if (pdf_document.Deleted) { continue; } pdf_documents.Add(pdf_document); } List <PDFDocument> pdf_documents_sorted = new List <PDFDocument>(pdf_documents.OrderBy(x => x.YearCombined)); bool alternator = false; foreach (PDFDocument pdf_document in pdf_documents_sorted) { TextBlock text_doc = ListFormattingTools.GetDocumentTextBlock(pdf_document, ref alternator, Features.Citations_OpenDoc, null, prefix); panel.Children.Add(text_doc); } // If the panel is empty, put NONE if (should_add_none_indicator) { if (0 == panel.Children.Count) { TextBlock text_doc = new TextBlock(); text_doc.Text = "(none)"; panel.Children.Add(text_doc); } } }
private void Handle(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { applicableToSpan = null; DateTime time1 = DateTime.Now; ITextSnapshot snapshot = this._sourceBuffer.CurrentSnapshot; var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot); if (triggerPoint == null) { AsmDudeToolsStatic.Output_WARNING("AsmQuickInfoSource:AugmentQuickInfoSession: trigger point is null"); return; } Brush foreground = AsmDudeToolsStatic.Get_Font_Color(); var enumerator = this._aggregator.GetTags(new SnapshotSpan(triggerPoint, triggerPoint)).GetEnumerator(); if (enumerator.MoveNext()) { var asmTokenTag = enumerator.Current; var enumerator2 = asmTokenTag.Span.GetSpans(this._sourceBuffer).GetEnumerator(); if (enumerator2.MoveNext()) { SnapshotSpan tagSpan = enumerator2.Current; string keyword = tagSpan.GetText(); string keywordUpper = keyword.ToUpper(); #region Tests // TODO: multiple tags at the provided triggerPoint is most likely the result of a bug in AsmTokenTagger, but it seems harmless... if (false) { if (enumerator.MoveNext()) { var asmTokenTagX = enumerator.Current; var enumeratorX = asmTokenTagX.Span.GetSpans(this._sourceBuffer).GetEnumerator(); enumeratorX.MoveNext(); AsmDudeToolsStatic.Output_WARNING(string.Format("{0}:AugmentQuickInfoSession. current keyword " + keyword + ": but span has more than one tag! next tag=\"{1}\"", ToString(), enumeratorX.Current.GetText())); } } #endregion //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: keyword=\""+ keyword + "\"; type=" + asmTokenTag.Tag.type +"; file="+AsmDudeToolsStatic.GetFileName(session.TextView.TextBuffer)); applicableToSpan = snapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeInclusive); TextBlock description = null; AsmTokenType type = asmTokenTag.Tag.Type; switch (type) { case AsmTokenType.Misc: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Keyword ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Misc)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.Directive: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Directive ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Directive)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.Register: { int lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan); if (keywordUpper.StartsWith("%")) { keywordUpper = keywordUpper.Substring(1); // remove the preceding % in AT&T syntax } Rn reg = RegisterTools.ParseRn(keywordUpper, true); if (this._asmDudeTools.RegisterSwitchedOn(reg)) { var registerTooltipWindow = new RegisterTooltipWindow(foreground); registerTooltipWindow.SetDescription(reg, this._asmDudeTools); registerTooltipWindow.SetAsmSim(this._asmSimulator, reg, lineNumber, true); quickInfoContent.Add(registerTooltipWindow); } break; } case AsmTokenType.Mnemonic: case AsmTokenType.Jump: { int lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan); Mnemonic mnemonic = AsmSourceTools.ParseMnemonic_Att(keywordUpper, true); if (this._asmDudeTools.MnemonicSwitchedOn(mnemonic)) { var instructionTooltipWindow = new InstructionTooltipWindow(foreground) { Session = session // set the owner of this windows such that we can manually close this window }; instructionTooltipWindow.SetDescription(mnemonic, this._asmDudeTools); instructionTooltipWindow.SetPerformanceInfo(mnemonic, this._asmDudeTools); instructionTooltipWindow.SetAsmSim(this._asmSimulator, lineNumber, true); quickInfoContent.Add(instructionTooltipWindow); } break; } case AsmTokenType.Label: { string label = keyword; string labelPrefix = asmTokenTag.Tag.Misc; string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(labelPrefix, label, AsmDudeToolsStatic.Used_Assembler); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = Get_Label_Description(full_Qualified_Label); if (descr.Length == 0) { descr = Get_Label_Description(label); } if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.LabelDef: { string label = keyword; string extra_Tag_Info = asmTokenTag.Tag.Misc; string full_Qualified_Label; if ((extra_Tag_Info != null) && extra_Tag_Info.Equals(AsmTokenTag.MISC_KEYWORD_PROTO)) { full_Qualified_Label = label; } else { full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(extra_Tag_Info, label, AsmDudeToolsStatic.Used_Assembler); } AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: found label def " + full_Qualified_Label); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = Get_Label_Def_Description(full_Qualified_Label, label); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.Constant: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Constant ", foreground)); var(Valid, Value, NBits) = AsmSourceTools.Evaluate_Constant(keyword); string constantStr = (Valid) ? Value + "d = " + Value.ToString("X") + "h = " + AsmSourceTools.ToStringBin(Value, NBits) + "b" : keyword; description.Inlines.Add(Make_Run2(constantStr, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Constant)))); break; } case AsmTokenType.UserDefined1: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 1: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined1)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.UserDefined2: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 2: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined2)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.UserDefined3: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 3: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined3)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } default: //description = new TextBlock(); //description.Inlines.Add(makeRun1("Unused tagType " + asmTokenTag.Tag.type)); break; } if (description != null) { description.FontSize = AsmDudeToolsStatic.Get_Font_Size() + 2; description.FontFamily = AsmDudeToolsStatic.Get_Font_Type(); //AsmDudeToolsStatic.Output_INFO(string.Format("{0}:AugmentQuickInfoSession; setting description fontSize={1}; fontFamily={2}", this.ToString(), description.FontSize, description.FontFamily)); quickInfoContent.Add(description); } } } //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: applicableToSpan=\"" + applicableToSpan + "\"; quickInfoContent,Count=" + quickInfoContent.Count); AsmDudeToolsStatic.Print_Speed_Warning(time1, "QuickInfo"); }
public IvyLabel() { label = new TextBlock(); }
protected void splitLabel(string text, Font font, TextBlock block, ref int x, ref int y, ref int lineHeight) { var spaced = Util.SplitAndKeep(text, " "); if (spaced.Length == 0) { return; } int spaceLeft = Width - x; string leftOver; // Does the whole word fit in? Point stringSize = Skin.Renderer.MeasureText(font, text); if (spaceLeft > stringSize.X) { createLabel(text, block, ref x, ref y, ref lineHeight, true); return; } // If the first word is bigger than the line, just give up. Point wordSize = Skin.Renderer.MeasureText(font, spaced[0]); if (wordSize.X >= spaceLeft) { createLabel(spaced[0], block, ref x, ref y, ref lineHeight, true); if (spaced[0].Length >= text.Length) { return; } leftOver = text.Substring(spaced[0].Length + 1); splitLabel(leftOver, font, block, ref x, ref y, ref lineHeight); return; } string newString = String.Empty; for (int i = 0; i < spaced.Length; i++) { wordSize = Skin.Renderer.MeasureText(font, newString + spaced[i]); if (wordSize.X > spaceLeft) { createLabel(newString, block, ref x, ref y, ref lineHeight, true); x = 0; y += lineHeight; break; } newString += spaced[i]; } int newstr_len = newString.Length; if (newstr_len < text.Length) { leftOver = text.Substring(newstr_len + 1); splitLabel(leftOver, font, block, ref x, ref y, ref lineHeight); } }
private void SetupYAxis() { YAxis.Children.Clear(); YLabels.Children.Clear(); //Adding the vertical axis line yAxisLine = new Polyline(); double lineH = GraphHeight + AxisThickness + GraphContentPadding + AxisOutlineLenght; yAxisLine.Points.Add(new Point(AxisThickness, AxisThickness / 2)); yAxisLine.Points.Add(new Point(AxisThickness, lineH)); yAxisLine.Stroke = AxisColor; yAxisLine.StrokeThickness = 0.5; //Adding the labels and the unit lines //Calculatin the steps height Double offset = 0; int n_division = 0; double stepHeight = GraphHeight; while (stepHeight > 10) { n_division++; stepHeight = stepHeight / 10; } //if ((stepHeight - Math.Round(stepHeight)) < 0.5) stepHeight += 0.5; stepHeight = Math.Round(stepHeight, MidpointRounding.AwayFromZero); for (int i = 0; i < n_division; i++) { stepHeight = stepHeight * 10; } stepHeight = stepHeight / (VerticalSteps - 1); //Adding the lines for (int i = 0; i < VerticalSteps; i++) { double verticalPosition = AxisThickness + GraphContentPadding + offset; Polyline line = new Polyline(); line.Points.Add(new Point(AxisThickness / 2, verticalPosition)); line.Points.Add(new Point(AxisThickness, verticalPosition)); line.Stroke = AxisColor; line.StrokeThickness = 0.5; YAxis.Children.Add(line); //Adding the labels TextBlock stepLabel = new TextBlock { Text = Math.Round((i * stepHeight) * (maxY - minY) / GraphHeight + minY).ToString(), FontSize = 8, Foreground = LabelsColor }; Canvas.SetBottom(stepLabel, verticalPosition - stepLabel.FontSize / 2); Canvas.SetLeft(stepLabel, -((stepLabel.Text.Length * stepLabel.FontSize) / 2)); YLabels.Children.Add(stepLabel); offset += stepHeight; //Avoiding lines over the vertical axis arrow if ((verticalPosition + stepHeight) > lineH - AxisOutlineLenght) { break; } } //Adding the Y axis name label Decorator label = CanvasLabel(YAxisName, -AxisThickness, lineH + 5, LabelsColor, 10); label.Width = 50; label.Height = 15; YLabels.Children.Add(label); //Adding the arrow on top of the axis line Polyline arrow = VerticalArrow(new Point(AxisThickness, lineH), AxisThickness / 2); arrow.Stroke = AxisColor; arrow.StrokeThickness = 1; YAxis.Children.Add(yAxisLine); YAxis.Children.Add(arrow); Graph.Height = lineH + label.Height + 10; }
public Gauge() { Canvas = new Canvas { ClipToBounds = true }; Content = Canvas; PieBack = new PieSlice(); Pie = new PieSlice(); TitleTextBlock = new TextBlock(); MeasureTextBlock = new TextBlock(); LeftLabel = new TextBlock(); RightLabel = new TextBlock(); Canvas.Children.Add(PieBack); Canvas.Children.Add(Pie); Canvas.Children.Add(TitleTextBlock); Canvas.Children.Add(MeasureTextBlock); Canvas.Children.Add(RightLabel); Canvas.Children.Add(LeftLabel); Panel.SetZIndex(PieBack, 0); Panel.SetZIndex(Pie, 1); Canvas.SetBinding(WidthProperty, new Binding { Path = new PropertyPath(WidthProperty), Source = this }); Canvas.SetBinding(HeightProperty, new Binding { Path = new PropertyPath(HeightProperty), Source = this }); PieBack.SetBinding(Shape.FillProperty, new Binding { Path = new PropertyPath(GaugeBackgroundProperty), Source = this }); PieBack.SetBinding(Shape.StrokeThicknessProperty, new Binding { Path = new PropertyPath(StrokeThicknessProperty), Source = this }); PieBack.SetBinding(Shape.StrokeProperty, new Binding { Path = new PropertyPath(StrokeProperty), Source = this }); Pie.SetBinding(Shape.StrokeThicknessProperty, new Binding { Path = new PropertyPath(StrokeThicknessProperty), Source = this }); Pie.Stroke = Brushes.Transparent; TitleTextBlock.SetBinding(TextBlock.TextProperty, new Binding { Path = new PropertyPath(TitleProperty), Source = this }); SetValue(GaugeBackgroundProperty, new SolidColorBrush(Color.FromRgb(21, 101, 191)) { Opacity = .1 }); SetValue(StrokeThicknessProperty, 0d); SetValue(StrokeProperty, new SolidColorBrush(Color.FromRgb(222, 222, 222))); SetValue(ToColorProperty, Color.FromRgb(100, 180, 245)); SetValue(FromColorProperty, Color.FromRgb(21, 101, 191)); SetValue(MinHeightProperty, 50d); SetValue(MinWidthProperty, 80d); SetValue(AnimationsSpeedProperty, TimeSpan.FromMilliseconds(800)); MeasureTextBlock.FontWeight = FontWeights.Bold; IsNew = true; SizeChanged += (sender, args) => { IsChartInitialized = true; Update(); }; }
/* Construction d'une nouvelle tab / onglet : Un texte placeholder et une image de croix dans un stackpanel, inséré dans * un tab, inséré dans le tabcontrol*/ public void CreateNewTab(string url = "") { if (MainTabControl.Items.Count < 27) { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.UriSource = new Uri("asset/img/close_cross.png", UriKind.Relative); bitmapImage.EndInit(); StackPanel stackPanel = new StackPanel { Margin = new Thickness(-4, 4, 0, 0), Orientation = Orientation.Horizontal }; Image imageCross = new Image { Source = bitmapImage, Width = 16 }; imageCross.MouseDown += ImageCross_MouseDown; TextBlock textBlock = new TextBlock { Text = "N" }; stackPanel.Children.Insert(0, textBlock); stackPanel.Children.Insert(1, imageCross); SolidColorBrush bgColor = new SolidColorBrush(); bgColor = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF5B5B5B")); SolidColorBrush borderColor = new SolidColorBrush(); borderColor = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF6A6666")); //Create ContextMenu ContextMenu contextMenu = new ContextMenu(); MenuItem menuItemDup = new MenuItem { Header = "Dupliquer" }; menuItemDup.Click += Click_Item_Duplicate; MenuItem menuItemClose = new MenuItem { Header = "Fermer" }; menuItemClose.Click += Click_Item_Close; contextMenu.Items.Add(menuItemDup); contextMenu.Items.Add(menuItemClose); TabItem tab = new TabItem { Header = stackPanel, ContextMenu = contextMenu, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(0), Height = 34, FontSize = 20, Background = bgColor, BorderBrush = borderColor }; Frame frame = new Frame { Content = new NavView(), Margin = new Thickness(-5) }; tab.Content = frame; MainTabControl.Items.Add(tab); MainTabControl.SelectedItem = tab; if (url != "") { this.Dispatcher.BeginInvoke((Action)(() => { NavView view = (NavView)frame.Content; view.Browser.Address = url; })); } } }
private void SetupXAxis() { XAxis.Children.Clear(); XLabels.Children.Clear(); double lineW = HorizontalStepsWidth * (HorizontalSteps - 1) + AxisThickness + GraphContentPadding + AxisOutlineLenght; //Adding the horizontal axis line xAxisLine = new Polyline(); xAxisLine.Points.Add(new Point(AxisThickness / 2, AxisThickness)); xAxisLine.Points.Add(new Point(lineW, AxisThickness)); xAxisLine.Stroke = AxisColor; xAxisLine.StrokeThickness = 0.5; //Setting the horizontal offset for the axis units and lines Double offset = AxisThickness + GraphContentPadding; //Adding the axis unit lines and labels for (int i = 0; i < HorizontalSteps; i++) { //Adding the lines Polyline line = new Polyline(); line.Points.Add(new Point(offset, AxisThickness / 2)); line.Points.Add(new Point(offset, AxisThickness)); line.Stroke = AxisColor; line.Visibility = Visibility.Hidden; line.StrokeThickness = 0.5; XAxis.Children.Add(line); //Adding the labels TextBlock stepLabel = new TextBlock { Text = "", FontSize = 10, Foreground = LabelsColor }; Canvas.SetBottom(stepLabel, -2 * stepLabel.FontSize); Canvas.SetLeft(stepLabel, offset - ((stepLabel.Text.Length * stepLabel.FontSize) / 4)); XLabels.Children.Add(stepLabel); offset += HorizontalStepsWidth; } //Adding the X axis name label Double XPosition = lineW + 5; Double YPosition = AxisThickness / 2; Decorator label = CanvasLabel(XAxisName, XPosition, YPosition, LabelsColor, 10); label.Width = 50; label.Height = 15; XLabels.Children.Add(label); //Creating the arrow for the end of the axis line Polyline arrow = HorizontalArrow(new Point(lineW, AxisThickness), 5); arrow.Stroke = AxisColor; arrow.StrokeThickness = 1; //Adding the X axis line and his arrow XAxis.Children.Add(xAxisLine); XAxis.Children.Add(arrow); Graph.Width = lineW + label.Width + 10; }
private void CreateAndShowMainWindow() { // Create the application's main window myWindow = new Window(); // Add a Border myBorder = new Border(); myBorder.BorderBrush = Brushes.Black; myBorder.BorderThickness = new Thickness(2); myBorder.Width = 400; myBorder.Height = 600; myBorder.Padding = new Thickness(15); myBorder.Background = Brushes.White; // Create a Grid to host the Shapes myGrid = new Grid(); myGrid.Margin = new Thickness(15); myColDef1 = new ColumnDefinition(); myColDef1.Width = new GridLength(125); myColDef2 = new ColumnDefinition(); myColDef2.Width = new GridLength(1, GridUnitType.Star); myGrid.ColumnDefinitions.Add(myColDef1); myGrid.ColumnDefinitions.Add(myColDef2); myRowDef = new RowDefinition(); myRowDef1 = new RowDefinition(); myRowDef2 = new RowDefinition(); myRowDef3 = new RowDefinition(); myRowDef4 = new RowDefinition(); myRowDef5 = new RowDefinition(); myRowDef6 = new RowDefinition(); myGrid.RowDefinitions.Add(myRowDef); myGrid.RowDefinitions.Add(myRowDef1); myGrid.RowDefinitions.Add(myRowDef2); myGrid.RowDefinitions.Add(myRowDef3); myGrid.RowDefinitions.Add(myRowDef4); myGrid.RowDefinitions.Add(myRowDef5); myGrid.RowDefinitions.Add(myRowDef6); myTextBlock = new TextBlock(); myTextBlock.FontSize = 20; myTextBlock.Text = "WPF Shapes Gallery"; myTextBlock.HorizontalAlignment = HorizontalAlignment.Left; myTextBlock.VerticalAlignment = VerticalAlignment.Center; myGrid.Children.Add(myTextBlock); Grid.SetRow(myTextBlock, 0); Grid.SetColumnSpan(myTextBlock, 2); // Add a Rectangle Element myRect = new Mono.System.Windows.Shapes.Rectangle(); myRect.Stroke = Brushes.Black; myRect.Fill = Brushes.SkyBlue; myRect.HorizontalAlignment = HorizontalAlignment.Left; myRect.VerticalAlignment = VerticalAlignment.Center; myRect.Height = 50; myRect.Width = 50; myGrid.Children.Add(myRect); Grid.SetRow(myRect, 1); Grid.SetColumn(myRect, 0); TextBlock myTextBlock1 = new TextBlock(); myTextBlock1.FontSize = 14; myTextBlock1.Text = "A Rectangle Element"; myTextBlock1.VerticalAlignment = VerticalAlignment.Center; myGrid.Children.Add(myTextBlock1); Grid.SetRow(myTextBlock1, 1); Grid.SetColumn(myTextBlock1, 1); // Add an Ellipse Element myEllipse = new Mono.System.Windows.Shapes.Ellipse(); myEllipse.Stroke = Brushes.Black; myEllipse.Fill = Brushes.DarkBlue; myEllipse.HorizontalAlignment = HorizontalAlignment.Left; myEllipse.VerticalAlignment = VerticalAlignment.Center; myEllipse.Width = 50; myEllipse.Height = 75; myGrid.Children.Add(myEllipse); Grid.SetRow(myEllipse, 2); Grid.SetColumn(myEllipse, 0); TextBlock myTextBlock2 = new TextBlock(); myTextBlock2.FontSize = 14; myTextBlock2.Text = "An Ellipse Element"; myTextBlock2.VerticalAlignment = VerticalAlignment.Center; myGrid.Children.Add(myTextBlock2); Grid.SetRow(myTextBlock2, 2); Grid.SetColumn(myTextBlock2, 1); // Add a Line Element myLine = new Mono.System.Windows.Shapes.Line(); myLine.Stroke = Brushes.LightSteelBlue; myLine.X1 = 1; myLine.X2 = 50; myLine.Y1 = 1; myLine.Y2 = 50; myLine.HorizontalAlignment = HorizontalAlignment.Left; myLine.VerticalAlignment = VerticalAlignment.Center; myLine.StrokeThickness = 2; myGrid.Children.Add(myLine); Grid.SetRow(myLine, 3); Grid.SetColumn(myLine, 0); TextBlock myTextBlock3 = new TextBlock(); myTextBlock3.FontSize = 14; myTextBlock3.Text = "A Line Element"; myTextBlock3.VerticalAlignment = VerticalAlignment.Center; myGrid.Children.Add(myTextBlock3); Grid.SetRow(myTextBlock3, 3); Grid.SetColumn(myTextBlock3, 1); //Add the Path Element myPath = new Mono.System.Windows.Shapes.Path(); myPath.Stroke = Brushes.Black; myPath.Fill = Brushes.MediumSlateBlue; myPath.StrokeThickness = 4; myPath.HorizontalAlignment = HorizontalAlignment.Left; myPath.VerticalAlignment = VerticalAlignment.Center; EllipseGeometry myEllipseGeometry = new EllipseGeometry(); myEllipseGeometry.Center = new Point(50, 50); myEllipseGeometry.RadiusX = 25; myEllipseGeometry.RadiusY = 25; myPath.Data = myEllipseGeometry; myGrid.Children.Add(myPath); Grid.SetRow(myPath, 4); Grid.SetColumn(myPath, 0); TextBlock myTextBlock4 = new TextBlock(); myTextBlock4.FontSize = 14; myTextBlock4.Text = "A Path Element"; myTextBlock4.VerticalAlignment = VerticalAlignment.Center; myGrid.Children.Add(myTextBlock4); Grid.SetRow(myTextBlock4, 4); Grid.SetColumn(myTextBlock4, 1); //Add the Polygon Element myPolygon = new Mono.System.Windows.Shapes.Polygon(); myPolygon.Stroke = Brushes.Black; myPolygon.Fill = Brushes.LightSeaGreen; myPolygon.StrokeThickness = 2; myPolygon.HorizontalAlignment = HorizontalAlignment.Left; myPolygon.VerticalAlignment = VerticalAlignment.Center; Point Point1 = new Point(1, 50); Point Point2 = new Point(10, 80); Point Point3 = new Point(50, 50); PointCollection myPointCollection = new PointCollection(); myPointCollection.Add(Point1); myPointCollection.Add(Point2); myPointCollection.Add(Point3); myPolygon.Points = myPointCollection; myGrid.Children.Add(myPolygon); Grid.SetRow(myPolygon, 5); Grid.SetColumn(myPolygon, 0); TextBlock myTextBlock5 = new TextBlock(); myTextBlock5.Text = "A Polygon Element"; myTextBlock5.FontSize = 14; myTextBlock5.VerticalAlignment = VerticalAlignment.Center; myGrid.Children.Add(myTextBlock5); Grid.SetRow(myTextBlock5, 5); Grid.SetColumn(myTextBlock5, 1); // Add the Polyline Element myPolyline = new Mono.System.Windows.Shapes.Polyline(); myPolyline.Stroke = Brushes.SlateGray; myPolyline.StrokeThickness = 2; myPolyline.FillRule = FillRule.EvenOdd; Point Point4 = new Point(1, 50); Point Point5 = new Point(10, 80); Point Point6 = new Point(20, 40); PointCollection myPointCollection2 = new PointCollection(); myPointCollection2.Add(Point4); myPointCollection2.Add(Point5); myPointCollection2.Add(Point6); myPolyline.Points = myPointCollection2; myGrid.Children.Add(myPolyline); Grid.SetRow(myPolyline, 6); Grid.SetColumn(myPolyline, 0); TextBlock myTextBlock6 = new TextBlock(); myTextBlock6.FontSize = 14; myTextBlock6.Text = "A Polyline Element"; myTextBlock6.VerticalAlignment = VerticalAlignment.Center; myGrid.Children.Add(myTextBlock6); Grid.SetRow(myTextBlock6, 6); Grid.SetColumn(myTextBlock6, 1); // Add the Grid to the Window as Content and show the Window myBorder.Child = myGrid; myWindow.Content = myBorder; myWindow.Background = Brushes.LightSlateGray; myWindow.Title = "Shapes Sample"; myWindow.Show(); }
async Task DrawBackgroundImage() { var targetButton = this.Control; if (!(this.Element is CalendarButton sourceButton) || targetButton == null) { return; } if (sourceButton.BackgroundImage != null) { var grid = new Grid { Padding = new Thickness(0) }; var _currentImage = await GetCurrentImage(); targetButton.HorizontalContentAlignment = HorizontalAlignment.Center; try { _currentImage.HorizontalAlignment = HorizontalAlignment.Center; grid.Children.Add(_currentImage); } catch (Exception e) { System.Diagnostics.Debug.WriteLine($"Error settings old image {e}"); } if (!string.IsNullOrEmpty(sourceButton.Text) || !string.IsNullOrEmpty(sourceButton.Text)) { var label = new TextBlock { TextAlignment = TextAlignment.Center, FontSize = 16, VerticalAlignment = VerticalAlignment.Center, Text = string.IsNullOrEmpty(sourceButton.TextWithoutMeasure) ? sourceButton.Text : sourceButton.TextWithoutMeasure }; grid.Children.Add(label); } targetButton.Padding = new Thickness(0); targetButton.Content = grid; } else if (sourceButton.BackgroundImage == null) { var grid = new Grid { Padding = new Thickness(0) }; var label = new TextBlock { TextAlignment = TextAlignment.Center, FontSize = 12, VerticalAlignment = VerticalAlignment.Center, Text = string.IsNullOrEmpty(sourceButton.TextWithoutMeasure) ? sourceButton.Text : sourceButton.TextWithoutMeasure }; targetButton.HorizontalContentAlignment = HorizontalAlignment.Center; grid.Children.Add(label); targetButton.Padding = new Thickness(0); targetButton.Content = grid; } }
private void setTextBlockText2(TextBlock textBlock, string value) { textBlock.Text = value; }
public MainPage() { this.InitializeComponent(); ViewModel = new State { Parent = this, Emotions = new ObservableCollection <string>() }; cameraControl.ShowDialogOnApiErrors = true; this.cameraControl.ImageCaptured += CameraControl_ImageCaptured; this.cameraControl.CameraRestarted += CameraControl_CameraRestarted; Paragraph paragraph = new Paragraph(); textDisplay.Blocks.Add(paragraph); Observable.FromEventPattern(textEditor, "TextChanged") .Throttle(TimeSpan.FromMilliseconds(1000)) .ObserveOnDispatcher() .Select(_ => textEditor.Text) .Where(text => text.EndsWith(" ")) .SelectMany(text => { textEditor.Text = ""; return(TextAnalyticsServiceHelper.GetSentimentAsync(text) .ToObservable() .Select(score => Tuple.Create(text, score))); }) .ObserveOnDispatcher() .Subscribe(textAndScore => { var score = textAndScore.Item2; Debug.WriteLine("Text: " + textAndScore.Item1); Debug.WriteLine("Score: " + score); TextBlock tb = new TextBlock() { Text = textAndScore.Item1 + " " }; Border border = new Border(); border.Child = tb; border.Background = new SolidColorBrush(Color.FromArgb(200, (byte)(255 * (1.0 - score)), (byte)(255 * score), 0)); InlineUIContainer inline = new InlineUIContainer(); inline.Child = border; paragraph.Inlines.Add(inline); }, e => { Debug.WriteLine(e.ToString()); }, () => { }); Observable.Timer(new TimeSpan(0, 0, 0), new TimeSpan(0, 0, 1)) .Where(i => ViewModel.IsRunning) .Where(i => i % 5 == 0) .ObserveOnDispatcher() .SelectMany(i => { Debug.WriteLine("Getting image"); return(cameraControl.CaptureFrameAsync().ToObservable()); }) .Do(i => Debug.WriteLine("Got result")) .Where(i => i != null) .SelectMany(i => { return(Task.WhenAll(i.DetectEmotionAsync(), i.DetectFacesAsync(detectFaceAttributes: true)).ToObservable().Select(_ => i)); }) .ObserveOnDispatcher() .Subscribe(image => { faceDescription.Text = GetFaceString(image); if (image.DetectedFaces != null && image.DetectedFaces.Count() > 0 && image.DetectedFaces.First().FaceAttributes != null) { var attrs = image.DetectedFaces.First().FaceAttributes; statusText.Text = ""; if (attrs.Glasses == Glasses.Sunglasses) { statusText.Text = "Please remove your sunglasses"; } else if (attrs.Smile > 0.15) { statusText.Text = "Do not smile"; } else if (attrs.Accessories != null && attrs.Accessories.Where(a => a.Type == AccessoryType.Headwear && a.Confidence > 0.8).Count() > 0) { statusText.Text = "Please remove your hat"; } else if (attrs.HeadPose != null && Math.Abs(attrs.HeadPose.Yaw) > 6) { statusText.Text = "Please turn to face the camera"; } else if (attrs.HeadPose != null && Math.Abs(attrs.HeadPose.Roll) > 6) { statusText.Text = "Please do not tilt your head"; } else if (attrs.Occlusion != null && attrs.Occlusion.EyeOccluded) { statusText.Text = "Do not cover your eyes"; } else if (attrs.Occlusion != null && attrs.Occlusion.ForeheadOccluded) { statusText.Text = "Do not cover your forehead"; } else if (attrs.Occlusion != null && attrs.Occlusion.MouthOccluded) { statusText.Text = "Do not cover your mouth"; } else if (attrs.Exposure != null && attrs.Exposure.ExposureLevel == ExposureLevel.OverExposure) { statusText.Text = "Your face is overexposed"; } else if (attrs.Exposure != null && attrs.Exposure.ExposureLevel == ExposureLevel.UnderExposure) { statusText.Text = "Your face is underexposed"; } if (String.IsNullOrEmpty(statusText.Text)) { this.cameraControl.SetFaceBorderColor(new SolidColorBrush(Colors.White)); statusText.Foreground = new SolidColorBrush(Colors.Green); statusText.Text = "Awesome passport pic!"; } else { this.cameraControl.SetFaceBorderColor(new SolidColorBrush(Colors.Red)); statusText.Foreground = new SolidColorBrush(Colors.Red); } } }, e => { Debug.WriteLine(e.ToString()); }, () => { }); }