コード例 #1
0
ファイル: UiVertexMenu.cs プロジェクト: 3c3/GRAPHical_learner
 void RemoveEdge(UiComponent sender, Object args)
 {
     int id = (int)args;
     //Console.WriteLine(id);
     Edge e = dict[id];
     graph.RemoveEdge(e);
     Remove();
 }
コード例 #2
0
        void BtnAddVertex(UiComponent sender, Object arg)
        {

            float x = (float)random.NextDouble() * 1600.0f - 800.0f;
            float y = (float)random.NextDouble() * 1400.0f - 700.0f;

            activeGraph.vertices.Add(new Vertex(x, y));

            if (activeGraph.vertices.Count < 2) return;

            int n = random.Next(3);
            for (int i = 0; i < n; i++)
            {
                int e_choice = random.Next(activeGraph.vertices.Count - 2);
                activeGraph.AddEdge(activeGraph.vertices.Count - 1, e_choice);
            }
        }
コード例 #3
0
ファイル: UiEdgeMenu.cs プロジェクト: 3c3/GRAPHical_learner
        void EditEdge(UiComponent sender, Object arg)
        {
            ui.edgeInputLabel.visible = true;
            ui.inputEdge = edge;

            if (Property.EdgeWeightId == -1) Property.SetSpecialProperty(Property.GetPropertyId("тегло"), SpecialProperty.EdgeWeight);

            if (edge.HasProperty(Property.EdgeWeightId))
            {
                object val = edge.GetPropertyValue(Property.EdgeWeightId);
                edge.SetProperty(Property.EdgeWeightId, val.ToString());
                ui.inputWeight = edge.GetProperty(Property.EdgeWeightId);
            }
            else
            {
                edge.SetProperty(Property.EdgeWeightId, "");
                ui.inputWeight = edge.GetProperty(Property.EdgeWeightId);
            }
        }
コード例 #4
0
ファイル: UiComponent.cs プロジェクト: 3c3/GRAPHical_learner
        /// <summary>
        /// Обработва позицията на мишката в компонента. Предава на децата, ако е необходимо
        /// </summary>
        public bool ProcessMousePosition(Vector2i mousePos)
        {
            Vector2i localPos = new Vector2i(mousePos.X - box.Left, mousePos.Y - box.Top); // превръща координатите в локални
            if (!CheckMouseEvents(mousePos)) return false;// проверява за влизане/излизане, връща дали мишката е вътрe

            gui.lastChildMoused = this;

            if(children!= null) foreach (UiComponent uic in children)
            { // предава позицията на мишката на децата
                if(uic.ProcessMousePosition(localPos))
                { // мишката е върху текущия под-компонент; уведомяваме предния такъв(ако има), че мишката е излязла от него
                    if (lastMoused != null) if (lastMoused != uic) lastMoused.CallMouseLeave(); 
                    lastMoused = uic;
                    FinalizeLastChildMoused();
                    return true;
                }
            }
            lastMoused = null;
            gui.lastChildMoused = this;
            return true;
        }
コード例 #5
0
 void menu_FileOpen(UiComponent sender, Object arg)
 {
     System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
     if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         Graph g = new Graph();
         IOHandler.ReadGraphFile(ofd.FileName, ref g);
         ChangeGraph(g);
         DisableEdgeAdding();
         DisablePhysics();
     }
 }
コード例 #6
0
 void BtnCenterGraph(UiComponent sender, Object arg)
 {
     CenterGraph();
 }
コード例 #7
0
 void MenuBtnPause(UiComponent sender, Object arg)
 {
     timerEnabled = false;
 }
コード例 #8
0
 void BtnPhysToggle(UiComponent sender, Object arg)
 {
     if (physics) DisablePhysics();
     else EnablePhysics();
 }
コード例 #9
0
 void menu_FileClicked(UiComponent sender, Object arg)
 {
     fileMenu.visible = true;
 }
コード例 #10
0
        protected bool shouldAdd = false; // Предпазна мярка някой да не ползва AddChild вместо AddItem

        /// <summary>
        /// НЕ използвай!
        /// </summary>
        /// <param name="uic"></param>
        public override void AddChild(UiComponent uic)
        {
            if (!shouldAdd) throw new InvalidOperationException("Use AddItem!");
            else base.AddChild(uic);
            shouldAdd = false;
        }
コード例 #11
0
ファイル: UiTextBox.cs プロジェクト: 3c3/GRAPHical_learner
 void SetFocus(UiComponent sender, Object arg)
 {
     gui.keyboardFocusComponent = this;
 }
