예제 #1
0
        private void ThumbListView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            if (e.IsSelected)
            {
                if (IsModified && !ShowSaveDialog())
                {
                    return;
                }

                CloseFile();

                var bmpPath = ThumbListView.SelectedImagePath;
                if (bmpPath != null && File.Exists(bmpPath))
                {
                    Bitmap res = CozyPixelHelper.ReadBitmapFromFile(bmpPath);
                    SelectedImagePath = bmpPath;

                    ChangePixelPainterImage(res);
                    SetCurrPathStatusLabel(bmpPath);
                }
            }
        }
예제 #2
0
        private bool OpenFile()
        {
            int            gw      = RefreshCurrGridWidth();
            OpenFileDialog OpenDlg = new OpenFileDialog();

            OpenDlg.Filter = OpenDlgFilter;

            if (OpenDlg.ShowDialog() == DialogResult.OK)
            {
                Bitmap res = CozyPixelHelper.ReadBitmapFromFile(OpenDlg.FileName);

                if (res.Width > 128 || res.Height > 128)
                {
                    MetroMessageBox.Show(this, "不支持超过128 * 128的文件", "打开失败");
                    return(false);
                }

                ChangePixelPainterImage(res);
                SetCurrPathStatusLabel(OpenDlg.FileName);
                SelectedImagePath = OpenDlg.FileName;
                return(true);
            }
            return(false);
        }