Exemplo n.º 1
0
 public static void Refresh()
 {
     lock (dbLock)
     {
         using (connection = new SQLiteConnection())
         {
             //  建立SQLiteDataReader物件
             using (SQLiteDataReader reader = ExecuteReader("SELECT * FROM `" + tableName + "`;"))
             {
                 //					languageTable.Clear();
                 while (reader.Read())
                 {
                     var key = reader["Key"].ToString();
                     if (languageTable.ContainsKey(key))
                     {
                     }
                     else
                     {
                         languageTable.Add(
                             reader["Key"].ToString(),
                             new words
                         {
                             En    = reader[En].ToString(),
                             Zh_tw = reader[Zh_tw].ToString(),
                         }
                             );
                     }
                 }
                 UpdateControlsLanguage();
                 OnRefreshed.Invoke(languageTable, new EventArgs());
             }
         }
     }
 }
Exemplo n.º 2
0
        public void Refresh()
        {
            users.Clear();

            using (connection = new SQLiteConnection())
            {
                string SqlCommand = "SELECT * FROM `Users`,`UserGroups` WHERE `Users`.`GroupID` = `UserGroups`.`GroupID` ORDER BY `GroupID`;";

                //  建立SQLiteDataReader物件
                using (SQLiteDataReader reader = ExecuteReader(SqlCommand))
                {
                    while (reader.Read())
                    {
                        //讀取成功
                        UserGroup _group = new UserGroup
                        {
                            ID            = int.Parse(reader["GroupID"].ToString()),
                            Name          = reader["GroupName"].ToString(),
                            TabsAvailable = reader["TabsAvailable"].ToString().Split(',').ToList(),
                        };
                        User _user = new User
                        {
                            Name     = reader["Name"].ToString(),
                            Password = reader["Password"].ToString(),
                            Group    = _group,
                        };

                        users.Add(_user);
                    }

                    OnRefreshed.Invoke(this, new EventArgs());
                }
            }
        }
