public void SetItem(IPointRule parent, IPointSymbolization2D point, Image img, double previewScale, int themeCategory) { if (point == null) { isPoint = false; isW2dSymbol = false; } else { isPoint = (point.Symbol.Type != PointSymbolType.W2D); isW2dSymbol = (point.Symbol.Type == PointSymbolType.W2D); } SetItemInternal(parent, point, previewScale, themeCategory); m_w2dsymbol = img; }
private void SetItemInternal(object parent, object item, double previewScale, int themeCategory) { m_parent = parent; m_label = item as ITextSymbol; m_point = item as IPointSymbolization2D; m_area = item as IAreaSymbolizationFill; m_comp = item as ICompositeSymbolization; m_w2dsymbol = item as Image; this.PreviewScale = previewScale; this.ThemeCategory = themeCategory; if (item is IEnumerable <IStroke> ) { m_line = new List <IStroke>((IEnumerable <IStroke>)item); } else { m_line = null; } }
private void EditRuleStyle(RuleModel rule) { PointRuleModel pr = rule as PointRuleModel; LineRuleModel lr = rule as LineRuleModel; AreaRuleModel ar = rule as AreaRuleModel; CompositeRuleModel cr = rule as CompositeRuleModel; UserControl uc = null; /* * if (m_owner.SelectedClass == null) * { * MessageBox.Show(Strings.NoFeatureClassAssigned); * return; * }*/ var previewScale = 0.0; if (_parentScaleRange.MinScale.HasValue) { previewScale = _parentScaleRange.MinScale.Value; } ILayerStylePreviewable prev = new LayerStylePreviewable(_edSvc.EditedResourceID, previewScale, 80, 40, "PNG", //NOXLATE this.ThemeIndexOffest + rule.Index); //TODO: This is obviously a mess and could do with some future cleanup, but the idea here should be //easy to understand. Each primitive basic style (that's not a label) has 3 actions. // - Commit (When user clicks OK on dialog) // - Rollback (When user clicks Cancel on dialog) // - Edit Commit (When user invokes refresh) //Those that support GETLEGENDIMAGE-based previews will be passed an edit commit action. Invoking the //edit commit action will update the session-based layer with this edit-copy rule, allowing for the changes //to be reflected when we do the GETLEGENDIMAGE call // //Labels are exempt as those previews can be sufficiently simulated with System.Drawing API var vl = (IVectorLayerDefinition)_editedLayer.SubLayer; ClassDefinition clsDef = GetLayerClass(); Action commit = null; Action rollback = null; if (pr != null) { var sym = pr.GetSymbolizationStyle(); m_origPoint = sym; m_editPoint = (sym == null) ? null : (IPointSymbolization2D)sym.Clone(); var pfse = new PointFeatureStyleEditor(_edSvc, clsDef, vl.ResourceId, pr.Style, prev); uc = pfse; pfse.Item = m_editPoint; Action editCommit = () => { m_editPoint = pfse.Item; pr.SetSymbolizationStyle(m_editPoint); }; pfse.SetEditCommit(editCommit); commit = () => { pr.SetSymbolizationStyle(pfse.Item); _edSvc.HasChanged(); UpdateRulePreviewAsync(pr); }; rollback = () => { pr.SetSymbolizationStyle(m_origPoint); }; } else if (lr != null) { var lineSym = lr.GetSymbolizationStyle(); var strokes = lineSym.Strokes; m_origLine = strokes; m_editLine = (strokes == null) ? new List <IStroke>() : LayerElementCloningUtil.CloneStrokes(strokes); var lfse = new LineFeatureStyleEditor(_edSvc, clsDef, vl.ResourceId, _editedLayer, prev); uc = lfse; lfse.Item = m_editLine; Action editCommit = () => { m_editLine = lfse.Item; lineSym.SetStrokes(m_editLine); }; lfse.SetEditCommit(editCommit); commit = () => { lineSym.SetStrokes(lfse.Item); _edSvc.HasChanged(); UpdateRulePreviewAsync(lr); }; rollback = () => { lineSym.SetStrokes(m_origLine); }; } else if (ar != null) { var area = ar.GetSymbolizationStyle(); m_origArea = area; m_editArea = (area == null) ? null : (IAreaSymbolizationFill)area.Clone(); var afse = new AreaFeatureStyleEditor(_edSvc, clsDef, vl.ResourceId, prev); uc = afse; afse.Item = m_editArea; Action editCommit = () => { m_editArea = afse.Item; ar.SetSymbolizationStyle(m_editArea); }; commit = () => { ar.SetSymbolizationStyle(afse.Item); _edSvc.HasChanged(); UpdateRulePreviewAsync(ar); }; rollback = () => { ar.SetSymbolizationStyle(m_origArea); }; afse.SetEditCommit(editCommit); } else if (cr != null) { var diag = new SymbolInstancesDialog(_edSvc, cr.GetSymbolizationStyle(), GetLayerClass(), GetLayerProvider(), vl.ResourceId, prev); diag.ShowDialog(); //HACK: Assume edits made _edSvc.HasChanged(); UpdateRulePreviewAsync(cr); return; } if (uc != null) { EditorTemplateForm dlg = new EditorTemplateForm(); dlg.ItemPanel.Controls.Add(uc); uc.Dock = DockStyle.Fill; dlg.RefreshSize(); var res = dlg.ShowDialog(this); if (res == DialogResult.OK) { if (commit != null) { commit.Invoke(); } if (pr != null) { _edSvc.HasChanged(); } else if (lr != null) { _edSvc.HasChanged(); } else if (ar != null) { _edSvc.HasChanged(); } } else if (res == DialogResult.Cancel) { if (rollback != null) { rollback.Invoke(); } } } }
private void SetItemInternal(object parent, object item, double previewScale, int themeCategory) { m_parent = parent; m_label = item as ITextSymbol; m_point = item as IPointSymbolization2D; m_area = item as IAreaSymbolizationFill; m_comp = item as ICompositeSymbolization; m_w2dsymbol = item as Image; this.PreviewScale = previewScale; this.ThemeCategory = themeCategory; if (item is IEnumerable<IStroke>) m_line = new List<IStroke>((IEnumerable<IStroke>)item); else m_line = null; }
private void EditButton_Click(object sender, EventArgs e) { UserControl uc = null; if (m_owner.SelectedClass == null) { MessageBox.Show(Strings.NoFeatureClassAssigned); return; } ILayerStylePreviewable prev = new LayerStylePreviewable(m_owner.EditorService.EditedResourceID, this.PreviewScale, 80, 40, "PNG", //NOXLATE this.ThemeCategory); //TODO: This is obviously a mess and could do with some future cleanup, but the idea here should be //easy to understand. Each primitive basic style (that's not a label) has 3 actions. // - Commit (When user clicks OK on dialog) // - Rollback (When user clicks Cancel on dialog) // - Edit Commit (When user invokes refresh) //Those that support GETLEGENDIMAGE-based previews will be passed an edit commit action. Invoking the //edit commit action will update the session-based layer with this edit-copy rule, allowing for the changes //to be reflected when we do the GETLEGENDIMAGE call // //Labels are exempt as those previews can be sufficiently simulated with System.Drawing API var factory = (ILayerElementFactory)m_owner.Editor.GetEditedResource(); Action commit = null; Action rollback = null; if (isLabel) { m_origLabel = m_label; m_editLabel = (m_label == null) ? null : (ITextSymbol)m_label.Clone(); uc = new FontStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId); ((FontStyleEditor)uc).Item = m_editLabel; } else if (isW2dSymbol) { m_origPoint = m_point; m_editPoint = (m_point == null) ? null : (IPointSymbolization2D)m_point.Clone(); var pfse = new PointFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, m_w2dsymbol, prev); uc = pfse; pfse.Item = m_editPoint; Action editCommit = () => { //We need to update this boolean state var w2d = pfse.W2DSymbolPreviewImage; this.isPoint = (w2d == null); this.isW2dSymbol = (w2d != null); m_editPoint = pfse.Item; ((IPointRule)m_parent).PointSymbolization2D = m_editPoint; m_w2dsymbol = w2d; }; pfse.SetEditCommit(editCommit); commit = () => { //We need to update this boolean state var w2d = pfse.W2DSymbolPreviewImage; this.isPoint = (w2d == null); this.isW2dSymbol = (w2d != null); m_point = pfse.Item; ((IPointRule)m_parent).PointSymbolization2D = m_point; m_w2dsymbol = w2d; }; rollback = () => { ((IPointRule)m_parent).PointSymbolization2D = m_origPoint; }; } else if (isPoint) { m_origPoint = m_point; m_editPoint = (m_point == null) ? null : (IPointSymbolization2D)m_point.Clone(); var pfse = new PointFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, prev); uc = pfse; pfse.Item = m_editPoint; Action editCommit = () => { //We need to update this boolean state var w2d = pfse.W2DSymbolPreviewImage; this.isPoint = (w2d == null); this.isW2dSymbol = (w2d != null); m_editPoint = pfse.Item; ((IPointRule)m_parent).PointSymbolization2D = m_editPoint; m_w2dsymbol = w2d; }; pfse.SetEditCommit(editCommit); commit = () => { //We need to update this boolean state var w2d = pfse.W2DSymbolPreviewImage; this.isPoint = (w2d == null); this.isW2dSymbol = (w2d != null); m_point = pfse.Item; ((IPointRule)m_parent).PointSymbolization2D = m_point; m_w2dsymbol = w2d; }; rollback = () => { ((IPointRule)m_parent).PointSymbolization2D = m_origPoint; }; } else if (isLine) { m_origLine = m_line; m_editLine = (m_line == null) ? new List<IStroke>() : LayerElementCloningUtil.CloneStrokes(m_line); var lfse = new LineFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, factory, prev); uc = lfse; lfse.Item = m_editLine; Action editCommit = () => { m_editLine = lfse.Item; ((ILineRule)m_parent).SetStrokes(m_editLine); }; lfse.SetEditCommit(editCommit); commit = () => { m_line = lfse.Item; ((ILineRule)m_parent).SetStrokes(m_line); }; rollback = () => { ((ILineRule)m_parent).SetStrokes(m_origLine); }; } else if (isArea) { m_origArea = m_area; m_editArea = (m_area == null) ? null : (IAreaSymbolizationFill)m_area.Clone(); var afse = new AreaFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, prev); uc = afse; afse.Item = m_editArea; Action editCommit = () => { m_editArea = afse.Item; ((IAreaRule)m_parent).AreaSymbolization2D = m_editArea; }; commit = () => { m_area = afse.Item; ((IAreaRule)m_parent).AreaSymbolization2D = m_area; }; rollback = () => { ((IAreaRule)m_parent).AreaSymbolization2D = m_origArea; }; afse.SetEditCommit(editCommit); } else if (isComp) { var diag = new SymbolInstancesDialog(m_owner.Editor, m_comp, m_owner.SelectedClass, m_owner.GetFdoProvider(), m_owner.FeatureSourceId, prev); diag.ShowDialog(); //HACK: Assume edits made Owner.RaiseResourceChanged(); return; } if (uc != null) { EditorTemplateForm dlg = new EditorTemplateForm(); dlg.ItemPanel.Controls.Add(uc); uc.Dock = DockStyle.Fill; dlg.RefreshSize(); var res = dlg.ShowDialog(this); if (res == DialogResult.OK) { if (commit != null) { commit.Invoke(); } if (isLabel) { m_label = ((FontStyleEditor)uc).Item; if (m_parent as IPointRule != null) ((IPointRule)m_parent).Label = m_label; else if (m_parent as ILineRule != null) ((ILineRule)m_parent).Label = m_label; else if (m_parent as IAreaRule != null) ((IAreaRule)m_parent).Label = m_label; if (ItemChanged != null) ItemChanged(m_label, null); } else if (isPoint || isW2dSymbol) { if (ItemChanged != null) ItemChanged(m_point, null); } else if (isLine) { if (ItemChanged != null) ItemChanged(m_line, null); } else if (isArea) { if (ItemChanged != null) ItemChanged(m_area, null); } this.Refresh(); } else if (res == DialogResult.Cancel) { if (rollback != null) rollback.Invoke(); } } }
private void EditButton_Click(object sender, EventArgs e) { UserControl uc = null; if (m_owner.SelectedClass == null) { MessageBox.Show(Strings.NoFeatureClassAssigned); return; } ILayerStylePreviewable prev = new LayerStylePreviewable(m_owner.EditorService.EditedResourceID, this.PreviewScale, 80, 40, "PNG", //NOXLATE _themeOffset + this.ThemeCategory); //TODO: This is obviously a mess and could do with some future cleanup, but the idea here should be //easy to understand. Each primitive basic style (that's not a label) has 3 actions. // - Commit (When user clicks OK on dialog) // - Rollback (When user clicks Cancel on dialog) // - Edit Commit (When user invokes refresh) //Those that support GETLEGENDIMAGE-based previews will be passed an edit commit action. Invoking the //edit commit action will update the session-based layer with this edit-copy rule, allowing for the changes //to be reflected when we do the GETLEGENDIMAGE call // //Labels are exempt as those previews can be sufficiently simulated with System.Drawing API var factory = (ILayerElementFactory)m_owner.Editor.GetEditedResource(); Action commit = null; Action rollback = null; if (isLabel) { m_origLabel = m_label; m_editLabel = (m_label == null) ? null : (ITextSymbol)m_label.Clone(); uc = new FontStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId); ((FontStyleEditor)uc).Item = m_editLabel; } else if (isW2dSymbol) { m_origPoint = m_point; m_editPoint = (m_point == null) ? null : (IPointSymbolization2D)m_point.Clone(); var pfse = new PointFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, m_w2dsymbol, prev); uc = pfse; pfse.Item = m_editPoint; Action editCommit = () => { //We need to update this boolean state var w2d = pfse.W2DSymbolPreviewImage; this.isPoint = (w2d == null); this.isW2dSymbol = (w2d != null); m_editPoint = pfse.Item; ((IPointRule)m_parent).PointSymbolization2D = m_editPoint; m_w2dsymbol = w2d; }; pfse.SetEditCommit(editCommit); commit = () => { //We need to update this boolean state var w2d = pfse.W2DSymbolPreviewImage; this.isPoint = (w2d == null); this.isW2dSymbol = (w2d != null); m_point = pfse.Item; ((IPointRule)m_parent).PointSymbolization2D = m_point; m_w2dsymbol = w2d; }; rollback = () => { ((IPointRule)m_parent).PointSymbolization2D = m_origPoint; }; } else if (isPoint) { m_origPoint = m_point; m_editPoint = (m_point == null) ? null : (IPointSymbolization2D)m_point.Clone(); var pfse = new PointFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, prev); uc = pfse; pfse.Item = m_editPoint; Action editCommit = () => { //We need to update this boolean state var w2d = pfse.W2DSymbolPreviewImage; this.isPoint = (w2d == null); this.isW2dSymbol = (w2d != null); m_editPoint = pfse.Item; ((IPointRule)m_parent).PointSymbolization2D = m_editPoint; m_w2dsymbol = w2d; }; pfse.SetEditCommit(editCommit); commit = () => { //We need to update this boolean state var w2d = pfse.W2DSymbolPreviewImage; this.isPoint = (w2d == null); this.isW2dSymbol = (w2d != null); m_point = pfse.Item; ((IPointRule)m_parent).PointSymbolization2D = m_point; m_w2dsymbol = w2d; }; rollback = () => { ((IPointRule)m_parent).PointSymbolization2D = m_origPoint; }; } else if (isLine) { m_origLine = m_line; m_editLine = (m_line == null) ? new List <IStroke>() : LayerElementCloningUtil.CloneStrokes(m_line); var lfse = new LineFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, factory, prev); uc = lfse; lfse.Item = m_editLine; Action editCommit = () => { m_editLine = lfse.Item; ((ILineRule)m_parent).SetStrokes(m_editLine); }; lfse.SetEditCommit(editCommit); commit = () => { m_line = lfse.Item; ((ILineRule)m_parent).SetStrokes(m_line); }; rollback = () => { ((ILineRule)m_parent).SetStrokes(m_origLine); }; } else if (isArea) { m_origArea = m_area; m_editArea = (m_area == null) ? null : (IAreaSymbolizationFill)m_area.Clone(); var afse = new AreaFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, prev); uc = afse; afse.Item = m_editArea; Action editCommit = () => { m_editArea = afse.Item; ((IAreaRule)m_parent).AreaSymbolization2D = m_editArea; }; commit = () => { m_area = afse.Item; ((IAreaRule)m_parent).AreaSymbolization2D = m_area; }; rollback = () => { ((IAreaRule)m_parent).AreaSymbolization2D = m_origArea; }; afse.SetEditCommit(editCommit); } else if (isComp) { var diag = new SymbolInstancesDialog(m_owner.Editor, m_comp, m_owner.SelectedClass, m_owner.GetFdoProvider(), m_owner.FeatureSourceId, prev); diag.ShowDialog(); //HACK: Assume edits made Owner.RaiseResourceChanged(); return; } if (uc != null) { EditorTemplateForm dlg = new EditorTemplateForm(); dlg.ItemPanel.Controls.Add(uc); uc.Dock = DockStyle.Fill; dlg.RefreshSize(); var res = dlg.ShowDialog(this); if (res == DialogResult.OK) { if (commit != null) { commit.Invoke(); } if (isLabel) { m_label = ((FontStyleEditor)uc).Item; if (m_parent as IPointRule != null) { ((IPointRule)m_parent).Label = m_label; } else if (m_parent as ILineRule != null) { ((ILineRule)m_parent).Label = m_label; } else if (m_parent as IAreaRule != null) { ((IAreaRule)m_parent).Label = m_label; } ItemChanged?.Invoke(m_label, null); } else if (isPoint || isW2dSymbol) { ItemChanged?.Invoke(m_point, null); } else if (isLine) { ItemChanged?.Invoke(m_line, null); } else if (isArea) { ItemChanged?.Invoke(m_area, null); } this.Refresh(); } else if (res == DialogResult.Cancel) { if (rollback != null) { rollback.Invoke(); } } } }
internal PointFeatureStyleEditor(IEditorService editor, ClassDefinition schema, string featureSource, ILayerStylePreviewable prev) : this() { m_editor = editor; m_schema = schema; _factory = (ILayerElementFactory)editor.GetEditedResource(); var fs = (IFeatureSource)editor.ResourceService.GetResource(featureSource); m_providername = fs.Provider; m_featureSource = featureSource; m_item = _factory.CreateDefaultPointSymbolization2D(); _preview = prev; var conn = editor.GetEditedResource().CurrentConnection; if (Array.IndexOf(conn.Capabilities.SupportedServices, (int)ServiceType.Mapping) >= 0) { _mappingSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping); } lnkRefresh.Visible = this.UseLayerIconPreview; }