Exemple #1
0
        public void GetImage_IsExist()
        {
            //arrange
            string path = "folder.ico";
            //act
            var image = model.GetBitmap(path);

            //assert
            Assert.IsNotNull(image);
        }
Exemple #2
0
 public ViewModel(IModelList list, IXamlScriptGenerator generator)
 {
     _modelList           = list;
     _xamlscriptgenerator = generator;
     ItemsCollection      = new ObservableCollection <Item>(_xamlscriptgenerator.GetData(datafile).Select(
                                                                x => new Item {
         Path = x.Path, Image = _modelList.GetBitmap(x.Image), Name = x.Name
     }).ToList());
     DragCommand       = new RelayCommand(Execute, CanExecute);
     ClickStartCommand = new RelayCommand(StartApplication, CanExecute);
 }
Exemple #3
0
        private void Execute(object parametr)
        {
            IDataObject idata = parametr as IDataObject;

            if (idata != null)
            {
                string[] path = (string[])idata.GetData(DataFormats.FileDrop, true);
                if (path != null)
                {
                    string directoryfile = @".\Icons\";
                    if (File.Exists(path[0]))
                    {
                        string filename = Path.GetFileName(path[0]);

                        directoryfile += filename + ".ico";
                        _modelList.SaveIcon(path[0], directoryfile);
                        ItemsCollection.Add(new Item {
                            Path = path[0], Image = _modelList.GetBitmap(filename + ".ico"), Name = Path.GetFileNameWithoutExtension(path[0])
                        });
                        _xamlscriptgenerator.SaveData(datafile, path[0], filename + ".ico", Path.GetFileNameWithoutExtension(path[0]));
                    }
                    else if (Directory.Exists(path[0]))
                    {
                        string filename = new DirectoryInfo(path[0]).Name;
                        directoryfile += filename + ".ico";
                        _modelList.SaveIcon(directoryfile, Properties.Resources.folder);
                        ItemsCollection.Add(new Item {
                            Path = path[0], Image = _modelList.GetBitmap(filename + ".ico"), Name = filename
                        });
                        _xamlscriptgenerator.SaveData(datafile, path[0], filename + ".ico", filename);
                    }
                }
                else
                {
                    MessageBox.Show("Invalid operaiton. You can't add to the ToolBar: Desktop or Basket.", "Error!");
                }
            }
        }