예제 #1
0
파일: Form1.cs 프로젝트: fel88/Dendrite
        private void dagreToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CurrentLayout = new DagreGraphLayout();
            WaitDialog wd = new WaitDialog();

            drawEnabled = false;
            wd.Init(() =>
            {
                CurrentLayout.GetRenderTextWidth = renderTextWidth;
                CurrentLayout.Layout(Model);
                drawEnabled = true;
            });
            wd.ShowDialog();
            fitAll();
        }
예제 #2
0
파일: Form1.cs 프로젝트: fel88/Dendrite
        public bool LoadModel(string path, bool _fitAll = true)
        {
            if (ParentForm != null)
            {
                ParentForm.FormClosing += ParentForm_FormClosing;
            }
            _lastPath = path;
            var fr = Providers.FirstOrDefault(z => z.IsSuitableFile(path));

            if (fr == null)
            {
                MessageBox.Show("Unsupported file format.", WindowCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            Stopwatch  sw = new Stopwatch();
            WaitDialog wd = new WaitDialog();

            timer1.Enabled = false;
            Action loadAct = () =>
            {
                sw.Start();
                var model = fr.LoadFromFile(path);
                Model = model;
                if (!loadedModels.Any(z => z.ToLower() == path.ToLower()))
                {
                    loadedModels.Add(path);
                }

                listView1.Items.Clear();

                foreach (var item in model.Nodes)
                {
                    //listView1.Items.Add(new ListViewItem(new string[] { item.Name, ss, item.Output[0] }) { Tag = nodes[i] });
                }

                //var cnt2 = res2.Graph.Output[0].Name;
                //nodes.InsertRange(0, res2.Graph.Input.Select(z => outs[z.Name]));

                updateNodesSizes();
                CurrentLayout.GetRenderTextWidth = renderTextWidth;
                CurrentLayout.Layout(Model);

                //Text = $"{WindowCaption}: {Path.GetFileName(path)}";
                if (ParentForm != null)
                {
                    ParentForm.Invoke((Action)(() =>
                    {
                        ParentForm.Text = Path.GetFileName(path);
                    }));
                }
                drawEnabled = true;
                reset.Set();
                if (_fitAll)
                {
                    fitAll();
                }
                sw.Stop();
            };

            drawEnabled = false;

            wd.Init(loadAct);
            wd.ShowDialog();
            timer1.Enabled = true;
            if (wd.Exception != null)
            {
                Helpers.ShowError(wd.Exception.Message, Program.MainForm.Text);
            }
            Program.MainForm.SetStatusMessage($"Load time: {sw.ElapsedMilliseconds} ms");

            return(true);
        }