Example #1
0
        // mark ticker for automatic RT window update
        internal void MarkTickerForRecentInfo()
        {
            lock (this)
            {
                // set default RI data
                RecentInfo        = new RecentInfo();
                RecentInfo.Bitmap = RecentInfoField.Last | RecentInfoField.DateChange | RecentInfoField.DateUpdate;

                // mark ticker for RI update
                UpdateRecentInfo = true;
            }
        }
Example #2
0
 internal void MarkTickerForRecentInfo()
 {
     lock (this)
     {
         RecentInfo = new RecentInfo
         {
             Bitmap = RecentInfoField.Last |
                      RecentInfoField.Bid |
                      RecentInfoField.Ask |
                      RecentInfoField.TradeVol |
                      RecentInfoField.TotalVol |
                      RecentInfoField.DateChange |
                      RecentInfoField.DateUpdate
         };
     }
 }
Example #3
0
        public RecentItem(RecentInfo info, int parentWidth, string fileName)
        {
            FileName = fileName;

            Size      = new Size(parentWidth - 10, 30);
            BackColor = Color.Transparent;

            Bitmap icon = new Bitmap(info.FileName.GetLargeIcon(), new Size(30, 30));

            icon.OptimizeImage();

            Icon                       = new MaterialAPI.PictureBox();
            Icon.Size                  = new Size(30, 30);
            Icon.Location              = new Point(0, 0);
            Icon.BackgroundImage       = icon;
            Icon.BackgroundImageLayout = ImageLayout.Center;
            Icon.BackColor             = Color.Transparent;
            Icon.MouseEnter           += (se, ev) => { OnMouseEnter(ev); };
            Icon.MouseLeave           += (se, ev) => { OnMouseLeave(ev); };
            Icon.MouseClick           += (se, ev) => { OnMouseClick(ev); };

            Title              = new MaterialAPI.Label();
            Title.AutoSize     = false;
            Title.AutoEllipsis = true;
            Title.Size         = new Size(Width - 30, Height);
            Title.Location     = new Point(30, 0);
            Title.BackColor    = Color.Transparent;
            Title.Text         = FileData.GetDescription(info.FileName);
            Title.TextAlign    = ContentAlignment.MiddleLeft;
            Title.Font         = new Font("Segoe UI", 12, FontStyle.Regular);
            Title.Padding      = new Padding(15, 0, 15, 0);
            Title.MouseEnter  += (se, ev) => { OnMouseEnter(ev); };
            Title.MouseLeave  += (se, ev) => { OnMouseLeave(ev); };
            Title.MouseClick  += (se, ev) => { OnMouseClick(ev); };

            Controls.Add(Icon);
            Controls.Add(Title);
        }
