Пример #1
0
 private void lstv_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         // Check if click on the select column item
         ListViewHitTestInfo          info    = lvGCNGrid.HitTest(e.X, e.Y);
         ListViewItem.ListViewSubItem subitem = info.SubItem;
         if (subitem is EXBoolListViewSubItem)
         {
             // Ok user clicked on selection column
             EXBoolListViewSubItem subool = subitem as EXBoolListViewSubItem;
             subool.BoolValue = !(subool.BoolValue);
             PQData pqd = subool.Tag as PQData;
             if (pqd != null)
             {
                 if (subool.BoolValue)
                 {
                     nbjours[pqd.Index] = nbjours[pqd.Index] + 1;
                 }
                 else
                 {
                     nbjours[pqd.Index] = nbjours[pqd.Index] - 1;
                 }
                 lvGCNGrid.Invalidate(subool.Bounds);
                 UpdateNbJours();
             }
         }
     }
 }
Пример #2
0
        //显示文件已有的共享权限
        private void AddDepAndUserToListView(List <File_Department> deps, List <ACL_File_User> users)
        {
            lvPermission.Items.Clear();
            foreach (File_Department fd in deps)
            {
                EXListViewItem item = new EXImageListViewItem(fd.DepartmentName, imageList1.Images["dep"]);
                item.Tag = fd;
                for (int i = 0; i < _accessArray_Values.Length; i++)
                {
                    EXBoolListViewSubItem sub = CreateBoolSubItem(_accessArray_Name[i], _accessArray_Values[i], (_accessArray_Values[i] & fd.FilePermission) == _accessArray_Values[i]);
                    item.SubItems.Add(sub);
                }
                lvPermission.Items.Add(item);
            }

            foreach (ACL_File_User fu in users)
            {
                EXListViewItem item = new EXImageListViewItem(fu.UserRealName, imageList1.Images["user"]);
                item.Tag = fu;
                for (int i = 0; i < _accessArray_Values.Length; i++)
                {
                    EXBoolListViewSubItem sub = CreateBoolSubItem(_accessArray_Name[i], _accessArray_Values[i], (_accessArray_Values[i] & fu.FilePermission) == _accessArray_Values[i]);
                    item.SubItems.Add(sub);
                }
                lvPermission.Items.Add(item);
            }
        }
Пример #3
0
        public void OnLevelChanged()
        {
            LayerList.BeginUpdate();
            LayerList.Clear();
            string active_layer = Program.engine.MainLevel.GetActiveLayer();

            for (int i = 0; i < Program.engine.MainLevel.GetLayerCount(); ++i)
            {
                string            text = Program.engine.MainLevel.GetLayerName(i);
                EXListViewItem    item = new EXImageListViewItem(NexusEditor.Properties.Resources.layer);
                EXListViewSubItem name = new EXListViewSubItem(text);
                name.OnItemValueChanged = this.OnLayerNameChanged; name.UserData = item;
                item.AddSubItem(name);
                EXBoolListViewSubItem active = new EXBoolListViewSubItem(active_layer == text);
                active.OnItemValueChanged = this.OnActiveLayer; active.UserData = item;
                item.AddSubItem(active);
                EXBoolListViewSubItem show = new EXBoolListViewSubItem(Program.engine.MainLevel.IsLayerVisible(text));
                show.OnItemValueChanged = this.OnShowLayer; show.UserData = item;
                item.AddSubItem(show);
                EXBoolListViewSubItem islock = new EXBoolListViewSubItem(Program.engine.MainLevel.IsLayerLocked(text));
                islock.OnItemValueChanged = this.OnLockLayer; islock.UserData = item;
                item.AddSubItem(islock);
                LayerList.AddItem(item);
            }
            LayerList.EndUpdate();
            //在右侧的列表中显示当前激活层中的所有actor
            UpdateActorList(Program.engine.MainLevel.GetActiveLayer());
            OperationTooltip.Text = "就绪";
        }
Пример #4
0
        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            //锁定或者解除锁定所有的层
            //只有当前层全部都冻结的时候,才设置为全部不冻结,否则全部冻结
            bool s = true;

            for (int i = 0; i < LayerList.ItemList.Count; ++i)
            {
                EXBoolListViewSubItem item = (EXBoolListViewSubItem)LayerList.Items[i].SubItems[4];
                if (item != null)
                {
                    if (!item.BoolValue)
                    {
                        s = false;
                    }
                }
            }

            for (int i = 0; i < LayerList.ItemList.Count; ++i)
            {
                EXBoolListViewSubItem item = (EXBoolListViewSubItem)LayerList.Items[i].SubItems[4];
                if (item != null)
                {
                    item.BoolValue = !s;
                    string layer = LayerList.Items[i].SubItems[1].Text;
                    Program.engine.MainLevel.LockLayer(layer, !s);
                }
            }

            LayerList.Invalidate();
            OperationTooltip.Text = "就绪";
        }