Exemplo n.º 3
0
        public void RefreshGroups()
        {
            groups.Clear();
            using (connection = new SQLiteConnection())
            {
                string SqlCommand = "SELECT * FROM `UserGroups`;";

                //  建立SQLiteDataReader物件
                using (SQLiteDataReader reader = ExecuteReader(SqlCommand))
                {
                    while (reader.Read())
                    {
                        groups.Add(
                            new UserGroup
                        {
                            ID            = int.Parse(reader["GroupID"].ToString()),
                            Name          = reader["GroupName"].ToString(),
                            TabsAvailable = reader["TabsAvailable"].ToString().Split(',').ToList(),
                        });
                    }
                    if (OnRefreshed != null)
                    {
                        OnRefreshed.Invoke(this, new EventArgs());
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void Refresh()
        {
            using (connection = new SQLiteConnection())
            {
                string SqlCommand = "SELECT * FROM `DataManager`;";

                //  建立SQLiteDataReader物件
                using (SQLiteDataReader reader = ExecuteReader(SqlCommand))
                {
                    while (reader.Read())
                    {
                        var key   = reader["Key"].ToString();
                        var value = reader["Value"].ToString();
                        if (datas.ContainsKey(key))
                        {
                            datas[key] = value;
                        }
                        else
                        {
                            datas.Add(key, value);
                        }
                    }
                    if (OnRefreshed != null)
                    {
                        OnRefreshed.Invoke(this, new EventArgs());
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <inheritdoc />
        public bool Refresh()
        {
            if (!RepositoryReferenceValid())
            {
                return(false);
            }

            if (string.IsNullOrEmpty(LocalRepositoryFolder))
            {
                return(false);
            }
            if (Repository.IsValid(LocalRepositoryFolder))
            {
                GitRepository = GitUtils.Synchronize(
                    LocalRepositoryFolder,
                    new FetchOptions
                {
                    CertificateCheck    = CertificateCheck,
                    CredentialsProvider = CredentialsProvider,
                    CustomHeaders       = CustomHeaders
                },
                    caller: this
                    );
            }
            else
            {
                GitRepository = GitUtils.Clone(
                    Url,
                    LocalRepositoryFolder,
                    new CloneOptions
                {
                    CertificateCheck    = CertificateCheck,
                    CredentialsProvider = CredentialsProvider,
                    FetchOptions        =
                    {
                        CertificateCheck    = CertificateCheck,
                        CredentialsProvider = CredentialsProvider,
                        CustomHeaders       = CustomHeaders
                    }
                },
                    this
                    );
            }

            if (GitRepository != null)
            {
                Synchronized = true;
                var res = this.GatherPackageReferencesFromFolder(LocalRepositoryFolder, _packages);
                OnRefreshed?.Invoke(this, EventArgs.Empty);
                Ready = true;
                return(res);
            }
            return(false);
        }
Exemplo n.º 6
0
        /// <inheritdoc />
        public bool Refresh()
        {
            if (!RepositoryReferenceValid())
            {
                return(false);
            }
            var res = this.GatherPackageReferencesFromFolder(AbsolutePath, _packages);

            OnRefreshed?.Invoke(this, EventArgs.Empty);
            Ready = true;
            return(res);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 导航至<see cref="FinancePage"/>时,进行初始化。
        /// </summary>
        /// <param name="e"></param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            await vm.InitializeAsync();

            OnRefreshed?.Invoke();

            if (App.IsAdmin)
            {
                AddButton.Visibility = Visibility.Visible;
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 更新<see cref="vm"/>
        /// </summary>
        /// <param name="result"></param>
        public async void Refresh(bool result)
        {
            await vm.InitializeAsync();

            OnRefreshed?.Invoke();
        }
Exemplo n.º 9
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            Graphics g = pe.Graphics;

            g.Clear(Color.White);
            if (transform == null)
            {
                CalcTransform();
            }
            g.Transform = transform;


            int w = (int)((CarModelState.MAX_POS_X - CarModelState.MIN_POS_X) / CarModel.MM_PER_PIXEL);
            int h = (int)((CarModelState.MAX_POS_Y - CarModelState.MIN_POS_Y) / CarModel.MM_PER_PIXEL);


            if (neuralController != null)
            {
                double orix = Math.Cos(carPositionProvider.GetCarState().Angle);
                double oriy = Math.Sin(carPositionProvider.GetCarState().Angle);

                PointF[] pp = new PointF[] { new PointF(0, 0), new PointF(Width - 1, Height - 1) };
                itransform.TransformPoints(pp);

                pp[0].X = (float)ComMath.Normal((pp[0].X - CarModel.OFFSET_X) * CarModel.MM_PER_PIXEL, CarModelState.MIN_POS_X, CarModelState.MAX_POS_X, NeuralController.MIN_NEURON_VALUE, NeuralController.MAX_NEURON_VALUE);
                pp[0].Y = (float)ComMath.Normal((pp[0].Y - CarModel.OFFSET_Y) * CarModel.MM_PER_PIXEL, CarModelState.MIN_POS_Y, CarModelState.MAX_POS_Y, NeuralController.MIN_NEURON_VALUE, NeuralController.MAX_NEURON_VALUE);
                pp[1].X = (float)ComMath.Normal((pp[1].X - CarModel.OFFSET_X) * CarModel.MM_PER_PIXEL, CarModelState.MIN_POS_X, CarModelState.MAX_POS_X, NeuralController.MIN_NEURON_VALUE, NeuralController.MAX_NEURON_VALUE);
                pp[1].Y = (float)ComMath.Normal((pp[1].Y - CarModel.OFFSET_Y) * CarModel.MM_PER_PIXEL, CarModelState.MIN_POS_Y, CarModelState.MAX_POS_Y, NeuralController.MIN_NEURON_VALUE, NeuralController.MAX_NEURON_VALUE);
                Bitmap background = neuralController.controller.Visualize(20, 20, new RectangleF(pp[0].X, pp[0].Y, pp[1].X - pp[0].X, pp[1].Y - pp[0].Y), 0, 1, new double[] { 0, 0, orix, oriy }, 0, -10, 10);


                pp = new PointF[] { new PointF(0, 0), new PointF(Width - 1, Height - 1) };
                itransform.TransformPoints(pp);

                g.DrawImage(background, new RectangleF(pp[0].X, pp[0].Y, pp[1].X - pp[0].X, pp[1].Y - pp[0].Y), new RectangleF(0, 0, background.Width - 1, background.Height - 1), GraphicsUnit.Pixel);
            }


            if (cameraCarPos != null)
            {
                Image im = cameraCarPos.GetImage();


                if (im != null)
                {
                    g.DrawImage(im, new Rectangle(0, 0, w, h), new Rectangle(0, 0, im.Width, im.Height), GraphicsUnit.Pixel);
                }
            }
            //g.DrawRectangle(new Pen(Color.Blue, 3), new Rectangle(0, 0, w, h));


            if (obstacleProvider != null)
            {
                List <ObstacleModel> obstacles = obstacleProvider.GetObstacleModels(0);
                foreach (ObstacleModel om in obstacles)
                {
                    om.Render(g);
                }
            }

            if (finishPositionProvider != null)
            {
                finishPositionProvider.GetFinishModel(0).Render(g);
            }


            if (trainingModels != null)
            {
                lock (trainingModels)
                {
                    foreach (CarModel m in trainingModels)
                    {
                        if (m != null)
                        {
                            m.Render(g, 120, false);
                        }
                    }
                }
            }

            if (carPositionProvider != null)
            {
                CarModel model = carPositionProvider.GetCarModel();
                model.Render(g, 255, true);
                if (recv)
                {
                    g.FillEllipse(new SolidBrush(Color.Red), new Rectangle((int)(model.state.Position.X / CarModel.MM_PER_PIXEL + CarModel.OFFSET_X) - 2, (int)(model.state.Position.Y / CarModel.MM_PER_PIXEL + CarModel.OFFSET_Y) - 2, 4, 4));
                    recv = false;
                }
            }

            // Calling the base class OnPaint
            base.OnPaint(pe);
            if (OnRefreshed != null)
            {
                OnRefreshed.Invoke();
            }
        }