Пример #1
0
 public virtual void HandleMouseHoverIn(LTSCanvas canvas)
 {
     if (this.CurrentState != ItemState.Selected)
     {
         this.CurrentState = ItemState.Hover;
     }
 }
Пример #2
0
 public ProcessEditingForm(LTSCanvas canves)
 {
     InitializeComponent();
     Canves = canves;
     TextBox_Name.Text = Canves.Node.Text;
     this.TextBox_Paramater.Text = Canves.Parameters;
 }
Пример #3
0
 public virtual void HandleMouseHoverOut(LTSCanvas canvas)
 {
     if (this.CurrentState == ItemState.Hover)
     {
         this.CurrentState = ItemState.Free;
     }
 }
Пример #4
0
        public LTSCanvas Duplicate()
        {
            LTSCanvas duplicate = new LTSCanvas();

            duplicate.LoadFromXml(this.Clone());
            duplicate.Node.Text = this.Node.Text + "-Copy";

            bool nameExist = true;

            while (nameExist)
            {
                nameExist = false;
                foreach (TreeNode node in this.Node.Parent.Nodes)
                {
                    if (node.Text.Equals(duplicate.Node.Text, StringComparison.CurrentCultureIgnoreCase))
                    {
                        duplicate.Node.Text = duplicate.Node.Text + "-Copy";
                        nameExist           = true;
                        break;
                    }
                }
            }

            return(duplicate);
        }
Пример #5
0
 public override void AddToCanvas(LTSCanvas canvas)
 {
     canvas.AddSingleCanvasItem(this);
     this.labelItems.X = this.X - 10;
     this.labelItems.Y = this.Y + 30;
     canvas.AddSingleCanvasItem(this.labelItems);
 }
Пример #6
0
 public override void HandleMouseHoverOut(LTSCanvas canvas)
 {
     try
     {
         Route route = this.FindSelectedRouteBasedOnTransition(canvas);
         route.HandleMouseHoverOut(canvas);
     }
     catch { }
 }
Пример #7
0
 public PAT.Common.GUI.Drawing.LTSCanvas.CanvasItemData FindStateDataBasedOnLabelItem(LTSCanvas canvas)
 {
     foreach (PAT.Common.GUI.Drawing.LTSCanvas.CanvasItemData item in canvas.itemsList)
     {
         if (item.Item is StateItem && (item.Item as StateItem).labelItems.Equals(this))
         {
             return item;
         }
     }
     throw new Exception("State not found");
 }
Пример #8
0
        public WSNConfigForm(IConfigurationForm configListener, LTSCanvas canvas, WSNExtendInfo extendInfo)
        {
            this.mCanvas = canvas;
            this.configListener = configListener;
            InitializeComponent();

            // init value
            InitDefaultValue(extendInfo);
            LoadSensorListInfo();
            LoadChannelListInfo();
        }
Пример #9
0
 public StateItem FindStateBasedOnLabelItem(LTSCanvas canvas)
 {
     foreach (PAT.Common.GUI.Drawing.LTSCanvas.CanvasItemData item in canvas.itemsList)
     {
         if (item.Item is StateItem && (item.Item as StateItem).labelItems.Equals(this))
         {
             return(item.Item as StateItem);
         }
     }
     throw new Exception("State not found");
 }
Пример #10
0
        /// <summary>
        /// Throw exception when route not found
        /// </summary>
        public Route FindSelectedRouteBasedOnTransition(LTSCanvas canvas)
        {
            foreach (Route route in canvas.diagramRouter.routes)
            {
                if (route.Transition.Equals(this))
                {
                    return(route);
                }
            }

            throw new Exception("Route not found");
        }
Пример #11
0
        public override void AddToCanvas(LTSCanvas canvas)
        {
            canvas.AddSingleLink(this);

            for (int i = 1; i < canvas.temporaryNails.Count; i++)
            {
                PointF p = canvas.temporaryNails[i];
                NailItem nailItem = new NailItem(this);
                nailItem.X = p.X;
                nailItem.Y = p.Y;
                canvas.AddSingleCanvasItem(nailItem);
                this.AddNail(nailItem, this.Nails.Count);
            }
            canvas.temporaryNails.Clear();

            FindLabelLocation();
            canvas.AddSingleCanvasItem(Label);
        }
