<Description>C# Rapid Open Widget</Description>
<BaseAddress>4194304</BaseAddress>
<ReleaseVersion>0.5</ReleaseVersion>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
<OutputPath>$(SolutionDir)build\$(Configuration)</OutputPath>
<IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
<AssemblyOriginatorKeyFile>crow.key</AssemblyOriginatorKeyFile>
<VerticalStack Margin="1">
<TextBox Text="{²./CurrentDirectory}"/>
<HorizontalStack Spacing="1">
- <DirectoryView ShowFiles="false" Name="dv" CurrentDirectory="{²./CurrentDirectory}" SelectedItemChanged="./Tv_SelectedItemChanged"
- Width="50%" Margin="0">
+ <DirectoryView ShowFiles="false" Name="dv" CurrentDirectory="{²./CurrentDirectory}" Width="50%" Margin="0">
<Template>
<TreeView IsRoot="true" Name="treeView" Data="{./FileSystemEntries}"
SelectedItemChanged="./onSelectedItemChanged">
</Template>
</DirectoryView>
<Splitter/>
- <DirectoryView ShowFiles="true" Name="dv" CurrentDirectory="{../dv.SelectedItem}"
+ <DirectoryView ShowFiles="true" Name="fv" CurrentDirectory="{../dv.SelectedItem}" SelectedItemChanged="./onSelectedItemChanged"
Width="100%" Margin="0">
<Template>
- <ListBox Name="fileView" Data="{./FileSystemEntries}">
+ <ListBox Name="fileView" Data="{./FileSystemEntries}" SelectedItemChanged="./onSelectedItemChanged">
<Template>
<Border BorderWidth="1" Margin="0" MinimumSize="10,10">
<VerticalStack>
</Template>
</DirectoryView>
</HorizontalStack>
- <TextBox Text="{../../dv.SelectedItem}"/>
+ <TextBox Text="{./SelectedFile}"/>
<HorizontalStack Fit="true" HorizontalAlignment="Right">
- <Button Caption="Ok" MouseClick="onFileSelect"/>
- <Button Caption="Cancel"/>
+ <Button Caption="Ok" MouseClick="./onFileSelect"/>
+ <Button Caption="Cancel" MouseClick="./onCancel"/>
</HorizontalStack>
</VerticalStack>
</Container>
</Button>
<Slider Name="Slider"
Orientation="{./Orientation}"
- Value="{./Value}"
+ Value="{²./Value}"
Maximum="{./Maximum}"
Height="{./HeightPolicy}" Width="{./WidthPolicy}"
LargeIncrement="{./LargeIncrement}"
SmallIncrement="{./SmallIncrement}"
- Background="hgradient|0:DimGray|0.1:Gray|0.95:Gray|1:White"
- ValueChanged="./onSliderValueChange"/>
+ Background="hgradient|0:DimGray|0.1:Gray|0.95:Gray|1:White"/>
<Button MouseRepeat="true" Width="12" Height="12" MouseClick="./onScrollForth"
Template="#Crow.Templates.ArrowButTemplate.crow">
<Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
<?xml version="1.0"?>
-<HorizontalStack
- HorizontalAlignment="Left"
- Height="Fit" Width="200" Margin="1" Focusable="true"
- MouseEnter="{Background=hgradient|0:DarkRed|1:Transparent}"
- MouseLeave="{Background=Transparent}">
- <GraphicObject Height="12" Width="20" Background="{}" Margin="0" CornerRadius="3"/>
- <Label Text="{}" Margin="0" Width="Stretched"/>
-</HorizontalStack>
+<Border Foreground="Transparent" Focusable="true" HorizontalAlignment="Left" Height="Fit" Width="200">
+ <HorizontalStack Margin="0"
+ MouseEnter="{Background=hgradient|0:DarkRed|1:Transparent}"
+ MouseLeave="{Background=Transparent}">
+ <GraphicObject Height="12" Width="20" Background="{}" Margin="0" CornerRadius="3"/>
+ <Label Text="{}" Margin="0" Width="Stretched"/>
+ </HorizontalStack>
+</Border>
thread.Join ();
//cancelLoading = false;
}
- Host.CurrentInterface.CrowThreads.Remove (this);
+ lock (Host.CurrentInterface.CrowThreads)
+ Host.CurrentInterface.CrowThreads.Remove (this);
}
}
}
{
string searchPattern, curDirectory;
+ #region events
+ public event EventHandler OkClicked;
+ #endregion
+
#region CTOR
public FileDialog () : base()
{
}
#endregion
- //[DefaultValue(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))]
+
[XmlAttributeAttribute][DefaultValue("/home")]
public virtual string CurrentDirectory {
get { return curDirectory; }
set {
if (curDirectory == value)
return;
- curDirectory = value;
+ curDirectory = value;
NotifyValueChanged ("CurrentDirectory", curDirectory);
}
- }
+ }
[XmlAttributeAttribute()][DefaultValue("*")]
public virtual string SearchPattern {
set {
if (searchPattern == value)
return;
- searchPattern = value;
+ searchPattern = value;
NotifyValueChanged ("SearchPattern", searchPattern);
}
- }
-
-// public DirectoryInfo[] Directories
-// {
-// get {
-// //currentDir.GetDirectories
-// List<DirectoryInfo> tmp = currentDir.GetDirectories ().Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToList();
-// if (currentDir.Parent != null)
-// tmp.Insert (0, currentDir.Parent);
-// return tmp.ToArray ();
-// }
-// }
-// public FileInfo[] Files
-// {
-// get {
-// string[] exts = searchPattern.Replace("*","").Split ('|');
-// //return currentDir.GetFiles (searchPattern).Where(fi => !fi.Attributes.HasFlag(FileAttributes.Hidden)).ToArray();
-// return currentDir.GetFiles().Where(f => exts.Any
-// (x => f.Name.EndsWith (x, StringComparison.InvariantCultureIgnoreCase))).ToArray();
-// }
-// }
+ }
+ string _selectedFile;
+ [XmlIgnore]public string SelectedFile {
+ get {
+ return _selectedFile;
+ }
+ set {
+ if (value == _selectedFile)
+ return;
+ _selectedFile = value;
+ NotifyValueChanged ("SelectedFile", _selectedFile);
+ }
+ }
+ public void onSelectedItemChanged (object sender, SelectionChangeEventArgs e){
-// void OnSelectedItemChanged (object sender, SelectionChangeEventArgs e)
-// {
-// currentDir = e.NewValue as DirectoryInfo;
-// NotifyValueChanged ("CurrentPath", CurrentPath);
-// NotifyValueChanged ("Directories", Directories);
-// NotifyValueChanged ("Files", Files);
-//
-// }
-// void onFileListItemChanged (object sender, SelectionChangeEventArgs e)
-// {
-// selectedFile = e.NewValue as FileInfo;
-// }
-// void onFileSelect(object sender, MouseButtonEventArgs e){
-// //OpenTKGameWindow.currentWindow.DeleteWidget(window);
-// }
+ string tmp = "";
+ if (e.NewValue != null)
+ tmp = e.NewValue.ToString();
+ if (tmp == SelectedFile)
+ return;
+ SelectedFile = tmp;
+ //SelectedItemChanged.Raise (this, e);
+ }
+ void onFileSelect(object sender, MouseButtonEventArgs e){
+ OkClicked.Raise (this, null);
+ unloadDialog ((sender as GraphicObject).CurrentInterface);
+ }
+ void onCancel(object sender, MouseButtonEventArgs e){
+ unloadDialog ((sender as GraphicObject).CurrentInterface);
+ }
+ void unloadDialog(Interface host){
+ host.DeleteWidget (this);
+ }
}
-// public class DirContainer: IValueChange
-// {
-// #region IValueChange implementation
-// public event EventHandler<ValueChangeEventArgs> ValueChanged;
-// public void NotifyValueChanged(string name, object value)
-// {
-// ValueChanged.Raise (this, new ValueChangeEventArgs (name, value));
-// }
-// #endregion
-//
-// public DirectoryInfo CurDir;
-// public DirContainer(DirectoryInfo _dir){
-// CurDir = _dir;
-// }
-// public string Name {
-// get { return CurDir.Name; }
-// }
-//
-// void onDirUp(object sender, MouseButtonEventArgs e)
-// {
-//
-// }
-// public void onMouseDown(object sender, MouseButtonEventArgs e)
-// {
-// Debug.WriteLine (sender.ToString ());
-// }
-//
-// }
}
set { _multiSelect = value; }
}
public virtual void AddChild(GraphicObject g){
- lock (children)
- Children.Add(g);
- g.Parent = this;
+ lock (children) {
+ Children.Add (g);
+ g.Parent = this;
+ }
g.RegisteredLayoutings = LayoutingType.None;
g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
g.LayoutChanged += OnChildLayoutChanges;
CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
gr.Clip ();
- foreach (GraphicObject c in Children) {
- if (!c.Visible)
- continue;
- if (Clipping.intersect(c.Slot + ClientRectangle.Position))
- c.Paint (ref gr);
+ lock (Children) {
+ foreach (GraphicObject c in Children) {
+ if (!c.Visible)
+ continue;
+ if (Clipping.intersect (c.Slot + ClientRectangle.Position))
+ c.Paint (ref gr);
+ }
}
#if DEBUG_CLIP_RECTANGLE
public void GotoWordStart(){
CurrentColumn--;
//skip white spaces
- while (char.IsWhiteSpace (this.CurrentChar) && CurrentColumn > 0)
+ while (!char.IsLetterOrDigit (this.CurrentChar) && CurrentColumn > 0)
CurrentColumn--;
- while (!char.IsWhiteSpace (lines [CurrentLine] [CurrentColumn]) && CurrentColumn > 0)
+ while (char.IsLetterOrDigit (lines [CurrentLine] [CurrentColumn]) && CurrentColumn > 0)
CurrentColumn--;
- if (char.IsWhiteSpace (this.CurrentChar))
+ if (!char.IsLetterOrDigit (this.CurrentChar))
CurrentColumn++;
}
public void GotoWordEnd(){
//skip white spaces
if (CurrentColumn >= lines [CurrentLine].Length - 1)
return;
- while (char.IsWhiteSpace (this.CurrentChar) && CurrentColumn < lines [CurrentLine].Length-1)
+ while (!char.IsLetterOrDigit (this.CurrentChar) && CurrentColumn < lines [CurrentLine].Length-1)
CurrentColumn++;
- while (!char.IsWhiteSpace (this.CurrentChar) && CurrentColumn < lines [CurrentLine].Length-1)
+ while (char.IsLetterOrDigit (this.CurrentChar) && CurrentColumn < lines [CurrentLine].Length-1)
CurrentColumn++;
- if (!char.IsWhiteSpace (this.CurrentChar))
+ if (char.IsLetterOrDigit (this.CurrentChar))
CurrentColumn++;
}
public void DeleteChar()
return (int)Math.Ceiling(fe.Height * lc) + Margin * 2;
}
+ try {
+ foreach (string s in lines) {
+ string l = s.Replace("\t", new String (' ', Interface.TabSize));
- foreach (string s in lines) {
- string l = s.Replace("\t", new String (' ', Interface.TabSize));
+ TextExtents tmp = gr.TextExtents (l);
- TextExtents tmp = gr.TextExtents (l);
-
- if (tmp.XAdvance > te.XAdvance)
- te = tmp;
+ if (tmp.XAdvance > te.XAdvance)
+ te = tmp;
+ }
+ } catch (Exception ex) {
+ return -1;
}
return (int)Math.Ceiling (te.XAdvance) + Margin * 2;
}
else
SelEndCursorPos = textCursorPos;
}
- }
+ }else
+ computeTextCursorPosition(gr);
}else
computeTextCursorPosition(gr);
//****** debug selection *************
// if (SelRelease >= 0) {
-// gr.Color = Color.Green;
+// new SolidColor(Color.DarkGreen).SetAsSource(gr);
// Rectangle R = new Rectangle (
-// rText.X + (int)SelEndCursorPos - 2,
+// rText.X + (int)SelEndCursorPos - 3,
// rText.Y + (int)(SelRelease.Y * fe.Height),
-// 4,
+// 6,
// (int)fe.Height);
// gr.Rectangle (R);
// gr.Fill ();
// }
// if (SelBegin >= 0) {
-// gr.Color = Color.UnmellowYellow;
+// new SolidColor(Color.DarkRed).SetAsSource(gr);
// Rectangle R = new Rectangle (
-// rText.X + (int)SelStartCursorPos - 2,
+// rText.X + (int)SelStartCursorPos - 3,
// rText.Y + (int)(SelBegin.Y * fe.Height),
-// 4,
+// 6,
// (int)fe.Height);
// gr.Rectangle (R);
// gr.Fill ();
if (arg.LayoutType == LayoutingType.Height) {
if (maxScroll < ScrollY) {
//Debug.WriteLine ("scrolly={0} maxscroll={1}", ScrollY, maxScroll);
- ScrollY = 0;
+ ScrollY = maxScroll;
}
NotifyValueChanged("MaximumScroll", maxScroll);
}
} else if (arg.LayoutType == LayoutingType.Width) {
if (maxScroll < ScrollX) {
//Debug.WriteLine ("scrolly={0} maxscroll={1}", ScrollY, maxScroll);
- ScrollX = 0;
+ ScrollX = maxScroll;
}
NotifyValueChanged("MaximumScroll", maxScroll);
}
using System.ComponentModel;
using System.Collections;
using System.Threading;
+using System.Linq;
namespace Crow
{
#endregion
IList data;
- int _selectedIndex;
+ int _selectedIndex = -1;
Color selBackground, selForeground;
int itemPerPage = 50;
CrowThread loadingThread = null;
volatile bool cancelLoading = false;
+ bool isPaged = false;
+
#region Templating
//TODO: dont instantiate ItemTemplates if not used
//but then i should test if null in msil gen
}
#endregion
- public virtual List<GraphicObject> Items{ get { return items.Children; }}
+ public virtual List<GraphicObject> Items{
+ get {
+ return isPaged ? items.Children.SelectMany(x => (x as Group).Children).ToList()
+ : items.Children;
+ }
+ }
[XmlAttributeAttribute][DefaultValue(-1)]public int SelectedIndex{
get { return _selectedIndex; }
set {
if (value == _selectedIndex)
return;
+ if (_selectedIndex >= 0) {
+ Items[_selectedIndex].Foreground = Color.Transparent;
+ Items[_selectedIndex].Background = Color.Transparent;
+ }
+
_selectedIndex = value;
+ if (_selectedIndex >= 0) {
+ Items[_selectedIndex].Foreground = SelectionForeground;
+ Items[_selectedIndex].Background = SelectionBackground;
+ }
+
NotifyValueChanged ("SelectedIndex", _selectedIndex);
NotifyValueChanged ("SelectedItem", SelectedItem);
SelectedItemChanged.Raise (this, new SelectionChangeEventArgs (SelectedItem));
public virtual void ClearItems()
{
+ _selectedIndex = -1;
+ NotifyValueChanged ("SelectedIndex", _selectedIndex);
+ NotifyValueChanged ("SelectedItem", null);
+
items.ClearChildren ();
NotifyValueChanged ("HasChildren", false);
}
gs.HorizontalAlignment = items.HorizontalAlignment;
page = gs;
page.Name = "page" + pageNum;
+ isPaged = true;
} else {
page = Activator.CreateInstance (items.GetType ()) as Group;
page.Name = "page" + pageNum;
+ isPaged = true;
}
for (int i = (pageNum - 1) * itemPerPage; i < pageNum * itemPerPage; i++) {