Пример #1
0
        public Window_Add_Solution()
        {
            Grid Grid_Add_Solution = new MyGrid();
            Grid_Add_Solution.Name = "Grid_Add_Solution";

            MyLabel Add_New_Solution_lbl = new MyLabel("Add_New_Solution_lbl", 30, 110, 0, 0, "Выберите компоненты, образующие смесь:");

            MyComboBox First_Compound = new MyComboBox("", 200, 30, 140, 0, 0);
            First_Compound.Items.Add("Выберите компонент");
            foreach (var a in Database.Query("select name from liquid_list")[0])
            {
                First_Compound.Items.Add(a);
            }
            First_Compound.Items.Add("Добавить жидкость...");
            First_Compound.SelectedIndex = 0;
            First_Compound.SelectionChanged += First_Compound_Selection_Changed;

            MyComboBox Second_Compound = new MyComboBox("", 200, 240, 140, 0, 0);
            Second_Compound.Items.Add("Выберите компонент");
            foreach (var a in Database.Query("select name from liquid_list")[0])
            {
                Second_Compound.Items.Add(a);
            }
            Second_Compound.SelectedIndex = 0;
            Second_Compound.SelectionChanged += Second_Compound_Selection_Changed;

            MyButton Add_New_Compound = new MyButton("Liquid_Add", 200, 30, 180, 0, 0, "Добавление новой жидкости");
            Add_New_Compound.Height = 30;
            Add_New_Compound.Background = Brushes.DarkGreen;
            Add_New_Compound.Foreground = Brushes.LightGray;
            Add_New_Compound.Visibility = Visibility.Hidden;
            Add_New_Compound.Click += Add_New_Compound_Click;

            MyButton Help = new MyButton("Help", 70, 18, 0, 0, 7, "Справка");
            Help.Height = 30;
            Help.HorizontalAlignment = HorizontalAlignment.Left;
            Help.VerticalAlignment = VerticalAlignment.Bottom;
            Help.Background = Brushes.DarkGreen;
            Help.Click += Help_Click;

            MyButton Solution_Add = new MyButton("Add_New_Compound", 150, 0, 0, 20, 7, "Добавить смесь");
            Solution_Add.Height = 30;
            Solution_Add.HorizontalAlignment = HorizontalAlignment.Right;
            Solution_Add.VerticalAlignment = VerticalAlignment.Bottom;
            Solution_Add.Background = Brushes.DarkGreen;
            Solution_Add.Click += Solution_Add_Click;
            /*
            MyButton Cancel_Solution_Add = new MyButton("Cancel_Solution_Add", 100, 0, 0, 140, 30, "Отменить");
            Cancel_Solution_Add.Height = 30;
            Cancel_Solution_Add.HorizontalAlignment = HorizontalAlignment.Right;
            Cancel_Solution_Add.VerticalAlignment = VerticalAlignment.Bottom;
            Cancel_Solution_Add.Click += Cancel_Solution_Add_Click;
            */

            Image Add_Solution_Img_Top = new Image()
            {
                Width = 650,
                Height = 90,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                Name = "Add_Solution_Img_Top",
                Margin = new Thickness(0, 0, 0, 0)
            };

            BitmapImage Add_Solution_Img_Top_bi = new BitmapImage();
            Add_Solution_Img_Top_bi.BeginInit();
            Add_Solution_Img_Top_bi.UriSource = new Uri(@"C:\EasyPACT\EasyPACT_Graphic\EasyPACT_New_Solution_Top.jpg");
            Add_Solution_Img_Top_bi.EndInit();
            Add_Solution_Img_Top.Source = Add_Solution_Img_Top_bi;

            Image Add_Solution_Img_Bottom = new Image()
            {
                Width = 900,
                Height = 50,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                Name = "Add_Solution_Img_Bottom",
                Margin = new Thickness(0, 366, 0, 0)
            };

            BitmapImage Add_Solution_Img_Bottom_bi = new BitmapImage();
            Add_Solution_Img_Bottom_bi.BeginInit();
            Add_Solution_Img_Bottom_bi.UriSource = new Uri(@"C:\EasyPACT\EasyPACT_Graphic\EasyPACT_New_Solution_Bottom.jpg");
            Add_Solution_Img_Bottom_bi.EndInit();
            Add_Solution_Img_Bottom.Source = Add_Solution_Img_Bottom_bi;

            Grid container_Solution = new Grid();
            container_Solution.Name = "container_Solution";

            container_Solution.Children.Add(Add_Solution_Img_Top);//0
            container_Solution.Children.Add(First_Compound);//1
            container_Solution.Children.Add(Second_Compound);//2
            container_Solution.Children.Add(Add_New_Compound);//3
            container_Solution.Children.Add(Add_New_Solution_lbl);//4
            container_Solution.Children.Add(Add_Solution_Img_Bottom);//5
            container_Solution.Children.Add(Help);//6
            container_Solution.Children.Add(Solution_Add);//7
            //container_Solution.Children.Add(Cancel_Solution_Add);//6

            this.Content = container_Solution;
            this.Title = "Добавление новой смеси - EasyPACT";
            Uri iconUri = new Uri("C://EasyPACT/EasyPACT_Graphic/EasyPACT_Icon.jpg", UriKind.RelativeOrAbsolute);
            this.Icon = BitmapFrame.Create(iconUri);
            this.Width = 658;
            this.Height = 450;
            this.MinWidth = 658;
            this.MaxWidth = 658;
            this.MinHeight = 450;
            this.MaxHeight = 450;
        }
Пример #2
0
 public void SetGrid(MyGrid m)
 {
     this.inGrid = m;
 }
Пример #3
0
 /// <summary>
 /// code for paging
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void MyGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     MyGrid.PageIndex = e.NewPageIndex;
     MyGrid.DataBind();
     Binddata1();
 }
Пример #4
0
 private void BtnChange_Click(object sender, RoutedEventArgs e)
 {
     MyGrid.CancelEdit();
 }
Пример #5
0
 private void Awake()
 {
     ServiceLocator.Provide(this);
     grid = new MyGrid <HeatSource>(gridOrigin, cellSize, numberOfCells);
 }
Пример #6
0
    /// <summary>
    /// A* 算法
    /// </summary>
    /// <returns></returns>
    IEnumerator Count()
    {
        //延时等待前面操作完成
        yield return(new WaitForSeconds(0.1f));

        //添加起始点
        openList.Add(myGrids[startX, startY]);
        //声明当前格子变量,并赋初值
        MyGrid currentGrid = openList[0] as MyGrid;

        //循环遍历路径最小的点
        while (openList.Count > 0 && currentGrid.gridType != MyGridType.End)
        {
            currentGrid = openList[0] as MyGrid;
            //将当前格子从开启列表中移除
            openList.Remove(currentGrid);
            //加入封闭列表
            closeList.Add(currentGrid);
            //如果当前点为目标点
            if (currentGrid.gridType == MyGridType.End)
            {
                Debug.Log("Find");
                //生成结果
                GenerateResult(currentGrid);
            }
            //遍历四周格子
            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    if (i != 0 || j != 0)
                    {
                        int tempX = currentGrid.x + i;
                        int tempY = currentGrid.y + j;
                        //未超出所有格子范围且不是障碍物且不是重复格子
                        if (tempX >= 0 && tempY >= 0 && tempX < row && tempY < colomn && myGrids[tempX, tempY].gridType != MyGridType.Obstacle && !closeList.Contains(myGrids[tempX, tempY]))
                        {
                            //计算g值
                            int g = currentGrid.g + (int)(Mathf.Sqrt(Mathf.Abs(i) + Mathf.Abs(j)) * 10);
                            //与原g值比较
                            if (myGrids[tempX, tempY].g == 0 || myGrids[tempX, tempY].g > g)
                            {
                                myGrids[tempX, tempY].g      = g;
                                myGrids[tempX, tempY].parent = currentGrid;
                            }

                            //使用Manhattan法计算h值
                            myGrids[tempX, tempY].h = (int)((Mathf.Abs(targetX - tempX) + Mathf.Abs(targetY - tempY)) * 10);
                            //计算f值
                            myGrids[tempX, tempY].f = myGrids[tempX, tempY].g + myGrids[tempX, tempY].h;

                            if (!openList.Contains(myGrids[tempX, tempY]))
                            {
                                openList.Add(myGrids[tempX, tempY]);
                            }
                            openList.Sort();
                        }
                    }
                }
            }
            if (openList.Count == 0)
            {
                Debug.Log("Can Not Find");
            }
        }
    }
Пример #7
0
        public ResultWindow(double Temperature_Out, double NK_dou, double VP)
        {
            this.Temperature_Out = Temperature_Out;
            this.NK_dou = NK_dou;
            this.VP = VP;

            MyLabel proizv = new MyLabel("proizv", 270, 330, 0, 0, "Введите производительность насоса, кг/с:");

            MyTextBox proizv_txt = new MyTextBox("proizv_txt", 60, 560, 332, 0, 0);

            MyButton proizv_but = new MyButton("", 100, 630, 330, 0, 0, "Получить ответ");
            proizv_but.Background = Brushes.DarkGreen;
            proizv_but.Foreground = Brushes.LightGray;
            proizv_but.Height = 23;
            proizv_but.Visibility = Visibility.Visible;
            proizv_but.Click += proizv_but_Click;

            MyLabel Machine = new MyLabel("Machine", 270, 130, 0, 0, "Требуемый насос", 15);
            Machine.FontWeight = FontWeights.Bold;

            MyLabel MachineRes = new MyLabel("MachineRes", 270, 160, 0, 0, "");

            MyLabel TO = new MyLabel("TO", 270, 200, 0, 0, "Требуемый теплообменный аппарат", 15);
            TO.FontWeight = FontWeights.Bold;

            MyLabel TORes = new MyLabel("TORes", 270, 230, 0, 0, "");

            Image Result_Img_Top = new Image()
            {
                Width = 900,
                Height = 90,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                Name = "Result_Img_Top",
                Margin = new Thickness(0, 0, 0, 0)
            };

            BitmapImage Result_Img_Top_bi = new BitmapImage();
            Result_Img_Top_bi.BeginInit();
            Result_Img_Top_bi.UriSource = new Uri(@"C:\EasyPACT\EasyPACT_Graphic\EasyPACT_Results.jpg");
            Result_Img_Top_bi.EndInit();
            Result_Img_Top.Source = Result_Img_Top_bi;

            Image Result_Img_Bottom = new Image()
            {
                Width = 900,
                Height = 50,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                Name = "Result_Img_Bottom",
                Margin = new Thickness(0, 366, 0, 0)
            };

            BitmapImage Result_Img_Bottom_bi = new BitmapImage();
            Result_Img_Bottom_bi.BeginInit();
            Result_Img_Bottom_bi.UriSource = new Uri(@"C:\EasyPACT\EasyPACT_Graphic\EasyPACT_Bottom_First.jpg");
            Result_Img_Bottom_bi.EndInit();
            Result_Img_Bottom.Source = Result_Img_Bottom_bi;

            Image Animation = new Image()
            {
                Width = 200,
                Height = 270,
                HorizontalAlignment = HorizontalAlignment.Left,
                Name = "Animation",
                Margin = new Thickness(10, 40, 0, 0)
            };

            BitmapImage Animation_bi = new BitmapImage();
            Animation_bi.BeginInit();
            Animation_bi.UriSource = new Uri(@"C:\EasyPACT\EasyPACT_Graphic\Animation.png");
            Animation_bi.EndInit();
            Animation.Source = Animation_bi;

            MyButton Next_last = new MyButton("Next_last", 150, 0, 0, 20, 7, "Закрыть");
            Next_last.HorizontalAlignment = HorizontalAlignment.Right;
            Next_last.VerticalAlignment = VerticalAlignment.Bottom;
            Next_last.Background = Brushes.DarkGreen;
            Next_last.FontSize = 12;
            Next_last.Foreground = Brushes.LightGray;
            Next_last.Click += Next_last_Click;

            MyButton Cred = new MyButton("Cred", 80, 18, 0, 0, 7, "Разработчики");
            Cred.Foreground = Brushes.LightGray;
            Cred.VerticalAlignment = VerticalAlignment.Bottom;
            Cred.Background = Brushes.DarkGreen;
            Cred.FontSize = 10;
            Cred.Click += OpenCredits_Click;

            Grid ResultWindow = new MyGrid();
            ResultWindow.Name = "ResultWindow";
            ResultWindow.Children.Add(Result_Img_Top);//0
            ResultWindow.Children.Add(Result_Img_Bottom);//1
            ResultWindow.Children.Add(Animation);//2
            ResultWindow.Children.Add(Machine);//3
            ResultWindow.Children.Add(MachineRes);//4
            ResultWindow.Children.Add(TO);//5
            ResultWindow.Children.Add(TORes);//6
            ResultWindow.Children.Add(Next_last);//7
            ResultWindow.Children.Add(Cred);//8
            ResultWindow.Children.Add(proizv);//9
            ResultWindow.Children.Add(proizv_txt);//10
            ResultWindow.Children.Add(proizv_but);//11

            this.Content = ResultWindow;
            this.Title = "Вывод результатов - EasyPACT";
            Uri iconUri = new Uri("C://EasyPACT/EasyPACT_Graphic/EasyPACT_Icon.jpg", UriKind.RelativeOrAbsolute);
            this.Icon = BitmapFrame.Create(iconUri);
            this.MinWidth = 908;
            this.MaxWidth = 908;
            this.MinHeight = 450;
            this.MaxHeight = 450;
        }