Пример #12
0
        public ChannelEditForm(Route route, LTSCanvas canvas, NetMode mode)
        {
            do
            {
                InitializeComponent();

                mChannel = (WSNChannel)route;
                mMode = mode;
                mCanvas = canvas;

                List<LTSCanvas.CanvasItemData> canvasItems = canvas.itemsList;
                foreach (LTSCanvas.CanvasItemData itemData in canvasItems)
                {
                    if (itemData.Item is StateItem)
                    {
                        this.cmbSource.Items.Add(itemData.Item);
                        this.cmbDest.Items.Add(itemData.Item);

                        if (itemData.Item.Equals(route.From))
                            this.cmbSource.SelectedItem = itemData.Item;

                        if (itemData.Item.Equals(route.To))
                            this.cmbDest.SelectedItem = itemData.Item;
                    }
                }

                if (!mMode.Equals(NetMode.MULTICAST))
                {
                    txtSensorsConn.Visible = false;
                    lblSensorsConn.Visible = false;
                    break;
                }

                StringBuilder subConn = new StringBuilder();
                subConn.Append(((WSNSensor)mChannel.To).ID.ToString());

                foreach (int item in mChannel.SubIdList)
                    subConn.Append("," + item);

                txtSensorsConn.Text = subConn.ToString();
            } while (false);
        }
Пример #13
0
        public override void RemovedFromCanvas(LTSCanvas canvas)
        {
            //Remove state
            canvas.RemoveSingleCanvasItem(this);

            //Remve transition
            Stack <Route> routesToRemove = new Stack <Route>();

            foreach (Route r in canvas.diagramRouter.Routes)
            {
                if (r.From == this || r.To == this)
                {
                    routesToRemove.Push(r);
                }
            }

            foreach (Route r in routesToRemove)
            {
                r.RemovedFromCanvas(canvas);
            }

            canvas.RemoveSingleCanvasItem(this.labelItems);
        }
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            Canvas = new PAT.Common.GUI.Drawing.LTSCanvas();
            this.SuspendLayout();
            //
            // Canvas
            //
            this.Canvas.AllowDrop  = true;
            this.Canvas.AutoScroll = true;
            this.Canvas.BackColor  = System.Drawing.Color.White;
            this.Canvas.Cursor     = System.Windows.Forms.Cursors.Default;
            this.Canvas.Dock       = System.Windows.Forms.DockStyle.Fill;
            this.Canvas.Location   = new System.Drawing.Point(0, 0);
            this.Canvas.Name       = "Canvas";
            this.Canvas.Size       = new System.Drawing.Size(1024, 728);
            this.Canvas.TabIndex   = 0;
            this.Canvas.Zoom       = 1F;
            this.Canvas.Visible    = true;
            this.Visible           = true;
            this.Controls.Add(Canvas);
            this.Canvas.ItemDoubleClick  += Canvas_ItemDoubleClick;
            this.Canvas.RouteDoubleClick += Canvas_RouteDoubleClick;

            //
            // StateMachineForm
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize          = new System.Drawing.Size(1024, 728);
            this.Margin        = new System.Windows.Forms.Padding(1, 1, 1, 1);
            this.Name          = "StateMachineForm";
            this.ShowIcon      = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text          = "State Machine Sensor ";
            this.ResumeLayout(false);
        }
Пример #15
0
 public override void AddToCanvas(LTSCanvas canvas)
 {
     canvas.AddSingleCanvasItem(this);
 }
Пример #16
0
        public override void HandleMouseHoverOut(LTSCanvas canvas)
        {
            StateItem state = this.FindStateBasedOnLabelItem(canvas);

            state.HandleMouseHoverOut(canvas);
        }
Пример #17
0
 public override void HandleSelected(LTSCanvas canvas)
 {
     StateItem state = this.FindStateBasedOnLabelItem(canvas);
     state.CurrentState = ItemState.Selected;
 }
Пример #18
0
 public virtual void RemovedFromCanvas(LTSCanvas canvas)
 {
     canvas.RemoveSingleCanvasItem(this);
 }
