Esempio n. 1
0
        //@Construct
        /// <summary>
        /// Initializes a ConvertToCurvesButton.
        /// </summary>
        public ConvertToCurvesButton()
        {
            this.InitializeComponent();
            this.Button.Click += (s, e) =>
            {
                if (this.SelectionViewModel.SelectionMode == ListViewSelectionMode.None)
                {
                    return;
                }

                //History
                LayeragesArrangeHistory history = new LayeragesArrangeHistory("Convert to curves", this.ViewModel.LayerageCollection);
                this.ViewModel.HistoryPush(history);

                this.SelectionViewModel.SetValue((layerage) =>
                {
                    ILayer layer = layerage.Self;

                    //Turn to curve layer
                    ILayer curveLayer = this.CreateCurveLayer(layerage);

                    if (curveLayer != null)
                    {
                        Layerage curveLayerage = curveLayer.ToLayerage();
                        LayerBase.Instances.Add(curveLayer);

                        //set image brush
                        if (layer.Type == LayerType.Image)
                        {
                            ImageLayer imageLayer = (ImageLayer)layer;
                            curveLayer.Style.Fill = imageLayer.ToBrush();
                        }

                        this.ReplaceLayerage(curveLayerage, layerage);
                    }
                });

                LayerageCollection.ArrangeLayers(this.ViewModel.LayerageCollection);
                LayerageCollection.ArrangeLayersBackground(this.ViewModel.LayerageCollection);
                this.SelectionViewModel.SetMode(this.ViewModel.LayerageCollection);//Selection

                //Change tools group value.
                {
                    ITool tool = this.TipViewModel.Tools.First(t => t != null && t.Type == ToolType.Node);

                    ToolBase.Instance = tool;
                    this.SelectionViewModel.ToolType = ToolType.Node;

                    this.ViewModel.TipTextBegin(tool.Button.Title);
                    this.ViewModel.Invalidate();//Invalidate
                }
            };
        }