Пример #8
0
        public FileTransferPage() : base("File Transfer")
        {
            MyLogger.TestMethodAdded += (name, task) =>
            {
                var ti = new MyToolbarItem(name);
                ti.Clicked += async delegate { await task(); };
                this.ToolbarItems.Add(ti);
            };
            {
                GDmain = new MyGrid();
                GDmain.RowDefinitions.Add(new Xamarin.Forms.RowDefinition {
                    Height = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Auto)
                });
                GDmain.RowDefinitions.Add(new Xamarin.Forms.RowDefinition {
                    Height = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                });
                {
                    GDctrl = new MyGrid();
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(3, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(2, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(4, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    GDctrl.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
                        Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
                    });
                    int columnNumber = 0;
                    {
                        var sw = new MySwitch("Auto Restart Failed tasks", "Manual Restart Failed Tasks", false);
                        FTmain       = new FileTransferContentView();
                        sw.Toggled  += delegate { FTmain.SetAutoRestartFailedTasks(sw.IsToggled); };
                        sw.IsToggled = true;
                        GDctrl.Children.Add(sw, columnNumber++, 0);
                    }
                    {
                        var toSpeedText = new Func <long, string>((value) =>
                        {
                            double v = value;
                            if (v <= 1023)
                            {
                                return($"{v.ToString("F5").Remove(5).PadRight(5, '0')} B/s");
                            }
                            v /= 1024;
                            if (v <= 1023)
                            {
                                return($"{v.ToString("F5").Remove(5).PadRight(5, '0')} KB/s");
                            }
                            v /= 1024;
                            return($"{v.ToString("F5").Remove(5).PadRight(5, '0')} MB/s");
                        });
                        var lbl = new MyLabel($"{toSpeedText(0)}")
                        {
                            VerticalTextAlignment = TextAlignment.Center
                        };
                        System.Threading.SemaphoreSlim semaphoreSlim = new System.Threading.SemaphoreSlim(1, 1);
                        long totalAmountSent = 0;
                        CloudFile.Networker.ChunkProcceeded += async(coda) =>
                        {
                            totalAmountSent += coda;
                            DateTime startTime = DateTime.Now;
                            await semaphoreSlim.WaitAsync();

                            while ((DateTime.Now - startTime).TotalSeconds <= 5)
                            {
                                lbl.Text = $"{toSpeedText(totalAmountSent / 5)}";
                                await Task.Delay(100);
                            }
                            totalAmountSent -= coda;
                            lbl.Text         = toSpeedText(totalAmountSent / 5);
                            lock (semaphoreSlim) semaphoreSlim.Release();
                        };
                        GDctrl.Children.Add(lbl, columnNumber++, 0);
                    }
                    {
                        var btn = new MyButton("Reset");
                        GDctrl.Children.Add(btn, columnNumber++, 0);
                        var lbl = new MyLabel("")
                        {
                            VerticalTextAlignment = TextAlignment.Center
                        };
                        long totalAmountLeft = 0, totalFilesLeft = 0, totalFoldersLeft = 0;
                        long totalAmount = 0, totalFiles = 0, totalFolders = 0;
                        btn.Clicked += async delegate
                        {
                            btn.IsEnabled = false;
                            if (await MyLogger.Ask("Are you sure to reset the statistic data?\r\nIncluding: total data amount, file count, folder count"))
                            {
                                totalAmount = totalFiles = totalFolders = 0;
                            }
                            btn.IsEnabled = true;
                        };
                        var toSizeText = new Func <long, string>((value) =>
                        {
                            double v = value;
                            if (v <= 1023)
                            {
                                return($"{v.ToString("F5").Remove(5)} B");
                            }
                            v /= 1024;
                            if (v <= 1023)
                            {
                                return($"{v.ToString("F5").Remove(5)} KB");
                            }
                            v /= 1024;
                            if (v <= 1023)
                            {
                                return($"{v.ToString("F5").Remove(5)} MB");
                            }
                            v /= 1024;
                            if (v <= 1023)
                            {
                                return($"{v.ToString("F5").Remove(5)} GB");
                            }
                            v /= 1024;
                            return($"{v.ToString("F5").Remove(5)} TB");
                        });
                        System.Threading.SemaphoreSlim semaphoreSlim = new System.Threading.SemaphoreSlim(1, 1);
                        DateTime lastUpdate = DateTime.MinValue;
                        var      showResult = new Func <Task>(async() =>
                        {
                            var updateTime = DateTime.Now;
                            await semaphoreSlim.WaitAsync();
                            if (updateTime <= lastUpdate)
                            {
                                return;
                            }
                            lbl.Text = $"{toSizeText(totalAmountLeft)} / {toSizeText(totalAmount)}   \t{totalFilesLeft } / {totalFiles} files   \t{totalFoldersLeft } / {totalFolders} folders";
                            await Task.Delay(100);
                            lock (semaphoreSlim) semaphoreSlim.Release();
                        });
                        CloudFile.Networker.TotalAmountRemainChanged += async(coda) => { if (coda < 0)
                                                                                         {
                                                                                             totalAmount -= coda;
                                                                                         }
                                                                                         totalAmountLeft += coda; await showResult(); };
                        CloudFile.Networker.TotalFilesRemainChanged += async(coda) => { if (coda < 0)
                                                                                        {
                                                                                            totalFiles -= coda;
                                                                                        }
                                                                                        totalFilesLeft += coda; await showResult(); };
                        CloudFile.Networker.TotalFoldersRemainChanged += async(coda) => { if (coda < 0)
                                                                                          {
                                                                                              totalFolders -= coda;
                                                                                          }
                                                                                          totalFoldersLeft += coda; await showResult(); };
                        GDctrl.Children.Add(lbl, columnNumber++, 0);
                    }
                    {
                        var actions = new Dictionary <CloudFile.Networker.NetworkStatus, Func <int, Task> >();
                        foreach (var status in Enum.GetValues(typeof(CloudFile.Networker.NetworkStatus)).Cast <CloudFile.Networker.NetworkStatus>())
                        {
                            networkers[status] = new HashSet <CloudFile.Networker>();
                            string text;
                            Func <CloudFile.Networker, Task> clickAction = null;
                            switch (status)
                            {
                            case CloudFile.Networker.NetworkStatus.Completed: text = "\u2714"; break;

                            case CloudFile.Networker.NetworkStatus.ErrorNeedRestart:
                            {
                                text        = "\u26a0";
                                clickAction = new Func <CloudFile.Networker, Task>(async(networker) =>
                                    {
                                        await networker.ResetAsync();
                                        await networker.StartAsync();
                                    });
                            }
                            break;

                            case CloudFile.Networker.NetworkStatus.Networking:
                            {
                                text        = "\u23f8";
                                clickAction = new Func <CloudFile.Networker, Task>(async(networker) =>
                                    {
                                        await networker.PauseAsync();
                                    });
                            }
                            break;

                            case CloudFile.Networker.NetworkStatus.NotStarted:
                            {
                                text        = "\u23f0";
                                clickAction = new Func <CloudFile.Networker, Task>(async(networker) =>
                                    {
                                        await networker.StartAsync();
                                    });
                            }
                            break;

                            case CloudFile.Networker.NetworkStatus.Paused:
                            {
                                text        = "\u25b6";
                                clickAction = new Func <CloudFile.Networker, Task>(async(networker) =>
                                    {
                                        await networker.StartAsync();
                                    });
                            }
                            break;

                            default: throw new Exception($"status: {status}");
                            }
                            MyButton btn = new MyButton(text)
                            {
                                Opacity = 0
                            };
                            if (status == CloudFile.Networker.NetworkStatus.Completed)
                            {
                                btn.IsEnabled = false;
                            }
                            btn.Clicked += async delegate
                            {
                                IEnumerable <Task> tasks;
                                lock (networkers)
                                {
                                    tasks = networkers[status].ToList().Select(async(networker) => { await clickAction(networker); });
                                }
                                await Task.WhenAll(tasks);
                            };
                            int number = 0;
                            System.Threading.SemaphoreSlim semaphoreSlim = new System.Threading.SemaphoreSlim(1, 1);
                            DateTime lastUpdate = DateTime.Now;
                            actions[status] = new Func <int, Task>(async(difference) =>
                            {
                                bool isZeroBefore   = (number == 0);
                                number             += difference;
                                DateTime updateTime = DateTime.Now;
                                await semaphoreSlim.WaitAsync();
                                try
                                {
                                    if (updateTime <= lastUpdate)
                                    {
                                        return;
                                    }
                                    lastUpdate = updateTime;
                                    btn.Text   = $"{text}{number}";
                                    if (number == 0 && !isZeroBefore)
                                    {
                                        await btn.FadeTo(0, 500);
                                    }
                                    if (number != 0 && isZeroBefore)
                                    {
                                        await btn.FadeTo(1, 500);
                                    }
                                    await Task.Delay(100);
                                }
                                finally
                                {
                                    lock (semaphoreSlim) semaphoreSlim.Release();
                                }
                            });
                            GDctrl.Children.Add(btn, columnNumber++, 0);
                        }
                        FTmain.StatusEnter += async(networker, status) =>
                        {
                            networkers[status].Add(networker);
                            await actions[status](1);
                        };
                        FTmain.StatusLeave += async(networker, status) =>
                        {
                            networkers[status].Remove(networker);
                            await actions[status](-1);
                        };
                    }
                    GDmain.Children.Add(GDctrl, 0, 0);
                }
                {
                    GDmain.Children.Add(new Frame {
                        OutlineColor = Color.Accent, Padding = new Thickness(5), Content = FTmain
                    }, 0, 1);
                }
                this.Content = GDmain;
            }
        }