Пример #19
0
        public override void LoadFromXML(XmlElement xmlElement, LTSCanvas canvas)
        {
            if (canvas is PNCanvas)
            {
                PNCanvas myCanvas = canvas as PNCanvas;
                string startingState = xmlElement.GetAttribute("From");
                this.From = myCanvas.FindState(startingState);
                string endState = xmlElement.GetAttribute("To");
                this.To = myCanvas.FindState(endState);

                if (From is PNTransition)
                    (From as PNTransition).OutputPlaces.Add(To as PNPlace);
                else
                    (To as PNTransition).InputPlaces.Add(From as PNPlace);

                this.Weight = int.Parse(xmlElement.GetAttribute("Weight"));

                for (int i = 0; i < xmlElement.ChildNodes.Count - 1; i++)
                {
                    NailItem nail = new NailItem(this);
                    nail.LoadFromXml(xmlElement.ChildNodes[i] as XmlElement);
                    this.Nails.Add(nail);
                }

                this.Label.LoadFromXml(xmlElement.ChildNodes[xmlElement.ChildNodes.Count - 1] as XmlElement);
            }
        }
Пример #20
0
 public override void AddToCanvas(LTSCanvas canvas)
 {
     StateItem state = this.FindStateBasedOnLabelItem(canvas);
     state.AddToCanvas(canvas);
 }
Пример #21
0
        public override void HandleSelected(LTSCanvas canvas)
        {
            StateItem state = this.FindStateBasedOnLabelItem(canvas);

            state.CurrentState = ItemState.Selected;
        }
Пример #22
0
        /// <summary>
        /// Throw exception when route not found
        /// </summary>
        public PNArc FindSelectedRouteBasedOnTransition(LTSCanvas canvas)
        {
            foreach (Route route in canvas.diagramRouter.routes)
            {
                if (route is PNArc && (route as PNArc).Label.Equals(this))
                    return route as PNArc;
            }

            throw new Exception("Route not found");
        }
Пример #23
0
        public virtual void LoadFromXML(XmlElement xmlElement, LTSCanvas canvas)
        {
            //string startingState = xmlElement.ChildNodes[0].InnerText;
            //this.from = canvas.FindState(startingState);
            //string endState = xmlElement.ChildNodes[1].InnerText;
            //this.to = canvas.FindState(endState);

            //this.Transition.Select = xmlElement.ChildNodes[2].InnerText;
            //this.Transition.Event = xmlElement.ChildNodes[3].InnerText;
            //this.Transition.ClockGuard = xmlElement.ChildNodes[4].InnerText;
            //this.Transition.Guard = xmlElement.ChildNodes[5].InnerText;
            //this.Transition.Program = xmlElement.ChildNodes[6].InnerText;
            //this.Transition.ClockReset = xmlElement.ChildNodes[7].InnerText;
            //this.Transition.Width = this.Transition.GetWidthOfLabel();

            //for (int i = 8; i < xmlElement.ChildNodes.Count - 1; i++)
            //{
            //    NailItem nail = new NailItem(this);
            //    nail.LoadFromXml(xmlElement.ChildNodes[i] as XmlElement);
            //    this.nails.Add(nail);
            //}

            //this.transition.LoadFromXml(xmlElement.ChildNodes[xmlElement.ChildNodes.Count - 1] as XmlElement);

            string startingState = xmlElement.SelectSingleNode("./" + FROM_NODE_NAME).InnerText;
            this.from = canvas.FindState(startingState);
            string endState = xmlElement.SelectSingleNode("./" + TO_NODE_NAME).InnerText;
            this.to = canvas.FindState(endState);

            this.Transition.Select = xmlElement.SelectSingleNode("./" + SELECT_NODE_NAME).InnerText;
            this.Transition.Event = xmlElement.SelectSingleNode("./" + EVENT_NODE_NAME).InnerText;
            this.Transition.ClockGuard = xmlElement.SelectSingleNode("./" + CLOCK_GUARD_NODE_NAME).InnerText;
            this.Transition.Guard = xmlElement.SelectSingleNode("./" + GUARD_NODE_NAME).InnerText;
            this.Transition.Program = xmlElement.SelectSingleNode("./" + PROGRAM_NODE_NAME).InnerText;
            this.Transition.ClockReset = xmlElement.SelectSingleNode("./" + CLOCK_RESET_NODE_NAME).InnerText;
            this.Transition.Width = this.Transition.GetWidthOfLabel();

            XmlNodeList nails = xmlElement.SelectNodes("./" + NAIL_NODE_NAME);
            if (nails != null)
            {
                foreach (XmlElement xmlNail in nails)
                {
                    NailItem nail = new NailItem(this);
                    nail.LoadFromXml(xmlNail);
                    this.nails.Add(nail);
                }
            }

            this.transition.LoadFromXml((XmlElement)xmlElement.SelectSingleNode("./" + LABEL_NODE_NAME));
        }
