/// <summary>
 /// 添加应急联动的窗体
 /// </summary>
 /// <param name="jsonStr">jsonStr</param>
 private void AddForm(string jsonStr = "")
 {
     try
     {
         GraphDrawing form;
         if (string.IsNullOrWhiteSpace(jsonStr))
         {
             form = new GraphDrawing();
         }
         else
         {
             form = new GraphDrawing(jsonStr);
         }
         form.FormBorderStyle = FormBorderStyle.None;
         form.MaximizeBox     = false;
         form.MinimizeBox     = false;
         form.TopLevel        = false;
         form.ControlBox      = false;
         form.WindowState     = FormWindowState.Normal;
         form.Visible         = true;
         form.Dock            = DockStyle.Fill;
         if (groupControlForm.Controls.Count > 0)
         {
             GraphDrawing itemForm = groupControlForm.Controls[0] as GraphDrawing;
             itemForm.Close();
             itemForm.Dispose();
         }
         groupControlForm.Controls.Add(form);
     }
     catch (Exception ex)
     {
         LogHelper.Error(ex.Message);
     }
 }
Example #2
0
        public MainWindow()
        {
            InitializeComponent();
            GraphBuilder_SizeChanged(null, null);

            graphDrawing = new GraphDrawing(DrawingSurface.Width, DrawingSurface.Height);

            graphDrawing.RadiusChanged += (sender, args1) =>
            {
                if (BasicTypeCheckBox.Checked)
                {
                    graphDrawing.DrawTheWholeGraph(digraph);
                }
                else
                {
                    graphDrawing.DrawTheWholeGraphSandpile(digraph, false);
                }
                DrawingSurface.Image = graphDrawing.Image;
            };

            VerticesColorPanel.BackColor = graphDrawing.VerticesColor;
            ArcsColorPanel.BackColor     = graphDrawing.ArcsColor;

            graphDrawing.SandpilePaletteChanged +=
                (sender, e) =>
                DigraphInformationDemonstration.DisplaySandpileColors(graphDrawing, SandpilePalette);

            CommandsManager.CanRedoChanged += (sender, e) => RedoButton.Enabled = (bool)sender;
            CommandsManager.CanUndoChanged += (sender, e) => UndoButton.Enabled = (bool)sender;
        }