Пример #9
0
 /// <summary>
 /// 基于栅格数据的构造函数
 /// </summary>
 /// <param name="grid"></param>
 internal MySpaceData(MyGrid grid)
 {
     myGrid   = grid;
     dataName = grid.Name;
     dataType = MySpaceDataType.MyGrid;
 }
Пример #10
0
    IEnumerator FindPath(Vector3 seeker, Vector3 target)
    {
        MyGrid grid = MyGrid.Instance;

        Node start = grid.GetNode(grid.ClampCoordinate(seeker));
        Node end   = grid.GetNode(grid.ClampCoordinate(target));

        if (!NeighboursAreNotWalkable(ref start) && !NeighboursAreNotWalkable(ref end))
        {
            Heap <Node> openList  = new Heap <Node>(grid.MaxSize);
            List <Node> closeList = new List <Node>();

            openList.Add(start);

            int loopsPerFrameCounter = 0;
            while (openList.Count > 0)
            {
                if (++loopsPerFrameCounter > maxIterationsPerFrame)
                {
                    loopsPerFrameCounter = 0;
                    yield return(null);
                }

                Node currentNode = openList.RemoveTop();
                closeList.Add(currentNode);

                if (currentNode == end)
                {
                    break;
                }

                foreach (Node node in grid.GetNeighbours(currentNode))
                {
                    if (++loopsPerFrameCounter > maxIterationsPerFrame)
                    {
                        loopsPerFrameCounter = 0;
                        yield return(null);
                    }

                    if (closeList.Contains(node))
                    {
                        continue;
                    }


                    int newCost = currentNode.gCost + GetDistance(currentNode, node) + node.extraCost;
                    if (newCost >= node.gCost && openList.Contains(node))
                    {
                        continue;
                    }


                    node.gCost  = newCost;
                    node.hCost  = GetDistance(node, end);
                    node.parent = currentNode;

                    if (openList.Contains(node))
                    {
                        continue;
                    }


                    openList.Add(node);
                }
            }

            StartCoroutine(SimplifyPathBeforeAddingTo(start, end, currentRequest.path));
        }
    }
Пример #11
0
 void Awake()
 {
     grid           = GetComponent <MyGrid>();
     requestManager = GetComponent <PathRequestManager>();
 }
 private void Awake()
 {
     meshRenderer   = GetComponent <MeshRenderer>();
     mainGameObject = GameObject.FindGameObjectWithTag("MainGameObject");
     myGrid         = mainGameObject.GetComponent <MyGrid>();
 }
Пример #13
0
 private void Awake()
 {
     requestManager = GetComponent <PathRequestManager>();
     grid           = GetComponent <MyGrid>();
 }
        internal void Scan()
        {
            using (_scanLock.AcquireExclusiveUsing())
            {
                if (!Scanning && Session.Tick - _lastScan > 100)
                {
                    Scanning          = true;
                    _lastScan         = Session.Tick;
                    GridVolume.Radius = MaxTargetingRange;
                    MyGamePruningStructure.GetAllTopMostEntitiesInSphere(ref GridVolume, _possibleTargets);
                    foreach (var grid in PrevSubGrids)
                    {
                        RemSubGrids.Add(grid);
                    }

                    PrevSubGrids.Clear();
                    for (int i = 0; i < _possibleTargets.Count; i++)
                    {
                        var ent = _possibleTargets[i];
                        using (ent.Pin())
                        {
                            if (ent is MyVoxelBase || ent.Physics == null || ent is MyFloatingObject ||
                                ent.MarkedForClose || !ent.InScene || ent.IsPreview || ent.Physics.IsPhantom)
                            {
                                continue;
                            }

                            var grid = ent as MyCubeGrid;
                            if (grid != null && MyGrid.IsSameConstructAs(grid))
                            {
                                PrevSubGrids.Add(grid);
                                continue;
                            }

                            Sandbox.ModAPI.Ingame.MyDetectedEntityInfo entInfo;
                            if (!CreateEntInfo(ent, MyOwner, out entInfo))
                            {
                                continue;
                            }

                            switch (entInfo.Relationship)
                            {
                            case MyRelationsBetweenPlayerAndBlock.Owner:
                            case MyRelationsBetweenPlayerAndBlock.FactionShare:
                            case MyRelationsBetweenPlayerAndBlock.Friends:
                                continue;
                            }

                            if (grid != null)
                            {
                                FatMap fatMap;
                                if (!Session.GridToFatMap.TryGetValue(grid, out fatMap) || fatMap.Trash)
                                {
                                    continue;
                                }

                                var allFat   = fatMap.MyCubeBocks;
                                var fatCount = allFat.Count;

                                if (fatCount <= 0 || !grid.IsPowered)
                                {
                                    continue;
                                }

                                if (fatCount <= 20) // possible debris
                                {
                                    var valid = false;
                                    for (int j = 0; j < fatCount; j++)
                                    {
                                        var fat = allFat[j];
                                        if (fat is IMyTerminalBlock && fat.IsWorking)
                                        {
                                            valid = true;
                                            break;
                                        }
                                    }
                                    if (!valid)
                                    {
                                        continue;
                                    }
                                }

                                int    partCount;
                                GridAi targetAi;
                                if (Session.GridTargetingAIs.TryGetValue(grid, out targetAi))
                                {
                                    targetAi.TargetAisTmp.Add(this);
                                    TargetAisTmp.Add(targetAi);
                                    partCount = targetAi.Construct.BlockCount;
                                }
                                else
                                {
                                    partCount = fatMap.MostBlocks;
                                }

                                NewEntities.Add(new DetectInfo(Session, ent, entInfo, partCount, fatCount));
                                ValidGrids.Add(ent);
                            }
                            else
                            {
                                NewEntities.Add(new DetectInfo(Session, ent, entInfo, 1, 0));
                            }
                        }
                    }
                    FinalizeTargetDb();
                    SubGridDetect();
                }
                Scanning = false;
            }
        }
Пример #15
0
        public void Click(int mouse)
        {
            RaycastHit hit;

            if (Physics.Raycast(CameraController.Instance.mouseRay, out hit))
            {
                //Debug.Log(hit.collider);
                if (hit.collider != null && hit.collider.GetComponent <MyGrid>() != null)
                {
                    MyGrid g = hit.collider.GetComponent <MyGrid>();
                    //Debug.Log(g + "is clicked");
                    if (mouse == 0)                     //sweep
                    {
                        if (g.state == GridState.Undiscovered)
                        {
                            if (g.isMine)
                            {
                                g.state = GridState.Discovered;
                                StartCoroutine(GameOverAsync(g, false));
                                return;
                            }
                            else
                            {
                                g.state = GridState.Discovered;
                                RevealSurroundings(g);
                            }
                        }
                    }
                    else if (mouse == 1)                       //flag
                    {
                        if (g.state != GridState.Discovered)
                        {
                            g.state = g.state == GridState.Flag ? GridState.Undiscovered : GridState.Flag;
                        }
                    }
                    else if (mouse == 2)
                    {
                        if (g.state == GridState.Discovered)
                        {
                            int mine = g.mineSuround;
                            int flag = 0;
                            foreach (Vector2Int vec in GetAllDirections(g.location))
                            {
                                MyGrid g2 = FindGrid(vec.x, vec.y);
                                if (g2 != null && g2.state == GridState.Flag)
                                {
                                    flag++;
                                }
                            }
                            if (flag >= mine)
                            {
                                foreach (Vector2Int vec in GetAllDirections(g.location))
                                {
                                    MyGrid g2 = FindGrid(vec.x, vec.y);
                                    //if(g2 != null && g2.state != GridState.Flag) {
                                    //	g2.state = GridState.Discovered;
                                    //	if(g2.isMine) {
                                    //		StartCoroutine(GameOverAsync(g2, false));
                                    //		return;
                                    //	}
                                    //}
                                    if (g2 != null && g2.state != GridState.Flag)
                                    {
                                        if (g2.state == GridState.Undiscovered)
                                        {
                                            if (g2.isMine)
                                            {
                                                g2.state = GridState.Discovered;
                                                StartCoroutine(GameOverAsync(g2, false));
                                                return;
                                            }
                                            else
                                            {
                                                g2.state = GridState.Discovered;
                                                RevealSurroundings(g2);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("???");
                    }
                }
            }
        }
Пример #16
0
        internal void FilterIt(GridFilterInfo filter)
        {
            try
            {
                // first for rowExpression
                foreach (MyGrid grid in m_grids)
                {
                    foreach (Xceed.Grid.DataRow row in grid.DataRows)
                    {
                        row.Visible = true;
                    }
                }

                if (!string.IsNullOrEmpty(filter.RowExpression))
                {
                    string[] expressions = filter.RowExpression.Split(new char[] { ';' },
                                                                      StringSplitOptions.RemoveEmptyEntries);
                    foreach (string expression in expressions)
                    {
                        int idx = expression.IndexOf(':');
                        if (idx == -1)
                        {
                            throw new ArgumentException("Invalid expression format");
                        }
                        string gridName       = expression.Substring(0, idx).Trim();
                        string realExpression = expression.Substring(idx + 1).Trim();

                        MyGrid grid = FindGridByName(gridName);
                        if (grid == null)
                        {
                            throw new ArgumentException("Invalid Grid Name");
                        }

                        EvaluationEngine.Parser.Token token = new EvaluationEngine.Parser.Token(realExpression);
                        MatchCollection mc = m_regex.Matches(realExpression);

                        foreach (Xceed.Grid.DataRow row in grid.DataRows)
                        {
                            Dictionary <string, string> variables = new Dictionary <string, string>();

                            foreach (Match m in mc)
                            {
                                variables[m.Groups[1].Value] = m.Groups[0].Value;
                            }

                            foreach (KeyValuePair <string, string> kvp in variables)
                            {
                                if (row.Cells[kvp.Key] == null)
                                {
                                    throw new ArgumentException("Invalid Grid Cell's Name");
                                }
                                else
                                {
                                    if (row.Cells[kvp.Key].ParentColumn.DataType == typeof(string))
                                    {
                                        token.Variables[kvp.Value].VariableValue =
                                            row.Cells[kvp.Key].GetDisplayText() == null
                                                ? string.Empty
                                                : row.Cells[kvp.Key].GetDisplayText();
                                    }
                                    else
                                    {
                                        token.Variables[kvp.Value].VariableValue = row.Cells[kvp.Key].Value == null
                                                                                       ? string.Empty
                                                                                       : row.Cells[kvp.Key].Value.
                                                                                   ToString();
                                    }
                                }
                            }

                            EvaluationEngine.Evaluate.Evaluator eval = new EvaluationEngine.Evaluate.Evaluator(token);

                            string ErrorMsg = "";
                            string result   = "";
                            if (eval.Evaluate(out result, out ErrorMsg) == false)
                            {
                                throw new InvalidOperationException("Error evaluating the tokens: " + ErrorMsg + System.Environment.NewLine
                                                                    + expression);
                            }

                            row.Visible = (result == "true");
                        }
                    }
                }


                // Then for columnExpression
                foreach (MyGrid grid in m_grids)
                {
                    foreach (Xceed.Grid.Column column in grid.Columns)
                    {
                        column.Fixed = false;
                    }
                }
                if (!string.IsNullOrEmpty(filter.ColumnExpression))
                {
                    string[] expressions = filter.ColumnExpression.Split(new char[] { ';' },
                                                                         StringSplitOptions.RemoveEmptyEntries);
                    foreach (string expression in expressions)
                    {
                        int idx = expression.IndexOf(':');
                        if (idx == -1)
                        {
                            throw new ArgumentException("Invalid expression format");
                        }
                        string gridName       = expression.Substring(0, idx).Trim();
                        string realExpression = expression.Substring(idx + 1).Trim();

                        MyGrid grid = FindGridByName(gridName);
                        grid.BeginInit();

                        if (grid == null)
                        {
                            throw new ArgumentException("Invalid Grid Name");
                        }

                        EvaluationEngine.Parser.Token token = new EvaluationEngine.Parser.Token(realExpression);
                        MatchCollection mc = m_regex.Matches(realExpression);

                        foreach (Xceed.Grid.Column column in grid.Columns)
                        {
                            Dictionary <string, string> variables = new Dictionary <string, string>();

                            foreach (Match m in mc)
                            {
                                if (m.Groups[0].Value != "$ColumnName$")
                                {
                                    throw new NotSupportedException("ColumnExpression Format is invalid !");
                                }
                                variables[m.Groups[1].Value] = m.Groups[0].Value;
                            }

                            foreach (KeyValuePair <string, string> kvp in variables)
                            {
                                token.Variables[kvp.Value].VariableValue = column.FieldName;
                            }

                            EvaluationEngine.Evaluate.Evaluator eval = new EvaluationEngine.Evaluate.Evaluator(token);

                            string ErrorMsg = "";
                            string result   = "";
                            if (eval.Evaluate(out result, out ErrorMsg) == false)
                            {
                                throw new InvalidOperationException("Error evaluating the tokens: " + ErrorMsg + System.Environment.NewLine
                                                                    + expression);
                            }

                            column.Fixed = (result == "true");
                        }
                        grid.EndInit();
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionProcess.ProcessWithNotify(ex);
            }
        }
Пример #17
0
 private void Awake()
 {
     Instance = this;
 }
Пример #18
0
 private void InitializeViews()
 {
     //this.GestureRecognizers.Add(new Xamarin.Forms.TapGestureRecognizer
     //{
     //    NumberOfTapsRequired = 1,
     //    Command = new Xamarin.Forms.Command(async () => { await MyLogger.Alert("Tapped"); })
     //});
     this.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
         Width = new Xamarin.Forms.GridLength(0, Xamarin.Forms.GridUnitType.Absolute)
     });
     this.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
         Width = new Xamarin.Forms.GridLength(4, Xamarin.Forms.GridUnitType.Star)
     });
     this.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
         Width = new Xamarin.Forms.GridLength(4, Xamarin.Forms.GridUnitType.Star)
     });
     this.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
         Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star)
     });
     this.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
         Width = new Xamarin.Forms.GridLength(50, Xamarin.Forms.GridUnitType.Absolute)
     });
     this.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition {
         Width = new Xamarin.Forms.GridLength(50, Xamarin.Forms.GridUnitType.Absolute)
     });
     this.RowDefinitions.Add(new Xamarin.Forms.RowDefinition {
         Height = new Xamarin.Forms.GridLength(25, Xamarin.Forms.GridUnitType.Absolute)
     });
     this.RowDefinitions.Add(new Xamarin.Forms.RowDefinition {
         Height = new Xamarin.Forms.GridLength(5, Xamarin.Forms.GridUnitType.Absolute)
     });
     {
         LBname = new MyLabel("");
         LBname.SetBinding(MyLabel.TextProperty, new Xamarin.Forms.Binding("LBname"));
         this.Children.Add(new MyScrollView(ScrollOrientation.Horizontal)
         {
             Content = LBname
         }, 1, 0);
     }
     {
         AIprogress = new MyActivityIndicator();
         AIprogress.SetBinding(MyActivityIndicator.IsVisibleProperty, new Xamarin.Forms.Binding("AIvisible"));
         AIprogress.SetBinding(MyActivityIndicator.IsRunningProperty, new Xamarin.Forms.Binding("AIvisible"));
         this.Children.Add(AIprogress, 0, 1);
         MyGrid.SetColumnSpan(AIprogress, this.ColumnDefinitions.Count - 2);
     }
     {
         PBprogress = new MyProgressBar();
         PBprogress.SetBinding(MyProgressBar.IsVisibleProperty, new Xamarin.Forms.Binding("PBvisible"));
         PBprogress.SetBinding(MyProgressBar.ProgressProperty, new Xamarin.Forms.Binding("Progress"));
         this.Children.Add(PBprogress, 0, 1);
         MyGrid.SetColumnSpan(PBprogress, this.ColumnDefinitions.Count - 2);
     }
     {
         LBstatus = new MyLabel("");
         LBstatus.SetBinding(MyLabel.TextProperty, new Xamarin.Forms.Binding("LBstatus"));
         this.Children.Add(LBstatus, 2, 0);
     }
     {
         LBspeed = new MyLabel("1.404 MB/s");
         LBspeed.SetBinding(MyLabel.TextProperty, new Xamarin.Forms.Binding("LBspeed"));
         this.Children.Add(LBspeed, 3, 0);
     }
     {
         BTNmessage = new MyButton("");
         BTNmessage.SetBinding(MyButton.TextProperty, new Xamarin.Forms.Binding("BTNmessage"));
         BTNmessage.SetBinding(MyButton.IsEnabledProperty, new Xamarin.Forms.Binding("BTNmessageEnabled"));
         BTNmessage.SetBinding(MyButton.CommandProperty, new Xamarin.Forms.Binding("BTNmessageClicked"));
         this.Children.Add(BTNmessage, 4, 0);
         MyGrid.SetRowSpan(BTNmessage, 2);
     }
     {
         BTNcontrol = new MyButton("");
         BTNcontrol.SetBinding(MyButton.TextProperty, new Xamarin.Forms.Binding("BTNcontrol"));
         BTNcontrol.SetBinding(MyButton.IsEnabledProperty, new Xamarin.Forms.Binding("BTNcontrolEnabled"));
         BTNcontrol.SetBinding(MyButton.CommandProperty, new Xamarin.Forms.Binding("BTNcontrolClicked"));
         this.Children.Add(BTNcontrol, 5, 0);
         MyGrid.SetRowSpan(BTNcontrol, 2);
     }
 }
