예제 #1
0
        /// <summary>
        /// show icon
        /// </summary>
        private void SetIcon()
        {
            var fileUtil = FileUtil.Create(this.cFileUrl.Text);

            if (null == fileUtil)
            {
                this.Model.Icon = Constant.NoItemIcon;
            }
            else
            {
                if (fileUtil.Exists())
                {
                    this.Model.Icon = $"{Constant.IconCache}{this.Model.PageNo}_{this.Model.Index}{Constant.TmpIconExt}";
                    if (fileUtil.IsDirectory)
                    {
                        AppUtil.CreateDirectoryIcon(this.cFileUrl.Text, this.Model.Icon);
                    }
                    else
                    {
                        AppUtil.CreateAppIcon(this.cFileUrl.Text, this.Model.Icon);
                    }
                }
                else
                {
                    this.Model.Icon = Constant.NoItemIcon;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Item Drop event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ItemView_Drop(object sender, DragEventArgs e)
        {
            if (!(e.Data.GetData(DataFormats.FileDrop) is string[] files))
            {
                return;
            }
            var model    = this._model.Clone();
            var fileUtil = FileUtil.Create(files[0]);

            model.FileUrl     = fileUtil.FilePath;
            model.DisplayName = fileUtil.Name;
            model.Icon        = $"{Constant.IconCache}{this._model.PageNo}_{this._model.Index}{Constant.TmpIconExt}";

            if (fileUtil.IsDirectory)
            {
                AppUtil.CreateDirectoryIcon(model.FileUrl, model.Icon);
            }
            else
            {
                AppUtil.CreateAppIcon(model.FileUrl, model.Icon);
            }
            this.ItemAdded?.Invoke(this, new ItemEventArgs(model));
        }
예제 #3
0
        /// <summary>
        /// Context Menu [Add] click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItemAdd_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog()
            {
                Filter      = "all|*.*",
                FilterIndex = 0,
                Title       = "ファイルを選択"
            };

            if (true != dialog.ShowDialog())
            {
                return;
            }
            var model    = this._model.Clone();
            var fileUtil = FileUtil.Create(dialog.FileName);

            model.FileUrl          = fileUtil.FilePath;
            model.DisplayName      = fileUtil.Name;
            model.Icon             = $"{Constant.IconCache}{this._model.PageNo}_{this._model.Index}.png.tmp";
            this.cDisplayName.Text = model.DisplayName;
            AppUtil.CreateAppIcon(model.FileUrl, model.Icon);
            this.ItemAdded?.Invoke(this, new ItemEventArgs(model));
        }