コード例 #12
0
ファイル: UiComponent.cs プロジェクト: 3c3/GRAPHical_learner
 /// <summary>
 /// Добавя компонент-дете
 /// </summary>
 /// <param name="uic"></param>
 public virtual void AddChild(UiComponent uic)
 {
     uic.parent = this;
     uic.gui = gui;
     uic.UpdateChildrenGuiReference();
     children.Add(uic);
 }
コード例 #13
0
ファイル: UiVertexMenu.cs プロジェクト: 3c3/GRAPHical_learner
 void RemoveVertex(UiComponent sender, Object args)
 {
     graph.RemoveVertex(v);
     Remove();
 }
コード例 #14
0
 void rmbMenu_AddVertex(UiComponent sender, Object arg)
 {
     Vector2f pos = ToGlobalCoords(Mouse.GetPosition(window));
     activeGraph.vertices.Add(new Vertex(pos.X, pos.Y));
     rmbMenu.visible = false;
 }
コード例 #15
0
        void menu_Generate(UiComponent sender, Object arg)
        {
            Vertex.ResetCounter();
            Graph g = new Graph();
            int n = random.Next(50);
            int m = random.Next(100);
            for (int i = 0; i < n; i++)
            {
                Vertex v = new Vertex((float)random.NextDouble() * 1000 - 500.0f, (float)random.NextDouble() * 600 - 300.0f);
                g.AddVertex(v);
                if (i == 0) continue;

                int connections = random.Next(1, (int)Math.Min(i, 3));
                for(int j = 0; j < connections; j++)
                {
                    int vo = random.Next(0, i);

                    bool contains = false;
                    foreach(Edge e in v.edges)
                    {
                        if(e.source.id == vo || e.destination.id == vo)
                        {
                            contains = true;
                            break;
                        }
                    }
                    if (contains) j--;
                    else g.AddEdge(v.id, vo);
                }
            }

            

            fs.SetForce(50);

            activeGraph = g;
            fs.SetGraph(g);
        }
コード例 #16
0
 void rmbMenu_Deselect(UiComponent sender, Object arg)
 {
     if(lastClickedVertex!=null)
     {
         lastClickedVertex.selected = false;
         lastClickedVertex = null;
     }
     
     rmbMenu.visible = false;
 }
コード例 #17
0
 private void badButton_ComponentClicked(UiComponent sender, Object arg)
 {
     Console.WriteLine("Why did you click me?");
 }
コード例 #18
0
 void menu_ArrangeClicked(UiComponent sender, Object arg)
 {
     arrangeMenu.visible = true;
 }
コード例 #19
0
 void menu_Shuffle(UiComponent sender, Object arg)
 {
     foreach(Vertex v in activeGraph.vertices)
     {
         v.x = (float)(random.NextDouble() * 1000 - 500);
         v.y = (float)(random.NextDouble() * 600 - 300);
     }
 }
コード例 #20
0
 void BtnAddEdgeToggle(UiComponent sender, Object arg)
 {
     if (addEdgeEnabled) DisableEdgeAdding();
     else EnableEdgeAdding();
 }
コード例 #21
0
 void menu_FileSave(UiComponent sender, Object arg)
 {
     System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
     if(sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         IOHandler.WriteGraphFile(sfd.FileName, activeGraph);
     }
 }
コード例 #22
0
 void MenuBtnPlay(UiComponent sender, Object arg)
 {
     timerEnabled = true;
     if (connector != null) connector.Resume();
 }
コード例 #23
0
 void menu_Clear(UiComponent sender, Object arg)
 {
     ClearAll();
 }
コード例 #24
0
 void menu_Circle(UiComponent sender, Object arg)
 {
     activeGraph.ArrangeInCircle();
 }
コード例 #25
0
 void menu_Directivity(UiComponent sender, Object arg)
 {
     if (activeGraph.Directed) DisableDirected();
     else EnableDirected();
 }
コード例 #26
0
 void BtnSingleStep(UiComponent sender, Object arg)
 {
     if (connector != null) connector.Resume();
 }
コード例 #27
0
 void menu_Weight(UiComponent sender, Object arg)
 {
     if (weighted) DisableWeight();
     else EnableWeight();
 }
コード例 #28
0
 void menu_newclick(UiComponent sender, Object arg)
 {
     Console.WriteLine("You clicked a new button." + arg.ToString());
 }
コード例 #29
0
ファイル: UiEdgeMenu.cs プロジェクト: 3c3/GRAPHical_learner
 void RemoveEdge(UiComponent sender, Object args)
 {
     graph.RemoveEdge(edge);
     Remove();
 }