Пример #19
0
 private void Awake()
 {
     manager = GameObject.Find("GameManager").GetComponent <Manager>();
     grid    = GameObject.Find("GameManager").GetComponent <MyGrid>();
 }
Пример #20
0
 protected void ChangePage(Object sender, GridViewPageEventArgs e)
 {
     MyGrid.PageIndex = e.NewPageIndex;
     MyGrid.DataBind();
 }
Пример #21
0
    // Update is called once per frame
    void Update()
    {
        // Move Left
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            // Modify position
            transform.position += new Vector3(-1, 0, 0);

            // See if valid
            if (isValidGridPos())
            {
                // Its valid. Update grid.
                updateGrid();
            }
            else
            {
                // Its not valid. revert.
                transform.position += new Vector3(1, 0, 0);
            }
        }

        // Move Right
        else if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            // Modify position
            transform.position += new Vector3(1, 0, 0);

            // See if valid
            if (isValidGridPos())
            {
                // It's valid. Update grid.
                updateGrid();
            }
            else
            {
                // It's not valid. revert.
                transform.position += new Vector3(-1, 0, 0);
            }
        }

        // Rotate
        else if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            transform.Rotate(0, 0, -90);

            // See if valid
            if (isValidGridPos())
            {
                // It's valid. Update grid.
                updateGrid();
            }
            else
            {
                // It's not valid. revert.
                transform.Rotate(0, 0, 90);
            }
        }

        // Fall
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            // Modify position
            transform.position += new Vector3(0, -1, 0);

            // See if valid
            if (isValidGridPos())
            {
                // It's valid. Update grid.
                updateGrid();
            }
            else
            {
                // It's not valid. revert.
                transform.position += new Vector3(0, 1, 0);

                foreach (Transform child in transform)
                {
                    while (MyGrid.insideBorder(child.position) && isValidGridPos())
                    {
                        child.position += new Vector3(0, -1, 0);

                        if (isValidGridPos())
                        {
                            // It's valid. Update grid.
                            updateGrid();
                        }
                    }


                    {
                        // It's not valid. revert.
                        child.position += new Vector3(0, 1, 0);

                        // Clear filled horizontal lines
                        MyGrid.deleteFullRows();

                        // Spawn next Group
                        FindObjectOfType <Spawner>().spawnNext();

                        // Disable script
                        enabled = false;
                    }
                }
            }
        }

        // Move Downwards and Fall
        else if (Input.GetKeyDown(KeyCode.DownArrow) ||
                 Time.time - lastFall >= 1)
        {
            // Modify position
            transform.position += new Vector3(0, -1, 0);

            // See if valid
            if (isValidGridPos())
            {
                // It's valid. Update grid.
                updateGrid();
            }
            else
            {
                // It's not valid. revert.
                transform.position += new Vector3(0, 1, 0);

                foreach (Transform child in transform)
                {
                    while (MyGrid.insideBorder(child.position) && isValidGridPos())
                    {
                        child.position += new Vector3(0, -1, 0);

                        if (isValidGridPos())
                        {
                            // It's valid. Update grid.
                            updateGrid();
                        }
                    }


                    {
                        // It's not valid. revert.
                        child.position += new Vector3(0, 1, 0);

                        // Clear filled horizontal lines
                        MyGrid.deleteFullRows();

                        // Spawn next Group
                        FindObjectOfType <Spawner>().spawnNext();

                        // Disable script
                        enabled = false;
                    }
                }
            }
            lastFall = Time.time;
        }
    }
Пример #22
0
 private void Grid_OnGridValueChanged(object sender, MyGrid <HeatMapGridObject> .OnGridObjectChangedEventArgs e)
 {
     updateMesh = true;
 }
Пример #23
0
    private void ButtonHandler(object sender, RoutedEventArgs e)
    {
        var myg1 = new MyGrid(textBox10.Text, textBox11.Text, textBox12.Text);

        gride.Add(myg1);
    }
Пример #24
0
 public void SetGrid(MyGrid myGrid)
 {
     this.inGrid = myGrid;
 }
Пример #25
0
 public HeatMapGridObject(MyGrid <HeatMapGridObject> grid, int x, int y)
 {
     this.grid = grid;
     this.x    = x;
     this.y    = y;
 }