Пример #5
0
        private void OnActiveLayer(EXListViewSubItemBase _item, string oldText, string newText)
        {
            EXBoolListViewSubItem item = (EXBoolListViewSubItem)_item;

            if (item.BoolValue)
            {
                //解除其它层的激活
                for (int i = 0; i < LayerList.ItemList.Count; ++i)
                {
                    EXBoolListViewSubItem iter = (EXBoolListViewSubItem)LayerList.ItemList[i].SubItemList[1];
                    if (iter != item && iter.BoolValue)
                    {
                        iter.SetValue(false);
                        LayerList.Invalidate(iter.Bounds);
                    }
                }

                // 激活编辑器中的对应层
                ListView.SelectedListViewItemCollection sel = LayerList.SelectedItems;
                if (sel.Count > 0)
                {
                    Program.engine.MainLevel.SetActiveLayer(sel[0].SubItems[1].Text);
                }

                //在右侧的列表中显示当前激活层中的所有actor
                UpdateActorList(sel[0].SubItems[1].Text);
            }
            else
            {
                //不能直接关闭激活层的激活,只能通过激活其它层来替换当前激活层
                item.BoolValue = true;
                LayerList.Invalidate(item.Bounds);
            }
            OperationTooltip.Text = "就绪";
        }
Пример #6
0
        private EXBoolListViewSubItem CreateBoolSubItem(string key, object tag, bool value)
        {
            EXBoolListViewSubItem sub = new EXBoolListViewSubItem(value);

            sub.ValueChanged += Permission_ValueChanged;
            sub.Name          = key;
            sub.Tag           = tag;
            return(sub);
        }
Пример #7
0
        private void OnLockLayer(EXListViewSubItemBase _item, string oldText, string newText)
        {
            //锁定或者解锁编辑器中对应的层
            EXBoolListViewSubItem item = (EXBoolListViewSubItem)_item;

            ListView.SelectedListViewItemCollection sel = LayerList.SelectedItems;
            if (sel.Count > 0)
            {
                Program.engine.MainLevel.LockLayer(sel[0].SubItems[1].Text, item.BoolValue);
            }
            OperationTooltip.Text = "就绪";
        }
Пример #8
0
 private void lstv_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         // Check if click on the select column item
         ListViewHitTestInfo          info    = lvGCNGrid.HitTest(e.X, e.Y);
         ListViewItem.ListViewSubItem subitem = info.SubItem;
         if (subitem is EXBoolListViewSubItem)
         {
             // Ok user clicked on selection column
             EXBoolListViewSubItem subool = subitem as EXBoolListViewSubItem;
             subool.BoolValue = !(subool.BoolValue);
             lvGCNGrid.Invalidate(subool.Bounds);
         }
     }
 }
Пример #9
0
        public void bt_Click(object sender, LinkLabelLinkClickedEventArgs e)
        {
            LinkLabel      ll      = sender as LinkLabel;
            EXListViewItem ev      = ll.Tag as EXListViewItem;
            string         fileurl = this.Parent.Tag as string + @"\" + ev.SubItems[5].Text;

            XmlPad.XmlEditor xe = new XmlPad.XmlEditor();
            xe._content = ev.SubItems[3].Text;
            if (!xe.LoadFile(fileurl))
            {
                xe.Close();
                xe.Dispose();
            }
            else
            {
                xe.ShowDialog();
                EXBoolListViewSubItem booes = ev.SubItems[1] as EXBoolListViewSubItem;
                booes.BoolValue = true;
                this.exListView1.Refresh();
            }
        }
Пример #10
0
        /// <summary>
        /// 点击添加用户菜单项需要向ListView中添加用户共享
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UserItem_Click(object sender, EventArgs e)
        {
            //在ListView中添加一个用户项
            ToolStripMenuItem mi = sender as ToolStripMenuItem;

            if (mi == null || mi.Tag == null)
            {
                return;
            }
            User u = mi.Tag as User;

            if (u == null)
            {
                return;
            }
            //向ListView项中添加一个ACL_File_User对象,ListViewItem中保存2种对象,1:File_Department 2:ACL_File_User
            ACL_File_User fu = new ACL_File_User
            {
                UserID         = u.UserID,
                FileID         = _fileID,
                FilePermission = GetDefaultPermission()
            };
            EXListViewItem item = new EXImageListViewItem(u.UserRealName, imageList1.Images["user"]);

            item.Tag = fu;

            for (int i = 0; i < _accessArray_Values.Length; i++)
            {
                EXBoolListViewSubItem sub = CreateBoolSubItem(_accessArray_Name[i], _accessArray_Values[i], _accessArray_Default[i]);
                item.SubItems.Add(sub);
            }
            lvPermission.Items.Add(item);

            if (!_fileUsersPreAdd.Contains(fu) && !_fileUsersOriginal.Contains(fu))
            {
                _fileUsersPreAdd.Add(fu);
            }
            _fileUsersPreDelete.Remove(fu);
        }
