Exemple #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MkaPropertiesBat(MkaBatManager bat)
        {
            InitializeComponent();
            _batManager = bat;

            dtpDate.MinDate = MkaDefine.StartDate;
            dtpDate.MaxDate = DateTime.Today;

            // initialize
            InitProperty();
        }
        /// <summary>
        /// Explore the bat file and glass file names to explorer windows
        /// </summary>
        /// <param name="bat">target bat information</param>
        public void Explore(MkaBatManager batFile)
        {
            _batFile = batFile;
            _batPath = batFile.BatDirectory;

            // set bat name
            treeExplorer.Nodes.Clear();
            treeExplorer.Nodes.Add(batFile.BatInfo.BatBangou);

            String       glass;
            FileStream   fs;
            Bitmap       bmp;
            ListViewItem lvi;
            int          width  = Math.Max(50, Math.Min((int)(0.5 * thumbExplorer.Width), 300));
            int          height = (int)(0.75 * width);

            viewImgList.Images.Clear();
            thumbExplorer.Items.Clear();
            _thumbBmps.Clear();
            viewImgList.ImageSize = new Size(width, height);

            // set view and outline of glass files
            for (int i = 0; i < batFile.GlassFilePaths.Count; i++)
            {
                glass = Path.GetFileNameWithoutExtension(batFile.GlassFilePaths[i]);
                treeExplorer.Nodes[0].Nodes.Add(new TreeNode(glass, 3, 3));

                fs  = new FileStream(_batFile.ImageFilePaths[i], FileMode.Open);
                bmp = (Bitmap)Bitmap.FromStream(fs);
                bmp = (Bitmap)bmp.GetThumbnailImage(200, 200, null, IntPtr.Zero);
                _thumbBmps.Add(bmp);
                fs.Close();

                viewImgList.Images.Add(bmp);
                lvi            = new ListViewItem(glass);
                lvi.ImageIndex = i;
                thumbExplorer.Items.Add(lvi);
            }

            treeExplorer.Sort();
            treeExplorer.ExpandAll();
        }
Exemple #3
0
        /// <summary>
        /// Open bat file
        /// </summary>
        private void FileOpenBat(String filename)
        {
            XmlDocument   doc       = new XmlDocument();
            IXmlFormatter formatter = FepXmlableFactory.CreateXmlFormatter();
            IXmlContext   cnt;
            XmlElement    _eleBat;

            // Deserialize object from xml format
            doc.Load(filename);
            cnt         = FepXmlableFactory.CreateXmlContext(formatter, doc);
            doc         = cnt.Document;
            _eleBat     = doc.DocumentElement;
            _batManager = cnt.FromXml(_eleBat) as MkaBatManager;
            _batManager.BatInfo.BatDirectory = Path.GetDirectoryName(filename);
            for (int i = 0; i < _batManager.ImageFileNames.Count; i++)
            {
                _batManager.ImageFilePaths.Add(_batManager.BatInfo.BatDirectory + "\\" + _batManager.ImageFileNames[i]);
                _batManager.GlassFilePaths.Add(_batManager.BatInfo.BatDirectory + "\\" + Path.GetFileNameWithoutExtension(_batManager.ImageFileNames[i]) + MkaDefine.MkaFileExt);
            }
        }
 /// <summary>
 /// Activate bat to edit property
 /// </summary>
 public void SelectBat(MkaBatManager bat)
 {
     this.propertyGrid.SelectedObject = bat.BatInfo;
     SelectedType = SelectedObjectType.Bat;
 }
Exemple #5
0
        /// <summary>
        /// OK button -> new bat file is created
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            // check input data
            if (!CheckValidInput())
            {
                return;
            }

            //update working directory
            DirectoryInfo wFolder = new DirectoryInfo(txtBatPath.Text);

            MkaDefine.MokkanPath = wFolder.Parent.Parent.FullName;

            // create bat information
            _batInfo               = new MkaBatInfo();
            _batInfo.ChousaJisuu   = Int32.Parse(txtChousaJisuu.Text.Trim());
            _batInfo.OoChiku       = txtOoChiku.Text.Trim();
            _batInfo.ChuushouChiku = txtChuushouChiku.Text.Trim();
            _batInfo.Ikoumei       = txtIkoumei.Text.Trim();
            _batInfo.Dosoumei      = txtDosoumei.Text.Trim();
            if (txtGrid.Text.Trim() == "")
            {
                _batInfo.Grid = 0;
            }
            else
            {
                _batInfo.Grid = Int32.Parse(txtGrid.Text.Trim());
            }
            _batInfo.Date         = dtpDate.Value;
            _batInfo.BatBangou    = txtBatBangou.Text.Trim();
            _batInfo.BatDirectory = txtBatPath.Text;

            // check if existed
            String batFile = _batInfo.BatDirectory + "\\" + _batInfo.BatBangou + MkaDefine.BmkFileExt;

            if (File.Exists(batFile))
            {
                switch (MessageBox.Show(this, String.Format(MkaMessage.WarnExistedFile, _batInfo.BatBangou + MkaDefine.BmkFileExt),
                                        MkaMessage.AppCaption, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning))
                {
                case DialogResult.Yes:
                    break;

                case DialogResult.No:
                    return;

                case DialogResult.Cancel:
                    this.DialogResult = DialogResult.Cancel;
                    this.Close();
                    return;
                }
            }

            MkaBatInfo.LastBat = _batInfo;

            BatManager                = new MkaBatManager(_owner);
            BatManager.BatInfo        = _batInfo;
            BatManager.ImageFilePaths = imgfullnames;
            BatManager.GlassFilePaths = glassnames;
            for (int i = 0; i < imgfullnames.Count; i++)
            {
                BatManager.ImageFileNames.Add(Path.GetFileName(imgfullnames[i]));
                BatManager.GlassFileNames.Add(Path.GetFileName(glassnames[i]));
            }

            // save bat path to registry
            RegistryKey key = MkaDefine.RootKey.CreateSubKey(MkaDefine.RegKey);

            key.SetValue(MkaDefine.RecentBatPath, batPath);

            // Close form
            this.DialogResult = DialogResult.OK;
            this.Close();
        }