Silverlight之控件应用总结(二)(4)
接着上篇继续
1.1. Label
<sdk:Label Height="28" HorizontalAlignment="Left" Margin="122,46,0,0"Name="label1"VerticalAlignment="Top" Width="120" />
1.2. ListBox
前台代码:
<!--SelectionMode属性确定用户一次可以选择多少个项。可以将此属性设置为 Single(默认值)、Multiple或Extended。下表描述了这些枚举值的行为。
Single
用户一次只能选择一项。
Multiple
用户可以选择多个项而无需按下修改键。
Extended
用户可以按下 Shift键来选择多个连续项,或按下 Ctrl键并单击项来选择多个不连续的项。-->
<ListBox Height="278" ItemsSource="{Binding}" HorizontalAlignment="Left" Margin="116,130,0,0"Name="listBox1"VerticalAlignment="Top" Width="328" SelectionChanged="listBox1_SelectionChanged">
</ListBox>
后台代码:
public ListBoxP()
{
InitializeComponent();
List<string> lst =new List<string>();
for (int i = 0; i< 100; i++)
{
lst.Add("张三" + i.ToString());
}
this.listBox1.ItemsSource = lst;
}
private voidlistBox1_SelectionChanged(object sender,SelectionChangedEventArgs e)
{
MessageBox.Show(this.listBox1.SelectedItem.ToString());
}
1.3. MediaElement
前台代码:
<MediaElement Source="Media/九阴真经.wmv" AutoPlay="True" Height="244" HorizontalAlignment="Left"Margin="109,45,0,0" Name="mediaElement1"VerticalAlignment="Top" Width="420" />
后台代码:
// MediaElement.Play() -播放视频
// MediaElement.Pause() -暂停视频
// MediaElement.Stop() -停止视频
// MediaElement.IsMuted -是否静音
// MediaElement.Volume -声音大小(0 - 1)
1.4. MultiScaleImage
1.5. OpenFileDialog
后台代码:
OpenFileDialogo =new OpenFileDialog();
o.Multiselect = true;
o.Filter = "文本文件|*.txt|所有文件|*.*";
o.ShowDialog();
1.6. Page
1.7. PasswordBox
<PasswordBox Password="123"PasswordChar="*" Height="23"HorizontalAlignment="Left"Margin="140,157,0,0" Name="passwordBox1"VerticalAlignment="Top" Width="120" />
1.8. Popup
//HtmlPopupWindowOptions - 需要弹出的新窗口的参数(如果浏览器是以标签的形式打开新窗口,则此参数无效)
HtmlPopupWindowOptions opt =new HtmlPopupWindowOptions();
opt.Left = 0;
opt.Top= 0;
opt.Width = 320;
opt.Height = 240;
// HtmlPage.IsPopupWindowAllowed -指定Silverlight 宿主是否可以使用 HtmlPage.PopupWindow()来弹出新的浏览器窗口
// HtmlPage.PopupWindow() -弹出新窗口
if (true ==HtmlPage.IsPopupWindowAllowed)
HtmlPage.PopupWindow(newUri("http://www.baidu.com/",UriKind.Absolute), "newWindow",opt);
1.9. ProgressBar
前台代码:
<ProgressBar Height="24" HorizontalAlignment="Left" Margin="134,225,0,0" Name="progressBar1"VerticalAlignment="Top" Width="314"/>
后台代码:
this.progressBar1.Maximum= 10000;
this.progressBar1.Minimum = 0;
for (int i = 0; i< 10000; i++)
{
this.progressBar1.Value += i;
}
1.10. RadioButton
前台代码:
<RadioButton Content="男" Height="16" IsChecked="True" HorizontalAlignment="Left"Margin="136,82,0,0" Name="radioButton1" VerticalAlignment="Top" />
<RadioButton Content="女" Height="16" HorizontalAlignment="Left" Margin="136,104,0,0"Name="radioButton2" VerticalAlignment="Top" />
1.11. RepeatButton
类似Button
1.12. RichTextBox
前台代码:
<RichTextBox HorizontalAlignment="Left" DataContext="123" Margin="222,47,0,0" Name="richTextBox1"VerticalAlignment="Top" Height="114" Width="250" />
后台代码:
在Silverlight4版本中,RichTextBox这个控件算是很受期待的控件了,希望通过这篇文章让你对该控件有所了解。
在Sl中,有TextBox,TextBlock,RichTextBox这3个核心的文本控件,从表面上看,RichTextBox看起来和一个普通的TextBox并没有太多的区别,实际上它提供了诸如格式化文本,段落,超链接,内联图像这些功能,它甚至可以显示任何UIElement,比如DataGrid。
MSDN有关于RichTextBox内容模型的一个关系图
RichTextBox的内容属性是Blocks,这是一个Paragraph的集合,这些Paragraph可以包含Inline元素派生的元素。比如Run,
Span,Bold,Italic,Hyperlink,InlineUIContainer,其实从图中你可能会注意到Hyperlink比较特殊,它不能包含其它Inline类型的元素。
下面熟悉RichTextBox中一些简单的属性:
添加RichTextBox:
1. <RichTextBox AcceptsReturn="True"x:Name="rbtMyRichTextBox">
<RichTextBoxAcceptsReturn="True" x:Name="rbtMyRichTextBox">
RichTextBox常用的属性包括AcceptReturn和IsReadOnly属性,只有在只读模式下,UI元素才是可用的。
添加元素:前面已经提到,RichTextBox包含了Paragraph集合,所以我们可以轻易添加任何内联元素,那么这里我们看一看在一个Paragraph中添加多个元素的Code
1. Paragraph prgParagraph =newParagraph();
2. Run rnMyText =new Run();
3. rnMyText.Text ="Thisis some example text with a ";
4. prgParagraph.Inlines.Add(rnMyText);
5. Hyperlink lnkSSLink =newHyperlink();
6. lnkSSLink.Inlines.Add("linkto Silverlight Show");
7. lnkSSLink.NavigateUri =new Uri("http://www.baidu.com");
8. prgParagraph.Inlines.Add(lnkSSLink);
9. rbtMyRichTextBox.Blocks.Add(prgParagraph);
ParagraphprgParagraph = new Paragraph();
Run rnMyText = newRun();
rnMyText.Text ="This is some example text with a ";
prgParagraph.Inlines.Add(rnMyText);
Hyperlink lnkSSLink= new Hyperlink();
lnkSSLink.Inlines.Add("linkto Silverlight Show");
lnkSSLink.NavigateUri= new Uri("http://www.mrtcode.com");
prgParagraph.Inlines.Add(lnkSSLink);
rbtMyRichTextBox.Blocks.Add(prgParagraph);
上面的代码中,添加了一些文本和一个超链接,那么首先要做的是实例化一个Paragraph,在这个Paragraph中,我们添加了文本和超链接,这些对象被添加到该Paragraph中的Inlines集合中,最后将这个Paragraph添加到了RichTextBox中
格式文本对象:Run元素只能包含非格式化的文本,如果想要对文本进行格式化,那么可以采用变通的方式,即将Run元素包含在内联的格式元素中
1. Paragraph prgParagraph =newParagraph();
2. Bold bldText =new Bold();
3. bldText.Inlines.Add(new Run() {Text = "This is some example text in bold" });
4. Italic itlText =new Italic();
5. itlText.Inlines.Add(new Run() {Text = "This is some example text in italics" });
6. Underline unText =newUnderline();
7. unText.Inlines.Add(new Run() {Text = "This is some example text, underlined" });
8. Bold bldTextWithItalic =new Bold();
9. bldTextWithItalic.Inlines.Add(new Italic(){ Inlines = { new Run(){Text ="This is some example text, bold and italic" } } });
10. prgParagraph.Inlines.Add(bldText);
11. prgParagraph.Inlines.Add(newLineBreak());
12. prgParagraph.Inlines.Add(itlText);
13. prgParagraph.Inlines.Add(newLineBreak());
14. prgParagraph.Inlines.Add(unText);
15. prgParagraph.Inlines.Add(newLineBreak());
16. prgParagraph.Inlines.Add(bldTextWithItalic);
17. rbtMyRichTextBox.Blocks.Add(prgParagraph);
ParagraphprgParagraph = new Paragraph();
Bold bldText = newBold();
bldText.Inlines.Add(newRun() { Text = "This is some example text in bold" });
Italic itlText =new Italic();
itlText.Inlines.Add(newRun() { Text = "This is some example text in italics" });
Underline unText =new Underline();
unText.Inlines.Add(newRun() { Text = "This is some example text, underlined" });
BoldbldTextWithItalic = new Bold();
bldTextWithItalic.Inlines.Add(newItalic() { Inlines = { new Run(){ Text = "This is some example text, boldand italic" } } });
prgParagraph.Inlines.Add(bldText);
prgParagraph.Inlines.Add(newLineBreak());
prgParagraph.Inlines.Add(itlText);
prgParagraph.Inlines.Add(newLineBreak());
prgParagraph.Inlines.Add(unText);
prgParagraph.Inlines.Add(newLineBreak());
prgParagraph.Inlines.Add(bldTextWithItalic);
rbtMyRichTextBox.Blocks.Add(prgParagraph);
上面的代码分别实现了文本的加粗,倾斜,下滑线功能,和添加元素的代码没有太大区别。
添加InlineUIContainer:顾名思义,这个元素就是UI元素的容器,当我们想要在内容中添加Image,DataGrid这些元素的时候,它非常的方便,步骤也是和其它内联元素一样的。先创建一个InlineUIContainer,然后在容器中添加UIElement,把这个容器添加到Paragraph中
1. InlineUIContainer iuicContainer =newInlineUIContainer();
2. DataGrid dtgGrid =newDataGrid();
3. dtgGrid.AutoGenerateColumns =true;
4. dtgGrid.Width = 400;
5. dtgGrid.Height = 200;
6. dtgGrid.ItemsSource = ...
7. iuicContainer.Child = dtgGrid;
8. Paragraph prgParagraph =newParagraph();
9. prgParagraph.Inlines.Add(iuicContainer);
10. rbtMyRichTextBox.Blocks.Add(prgParagraph);
InlineUIContaineriuicContainer = new InlineUIContainer();
DataGrid dtgGrid =new DataGrid();
dtgGrid.AutoGenerateColumns= true;
dtgGrid.Width =400;
dtgGrid.Height =200;
dtgGrid.ItemsSource= ...
iuicContainer.Child= dtgGrid;
ParagraphprgParagraph = new Paragraph();
prgParagraph.Inlines.Add(iuicContainer);
rbtMyRichTextBox.Blocks.Add(prgParagraph);
上面的CODE如果改成XAML声明:
1. <RichTextBox AcceptsReturn="True"
2. Margin="5"
3. x:Name="rbtMyRichTextBox">
4. <Paragraph>
5. <InlineUIContainer>
6. <Image Source="Assets/logo.png" Width="100"></Image>
7. </InlineUIContainer>
8. </Paragraph>
9. </RichTextBox>
<RichTextBoxAcceptsReturn="True"
Margin="5"
x:Name="rbtMyRichTextBox">
<Paragraph>
<InlineUIContainer>
<ImageSource="Assets/logo.png" Width="100"></Image>
</InlineUIContainer>
</Paragraph>
</RichTextBox>
通过上面的内容已经对RichTextBox有了基本的了解,其实之前我们都是通过编程的方式加入这些元素,但是更为常见的场景是用户可以通过选择某些文本,并对选中的文本进行加粗等操作,RichTextBox提供了一个类型为TextSelection的Selection属性,它包含了当前被选择的文本,然后我们可以通过GetPropertyValue和ApplyPropertyValue方法对选择的文本进行操作。
操作Selection:
1. if(rbtMyRichTextBox !=null&& rbtMyRichTextBox.Selection.Text.Length > 0)
2. {
3. if (rbtMyRichTextBox.Selection.GetPropertyValue(Run.FontWeightProperty)is FontWeight
4. &&((FontWeight)rbtMyRichTextBox.Selection.GetPropertyValue(Run.FontWeightProperty))== FontWeights.Normal)
5. {
6. rbtMyRichTextBox.Selection.ApplyPropertyValue(Run.FontWeightProperty,FontWeights.Bold);
7. }
8. else
9. {
10. rbtMyRichTextBox.Selection.ApplyPropertyValue(Run.FontWeightProperty,FontWeights.Normal);
11. }
12. }
13. if(rbtMyRichTextBox !=null)
14. {
15. rbtMyRichTextBox.Focus();
16. }
if (rbtMyRichTextBox !=null && rbtMyRichTextBox.Selection.Text.Length > 0)
{
if(rbtMyRichTextBox.Selection.GetPropertyValue(Run.FontWeightProperty) isFontWeight
&&((FontWeight)rbtMyRichTextBox.Selection.GetPropertyValue(Run.FontWeightProperty))== FontWeights.Normal)
{
rbtMyRichTextBox.Selection.ApplyPropertyValue(Run.FontWeightProperty,FontWeights.Bold);
}
else
{
rbtMyRichTextBox.Selection.ApplyPropertyValue(Run.FontWeightProperty,FontWeights.Normal);
}
}
if (rbtMyRichTextBox != null)
{
rbtMyRichTextBox.Focus();
}
上面的代码中,我们获取了选中文本的FontWeight属性,通过检查它是Normal还是Bold改变其值,这里的逻辑也可以用在 FontSize等其它的属性上。
简单的复制,剪切,粘贴功能:Sl4支持Clipboard功能,所以通过访问Clipboard我们可以很容易实现剪切,复制功能。
1. privatevoidCopy_Click(object sender, RoutedEventArgs e)
2. {
3. Clipboard.SetText(rbtMyRichTextBox.Selection.Text);
4. rbtMyRichTextBox.Focus();
5. }
6. privatevoidCut_Click(object sender, RoutedEventArgs e)
7. {
8. Clipboard.SetText(rbtMyRichTextBox.Selection.Text);
9. rbtMyRichTextBox.Selection.Text ="";
10. rbtMyRichTextBox.Focus();
11. }
12. //上面的代码分别演示如何对RichTextBox中被选中的文本进行复制,剪切
13. privatevoidPaste_Click(object sender, RoutedEventArgs e)
14. {
15. rbtMyRichTextBox.Selection.Text =Clipboard.GetText();
16. rbtMyRichTextBox.Focus();
17. }
private voidCopy_Click(object sender, RoutedEventArgs e)
{
Clipboard.SetText(rbtMyRichTextBox.Selection.Text);
rbtMyRichTextBox.Focus();
}
private voidCut_Click(object sender, RoutedEventArgs e)
{
Clipboard.SetText(rbtMyRichTextBox.Selection.Text);
rbtMyRichTextBox.Selection.Text ="";
rbtMyRichTextBox.Focus();
}
//上面的代码分别演示如何对RichTextBox中被选中的文本进行复制,剪切
private voidPaste_Click(object sender, RoutedEventArgs e)
{
rbtMyRichTextBox.Selection.Text = Clipboard.GetText();
rbtMyRichTextBox.Focus();
}
复制的时候,如果RichTextBox没有选择任何元素,那么剪切板上的文本将显示在鼠标的当前位置上。注意的是,Cilpboard只能保护简单的文本,所以当粘贴,复制的时候会丢失之前格式化的信息。
保存内容为文件:RichTextBox提供了一个名为Xaml的属性,通过这个属性可以很方便的将内容保存为文件。
1. privatevoidSave_Click(object sender, RoutedEventArgs e)
2. {
3. var uiElements = from blockinrbtMyRichTextBox.Blocks
4. from inlinein (blockasParagraph).Inlines
5. where inline.GetType() ==typeof(InlineUIContainer)
6. select inline;
7. if(uiElements.Count() != 0)
8. {
9. MessageBox.Show("UIElementscannot be saved");
10. return;
11. }
12. SaveFileDialog sfdSaveXaml =newSaveFileDialog();
13. sfdSaveXaml.DefaultExt =".sav";
14. sfdSaveXaml.Filter ="Savedrtb files|*.rtb";
15. if(sfdSaveXaml.ShowDialog().Value)
16. {
17. using (FileStreamfs = (FileStream)sfdSaveXaml.OpenFile())
18. {
19. System.Text.UTF8Encoding enc =newSystem.Text.UTF8Encoding();
20. byte[] buffer= enc.GetBytes(rbtMyRichTextBox.Xaml);
21. fs.Write(buffer, 0, buffer.Length);
22. fs.Close();
23. }
24. }
25. }
private voidSave_Click(object sender, RoutedEventArgs e)
{
var uiElements = from block inrbtMyRichTextBox.Blocks
from inline in (block asParagraph).Inlines
where inline.GetType() ==typeof(InlineUIContainer)
select inline;
if (uiElements.Count() != 0)
{
MessageBox.Show("UIElementscannot be saved");
return;
}
SaveFileDialog sfdSaveXaml = newSaveFileDialog();
sfdSaveXaml.DefaultExt =".sav";
sfdSaveXaml.Filter = "Saved rtbfiles|*.rtb";
if (sfdSaveXaml.ShowDialog().Value)
{
using (FileStream fs =(FileStream)sfdSaveXaml.OpenFile())
{
System.Text.UTF8Encoding enc =new System.Text.UTF8Encoding();
byte[] buffer =enc.GetBytes(rbtMyRichTextBox.Xaml);
fs.Write(buffer, 0,buffer.Length);
fs.Close();
}
}
}
因为RichTextBox不支持保存InlineUIContainer的元素,所以上面的代码中先将其排除,然后通过FileStream保存
打开文件:这个与保存文件过程是相反的,只要将RichTextBox的Xaml属性设置为读出的XAML。
1. privatevoidOpen_Click(object sender, RoutedEventArgs e)
2. {
3. OpenFileDialog ofdOpenXaml =newOpenFileDialog();
4. ofdOpenXaml.Multiselect =false;
5. ofdOpenXaml.Filter ="Savedrtb files|*.rtb";
6. if (ofdOpenXaml.ShowDialog().Value)
7. {
8. FileInfo fiXamlFile = ofdOpenXaml.File;
9. StreamReader sr = fiXamlFile.OpenText();
10. rbtMyRichTextBox.Xaml = sr.ReadToEnd();
11. sr.Close();
12. }
13. }
private voidOpen_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofdOpenXaml = newOpenFileDialog();
ofdOpenXaml.Multiselect = false;
ofdOpenXaml.Filter = "Saved rtbfiles|*.rtb";
if (ofdOpenXaml.ShowDialog().Value)
{
FileInfo fiXamlFile =ofdOpenXaml.File;
StreamReader sr =fiXamlFile.OpenText();
rbtMyRichTextBox.Xaml =sr.ReadToEnd();
sr.Close();
}
}
上面的保存,读取的文件只支持rtb格式的,其实可以使用其它的格式,当然肯定需要额外的编码,比如你打开一个文本文件,那么首先需要你创建所必须的Run标记。总之,你需要将内容转换成Xaml格式。对于保存文件,可以看看CodePlex上一个开眼项目:WordToXaml这篇文章是参考的国外这篇RichTextBox,文中的源码可以在其中找到。
1.13. SaveFileDialog
后台代码:
SaveFileDialogsd = new SaveFileDialog();
sd.Filter = "文本格式|*.txt";
sd.DefaultExt = "txt";
bool?result = sd.ShowDialog();
if(result == true)
{
System.IO.Stream fileStream = sd.OpenFile();
System.IO.StreamWriter sw =newSystem.IO.StreamWriter(fileStream);
sw.WriteLine("中华人民共和国.");
sw.Flush();
sw.Close();
}
1.14. ScrollBar
前台代码:
<ScrollBar Orientation="Vertical" Height="220" HorizontalAlignment="Left" Margin="60,35,0,0"Name="Vscrlb"VerticalAlignment="Top" Width="18" Maximum="100" Value="50" />
<ScrollBar Orientation="Horizontal" Height="22" HorizontalAlignment="Left" Margin="93,12,0,0"Name="Hscrlb" VerticalAlignment="Top" Width="422" Value="0" Maximum="1000" /
1.15. ScrollViewer
前台代码:
<ScrollViewer Height="121" Background="Blue" HorizontalAlignment="Left" Margin="132,304,0,0"Name="scrollViewer1"VerticalAlignment="Top" Width="383">
<TextBox Height="107" Name="textBox1" Width="326" />
</ScrollViewer>
1.16. Slider
<Slider Height="23" HorizontalAlignment="Left" Margin="182,251,0,0" Name="slider1" VerticalAlignment="Top"Width="357" Maximum="1000" Value="80" Orientation="Horizontal" />
1.17. StackPanel
<StackPanel x:Name="st1" Height="300" Width="400" >
<Button Height="90" Width="129" ></Button>
<Ellipse Height="100" Name="ellipse1" Stroke="Black" StrokeThickness="1" Width="200" />
</StackPanel>
1.18. TabControl
<sdk:TabControl Height="100" Name="tabControl1" Width="200">
<sdk:TabItem Header="tabItem1" Name="tabItem1">
<Grid />
</sdk:TabItem>
<sdk:TabItem Header="tabItem2" Name="tabItem2">
<Grid />
</sdk:TabItem>
<sdk:TabItem Header="tabItem3" Name="tabItem3">
<Grid />
</sdk:TabItem>
</sdk:TabControl>
1.19. TextBlock
<TextBlock Height="23" HorizontalAlignment="Left" Margin="124,78,0,0" Name="textBlock1"Text="TextBlock"VerticalAlignment="Top" />
1.20. TextBox
<TextBox Height="23" HorizontalAlignment="Left" Margin="110,160,0,0"Name="textBox1"VerticalAlignment="Top" Width="120">
<TextBox.BorderBrush>
<LinearGradientBrush>
<GradientStop Color="#FFA3AEB9" Offset="0" />
<GradientStop Color="#FF8399A9" Offset="0.375" />
<GradientStop Color="#FF718597" Offset="0.375" />
<GradientStop Color="#FF2E9CEF" Offset="1" />
</LinearGradientBrush>
</TextBox.BorderBrush>
</TextBox>
@原文引入:http://blog.csdn.net/zhaoyu_1979/article/details/7424514
Silverlight之控件应用总结(二)(4)的更多相关文章
- javascript实现silverlight pivotViewer控件
一时无事,就用js实现了一个silverlight pivotViewer控件来练手. 实现效果: silverlight PivotViewer说明地址:https://msdn.microsoft ...
- silverlight visifire控件图表制作——silverlight 后台方法页面事件
1.返回事件 (1.返回silverlight页面,2.返回web页面) private void button_ClickBack(object sender, RoutedEventArgs e) ...
- silverlight visifire控件图表制作——silverlight 后台方法ControlChart.xaml.cs
一.构造方法ControlChart 1.前台页面控件赋值 //时间下拉框赋值,下拉框赋选定值 for (int ii = DateTime.Today.Year; ii ...
- Silverlight第三方控件专题
原文http://www.cnblogs.com/nasa/archive/2008/12/01/1344927.html 这里我收集整理了目前网上silverlight第三方控件的专题,若果有所遗漏 ...
- 非常精彩的Silverlight 2控件样式
概述 大家是否觉的现在Silverlight 2提供的默认的控件不能满足自己的要求?好在Silverlight的控件可以运用皮肤,微软Silverlight控件的设计者的主管Corrina开发了几套非 ...
- [置顶] Silverlight之控件应用总结(一)(3)
[置顶] Silverlight之控件应用总结(一)(3) 分类: 技术2012-04-02 20:35 2442人阅读 评论(1) 收藏 举报 silverlightradiobuttondatat ...
- 转)delphi chrome cef3 控件学习笔记 (二)
(转)delphi chrome cef3 控件学习笔记 (二) https://blog.csdn.net/risesoft2012/article/details/51260832 原创 2016 ...
- Silverlight Visifire控件应用去水印
版本几之前可以用属性直接去掉水印: chart.Watermark = false; 现在我用的会报错,已过时,在网上查了写资料,解决办法如下: 一.很多人都是利用摭罩的办法,定位到水印显示的地方,建 ...
- echart图表控件配置入门(二)常用图表数据动态绑定
上一节 <echart图表控件配置入门(一)>介绍了echarts图表控件的入门配置,使开发人员可以快速搭建出一个静态的图表.但是在实际开发过程这还是不够的,不可能所有的图表控件都是静态数 ...
随机推荐
- BZOJ 3158 千钧一发 最小割
分析: 偶数对满足条件2,所有奇数对满足条件1. 如果你能一眼看出这个规律,这道题就完成了一半. 我们只需要将数分为两类,a值为奇数,就从S向这个点连容量为b值的边,a值为偶数,就从这个点向T连容量为 ...
- CSU 2018年12月月赛 B 2214: Sequence Magic
Description 有一个1到N的自然数序列1,2,3,...,N-1,N. 我们对它进行M次操作,每次操作将其中连续的一段区间 [Ai,Bi][Ai,Bi] (即第Ai个元素到第Bi个元素之间的 ...
- 笔试算法题(19):判断两条单向链表的公共节点 & 字符集删除函数
出题:给定两个单向链表的头结点,判断其是否有公共节点并确定第一个公共节点的索引: 分析: 由于是单向链表,所以每个节点有且仅有一个后续节点,所以只可能是Y型交叉(每条链表中的某个节点同时指向一个公共节 ...
- SSH安全服务
ssh安全服务 client \ sever ssh: secure shell, protocol, 22 / tcp, 安全的远程登录, 基于RSA或DSA实现身份认证 两 ...
- Nginx的初识
今日刚接触了解到Nginx的反向代理,正向代理,并发,集群,同个站点不同域名的解析访问等等. 1.反向代理:Nginx充当一个桥接的作用,对用户和服务端进行链接,进行服务端的代理,这样有什么好处: a ...
- 87-Moving average of oscillator,移动平均振荡指标.(2015.7.4)
Moving average of oscillator 移动平均振荡指标 ~计算: OSMA = MACD-SIGNAL 注释:OSMA的值即为MACD中两个主要指标线的差值 ~思想: 该指标当作一 ...
- [NOIP2004] 提高组 洛谷P1092 虫食算
题目描述 所谓虫食算,就是原先的算式中有一部分被虫子啃掉了,需要我们根据剩下的数字来判定被啃掉的字母.来看一个简单的例子: 43#9865#045 +8468#6633 44445509678 其中# ...
- LOJ#539. 「LibreOJ NOIP Round #1」旅游路线
n<=100,m<=1000的图,在此图上用油箱容量C<=1e5的车来旅行,旅行时,走一条边会耗一单伟油,在点i时,若油量<ci,则可以把油以pi的价格补到ci,pi<= ...
- HTML5学习之语义化标签
一.为什么HTML5要引入新语义标签 在HTML5出现之前,我们一般采用DIV+CSS布局我们的页面.但是这样的布局方式不仅使我们的文档结构不够清晰,而且不利于搜索引擎爬虫对我们页面的爬取.为了解决上 ...
- js格式化日期时间
// 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).周(E).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1 ...