コード例 #1
0
        public void LoadGraph(string data, string CWD, bool readOnly = false)
        {
            Release();

            Graph = new ImageGraph("Untitled");

            if (string.IsNullOrEmpty(data))
            {
                return;
            }

            Original = Graph;

            Graph.CWD = CWD;
            Graph.FromJson(data);
            HdriManager.Selected = Graph.HdriIndex;

            Graph.OnGraphUpdated += Graph_OnGraphUpdated;

            Scale  = Graph.Zoom;
            XShift = Graph.ShiftX;
            YShift = Graph.ShiftY;

            ZoomLevel.Text = String.Format("{0:0}", Scale * 100);

            LoadGraphUI();
            ReadOnly = readOnly;

            Crumbs.Clear();

            BreadCrumb cb = new BreadCrumb(Crumbs, "Root", this, null);
        }
コード例 #2
0
        public UIGraph()
        {
            InitializeComponent();

            Id = Guid.NewGuid().ToString();

            GraphStack    = new Stack <GraphStackItem>();
            SelectedNodes = new List <UINode>();

            selectionRect        = new Rectangle();
            selectionRect.Stroke = new SolidColorBrush(Colors.DarkRed);
            selectionRect.StrokeDashArray.Add(2);
            selectionRect.StrokeDashArray.Add(2);
            selectionRect.StrokeDashCap       = PenLineCap.Round;
            selectionRect.StrokeEndLineCap    = PenLineCap.Round;
            selectionRect.StrokeThickness     = 1;
            selectionRect.HorizontalAlignment = HorizontalAlignment.Left;
            selectionRect.VerticalAlignment   = VerticalAlignment.Top;

            selectionRect.Fill = null;
            selectionRect.RenderTransformOrigin = new Point(0, 0);

            lookup    = new Dictionary <string, UINode>();
            Scale     = 1;
            PrevScale = 1;

            moving     = false;
            GraphNodes = new List <UINode>();
            Original   = Graph = new ImageGraph("Untitled");

            UpdateGrid();

            Crumbs.Clear();

            ConnectionPointPreview.RadiusX = 8;
            ConnectionPointPreview.RadiusY = 8;

            ConnectionPointPreview.Width  = 16;
            ConnectionPointPreview.Height = 16;

            ConnectionPointPreview.Fill = new SolidColorBrush(Colors.DarkRed);

            ConnectionPointPreview.HorizontalAlignment = HorizontalAlignment.Left;
            ConnectionPointPreview.VerticalAlignment   = VerticalAlignment.Top;

            ConnectionPathPreview.HorizontalAlignment = HorizontalAlignment.Left;
            ConnectionPathPreview.VerticalAlignment   = VerticalAlignment.Top;

            ConnectionPathPreview.Stroke = new SolidColorBrush(Colors.DarkRed);

            ConnectionPointPreview.IsHitTestVisible = false;
            ConnectionPathPreview.IsHitTestVisible  = false;

            BreadCrumb cb = new BreadCrumb(Crumbs, "Root", this, null);
        }
コード例 #3
0
        public void FromJson(string json, Graph parentGraph, MTGArchive archive = null)
        {
            LayerData d = JsonConvert.DeserializeObject <LayerData>(json);

            if (d == null)
            {
                return;
            }


            if (d.blendModes != null)
            {
                foreach (LayerPasses pass in d.blendModes.Keys)
                {
                    blendModes[pass] = d.blendModes[pass];
                }
            }
            if (d.opacityModes != null)
            {
                foreach (LayerPasses pass in d.opacityModes.Keys)
                {
                    opacityModes[pass] = d.opacityModes[pass];
                }
            }

            Name    = d.name;
            visible = d.visible;
            width   = d.width;
            height  = d.height;
            Id      = d.id;

            Graph temp = new ImageGraph(Name, width, height, parentGraph);

            temp.FromJson(d.core, archive);
            Core = temp;

            if (!string.IsNullOrEmpty(d.mask))
            {
                Node n = null;
                if (Core.NodeLookup.TryGetValue(d.mask, out n))
                {
                    Mask = n;
                }
            }

            if (parentGraph != null)
            {
                parentGraph.LayerLookup[Id] = this;
            }
        }
コード例 #4
0
        private void CreateButton_Click(object sender, RoutedEventArgs e)
        {
            GraphPixelType px;

            string spx = (DefaultFormat.SelectedItem as ComboBoxItem).Content.ToString();

            if (!Enum.TryParse(spx, out px))
            {
                px = GraphPixelType.RGBA;
            }

            int sizeIndex = DefaultNodeSize.SelectedIndex;
            int size      = Graph.DEFAULT_SIZE;

            if (sizeIndex > -1 && sizeIndex < Graph.GRAPH_SIZES.Length)
            {
                size = Graph.GRAPH_SIZES[sizeIndex];
            }

            ImageGraph g = new ImageGraph("Untitled", size, size);

            g.DefaultTextureType = px;
            Result = g;

            switch (TemplateType.SelectedIndex)
            {
            case 0:
                PBRFullTemplate();
                break;

            case 1:
                PBRNoHeightTemplate();
                break;

            case 2:
                PBRNoHeightAOTemplate();
                break;

            case 3:
                PBRNoHeightAONormalTemplate();
                break;

            default:
                break;
            }

            DialogResult = true;
        }
コード例 #5
0
        public Layer(string name, int w, int h, Graph parent)
        {
            opacityModes = new Dictionary <LayerPasses, float>();
            blendModes   = new Dictionary <LayerPasses, BlendType>();

            Id               = Guid.NewGuid().ToString();
            Name             = name;
            width            = w;
            height           = h;
            Core             = new ImageGraph(name, w, h);
            Core.ParentGraph = parent;

            ParentGraph = parent;

            Blending  = BlendType.Copy;
            Opacity   = 1.0f;
            processor = new BlendProcessor();

            InitDefaultModes();
        }
コード例 #6
0
        void PrepareGraph()
        {
            isDirty   = true;
            GraphInst = new ImageGraph(Name, width, height);
            GraphInst.AssignParentNode(this);
            GraphInst.FromJson(GraphData, child);

            GraphInst.AssignParameters(jsonParameters);
            GraphInst.AssignCustomParameters(jsonCustomParameters);
            GraphInst.AssignSeed(randomSeed);
            GraphInst.AssignPixelType(internalPixelType);
            GraphInst.OnGraphParameterUpdate += GraphInst_OnGraphParameterUpdate;
            //now do real initial resize
            GraphInst.ResizeWith(width, height);

            GraphInst.InitializeRenderTextures();
            //mark as readonly
            GraphInst.ReadOnly = true;

            //setup inputs and outputs
            Setup();
            loading = false;
        }