Пример #26
0
    protected void shoplist()
    {
        Hashtable Hash;

        if (Session["ShoppingCar"] == null)
        {
            Hash = new Hashtable();
        }
        else
        {
            Hash = (Hashtable)Session["ShoppingCar"];
        }
        if (Hash.Count == 0)
        {
            Msg.Visible = true;
            Msg.Text    = "您还没有购物呢?赶快购物吧!";
        }

        string[] ArrKey   = new string[Hash.Count];
        int[]    ArrVal   = new int[Hash.Count];
        string   Products = "('";

        Hash.Keys.CopyTo(ArrKey, 0);
        Hash.Values.CopyTo(ArrVal, 0);
        int k = 0;

        for (int j = 0; j < ArrKey.Length; j++)
        {
            if (k > 0)
            {
                Products += "','";
            }
            k++;
            Products += ArrKey.GetValue(j).ToString();
        }
        Products += "')";

        SqlConnection conn = new SqlConnection(SqlHelper.connstring);

        conn.Open();
        string         mysql = "select * from ShangPinInfo where ShangPinID in" + Products;
        SqlCommand     cmd   = new SqlCommand(mysql, conn);
        SqlDataAdapter da    = new SqlDataAdapter(cmd);
        DataSet        ds    = new DataSet();

        da.Fill(ds, "ShangPinInfo");
        DataTable Table1 = new DataTable();

        Table1 = ds.Tables["ShangPinInfo"];
        Table1.Columns.Add(new DataColumn("PurchaseCount", System.Type.GetType("System.Int32")));

        DataColumn[] Keys = { Table1.Columns["ShangPinID"] };
        Table1.PrimaryKey = Keys;
        foreach (string X in Hash.Keys)
        {
            Table1.Rows.Find(X)["PurchaseCount"] = Hash[X];
        }
        Table1.Columns.Add(new DataColumn("TotalPrice", System.Type.GetType("System.Double"), "ShangPinPrice*PurchaseCount"));


        for (int I = 0; I < Table1.Rows.Count; I++)
        {
            TtlPrice += Convert.ToDouble(Table1.Rows[I]["TotalPrice"]);
        }

        Label1.Text           = TtlPrice.ToString();
        Session["TotalPrice"] = Label1.Text.ToString();
        MyGrid.DataSource     = Table1.DefaultView;
        MyGrid.DataBind();
    }
    public List <Nodo> FindPath(Nodo startNode, Nodo targetNode, int distance, MyGrid grid, float [,] mapaCostes)
    {
        List <Nodo> ClosedList = new List <Nodo>();

        Nodo actualNode = startNode;
        int  moveCost;

        switch (distance)
        {
        case 1:
            moveCost = actualNode.igCost + GetManhattenDistance(actualNode, targetNode);
            break;

        case 2:
            moveCost = actualNode.igCost + GetChebyshevDistance(actualNode, targetNode);
            break;

        case 3:
            moveCost = actualNode.igCost + GetEuclideDistance(actualNode, targetNode);
            break;

        default:
            moveCost = actualNode.igCost + GetManhattenDistance(actualNode, targetNode);
            break;
        }
        actualNode.ihCost = moveCost;
        //Mientras el estado actual no sea el estado objetivo
        while (actualNode != targetNode)
        {
            Nodo        nextNode     = null;
            List <Nodo> nodesVecinos = grid.GetNeighboringNodes(actualNode);

            foreach (Nodo NeighborNode in nodesVecinos)
            {
                moveCost = 0;
                switch (distance)
                {
                case 1:
                    moveCost = actualNode.igCost + GetManhattenDistance(NeighborNode, targetNode);
                    break;

                case 2:
                    moveCost = actualNode.igCost + GetChebyshevDistance(NeighborNode, targetNode);
                    break;

                case 3:
                    moveCost = actualNode.igCost + GetEuclideDistance(NeighborNode, targetNode);
                    break;
                }
                NeighborNode.igCost = moveCost;
            }

            float minCost = Mathf.Infinity;
            foreach (Nodo NeighborNode in nodesVecinos)
            {
                if (NeighborNode.bIsWall)
                {
                    if (minCost == Mathf.Infinity)
                    {
                        nextNode = NeighborNode;
                        minCost  = NeighborNode.FCost;
                    }
                    else if (NeighborNode.FCost < nextNode.FCost)
                    {
                        nextNode = NeighborNode;
                        minCost  = NeighborNode.FCost;
                    }
                }
            }
            ClosedList.Add(actualNode);
            actualNode = nextNode;
        }
        return(ClosedList);
    }
Пример #28
0
        public ResistanceOut(EasyPACT.LiquidInPipeline lip_In, EasyPACT.LiquidInPipeline lip_Out, double Temperature_Out, double NK_dou, double VP)
        {
            this.lip_In = lip_In;
            this.lip_Out = lip_Out;
            this.Temperature_Out = Temperature_Out;
            this.NK_dou = NK_dou;
            this.VP = VP;

            Grid Grid_Add_Resistance = new MyGrid();
            Grid_Add_Resistance.Name = "Grid_Add_Resistance";

            MyLabel Pipe_Resist_In = new MyLabel("Pipe_Resist_In", 30, 100, 0, 0, "Нагнетательный трубопровод", 14);
            Pipe_Resist_In.FontWeight = FontWeights.Bold;

            MyLabel Local_Resistance_In_lbl = new MyLabel("Local_Resistance_In_lbl", 30, 140, 0, 0, "Местное сопротивление:");

            MyComboBox Local_Resistance_In = new MyComboBox("Local_Resistance_In_1", 200, 200, 142, 0, 0);
            Local_Resistance_In.Items.Add("Выберите сопротивление");
            Local_Resistance_In.Items.Add("Вход в трубу");
            Local_Resistance_In.Items.Add("Выход и трубы");
            Local_Resistance_In.Items.Add("Диафрагма");
            Local_Resistance_In.Items.Add("Отвод");
            Local_Resistance_In.Items.Add("Колено");
            Local_Resistance_In.Items.Add("Вентиль нормальный");
            //Local_Resistance_In.Items.Add("Вентиль прямоточный");
            //Local_Resistance_In.Items.Add("Кран пробочный");
            //Local_Resistance_In.Items.Add("Задвижка");
            Local_Resistance_In.SelectedIndex = 0;
            Local_Resistance_In.SelectionChanged += Local_Resistance_In_SelectionChanged;

            // Комбобоксы для сопротивлений

            MyComboBox First = new MyComboBox("First_1", 200, 410, 142, 0, 0);
            First.Visibility = Visibility.Hidden;

            MyComboBox Second = new MyComboBox("Second_1", 200, 620, 142, 0, 0);
            Second.Visibility = Visibility.Hidden;

            MyTextBox Third = new MyTextBox("Third_1", 200, 410, 142, 0, 0);
            Third.Visibility = Visibility.Hidden;
            /*
            MyLabel Number_Local_Resistance_In_lbl = new MyLabel("Number_Local_Resistance_In_lbl", 334, 100, 0, 0, "Количество:");

            MyTextBox Number_Local_Resistance_In = new MyTextBox("Number_Local_Resistance_In", 60, 425, 100, 0, 0);

            MyLabel Shtyk = new MyLabel("Shtyk", 489, 100, 0, 0, "штук.");

            MyLabel Size = new MyLabel("Size_1", 556, 100, 0, 0, "Размеры");

            MyComboBox Size_Choose = new MyComboBox("", 100, 620, 102, 0, 0);
            */
            MyButton Add_New_Local_Resistance = new MyButton("Add_New_Local_Resistance", 100, 100, 170, 0, 0, "Добавить");
            Add_New_Local_Resistance.Click += Add_New_Local_Resistance_Click;

            ScrollBar hSBar = new ScrollBar();
            hSBar.Orientation = Orientation.Vertical;
            hSBar.HorizontalAlignment = HorizontalAlignment.Right;
            hSBar.Width = 10;
            hSBar.Height = 200;
            hSBar.Minimum = 0;
            hSBar.Value = 0;
            hSBar.Scroll += scroll;
            hSBar.Visibility = Visibility.Hidden;

            MyButton Next_3 = new MyButton("Next_3", 150, 0, 0, 20, 7, "Далее");
            Next_3.HorizontalAlignment = HorizontalAlignment.Right;
            Next_3.VerticalAlignment = VerticalAlignment.Bottom;
            Next_3.Background = Brushes.DarkGreen;
            Next_3.FontSize = 12;
            Next_3.Foreground = Brushes.LightGray;
            Next_3.Click += Next_3_Click;

            MyButton Help_Add_Resistance = new MyButton("Help_Add_Resistance", 70, 18, 0, 0, 7, "Справка");
            Help_Add_Resistance.VerticalAlignment = VerticalAlignment.Bottom;
            Help_Add_Resistance.Background = Brushes.DarkGreen;
            Help_Add_Resistance.FontSize = 12;
            Help_Add_Resistance.Foreground = Brushes.LightGray;
            Help_Add_Resistance.Click += Help_Add_Resistance_Click;

            Image Resistance_Img_Top = new Image()
            {
                Width = 900,
                Height = 90,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                Name = "Resistance_Img_Top",
                Margin = new Thickness(0, 0, 0, 0)
            };

            var Resistance_Img_Top_bi = new BitmapImage();
            Resistance_Img_Top_bi.BeginInit();
            Resistance_Img_Top_bi.UriSource = new Uri(@"C:\EasyPACT\EasyPACT_Graphic\EasyPACT_Resists.jpg");

            Resistance_Img_Top_bi.EndInit();
            Resistance_Img_Top.Source = Resistance_Img_Top_bi;

            Image Resistance_Img_Bottom = new Image()
            {
                Width = 900,
                Height = 50,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                Name = "Resistance_Img_Bottom",
                Margin = new Thickness(0, 366, 0, 0)
            };

            BitmapImage Resistance_Img_Bottom_bi = new BitmapImage();
            Resistance_Img_Bottom_bi.BeginInit();
            Resistance_Img_Bottom_bi.UriSource = new Uri(@"C:\EasyPACT\EasyPACT_Graphic\EasyPACT_Bottom_First.jpg");
            Resistance_Img_Bottom_bi.EndInit();
            Resistance_Img_Bottom.Source = Resistance_Img_Bottom_bi;

            Grid_Add_Resistance.Children.Add(Local_Resistance_In_lbl);//0
            Grid_Add_Resistance.Children.Add(Local_Resistance_In);//1
            Grid_Add_Resistance.Children.Add(Add_New_Local_Resistance);//2
            Grid_Add_Resistance.Children.Add(hSBar);//3
            Grid_Add_Resistance.Children.Add(First);//4
            Grid_Add_Resistance.Children.Add(Second);//5
            Grid_Add_Resistance.Children.Add(Third);//6
            Grid_Add_Resistance.Children.Add(Resistance_Img_Bottom);//7
            Grid_Add_Resistance.Children.Add(Next_3);//8
            Grid_Add_Resistance.Children.Add(Help_Add_Resistance);//9
            Grid_Add_Resistance.Children.Add(Resistance_Img_Top);//10
            Grid_Add_Resistance.Children.Add(Pipe_Resist_In);//11

            this.Content = Grid_Add_Resistance;
            Uri iconUri = new Uri("C://EasyPACT/EasyPACT_Graphic/EasyPACT_Icon.jpg", UriKind.RelativeOrAbsolute);
            this.Icon = BitmapFrame.Create(iconUri);
            this.MinHeight = 450;
            this.MinWidth = 900;
            this.MaxHeight = 450;
            this.MaxWidth = 900;
            this.Title = "Местные сопротивления - Нагнетательный трубопровод - EasyPACT";
        }
Пример #29
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            if (m_haveSaved)
            {
                if (!ServiceProvider.GetService <IMessageBox>().ShowYesNoDefaultNo("已保存过一次,是否再次保存(会导致2份记录)?", "确认"))
                {
                    return;
                }
            }
            int cnt = 0;

            IBatchDao batchDao = m_cm.Dao as IBatchDao;

            if (batchDao == null)
            {
                ServiceProvider.GetService <IMessageBox>().ShowWarning("不支持批量保存,将逐条保存!");
            }

            try
            {
                m_cm.CancelEdit();
                MyGrid.CancelEditCurrentDataRow(m_excelGrid);

                if (batchDao != null)
                {
                    batchDao.SuspendOperation();
                }

                foreach (Xceed.Grid.DataRow row in m_excelGrid.DataRows)
                {
                    bool hasValue = false;
                    foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(m_excelGrid.GridName))
                    {
                        if (row.Cells[info.GridColumnName] != null && !string.IsNullOrEmpty(info.PropertyName))
                        {
                            if (row.Cells[info.GridColumnName].ReadOnly)
                            {
                                continue;
                            }
                            if (row.Cells[info.GridColumnName].Value != null)
                            {
                                hasValue = true;
                            }
                        }
                    }
                    if (!hasValue)
                    {
                        continue;
                    }

                    object entity = m_cm.AddNew();
                    if (entity == null)
                    {
                        continue;
                    }

                    foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(m_excelGrid.GridName))
                    {
                        if (row.Cells[info.GridColumnName] != null && !string.IsNullOrEmpty(info.PropertyName))
                        {
                            if (row.Cells[info.GridColumnName].ReadOnly)
                            {
                                continue;
                            }

                            EntityScript.SetPropertyValue(entity, info.Navigator, info.PropertyName, row.Cells[info.GridColumnName].Value);
                        }
                    }

                    m_cm.EndEdit(false);

                    m_cm.Dao.Save(entity);
                    cnt++;
                }
                if (batchDao != null)
                {
                    batchDao.ResumeOperation();
                }

                m_haveSaved = true;
                MessageForm.ShowInfo(string.Format("已保存{0}条记录!", cnt));
            }
            catch (Exception ex)
            {
                if (batchDao != null)
                {
                    batchDao.CancelSuspendOperation();
                }
                ExceptionProcess.ProcessWithNotify(ex);
            }
        }