Example #3
0
        /// <summary>
        /// Initializes new instance of MovementModeling class
        /// </summary>
        /// <param name="digraph">Digraph</param>
        /// <param name="speed">Speed in unit per millisecond</param>
        /// <param name="type">Modeling type</param>
        /// <param name="actions">Array of additional actions</param>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="ArgumentOutOfRangeException"/>
        public MovementModeling(Digraph digraph, double speed, MovementModelingType type, MovementModelingActions[] actions)
        {
            if (speed <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(speed), @"Speed of movement should be positive");
            }
            this.digraph = digraph ?? throw new ArgumentNullException(nameof(digraph));
            this.speed   = speed;
            this.type    = type;
            this.actions = actions;
            IsActive     = false;

            MovementEnded += (sender, e) =>
            {
                if (type == MovementModelingType.Sandpile)
                {
                    GraphDrawing.DrawTheWholeGraphSandpile(digraph, false);
                }
                if (type == MovementModelingType.Basic)
                {
                    GraphDrawing.DrawTheWholeGraph(digraph);
                }
                DrawingSurface.Image = GraphDrawing.Image;
            };

            verticesTime = new List <double>(digraph.Vertices.Count);
            verticesTime.AddRange(digraph.Vertices.ConvertAll(vertex => 0d));
            stateReleaseCondition = i =>
                                    type == MovementModelingType.Sandpile && digraph.State[i] >= incidenceList[i].Count ||
                                    type == MovementModelingType.Basic && digraph.State[i] >= digraph.Thresholds[i];

            refractoryPeriodAdded = new bool[digraph.Vertices.Count];
            hasFired  = new bool[digraph.Vertices.Count];
            lastFires = new Double[digraph.Vertices.Count];
        }
        /// <summary>
        /// 清除联动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnClear_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var graph = new GraphicOperations();

            graph.DoClearDrawing(GraphDrawing.Mapobj);
            GraphDrawing gr = new GraphDrawing();

            gr.Jsonstr = "";
        }
 private void SetEmergencyLinkage_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (groupControlForm.Controls.Count > 0)
     {
         GraphDrawing itemForm = groupControlForm.Controls[0] as GraphDrawing;
         itemForm.Close();
         itemForm.Dispose();
     }
 }
 /// <summary>
 /// Initializes a new ChangeColorCommand instance
 /// </summary>
 /// <param name="target">GraphDrawing instance in which color is changed</param>
 /// <param name="type">Shows if the color of arcs or vertices is changed</param>
 /// <param name="oldColor">Color before changes</param>
 /// <param name="newColor">New color</param>
 /// <exception cref="ArgumentException"/>
 public ChangeColorCommand(GraphDrawing target, Type type, Color oldColor, Color newColor)
 {
     if (type != typeof(Arc) && type != typeof(Vertex))
     {
         throw new ArgumentException(nameof(type));
     }
     this.target   = target;
     this.type     = type;
     this.oldColor = oldColor;
     this.newColor = newColor;
 }
 /// <summary>
 /// Initializes a new ChangeColorCommand instance
 /// </summary>
 /// <param name="target">GraphDrawing instance in which color is changed</param>
 /// <param name="oldRadius">Previous vertices radius</param>
 /// <param name="newRadius">New vertices radius</param>
 /// <exception cref="ArgumentException"/>
 public ChangeRadiusCommand(GraphDrawing target, int oldRadius, int newRadius)
 {
     if (oldRadius < 8)
     {
         throw new ArgumentOutOfRangeException(nameof(oldRadius));
     }
     if (newRadius < 8)
     {
         throw new ArgumentOutOfRangeException(nameof(newRadius));
     }
     this.target    = target;
     this.oldRadius = oldRadius;
     this.newRadius = newRadius;
 }
        /// <summary>
        /// Draws all the moving dots, removes all the dots got to their destination
        /// and releases new dots if destination vertices are ready
        /// </summary>
        private void ProcessDots()
        {
            if (type == MovementModelingType.Basic)
            {
                GraphDrawing.DrawTheWholeGraph(digraph);
            }
            else
            {
                GraphDrawing.DrawTheWholeGraphSandpile(digraph, false);
            }

            int newOldMax = -1;

            for (var i = 0; i < involvedArcs.Count; i++)
            {
                if (stopwatches[i].ElapsedMilliseconds >= GetTime(involvedArcs[i].Length, speed))
                {
                    if (Math.Max(dotsTime[i], verticesTime[involvedArcs[i].EndVertex]) > oldMax)
                    {
                        oldMax = Math.Max(dotsTime[i], verticesTime[involvedArcs[i].EndVertex]);
                    }
                    bool addTime = !stateReleaseCondition(involvedArcs[i].EndVertex);

                    digraph.State[involvedArcs[i].EndVertex]++;

                    if (verticesTime[involvedArcs[i].EndVertex] < dotsTime[i])
                    {
                        verticesTime[involvedArcs[i].EndVertex] = dotsTime[i];
                    }
                    if (!releaseCondition(involvedArcs[i].EndVertex) &&
                        stateReleaseCondition(involvedArcs[i].EndVertex) && addTime)
                    {
                        verticesTime[involvedArcs[i].EndVertex] += digraph.RefractoryPeriods[involvedArcs[i].EndVertex] -
                                                                   dotsTime[i] + lastFires[involvedArcs[i].EndVertex];

                        refractoryPeriodAdded[involvedArcs[i].EndVertex] = true;
                    }

                    stopwatches.RemoveAt(i);
                    involvedArcs.RemoveAt(i);
                    dotsTime.RemoveAt(i);

                    i--;
                    continue;
                }

                PointF point =
                    GetPoint(digraph.Vertices[involvedArcs[i].StartVertex],
                             digraph.Vertices[involvedArcs[i].EndVertex],
                             involvedArcs[i].Length,
                             stopwatches[i]);

                GraphDrawing.DrawDot(point);
            }

            if (newOldMax > 0)
            {
                oldMax = newOldMax;
            }

            CheckDotsNumber(20000);

            if (type == MovementModelingType.Basic)
            {
                GraphDrawing.DrawVertices(digraph);
            }
            else
            {
                GraphDrawing.DrawVerticesSandpile(digraph);
            }
            DrawingSurface.Image = GraphDrawing.Image;
        }
        public Form1()
        {
            InitializeComponent();

            if (System.IO.File.Exists("config.txt"))
            {
                string[] lines = System.IO.File.ReadAllLines("config.txt");
                if (lines.Length == 0)
                {
                    MessageBox.Show("Configuration file config.txt is empty");
                    this.Enabled = false;
                }
                else
                {
                    connString = lines[0];
                }
            }
            else
            {
                MessageBox.Show("Configuration file doesn't exist");
                this.Enabled = false;
            }

            ConnToDB.ConnectionString = connString;
            materijaliSt                     = new MaterijaliStorage();
            vrstaObradeSt                    = new VrstaObradeStorage();
            tipObradeSt                      = new TipObradeStorage();
            oblikPlociceSt                   = new ObliciPlocicaStorage();
            kvalitetObradeSt                 = new KvalitetObradeStorage();
            dodaciSt                         = new DodaciStorage();
            pripremaciSt                     = new PripremciStorage();
            kvalitetiRPlSt                   = new KvalitetiReznihPlocicaStorage();
            prepRezimiSt                     = new PrepRezimiStorage();
            drzaciSt                         = new DrzaciAlataStorage();
            masineSt                         = new MasineDataStorage();
            preporukeISOPSt                  = new PreporukeISOPStorage();
            gradacijeObradeSt                = new GradacijeObradaStorage();
            interpolacijaBrzina              = new InterpolacijaBrzina();
            filterPlocica                    = new FilterReznihPlocica();
            listaPlocica                     = new List <ReznaPlocica>();
            graphDrawBrzinaProizvodnost      = new GraphDrawing();
            graphDrawPostojanostProizvodnost = new GraphDrawing();
            graphDrawBrzinaPostojanost       = new GraphDrawing();
            preporukeZaPostojanost           = new PreporukeZaPostojanostAlataStorage();
            slikeZaFormuSt                   = new SlikeZaFormuStorage();
            listaTacaka                      = new List <PointCoordinates>();
            rezimi                     = new RezimiObrade();
            plocica                    = new ReznaPlocica();
            izracunatiRezimi           = new IzracunatiRezimi();
            izracunatiPrepRezimi       = new IzracunatiPreporuceniRezimi();
            preporuceniRezim           = new PreporuceniRezim();
            granicnaVrednostDubine     = new GranicnaVrednostDubneRezanja();
            racunanjeParametaraRezanja = new RacunanjeParametaraRezanja();

            graphDrawBrzinaProizvodnost.SetNamesOfAxisAndLabels("Brzina rezanja v (m/min)", "Proizvodnost Q (cm³/min)", "v", "Q", brzinaProizvodnostChart);
            graphDrawPostojanostProizvodnost.SetNamesOfAxisAndLabels("Postojanost alata T (min)", "Proizvodnost Q (cm³/min)", "T", "Q", postojanostProizvodnostChart);
            graphDrawBrzinaPostojanost.SetNamesOfAxisAndLabels("Brzina rezanja v (m/min)", "Postojanost alata T (min)", "v", "T", brzinaPostojanostChart);

            maxSerijeCheckBox.Checked         = true;
            preporuceneSerijeCheckBox.Checked = true;
            minSerijeCheckBox.Checked         = true;
            ukljanjanjeLabelaCheckBox.Checked = true;

            fillComboBoxAndSetToDropDownList(materialComBox, materijaliSt.ListOfDictElements);
            fillComboBoxAndSetToDropDownList(vrstaObradeComboBox, vrstaObradeSt.ListOfDictElements);
            fillComboBoxAndSetToDropDownList(klasaKvalitetaComboBox, kvalitetObradeSt.ListOfDictElements);



            granicnaVrednostDubine.ListaGradacijaObrade = gradacijeObradeSt.ListaGradacija;
        }