Пример #24
0
        /// <summary>
        /// Do seetings for added process
        /// </summary>
        /// <param name="addedCanvas"></param>
        private void AddNewProcess(LTSCanvas addedCanvas)
        {
            addedCanvas.Dock = DockStyle.Fill;
            addedCanvas.ContextMenuStrip = contextMenuStrip1;
            addedCanvas.CanvasItemSelected += new EventHandler<CanvasItemEventArgs>(Canvas_CanvasItemSelected);
            addedCanvas.CanvasItemsSelected += new EventHandler<CanvasItemsEventArgs>(Canvas_CanvasItemsSelected);
            addedCanvas.CanvasRouteSelected += new EventHandler<CanvasRouteEventArgs>(Canvas_CanvasRouteSelected);
            addedCanvas.ItemDoubleClick += new EventHandler<CanvasItemEventArgs>(Canvas_ItemDoubleClick);
            addedCanvas.RouteDoubleClick += new EventHandler<CanvasRouteEventArgs>(Canvas_RouteDoubleClick);
            addedCanvas.LayoutChanged += new EventHandler(Canvas_LayoutChanged);
            addedCanvas.SaveCurrentCanvas += new EventHandler(Canvas_SaveCurrentCanvas);

            this.Button_AddLink.Checked = false;
            this.Button_AddNewState.Checked = false;
            this.Button_Delete.Enabled = false;

            toolStripContainer1.ContentPanel.Controls.Add(addedCanvas);
            textEditorControl.Visible = false;
            toolStripContainer1.Visible = true;
        }
Пример #25
0
        /// <summary>
        /// Throw exception when route not found
        /// </summary>
        public Route FindSelectedRouteBasedOnTransition(LTSCanvas canvas)
        {
            foreach (Route route in canvas.diagramRouter.routes)
            {
                if (route.Transition.Equals(this))
                    return route;
            }

            throw new Exception("Route not found");
        }
Пример #26
0
 private void StoreCanvas(LTSCanvas canvas)
 {
     canvas.undoStack.RemoveRange(canvas.currentStateIndex + 1, (canvas.undoStack.Count - 1) - (canvas.currentStateIndex + 1) + 1);
     canvas.undoStack.Add(canvas.Clone());
     canvas.currentStateIndex = canvas.undoStack.Count - 1;
 }
Пример #27
0
 public override void HandleMouseHoverIn(LTSCanvas canvas)
 {
     StateItem state = this.FindStateBasedOnLabelItem(canvas);
     state.HandleMouseHoverIn(canvas);
 }
Пример #28
0
        public override void LoadFromXML(XmlElement xmlElement, LTSCanvas canvas)
        {
            base.LoadFromXML(xmlElement, canvas);
            try
            {
                Kind = (ChannelKind)Enum.Parse(typeof(ChannelKind), xmlElement.GetAttribute(XmlTag.ATTR_CHANNEL_KIND), true);
                Type = (ChannelType)int.Parse(xmlElement.GetAttribute(XmlTag.ATTR_LINK_TYPE));
                SendingRate = int.Parse(xmlElement.GetAttribute(XmlTag.ATTR_MAX_SENDING_RATE));

                string cgnLevel = xmlElement.GetAttribute(XmlTag.ATTR_CONGESTION_LEVEL);
                CongestionLevel = (CGNLevel)Enum.Parse(typeof(CGNLevel), cgnLevel);

                ID = xmlElement.GetAttribute(XmlTag.ATTR_ID);
                if (ID != null && ID.Length == 0)
                    ID = null;
            }
            catch (Exception ex)
            {
                DevLog.d(TAG, ex.ToString());
            }
        }
Пример #29
0
 public void HandleMouseHoverIn(LTSCanvas canvas)
 {
     if (this.CurrentState != ItemState.Selected)
         this.CurrentState = ItemState.Hover;
 }