Пример #30
0
        internal void Scan()
        {
            MyGamePruningStructure.GetAllTopMostEntitiesInSphere(ref ScanVolume, _possibleTargets);
            NearByEntitiesTmp = _possibleTargets.Count;

            foreach (var grid in PrevSubGrids)
            {
                RemSubGrids.Add((MyCubeGrid)grid);
            }

            PrevSubGrids.Clear();
            for (int i = 0; i < NearByEntitiesTmp; i++)
            {
                var ent = _possibleTargets[i];
                using (ent.Pin()) {
                    if (ent is MyVoxelBase || ent.Physics == null || ent is MyFloatingObject || ent.MarkedForClose || !ent.InScene || ent.IsPreview || ent.Physics.IsPhantom)
                    {
                        continue;
                    }

                    var grid = ent as MyCubeGrid;
                    if (grid != null && MyGrid.IsSameConstructAs(grid))
                    {
                        PrevSubGrids.Add(grid);
                        continue;
                    }

                    Sandbox.ModAPI.Ingame.MyDetectedEntityInfo entInfo;
                    if (!CreateEntInfo(ent, AiOwner, out entInfo))
                    {
                        continue;
                    }

                    switch (entInfo.Relationship)
                    {
                    case MyRelationsBetweenPlayerAndBlock.Owner:
                    case MyRelationsBetweenPlayerAndBlock.FactionShare:
                    case MyRelationsBetweenPlayerAndBlock.Friends:
                        continue;
                    }

                    if (grid != null)
                    {
                        GridMap gridMap;
                        if (!Session.GridToInfoMap.TryGetValue(grid, out gridMap) || gridMap.Trash)
                        {
                            continue;
                        }

                        var allFat   = gridMap.MyCubeBocks;
                        var fatCount = allFat.Count;

                        if (fatCount <= 0)
                        {
                            continue;
                        }

                        var loneWarhead = false;
                        if (fatCount <= 20)    // possible debris

                        {
                            var valid = false;
                            for (int j = 0; j < fatCount; j++)
                            {
                                var fat     = allFat[j];
                                var warhead = fat is IMyWarhead;
                                if (warhead || fat is IMyTerminalBlock && fat.IsWorking)
                                {
                                    loneWarhead = warhead && fatCount == 1;
                                    valid       = true;
                                    break;
                                }
                            }
                            if (!valid)
                            {
                                continue;
                            }
                        }
                        int    partCount;
                        GridAi targetAi;
                        if (Session.GridTargetingAIs.TryGetValue(grid, out targetAi))
                        {
                            targetAi.TargetAisTmp.Add(this);
                            TargetAisTmp.Add(targetAi);
                            partCount = targetAi.Construct.BlockCount;
                        }
                        else
                        {
                            partCount = gridMap.MostBlocks;
                        }

                        NewEntities.Add(new DetectInfo(Session, ent, entInfo, partCount, !loneWarhead? fatCount : 2));// bump warhead to 2 fatblocks so its not ignored by targeting
                        ValidGrids.Add(ent);
                    }
                    else
                    {
                        NewEntities.Add(new DetectInfo(Session, ent, entInfo, 1, 0));
                    }
                }
            }
            FinalizeTargetDb();
            SubGridDetect();
        }
