Ejemplo n.º 1
0
        private async void MenuFlyoutItem_Click_s(object sender, RoutedEventArgs e)
        {
            if ((sender as FrameworkElement).DataContext is Pen9Model pen9)
            {
                var openPicker = new FileOpenPicker();
                openPicker.FileTypeFilter.Add(".jpeg");
                openPicker.FileTypeFilter.Add(".jpg");
                openPicker.FileTypeFilter.Add(".png");
                openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                openPicker.ViewMode = PickerViewMode.Thumbnail;
                try
                {
                    var res = await openPicker.PickSingleFileMux();

                    if (res != null)
                    {
                        Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(res);

                        pen9.fgurl = res.Path;
                        sz_ValueChanged(null, null);
                    }
                }
                catch (Exception)
                {
                }
            }
        }
Ejemplo n.º 2
0
        public NewFileDialog(VModel d)
        {
            this.InitializeComponent();
            W = d.FileWidth;
            H = d.FileHeight;
            //新建
            First.Click += (s, e) => {
                if (int.TryParse(W, out var w) && int.TryParse(H, out var h) && w > 1 && h > 1)
                {
                    d.FileWidth  = W;
                    d.FileHeight = H;


                    d.LayerList.Clear();
                    d.DrawRect = new Rect()
                    {
                        Width = w, Height = h
                    };
                    d.LayerList.Add(new LayerModel()
                    {
                    });
                    d.FileName     = "";
                    d.CurrentLayer = d.LayerList[0];
                    Exec.Clean();
                    Hide();
                }
            };
            //打开
            Open.Click += async(s, e) => {
                Hide();
                FileOpenPicker openPicker = new FileOpenPicker();
                //openPicker.ContinuationData["new"] = true;
                openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;


                openPicker.ViewMode = PickerViewMode.List;
                openPicker.FileTypeFilter.Add(".psd");
                openPicker.FileTypeFilter.Add(".jpeg");
                openPicker.FileTypeFilter.Add(".jpg");
                openPicker.FileTypeFilter.Add(".png");
                var file = await openPicker.PickSingleFileMux();

                if (file == null)
                {
                    return;
                }

                d.LayerList.Clear();
                d.FileName = file.Path;
                await d.LoadFile(file, d.LayerList, (w, h) => {
                    d.DrawRect = new Rect()
                    {
                        Width = w, Height = h
                    };
                });

                d.CurrentLayer = d.LayerList[0];
                Exec.Clean();
            };
            //取消
            Second.Click += (s, e) => {
                base.Hide();
            };
            //重置
            ReSize.Click += (s, e) => {
                W = Math.Floor(Window.Current.Bounds.Width).ToString();
                H = Math.Floor(Window.Current.Bounds.Height).ToString();
            };
        }