Пример #30
0
 public override void AddToCanvas(LTSCanvas canvas)
 {
     canvas.AddSingleCanvasItem(this);
     this.route.AddNail(this, this.route.SegmentSelected);
 }
Пример #31
0
 public virtual void HandleMouseHoverOut(LTSCanvas canvas)
 {
     if (this.CurrentState == ItemState.Hover)
         this.CurrentState = ItemState.Free;
 }
Пример #32
0
 public override void RemovedFromCanvas(LTSCanvas canvas)
 {
     StateItem state = this.FindStateBasedOnLabelItem(canvas);
     state.RemovedFromCanvas(canvas);
 }
Пример #33
0
 public override void RemovedFromCanvas(LTSCanvas canvas)
 {
     canvas.RemoveSingleCanvasItem(this);
     this.RemoveFromCurrentRoute();
 }
Пример #34
0
        public override void AddToCanvas(LTSCanvas canvas)
        {
            StateItem state = this.FindStateBasedOnLabelItem(canvas);

            state.AddToCanvas(canvas);
        }
Пример #35
0
        public override void RemovedFromCanvas(LTSCanvas canvas)
        {
            Route route = this.FindSelectedRouteBasedOnTransition(canvas);

            route.RemovedFromCanvas(canvas);
        }
Пример #36
0
 public override void RemovedFromCanvas(LTSCanvas canvas)
 {
     PNArc route = this.FindSelectedRouteBasedOnTransition(canvas);
     route.RemovedFromCanvas(canvas);
 }
Пример #37
0
 public virtual void HandleSelected(LTSCanvas canvas)
 {
     this.CurrentState = ItemState.Selected;
 }
Пример #38
0
 public override void AddToCanvas(LTSCanvas canvas)
 {
     canvas.AddSingleCanvasItem(this);
 }
Пример #39
0
 public virtual void AddToCanvas(LTSCanvas canvas)
 {
     canvas.AddSingleCanvasItem(this);
 }
Пример #40
0
 public override void AddToCanvas(LTSCanvas canvas)
 {
     canvas.AddSingleCanvasItem(this);
     this.labelItems.X = this.X - 10;
     this.labelItems.Y = this.Y + 30;
     canvas.AddSingleCanvasItem(this.labelItems);
 }
Пример #41
0
        public override void RemovedFromCanvas(LTSCanvas canvas)
        {
            //Remove nail
            foreach (NailItem nailItem in this.Nails)
                canvas.RemoveSingleCanvasItem(nailItem);
            this.Nails.Clear();

            //Remove transition
            canvas.RemoveSingleCanvasItem(Label);
            canvas.RemoveSingleRoute(this);
        }
Пример #42
0
        public override void RemovedFromCanvas(LTSCanvas canvas)
        {
            //Remove state
            canvas.RemoveSingleCanvasItem(this);

            //Remve transition
            Stack<Route> routesToRemove = new Stack<Route>();
            foreach (Route r in canvas.diagramRouter.Routes)
            {
                if (r.From == this || r.To == this)
                    routesToRemove.Push(r);
            }

            foreach (Route r in routesToRemove)
                r.RemovedFromCanvas(canvas);

            canvas.RemoveSingleCanvasItem(this.labelItems);
        }
Пример #43
0
 public override void HandleMouseHoverOut(LTSCanvas canvas)
 {
     try
     {
         PNArc route = this.FindSelectedRouteBasedOnTransition(canvas);
         route.HandleMouseHoverOut(canvas);
     }
     catch { }
 }
Пример #44
0
        public override void HandleSelected(LTSCanvas canvas)
        {
            Route route = this.FindSelectedRouteBasedOnTransition(canvas);

            route.CurrentState = ItemState.Selected;
        }
Пример #45
0
 public override void HandleSelected(LTSCanvas canvas)
 {
     PNArc route = this.FindSelectedRouteBasedOnTransition(canvas);
     route.CurrentState = ItemState.Selected;
 }
Пример #46
0
        public override void RemovedFromCanvas(LTSCanvas canvas)
        {
            StateItem state = this.FindStateBasedOnLabelItem(canvas);

            state.RemovedFromCanvas(canvas);
        }