ãªã³ã¯ã¨ã©ã¼
1>LINK : fatal error LNK1123: COFF ã¸ã®å¤æä¸ã«é害ãçºçãã¾ãã: ãã¡ã¤ã«ãç¡å¹ã§ããããã¾ãã¯å£ãã¦ãã¾ãã
ã®ã¡ã¢ã
VC2012ãã¤ã³ã¹ãã¼ã«ããã¨ãVC2010ã§åºãããã«ãªãã£ã½ãã
ãªã³ã¯ãªãã·ã§ã³ã§ã¤ã³ã¯ãªã¡ã³ã¿ã«ãªã³ã¯ãNOã«ããã
premake4.luaçã«ã¯
flags { "NoIncrementalLink" }
premake4.4æ°æ©è½
rails-3.1.0ãcygwinã§ããã¡ã¢
javascript engine
ãªãã¨ãªãspidermonkeyã«ããã
http://ftp.mozilla.org/pub/mozilla.org/js/
ãã
js-1.7.0.tar.gz
ããã¦ã³ãã¼ãããã
$ cd /usr/local/src $ wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz $ tar xzf js-1.7.0.tar.gz $ cd js/src $ make -f Makefile.ref OS_ARCH=Linux LD=gcc $ cp cp Linux_All_DBG.OBJ/js.exe /usr/local/bin/
railsã使ãã·ã§ã«ã«ç°å¢å¤æ°ãã»ãããã
export EXECJS_RUNTIME=SpiderMonkey
Ruby version 1.9.3 (i386-cygwin) RubyGems version 1.8.23 Rack version 1.3 Rails version 3.1.0 JavaScript Runtime SpiderMonkey Active Record version 3.1.0 Action Pack version 3.1.0 Active Resource version 3.1.0 Action Mailer version 3.1.0 Active Support version 3.1.0 Middleware ActionDispatch::Static Rack::Lock #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x80ef9ba8> Rack::Runtime Rack::MethodOverride Rails::Rack::Logger ActionDispatch::ShowExceptions ActionDispatch::RemoteIp Rack::Sendfile ActionDispatch::Reloader ActionDispatch::Callbacks ActiveRecord::ConnectionAdapters::ConnectionManagement ActiveRecord::QueryCache ActionDispatch::Cookies ActionDispatch::Session::CookieStore ActionDispatch::Flash ActionDispatch::ParamsParser ActionDispatch::Head Rack::ConditionalGet Rack::ETag ActionDispatch::BestStandardsSupport Application root /cygdrive/c/work/_rails/demo Environment development Database adapter sqlite3 Database schema version 0
JSONã¨ç¸äºå¤æã§ããXMLã®è¨è¿°
JsonReaderWriterFactoryã¯ã©ããªJSONã§ãParseãã¦XElemntåã§ããããXmlãJSONåããã«ã¯ç¹å®ã®æ§é ãæã£ã¦ããå¿
è¦ãããã
objectã¨arrayã¨ãã®ä»ã®åä¸é
ç®(number, boolean, stringãªã©)ã®æã¡æ¹ã決ã¾ã£ã¦ããã
è¦ãç®ã«åãããããªãã®ãwpfã§ä½ã£ã¦ã¿ãããã¨ã§ç¶ããä½ããããããªããååãã§ããã®ã§ã¡ã¢ã
<Window x:Class="XMLExperiment.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <TreeView x:Name="tree" Grid.Column="0" ItemsSource="{Binding Root.Children}"> <!--DirectoryViewModel ã®ãã¼ã¿ã表示ããã¨ãã«ä½¿ããã³ãã¬ã¼ã--> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Children}"> <TextBlock Text="{Binding Name}"/> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView> <TextBox x:Name="xml" Grid.Column="1" Text="{Binding Xml}" /> <TextBox x:Name="json" Grid.Column="2" Text="{Binding Json}" /> </Grid> </Window>
namespace XMLExperiment { /// <summary> /// MainWindow.xaml ã®ç¸äºä½ç¨ãã¸ã㯠/// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); var tree = new Tree(); DataContext = tree; } } }
namespace XMLExperiment { public class Node : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } } private XElement _e; private ObservableCollection<Node> _children; public Node(XElement e) { _e = e; } public String Name { get { return _e.Name.ToString(); } } public ObservableCollection<Node> Children { get { if (_children == null) { _children = new ObservableCollection<Node>(_e.Elements().Select(e => new Node(e))); } return _children; } } } public class Tree { public Tree() { Json = @"{ ""hoge"":[ 1 ,2 ,3 ,{ ""nazo"": true } ] }"; } private XElement _root; public Node Root { get { return new Node(_root); } } public String Xml { set { } get { return _root.ToString(); } } public String Json { set { using (var reader = JsonReaderWriterFactory.CreateJsonReader(Encoding.Unicode.GetBytes(value), XmlDictionaryReaderQuotas.Max)) { _root=XElement.Load(reader); } } get { using (var ms = new MemoryStream()) using (var writer = JsonReaderWriterFactory.CreateJsonWriter(ms, Encoding.Unicode)) { _root.WriteTo(writer); writer.Flush(); return Encoding.Unicode.GetString(ms.ToArray()); } } } } }
èªåã¯objectãã·ãªã¢ã©ã¤ãºããããã·ãªã¢ã©ã¤ãºãããã®ã§ã¯ãªãã¦åçã«çµã¿ç«ã¦ã¦ãããJSONã¨ç¸äºã«å¤æãããã®ã§ã
ãã¾ãã¡æ¢åã®ã©ã¤ãã©ãªã¨ã¯ç®çãä¸è´ããªãã®ã ããªã»ã»ã»ã
æ³¥èãXElementã©ãããä½ãã®ãæ©ãããç¥ãã¬ã
ãã¡ã¤ã©ã¼ãã®ï¼
ã¢ã¤ã³ã³ãã¤ããã
Win32apiã®SHGetFileInfoãå¼ã¹ãããã«ãã
[StructLayout(LayoutKind.Sequential)] public struct SHFILEINFO { public IntPtr hIcon; public IntPtr iIcon; public uint dwAttributes; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szDisplayName; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)] public string szTypeName; }; class Win32 { public const uint SHGFI_ICON = 0x100; public const uint SHGFI_LARGEICON = 0x0; // 'Large icon public const uint SHGFI_SMALLICON = 0x1; // 'Small icon [DllImport("shell32.dll")] public static extern IntPtr SHGetFileInfo( string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags); [DllImport("user32")] public static extern int DestroyIcon(IntPtr hIcon); }
ãã¡ã¤ã«ãã¹ããã¢ã¤ã³ã³ç»åãå¾ããObservableCollection
class Item { public FileSystemInfo Info { set; get; } public String Name { get { return Info.Name; } } public String Length { get { var file = Info as FileInfo; if (file == null) { return ""; } else { return file.Length.ToString(); } } } public BitmapSource Bitmap { get { SHFILEINFO shinfo = new SHFILEINFO(); var hImgLarge = Win32.SHGetFileInfo(Info.FullName, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), Win32.SHGFI_ICON | Win32.SHGFI_LARGEICON); BitmapSource source = Imaging.CreateBitmapSourceFromHIcon(shinfo.hIcon, Int32Rect.Empty, null); Win32.DestroyIcon(shinfo.hIcon); return source; } } };
ListViewã®DataTemplateã«Bitmapããã¤ã³ãã£ã³ã°ãã
<ListView Grid.Row="1" ItemsSource="{Binding Path=Files}" AlternationCount="2"> <ListView.View> <GridView> <GridView.Columns> <GridViewColumn Header="Name"> <GridViewColumn.CellTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Image Grid.Column="0" Source="{Binding Path=Bitmap}" Margin="5,0,5,0" /> <Label Grid.Column="1" Content="{Binding Path=Name}"/> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="Size"> <GridViewColumn.CellTemplate> <DataTemplate> <Label Content="{Binding Path=Length}" HorizontalAlignment="Right"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView.Columns> </GridView> </ListView.View> <ListView.ItemContainerStyle> <Style TargetType="{x:Type ListViewItem}" > <Setter Property="HorizontalContentAlignment" Value="Stretch" /> <EventSetter Event="MouseDoubleClick" Handler="listBoxItem_DoubleClick"/> </Style> </ListView.ItemContainerStyle> </ListView>
ã¢ã¤ã³ã³ãåºãããã«ãªã£ãã
å¥ã¹ã¬ããã§ã¢ã¤ã³ã³ç»åã®èªã¿è¾¼ã¿ããã
public DirectoryInfo Current { get { return current_; } set { current_ = value; NotifyPropertyChanged("Current"); NotifyPropertyChanged("Path"); files_.Clear(); var workList=new List<Item>(); try { foreach (var e in current_.GetFileSystemInfos()) { // FileSystemInfoã ãã®ãªã¹ããä½ã£ã¦ã // å¾ã§ã¢ã¤ã³ã³ç»åããã¼ããã var item=new Item { Info = e }; files_.Add(item); workList.Add(item); } // å¥ã¹ã¬ããã§ããããããæ´æ°ãå¼ã³åºã var task = new Task(() => { foreach (var item in workList) { var source = LoadBitmapSource(item.Info); source.Freeze(); // éè¦ Action action = () => { // UIã¹ã¬ãã item.Bitmap = source; }; dispatcher_.Invoke(action); } }); task.Start(); } catch (UnauthorizedAccessException e) { // do nothing } catch (DirectoryNotFoundException e) { // do nothing } } }
githubä½ã£ãã
https://github.com/ousttrue/CSFiler
ãã¡ã¤ã©ã¼ãã®ï¼
ListBoxããListViewã«å¤ãã¦ã¿ãã
MainWindow.xaml
<Window x:Class="filer.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:IO="clr-namespace:System.IO;assembly=mscorlib" Title="Filer" Height="350" Width="525"> <Window.Resources> <Style TargetType="ListViewItem"> <EventSetter Event="MouseDoubleClick" Handler="listBoxItem_DoubleClick"/> </Style> </Window.Resources> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <TextBox Grid.Column="0" Name="currentFolder" Text="{Binding Path=Path}" /> <Button Grid.Column="1" Name="goParent" Width="30" Content=".." Click="goParent_Click" Cursor="Hand"/> </Grid> <ScrollViewer Grid.Row="1" > <ListView ItemsSource="{Binding Path=Files}" AlternationCount="2"> <ListView.View> <GridView> <GridView.Columns> <GridViewColumn Header="Name"> <GridViewColumn.CellTemplate> <DataTemplate> <Label Content="{Binding Path=Name}"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="Size"> <GridViewColumn.CellTemplate> <DataTemplate> <Label Content="{Binding Path=Length}"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView.Columns> </GridView> </ListView.View> </ListView> </ScrollViewer> </Grid> </Window>
ListBoxãListViewã«å¤æ´ãã¦ãä¸ã®GridViewã«ã«ã©ã ãï¼ã¤ä½ã£ãã
ããã«DataTemplateãWindow.ResourcesããGridViewColumn.CellTemplateã«ç§»åããã
DataTypeã¨Columnçªå·ããDataTemplateãé¸æããæ¹æ³ã模索ããã®ã ãã
CellTemplateSelectorãæ¸ãæ¹æ³ããè¦ã¤ãããªãã£ãã®ã§ãªãã¹ãxamlã ãã§æ¸ã¾ãæ¹éããè¦éã£ãã
å³å¯ãã«ãã
Styleã§ä¼¸ã°ãã¦ãã
<Style TargetType="ListViewItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> </Style>
DataTemplateã§å³ã«å¯ãã
<DataTemplate> <Label Content="{Binding Path=Length}" HorizontalAlignment="Right"/> </DataTemplate>
ã¹ã¿ã¤ã«ãResourcesããListViewã®ä¸ã«ç§»åãã
<ListView.ItemContainerStyle> <Style TargetType="{x:Type ListViewItem}" > <Setter Property="HorizontalContentAlignment" Value="Stretch" /> <EventSetter Event="MouseDoubleClick" Handler="listBoxItem_DoubleClick"/> </Style> </ListView.ItemContainerStyle>
FileSystemInfoã®ã©ãããä½ã£ã¦Lengthããããã£ã¢ã¯ã»ã¹æã«ã¨ã©ã¼ãåºãªãããã«ãã
DirectoryInfo.Lengthã«ã¢ã¯ã»ã¹ããã¨ãããããªããããã£ã¯ç¡ãã¨ããã¨ã©ã¼ãåºãã
ObservableCollection
class Item { public bool IsDirectory { set; get; } public FileSystemInfo Info { set; get; } public String Name { get { return Info.Name; } } public String Length { get { var file = Info as FileInfo; if (file == null) { return ""; } else { return file.Length.ToString(); } } } };
ToDo: ã¢ã¤ã³ã³ãã¤ãã
ãã¡ã¤ã©ã¼ãã®ï¼
ListBoxItemã®ããã«ã¯ãªãã¯ã¤ãã³ããå®è£ ããã
MainWindow.xaml
<ListBox Name="currentFolderFiles" ItemsSource="{Binding Path=Files}"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <EventSetter Event="MouseDoubleClick" Handler="listBoxItem_DoubleClick" /> </Style> </ListBox.ItemContainerStyle> </ListBox>
MainWindow.xaml.cs
public partial class MainWindow : Window { private FileView fileView_ = new FileView("C:\\"); public MainWindow() { InitializeComponent(); DataContext=fileView_; } private void listBoxItem_DoubleClick(object sender, MouseButtonEventArgs args) { var item = sender as ListBoxItem; var directory = item.Content as DirectoryInfo; if (directory != null) { fileView_.Current=directory; return; } var file = item.Content as FileInfo; if(file != null) { return; } } }
FileView.cs
private DirectoryInfo current_; // 追å public DirectoryInfo Current { get { return current_; } set { current_ = value; NotifyPropertyChanged("Current"); NotifyPropertyChanged("Path"); /* å ¥ãç©ãå¤ãã£ã¦ãã¾ãã»ã»ã» files_ = new ObservableCollection<FileSystemInfo>( current_.GetFileSystemInfos().ToArray()); */ files_.Clear(); foreach (var e in current_.GetFileSystemInfos()) { files_.Add(e); } } } public string Path { get { return current_.FullName; } set { Current = new DirectoryInfo(value); } }
ãã£ã¬ã¯ããªã®ä¸ã«æ¥ãããã¦ã¹ã«ã¼ã½ã«ãå¤ãã
MainWindow.xaml
<DataTemplate DataType="{x:Type IO:DirectoryInfo}"> <Label Content="{Binding Path=Name}" Foreground="#FF2222" Cursor="Hand"/> </DataTemplate>
横ãã£ã±ãã«åºãã
<ListBox x:Name="currentFolderFiles" ItemsSource="{Binding Path=Files}" HorizontalContentAlignment="Stretch">
親ãã£ã¬ã¯ããªã«æ»ããã¿ã³
MainWindow.xaml
<Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <TextBox Grid.Column="0" Name="currentFolder" Text="{Binding Path=Path}" /> <Button Grid.Column="1" Name="goParent" Width="30" Content=".." Click="goParent_Click" Cursor="Hand"/> </Grid>
ç«ã¦åå²ã®Gridã«ã横åå²ã®Gridãå
¥ãåã«ãã
MainWindow.xaml.cs
private void goParent_Click(object sender, RoutedEventArgs e) { if (fileView_.Current.Parent != null) { fileView_.Current = fileView_.Current.Parent; } }