public void ClickResetBtn()
 {
     buttonNumber = 0;
     OpenList.Clear();
     CloseList.Clear();
     FinalList.Clear();
     path.positionCount = 0;
     isDrawn            = false;
 }
    public void Clear()
    {
        Path.Clear();
        while (OpenHeap.Count > 0)
        {
            var node = OpenHeap.RemoveAtEnd();
            node.Clear();
        }

        for (int i = 0; i < CloseList.Count; i++)
        {
            CloseList[i].Clear();
        }
        CloseList.Clear();
    }
Example #3
0
    public void init(ref INode[,] map)
    {
        this.map = map;

        foreach (INode node in map)
        {
            if (node.property == nodeProp.START)
            {
                start = node;
            }
            if (node.property == nodeProp.GOAL)
            {
                goal = node;
            }
        }

        curTile       = null;
        isCalculating = false;

        if (OpenList == null)
        {
            OpenList = new List <INode>();
        }
        else
        {
            OpenList.Clear();
        }

        if (CloseList == null)
        {
            CloseList = new List <INode>();
        }
        else
        {
            CloseList.Clear();
        }

        if (PathList == null)
        {
            PathList = new List <INode>();
        }
        else
        {
            PathList.Clear();
        }
    }
    /*경로탐색 시작. OpenList에 더이상 남아있는 노드가 없을 때까지 탐색.
     * OpenList의 노드 중 가장 F가 작은 노드를 다음 currentNode로 정함.*/
    void Pathfinding()
    {
        ReadMap();
        startNode = nodeArray[startPos.y - bottomLeft.y, startPos.x - bottomLeft.x];
        endNode   = nodeArray[endPos.y - bottomLeft.y, endPos.x - bottomLeft.x];

        currentNode = startNode;

        CloseList.Add(startNode);

        while (!Search())
        {
            if (OpenList.Count == 0)
            {
                warningText.SetActive(true);
                isDrawn = false;
                return;
            }
            Node temp = null;
            foreach (Node element in OpenList)
            {
                if (temp == null)
                {
                    temp = element;
                }
                else if (temp.F > element.F)
                {
                    for (int y = -1; y <= 1; y++)
                    {
                        for (int x = -1; x <= 1; x++)
                        {
                            if (currentNode.x + x == element.x && currentNode.y + y == element.y)
                            {
                                temp = element;
                            }
                        }
                    }
                }
            }

            currentNode = temp;
            OpenList.Remove(temp);
            CloseList.Add(temp);
        }
        GetFinalList();
    }
        private bool SetConfiguration()
        {
            if (_soundChanged)
            {
                if (!_notifier.LoadSound(SoundPath.Text) && PlaysSound.Checked)
                {
                    MessageBox.Show("音声ファイルの読み込みに失敗しました。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }
            if (_imageChanged)
            {
                if (!_notifier.DialogData.LoadImage(ImagePath.Text) && DrawsImage.Checked)
                {
                    MessageBox.Show("画像ファイルの読み込みに失敗しました。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }


            //set configuration
            _notifier.IsEnabled = IsEnabled.Checked;

            _notifier.PlaysSound            = PlaysSound.Checked;
            _notifier.DialogData.DrawsImage = DrawsImage.Checked;
            _notifier.SoundVolume           = (int)SoundVolume.Value;
            _notifier.LoopsSound            = LoopsSound.Checked;

            _notifier.ShowsDialog                = ShowsDialog.Checked;
            _notifier.DialogData.TopMost         = TopMostFlag.Checked;
            _notifier.DialogData.Alignment       = (NotifierDialogAlignment)Alignment.SelectedIndex;
            _notifier.DialogData.Location        = new Point((int)LocationX.Value, (int)LocationY.Value);
            _notifier.DialogData.DrawsMessage    = DrawsMessage.Checked;
            _notifier.DialogData.HasFormBorder   = HasFormBorder.Checked;
            _notifier.AccelInterval              = (int)(AccelInterval.Value * 1000);
            _notifier.DialogData.ClosingInterval = (int)(ClosingInterval.Value * 1000);
            {
                int flag = 0;
                for (int i = 0; i < (int)NotifierDialogClickFlags.HighestBit; i++)
                {
                    flag |= (CloseList.GetItemChecked(i) ? 1 : 0) << i;
                }
                _notifier.DialogData.ClickFlag = (NotifierDialogClickFlags)flag;
            }
            _notifier.DialogData.CloseOnMouseMove   = CloseList.GetItemChecked((int)NotifierDialogClickFlags.HighestBit);
            _notifier.DialogData.ForeColor          = ForeColorPreview.ForeColor;
            _notifier.DialogData.BackColor          = BackColorPreview.ForeColor;
            _notifier.DialogData.ShowWithActivation = ShowWithActivation.Checked;

            var ndmg = _notifier as NotifierDamage;

            if (ndmg != null)
            {
                ndmg.NotifiesBefore        = NotifiesBefore.Checked;
                ndmg.NotifiesNow           = NotifiesNow.Checked;
                ndmg.NotifiesAfter         = NotifiesAfter.Checked;
                ndmg.ContainsNotLockedShip = ContainsNotLockedShip.Checked;
                ndmg.ContainsSafeShip      = ContainsSafeShip.Checked;
                ndmg.ContainsFlagship      = ContainsFlagship.Checked;
                ndmg.LevelBorder           = (int)LevelBorder.Value;
                ndmg.NotifiesAtEndpoint    = NotifiesAtEndpoint.Checked;
            }

            var nanc = _notifier as NotifierAnchorageRepair;

            if (nanc != null)
            {
                nanc.NotificationLevel = AnchorageRepairNotificationLevel.SelectedIndex;
            }

            return(true);
        }
        public DialogConfigurationNotifier(NotifierBase notifier)
        {
            InitializeComponent();

            _notifier = notifier;

            //init base
            _soundChanged = false;
            _imageChanged = false;

            GroupSound.AllowDrop = true;
            GroupImage.AllowDrop = true;



            //init from data

            IsEnabled.Checked = notifier.IsEnabled;

            PlaysSound.Checked = notifier.PlaysSound;
            SoundPath.Text     = notifier.SoundPath;
            SoundVolume.Value  = notifier.SoundVolume;
            LoopsSound.Checked = notifier.LoopsSound;

            DrawsImage.Checked = notifier.DialogData.DrawsImage;
            ImagePath.Text     = notifier.DialogData.ImagePath;

            ShowsDialog.Checked     = notifier.ShowsDialog;
            TopMostFlag.Checked     = notifier.DialogData.TopMost;
            Alignment.SelectedIndex = (int)notifier.DialogData.Alignment;
            LocationX.Value         = notifier.DialogData.Location.X;
            LocationY.Value         = notifier.DialogData.Location.Y;
            DrawsMessage.Checked    = notifier.DialogData.DrawsMessage;
            HasFormBorder.Checked   = notifier.DialogData.HasFormBorder;
            AccelInterval.Value     = notifier.AccelInterval / 1000;
            ClosingInterval.Value   = notifier.DialogData.ClosingInterval / 1000;
            for (int i = 0; i < (int)NotifierDialogClickFlags.HighestBit; i++)
            {
                CloseList.SetItemChecked(i, ((int)notifier.DialogData.ClickFlag & (1 << i)) != 0);
            }
            CloseList.SetItemChecked((int)NotifierDialogClickFlags.HighestBit, notifier.DialogData.CloseOnMouseMove);
            ShowWithActivation.Checked = notifier.DialogData.ShowWithActivation;
            ForeColorPreview.ForeColor = notifier.DialogData.ForeColor;
            BackColorPreview.ForeColor = notifier.DialogData.BackColor;
            LevelBorder.Maximum        = ExpTable.ShipMaximumLevel;

            NotifierDamage ndmg = notifier as NotifierDamage;

            if (ndmg != null)
            {
                NotifiesBefore.Checked        = ndmg.NotifiesBefore;
                NotifiesNow.Checked           = ndmg.NotifiesNow;
                NotifiesAfter.Checked         = ndmg.NotifiesAfter;
                ContainsNotLockedShip.Checked = ndmg.ContainsNotLockedShip;
                ContainsSafeShip.Checked      = ndmg.ContainsSafeShip;
                ContainsFlagship.Checked      = ndmg.ContainsFlagship;
                LevelBorder.Value             = ndmg.LevelBorder;
                NotifiesAtEndpoint.Checked    = ndmg.NotifiesAtEndpoint;
            }
            else
            {
                GroupDamage.Visible = false;
                GroupDamage.Enabled = false;
            }

            NotifierAnchorageRepair nanc = notifier as NotifierAnchorageRepair;

            if (nanc != null)
            {
                AnchorageRepairNotificationLevel.SelectedIndex = nanc.NotificationLevel;
            }
            else
            {
                GroupAnchorageRepair.Visible = false;
                GroupAnchorageRepair.Enabled = false;
            }


            DialogOpenSound.Filter = "音楽ファイル|" + string.Join(";", Utility.MediaPlayer.SupportedExtensions.Select(s => "*." + s)) + "|File|*";
        }
        public DialogConfigurationNotifier(NotifierBase notifier)
        {
            InitializeComponent();

            _notifier = notifier;

            //init base
            _soundChanged = false;
            _imageChanged = false;

            GroupSound.AllowDrop = true;
            GroupImage.AllowDrop = true;



            //init from data

            IsEnabled.Checked = notifier.IsEnabled;

            PlaysSound.Checked = notifier.PlaysSound;
            SoundPath.Text     = notifier.SoundPath;

            DrawsImage.Checked = notifier.DialogData.DrawsImage;
            ImagePath.Text     = notifier.DialogData.ImagePath;

            ShowsDialog.Checked     = notifier.ShowsDialog;
            TopMostFlag.Checked     = notifier.DialogData.TopMost;
            Alignment.SelectedIndex = (int)notifier.DialogData.Alignment;
            LocationX.Value         = notifier.DialogData.Location.X;
            LocationY.Value         = notifier.DialogData.Location.Y;
            DrawsMessage.Checked    = notifier.DialogData.DrawsMessage;
            HasFormBorder.Checked   = notifier.DialogData.HasFormBorder;
            AccelInterval.Value     = notifier.AccelInterval / 1000;
            ClosingInterval.Value   = notifier.DialogData.ClosingInterval / 1000;
            for (int i = 0; i < (int)NotifierDialogClickFlags.HighestBit; i++)
            {
                CloseList.SetItemChecked(i, ((int)notifier.DialogData.ClickFlag & (1 << i)) != 0);
            }
            CloseList.SetItemChecked((int)NotifierDialogClickFlags.HighestBit, notifier.DialogData.CloseOnMouseMove);
            ShowWithActivation.Checked = notifier.DialogData.ShowWithActivation;
            ForeColorPreview.ForeColor = notifier.DialogData.ForeColor;
            BackColorPreview.ForeColor = notifier.DialogData.BackColor;

            NotifierDamage ndmg = notifier as NotifierDamage;

            if (ndmg != null)
            {
                NotifiesBefore.Checked        = ndmg.NotifiesBefore;
                NotifiesNow.Checked           = ndmg.NotifiesNow;
                NotifiesAfter.Checked         = ndmg.NotifiesAfter;
                ContainsNotLockedShip.Checked = ndmg.ContainsNotLockedShip;
                ContainsSafeShip.Checked      = ndmg.ContainsSafeShip;
                ContainsFlagship.Checked      = ndmg.ContainsFlagship;
                LevelBorder.Value             = ndmg.LevelBorder;
                NotifiesAtEndpoint.Checked    = ndmg.NotifiesAtEndpoint;
            }
            else
            {
                GroupDamage.Visible = false;
                GroupDamage.Enabled = false;
            }
        }
        /// <summary>
        /// NOTE: The workingLibrary will be deleted when this method is called.
        ///
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public DiskStatus[] getDiskStatuses(final CommandConnection cc, final DDMConnection ddmConn, String workingLibrary, boolean reset) throws IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        public virtual DiskStatus[] getDiskStatuses(CommandConnection cc, DDMConnection ddmConn, string workingLibrary, bool reset)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final SystemInfo si1 = cc.getInfo();
            SystemInfo si1 = cc.Info;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final SystemInfo si2 = ddmConn.getInfo();
            SystemInfo si2 = ddmConn.Info;

            if (!si1.System.Equals(si2.System) || si1.ServerLevel != si2.ServerLevel)
            {
                throw new IOException("Command connection does not match DDM connection.");
            }

            skip_   = 0;
            theEnd_ = false;
            statuses_.Clear();
            elapsedTime_        = null;
            done_               = false;
            outputQueueLibrary_ = workingLibrary;

            // I really wish spooled files could go into QTEMP!
            // DDMConnection conn = DDMConnection.getConnection("rchasa12", "csmith",
            // "s1r4l0in");
            // CommandConnection conn = CommandConnection.getConnection("rchasa12",
            // "csmith", "s1r4l0in");
            // System.out.println(conn.getJobName());
            CommandResult result = cc.execute("CLROUTQ OUTQ(" + workingLibrary + "/DSKSTS)");

            if (!result.succeeded())
            {
                IList <Message> messages = result.MessagesList;
                if (messages.Count != 1 && !messages[0].ID.Equals("CPF3357"))
                {
                    throw new IOException("Error clearing output queue: " + result.ToString());
                }
            }
            result = cc.execute("DLTLIB " + workingLibrary);
            if (!result.succeeded())
            {
                IList <Message> messages = result.MessagesList;
                if (messages.Count != 1 || !messages[0].ID.Equals("CPF2110"))   // Library
                // not
                // found.
                {
                    throw new IOException("Error deleting library: " + result.ToString());
                }
            }
            result = cc.execute("CRTLIB " + workingLibrary);
            if (!result.succeeded())
            {
                throw new IOException("Error creating library: " + result.ToString());
            }
            result = cc.execute("CRTPF " + workingLibrary + "/DSKSTS RCDLEN(132) MAXMBRS(*NOMAX) SIZE(*NOMAX) LVLCHK(*NO)");
            if (!result.succeeded())
            {
                throw new IOException("Error creating physical file: " + result.ToString());
            }
            result = cc.execute("CRTOUTQ OUTQ(" + workingLibrary + "/DSKSTS)");
            if (!result.succeeded())
            {
                throw new IOException("Error creating output queue: " + result.ToString());
            }
            result = cc.execute("CHGJOB OUTQ(" + workingLibrary + "/DSKSTS)");
            if (!result.succeeded())
            {
                throw new IOException("Error changing job: " + result.ToString());
            }
            result = cc.execute("WRKDSKSTS OUTPUT(*PRINT) RESET(" + (reset ? "*YES" : "*NO") + ")");
            if (!result.succeeded())
            {
                throw new IOException("Error running WRKDSKSTS: " + result.ToString());
            }
            OpenListOfSpooledFilesFormatOSPL0300 format = new OpenListOfSpooledFilesFormatOSPL0300();
            OpenListOfSpooledFiles list = new OpenListOfSpooledFiles(format, 256, -1, null, this, null, null, null);

            list.FormatListener = this;
            result = cc.call(list);
            if (!result.succeeded())
            {
                throw new IOException("Error retrieving spooled file: " + result.ToString());
            }
            ListInformation info  = list.ListInformation;
            CloseList       close = new CloseList(info.RequestHandle);

            result = cc.call(close);
            if (!result.succeeded())
            {
                throw new IOException("Error closing spooled file list: " + result.ToString());
            }
            string jobID = jobNumber_.Trim() + "/" + jobUser_.Trim() + "/"
                           + jobName_.Trim();

            result = cc.execute("CPYSPLF FILE(" + spooledFileName_.Trim() + ") TOFILE(" + workingLibrary + "/DSKSTS) JOB(" + jobID + ") SPLNBR(" + spooledFileNumber_ + ") MBROPT(*REPLACE)");
            if (!result.succeeded())
            {
                throw new IOException("Error copying spooled file: " + result.ToString());
            }

            DDMFile file = ddmConn.open(workingLibrary, "DSKSTS", "DSKSTS", "DSKSTS", DDMFile.READ_ONLY, false, 200, 1);

            while (!done())
            {
                ddmConn.readNext(file, this);
            }
            ddmConn.close(file);
            result = cc.execute("DLTLIB " + workingLibrary);

            DiskStatus[] arr = new DiskStatus[statuses_.Count];
            statuses_.toArray(arr);
            return(arr);

            /*
             * Class.forName("com.ibm.jtopenlite.database.jdbc.JDBCDriver");
             * java.sql.Connection c =
             * DriverManager.getConnection("jdbc:systemi://rchasa12", "csmith",
             * "s1r4l0in"); Statement s = c.createStatement(); ResultSet rs =
             * s.executeQuery("SELECT * FROM QZRDDSKSTS.DSKSTS"); int skip = 0;
             * boolean theEnd = false; while (rs.next()) { String line =
             * rs.getString(1); if (skip < 4) { ++skip; } else if (!theEnd) { if
             * (line.indexOf("E N D  O F  L I S T I N G") >= 0) { theEnd = true; }
             * else { StringTokenizer st = new StringTokenizer(line); String unit =
             * st.nextToken(); String type = st.nextToken(); String sizeMB =
             * st.nextToken(); String percentUsed = st.nextToken(); String
             * ioRequests = st.nextToken(); String requestSizeKB = st.nextToken();
             * String readRequests = st.nextToken(); String writeRequests =
             * st.nextToken(); String readKB = st.nextToken(); String writeKB =
             * st.nextToken(); String percentBusy = st.nextToken(); String asp =
             * st.nextToken(); String protectionType = st.nextToken(); String
             * protectionStatus = st.nextToken(); String compression =
             * st.nextToken(); //TODO } } } rs.close(); s.close(); c.close();
             */
        }
    /*현재 노드의 8방위를 확인해서 G와 H를 계산하고 OpenList에 추가.
     * 아래의 조건에 해당한다면 다음으로 넘어가고, 목표지점에 도달하면 CloseList에 추가하고 종료.
     * OpenList에 포함된 노드라면 더 작은 F를 갖는 쪽으로 수정.*/
    bool Search()
    {
        for (int y = -1; y <= 1; y++)
        {
            for (int x = -1; x <= 1; x++)
            {
                Direction dir    = GetDirection(x, y);
                int       arrayX = currentNode.x - bottomLeft.x;
                int       arrayY = currentNode.y - bottomLeft.y;

                if (arrayX + x < 0 || arrayX + x >= sizeX)
                {
                    continue;
                }
                if (arrayY + y < 0 || arrayY + y >= sizeY)
                {
                    continue;
                }

                Node temp = nodeArray[y + arrayY, x + arrayX];

                if (CloseList.Contains(temp))
                {
                    continue;
                }
                if (temp.isWall)
                {
                    continue;
                }
                if (Corner(dir, arrayX, arrayY))
                {
                    continue;
                }
                if (Goal(temp))
                {
                    endNode.H          = CalculateH(temp);
                    endNode.G          = CalculateG(dir, currentNode.G);
                    endNode.parentNode = currentNode;
                    CloseList.Add(endNode);
                    return(true);
                }
                foreach (Node node in OpenList)
                {
                    if (temp.x == node.x && temp.y == node.y)
                    {
                        temp.H = node.H;
                        temp.G = node.G;
                    }
                }
                if (temp.F == 0)
                {
                    temp.H          = CalculateH(temp);
                    temp.G          = CalculateG(dir, currentNode.G);
                    temp.parentNode = currentNode;
                    OpenList.Add(temp);
                }
                else
                {
                    int tempG = CalculateG(dir, currentNode.G);
                    if (temp.G > tempG)
                    {
                        temp.G          = tempG;
                        temp.parentNode = currentNode;
                    }
                }
            }
        }
        return(false);
    }