• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisiónb34bc4e15708c54345e7db4472fc9a677478c50d (tree)
Tiempo2011-02-19 14:14:19
Autorazyobuzin <azyobuzin@user...>
Commiterazyobuzin

Log Message

・@#補完完成
・SortOrderを使うようにした
・SelectCaseのバグを修正

Cambiar Resumen

  • delete: "\202\302\202\242\202\351\202\361\202\351\202\361/Controls/StatusesListView.cs"
  • delete: "\202\302\202\242\202\351\202\361\202\351\202\361/Controls/UpdateStatusTextBox.Designer.cs"
  • delete: "\202\302\202\242\202\351\202\361\202\351\202\361/Controls/UpdateStatusTextBox.cs"
  • delete: "\202\302\202\242\202\351\202\361\202\351\202\361/Extensions.cs"
  • delete: "\202\302\202\242\202\351\202\361\202\351\202\361/Forms/MainForm.cs"
  • delete: "\202\302\202\242\202\351\202\361\202\351\202\361/Settings/Settings.cs"
  • delete: "\202\302\202\242\202\351\202\361\202\351\202\361/Settings/SettingsBase.cs"

Diferencia incremental

--- "a/\202\302\202\242\202\351\202\361\202\351\202\361/Controls/StatusesListView.cs"
+++ "b/\202\302\202\242\202\351\202\361\202\351\202\361/Controls/StatusesListView.cs"
@@ -55,8 +55,9 @@ namespace Azyobuzi.Twirunrun
5555 this.SelectedIndices.Clear();
5656 indexes.Select(oldIndex => oldIndex +
5757 (int)Settings.Instance.OrderType.SelectCase()
58- .Case(OrderTypes.Ascending, () => -1)
59- .Case(OrderTypes.Descending, () => +1)
58+ .Case(SortOrder.Ascending, () => -1)
59+ .Case(SortOrder.Descending, () => +1)
60+ .Default(() => 0)
6061 .Result
6162 )
6263 .ForEach(newIndex => this.SelectedIndices.Add(newIndex));
--- "a/\202\302\202\242\202\351\202\361\202\351\202\361/Controls/UpdateStatusTextBox.Designer.cs"
+++ "b/\202\302\202\242\202\351\202\361\202\351\202\361/Controls/UpdateStatusTextBox.Designer.cs"
@@ -65,6 +65,7 @@
6565 this.textBox1.Name = "textBox1";
6666 this.textBox1.Size = new System.Drawing.Size(150, 150);
6767 this.textBox1.TabIndex = 0;
68+ this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
6869 this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyDown);
6970 this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
7071 //
@@ -77,6 +78,7 @@
7778 this.listBox1.Name = "listBox1";
7879 this.listBox1.Size = new System.Drawing.Size(96, 100);
7980 this.listBox1.TabIndex = 0;
81+ this.listBox1.TabStop = false;
8082 //
8183 // UpdateStatusTextBox
8284 //
--- "a/\202\302\202\242\202\351\202\361\202\351\202\361/Controls/UpdateStatusTextBox.cs"
+++ "b/\202\302\202\242\202\351\202\361\202\351\202\361/Controls/UpdateStatusTextBox.cs"
@@ -14,7 +14,19 @@ namespace Azyobuzi.Twirunrun
1414 public UpdateStatusTextBox()
1515 {
1616 InitializeComponent();
17- listBox1.DataSource = Settings.Instance.AtHashtagList;
17+ Settings.Instance.PropertyChanged += (sender, e) =>
18+ {
19+ if (e.PropertyName == "AtHashtagList")
20+ {
21+ listBox1.Invoke((MethodInvoker)(() =>
22+ {
23+ var selected = listBox1.SelectedItem;
24+ listBox1.Items.Clear();
25+ listBox1.Items.AddRange(Settings.Instance.AtHashtagList);
26+ listBox1.SelectedItem = selected;
27+ }));
28+ }
29+ };
1830 }
1931
2032 public void Clear()
@@ -36,26 +48,43 @@ namespace Azyobuzi.Twirunrun
3648 }
3749 }
3850
39- private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
51+ private void textBox1_KeyPress(object sender, KeyPressEventArgs e)//読みにくくて辛い
4052 {
4153 if (e.KeyChar == (char)Keys.Back)
4254 {
4355 if (textBox1.SelectionStart > 0 && "@@##".Contains(textBox1.Text[textBox1.SelectionStart - 1]))
56+ {
4457 splitContainer1.Panel2Collapsed = true;
45- else
46- return;
58+ }
59+ return;
4760 }
48- else if (e.KeyChar == (char)Keys.Delete)
61+ else if (e.KeyChar == (char)Keys.Escape)
4962 {
50- if (textBox1.SelectionStart != textBox1.TextLength && "@@##".Contains(textBox1.Text[textBox1.SelectionStart]))
51- splitContainer1.Panel2Collapsed = true;
52- else
53- return;
63+ splitContainer1.Panel2Collapsed = true;
64+ return;
65+ }
66+ else if (e.KeyChar == (char)Keys.Enter)
67+ {
68+ splitContainer1.Panel2Collapsed = true;
69+ if ((Control.ModifierKeys & Keys.Shift) != Keys.Shift && listBox1.SelectedIndex != -1)
70+ {
71+ int atHashtagStart = textBox1.Text.LastIndexOfAny("@@##".ToArray(), textBox1.SelectionStart - 1);
72+ var selected = listBox1.SelectedItem.ToString();
73+ textBox1.Text = textBox1.Text.Substring(0, atHashtagStart) + selected + textBox1.Text.Substring(textBox1.SelectionStart);
74+ textBox1.SelectionStart = atHashtagStart + selected.Length;
75+ e.Handled = true;
76+ }
77+ return;
5478 }
5579
5680 if ("@@##".Contains(e.KeyChar))
57- splitContainer1.Panel2Collapsed = false;
58- else if (!"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWSYZ_-0123456789".Contains(e.KeyChar))
81+ {
82+ if (Settings.Instance.AutoComplete)
83+ splitContainer1.Panel2Collapsed = false;
84+ return;
85+ }
86+
87+ if (!"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWSYZ_-0123456789".Contains(e.KeyChar))
5988 splitContainer1.Panel2Collapsed = true;
6089 }
6190
@@ -76,11 +105,26 @@ namespace Azyobuzi.Twirunrun
76105 {
77106 if (!splitContainer1.Panel2Collapsed)
78107 {
79- if (e.KeyCode == Keys.Down && listBox1.SelectedIndex != listBox1.Items.Count - 1)
108+ if (e.KeyCode == Keys.Down)
80109 listBox1.SelectedIndex++;
81- else if (e.KeyCode == Keys.Up && listBox1.SelectedIndex > -1)
110+ else if (e.KeyCode == Keys.Up)
82111 listBox1.SelectedIndex--;
83112 }
84113 }
114+
115+ private void textBox1_TextChanged(object sender, EventArgs e)
116+ {
117+ if (!splitContainer1.Panel2Collapsed)
118+ {
119+ int atHashtagStart = textBox1.Text.LastIndexOfAny("@@##".ToArray(), textBox1.SelectionStart - 1);
120+ listBox1.SelectedItem = Settings.Instance.AtHashtagList
121+ .FirstOrDefault(_ =>
122+ _.StartsWith(
123+ textBox1.Text.Substring(atHashtagStart, textBox1.SelectionStart - atHashtagStart)
124+ )
125+ )
126+ ?? listBox1.SelectedItem;
127+ }
128+ }
85129 }
86130 }
--- "a/\202\302\202\242\202\351\202\361\202\351\202\361/Extensions.cs"
+++ "b/\202\302\202\242\202\351\202\361\202\351\202\361/Extensions.cs"
@@ -72,20 +72,16 @@ namespace Azyobuzi.Twirunrun
7272 #endregion
7373
7474 #region OrderByの拡張
75- public static OrderedParallelQuery<TSource> OrderBy<TSource, TKey>(this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, OrderTypes orderType)
75+ public static ParallelQuery<TSource> OrderBy<TSource, TKey>(this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, SortOrder orderType)
7676 {
77- var re = (OrderedParallelQuery<TSource>)orderType.SelectCase()
78- .Case(OrderTypes.Ascending, () => source.OrderBy(keySelector))
79- .Case(OrderTypes.Descending, () => source.OrderByDescending(keySelector))
80- .Result;
81-
82- if (re == null)
83- throw new ArgumentException("orderTypeが正しくありません。");
84-
85- return re;
77+ return orderType.SelectCase()
78+ .Case(SortOrder.Ascending, () => source.OrderBy(keySelector))
79+ .Case(SortOrder.Descending, () => source.OrderByDescending(keySelector))
80+ .Default(() => source)
81+ .Result as ParallelQuery<TSource>;
8682 }
8783
88- public static OrderedParallelQuery<T> OrderBy<T>(this ParallelQuery<T> source, OrderTypes orderType)
84+ public static ParallelQuery<T> OrderBy<T>(this ParallelQuery<T> source, SortOrder orderType)
8985 {
9086 return OrderBy(source, o => o, orderType);
9187 }
@@ -308,51 +304,6 @@ namespace Azyobuzi.Twirunrun
308304 }
309305 }
310306
311- //public class StringRegex
312- //{
313- // public StringRegex(string source)
314- // {
315- // this._source = source;
316- // }
317-
318- // private string _source;
319-
320- // public bool IsMatch(string pattern)
321- // {
322- // return Regex.IsMatch(_source, pattern);
323- // }
324-
325- // public Match Match(string pattern)
326- // {
327- // return Regex.Match(_source, pattern);
328- // }
329-
330- // public IEnumerable<Match> Matches(string pattern)
331- // {
332- // return Regex.Matches(_source, pattern).Cast<Match>();
333- // }
334-
335- // public string Replace(string pattern, string replacement)
336- // {
337- // return Regex.Replace(_source, pattern, replacement);
338- // }
339-
340- // public string Replace(string pattern, MatchEvaluator evaluator)
341- // {
342- // return Regex.Replace(_source, pattern, evaluator);
343- // }
344-
345- // public string[] Split(string pattern)
346- // {
347- // return Regex.Split(_source, pattern);
348- // }
349-
350- // public override string ToString()
351- // {
352- // return _source;
353- // }
354- //}
355-
356307 public class Selecting<T>
357308 {
358309 public Selecting(T selectObj, Func<T, T, bool> equalsFunc)
@@ -389,15 +340,21 @@ namespace Azyobuzi.Twirunrun
389340
390341 public Selecting<T> Default(Action<T> action)
391342 {
392- flag = true;
393- action(selectObj);
343+ if (!flag)
344+ {
345+ flag = true;
346+ action(selectObj);
347+ }
394348 return this;
395349 }
396350
397351 public Selecting<T> Default(Action action)
398352 {
399- flag = true;
400- action();
353+ if (!flag)
354+ {
355+ flag = true;
356+ action();
357+ }
401358 return this;
402359 }
403360
@@ -423,15 +380,21 @@ namespace Azyobuzi.Twirunrun
423380
424381 public Selecting<T> Default(Func<T, object> action)
425382 {
426- flag = true;
427- Result = action(selectObj);
383+ if (!flag)
384+ {
385+ flag = true;
386+ Result = action(selectObj);
387+ }
428388 return this;
429389 }
430390
431391 public Selecting<T> Default(Func<object> action)
432392 {
433- flag = true;
434- Result = action();
393+ if (!flag)
394+ {
395+ flag = true;
396+ Result = action();
397+ }
435398 return this;
436399 }
437400 }
--- "a/\202\302\202\242\202\351\202\361\202\351\202\361/Forms/MainForm.cs"
+++ "b/\202\302\202\242\202\351\202\361\202\351\202\361/Forms/MainForm.cs"
@@ -12,6 +12,7 @@ using System.Threading.Tasks;
1212 using System.Net;
1313 using System.Reflection;
1414 using Azyobuzi.UserStreamEx;
15+using System.Text.RegularExpressions;
1516
1617 namespace Azyobuzi.Twirunrun
1718 {
@@ -146,10 +147,38 @@ namespace Azyobuzi.Twirunrun
146147 #endregion
147148 timelineTabs.TabPages.AddRange(Settings.Instance.Tabs.Select(tab => tab.CreateTabPage(timelineTabs)).ToArray());
148149
150+ RecentStatusesCollection.Instance.CollectionChanged += (_sender, _e) =>
151+ {
152+ var newAtHashtagList = Settings.Instance.AtHashtagList.Concat(
153+ _e.NewItems.Cast<StatusInfo>().SelectMany(_ =>
154+ new[] { "@" + _.User.Identifier.ScreenName }
155+ .Concat(_.Text.RegexMatches(@"[@@][a-zA-Z0-9_]+")
156+ .Cast<Match>()
157+ .Select(atMatch => atMatch.ToString())
158+ .Concat(_.Text.RegexMatches(@"(^|[^\w&])([##][a-zA-Z0-9_\-]+)")
159+ .Cast<Match>()
160+ .Select(hashtagMatch => hashtagMatch.Groups[2].ToString())
161+ )
162+ )
163+ )
164+ )
165+ .Select(_ =>
166+ {
167+ if (_.FirstOrDefault() == '@')
168+ return "@" + _.Substring(1);
169+ else if (_.FirstOrDefault() == '#')
170+ return "#" + _.Substring(1);
171+ else
172+ return _;
173+ })
174+ .Distinct()
175+ .ToArray();
176+ Array.Sort(newAtHashtagList);
177+ Settings.Instance.AtHashtagList = newAtHashtagList;
178+ };
179+
149180 Settings.Instance.PropertyChanged += Settings_PropertyChanged;
150- //全設定項目でSettings_PropertyChangedを呼び出す
151- typeof(Settings).GetProperties().ForEach(property =>
152- Settings_PropertyChanged(Settings.Instance, new PropertyChangedEventArgs(property.Name)));
181+ Settings.Instance.RaiseAllEvents();
153182
154183 statusBrowser1.Navigate(statusBrowserUri);
155184 }
--- "a/\202\302\202\242\202\351\202\361\202\351\202\361/Settings/Settings.cs"
+++ "b/\202\302\202\242\202\351\202\361\202\351\202\361/Settings/Settings.cs"
@@ -1,8 +1,8 @@
11 using System;
22 using System.Collections.Generic;
33 using System.Drawing;
4-using System.Windows.Forms;
54 using System.Linq;
5+using System.Windows.Forms;
66 using System.Xml.Serialization;
77
88 namespace Azyobuzi.Twirunrun
@@ -513,8 +513,8 @@ namespace Azyobuzi.Twirunrun
513513 //
514514 //並べ替え順
515515 //
516- private OrderTypes orderType = OrderTypes.Descending;
517- public OrderTypes OrderType
516+ private SortOrder orderType = SortOrder.Descending;
517+ public SortOrder OrderType
518518 {
519519 set
520520 {
@@ -773,17 +773,17 @@ namespace Azyobuzi.Twirunrun
773773
774774
775775 //
776- //@・#の履歴
776+ //@・#補完
777777 //
778- private List<string> atHashtagList = new List<string>();
779- public List<string> AtHashtagList
778+ private string[] atHashtagList = new string[] { };
779+ public string[] AtHashtagList
780780 {
781781 set
782782 {
783783 if (!atHashtagList.SequenceEqual(value))
784784 {
785785 atHashtagList = value;
786- OnPropertyChanged("AtHashtagList");//あんまり意味無い
786+ OnPropertyChanged("AtHashtagList");
787787 }
788788 }
789789 get
@@ -791,6 +791,23 @@ namespace Azyobuzi.Twirunrun
791791 return atHashtagList;
792792 }
793793 }
794+
795+ private bool autoComplete = true;
796+ public bool AutoComplete
797+ {
798+ set
799+ {
800+ if (autoComplete != value)
801+ {
802+ autoComplete = value;
803+ OnPropertyChanged("AutoComplete");
804+ }
805+ }
806+ get
807+ {
808+ return autoComplete;
809+ }
810+ }
794811 }
795812
796813 public class FormSettings : IEquatable<FormSettings>
@@ -822,20 +839,7 @@ namespace Azyobuzi.Twirunrun
822839 public enum PostKeys
823840 {
824841 Enter,
825- CtrlEnter,
826- ShiftEnter
827- }
828-
829- public enum OrderTypes
830- {
831- /// <summary>
832- /// 昇順
833- /// </summary>
834- Ascending,
835- /// <summary>
836- /// 降順
837- /// </summary>
838- Descending
842+ CtrlEnter
839843 }
840844
841845 public enum NameTypes
--- "a/\202\302\202\242\202\351\202\361\202\351\202\361/Settings/SettingsBase.cs"
+++ "b/\202\302\202\242\202\351\202\361\202\351\202\361/Settings/SettingsBase.cs"
@@ -1,5 +1,6 @@
11 using System.ComponentModel;
22 using System.IO;
3+using System.Linq;
34 using System.Windows.Forms;
45 using System.Xml.Serialization;
56
@@ -61,5 +62,15 @@ namespace Azyobuzi.Twirunrun
6162 if (PropertyChanged != null)
6263 PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
6364 }
65+
66+ /// <summary>
67+ /// このクラスのすべてのプロパティ名を使用してPropertyChangedイベントを発生させる
68+ /// </summary>
69+ public void RaiseAllEvents()
70+ {
71+ this.GetType().GetProperties()
72+ .Select(property => property.Name)
73+ .ForEach(OnPropertyChanged);
74+ }
6475 }
6576 }