Пример #11
0
        private void DepItem_Click(object sender, EventArgs e)
        {
            //在ListView中添加一个部门项
            ToolStripMenuItem mi = sender as ToolStripMenuItem;

            if (mi == null || mi.Tag == null)
            {
                return;
            }
            Department d = mi.Tag as Department;

            if (d == null)
            {
                return;
            }
            File_Department fd = new File_Department
            {
                FileID         = _fileID,
                DepartmentID   = d.DepartmentID,
                FilePermission = GetDefaultPermission()
            };
            EXListViewItem item = new EXImageListViewItem(d.DepartmentName, imageList1.Images["dep"]);

            item.Tag = fd;

            for (int i = 0; i < _accessArray_Values.Length; i++)
            {
                EXBoolListViewSubItem sub = CreateBoolSubItem(_accessArray_Name[i], _accessArray_Values[i], _accessArray_Default[i]);
                item.SubItems.Add(sub);
            }
            lvPermission.Items.Add(item);

            if (!_fileDepsPreAdd.Contains(fd) && !_fileDepsOriginal.Contains(fd))
            {
                _fileDepsPreAdd.Add(fd);
            }
            _fileDepsPreDelete.Remove(fd);
        }
Пример #12
0
        public bool OnNextButton()
        {
            bool ischeck = true;

            foreach (EXListViewItem element in this.exListView1.Items)
            {
                EXBoolListViewSubItem exb = element.SubItems[1] as EXBoolListViewSubItem;
                if (!exb.BoolValue)
                {
                    ischeck = false;
                    break;
                }
            }
            if (!ischeck)
            {
                MessageBox.Show("还有没有完成修改的文件请验证", "警告");
                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #13
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            //添加新层
            //确定可用的默认层名称
            string text;

            for (int i = 1;; ++i)
            {
                text = "新作业层" + i.ToString();
                if (!Program.engine.MainLevel.IsLayerExist(text))
                {
                    break;
                }
            }

            EXListViewItem    item = new EXImageListViewItem(NexusEditor.Properties.Resources.layer);
            EXListViewSubItem name = new EXListViewSubItem(text);

            name.OnItemValueChanged = this.OnLayerNameChanged; name.UserData = item;
            item.AddSubItem(name);
            EXBoolListViewSubItem active = new EXBoolListViewSubItem(false);

            active.OnItemValueChanged = this.OnActiveLayer; active.UserData = item;
            item.AddSubItem(active);
            EXBoolListViewSubItem show = new EXBoolListViewSubItem(true);

            show.OnItemValueChanged = this.OnShowLayer; show.UserData = item;
            item.AddSubItem(show);
            EXBoolListViewSubItem islock = new EXBoolListViewSubItem(true);

            islock.OnItemValueChanged = this.OnLockLayer; islock.UserData = item;
            item.AddSubItem(islock);
            LayerList.AddItem(item);
            // 在编辑器中对应的增加一层
            Program.engine.MainLevel.CreateNewLayer(text);
            OperationTooltip.Text = "就绪";
        }
Пример #14
0
        private void Permission_ValueChanged(ListViewItem item, EXBoolListViewSubItem subItem, int colIndex, bool value)
        {
            //权限值更改后即时修改ListViewItem.Tag中对象里面的FilePermission属性
            File_Department fd    = item.Tag as File_Department;
            int             index = colIndex - 1;

            if (index < 0 || index >= _accessArray_Values.Length)
            {
                return;
            }
            if (fd != null)
            {
                if (value)
                {
                    fd.FilePermission |= _accessArray_Values[index];
                }
                else
                {
                    fd.FilePermission = fd.FilePermission & ~_accessArray_Values[index];
                }
                return;
            }
            ACL_File_User fu = item.Tag as ACL_File_User;

            if (fu == null)
            {
                return;
            }
            if (value)
            {
                fu.FilePermission |= _accessArray_Values[index];
            }
            else
            {
                fu.FilePermission = fu.FilePermission & ~_accessArray_Values[index];
            }
        }
Пример #15
0
        void Button2Click(object sender, EventArgs e)
        {
            // Supprime la sélection
            try
            {
                _daddy._ThreadProgressBarTitle = _daddy.GetTranslator().GetString("PQBtnDelete");
                _daddy.CreateThreadProgressBar();

                // On va parcourir chaque PQ, ouvrir sa page et poster la suppression
                for (int i = 0; i < lvGCNGrid.Items.Count; i++)
                {
                    EXListViewItem lvi = (EXListViewItem)(lvGCNGrid.Items[i]);

                    EXBoolListViewSubItem svi = lvi.SubItems[1] as EXBoolListViewSubItem;
                    if (svi != null)
                    {
                        if (svi.BoolValue == true)
                        {
                            String guid = lvi.MyValue;
                            guid = "https://www.geocaching.com/pocket/gcquery.aspx?guid=" + guid;
                            PQDownloadHMI.DeletePQ(_daddy, guid);
                        }
                    }
                }

                // On rafraichit
                InitPQs();

                _daddy.KillThreadProgressBar();
            }
            catch (Exception ex)
            {
                _daddy.ShowException("", _daddy.GetTranslator().GetString("checkPQToolStripMenuItem"), ex);
                _daddy.KillThreadProgressBar();
            }
        }
Пример #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="daddy"></param>
        public NotificationCreation(MainWindow daddy)
        {
            _daddy      = daddy;
            _sErrTitle  = _daddy.GetTranslator().GetString("Error");
            _sErrFormat = _daddy.GetTranslator().GetString("ErrWrongParameter");

            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            if (!SpecialFeatures.SpecialFeaturesMgt.AreSpecialFeaturesEnabled())
            {
                return;
            }

            btnGCNMap.Image = _daddy.GetImageSized("Earth");
            _daddy._cacheDetail._gmap.ControlTextLatLon = tbGCNCenter;
            tbGCNCenter.TextChanged += new System.EventHandler(this.txtCoord_TextChanged);
            tbGCNCenter.Text         = _daddy.HomeLat.ToString() + " " + _daddy.HomeLon.ToString();
            this.Text         = _daddy.GetTranslator().GetString("createpublishnotifications");
            lblGCNRadius.Text = _daddy.GetTranslator().GetString("FTFDistance");
            lblGCNCentre.Text = _daddy.GetTranslator().GetString("ParamCenterLatLon");
            lblGCNEmail.Text  = _daddy.GetTranslator().GetString("FTFEmails");
            lblGCNGrid.Text   = _daddy.GetTranslator().GetString("FTFCacheTypes");
            lblGCNNom.Text    = _daddy.GetTranslator().GetString("FTFName");
            btnGCNCancel.Text = _daddy.GetTranslator().GetString("BtnCancel");
            btnGCNCreate.Text = _daddy.GetTranslator().GetString("BtnOK");

            daddy.UpdateHttpDefaultWebProxy();
            String post_response = "";
            // On checke que les L/MDP soient corrects
            // Et on récupère les cookies au passage
            CookieContainer cookieJar = daddy.CheckGCAccount(true, false);

            if (cookieJar == null)
            {
                return;
            }

            // Pour récupérer les emails
            String         url        = "https://www.geocaching.com/notify/edit.aspx";
            HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);

            objRequest.Proxy           = daddy.GetProxy(); // Là encore, on peut virer le proxy si non utilisé (NULL)
            objRequest.CookieContainer = cookieJar;        // surtout récupérer le container de cookie qui est maintenant renseigné avec le cookie d'authentification
            HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();

            using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream()))
            {
                post_response = responseStream.ReadToEnd();
                responseStream.Close();
            }
            if (NotificationsManager.CheckWarningMessage(_daddy, post_response))
            {
                // Shit
            }

            List <String> lsemails = new List <string>();
            String        email    = "";
            String        mails    = MyTools.GetSnippetFromText("ctl00$ContentBody$LogNotify$ddlAltEmails", "select>", post_response);

            lsemails = MyTools.GetSnippetsFromText("value=\"", "\">", mails);
            if (lsemails.Count != 0)
            {
                email = lsemails[0];
            }
            cbGCNEmails.Items.AddRange(lsemails.ToArray());
            if (cbGCNEmails.Items.Count != 0)
            {
                cbGCNEmails.SelectedIndex = 0;
            }
            else
            {
                cbGCNEmails.Visible = false;
                lblGCNEmail.Visible = false;
            }

            // List of cache type (to associate with list of int)
            listOfCacheTypes   = new List <string>(new String[] { "Earthcache", "Event Cache", "Cache In Trash Out Event", "Giga-Event Cache", "Mega-Event Cache", "Letterbox Hybrid", "Multi-cache", "Traditional Cache", "Unknown Cache", "Wherigo Cache", "Virtual Cache" }); // BCR 20170825
            listOfCacheTypesId = new List <int>(new int[] { 137, 6, 13, 7005, 453, 5, 3, 2, 8, 1858, 4 });                                                                                                                                                                       // BCR 20170825

            //Matrix
            listOfAlloweKindPerCacheType = new List <Tuple <String, List <int> > >();        // BCR 20170825
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Found it", new List <int>(new int[] { 0, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Retract Listing", new List <int>(new int[] { 7, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Didn't find it", new List <int>(new int[] { 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Temporarily Disable Listing", new List <int>(new int[] { 8, 10, 10, 10, 9, 8, 8, 8, 8, 8, 8 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Write note", new List <int>(new int[] { 2, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Enable Listing", new List <int>(new int[] { 9, 11, 11, 11, 10, 9, 9, 9, 9, 9, 9 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Archive", new List <int>(new int[] { 3, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Update Coordinates", new List <int>(new int[] { 10, 9, 9, 9, 11, 10, 10, 10, 10, 10, 10 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Needs Archived", new List <int>(new int[] { 4, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Needs Maintenance", new List <int>(new int[] { 11, -1, -1, -1, 12, 11, 11, 11, 11, 11, 11 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Unarchive", new List <int>(new int[] { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Owner Maintenance", new List <int>(new int[] { 12, -1, -1, -1, -1, 12, 12, 12, 12, 12, 12 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Publish Listing", new List <int>(new int[] { 6, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Announcement", new List <int>(new int[] { -1, 6, 6, 6, 6, -1, -1, -1, -1, -1, -1 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Will Attend", new List <int>(new int[] { -1, 3, 3, 3, 3, -1, -1, -1, -1, -1, -1 })));
            listOfAlloweKindPerCacheType.Add(new Tuple <String, List <int> >("Attended", new List <int>(new int[] { -1, 4, 4, 4, 4, -1, -1, -1, -1, -1, -1 })));

            // Create listview
            lvGCNGrid.HeaderStyle = ColumnHeaderStyle.None;
            ImageList imglist = new ImageList();

            imglist.ColorDepth = ColorDepth.Depth32Bit;
            imglist.ImageSize  = new Size(20, 20); // this will affect the row height
            imglist.Images.Add(_daddy.GetImageSized("Fail"));
            lvGCNGrid.SmallImageList   = imglist;
            lvGCNGrid.MouseClick      += new MouseEventHandler(lstv_MouseClick);
            lvGCNGrid.FullRowSelect    = true;
            lvGCNGrid.MyHighlightBrush = new SolidBrush(Color.Transparent);
            lvGCNGrid.MySelectBrush    = new SolidBrush(Color.Transparent);

            // Create columns
            // First column is for notification kind
            EXColumnHeader col = new EXColumnHeader("Type", 150);

            lvGCNGrid.Columns.Add(col);
            // And a column per cache type
            foreach (String key in listOfCacheTypes)
            {
                EXBoolColumnHeader boolcol = new EXBoolColumnHeader("", 20);
                boolcol.TrueImage  = _daddy.GetImageSized("Selected");
                boolcol.FalseImage = _daddy.GetImageSized("NotSelected");
                //col = new EXColumnHeader("", 50);
                lvGCNGrid.Columns.Add(boolcol);
            }

            // And a line with all cache type
            EXListViewItem lvi = new EXListViewItem("Cache types");

            lvGCNGrid.Items.Add(lvi);
            foreach (String key in listOfCacheTypes)
            {
                EXImageListViewSubItem si = new EXImageListViewSubItem(MyTools.ResizeImage(_daddy.GetImageSized(key), 16, 16));
                lvi.SubItems.Add(si);
            }

            // Add a line for each notification kind
            foreach (Tuple <String, List <int> > o in listOfAlloweKindPerCacheType)
            {
                lvi = new EXListViewItem(o.Item1);
                lvGCNGrid.Items.Add(lvi);
                foreach (int i in o.Item2)
                {
                    if (i != -1)
                    {
                        EXBoolListViewSubItem subi = new EXBoolListViewSubItem(false);
                        lvi.SubItems.Add(subi);
                    }
                    else
                    {
                        EXListViewSubItem subi = new EXListViewSubItem("");
                        subi.BackColor = Color.DarkBlue;
                        lvi.SubItems.Add(subi);
                    }
                }
            }
        }
Пример #17
0
        void BtnGCNCreateClick(object sender, EventArgs e)
        {
            // On vérifie
            // coordonnées
            Double dLat = Double.MaxValue;
            Double dLon = Double.MaxValue;
            String sLat = "";
            String sLon = "";
            bool   bOK  = ParameterObject.TryToConvertCoordinates(tbGCNCenter.Text, ref sLat, ref sLon);

            if (sLat != CoordConvHMI._sErrorValue)
            {
                dLat = MyTools.ConvertToDouble(sLat);
            }
            if (sLon != CoordConvHMI._sErrorValue)
            {
                dLon = MyTools.ConvertToDouble(sLon);
            }
            if (!bOK)
            {
                DisplayError(lblGCNCentre.Text, _daddy.GetTranslator().GetString("WaypointCoord"), tbGCNCenter.Text, "");
                return;
            }

            // nom
            if (tbGCNName.Text == "")
            {
                DisplayError(lblGCNNom.Text, _daddy.GetTranslator().GetString("lblnotempty"), tbGCNName.Text, "");
                return;
            }

            // radius
            Int32 radius = 0;

            if (!Int32.TryParse(tbGCNRadius.Text, out radius))
            {
                DisplayError(lblGCNRadius.Text, _daddy.GetTranslator().GetString("lblnotnumber"), tbGCNRadius.Text, "");
                return;
            }

            // email
            if ((cbGCNEmails.Visible) && (cbGCNEmails.SelectedIndex == -1))
            {
                DisplayError(lblGCNEmail.Text, _daddy.GetTranslator().GetString("lblvalue"), "", "");
                return;
            }

            String email = "";

            if (cbGCNEmails.Items.Count != 0)
            {
                int pos = cbGCNEmails.SelectedIndex;
                email = cbGCNEmails.Items[pos].ToString();
            }

            // type
            // au moins une croix quelque part...
            // int associé au type de cache, nom du type de cache, liste des commandes POST pour kind of notif
            // Tuple<int, string, List<String>
            // on va créer un dico avec comme clé le type de cache
            Dictionary <String, Tuple <int, string, List <String> > > dicoCreation = new Dictionary <string, Tuple <int, string, List <string> > >();

            // On parcourt toutes les lignes, sauf la première qui correspond aux types
            for (int i = 1; i < lvGCNGrid.Items.Count; i++)
            {
                // On a l'item
                EXListViewItem lvi = (EXListViewItem)(lvGCNGrid.Items[i]);

                // On parcourt ses sous items
                for (int k = 1; k < lvi.SubItems.Count; k++)
                {
                    EXBoolListViewSubItem svi = lvi.SubItems[k] as EXBoolListViewSubItem;
                    if (svi != null)
                    {
                        // On a une valeur checkable
                        if (svi.BoolValue)
                        {
                            // Et elle est checkée !!
                            // On construit ce qu'il nous faut maintenant
                            //msg += listOfCacheTypes[k-1] + " " + listOfCacheTypesId[k-1] + " " + listOfAlloweKindPerCacheType[i-1].Item1 + " " + listOfAlloweKindPerCacheType[i-1].Item2[k-1] + "\r\n";


                            String typeofcache         = listOfCacheTypes[k - 1];
                            int    typeofcacheid       = listOfCacheTypesId[k - 1];
                            String kindofnotifreadable = listOfAlloweKindPerCacheType[i - 1].Item1;
                            String kindofnotifpost     = "ctl00$ContentBody$LogNotify$cblLogTypeList$" + listOfAlloweKindPerCacheType[i - 1].Item2[k - 1];
                            if (dicoCreation.ContainsKey(typeofcache))
                            {
                                // On met à jour la liste des kind of notif
                                Tuple <int, string, List <String> > obj = dicoCreation[typeofcache];
                                obj.Item3.Add(kindofnotifpost);
                            }
                            else
                            {
                                Tuple <int, string, List <String> > obj = new Tuple <int, string, List <string> >(typeofcacheid, typeofcache, new List <string>(new string[] { kindofnotifpost }));
                                dicoCreation.Add(typeofcache, obj);
                            }
                        }
                    }
                }
            }

            if (dicoCreation.Count == 0)
            {
                DisplayError(lblGCNGrid.Text, _daddy.GetTranslator().GetString("lblvalue"), "", "");
                return;
            }

            /*
             * foreach(KeyValuePair<String, Tuple<int, string, List<String>>> pair in dicoCreation)
             * {
             *      Tuple<int, string, List<String>> obj = pair.Value;
             *      msg += obj.Item1.ToString() + " " + obj.Item2 + " -> ";
             *      foreach(String s in obj.Item3)
             *      {
             *              msg += s + " ";
             *      }
             *      msg += "\r\n";
             * }
             * _daddy.MSG(msg);
             * return;
             */

            // On est valide, on peut créer
            _daddy._cacheDetail._gmap.ControlTextLatLon = null;

            // Go création
            CookieContainer cookieJar = _daddy.CheckGCAccount(true, false);
            String          url       = "https://www.geocaching.com/notify/edit.aspx";
            bool            error     = false;

            foreach (KeyValuePair <String, Tuple <int, string, List <String> > > pair in dicoCreation)
            {
                Tuple <int, string, List <String> > obj = pair.Value;
                // On demande la page par défaut pour initialiser une nouvelle demande
                HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
                objRequest.Proxy           = _daddy.GetProxy(); // Là encore, on peut virer le proxy si non utilisé (NULL)
                objRequest.CookieContainer = cookieJar;         // surtout récupérer le container de cookie qui est maintenant renseigné avec le cookie d'authentification
                HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
                String          post_response;
                using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream()))
                {
                    post_response = responseStream.ReadToEnd();
                    responseStream.Close();
                }
                // On regarde si on a un message de warning
                if (NotificationsManager.CheckWarningMessage(_daddy, post_response))
                {
                    // Shit
                    error = true;
                    break;
                }

                // Une mise à jour pour définir le type de cache
                String post_string = NotificationsManager.GeneratePostString(_daddy, post_response, dLat, dLon, radius, tbGCNName.Text, obj, email, true);
                post_response = NotificationsManager.GeneratePostRequets(_daddy, url, post_string, cookieJar);

                // Une mise à jour pour définir le type de notif
                post_string   = NotificationsManager.GeneratePostString(_daddy, post_response, dLat, dLon, radius, tbGCNName.Text, obj, email, true);
                post_response = NotificationsManager.GeneratePostRequets(_daddy, url, post_string, cookieJar);
                if (NotificationsManager.CheckValidationMessage(_daddy, post_response))
                {
                    // Shit
                    error = true;
                    break;
                }
            }
            if (!error)
            {
                _daddy.MsgActionDone(this);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Пример #18
0
        void BtnGCNCreateClick(object sender, EventArgs e)
        {
            foreach (int nb in nbjours)
            {
                if (nb > 10)
                {
                    _daddy.MsgActionError(this, _daddy.GetTranslator().GetString("PQCheckErrNb"));
                    return;
                }
            }
            String msg = "";

            _daddy._ThreadProgressBarTitle = _daddy.GetTranslator().GetString("LblOperationInProgress");
            _daddy.CreateThreadProgressBar();

            // On va commencer par décocher les PQs qui ne sont plus cochées
            // *************************************************************
            for (int i = 0; i < lvGCNGrid.Items.Count; i++)
            {
                EXListViewItem lvi = (EXListViewItem)(lvGCNGrid.Items[i]);
                // On parcourt ses sous items
                for (int k = 2; k < lvi.SubItems.Count; k++)
                {
                    EXBoolListViewSubItem svi = lvi.SubItems[k] as EXBoolListViewSubItem;
                    if (svi != null)
                    {
                        PQData pqd = svi.Tag as PQData;
                        if (pqd != null)
                        {
                            if ((svi.BoolValue == false) && (pqd.Checked))
                            {
                                // On a décoché, on traite
                                //msg += lvi.Text + " décochée pour le jour " + k.ToString() + "\r\n";
                                String res = PQCheck(pqd, svi.BoolValue);
                                CheckResult(lvi.Text, res, ref msg);
                            }
                        }
                    }
                }
            }

            // Puis on coche les nouvelles PQs
            // *******************************
            for (int i = 0; i < lvGCNGrid.Items.Count; i++)
            {
                EXListViewItem lvi = (EXListViewItem)(lvGCNGrid.Items[i]);
                // On parcourt ses sous items
                for (int k = 2; k < lvi.SubItems.Count; k++)
                {
                    EXBoolListViewSubItem svi = lvi.SubItems[k] as EXBoolListViewSubItem;
                    if (svi != null)
                    {
                        PQData pqd = svi.Tag as PQData;
                        if (pqd != null)
                        {
                            if ((svi.BoolValue) && (!pqd.Checked))
                            {
                                // On a coché, on traite
                                //msg += lvi.Text + " cochée pour le jour " + k.ToString() + "\r\n";
                                String res = PQCheck(pqd, svi.BoolValue);
                                CheckResult(lvi.Text, res, ref msg);
                            }
                        }
                    }
                }
            }

            if (msg != "")
            {
                textBox8.Text = msg;
            }
            else
            {
                textBox8.Text = _daddy.GetTranslator().GetString("LblActionDone");
            }

            // Recharge ?
            InitPQs();
            _daddy.KillThreadProgressBar();
        }
Пример #19
0
        private void InitPQs()
        {
            try
            {
                _daddy._ThreadProgressBarTitle = _daddy.GetTranslator().GetString("LblOperationInProgress");
                _daddy.CreateThreadProgressBar();

                nbjours = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
                lvGCNGrid.Items.Clear();

                // Premire ligne pour les noms de colonne
                EXListViewItem lvi = null;

                _daddy.UpdateHttpDefaultWebProxy();
                String post_response = "";
                // On checke que les L/MDP soient corrects
                // Et on récupère les cookies au passage
                cookieJar = _daddy.CheckGCAccount(true, false);
                if (cookieJar == null)
                {
                    return;
                }

                // Pour récupérer les emails
                String         url        = "https://www.geocaching.com/pocket/default.aspx";
                HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
                objRequest.Proxy           = _daddy.GetProxy(); // Là encore, on peut virer le proxy si non utilisé (NULL)
                objRequest.CookieContainer = cookieJar;         // surtout récupérer le container de cookie qui est maintenant renseigné avec le cookie d'authentification
                HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
                using (StreamReader responseStream = new StreamReader(objResponse.GetResponseStream()))
                {
                    post_response = responseStream.ReadToEnd();
                    responseStream.Close();
                }

                // L'heure du serveur
                label8.Text = _daddy.GetTranslator().GetString("PQCheckServerTime");
                String heure = MyTools.GetSnippetFromText("<div id=\"ActivePQs\">", "</p>", post_response);
                heure = MyTools.GetSnippetFromText("</strong>", "</small>", heure);
                heure = CleanBloodyHTML(heure);
                DateTime servtime;    // = new DateTime(1990, 1, 1);
                DateTime.TryParse(heure, out servtime);
                label8.Text += heure;

                int i = 1;
                while (true)
                {
                    String pqdeb = "";

                    if (i < 100)
                    {
                        pqdeb = String.Format("ctl00_ContentBody_PQListControl1_PQRepeater_ctl{0:00}_uxPQImageType", i);
                    }
                    else if (i < 1000)
                    {
                        pqdeb = String.Format("ctl00_ContentBody_PQListControl1_PQRepeater_ctl{0:000}_uxPQImageType", i);
                    }
                    else if (i < 10000)
                    {
                        pqdeb = String.Format("ctl00_ContentBody_PQListControl1_PQRepeater_ctl{0:0000}_uxPQImageType", i);
                    }

                    String pqbloc = MyTools.GetSnippetFromText(pqdeb, "</tr>", post_response);
                    if (pqbloc == "")
                    {
                        break;
                    }
                    else
                    {
                        // On a un bloc valide
                        List <String> vals = MyTools.GetSnippetsFromText("<td class=", "</td>", pqbloc);
                        String        guid = MyTools.GetSnippetFromText("<a href=", "</a>", pqbloc);
                        guid = MyTools.GetSnippetFromText("aspx?guid=", "\"", guid);
                        String name = MyTools.GetSnippetFromText("<a href=", "</a>", pqbloc);
                        name        = MyTools.GetSnippetFromText(">", "", name);
                        lvi         = new EXListViewItem(name);
                        lvi.MyValue = guid;
                        lvGCNGrid.Items.Add(lvi);

                        // La suppression
                        EXBoolListViewSubItem subi = new EXBoolListViewSubItem(false);
                        subi.Tag = null;
                        lvi.SubItems.Add(subi);

                        // Maintenant les jours
                        for (int d = 1; d <= 7; d++)
                        {
                            String bloc  = vals[d];
                            String urlpq = MyTools.GetSnippetFromText("<a href=\"", "\">", bloc);
                            if (bloc.Contains("checkbox_off.png"))
                            {
                                subi     = new EXBoolListViewSubItem(false);
                                subi.Tag = new PQData(urlpq, false, d - 1);
                                lvi.SubItems.Add(subi);
                            }
                            else
                            {
                                subi           = new EXBoolListViewSubItem(true);
                                subi.Tag       = new PQData(urlpq, true, d - 1);
                                nbjours[d - 1] = nbjours[d - 1] + 1;
                                lvi.SubItems.Add(subi);
                            }
                        }
                        // Dernière génération
                        String dategen = MyTools.GetSnippetFromText("<td>", "</td>", pqbloc);
                        dategen = CleanBloodyHTML(dategen);
                        var      subi2 = lvi.SubItems.Add(new EXListViewSubItem(dategen));
                        DateTime lastgen;
                        if (DateTime.TryParse(dategen, out lastgen))
                        {
                            if ((servtime.Year == lastgen.Year) && (servtime.Month == lastgen.Month) && (servtime.Day == lastgen.Day))
                            {
                                // On met en gras
                                subi2.BackColor = Color.LightGreen;
                            }
                        }
                    }

                    i++;
                }

                UpdateNbJours();
                _daddy.KillThreadProgressBar();
            }
            catch (Exception ex)
            {
                _daddy.ShowException("", _daddy.GetTranslator().GetString("checkPQToolStripMenuItem"), ex);
                _daddy.KillThreadProgressBar();
            }
        }