Пример #31
0
        public Window_Add_Pipeline(EasyPACT.Liquid liq, double Temperature_Out, double NK_dou, double VP)
        {
            Grid Grid_Add_Pipeline = new MyGrid();
            Grid_Add_Pipeline.Name = "Grid_Add_Pipeline";

            this.liq = liq;
            this.Temperature_Out = Temperature_Out;
            this.NK_dou = NK_dou;
            this.VP = VP;

            MyButton Next_2 = new MyButton("Next_2", 150, 0, 0, 20, 7, "Продолжить");
            Next_2.Height = 30;
            Next_2.FontSize = 12;
            Next_2.Foreground = Brushes.LightGray;
            Next_2.HorizontalAlignment = HorizontalAlignment.Right;
            Next_2.VerticalAlignment = VerticalAlignment.Bottom;
            Next_2.Background = Brushes.DarkGreen;
            Next_2.Click += Next_2_Click;

            MyButton Help_Add_Pipeline = new MyButton("Help_Add_Liquid", 70, 18, 0, 0, 7, "Справка");
            Help_Add_Pipeline.Height = 30;
            Help_Add_Pipeline.Foreground = Brushes.LightGray;
            Help_Add_Pipeline.FontSize = 12;
            Help_Add_Pipeline.VerticalAlignment = VerticalAlignment.Bottom;
            Help_Add_Pipeline.Background = Brushes.DarkGreen;
            Help_Add_Pipeline.Click += Help_Add_Pipeline_Click;
            /*
            MyButton Cancel_Add_Pipeline = new MyButton("Cancel_Add_Pipeline", 100, 0, 0, 140, 30, "Отменить");
            Cancel_Add_Pipeline.Height = 30;
            Cancel_Add_Pipeline.HorizontalAlignment = HorizontalAlignment.Right;
            Cancel_Add_Pipeline.VerticalAlignment = VerticalAlignment.Bottom;
            //Cancel_Add_Liquid.Click += Cancel_Add_Liquid_Click;
            */
            //MyLabel Add_New_Pipeline_lbl = new MyLabel("Add_New_Pipeline_lbl", 30, 110, 0, 0, "Всасывающий трубопровод.", 14);

            MyLabel Pipeline_In_lbl = new MyLabel("Pipeline_In_lbl", 30, 100, 0, 0, "Всасывающий трубопровод", 16);
            Pipeline_In_lbl.FontWeight = FontWeights.Bold;

            MyLabel Pipeline_Type_lbl = new MyLabel("Pipeline_Type_lbl_1", 30, 140, 0, 0, "Тип трубопровода:");

            MyComboBox Pipeline_Type = new MyComboBox("Pipeline_Type_1", 460, 163, 142, 0, 0);
            foreach (var a in Database.Query("select name from XII")[0])
            {
                Pipeline_Type.Items.Add(a);
            }
            Pipeline_Type.SelectedIndex = 0;

            MyLabel Material_In_lbl = new MyLabel("Material_In_lbl_1", 633, 140, 0, 0, "Материал:");

            MyComboBox Material_In = new MyComboBox("Material_In_1", 150, 713, 142, 0, 0);
            foreach (var a in Database.Query("select name from XXVIII")[0])
            {
                Material_In.Items.Add(a);
            }
            Material_In.SelectedIndex = 32;

            MyLabel Length_In_lbl = new MyLabel("Length_In_lbl_1", 30, 170, 0, 0, "Длина:");

            MyTextBox Length_In = new MyTextBox("Length_In_1", 60, 88, 172, 0, 0);

            MyComboBox Length_In_Measure_Choose = new MyComboBox("Length_In_Measure_Choose_1", 120, 153, 172, 0, 0);
            Length_In_Measure_Choose.SelectedIndex = 0;
            Length_In_Measure_Choose.Items.Add("м");
            Length_In_Measure_Choose.Items.Add("см");
            Length_In_Measure_Choose.Items.Add("мм");
            Length_In_Measure_Choose.SelectedIndex = 0;
            //Length_In_Measure_Choose.SelectionChanged += Length_In_Measure_Choose_SelectionChanged;

            MyLabel Length_In_Help = new MyLabel("Length_In_Help", 82, 197, 0, 0, "Пример: '20'; '33.1'; '10.83'", 10);

            MyLabel Diameter_In_lbl = new MyLabel("Diameter_lbl_1", 283, 170, 0, 0, "Диаметр:");

            MyTextBox Diameter_In = new MyTextBox("Diameter_In_1", 60, 360, 172, 0, 0);

            MyComboBox Diameter_In_Measure_Choose = new MyComboBox("Diameter_In_Measure_Choose_1", 120, 425, 172, 0, 0);
            Diameter_In_Measure_Choose.SelectedIndex = 0;
            Diameter_In_Measure_Choose.Items.Add("м");
            Diameter_In_Measure_Choose.Items.Add("см");
            Diameter_In_Measure_Choose.Items.Add("мм");
            Diameter_In_Measure_Choose.SelectedIndex = 0;
            //Diameter_In_Measure_Choose.SelectionChanged += Diameter_In_Measure_Choose_SelectionChanged;

            MyLabel Diameter_In_Help = new MyLabel("Diameter_In_Help", 354, 197, 0, 0, "Пример: '12'; '23.1'; '65.34'", 10);

            MyLabel Wall_Width_In_lbl = new MyLabel("Wall_Width_In_lbl_1", 556, 170, 0, 0, "Толщина стенки:");

            MyTextBox Wall_Width_In = new MyTextBox("Wall_Width_In_1", 60, 678, 172, 0, 0);

            MyComboBox Wall_Width_In_Measure_Choose = new MyComboBox("Wall_Width_In_Measure_Choose_1", 120, 743, 172, 0, 0);
            Wall_Width_In_Measure_Choose.SelectedIndex = 0;
            Wall_Width_In_Measure_Choose.Items.Add("м");
            Wall_Width_In_Measure_Choose.Items.Add("см");
            Wall_Width_In_Measure_Choose.Items.Add("мм");
            Wall_Width_In_Measure_Choose.SelectedIndex = 0;
            //Wall_Width_In_Measure_Choose.SelectionChanged += Wall_Width_In_Measure_Choose_SelectionChanged;

            MyLabel Wall_Width_In_Help = new MyLabel("", 672, 197, 0, 0, "Пример: '2'; '3.4'; '12.15'", 10);

            // Нагнетающий

            MyLabel Pipeline_Out_lbl = new MyLabel("Pipeline_Out_lbl", 30, 230, 0, 0, "Нагнетательный трубопровод", 16);
            Pipeline_Out_lbl.FontWeight = FontWeights.Bold;

            MyLabel Pipeline_Out_Type_lbl = new MyLabel("Pipeline_Out_Type_lbl_1", 30, 270, 0, 0, "Тип трубопровода:");

            MyComboBox Pipeline_Out_Type = new MyComboBox("Pipeline_Out_Type_1", 460, 163, 272, 0, 0);
            foreach (var a in Database.Query("select name from XII")[0])
            {
                Pipeline_Out_Type.Items.Add(a);
            }
            Pipeline_Out_Type.SelectedIndex = 0;

            MyLabel Material_Out_lbl = new MyLabel("Material_Out_lbl_1", 633, 270, 0, 0, "Материал:");

            MyComboBox Material_Out = new MyComboBox("Material_Out_1", 150, 713, 272, 0, 0);
            foreach (var a in Database.Query("select name from XXVIII")[0])
            {
                Material_Out.Items.Add(a);
            }
            Material_Out.SelectedIndex = 32;

            MyLabel Length_Out_lbl = new MyLabel("Length_In_lbl_1", 30, 300, 0, 0, "Длина:");

            MyTextBox Length_Out = new MyTextBox("Length_Out_1", 60, 88, 302, 0, 0);

            MyComboBox Length_Out_Measure_Choose = new MyComboBox("Length_Out_Measure_Choose_1", 120, 153, 302, 0, 0);
            Length_Out_Measure_Choose.SelectedIndex = 0;
            Length_Out_Measure_Choose.Items.Add("м");
            Length_Out_Measure_Choose.Items.Add("см");
            Length_Out_Measure_Choose.Items.Add("мм");
            Length_Out_Measure_Choose.SelectedIndex = 0;
            //Length_In_Measure_Choose.SelectionChanged += Length_In_Measure_Choose_SelectionChanged;

            MyLabel Length_Out_Help = new MyLabel("Length_Out_Help", 82, 327, 0, 0, "Пример: '20'; '33.1'; '10.83'", 10);

            MyLabel Diameter_Out_lbl = new MyLabel("Diameter_Out_lbl_1", 283, 300, 0, 0, "Диаметр:");

            MyTextBox Diameter_Out = new MyTextBox("Diameter_Out_1", 60, 360, 302, 0, 0);

            MyComboBox Diameter_Out_Measure_Choose = new MyComboBox("Diameter_Out_Measure_Choose_1", 120, 425, 302, 0, 0);
            Diameter_Out_Measure_Choose.SelectedIndex = 0;
            Diameter_Out_Measure_Choose.Items.Add("м");
            Diameter_Out_Measure_Choose.Items.Add("см");
            Diameter_Out_Measure_Choose.Items.Add("мм");
            Diameter_Out_Measure_Choose.SelectedIndex = 0;
            //Diameter_Out_Measure_Choose.SelectionChanged += Diameter_Out_Measure_Choose_SelectionChanged;

            MyLabel Diameter_Out_Help = new MyLabel("Diameter_Out_Help", 354, 327, 0, 0, "Пример: '12'; '23.1'; '65.34'", 10);

            MyLabel Wall_Width_Out_lbl = new MyLabel("Wall_Width_Out_lbl_1", 556, 300, 0, 0, "Толщина стенки:");

            MyTextBox Wall_Width_Out = new MyTextBox("Wall_Width_Out_1", 60, 678, 302, 0, 0);

            MyComboBox Wall_Width_Out_Measure_Choose = new MyComboBox("Wall_Width_Out_Measure_Choose_1", 120, 743, 302, 0, 0);
            Wall_Width_Out_Measure_Choose.SelectedIndex = 0;
            Wall_Width_Out_Measure_Choose.Items.Add("м");
            Wall_Width_Out_Measure_Choose.Items.Add("cм");
            Wall_Width_Out_Measure_Choose.Items.Add("мм");
            Wall_Width_Out_Measure_Choose.SelectedIndex = 0;
            //Wall_Width_Out_Measure_Choose.SelectionChanged += Wall_Width_Out_Measure_Choose_SelectionChanged;

            MyLabel Wall_Width_Out_Help = new MyLabel("", 672, 327, 0, 0, "Пример: '2'; '3.4'; '12.15'", 10);
            /*
            MyLabel Pipeline_Out_Type_lbl = new MyLabel("Pipeline_Out_Type_lbl_1", 30, 110, 0, 0, "Тип трубопровода:");

            MyComboBox Pipeline_Out_Type = new MyComboBox("Pipeline_Out_Type_1", 460, 163, 112, 0, 0);
            foreach (var a in Database.Query("select name from XII")[0])
            {
                Pipeline_Type.Items.Add(a);
            }
            Pipeline_Type.SelectedIndex = 0;
            */

            /*
            MyButton Add_New_Pipe = new MyButton("Add_New_Pipe", 250, 30, 202, 0, 0, "Добавить новую трубу");
            Add_New_Pipe.Click += Add_New_Pipe_Click;
            */
            Image Add_Pipeline_Img_Top = new Image()
            {
                Width = 900,
                Height = 90,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                Name = "Add_Pipeline_Img_Top",
                Margin = new Thickness(0, 0, 0, 0)
            };

            BitmapImage Add_Pipeline_Img_Top_bi = new BitmapImage();
            Add_Pipeline_Img_Top_bi.BeginInit();
            Add_Pipeline_Img_Top_bi.UriSource = new Uri(@"C:\EasyPACT\EasyPACT_Graphic\EasyPACT_Pipe_Params.jpg");
            Add_Pipeline_Img_Top_bi.EndInit();
            Add_Pipeline_Img_Top.Source = Add_Pipeline_Img_Top_bi;

            Image Add_Pipeline_Img_Bottom = new Image()
            {
                Width = 900,
                Height = 50,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                Name = "Add_Pipeline_Img_Bottom",
                Margin = new Thickness(0, 366, 0, 0)
            };

            BitmapImage Add_Pipeline_Img_Bottom_bi = new BitmapImage();
            Add_Pipeline_Img_Bottom_bi.BeginInit();
            Add_Pipeline_Img_Bottom_bi.UriSource = new Uri(@"C:\EasyPACT\EasyPACT_Graphic\EasyPACT_Bottom_First.jpg");
            Add_Pipeline_Img_Bottom_bi.EndInit();
            Add_Pipeline_Img_Bottom.Source = Add_Pipeline_Img_Bottom_bi;

            /*
            var scrbr = new ScrollBar();
            scrbr.Orientation = Orientation.Vertical;
            scrbr.HorizontalAlignment = HorizontalAlignment.Right;
            scrbr.Width = 20;
            scrbr.Height = 100;
            scrbr.Scroll += scrbr_Scroll;
            */

            /*
            MyLabel Local_Resistance_In_lbl = new MyLabel("Local_Resistance_In_lbl", 30, 200, 0, 0, "Местные сопротивления:");

            MyComboBox Local_Resistance_In = new MyComboBox("Local_Resistance_In", 124, 200, 202, 0, 0);
            Local_Resistance_In.Items.Add("Всякая фигня");
            Local_Resistance_In.SelectedIndex = 0;

            MyLabel Number_Local_Resistance_In_lbl = new MyLabel("Number_Local_Resistance_In_lbl", 334, 200, 0, 0, "Количество:");

            MyTextBox Number_Local_Resistance_In = new MyTextBox("Number_Local_Resistance_In", 60, 425, 202, 0, 0);

            MyLabel Shtyk = new MyLabel("Shtyk", 489, 200, 0, 0, "штук.");

            MyLabel Size = new MyLabel("Size_1", 556, 200, 0, 0, "Размеры");

            MyComboBox Size_Choose = new MyComboBox("", 100, 620, 202, 0, 0);

            */

            Grid_Add_Pipeline.Children.Add(Add_Pipeline_Img_Top);//0
            Grid_Add_Pipeline.Children.Add(Add_Pipeline_Img_Bottom);//1
            Grid_Add_Pipeline.Children.Add(Next_2);//2
            Grid_Add_Pipeline.Children.Add(Help_Add_Pipeline);//3
            Grid_Add_Pipeline.Children.Add(Pipeline_Type);//4
            Grid_Add_Pipeline.Children.Add(Material_In_lbl);//5
            Grid_Add_Pipeline.Children.Add(Material_In);//6
            Grid_Add_Pipeline.Children.Add(Length_In_lbl);//7
            Grid_Add_Pipeline.Children.Add(Length_In);//8
            Grid_Add_Pipeline.Children.Add(Length_In_Measure_Choose);//9
            Grid_Add_Pipeline.Children.Add(Length_In_Help);//10
            Grid_Add_Pipeline.Children.Add(Diameter_In_lbl);//11
            Grid_Add_Pipeline.Children.Add(Diameter_In);//12
            Grid_Add_Pipeline.Children.Add(Diameter_In_Measure_Choose);//13
            Grid_Add_Pipeline.Children.Add(Diameter_In_Help);//14
            Grid_Add_Pipeline.Children.Add(Wall_Width_In_lbl);//15
            Grid_Add_Pipeline.Children.Add(Wall_Width_In);//16
            Grid_Add_Pipeline.Children.Add(Wall_Width_In_Measure_Choose);//17
            Grid_Add_Pipeline.Children.Add(Wall_Width_In_Help);//18
            Grid_Add_Pipeline.Children.Add(Pipeline_Type_lbl);//19

            // Нагнетающий
            Grid_Add_Pipeline.Children.Add(Pipeline_Out_Type_lbl);//20
            Grid_Add_Pipeline.Children.Add(Pipeline_Out_Type);//21
            Grid_Add_Pipeline.Children.Add(Material_Out_lbl);//22
            Grid_Add_Pipeline.Children.Add(Material_Out);//23
            Grid_Add_Pipeline.Children.Add(Length_Out_lbl);//24
            Grid_Add_Pipeline.Children.Add(Length_Out);//25
            Grid_Add_Pipeline.Children.Add(Length_Out_Measure_Choose);//26
            Grid_Add_Pipeline.Children.Add(Length_Out_Help);//27
            Grid_Add_Pipeline.Children.Add(Diameter_Out_lbl);//28
            Grid_Add_Pipeline.Children.Add(Diameter_Out);//29
            Grid_Add_Pipeline.Children.Add(Diameter_Out_Measure_Choose);//30
            Grid_Add_Pipeline.Children.Add(Diameter_Out_Help);//31
            Grid_Add_Pipeline.Children.Add(Wall_Width_Out_lbl);//32
            Grid_Add_Pipeline.Children.Add(Wall_Width_Out);//33
            Grid_Add_Pipeline.Children.Add(Wall_Width_Out_Measure_Choose);//34
            Grid_Add_Pipeline.Children.Add(Wall_Width_Out_Help);//35

            Grid_Add_Pipeline.Children.Add(Pipeline_In_lbl);//36
            Grid_Add_Pipeline.Children.Add(Pipeline_Out_lbl);//37

            Content = Grid_Add_Pipeline;
            Uri iconUri = new Uri("C://EasyPACT/EasyPACT_Graphic/EasyPACT_Icon.jpg", UriKind.RelativeOrAbsolute);
            this.Icon = BitmapFrame.Create(iconUri);
            this.MinWidth = 908;
            this.MaxWidth = 908;
            this.MinHeight = 450;
            this.MaxHeight = 450;
            Title = "Добавление нового трубопровода - EasyPACT";
        }
        private void FinalizeTargetDb()
        {
            MyPlanetTmp   = MyGamePruningStructure.GetClosestPlanet(GridVolume.Center);
            ShieldNearTmp = false;
            ObstructionsTmp.Clear();
            StaticsInRangeTmp.Clear();
            for (int i = 0; i < _possibleTargets.Count; i++)
            {
                var ent        = _possibleTargets[i];
                var hasPhysics = ent.Physics != null;
                if (Session.ShieldApiLoaded && hasPhysics && !ent.Physics.Enabled && ent.Physics.IsPhantom && !ent.Render.CastShadows)
                {
                    long testId;
                    long.TryParse(ent.Name, out testId);
                    if (testId != 0)
                    {
                        MyEntity shieldEnt;
                        if (testId == MyGrid.EntityId)
                        {
                            MyShieldTmp = ent;
                        }
                        else if (MyEntities.TryGetEntityById(testId, out shieldEnt))
                        {
                            var shieldGrid = shieldEnt as MyCubeGrid;
                            if (shieldGrid != null && MyGrid.IsSameConstructAs(shieldGrid))
                            {
                                MyShieldTmp = ent;
                            }
                        }
                        else if (!ShieldNearTmp)
                        {
                            ShieldNearTmp = true;
                        }
                    }
                }
                var voxel          = ent as MyVoxelBase;
                var grid           = ent as MyCubeGrid;
                var blockingThings = ent.Physics != null && (voxel != null && voxel.RootVoxel == voxel || grid != null);
                if (!blockingThings)
                {
                    continue;
                }
                if (ent.Physics.IsStatic)
                {
                    if (voxel is MyPlanet)
                    {
                        continue;
                    }

                    StaticsInRangeTmp.Add(ent);
                }

                if (grid != null && (PrevSubGrids.Contains(grid) || ValidGrids.Contains(ent) || grid.PositionComp.LocalVolume.Radius < 6))
                {
                    continue;
                }
                ObstructionsTmp.Add(ent);
            }
            ValidGrids.Clear();
            _possibleTargets.Clear();
        }
