Example #1
0
        // 追加の場合
        public InputForm(string path)
        {
            InitializeComponent();

            Info = new IdeInfo();

            // パス
            textPath.Text = path;

            // 名前と種別
            string filename = System.IO.Path.GetFileNameWithoutExtension(path);

            if (filename.ToLower().Equals("arduino"))
            {
                // Arduinoの場合
                textName.Text        = "Arduino";
                radioArduino.Checked = true;
            }
            else if (filename.ToLower().Equals("ide4gr"))
            {
                // IDE for GRの場合
                textName.Text   = "IDE for GR";
                radioGR.Checked = true;
            }
            else
            {
                // 不明なIDEの場合
                textName.Text        = filename;
                radioArduino.Checked = true;
            }

            // アイコン画像の取得
            getIcon(path);
        }
Example #2
0
        // 編集の場合
        public InputForm(IdeInfo info)
        {
            InitializeComponent();

            Info = info;

            // パス
            textPath.Text = info.Path;
            // 名前
            textName.Text = info.Name;
            // 種別
            switch (info.Type)
            {
            case IdeType.ARDUINO:
                radioArduino.Checked = true;
                break;

            case IdeType.IDE4GR:
                radioGR.Checked = true;
                break;

            default:
                radioArduino.Checked = true;
                break;
            }

            // アイコン画像の取得
            getIcon(info.Path);
        }
Example #3
0
        public IdeItemControl(IdeInfo ide)
        {
            InitializeComponent();

            m_ideInfo = ide;

            // IDEの名前
            labelIdeName.Text = ide.Name;
            // IDEのパス
            labelIdePath.Text = ide.Path;

            // アイコン画像の取得
            Icon ico;

            try{
                ico = Icon.ExtractAssociatedIcon(ide.Path);
            }catch {
                ico = SystemIcons.Application; // 取得できないとき
            }
            Bitmap   resizeBmp = new Bitmap(70, 70);
            Graphics g         = Graphics.FromImage(resizeBmp);

            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            g.DrawImage(ico.ToBitmap(), 3, 3, 64, 64);
            g.Dispose();
            buttonIde.BackgroundImage = resizeBmp;
        }
Example #4
0
        // IDE情報を作成する
        void createIdeInfo(string path)
        {
            IdeInfo info = new IdeInfo();

            // IDE情報入力画面を表示
            InputForm inputForm = new InputForm(path);

            inputForm.ShowDialog(this);
            if (inputForm.Info != null)
            {
                // IDE追加時のイベント発行
                var args = new IdeInfoEventArgs(inputForm.Info);
                onAdd(this, args);
            }
        }
Example #5
0
        // IDEが選択されたとき
        private void onSelect(object sender, IdeInfoEventArgs e)
        {
            // 選択されたIDE
            SelectedIde = e.ideInfo;

            // inoファイルを開くとき
            if (m_toOpenInoFile)
            {
                // フォームを閉じる (親フォーム側でinoファイルを開く)
                this.Close();
            }
            // inoファイルを開かないとき
            else
            {
                // IDEを起動
                try{
                    var p = Process.Start(SelectedIde.Path);
                }catch {
                    MessageBox.Show("IDEが起動できませんでした", "エラー");
                }
            }
        }
Example #6
0
        // IDE情報ファイルの読み込み
        private bool loadSetting(string path)
        {
            try
            {
                // IDE情報をデシリアライズして読み込み
                var serializer = new XmlSerializer(typeof(IdeInfo));
                var sr         = new StreamReader(path, new UTF8Encoding(false));
                m_ideInfo = (IdeInfo)serializer.Deserialize(sr);
                sr.Close();

                // 有効なIDE情報があるか?
                if (m_ideInfo.Path == "")
                {
                    return(false);
                }

                return(true);
            }
            catch
            {
                MessageBox.Show("IDE情報ファイルが読み込めませんでした", "エラー");
                return(false);
            }
        }
Example #7
0
 // キャンセルボタン
 private void buttonCancel_Click(object sender, EventArgs e)
 {
     Info = null;
     this.Close();
 }
Example #8
0
 public IdeInfoEventArgs(IdeInfo info)
 {
     ideInfo = info;
 }
Example #9
0
        // 起動時
        private void FormMain_Load(object sender, EventArgs e)
        {
            // コマンド引数をチェックする
            checkArgs();

            // 引数がないとき(inoファイルを開かないとき)
            if (m_inoPath.Equals(""))
            {
                // inoファイルが関連付けられていないなら関連付ける
                if (checkAssociation() == false)
                {
                    // 関連付けの可否を確認
                    if (MessageBox.Show("inoファイルを関連づけますか?", "確認",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question
                                        ) == DialogResult.Yes)
                    {
                        // inoファイルの関連付け
                        if (associateIno() == false)
                        {
                            MessageBox.Show("関連付けできませんでした", "エラー");
                        }
                    }
                }
                // IDEマネージャ画面を表示 (inoファイルを開かない)
                ManagerForm form = new ManagerForm(false);
                form.ShowDialog(this);

                // 終了
                m_forceClose = true;
                this.Close();
                return;
            }
            // inoファイルを開くとき
            else
            {
                // IDE情報ファイルがあるか?
                bool   opened  = false;
                string setting = Path.GetDirectoryName(m_inoPath) + @"\inoSwitch.txt";
                if (File.Exists(setting))
                {
                    // IDE情報ファイルを読み込んでIDEを起動
                    if (loadSetting(setting))
                    {
                        copyPreferences();
                        opened = startIde();
                    }
                }
                // IDEを起動しなかった場合
                if (!opened)
                {
                    // IDEマネージャ画面を表示 (inoファイルを開く)
                    ManagerForm form = new ManagerForm(true);
                    form.ShowDialog(this);
                    // 選択されたIDEで起動
                    m_ideInfo = form.SelectedIde;
                    if (m_ideInfo != null)
                    {
                        copyPreferences();
                        opened = startIde();
                    }
                }
                // それでもIDE起動しなかった場合は終了
                if (!opened)
                {
                    m_forceClose = true;
                    this.Close();
                    return;
                }
                // IDE情報ファイルに保存
                saveSetting(setting);

                // スケッチ名
                textSketch.Text = m_inoPath;
                // IDE名
                textIde.Text = m_ideInfo.Name;
                // アイコン
                Icon ico;
                try{
                    ico = Icon.ExtractAssociatedIcon(m_ideInfo.Path);
                }catch {
                    ico = SystemIcons.Application; // 取得できないとき
                }
                Bitmap   resizeBmp = new Bitmap(128, 128);
                Graphics g         = Graphics.FromImage(resizeBmp);
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                g.DrawImage(ico.ToBitmap(), 0, 0, 128, 128);
                g.Dispose();
                pictureIde.Image = resizeBmp;
            }
        }