Exemplo n.º 1
0
 //当选项卡发生变化时
 void mainTabControl_Selected(object sender, TabControlEventArgs e)
 {
     if (this.mainTabControl.SelectedTab.Text == this.CurrentStage.PaperName)
     {
         this.currentPaper = this.CurrentStage;
         this.currentPaper.RePaint();
     }
     else
     {
         for (int i = 0; i < this.LayerArrayList.Count; i++)
         {
             if (this.mainTabControl.SelectedTab.Text == ((EasyPhoto.EPControl.Layer) this.LayerArrayList[i]).PaperName)
             {
                 this.currentPaper = (EasyPhoto.EPControl.Layer) this.LayerArrayList[i];
                 this.currentPaper.RePaint();
                 break;
             }
         }
     }
     foreach (ToolStripButton tsbutton in this.mainToolStrip.Items)
     {
         tsbutton.CheckState = CheckState.Unchecked;
     }
     this.toolSelected = ToolSelected.None;
     this.initializeToolSelected();
     this.CheckLayerInformaiton();
 }
Exemplo n.º 2
0
        public void SelectTool(ITool tool)
        {
            ITool oldTool = null;
            ITool newTool = null;

            if (tool.IsActivatable)
            {
                if (ActivatedTools.Contains(tool))
                {
                    ActivatedTools.Remove(tool);
                }
                else
                {
                    ActivatedTools.Add(tool);
                }

                tool.IsActivated = ActivatedTools.Contains(tool);
            }
            else
            {
                oldTool = SelectedTool;

                SelectedTool?.Unselect();
                SelectedTool = tool;
                SelectedTool.Select();

                newTool = SelectedTool;
            }

            ToolSelected?.Invoke(this, new ToolSelectedEventArgs(oldTool, newTool));
        }
Exemplo n.º 3
0
        public void LoadData(IMotherboard motherboard)
        {
            Motherboard = new MotherboardRowData(motherboard ?? throw new ArgumentNullException(nameof(motherboard)));

            picMotherboard.ImageLocation = Motherboard.Images.FirstOrDefault()?.Url;
            txtId.Text          = Motherboard.Id;
            txtName.Text        = Motherboard.Name;
            txtBrand.Text       = Motherboard.Brand;
            txtModel.Text       = Motherboard.Model;
            txtVersion.Text     = Motherboard.Version;
            txtTags.Text        = Motherboard.TagsString;
            txtDescription.Text = Motherboard.Description;

            {
                List <ITool> tools = _model.Tools.Where(x => motherboard.ToolIds.Contains(x.Id)).ToList();

                flpTools.Controls.Clear();

                foreach (ITool item in tools)
                {
                    ITool     tool = item;
                    LinkLabel lbl  = new LinkLabel()
                    {
                        Text     = tool.Name,
                        AutoSize = true,
                        Anchor   = AnchorStyles.Left | AnchorStyles.Right
                    };

                    flpTools.Controls.Add(lbl);

                    lbl.Click += (s, a) =>
                    {
                        ToolSelected?.Invoke(this, tool);
                    };
                }
            }

            grdImages.DataSource = motherboard.Images.Select(x => new
            {
                x.Name,
                x.Url,
                Image = new Bitmap(x.Url)
            }).ToList();
            grdImages.AutoResizeColumns();

            grdBioses.DataSource = new GenericBindingList <BiosRowData>
                                   (
                _model
                .Bioses
                .Where(x => x.MotherboardIds.Contains(motherboard.Id))
                .Select(x => new BiosRowData(x))
                                   );
            grdBioses.AutoResizeColumns();

            grdLinks.DataSource = motherboard.Links;
            grdLinks.AutoResizeColumns();
        }
Exemplo n.º 4
0
        private void toggleButton_CheckedChanged(object sender, EventArgs e)
        {
            if (sender is ToolStripButton)
            {
                ToolStripButton button = (ToolStripButton)sender;

                if (button.Checked)
                {
                    if (button is ITool)
                    {
                        this.activeTool = (ITool)button;
                        Debug.WriteLine(this.activeTool.Name + " is activated.");

                        ToolSelected?.Invoke(this.activeTool);

                        UncheckInactiveToggleButtons();
                    }
                    else
                    {
                        throw new InvalidCastException("The tool is not an instance of ITool.");
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            EasyPhoto.FileInfo fileinfo = new FileInfo(".hdk", Application.StartupPath + @"\EasyPhoto.ico", "EasyPhoto文件", Application.StartupPath + @"\EasyPhoto.exe");
            EasyPhoto.FileTypeRegister.RegisterFileType(fileinfo);
            if (MainForm.DefaultPath != "")
            {
                string temp = (string)MainForm.DefaultPath.Clone();
                MainForm.DefaultPath = "";
                this.LoadFile(temp);
                return;
            }

            this.mainTabControl.Visible = false;

            this.DrawClientWidth  = this.ClientSize.Width - this.mainToolStrip.Width - this.imageTabControl.Width - 8;
            this.DrawClientHeight = this.ClientSize.Height - this.mainMenuStrip.Height - this.mainStatusStrip.Height - 5;

            //工具栏各工具的初始化
            this.mainTabControl.Visible = false;
            this.treeView1.Visible      = false;
            this.CurrentPen             = new Pen(new SolidBrush(Color.Black));
            this.TempPen      = (Pen)this.CurrentPen.Clone();
            TempPen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;
            this.CurrentBrush = new SolidBrush(Color.Black);
            this.UpdateFont(new FontFamily("宋体"), 12, FontStyle.Regular);
            this.toolSelected             = ToolSelected.None;
            this.currentMouseDownPosition = new Point();
            this.currentgraphics          = null;
            this.BrushRadius   = 1;
            this.IsMouseClick  = false;
            this.IsMouseDown   = false;
            this.IsCopyCell    = false;
            this.IsCopyLayer   = false;
            this.TempCell      = null;
            this.TempLayer     = null;
            this.Zoom          = 1;
            defaultTabPageName = "图层";
            currentPaper       = null;
            defaultTabPageNum  = 0;
            this.paperName     = "";
            this.CurrentStage  = null;
            this.LayerArrayList.Clear();
            this.tempArrayList.Clear();
            this.finalArrayList.Clear();
            try
            {
                HandCursor      = new Cursor(Application.StartupPath + @"\Resources\Hand.cur");
                PencilCursor    = new Cursor(Application.StartupPath + @"\Resources\Pencil.cur");
                MagnifierCursor = new Cursor(Application.StartupPath + @"\Resources\Magnifier.cur");
                EraserCursor    = new Cursor(Application.StartupPath + @"\Resources\Eraser.cur");
                BrushCursor     = new Cursor(Application.StartupPath + @"\Resources\Brush.cur");
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message, "图标加载失败");
                HandCursor      = Cursors.Default;
                PencilCursor    = Cursors.Default;
                MagnifierCursor = Cursors.Default;
                EraserCursor    = Cursors.Default;
                BrushCursor     = Cursors.Default;
            }

            this.CheckLayerInformaiton();
        }
Exemplo n.º 6
0
 private void OnToolSelected(string ToolName)
 {
     ToolSelected?.Invoke(this, new PropertyChangedEventArgs(ToolName));
 }