private void Window_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            Storm Sto = CurrentProject.SelectedBasin.GetCurrentStorm();


            if (Sto != null)
            {
                if (Sto.LastNode != null)
                {
                    Node LastNode = Sto.LastNode;

                    RelativePositionConverter RPC = new RelativePositionConverter();

                    RelativePosition RP = (RelativePosition)RPC.Convert(e.GetPosition(HurricaneBasin), typeof(RelativePosition), null, null);
                    LastNode.Position = RP;

                    Sto.AddNode(LastNode);
                    LastNode = null;
                }
            }
            else
            {
                // left mouse button clicked (no zoom)
                if (e.LeftButton == MouseButtonState.Pressed)
                {
                    Project CurProj = CurrentProject;

                    // fix retardation
                    if (CurProj != null && CurProj.SelectedBasin != null && CurProj.SelectedBasin.CurrentLayer != null)
                    {
                        // if we have no storms, ask the user to create a storm instead of add a track point.
                        if (Sto == null)
                        {
                            AddNewStormHost Addstwindow = new AddNewStormHost(CurProj.SelectedBasin.SeasonStartTime);
                            Addstwindow.Owner = this;
                            Addstwindow.Show();
                            return;
                        }
                        else
                        {
                            // build 524
#if PRISCILLA
                            StormTypeManager ST2M = ST2Manager;
#else
                            StormTypeManager ST2Manager = GlobalState.GetST2Manager();
#endif
                            Storm SelectedStorm = CurProj.SelectedBasin.GetCurrentStorm();

                            int NodeCount = SelectedStorm.NodeList.Count - 1;

                            // build 547: implement season start time on window feature
                            AddTrackPointHost ATPHost = new AddTrackPointHost(ST2M.GetListOfStormTypeNames(), e.GetPosition(HurricaneBasin), SelectedStorm.GetNodeDate(NodeCount));
                            ATPHost.Owner = this;
                            ATPHost.Show();
                        }
                    }
                }
                else if (e.RightButton == MouseButtonState.Pressed)
                {
                    // temporary code
                    // this should be a matrix transformation but /shrug
                    // not best practice
                    LastRightMouseClickPos = e.GetPosition(HurricaneBasin);
                }
            }
        }
Exemple #2
0
        private protected NodeImportResult ImportNodes(XmlNode XNN)
        {
            NodeImportResult NIR = new NodeImportResult();

            // get globalstate structures in Dano, use MainWindow for Priscilla

#if DANO
            StormTypeManager ST2Manager = GlobalState.GetST2Manager();
#else
            MainWindow       MnWindow   = (MainWindow)Application.Current.MainWindow;
            StormTypeManager ST2Manager = MnWindow.ST2Manager;
#endif
            if (!XNN.HasChildNodes)
            {
                NIR.Successful = true;
                NIR.Empty      = true;
                return(NIR);
            }
            else
            {
                foreach (XmlNode XNNChild in XNN.ChildNodes)
                {
                    Node NewNode = new Node();

                    if (!XNNChild.HasChildNodes)
                    {
                        Error.Throw("Error!", "Empty node detected!", ErrorSeverity.Error, 222);
                    }
                    else
                    {
                        foreach (XmlNode NodeInformationNode in XNNChild.ChildNodes)
                        {
                            switch (NodeInformationNode.Name)
                            {
                            case "Intensity":
                                NewNode.Intensity = Convert.ToInt32(NodeInformationNode.InnerText);
                                continue;

                            case "Position":

                                Point Npos = NodeInformationNode.InnerText.SplitXY();
                                RelativePositionConverter RPC = new RelativePositionConverter();
                                RelativePosition          RP  = (RelativePosition)RPC.Convert(Npos, typeof(RelativePosition), null, null);

                                NewNode.Position = RP;
                                continue;

                            case "Type":
                                NewNode.NodeType = ST2Manager.GetStormTypeWithName(NodeInformationNode.InnerText);
                                continue;
                            }
                        }
                    }



                    NIR.Nodes.Add(NewNode);
                }

                NIR.Successful = true;
                NIR.Empty      = false;
                return(NIR);
            }
        }