public RouteDetailsPanoramaPage() { InitializeComponent(); pins = new List<Pushpin>(); var clusterer = new PushpinClusterer(map1, pins, this.Resources["ClusterTemplate"] as DataTemplate); SystemTray.SetIsVisible(this, true); if (watcher == null) { //---get the highest accuracy--- watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High) { //---the minimum distance (in meters) to travel before the next // location update--- MovementThreshold = 10 }; //---event to fire when a new position is obtained--- watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged); //---event to fire when there is a status change in the location // service API--- watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged); watcher.Start(); map1.Center = new GeoCoordinate(58.383333, 26.716667); map1.ZoomLevel = 15; map1.Mode = new MyMapMode(); } }
public MainWindow() { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); InitializeComponent(); DateTime lastDate = new DateTime(2011, 11, 15); double lastVal = 20; List<ChartDataObject> dataSouce = new List<ChartDataObject>(); for (int i = 0; i < 5; ++i) { ChartDataObject obj = new ChartDataObject { Date = lastDate.AddMonths(1), Value = lastVal++ }; dataSouce.Add(obj); lastDate = obj.Date; } LineSeries series = (LineSeries)this.chart1.Series[0]; series.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "Date" }; series.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Value" }; series.ItemsSource = dataSouce; series = (LineSeries)this.chart2.Series[0]; series.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "Date" }; series.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Value" }; series.ItemsSource = dataSouce; }
public LowerList() { InitializeComponent(); PageSum = new LowerListData(); PageSum.UserID = "本页合计"; PageSum.IsOnline = -1; TotalSum = new LowerListData(); TotalSum.UserID = "总合计"; TotalSum.IsOnline = -1; BindedLst = new List<long>(); srv_UserList = WcfProxy.GetProxy; srv_UserList.GetLowerListDataCompleted += new EventHandler<LotterySrv.GetLowerListDataCompletedEventArgs>(srv_UserList_GetLowerListDataCompleted); srv_UserList.GetLowerListDataByUIDCompleted += new EventHandler<GetLowerListDataByUIDCompletedEventArgs>(srv_UserList_GetLowerListDataByUIDCompleted); BindLowerList(user.ID); TextBlock txtb = new TextBlock() { Text = "本级", Style = Resources["TextBlockStyle1"] as Style, Cursor=Cursors.Hand }; if (user.RoleID == 3) btAddLower.Visibility = Visibility.Collapsed; txtb.Tag = user.ID; BindedLst.Add(user.ID); txtb.MouseLeftButtonDown += new MouseButtonEventHandler(TextBlock_MouseLeftButtonDown); NavMenu.Children.Add(txtb); }
public void StartNewGame(bool isFirstGame) { NextLevel = 1; if (!isFirstGame) { bw.Dispose(); bw2.Dispose(); } Pathing = new Pathing(); Money = new Money(); Level = new Level(); myCreeps = new Creeps(); Player = new Player(); Money.CashChange += Source_CashChange; Player.LifeChange += Source_LifeChange; DisplayMoney = 1000; DisplayLives = 5; NextLevel = 1; ReadyForNextLevel = true; AllTowers = new List<Tower>(); CurrentLevel = 0; // Listener for change money myCreeps.CreepDied += myCreeps_CreepDied; }
public SignatureWindow(string signature) { var digitalSignatureCollection = new List<object>(); digitalSignatureCollection.Add(new ComboBoxItem() { Content = "" }); digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatureCollection.Select(n => new DigitalSignatureComboBoxItem(n)).ToArray()); InitializeComponent(); { var icon = new BitmapImage(); icon.BeginInit(); icon.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read); icon.EndInit(); if (icon.CanFreeze) icon.Freeze(); this.Icon = icon; } _signatureComboBox.ItemsSource = digitalSignatureCollection; for (int index = 0; index < Settings.Instance.Global_DigitalSignatureCollection.Count; index++) { if (Settings.Instance.Global_DigitalSignatureCollection[index].ToString() == signature) { _signatureComboBox.SelectedIndex = index + 1; break; } } }
public Rotation() { } // here for XML deserialization public Rotation(string name, string filler, string execute, params string[] priorities) { Name = name; Filler = filler; Execute = execute; SpellPriority = new List<string>(priorities); }
public ConnectorCreationAdorner(UIElement adornedElement, List<Point> linkPoints) : base(adornedElement) { Debug.Assert(adornedElement != null, "adornedElement is null"); this.IsHitTestVisible = false; this.linkPoints = linkPoints; }
public treeGraph() { InitializeComponent(); AnalyseFuction af; if (Program.curFileNamepath == "C:\\FishGame") { af = new AnalyseFuction("./test.txt"); } else { af = new AnalyseFuction("./calls.txt"); } af.readFile(); pieces = af.getPieceList(); //pieces[1].isHidden = true; //pieces[2].isHidden = true; //pieces[81].isHidden = true; //pieces[61].isHidden = true; // pieces[1].isHighlight = true; tc = new TreeControl(drawingSurface,pieces); //tc.setBranchHidden(86); //tc.setBranchHidden("fillColor"); tc.drawTree(); scrollViewer.ScrollToHorizontalOffset(pieces[0].topLeftCorner.X - this.Width/2 - 75); }
public AppointmentCreate() { InitializeComponent(); List<string> source = new List<string>(); source.Add("Christmas Market"); listPicker.ItemsSource = source; }
public List<IPrimitiveConditionData> GenerateRules(List<TouchPoint2> points) { List<IPrimitiveConditionData> result = new List<IPrimitiveConditionData>(); TouchTime ruleData = new TouchTime(); ruleData.Unit = "secs"; foreach (TouchPoint2 point in points) { if (point.Action == TouchAction.Move) { if (point.Tag == null) { if (point.isFinger) { double length = TrigonometricCalculationHelper.CalculatePathLength(point); if (length >= 5) continue; } } ruleData.Value = point.Age.Seconds; result.Add(ruleData); } } return result; }
void btnChangeLanguage_Click(object sender, RoutedEventArgs e) { try { Window wdw = Window.GetWindow(this); wdw.Cursor = Cursors.Wait; List<JMMServerBinary.Contract_TvDBLanguage> lans = JMMServerVM.Instance.clientBinaryHTTP.GetTvDBLanguages(); List<TvDB_LanguageVM> languages = new List<TvDB_LanguageVM>(); foreach (JMMServerBinary.Contract_TvDBLanguage lan in lans) languages.Add(new TvDB_LanguageVM(lan)); wdw.Cursor = Cursors.Arrow; SelectTvDBLanguage frm = new SelectTvDBLanguage(); frm.Owner = wdw; frm.Init(languages); bool? result = frm.ShowDialog(); if (result.Value) { // update info JMMServerVM.Instance.TvDB_Language = frm.SelectedLanguage; JMMServerVM.Instance.SaveServerSettingsAsync(); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public ValidSetOfPointsCollection Validate(List<TouchPoint2> points) { ValidSetOfPointsCollection sets = new ValidSetOfPointsCollection(); bool result = true; foreach (var point in points) { // TODO: We need to check the unit type (i.e. sec, min,...) and compare accordingly if (_data.Unit.StartsWith("msec")) { if (point.Age.TotalMilliseconds <= _data.Value) result = false; } else if (_data.Unit.StartsWith("sec")) { if (point.Age.TotalSeconds <= _data.Value) result = false; } else { throw new LanguageSyntaxErrorException("Invalid unit for \"TouchTime\" primitive condition!"); } } if (result) sets.Add(new ValidSetOfTouchPoints(points)); return sets; }
public ChildMenu(List<MyChildMenu> childMenus) { InitializeComponent(); this.childMenus = childMenus; if (childMenus.Count != 0) { switch (childMenus[0].mainmenu_num) { case 2:loadMenu(_grid_1); break; case 3: _grid_1.HorizontalAlignment = HorizontalAlignment.Center; loadMenu(_grid_1); break; case 4: _grid_1.HorizontalAlignment = HorizontalAlignment.Right; loadMenu(_grid_1); break; case 5: loadMenu(_grid_2); break; case 6: _grid_2.HorizontalAlignment = HorizontalAlignment.Center; loadMenu(_grid_2); break; case 7: _grid_2.HorizontalAlignment = HorizontalAlignment.Right; loadMenu(_grid_2); break; case 8: _grid_2.HorizontalAlignment = HorizontalAlignment.Right; loadMenu(_grid_2); break; default: break; } } }
public DashboardView() { InitializeComponent(); AndonManager = new AndonManager(StationList, null, Andonmanager.AndonManager.MODE.MASTER); AndonManager.start(); StationList = new Queue<int>(); Plans = new Plans(); PlanGrid.DataContext = Plans; Actuals = new Models.Actuals(); ActualGrid.DataContext = Actuals; AppTimer = new Timer(1000); AppTimer.AutoReset = false; AppTimer.Elapsed += AppTimer_Elapsed; EfficiencyWatch = new Stopwatch(); using (PSBContext DBContext = new PSBContext()) { Shifts = DBContext.Shifts.ToList(); foreach (Shift s in Shifts) { s.Update(); } } AppTimer.Start(); }
public EditDrinksPage() { InitializeComponent(); DataContext = App.ViewModel; Drink TapToAdd = new Drink() { Name = "Tap to add a drink", Size = 0, mg = 0, drinkId = 1, IsActive = false }; Drink AddedDrinks = new Drink() { Name = "------ Added Drinks ------", Size = 0, mg = 0 }; var drinkList = new List<Drink>(App.ViewModel.drinkList); int i; for (i = 0; i < drinkList.Count; i++) { if ((drinkList[i] as Drink).Name == "Tap to add a drink") { var drink = (drinkList[i] as Drink); if (drinkList.Contains(drink)) drinkList.Remove(drink); } else if ((drinkList[i] as Drink).Name == "------ Added Drinks ------") { var drink = (drinkList[i] as Drink); if (drinkList.Contains(drink)) drinkList.Remove(drink); } } drinkList.Remove(TapToAdd); if (drinkList.Contains(AddedDrinks)) drinkList.Remove(AddedDrinks); drinksListBox.ItemsSource = drinkList; }
protected override List<CodeLexem> Parse(SourcePart text) { var list = new List<CodeLexem>(); while (text.Length > 0) { var lenght = text.Length; TryExtract(list, ref text, ByteOrderMark); TryExtract(list, ref text, "[", LexemType.Symbol); TryExtract(list, ref text, "{", LexemType.Symbol); if (TryExtract(list, ref text, "\"", LexemType.Quotes)) { ParseJsonPropertyName(list, ref text); // Extract Name TryExtract(list, ref text, "\"", LexemType.Quotes); TryExtract(list, ref text, ":", LexemType.Symbol); TrySpace(list, ref text); TryExtractValue(list, ref text); // Extract Value } ParseSymbol(list, ref text); // Parse extras TrySpace(list, ref text); TryExtract(list, ref text, "\r\n", LexemType.LineBreak); TryExtract(list, ref text, "\n", LexemType.LineBreak); TryExtract(list, ref text, "}", LexemType.Symbol); TryExtract(list, ref text, "]", LexemType.Symbol); if (lenght == text.Length) break; } return list; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var htmlText = value as string; if (string.IsNullOrWhiteSpace(htmlText)) return value; var splits = Regex.Split(htmlText, "<a "); var result = new List<Inline>(); foreach (var split in splits) { if (!split.StartsWith("href=\"")) { result.AddRange(FormatText(split)); continue; } var match = Regex.Match(split, "^href=\"(?<url>(.+?))\" class=\".+?\">(?<text>(.*?))</a>(?<content>(.*?))$", RegexOptions.Singleline); if (!match.Success) { result.Add(new Run(split)); continue; } var hyperlink = new Hyperlink(new Run(match.Groups["text"].Value)) { NavigateUri = new Uri(match.Groups["url"].Value) }; hyperlink.RequestNavigate += Hyperlink_RequestNavigate; result.Add(hyperlink); result.AddRange(FormatText(match.Groups["content"].Value)); } return result; }
public WPF_Graph() { InitializeComponent(); if (null == VValue) VValue = new List<string>(); this.Loaded += WPF_Graph_Loaded; }
public MetroMultiInterfaceMessageBox(string message, List<string> interfaceStringList) { InitializeComponent(); var dataContext = new { Message = message, InterfaceList = interfaceStringList }; this.DataContext = dataContext; Microsoft.Win32.SystemEvents.DisplaySettingsChanged += new EventHandler(SystemEvents_DisplaySettingsChanged); }
public MainWindow() { InitializeComponent(); IniMyStuff(); txtToday.Text = DateTime.Today.ToShortDateString(); mitatut = new List<MittausData>(); }
/// <summary> /// Tests for Vector3D class /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnVector3D_Click(object sender, RoutedEventArgs e) { System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); txtVector3D.Text = "Starting test suite for the Vektor3D class.\r\n\r\n"; // Sample data List<Eksam.Vektor3D> vectors = new List<Vektor3D>{ new Vektor3D(), new Vektor3D(1,1,1), new Vektor3D(0,-1,0), new Vektor3D(2.2, 1.2, 3.1), new Vektor3D(10,4,3), null }; // Go over all defined operations and input combinations foreach (Vektor3D vector in vectors) { foreach (Vektor3D secondVector in vectors) { txtVector3D.Text += vector + " + " + secondVector + " = " + (vector + secondVector) + "\r\n"; txtVector3D.Text += vector + " - " + secondVector + " = " + (vector - secondVector) + "\r\n"; txtVector3D.Text += vector + " == " + secondVector + " ... " + (vector == secondVector) + "\r\n"; txtVector3D.Text += vector + vector + " (length " + (vector == null ? 0 : vector.Length()) + ") > " + secondVector + " (length " + (secondVector == null ? 0 : secondVector.Length()) + ")" + " ... " + (vector > secondVector) + "\r\n"; txtVector3D.Text += vector + vector + " (length " + (vector == null ? 0 : vector.Length()) + ") < " + secondVector + " (length " + (secondVector == null ? 0 : secondVector.Length()) + ")" + " ... " + (vector < secondVector) + "\r\n"; } } watch.Stop(); double elapsed = watch.ElapsedMilliseconds; txtVector3D.Text += "\r\nTest suite finished, time elapsed: " + elapsed + "ms."; }
public HistoryWindow() { InitializeComponent(); historial = new Historiales(); medic = new Medic(); user = new User(); history = new History(); medics = medic.GetAll(); users = user.GetAll(); histories = history.GetAll(); foreach (Usuarios user in users) { comboUsers.Items.Add(user.nombre + " " + user.apellidos); } foreach (Medicos medic in medics) { comboMedics.Items.Add(medic.nombre + " " + medic.apellidos); } historialGrid.ItemsSource = histories.ToArray(); }
public static List<String> GetSystemDriverList() { List<string> names = new List<string>(); // get system dsn's Microsoft.Win32.RegistryKey reg = (Microsoft.Win32.Registry.LocalMachine).OpenSubKey("Software"); if (reg != null) { reg = reg.OpenSubKey("ODBC"); if (reg != null) { reg = reg.OpenSubKey("ODBCINST.INI"); if (reg != null) { reg = reg.OpenSubKey("ODBC Drivers"); if (reg != null) { // Get all DSN entries defined in DSN_LOC_IN_REGISTRY. foreach (string sName in reg.GetValueNames()) { names.Add(sName); } } try { reg.Close(); } catch { /* ignore this exception if we couldn't close */ } } } } return names; }
private void BindFeatures(List<HalanVersionInfo> products) { foreach( HalanVersionInfo inf in products ) { string title = string.Format("{0} {1}.{2:D2}", inf.Product.Replace("ServiceBusMQManager", "Service Bus MQ Manager"), inf.LatestVersion.Major, inf.LatestVersion.Minor); Paragraph para = new Paragraph(); para.Inlines.Add(new Bold( new Run(title) { FontSize = 19 } )); if( inf.ReleaseDate > DateTime.MinValue ) para.Inlines.Add( new Run(string.Concat(", Released: ", inf.ReleaseDate.ToShortDateString())) ); tbFeatures.Document.Blocks.Add(para); var list = new System.Windows.Documents.List(); foreach( var f in inf.Features ) list.ListItems.Add( new ListItem(new Paragraph(new Run(f))) ); tbFeatures.Document.Blocks.Add(list); if( !_url.IsValid() ) _url = inf.Url; } }
/* Constructor * * Initializes the window and calls the data provider to initialize * airports lists. Creates the autocomplete boxes. In case the connection * to the database is unavailable, displays an information and exits. */ public MainWindow() { SplashScreen splash = new SplashScreen("SplashScreen.png"); splash.Show(true); InitializeComponent(); try { EtosPRODataProvider provider = new EtosPRODataProvider(this); airportsFullList = provider.GetFullAirportsList(); airportCodes = provider.GetAirportsCodesList(); SearchDepartureBox = new AutoCompleteBox(); SearchDepartureBox.FilterMode = AutoCompleteFilterMode.Contains; SearchDepartureBox.ItemsSource = airportsFullList; SearchDeparturePanel.Children.Add(SearchDepartureBox); SearchArrivalBox = new AutoCompleteBox(); SearchArrivalBox.FilterMode = AutoCompleteFilterMode.Contains; SearchArrivalBox.ItemsSource = airportsFullList; SearchArrivalPanel.Children.Add(SearchArrivalBox); } catch (SqlException e) { splash.Close(TimeSpan.Zero); ErrorWindow error = new ErrorWindow("Could not connect to the server! The application will exit.\n\n" + "Verify your connection or contact the developers."); error.Show(); this.Hide(); } splash.Close(TimeSpan.FromSeconds(1)); }
/// <summary> /// 保存单据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void EditForm_Saving(object sender, SavingEventArgs e) { List<string> msgs = new List<string>(); T_FB_SUMSETTINGSMASTER entCurr = this.OrderEntity.Entity as T_FB_SUMSETTINGSMASTER; entCurr.CHECKSTATES = 0; entCurr.EDITSTATES = 1; if (string.IsNullOrWhiteSpace(entCurr.OWNERID) || string.IsNullOrWhiteSpace(entCurr.OWNERNAME)) { msgs.Add("汇总人不能为空"); e.Action = Actions.Cancel; CommonFunction.ShowErrorMessage(msgs); return; } ObservableCollection<FBEntity> details = this.OrderEntity.GetRelationFBEntities(typeof(T_FB_SUMSETTINGSDETAIL).Name); ObservableCollection<FBEntity> list0 = new ObservableCollection<FBEntity>(); //明细为为0的不能提交 if (details.ToList().Count <= 1) { msgs.Add("预算汇总设置中添加的公司至少超过一家"); } if (msgs.Count > 0) { e.Action = Actions.Cancel; CommonFunction.ShowErrorMessage(msgs); } }
private void BindFeatures(List<HalanVersionInfo> products) { foreach( HalanVersionInfo inf in products ) { string v = inf.LatestVersion.ToString(2); Paragraph para = new Paragraph(); para.Inlines.Add(new Bold(new Run(string.Format("{0} v{1}", inf.Product, v)))); if( inf.ReleaseDate > DateTime.MinValue ) para.Inlines.Add( new Run(string.Concat(", Released: ", inf.ReleaseDate.ToShortDateString())) ); tbFeatures.Document.Blocks.Add(para); var list = new System.Windows.Documents.List(); foreach( var f in inf.Features ) list.ListItems.Add( new ListItem(new Paragraph(new Run(f))) ); tbFeatures.Document.Blocks.Add(list); if( !_url.IsValid() ) _url = inf.Url; } }
public override void GetSymbolResourceDictionaryEntriesAsync(GeometryType geometryType, object userState) { if (m_symbolResourceDictionaries != null) { List<SymbolResourceDictionaryEntry> resourceDictionaries = new List<SymbolResourceDictionaryEntry>(); foreach (SymbolResourceDictionaryEntry entry in m_symbolResourceDictionaries) { if (entry.GeometryType == geometryType || (entry.GeometryType == GeometryType.Point && geometryType == GeometryType.MultiPoint)) resourceDictionaries.Add(entry); } OnGetResourceDictionariesCompleted(new GetSymbolResourceDictionaryEntriesCompletedEventArgs() { SymbolResourceDictionaries = resourceDictionaries, UserState = userState }); return; } #region Validation if (ConfigFileUrl == null) { base.OnGetResourceDictionariesFailed(new ExceptionEventArgs(Resources.Strings.ExceptionConfigFileUrlMustBeSpecified, userState)); return; } if (SymbolFolderParentUrl == null) { base.OnGetResourceDictionariesFailed(new ExceptionEventArgs(Resources.Strings.ExceptionSymbolFolderParentUrlMustBeSpecified, userState)); return; } #endregion getSymbolResourceDictionaryEntries(geometryType, userState, (o, e) => { OnGetResourceDictionariesCompleted(e); }, (o, e) => { OnGetResourceDictionariesFailed(e); }); }
public EditAlat(Alat alat) { InitializeComponent(); this.alat = alat; status = new List<KV>(); status.Add(new KV("Baik", 1)); status.Add(new KV("Rusak", 0)); comboBox_Status.ItemsSource = status; comboBox_Status.DisplayMemberPath = "Key"; comboBox_Status.SelectedValuePath = "Value"; comboBox_Status.SelectedValue = (alat.KondisiAlat) ? 1 : 0; textbox_Laboratorium.Text = alat.Lokasi; string query = "SELECT * FROM master_inventory_type"; using (MySqlCommand cmd = new MySqlCommand(query, db.ConnectionManager.Connection)) { try { DataTable dataSet = new DataTable(); using (MySqlDataAdapter dataAdapter = new MySqlDataAdapter(cmd)) { dataAdapter.Fill(dataSet); comboBox_Jenis_Barang.ItemsSource = dataSet.DefaultView; comboBox_Jenis_Barang.DisplayMemberPath = dataSet.Columns["nama"].ToString(); comboBox_Jenis_Barang.SelectedValuePath = dataSet.Columns["id"].ToString(); comboBox_Jenis_Barang.SelectedValue = alat.IdJenis; } } catch (MySql.Data.MySqlClient.MySqlException ex) { MessageBox.Show(ex.Message); } } }
/// <summary> /// добавление правила /// </summary> private void RAdd_Click(object sender, RoutedEventArgs e) { if (RIf.Text.Length > 0 && RThen.SelectedItem != null) { List<Fact> fl = new List<Fact>(); string s = RIf.Text; string[] t = s.Split('&'); foreach (string k in t) { fl.Add(knowlegeBase.Facts.Find(x => x.Title == k)); } Conclusion c = new Conclusion(); c.Title = RThen.SelectedItem.ToString(); ////////формирование строки string rule = string.Empty; rule += "IF ("; foreach (var fact in fl) { rule += fact + "&"; } rule = rule.Substring(0, rule.Length - 1); rule += ") THEN " + c; //////// knowlegeBase.RulesViews.Add(rule); XMLDataLoader.Serialize(knowlegeBase); Load_CB(); FQ.Clear(); } }
public List(ListTypes type) { switch (type) { case ListTypes.None: internalList = new System.Windows.Documents.List(); break; case ListTypes.Unordered: internalList = new UnorderedList(); break; } this.InitializeComponent(); this.Blocks.Add(internalList); }
public void Accept_HyperlinkInLists_AllHyperlinksFound() { var document = new FlowDocument(); var list = new List(); list.ListItems.Add(new ListItem(new Paragraph(new Hyperlink(new Run("http://github.com"))))); list.ListItems.Add(new ListItem(new Paragraph(new Hyperlink(new Run("http://github.com"))))); list.ListItems.Add(new ListItem(new Paragraph(new Hyperlink(new Run("http://github.com"))))); document.Blocks.Add(list); var visitor = new FlowDocumentVisitor(e => e is Hyperlink) { ContinueAfterMatch = true }; visitor.Accept(document); Assert.That(visitor.Results.OfType <Hyperlink>().Count(), Is.EqualTo(3)); }
private void BindFeatures(List <HalanVersionInfo> products) { foreach (HalanVersionInfo inf in products) { string title = string.Format("{0} {1}.{2:D2}", inf.Product.Replace("ServiceBusMQManager", "Service Bus MQ Manager"), inf.LatestVersion.Major, inf.LatestVersion.Minor); Paragraph para = new Paragraph(); para.Inlines.Add(new Bold( new Run(title) { FontSize = 19 })); if (inf.ReleaseDate > DateTime.MinValue) { para.Inlines.Add(new Run(string.Concat(", Released: ", inf.ReleaseDate.ToShortDateString()))); } tbFeatures.Document.Blocks.Add(para); var list = new System.Windows.Documents.List(); foreach (var f in inf.Features) { list.ListItems.Add(new ListItem(new Paragraph(new Run(f)))); } tbFeatures.Document.Blocks.Add(list); if (!_url.IsValid()) { _url = inf.Url; } } }
/// <summary> /// Adds the see also section for the calling element. /// </summary> /// <param name="parsedBlocks">The parsed comments block for the element.</param> /// <remarks> /// The <paramref name="parsedBlocks"/> should contain any and all parsed comments /// for the calling element. This method will throw the list to the Parser and /// then output the seealso comment elements to a list. /// </remarks> protected void AddSeeAlso(List <Block> parsedBlocks) { List <SeeAlso> seeAlsoList = Parser.ParseElement <SeeAlso>(parsedBlocks); if (seeAlsoList.Count > 0) { SeeAlsoList seeAlso = new SeeAlsoList(); seeAlso.Blocks.Add(new Header2("See Also")); System.Windows.Documents.List displayList = new System.Windows.Documents.List(); foreach (SeeAlso currentSeeAlso in seeAlsoList) { if (currentSeeAlso.IsEnabled) { displayList.ListItems.Add(new ListItem(new Paragraph(currentSeeAlso.Clone()))); } else { displayList.ListItems.Add(new ListItem(new Paragraph(new Run(currentSeeAlso.Name)))); } } seeAlso.Blocks.Add(displayList); this.Blocks.Add(seeAlso); } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.userImageCircle = ((System.Windows.Controls.Image)(target)); return; case 2: this.userName = ((System.Windows.Controls.Expander)(target)); return; case 3: this.TabControl = ((System.Windows.Controls.TabControl)(target)); return; case 4: this.UserImage = ((System.Windows.Controls.Image)(target)); return; case 5: #line 83 "..\..\CareGiverProfile.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnChangePersonalInfo_Click); #line default #line hidden return; case 6: this.FName = ((System.Windows.Controls.TextBlock)(target)); return; case 7: this.LastName = ((System.Windows.Controls.TextBlock)(target)); return; case 8: this.Age = ((System.Windows.Controls.TextBlock)(target)); return; case 9: this.Email = ((System.Windows.Controls.TextBlock)(target)); return; case 10: #line 130 "..\..\CareGiverProfile.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnAddPhoto_Click); #line default #line hidden return; case 11: #line 144 "..\..\CareGiverProfile.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnChangeACC_Click); #line default #line hidden return; case 12: this.AddressCityCountry = ((System.Windows.Controls.TextBlock)(target)); return; case 13: #line 159 "..\..\CareGiverProfile.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnAnoutMe_Click); #line default #line hidden return; case 14: this.AboutMeBox = ((System.Windows.Controls.TextBlock)(target)); return; case 15: this.JobsBox = ((System.Windows.Controls.FlowDocumentReader)(target)); return; case 16: this.jobList = ((System.Windows.Documents.List)(target)); return; } this._contentLoaded = true; }
/// <summary> /// Renders DOM text elements recursively, i.e. including their childs. /// </summary> /// <param name="e">The root DOM text element.</param> /// <returns>The corresponding Wpf element.</returns> /// <exception cref="System.InvalidOperationException"> /// </exception> /// <exception cref="System.NotImplementedException"></exception> public object RenderRecursively(TextElement e) { object wpf = null; switch (e) { case BlockUIContainer buc: { wpf = new swd.BlockUIContainer(); } break; case FlowDocument flowDocument: { // make sure the standard colors were set flowDocument.Foreground = ExCSS.Color.Black; flowDocument.Background = ExCSS.Color.White; var flowDocumente = new swd.FlowDocument() { Name = NameOfFlowDocument }; if (TemplateBindingViewportWidth is null) { TemplateBindingViewportWidth = new Binding("ColumnWidth") { Source = flowDocumente } } ; if (TemplateBindingViewportHeight is null) { TemplateBindingViewportHeight = new Binding("ColumnWidth") { Source = flowDocumente } } ; // Binding to ColumnWidth is not optimal, but better than nothing! if (flowDocument.Background.HasValue) { flowDocumente.Background = GetBrushFromColor(flowDocument.Background.Value); } if (flowDocument.Foreground.HasValue) { flowDocumente.Foreground = GetBrushFromColor(flowDocument.Foreground.Value); } wpf = flowDocumente; } break; case Hyperlink hl: { var hle = new swd.Hyperlink(); if (!string.IsNullOrEmpty(hl.NavigateUri)) { if (System.Uri.TryCreate(hl.NavigateUri, UriKind.RelativeOrAbsolute, out var uri)) { hle.NavigateUri = uri; } } if (!string.IsNullOrEmpty(hl.TargetName)) { hle.TargetName = hl.TargetName; } wpf = hle; } break; case Image image: { var imagee = new System.Windows.Controls.Image(); if (!string.IsNullOrEmpty(image.Source)) { imagee.SetBinding(System.Windows.Controls.Image.SourceProperty, $"ImageProvider[{image.Source}]"); } if (image.Width == null && image.Height == null) { imagee.Stretch = System.Windows.Media.Stretch.Uniform; var binding = new Binding() { RelativeSource = RelativeSource.Self, Path = new System.Windows.PropertyPath("Source") }; binding.Converter = ImageToImageWidthConverter.Instance; imagee.SetBinding(System.Windows.Controls.Image.WidthProperty, binding); } else { imagee.Stretch = System.Windows.Media.Stretch.Uniform; } if (image.Width != null) { if (image.Width.IsPurelyAbsolute(out var widthPx)) { imagee.Width = widthPx; } else { var multibinding = new MultiBinding(); multibinding.Bindings.Add(new Binding() { Source = TemplateBindingViewportWidth.Source, Path = TemplateBindingViewportWidth.Path }); multibinding.Bindings.Add(new Binding() { Source = TemplateBindingViewportHeight.Source, Path = TemplateBindingViewportHeight.Path }); multibinding.Converter = CompoundLengthConverter.Instance; multibinding.ConverterParameter = GetCompoundLengthConverterParameters(image.Width); imagee.SetBinding(System.Windows.Controls.Image.WidthProperty, multibinding); } } if (image.Height != null) { if (image.Height.IsPurelyAbsolute(out var heightPx)) { imagee.Height = heightPx; } else { var multibinding = new MultiBinding(); multibinding.Bindings.Add(new Binding() { Source = TemplateBindingViewportWidth.Source, Path = TemplateBindingViewportWidth.Path }); multibinding.Bindings.Add(new Binding() { Source = TemplateBindingViewportHeight.Source, Path = TemplateBindingViewportHeight.Path }); multibinding.Converter = CompoundLengthConverter.Instance; multibinding.ConverterParameter = GetCompoundLengthConverterParameters(image.Height); imagee.SetBinding(System.Windows.Controls.Image.HeightProperty, multibinding); } } // set max-width and max-height if (image.MaxWidth != null && image.MaxWidth.Value.IsAbsolute) { imagee.MaxWidth = image.MaxWidth.Value.ToPixel(); } else if (image.MaxWidth == null || image.MaxWidth.Value.Type == ExCSS.Length.Unit.Vw) { double vwValue = image.MaxWidth.HasValue ? image.MaxWidth.Value.Value : 100; var binding = new Binding() { Source = TemplateBindingViewportWidth.Source, Path = TemplateBindingViewportWidth.Path }; binding.Converter = RelativeSizeConverter.Instance; binding.ConverterParameter = vwValue; imagee.SetBinding(System.Windows.Controls.Image.MaxWidthProperty, binding); } else { throw new InvalidProgramException(); } if (image.MaxHeight != null && image.MaxHeight.Value.IsAbsolute) { imagee.MaxHeight = image.MaxHeight.Value.ToPixel(); } else if (image.MaxHeight == null || image.MaxHeight.Value.Type == ExCSS.Length.Unit.Vh) { double vhValue = image.MaxHeight.HasValue ? image.MaxHeight.Value.Value : 100; var binding = new Binding() { Source = TemplateBindingViewportWidth.Source, Path = TemplateBindingViewportWidth.Path }; binding.Converter = RelativeSizeConverter.Instance; binding.ConverterParameter = vhValue; imagee.SetBinding(System.Windows.Controls.Image.MaxHeightProperty, binding); } else { throw new InvalidProgramException(); } wpf = imagee; } break; case InlineUIContainer iuc: { var inlineuiContainere = new swd.InlineUIContainer(); wpf = inlineuiContainere; } break; case LineBreak lb: { wpf = new swd.LineBreak(); } break; case List list: { var liste = new swd.List(); if (list.MarkerStyle.HasValue) { liste.MarkerStyle = ToMarkerStyle(list.MarkerStyle.Value); } wpf = liste; } break; case ListItem li: { wpf = new swd.ListItem(); } break; case Paragraph p: { var pe = new swd.Paragraph(); if (p.TextDecorations.HasValue) { pe.TextDecorations = ToTextDecorations(p.TextDecorations.Value); } if (p.TextIndent.HasValue) { pe.TextIndent = p.TextIndent.Value.IsAbsolute ? p.TextIndent.Value.ToPixel() : 0; } wpf = pe; } break; case Run run: { if (SplitIntoWords) { wpf = CreateTextElement_SeparateWords(run.Text); } else if (SplitIntoSentences) { wpf = CreateTextElement_SeparateSentences(run.Text); } else { wpf = new swd.Run(run.Text); } } break; case Section s: { wpf = new swd.Section(); } break; case Span span: { wpf = new swd.Span(); } break; case Table tb: { var tbe = new swd.Table(); foreach (var c in tb.Columns) { if (c.Width.HasValue) { tbe.Columns.Add(new swd.TableColumn() { Width = new System.Windows.GridLength(c.Width.Value) }); } else { tbe.Columns.Add(new swd.TableColumn()); } } wpf = tbe; } break; case TableCell tc: { var tce = new swd.TableCell(); if (1 != tc.ColumnSpan) { tce.ColumnSpan = tc.ColumnSpan; } if (1 != tc.RowSpan) { tce.RowSpan = tc.RowSpan; } if (tc.BorderBrush.HasValue) { tce.BorderBrush = new System.Windows.Media.SolidColorBrush(ToColor(tc.BorderBrush.Value)); } if (tc.BorderThickness.HasValue) { tce.BorderThickness = ToThickness(tc.BorderThickness.Value); } wpf = tce; } break; case TableRow trow: { wpf = new swd.TableRow(); } break; case TableRowGroup trg: { wpf = new swd.TableRowGroup(); } break; default: { wpf = null; } break; } // Render TextElement properties if (wpf is swd.TextElement te) { if (!string.IsNullOrEmpty(e.FontFamily)) { te.FontFamily = GetFontFamily(e.FontFamily); } if (e.FontSize.HasValue) { var fs = e.FontSize.Value; fs = Math.Max(0.004, fs); te.FontSize = fs; } if (e.FontStyle.HasValue) { te.FontStyle = ToFontStyle(e.FontStyle.Value); } if (e.FontWeight.HasValue) { te.FontWeight = ToFontWeight(e.FontWeight.Value); } if (e.Foreground.HasValue && e.Foreground != e.ForegroundInheritedOnly) { te.Foreground = GetBrushFromColor(e.Foreground.Value); } if (e.Background.HasValue && e.Background != e.BackgroundInheritedOnly) { te.Background = GetBrushFromColor(e.Background.Value); } } // now special properties if (e is Block b && wpf is swd.Block be) { if (b.Margin.HasValue) { be.Margin = ToThickness(b.Margin.Value); } if (b.Padding.HasValue) { be.Padding = ToThickness(b.Padding.Value); } if (b.BorderBrush.HasValue) { be.BorderBrush = new System.Windows.Media.SolidColorBrush(ToColor(b.BorderBrush.Value)); } if (b.BorderThickness.HasValue) { be.BorderThickness = ToThickness(b.BorderThickness.Value); } if (b.TextAlignment.HasValue) { be.TextAlignment = ToTextAlignment(b.TextAlignment.Value); } if (b.LineHeight.HasValue) { be.LineHeight = b.LineHeight.Value; } } if (e is Inline i && wpf is swd.Inline ie) { if (i.VerticalAlignment.HasValue) { ie.BaselineAlignment = ToBaselineAlignment(i.VerticalAlignment.Value); } } // finished rendering the attributes // now, render all children foreach (var child in e.Childs) { var childe = RenderRecursively(child); switch (wpf) { case swd.Figure figure: figure.Blocks.Add((swd.Block)childe); break; case swd.Floater floater: floater.Blocks.Add((swd.Block)childe); break; case swd.FlowDocument flowDocument: flowDocument.Blocks.Add((swd.Block)childe); break; case swd.List list: list.ListItems.Add((swd.ListItem)childe); break; case swd.ListItem listItem: listItem.Blocks.Add((swd.Block)childe); break; case swd.Section section: section.Blocks.Add((swd.Block)childe); break; case swd.Table table: table.RowGroups.Add((swd.TableRowGroup)childe); break; case swd.TableCell tableCell: tableCell.Blocks.Add((swd.Block)childe); break; case swd.TableRow tableRow: tableRow.Cells.Add((swd.TableCell)childe); break; case swd.TableRowGroup tableRowGroup: tableRowGroup.Rows.Add((swd.TableRow)childe); break; // now elements that can contain inlines case swd.Paragraph paragraph: paragraph.Inlines.Add((swd.Inline)childe); break; case swd.Span span: span.Inlines.Add((swd.Inline)childe); break; // now some specialties case swd.InlineUIContainer inlineUIContainer: if (inlineUIContainer.Child != null) { throw new InvalidOperationException($"{nameof(swd.InlineUIContainer)} can not contain more than one child"); } inlineUIContainer.Child = (System.Windows.UIElement)childe; break; case swd.BlockUIContainer blockUIContainer: if (blockUIContainer.Child != null) { throw new InvalidOperationException($"{nameof(swd.BlockUIContainer)} can not contain more than one child"); } blockUIContainer.Child = (System.Windows.UIElement)childe; break; default: throw new NotImplementedException(); } } if (AttachDomAsTags) { if (wpf is System.Windows.FrameworkContentElement conEle) { conEle.Tag = e; } else if (wpf is System.Windows.FrameworkElement uiEle) { uiEle.Tag = e; } } return(wpf); }
public override DependencyObject Visit(Documentation.List list) { if (list.Type == ListType.Table) { var result = new Table(); result.Columns.Add(new TableColumn() { Width = new GridLength(1, GridUnitType.Star) }); result.Columns.Add(new TableColumn() { Width = new GridLength(3, GridUnitType.Star) }); result.RowGroups.Add(new TableRowGroup()); var header = new TableRow(); var termHeader = new TableCell(); if (list.Header?.Term.Count > 0) { termHeader.Blocks.AddRange(GetBlocks(list.Header?.Term.Select(e => e.Visit(this)))); } else { termHeader.Blocks.Add(new System.Windows.Documents.Paragraph(new Run("Term") { FontWeight = FontWeight.FromOpenTypeWeight(700) })); } header.Cells.Add(termHeader); var descripHeader = new TableCell(); if (list.Header?.Description.Count > 0) { descripHeader.Blocks.AddRange(GetBlocks(list.Header?.Description.Select(e => e.Visit(this)))); } else { descripHeader.Blocks.Add(new System.Windows.Documents.Paragraph(new Run("Description") { FontWeight = FontWeight.FromOpenTypeWeight(700) })); } header.Cells.Add(descripHeader); result.RowGroups[0].Rows.Add(header); foreach (var item in list.Children) { var row = new TableRow(); row.Cells.Add(new TableCell()); row.Cells.Add(new TableCell()); if (item.Term.Count > 0) { row.Cells[0].Blocks.AddRange(GetBlocks(item.Term.Select(e => e.Visit(this)))); } if (item.Description.Count > 0) { row.Cells[1].Blocks.AddRange(GetBlocks(item.Description.Select(e => e.Visit(this)))); } result.RowGroups[0].Rows.Add(row); } return(result); } else { var result = new System.Windows.Documents.List { MarkerStyle = list.Type == ListType.Number ? TextMarkerStyle.Decimal : TextMarkerStyle.Disc }; if (_listLevel > 0) { result.Margin = new Thickness(0); } try { _listLevel++; result.ListItems.AddRange(list.Children.Select(i => { var item = new System.Windows.Documents.ListItem(); item.Blocks.AddRange(GetBlocks(i.Description.Select(e => e.Visit(this)))); return(item); })); return(result); } finally { _listLevel--; } } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.userImage = ((System.Windows.Controls.Image)(target)); return; case 2: this.FName = ((System.Windows.Controls.TextBox)(target)); #line 76 "..\..\ClientProfile.xaml" this.FName.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.FNameText_TextChanged); #line default #line hidden return; case 3: this.LName = ((System.Windows.Controls.TextBox)(target)); #line 77 "..\..\ClientProfile.xaml" this.LName.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.LNameText_TextChanged); #line default #line hidden return; case 4: this.Age = ((System.Windows.Controls.TextBox)(target)); #line 78 "..\..\ClientProfile.xaml" this.Age.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.AgeText_TextChanged); #line default #line hidden return; case 5: this.Email = ((System.Windows.Controls.TextBox)(target)); #line 79 "..\..\ClientProfile.xaml" this.Email.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.EmailText_TextChanged); #line default #line hidden return; case 6: #line 92 "..\..\ClientProfile.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnAddPhoto_Click); #line default #line hidden return; case 7: #line 106 "..\..\ClientProfile.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnChangeACC_Click); #line default #line hidden return; case 8: this.AddressCityCountry = ((System.Windows.Controls.TextBox)(target)); return; case 9: this.AboutMeBox = ((System.Windows.Controls.TextBox)(target)); #line 124 "..\..\ClientProfile.xaml" this.AboutMeBox.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.AboutMeBox_TextChanged); #line default #line hidden return; case 10: this.JobsBox = ((System.Windows.Controls.FlowDocumentReader)(target)); return; case 11: this.jobList = ((System.Windows.Documents.List)(target)); return; case 12: #line 142 "..\..\ClientProfile.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnAddJob_Click); #line default #line hidden return; case 13: #line 143 "..\..\ClientProfile.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnSave_Click); #line default #line hidden return; case 14: #line 144 "..\..\ClientProfile.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnOk_Click); #line default #line hidden return; } this._contentLoaded = true; }
public Action AddToFlowDocument(IResumeDataObject rdo, IResumeFormatObject rfo, Win.FlowDocument flowDoc) { return(() => { var list = new List <Win.Block>(); // "Experience" header Win.Paragraph expTitlePara = new Win.Paragraph(); expTitlePara.Inlines.Add(new Win.Run("Experience")); expTitlePara.Margin = new System.Windows.Thickness(0, 20, 0, 20); expTitlePara.Foreground = rfo.HeaderColorBrush; expTitlePara.FontFamily = new FontFamily(rfo.HeaderFontName); expTitlePara.FontSize = rfo.HeaderFontSizeWindows; expTitlePara.Margin = rfo.HeaderMargin; list.Add(expTitlePara); for (int i = 0; i < rdo.ExperienceEntities.Count; i++) { var expItem = rdo.ExperienceEntities[i]; // Employer Name Win.Paragraph empName = new Win.Paragraph(new Win.Run(expItem.Employer)); empName.Foreground = rfo.JobInfoColorBrush; empName.FontFamily = new FontFamily(rfo.JobInfoFontName); empName.FontSize = rfo.JobInfoFontSizeWindows; list.Add(empName); // Title Win.Paragraph title = new Win.Paragraph(new Win.Run(expItem.Titles.FirstOrDefault())); title.Foreground = rfo.JobInfoColorBrush; title.FontFamily = new FontFamily(rfo.JobInfoFontName); title.FontSize = rfo.JobInfoFontSizeWindows; list.Add(title); // Dates Win.Paragraph dates = new Win.Paragraph(new Win.Run(expItem.StartDate + " - " + expItem.EndDate)); dates.Foreground = rfo.JobInfoColorBrush; dates.FontFamily = new FontFamily(rfo.JobInfoFontName); dates.FontSize = rfo.JobInfoFontSizeWindows; list.Add(dates); // List of experience items Win.List bullets = new Win.List(); for (int j = 0; j < rdo.ExperienceEntities[i].Details.Count; j++) { var item = new Win.ListItem(new Win.Paragraph(new Win.Run(rdo.ExperienceEntities[i].Details[j]))); bullets.ListItems.Add(item); item.FontFamily = new FontFamily(rfo.BodyFontName); item.FontSize = rfo.BodyFontSizeWindows; bullets.Margin = bulletMargin; list.Add(bullets); } } foreach (var item in list) { flowDoc.Blocks.Add(item); } }); }