Пример #33
0
 private void CheckBox_Checked(object sender, RoutedEventArgs e)
 {
     MyGrid.SelectAll();
 }
Пример #34
0
        public Window_Add_Liquid()
        {
            Grid Grid_Add_Liquid = new MyGrid();
                Grid_Add_Liquid.Name = "Grid_Add_Liquid";

                MyButton OK_Add_Liquid = new MyButton("OK_Add_Liquid", 150, 0, 0, 20, 7, "Добавить");
                OK_Add_Liquid.Height = 30;
                OK_Add_Liquid.HorizontalAlignment = HorizontalAlignment.Right;
                OK_Add_Liquid.VerticalAlignment = VerticalAlignment.Bottom;
                OK_Add_Liquid.Background = Brushes.DarkGreen;
                OK_Add_Liquid.Click += OK_Add_Liquid_Click;

                MyButton Help_Add_Liquid = new MyButton("Help_Add_Liquid", 70, 18, 0, 0, 7, "Справка");
                Help_Add_Liquid.Height = 30;
                Help_Add_Liquid.VerticalAlignment = VerticalAlignment.Bottom;
                Help_Add_Liquid.Background = Brushes.DarkGreen;
                Help_Add_Liquid.Click += Help_Add_Liquid_Click;
                /*
                MyButton Cancel_Add_Liquid = new MyButton("Cancel_Add_Liquid", 100, 0, 0, 140, 30, "Отменить");
                Cancel_Add_Liquid.Height = 30;
                Cancel_Add_Liquid.HorizontalAlignment = HorizontalAlignment.Right;
                Cancel_Add_Liquid.VerticalAlignment = VerticalAlignment.Bottom;
                Cancel_Add_Liquid.Click += Cancel_Add_Liquid_Click;
                */
                MyLabel New_Liquid_Name_lbl = new MyLabel("New_Liquid_Name_lbl",160, 30, 120, 0, 0, "Название вещества:");
                New_Liquid_Name_lbl.Height = 28;

                MyTextBox New_Liquid_Name = new MyTextBox("New_Liquid_Name", 100, 171, 121, 0, 0);

                MyLabel New_Liquid_Name_Help = new MyLabel("New_Liquid_Name_Help", 30, 145, 0, 0, "Пример: 'Ацетон'; 'Азотная кислота, 50%'", 10);

                MyLabel New_Chemical_Formula_lbl = new MyLabel("New_Chemical_Formula_lbl", 170, 332, 120, 0, 0, "Химическая формула:");

                MyTextBox New_Chemical_Formula = new MyTextBox("New_Chemical_Formula", 100, 483, 121, 0, 0);

                MyLabel New_Chemical_Formula_Help = new MyLabel("New_Chemical_Formula_Help", 332, 145, 0, 0, "Пример: 'CH3COCH3'; 'NH3', 'HNO3'", 10);

                MyLabel New_Molar_Mass_lbl = new MyLabel("New_Molar_Mass_lbl",640, 120, 0, 0,"Молярная масса:");

                MyTextBox New_Molar_Mass = new MyTextBox("New_Molar_Mass", 100, 760, 121, 0, 0);

                MyLabel New_Molar_Mass_Help = new MyLabel("New_Molar_Mass_Help", 640, 145, 0, 0, "Пример: '63.01'; '17.03'", 10);

                MyLabel Table_Data_lbl = new MyLabel("Table_Data_lbl", 397, 178, 0, 0,"Зависимости", 14);

                MyLabel New_Temp_Viscosity_lbl = new MyLabel("New_Temp_Viscosity_lbl",58, 210, 0, 0,"Вязкость от температуры");

                MyLabel New_Temp_Density_lbl = new MyLabel("New_Temp_Density_lbl",360, 210, 0, 0,"Плотность от температуры");

                MyLabel New_Pressure_BoilingPoint_lbl = new MyLabel("New_Pressure_BoilingPoint_lbl", 667, 210, 0, 0, "Точка кипения от давления");

                MyLabel First_Temperature_lbl = new MyLabel("First_Temperature_lbl",35, 240, 0, 0,"Температура");

                MyTextBox First_Temperature = new MyTextBox("First_Temperature_1", 100, 30, 260, 0, 0);

                MyLabel First_Viscosity_lbl = new MyLabel("First_Viscosity_lbl", 163, 240, 0, 0, "Вязкость");

                MyTextBox First_Viscosity = new MyTextBox("First_Viscosity_1", 100, 145, 260, 0, 0);

                MyLabel Second_Temperature_lbl = new MyLabel("Second_Temperature_lbl",343, 240, 0, 0,"Температура");

                MyTextBox Second_Temperature = new MyTextBox("Second_Temperature_1", 100, 337, 260, 0, 0);

                MyLabel Second_Density_lbl = new MyLabel("Second_Density_lbl",465, 240, 0, 0,"Плотность");

                MyTextBox Second_Density = new MyTextBox("Second_Density_1", 100, 452, 260, 0, 0);

                MyLabel Third_Pressure_lbl = new MyLabel("Third_Pressure_lbl", 660, 240, 0, 0,"Давление");

                MyTextBox Third_Pressure = new MyTextBox("Third_Pressure_1", 100, 645, 260, 0, 0);

                MyLabel Third_Temperature_lbl = new MyLabel("Third_Temperature_lbl",758, 240, 0, 0,"Точка кипения");

                MyTextBox Third_Temperature = new MyTextBox("Third_Temperature_1", 100, 760, 260, 0, 0);

                MyButton Add_Temp_Viscosity = new MyButton("Add_Temp_Viscosity", 120, 77, 285, 0, 0, "Добавить точку");
                Add_Temp_Viscosity.Click += Add_Temp_Viscosity_Click;

                MyButton Add_Temp_Density = new MyButton("Add_Temp_Density", 120, 385, 285, 0, 0, "Добавить точку");
                Add_Temp_Density.Click += Add_Temp_Density_Click;

                MyButton Add_Pressure_BoilingPoint = new MyButton("Add_Pressure_BoilingPoint", 120, 695, 285, 0, 0, "Добавить точку");
                Add_Pressure_BoilingPoint.Click += Add_Pressure_BoilingPointy_Click;

                Image Add_Liquid_Img_Top = new Image()
                {
                    Width = 900,
                    Height = 90,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment = VerticalAlignment.Top,
                    Name = "Add_Liquid_Img_Top",
                    Margin = new Thickness(0, 0, 0, 0)
                };

                BitmapImage Add_Liquid_Img_Top_bi = new BitmapImage();
                Add_Liquid_Img_Top_bi.BeginInit();
                Add_Liquid_Img_Top_bi.UriSource = new Uri(@"C:\EasyPACT\EasyPACT_Graphic\EasyPACT_Add_New_Liquid.jpg");
                Add_Liquid_Img_Top_bi.EndInit();
                Add_Liquid_Img_Top.Source = Add_Liquid_Img_Top_bi;

                Image Add_Liquid_Img_Bottom = new Image()
                {
                    Width = 900,
                    Height = 50,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment = VerticalAlignment.Top,
                    Name = "Add_Liquid_Img_Bottom",
                    Margin = new Thickness(0, 366, 0, 0)
                };

                BitmapImage Add_Liquid_Img_Bottom_bi = new BitmapImage();
                Add_Liquid_Img_Bottom_bi.BeginInit();
                Add_Liquid_Img_Bottom_bi.UriSource = new Uri(@"C:\EasyPACT\EasyPACT_Graphic\EasyPACT_Bottom_First.jpg");
                Add_Liquid_Img_Bottom_bi.EndInit();
                Add_Liquid_Img_Bottom.Source = Add_Liquid_Img_Bottom_bi;

                Grid_Add_Liquid.Children.Add(Add_Liquid_Img_Top);//0
                Grid_Add_Liquid.Children.Add(New_Liquid_Name);//1
                Grid_Add_Liquid.Children.Add(New_Liquid_Name_Help);//2
                Grid_Add_Liquid.Children.Add(New_Chemical_Formula_lbl);//3
                Grid_Add_Liquid.Children.Add(New_Chemical_Formula);//4
                Grid_Add_Liquid.Children.Add(New_Chemical_Formula_Help);//5
                Grid_Add_Liquid.Children.Add(New_Molar_Mass_lbl);//6
                Grid_Add_Liquid.Children.Add(New_Molar_Mass);//7
                Grid_Add_Liquid.Children.Add(New_Molar_Mass_Help);//8
                Grid_Add_Liquid.Children.Add(Add_Liquid_Img_Bottom);//9
                Grid_Add_Liquid.Children.Add(OK_Add_Liquid);//10
                //Grid_Add_Liquid.Children.Add(Cancel_Add_Liquid);//11
                Grid_Add_Liquid.Children.Add(Help_Add_Liquid);//11
                Grid_Add_Liquid.Children.Add(Table_Data_lbl);//12
                Grid_Add_Liquid.Children.Add(New_Temp_Viscosity_lbl);//13
                Grid_Add_Liquid.Children.Add(New_Temp_Density_lbl);//14
                Grid_Add_Liquid.Children.Add(New_Pressure_BoilingPoint_lbl);//15
                Grid_Add_Liquid.Children.Add(First_Temperature_lbl);//16
                Grid_Add_Liquid.Children.Add(First_Temperature);//17
                Grid_Add_Liquid.Children.Add(First_Viscosity_lbl);//18
                Grid_Add_Liquid.Children.Add(First_Viscosity);//19
                Grid_Add_Liquid.Children.Add(Second_Temperature_lbl);//20
                Grid_Add_Liquid.Children.Add(Second_Temperature);//21
                Grid_Add_Liquid.Children.Add(Second_Density_lbl);//22
                Grid_Add_Liquid.Children.Add(Second_Density);//23
                Grid_Add_Liquid.Children.Add(Third_Pressure_lbl);//24
                Grid_Add_Liquid.Children.Add(Third_Pressure);//25
                Grid_Add_Liquid.Children.Add(Third_Temperature_lbl);//26
                Grid_Add_Liquid.Children.Add(Third_Temperature);//27
                Grid_Add_Liquid.Children.Add(Add_Temp_Viscosity);//28
                Grid_Add_Liquid.Children.Add(Add_Temp_Density);//29
                Grid_Add_Liquid.Children.Add(Add_Pressure_BoilingPoint);//30
                Grid_Add_Liquid.Children.Add(New_Liquid_Name_lbl);//31

                Name = "Window_Add_Liquid";
                Content = Grid_Add_Liquid;
                Uri iconUri = new Uri("C://EasyPACT/EasyPACT_Graphic/EasyPACT_Icon.jpg", UriKind.RelativeOrAbsolute);
                this.Icon = BitmapFrame.Create(iconUri);
                this.MinWidth = 908;
                this.MaxWidth = 908;
                this.MinHeight = 450;
                this.MaxHeight = 450;
                Title = "Добавление новой жидкости - EasyPACT";
        }
Пример #35
0
 public Pathfinding(int width, int height)
 {
     Instance = this;
     grid     = new MyGrid <PathNode>(width, height, 10f, Vector3.zero, (MyGrid <PathNode> g, int x, int y) => new PathNode(g, x, y));
 }