Example #4
0
 protected override bool HandleRecentInfo()
 {
     if (RecentInfo.Length == 0)
     {
         UserConfig            = new InfoGetConfig();
         UserConfig.reply_code = (int)ReplyCodeMeaning.NoNetWork;
         UserConfig.reply_msg  = "没有校园网";
         UserConfig.userinfo   = null;
         Debug.WriteLine(UserConfig.reply_msg);
         return(false);
     }
     else
     {
         bool IsLoggedIn = RecentInfo.IndexOf("userinfo") >= 0;
         if (IsLoggedIn)
         {
             //如果有返回信息
             var serializer = new DataContractJsonSerializer(typeof(InfoGetConfig));
             var mStream    = new MemoryStream(Encoding.UTF8.GetBytes(RecentInfo));
             UserConfig            = (InfoGetConfig)serializer.ReadObject(mStream);
             UserConfig.reply_code = (int)ReplyCodeMeaning.AlreadyLoggedIn;
             UserConfig.reply_msg  = "登录成功!";
             Debug.WriteLine(UserConfig.reply_msg);
             return(true);
         }
         else
         {
             UserConfig            = new InfoGetConfig();
             UserConfig.reply_code = (int)ReplyCodeMeaning.NotLoggedIn;
             UserConfig.reply_msg  = "无用户portal信息";
             UserConfig.userinfo   = null;
             Debug.WriteLine(UserConfig.reply_msg);
             return(false);
         }
     }
 }
        /// <summary>
        /// ファイル更新情報キューに、ファイル更新情報を追加する
        /// </summary>
        /// <remarks>
        /// 対象パスがキューに登録済みの場合は、登録情報の更新を行います。
        /// 未登録の場合は、情報を新規登録します。
        /// </remarks>
        /// <param name="watchTarget">変更通知が発生した、ファイル情報</param>
        /// <param name="watcherChangeType">変更内容区分</param>
        /// <param name="beforeRenamedName">変更内容区分がリネームの場合、リネーム前のファイル名を入力してください</param>
        FileUpdateQueueItem UpdateOrInsertUpdatedFileQueueItem(FileInfo watchTarget, WatcherChangeTypes watcherChangeType, string beforeRenamedName)
        {
            FileUpdateQueueItem fileUpdateQueueItem;
            string key;

            lock (this) {
                // 更新イベントの対象ファイルが、ACLファイルか物理ファイルか更新キューに使用するキーが異なる。
                // ACLファイルでは、ACLハッシュをキーに使用します。
                // 物理ファイルでは、ファイルパスをキーに使用します。
                if (watchTarget.Extension == ".aclgene")
                {
                    // ACLファイルの場合、更新イベントを追わなくてもACLハッシュで常にどのファイルが更新キュー内のどこにあるかがわかる
                    // ※ただし、ファイル削除を除く

                    if (watcherChangeType == WatcherChangeTypes.Deleted)
                    {
                        var deletedFileRelativePath = this.mWorkspace.TrimWorekspacePath(watchTarget.FullName);
                        var r = from u in mUpdatesWatchFiles
                                where u.Value.OldRenameNamePath == deletedFileRelativePath
                                select u;
                        var prop = r.FirstOrDefault();
                        if (prop.Key != null)
                        {
                            mUpdatesWatchFiles.TryGetValue(prop.Key, out fileUpdateQueueItem);
                        }
                        else
                        {
                            fileUpdateQueueItem = new FileUpdateQueueItem {
                                Target = watchTarget
                            };

                            mUpdatesWatchFiles.AddOrUpdate(deletedFileRelativePath,
                                                           fileUpdateQueueItem, (_key, _value) => fileUpdateQueueItem
                                                           );

                            // 発生はありえないが、発生した場合は処理せず終了
                            // →発生はありうる。
                            //LOG.Warn("更新キューに登録されていないACLファイルの削除イベント");
                            //return null;
                        }
                    }
                    else
                    {
                        // ACLファイルからACLデータを取得
                        AclFileStructure aclFileData;
                        using (var file = File.OpenRead(watchTarget.FullName)) {
                            aclFileData = Serializer.Deserialize <AclFileStructure> (file);
                        }

                        var aclhash = aclFileData.FindKeyValue("ACLHASH");

                        if (!mUpdatesWatchFiles.ContainsKey(aclhash))
                        {
                            fileUpdateQueueItem = new FileUpdateQueueItem {
                                Target = watchTarget
                            };

                            mUpdatesWatchFiles.AddOrUpdate(aclhash, fileUpdateQueueItem, (_key, _value) => fileUpdateQueueItem);
                        }
                        else
                        {
                            // キューから情報を取得
                            mUpdatesWatchFiles.TryGetValue(aclhash, out fileUpdateQueueItem);
                            fileUpdateQueueItem.Target = watchTarget; // 登録している物理ファイル情報を最新のオブジェクトにする
                        }

                        // 最後に更新イベントが発生した時のファイルパスを格納しておく(Deleteイベント用)
                        fileUpdateQueueItem.OldRenameNamePath = this.mWorkspace.TrimWorekspacePath(watchTarget.FullName);
                    }
                }
                else
                {
                    if (watcherChangeType == WatcherChangeTypes.Renamed && !string.IsNullOrEmpty(beforeRenamedName))
                    {
                        // 変更内容がリネームの場合、名前変更前のファイルパスで登録済みの項目を取得し、
                        // 名前変更前の項目はキューから削除します。
                        // 名前変更後の項目として、新たにキューに再登録を行います。
                        var renamedFullName = watchTarget.FullName.Replace(watchTarget.FullName, beforeRenamedName);

                        var oldkey = this.mWorkspace.TrimWorekspacePath(renamedFullName);
                        key = this.mWorkspace.TrimWorekspacePath(watchTarget.FullName);

                        if (mUpdatesWatchFiles.ContainsKey(oldkey))
                        {
                            // 古いキーの項目をキューから削除します。
                            // 新しいキーで、キューに情報を再登録します。
                            mUpdatesWatchFiles.TryRemove(oldkey, out fileUpdateQueueItem);
                            mUpdatesWatchFiles.AddOrUpdate(key, fileUpdateQueueItem, (_key, _value) => fileUpdateQueueItem);
                        }
                    }
                    else if (watcherChangeType == WatcherChangeTypes.Created)
                    {
                        key = this.mWorkspace.TrimWorekspacePath(watchTarget.FullName);
                    }
                    else
                    {
                        key = this.mWorkspace.TrimWorekspacePath(watchTarget.FullName);
                    }

                    // 更新通知があったファイルが処理キューに未登録の場合、キューに更新通知情報を新規登録します
                    if (!mUpdatesWatchFiles.ContainsKey(key))
                    {
                        fileUpdateQueueItem = new FileUpdateQueueItem {
                            Target = watchTarget
                        };

                        mUpdatesWatchFiles.AddOrUpdate(key, fileUpdateQueueItem, (_key, _value) => fileUpdateQueueItem);
                    }
                    else
                    {
                        // キューから情報を取得
                        mUpdatesWatchFiles.TryGetValue(key, out fileUpdateQueueItem);
                        fileUpdateQueueItem.Target = watchTarget; // 登録している物理ファイル情報を最新のオブジェクトにする
                    }

                    // 更新通知のイベント区分が『リネーム』の場合、元のファイル名も保存しておく。
                    // イベント処理前は物理ディレクトリ空間のファイルパスはリネーム前のパスのままなので、
                    // リネーム前のファイル名のみを保存します。
                    if (watcherChangeType == WatcherChangeTypes.Renamed &&
                        string.IsNullOrEmpty(fileUpdateQueueItem.OldRenameNamePath))
                    {
                        fileUpdateQueueItem.OldRenameNamePath = beforeRenamedName;
                    }
                }

                // 情報に、履歴を追加
                var now = DateTime.Now;
                fileUpdateQueueItem.LastUpdate = now;
                var rec = new RecentInfo {
                    EventType  = watcherChangeType,
                    RecentDate = now
                };
                fileUpdateQueueItem.Recents.Add(rec);

                return(fileUpdateQueueItem);
            }
        }