コード例 #1
0
        private void showGridToolStripMenuItem_CheckStateChanged(object sender, EventArgs e)
        {
            var item = sender as ToolStripMenuItem;

            if (item != null)
            {
                Global.GridStyle.ShowGrid = item.Checked;
                tsbtnShowGrid.Checked     = item.Checked;
                MainPictureBox.ChangeColor(Global.GridStyle);
            }
        }
コード例 #2
0
        private void blackToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tsmi = sender as ToolStripMenuItem;

            if (tsmi != null && tsmi.Tag != null)
            {
                GridStyle gridStyle = CommonLib.GetGridStyle(tsmi.Tag.ToString());
                if (gridStyle != null)
                {
                    gridStyle.ShowGrid = showGridToolStripMenuItem.Checked;
                    Global.GridStyle   = gridStyle;
                    MainPictureBox.ChangeColor(gridStyle);
                }
            }
        }
コード例 #3
0
        private void openProjectToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            if (Global.ProjectSaved == false && MessageBox.Show(CommonLib.GetLocalString("project_no_saved"), CommonLib.GetLocalString("confirm_windows_title"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
            {
                return;
            }


            OpenFileDialog openfileDialog = new OpenFileDialog();

            openfileDialog.AddExtension    = true;
            openfileDialog.CheckFileExists = true;
            openfileDialog.Multiselect     = false;
            openfileDialog.Filter          = String.Format("{0}(2017)|*.cssp", CommonLib.GetLocalString("project_file_format_2017"));

            if (openfileDialog.ShowDialog() == DialogResult.OK)
            {
                byte[] buffer = null;
                try
                {
                    using (FileStream fs = new FileStream(openfileDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.None))
                    {
                        buffer = new byte[fs.Length];
                        fs.Read(buffer, 0, (int)fs.Length);
                        fs.Close();
                    }
                }
                catch (Exception ex)
                {
                    //将文件读取到流出错
                    MessageBox.Show(CommonLib.GetLocalString("open_project_file_error_exception", ex.Message),
                                    CommonLib.GetLocalString("alert_windows_title"),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
                if (buffer == null)
                {
                    //加载的流文件为空
                    MessageBox.Show(CommonLib.GetLocalString("open_project_file_error_buffer_null"),
                                    CommonLib.GetLocalString("alert_windows_title"),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }


                Project p = null;
                try
                {
                    p = Project.ReadFromBytes(buffer);
                }
                catch (Exception ex)
                {
                    //从流读取项目信息出错
                    MessageBox.Show(CommonLib.GetLocalString("open_project_format_error", ex.Message),
                                    CommonLib.GetLocalString("alert_windows_title"),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }

                _defaultGroup = CommonLib.CreateNewProject(listView1, p.Name);

                MainPictureBox.Clear();
                etbGridSize.Value = Global.GridSizeNum = p.GridSizeNum;

                //TODO: InsertImage 判断出错
                foreach (ImagePanel panel in p.Panels)
                {
                    foreach (ImageObj io in panel.Images)
                    {
                        MainPictureBox.InsertImage(io.Content, io.CssName, io.X, io.Y, io.Mark, io.Key);
                    }
                }

                if (tsbtnShowGrid.Checked != p.ShowGrid)
                {
                    tsbtnShowGrid.Checked = p.ShowGrid;
                    tsbtnShowGrid_Click(tsbtnShowGrid, e);
                }
                if (tsbtnAutoSorption.Checked != p.AutoSorption)
                {
                    tsbtnAutoSorption.Checked = p.AutoSorption;
                    tsbtnAutoSorption_CheckedChanged(tsbtnAutoSorption, e);
                }
                if (tsbShowLeftTree.Checked != p.ShowSider)
                {
                    tsbShowLeftTree.Checked = p.ShowSider;
                    toolStripButton1_CheckStateChanged(tsbShowLeftTree, e);
                }
                GridStyle gs = new GridStyle()
                {
                    BgColor = CommonLib.IntToColor(p.GridBgColor), LineColor = CommonLib.IntToColor(p.GridLineColor), LineWidth = p.GridLineWidth, Name = p.GridStyleName, ShowGrid = p.ShowGrid
                };
                MainPictureBox.ChangeColor(gs);
                Global.GridStyle = gs;

                Global.SavedPath    = openfileDialog.FileName;
                Global.ProjectSaved = true;
                Global.SetCurrentProject(p);
                ReWriteTitle();
            }
        }