Exemple #1
0
 public void UpdateMessage(AbstractAnalyser me, string key, PlainTextMessage message)
 {
     lock (operationLock)
     {
         if (me != null && !CheckPermission(me))
         {
             return;
         }
         if (existMessages.ContainsKey(key))
         {
             PlainTextMessage intermes = existMessages[key];
             if (intermes.Equals(message))
             {
                 return;
             }
             for (int i = 0; i < linkAnalysisMessages.Count; ++i)
             {
                 if (linkAnalysisMessages[i].Equals(intermes))
                 {
                     linkAnalysisMessages.RemoveAt(i);
                     linkAnalysisMessages.Insert(i, message);
                     break;
                 }
             }
         }
         else
         {
             linkAnalysisMessages.Add(message);
         }
         existMessages[key] = message;
     }
 }
Exemple #2
0
 public void AddComboBoxItem(AbstractAnalyser me, PlainTextComboBoxData item)
 {
     lock (operationLock)
     {
         if (me != null && !CheckPermission(me))
         {
             return;
         }
         comboBoxItems.Add(item);
     }
 }
Exemple #3
0
 public void ClearComboBoxItem(AbstractAnalyser me)
 {
     lock (operationLock)
     {
         if (me != null && !CheckPermission(me))
         {
             return;
         }
         comboBoxItems.Clear();
     }
 }
Exemple #4
0
 public void SetComboBoxSelectionChangedListener(AbstractAnalyser me, Action <PlainTextComboBoxData> listener)
 {
     lock (operationLock)
     {
         if (me != null && !CheckPermission(me))
         {
             return;
         }
         this.ComboBoxSelectionChanged = listener;
     }
 }
Exemple #5
0
 public void SetRecommendedName(AbstractAnalyser me, string name, double opacity)
 {
     lock (operationLock)
     {
         if (me != null && !CheckPermission(me))
         {
             return;
         }
         recommendedNameBlock.Text    = name;
         recommendedNameBlock.Opacity = opacity;
     }
 }
Exemple #6
0
        private async void URLBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            string url = URLBox.Text;

            analyser?.Dispose();
            analyser = UrlConverter.GetAnalyser(url);
            if (analyser == null)
            {
                return;
            }

            controller.RegistAnalyser(null, analyser);
            analyser.BindVisualController(controller);
            await analyser.SetURLAsync(url);
        }
Exemple #7
0
 public void RemoveAnalyser(AbstractAnalyser analyser)
 {
     lock (operationLock)
     {
         if (analyser == null)
         {
             throw new Exception("不能为null移除权限");
         }
         while (analysers.Contains(analyser))
         {
             analysers.Remove(analyser);
         }
         GC.Collect();
     }
 }
Exemple #8
0
 public void RegistAnalyser(AbstractAnalyser me, AbstractAnalyser analyser)
 {
     lock (operationLock)
     {
         if (me != null && !CheckPermission(me))
         {
             return;
         }
         if (analyser == null)
         {
             throw new Exception("不能为null添加权限");
         }
         analysers.Add(analyser);
     }
 }
Exemple #9
0
 public void SetSubmitButtonEnabled(AbstractAnalyser me, bool enable)
 {
     lock (operationLock)
     {
         if (me != null && !CheckPermission(me))
         {
             return;
         }
         if (enable == submitButton.IsEnabled)
         {
             return;
         }
         submitButton.IsEnabled = enable;
     }
 }
Exemple #10
0
 public void RemoveMessage(AbstractAnalyser me, string key)
 {
     lock (operationLock)
     {
         if (me != null && !CheckPermission(me))
         {
             return;
         }
         if (existMessages.ContainsKey(key))
         {
             linkAnalysisMessages.Remove(existMessages[key]);
             existMessages.Remove(key);
         }
     }
 }
Exemple #11
0
 public void SetComboBoxLayoutVisibility(AbstractAnalyser me, bool visible)
 {
     lock (operationLock)
     {
         if (me != null && !CheckPermission(me))
         {
             return;
         }
         if (visible)
         {
             comboBoxLayoutVisibilityManager.Show();
         }
         else
         {
             comboBoxLayoutVisibilityManager.Hide();
         }
     }
 }
        //得到了一个新URL,分析其文件名,文件大小
        private async void AddURL(string URL)
        {
            AbstractAnalyser analyser = Converters.UrlConverter.GetAnalyser(URL);
            await analyser.SetURLAsync(URL);

            if (analyser.IsLegal())
            {
                URLMessage message = new URLMessage();
                message.URL                 = analyser.URL;
                message.StreamSize          = analyser.GetStreamSize();
                message.RecommendedFileName = analyser.GetRecommendedName();
                if (message.RecommendedFileName == null)
                {
                    message.RecommendedFileName = string.Empty;
                }
                message.StreamSizeToString = Converters.StringConverter.GetPrintSize(analyser.GetStreamSize());
                AddListViewItem(message);
                LimitListLength();
            }
            analyser.Dispose();
        }
Exemple #13
0
 /// <summary>
 /// 对Analyser的权限管理:每个函数第一个参数要求传入正在调用的Analyser
 /// 当当前调用的Analyser没有修改权限时,修改将不会生效
 /// 有权限的Analyser或null才能修改其他Analyser的权限
 /// </summary>
 ///
 public bool CheckPermission(AbstractAnalyser analyser)
 {
     return(analysers.Contains(analyser));
 }