Exemple #1
0
        private void LoadView()
        {
            if (this.FIsLoaded)
            {
                return;
            }

            this.ugLayers.Children.Clear();
            this.sp.Children.Remove(this.FCommonLayer);
            this.ugShapeValue.Children.Clear();

            this.sp.Orientation = this.IsHighDefenition ? Orientation.Horizontal : Orientation.Vertical;

            this.ugLayers.Columns = this.IsHighDefenition ? 2 : 1;
            this.ugLayers.Rows    = this.LayersNumber / this.ugLayers.Columns + 1;

            this.ugShapeValue.Columns = this.ShapeSize;
            this.ugShapeValue.Rows    = this.ShapeSize;
            for (int i = 0; i < this.ShapeSize; i++)
            {
                for (int j = 0; j < this.ShapeSize; j++)
                {
                    TextBox _tb = new TextBox();
                    _tb.MinWidth = this.IsHighDefenition ? 27 : 18;
                    this.ugShapeValue.Children.Add(_tb);
                    Binding _binding = new Binding(ShapeCellViewModel.ShapeCellValuePropertyName);
                    _binding.Source = this.ViewModel.Data[j, i];
                    _binding.Mode   = BindingMode.TwoWay;
                    _tb.SetBinding(TextBox.TextProperty, _binding);
                }
            }

            LayerViewModel _commonViewModel = new LayerViewModel(this.IsHighDefenition, -1);

            this.FCommonLayer = new LayerView(_commonViewModel);
            foreach (LayerCellViewModel _cell in this.FCommonLayer.ViewModel.Cells)
            {
                _cell.PropertyChanged += CommonCell_PropertyChanged;
            }
            this.FCommonLayer.Margin = new Thickness(2, 0, 2, 0);
            this.FCommonLayer.Header = "All Layers";
            this.sp.Children.Add(this.FCommonLayer);

            this.FLayers = new List <LayerView>(this.LayersNumber);
            for (int k = this.LayersNumber - 1; k >= 0; k--)
            {
                LayerView _layer = new LayerView(this.ViewModel.Layers[k]);
                foreach (LayerCellViewModel _cell in _layer.ViewModel.Cells)
                {
                    _cell.PropertyChanged += Cell_PropertyChanged;
                }
                _layer.Number = String.Format("{0}", k + 1);
                _layer.Margin = new Thickness(2, 0, 2, 0);
                this.ugLayers.Children.Add(_layer);
                this.FLayers.Add(_layer);
            }

            this.FIsLoaded = true;
        }
 public LayerView(LayerViewModel aViewModel)
 {
     this.ViewModel = aViewModel;
     InitializeComponent();
 }