private void cmbPatternType_SelectedIndexChanged(object sender, EventArgs e) { if ((string)cmbPatternType.SelectedItem == "Simple") { if (tabPatternProperties.TabPages.Contains(tabPicture)) { tabPatternProperties.TabPages.Remove(tabPicture); } if (tabPatternProperties.TabPages.Contains(tabGradient)) { tabPatternProperties.TabPages.Remove(tabGradient); } if (tabPatternProperties.TabPages.Contains(tabHatch)) { tabPatternProperties.TabPages.Remove(tabHatch); } if (tabPatternProperties.TabPages.Contains(tabSimple) == false) { tabPatternProperties.TabPages.Add(tabSimple); tabPatternProperties.SelectedTab = tabSimple; } } if ((string)cmbPatternType.SelectedItem == "Picture") { if (tabPatternProperties.TabPages.Contains(tabSimple)) { tabPatternProperties.TabPages.Remove(tabSimple); } if (tabPatternProperties.TabPages.Contains(tabGradient)) { tabPatternProperties.TabPages.Remove(tabGradient); } if (tabPatternProperties.TabPages.Contains(tabHatch)) { tabPatternProperties.TabPages.Remove(tabHatch); } if (tabPatternProperties.TabPages.Contains(tabPicture) == false) { tabPatternProperties.TabPages.Add(tabPicture); tabPatternProperties.SelectedTab = tabPicture; } } if ((string)cmbPatternType.SelectedItem == "Gradient") { if (tabPatternProperties.TabPages.Contains(tabSimple)) { tabPatternProperties.TabPages.Remove(tabSimple); } if (tabPatternProperties.TabPages.Contains(tabPicture)) { tabPatternProperties.TabPages.Remove(tabPicture); } if (tabPatternProperties.TabPages.Contains(tabHatch)) { tabPatternProperties.TabPages.Remove(tabHatch); } if (tabPatternProperties.TabPages.Contains(tabGradient) == false) { tabPatternProperties.TabPages.Add(tabGradient); tabPatternProperties.SelectedTab = tabGradient; } } if ((string)cmbPatternType.SelectedItem == "Hatch") { if (tabPatternProperties.TabPages.Contains(tabSimple)) { tabPatternProperties.TabPages.Remove(tabSimple); } if (tabPatternProperties.TabPages.Contains(tabPicture)) { tabPatternProperties.TabPages.Remove(tabPicture); } if (tabPatternProperties.TabPages.Contains(tabGradient)) { tabPatternProperties.TabPages.Remove(tabGradient); } if (tabPatternProperties.TabPages.Contains(tabHatch) == false) { tabPatternProperties.TabPages.Add(tabHatch); tabPatternProperties.SelectedTab = tabHatch; } } if (_ignoreChanges) return; int index = ccPatterns.Patterns.IndexOf(ccPatterns.SelectedPattern); if (index == -1) return; IPattern oldPattern = ccPatterns.SelectedPattern; if ((string)cmbPatternType.SelectedItem == "Simple") { SimplePattern sp = new SimplePattern(); if (oldPattern != null) sp.CopyOutline(oldPattern); ccPatterns.Patterns[index] = sp; ccPatterns.RefreshList(); ccPatterns.SelectedPattern = sp; UpdateSimplePatternControls(sp); } if ((string)cmbPatternType.SelectedItem == "Picture") { PicturePattern pp = new PicturePattern(); if (oldPattern != null) pp.CopyOutline(oldPattern); ccPatterns.Patterns[index] = pp; ccPatterns.RefreshList(); ccPatterns.SelectedPattern = pp; UpdatePicturePatternControls(pp); } if ((string)cmbPatternType.SelectedItem == "Gradient") { GradientPattern gp = new GradientPattern(); if (oldPattern != null) gp.CopyOutline(oldPattern); ccPatterns.Patterns[index] = gp; ccPatterns.RefreshList(); ccPatterns.SelectedPattern = gp; UpdateGradientPatternControls(gp); } if ((string)cmbPatternType.SelectedItem == "Hatch") { HatchPattern hp = new HatchPattern(); if (oldPattern != null) hp.CopyOutline(oldPattern); ccPatterns.Patterns[index] = hp; ccPatterns.RefreshList(); ccPatterns.SelectedPattern = hp; } }
private void SetType(PatternTypes type) { _patternType = type; IPattern result = null; switch (type) { case PatternTypes.Gradient: result = new GradientPattern(); break; case PatternTypes.Line: break; case PatternTypes.Marker: break; case PatternTypes.Picture: result = new PicturePattern(); break; case PatternTypes.Simple: result = new SimplePattern(); break; } if (result != null) result.Outline = _innerPattern.Outline; _innerPattern = result; }