Exemple #1
0
        public static bool IsInReplyToMeCurrentStrict(TweetViewModel status, TabProperty property)
        {
            if (status == null || !status.IsStatusInfoContains || property == null)
            {
                return(false);
            }
            var s = status.Status as TwitterStatus;

            if (s != null)
            {
                return(property.LinkAccountScreenNames.Any(a => a == s.InReplyToUserScreenName));
            }
            else
            {
                var dm = status.Status as TwitterDirectMessage;
                if (dm != null)
                {
                    return(property.LinkAccountScreenNames.Any(a => a == dm.Recipient.ScreenName));
                }
                else
                {
                    return(false);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// タブをこのカラムの末尾に追加します。
        /// </summary>
        public TabViewModel AddTab(TabProperty tabProperty = null)
        {
            var nvm = new TabViewModel(this, tabProperty);

            this.AddTab(nvm);
            return(nvm);
        }
Exemple #3
0
 public static bool IsMyCurrentTweet(TweetViewModel status, TabProperty property)
 {
     if (status == null || !status.IsStatusInfoContains || property == null)
     {
         return(false);
     }
     return(property.LinkAccountScreenNames.Any(a => a == status.Status.User.ScreenName));
 }
Exemple #4
0
 public static bool IsFollowerCurrent(UserViewModel user, TabProperty property)
 {
     if (user == null || property == null)
     {
         return(false);
     }
     return(property.LinkAccountInfos.All(i => i.IsFollowedBy(user.TwitterUser.NumericId)));
 }
Exemple #5
0
 public static bool IsInReplyToMeCurrent(TweetViewModel status, TabProperty property)
 {
     if (status == null || !status.IsStatusInfoContains || property == null)
     {
         return(false);
     }
     return(property.LinkAccountScreenNames.Any(a =>
                                                Regex.IsMatch(status.Status.Text, "@" + a + "(?![a-zA-Z0-9_])", RegexOptions.Singleline | RegexOptions.IgnoreCase)));
 }
Exemple #6
0
        public static bool IsFavoredThisWithCurrent(TweetViewModel status, TabProperty property)
        {
            if (status == null || !status.IsStatusInfoContains || property == null)
            {
                return(false);
            }
            var fvd = status.FavoredUsers.Select(d => d.TwitterUser.ScreenName).ToArray();

            return(property.LinkAccountScreenNames.Any(a => fvd.Contains(a)));
        }
Exemple #7
0
        public TabViewModel(ColumnViewModel parent, TabProperty property = null)
        {
            this.Parent = parent;

            this.IsAlive     = true;
            this.TabProperty = property ?? new TabProperty();

            // 初期TLとしてnullを
            this.AddTopTimeline(null);
            ViewModelHelper.BindNotification(Setting.SettingValueChangedEvent, this, (o, e) => UpdateSettingValue());
        }
Exemple #8
0
        private TabProperty ShowTabEditor(TabProperty property = null)
        {
            if (property == null)
            {
                property = new TabProperty();
            }
            var vm = new TabEditorViewModel(property);

            this.Messenger.Raise(new TransitionMessage(vm, "EditTab"));
            property.TweetSources = vm.FilterEditorViewModel.RootFilters;
            return(property);
        }
Exemple #9
0
        private void tab_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            TabItem     tab = sender as TabItem;
            TabProperty dlg = new TabProperty();

            dlg.txtTitle.Text = tab.Header.ToString();
            if (dlg.ShowDialog() == true)
            {
                // change header text
                tab.Header = dlg.txtTitle.Text.Trim();
            }
        }
 private void CreateTab(TabProperty property)
 {
     KernelService.MainWindowViewModel.ColumnOwnerViewModel.CurrentFocusColumn.AddTab(property);
 }
Exemple #11
0
        public void DoIt()
        {
            try
            {
                StreamWriter sw;
                string       fileName        = Path.GetDirectoryName(project.FileName) + "\\" + className + ".cs";
                string       partialFileName = fileName.Substring(0, fileName.Length - 3);
                partialFileName += ".ndo.cs";
                string namespc = (string)project.Properties.Item("RootNamespace").Value;
                using (sw = new StreamWriter(fileName, false, System.Text.Encoding.UTF8))
                {
                    StringBuilder sb = new StringBuilder();

                    sb.Append("using System;\n");
                    sb.Append("using System.Linq;\n");
                    sb.Append("using System.Collections.Generic;\n");
                    sb.Append("using NDO;\n\n");
                    sb.Append("namespace " + namespc + "\n");
                    sb.Append("{\n");

                    sb.Append("\t/// <summary>\n");
                    sb.Append("\t/// Summary for " + className + "\n");
                    sb.Append("\t/// </summary>\n");
                    sb.Append("\t[NDOPersistent");
                    if (this.isSerializable)
                    {
                        sb.Append(", Serializable");
                    }
                    sb.Append("]\n");
                    sb.Append("\tpublic partial class " + className + "\n");
                    sb.Append("\t{\n");
                    sb.Append("\t\tpublic " + className + "()\n");
                    sb.Append("\t\t{\n");
                    sb.Append("\t\t}\n");
                    sb.Append("\t}\n");
                    sb.Append("}\n");
                    string      result = sb.ToString();
                    TabProperty tp     = TabProperties.Instance.CSharp;
                    if (tp.UseSpaces)
                    {
                        sw.Write(result.Replace("\t", tp.Indent));
                    }
                    else
                    {
                        sw.Write(result);
                    }
                }
                ProjectItem pi = null;
                if (parentItem == null)
                {
                    pi = project.ProjectItems.AddFromFile(fileName);
                }
                else
                {
                    pi = parentItem.ProjectItems.AddFromFile(fileName);
                }

                using (sw = new StreamWriter(partialFileName))
                {
                    string newPartial = partialTemplate.Replace("#ns#", namespc);
                    newPartial = newPartial.Replace("#cl#", className);
                    sw.Write(newPartial);
                }

                pi.ProjectItems.AddFromFile(partialFileName);
                CodeGenHelper.ActivateAndGetTextDocument(project, Path.GetFileName(fileName));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #12
0
        public void DoIt()
        {
            bool genChangeEvent = false;

            try
            {
                string result;
                int    textLine = textDoc.Selection.TopLine;
                if (textLine != textDoc.Selection.BottomLine)
                {
                    return;
                }
                textDoc.Selection.SelectLine();
                string original = textDoc.Selection.Text;
                Regex  regex    = new Regex(@"<[^\>]+\>");
                Match  match    = regex.Match(original);
                string attrtext;
                if (match.Success)
                {
                    attrtext = match.Value;
                }
                else
                {
                    textDoc.Selection.LineUp(false, 1);
                    textDoc.Selection.SelectLine();
                    match    = regex.Match(textDoc.Selection.Text);
                    attrtext = match.Value;
                }
                bool hasAttribute = match.Success;
                textDoc.Selection.CharRight(false, 1);
                textDoc.Selection.LineDown(false, 1);

//				int i = 0;
//				string bl = string.Empty;
//				while (char.IsWhiteSpace(original[i]))
//					bl += original[i++];
                TabProperty tp = TabProperties.Instance.VBasic;
                string      bl = tp.Indent;

                string selLine = original.Trim();
                regex = new Regex(@"(Dim|Private)\s([^\s]+)\sAs\s(New\s|)([^\s^(]+)(\s*|)(\(Of\s*([^\s]+)\)|)", RegexOptions.IgnoreCase);
                match = regex.Match(selLine);
                if (!match.Success)
                {
                    MessageBox.Show("Please select a private member variable declaration");
                    return;
                }
                string typeStr = match.Groups[4].Value;
                string bigname;
                string name                = match.Groups[2].Value;
                string genericParameter    = match.Groups[6].Value;
                string genericArgumentType = match.Groups[7].Value;

                bool hasPrefix = false;

                if (name.StartsWith("_"))
                {
                    bigname   = name.Substring(1);
                    hasPrefix = true;
                }
                else if (name.StartsWith("m_"))
                {
                    bigname   = name.Substring(2);
                    hasPrefix = true;
                }
                else
                {
                    bigname = name;
                }

                if (!hasPrefix)
                {
                    bigname = "P" + bigname;
                }
                else
                {
                    bigname = bigname.Substring(0, 1).ToUpper() + bigname.Substring(1);
                }

                bool isContainer = (typeStr == "IList" || typeStr == "List" || typeStr == "ArrayList" || typeStr == "NDOArrayList" || typeStr == "NDOGenericList");
                isContainer = hasAttribute && isContainer;

                bool isGenericList = genericParameter != string.Empty && genericArgumentType != string.Empty;
                if (isGenericList)
                {
                    typeStr += genericParameter;
                }

                if (isContainer)
                {
                    attrtext = attrtext.Trim();
                    string elementTyp = null;
                    if (!isGenericList)
                    {
                        elementTyp = GetElementTyp(attrtext);
                    }
                    else
                    {
                        elementTyp = genericArgumentType;
                    }
                    string relationName = GetRelationName(attrtext);

                    if (relationName == null)
                    {
                        int p = elementTyp.LastIndexOf(".");
                        relationName = elementTyp.Substring(p + 1);
                    }

                    bool   isComposite = (attrtext.IndexOf("RelationInfo.Composite") > -1);
                    string parameter   = elementTyp.Substring(0, 1).ToLower();
                    result = string.Empty;
                    if (isComposite)
                    {
                        result += bl + "Public Function New" + relationName + "() As " + elementTyp + "\n";
                        result += bl + "\tDim " + parameter + " As " + elementTyp + " = New " + elementTyp + "\n";
                        result += bl + "\t" + name + ".Add(" + parameter + ")\n";
                        result += bl + "\t" + "return " + parameter + "\n";
                        result += bl + "End Function\n";
                    }
                    else
                    {
                        result += bl + "Public Sub Add" + relationName + "(" + parameter + " As " + elementTyp + ")\n";
                        result += bl + "\t" + name + ".Add(" + parameter + ")\n";
                        result += bl + "End Sub\n";
                    }
                    result += bl + "Public Sub Remove" + relationName + "(" + parameter + " As " + elementTyp + ")\n";
                    result += bl + "\tIf " + name + ".Contains(" + parameter + ") Then\n";
                    result += bl + "\t\t" + name + ".Remove(" + parameter + ")\n";
                    result += bl + "\tEnd If\n";
                    result += bl + "End Sub\n";
                    textDoc.Selection.Insert(result, (int)vsInsertFlags.vsInsertFlagsInsertAtStart);
                }
                else                 // wir haben es mit einer Elementbeziehung bzw. einem Feld zu tun
                {
                    ConfigurationOptions options = new ConfigurationOptions(document.ProjectItem.ContainingProject);
                    if (options.GenerateChangeEvents)
                    {
                        genChangeEvent = true;
                        result         = bl + "Public Event " + bigname + "Changed As EventHandler\n";
                        textDoc.Selection.Insert(result, (int)vsInsertFlags.vsInsertFlagsInsertAtStart);
                    }
                }

                string ilistType = isGenericList ? "IEnumerable " + genericParameter : "IEnumerable";

                result = string.Empty;
                if (isContainer)
                {
                    result += bl + "Public Property " + bigname + "() As " + ilistType + "\n";
                }
                else
                {
                    result += bl + "Public Property " + bigname + "() As " + typeStr + "\n";
                }
                result += bl + "\tGet\n";
                result += bl + "\t\tReturn " + name + "\n";
                result += bl + "\tEnd Get\n";
                if (isContainer)
                {
                    result += bl + "\tSet(ByVal Value As " + ilistType + ")\n";
                }
                else
                {
                    result += bl + "\tSet(ByVal Value As " + typeStr + ")\n";
                }
                if (isContainer)
                {
                    if (!isGenericList)
                    {
                        result += bl + "\t\t" + name + " = New ArrayList(CType(Value, ICollection))\n";
                    }
                    else
                    {
                        result += bl + "\t\t" + name + " = Value.ToList()\n";
                    }
                }
                else
                {
                    result += bl + "\t\t" + name + " = Value\n";
                }
                if (genChangeEvent)
                {
                    result += bl + "\t\tRaiseEvent " + bigname + "Changed(Me, EventArgs.Empty)\n";
                }
                result += bl + "\tEnd Set\n";
                result += bl + "End Property\n";
                textDoc.Selection.Insert(result, (int)vsInsertFlags.vsInsertFlagsInsertAtStart);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Add Accessor Add-in");
            }
        }
Exemple #13
0
 public TabEditorViewModel(TabProperty property)
 {
     this.property = property;
     this._filterEditorViewModel = new FilterEditorViewModel(property.TweetSources.ToArray());
 }
Exemple #14
0
        public void DoIt()
        {
            bool genChangeEvent = false;

            try
            {
                string result;
                int    textLine = textDoc.Selection.TopLine;
                if (textLine != textDoc.Selection.BottomLine)
                {
                    return;
                }
                textDoc.Selection.SelectLine();
                string original = textDoc.Selection.Text;
                textDoc.Selection.LineUp(false, 1);
                textDoc.Selection.SelectLine();
                string attrtext = textDoc.Selection.Text;
                textDoc.Selection.CharRight(false, 1);
                textDoc.Selection.LineDown(false, 1);

                int    i  = 0;
                string bl = string.Empty;
                while (char.IsWhiteSpace(original[i]))
                {
                    bl += original[i++];
                }
                string selLine = original.Trim();
                Regex  regex   = new Regex(@"(private[\s]*|)([^\s]+(\s*<[^\s]+|))\s+([^\s^;^=]+)\s*(=|;)");
                Match  match   = regex.Match(selLine);
                if (!match.Success)
                {
                    MessageBox.Show("Please select a private member variable declaration");
                    return;
                }
                string typeStr = match.Groups[2].Value;
                string bigname;
                string name = match.Groups[4].Value;
                if (name.StartsWith("_"))
                {
                    bigname = name.Substring(1);
                }
                else if (name.StartsWith("m_"))
                {
                    bigname = name.Substring(2);
                }
                else
                {
                    bigname = name;
                }
                bigname = bigname.Substring(0, 1).ToUpper() + bigname.Substring(1);

                string genericTypeStr      = string.Empty;
                string genericArgumentType = string.Empty;
                string genericParameter    = string.Empty;
                regex = new Regex(@"([^\s]+)\s*<([^>]+)>");
                match = regex.Match(typeStr);
                if (match.Success)
                {
                    genericTypeStr      = match.Groups[1].Value;
                    genericArgumentType = match.Groups[2].Value;
                    genericParameter    = "<" + genericArgumentType + '>';
                }

                bool isContainer = (typeStr == "IList" || typeStr == "ArrayList");
                if (genericTypeStr != string.Empty)
                {
                    isContainer = isContainer || (genericTypeStr == "IList" || genericTypeStr == "List");
                }

                bool isGenericList = genericTypeStr != string.Empty && isContainer;

//				bool isIList = (typeStr == "IList" || genericTypeStr == "IList");

                if (isContainer)
                {
                    attrtext = attrtext.Trim();
                    string elementTyp = null;
                    if (!isGenericList)
                    {
                        elementTyp = GetElementTyp(attrtext);
                    }
                    else
                    {
                        elementTyp = genericArgumentType;
                    }

                    string relationName = GetRelationName(attrtext);

                    if (elementTyp == null)
                    {
                        isContainer = false;
                    }
                    else
                    {
                        if (relationName == null)
                        {
                            int p = elementTyp.LastIndexOf(".");
                            relationName = elementTyp.Substring(p + 1);
                        }

                        bool   isComposite = (attrtext.IndexOf("RelationInfo.Composite") > -1);
                        string parameter   = elementTyp.Substring(0, 1).ToLower();
                        result = string.Empty;
                        if (isComposite)
                        {
                            result += bl + "public " + elementTyp + " New" + relationName + "()\n";
                            result += bl + "{\n";
                            result += bl + "\t" + elementTyp + " " + parameter + " = new " + elementTyp + "();\n";
                            result += bl + "\tthis." + name + ".Add(" + parameter + ");\n";
                            result += bl + "\t" + "return " + parameter + ";\n";
                            result += bl + "}\n";
                        }
                        else
                        {
                            result += bl + "public void Add" + relationName + "(" + elementTyp + " " + parameter + ")\n";
                            result += bl + "{\n";
                            result += bl + "\tthis." + name + ".Add(" + parameter + ");\n";
                            result += bl + "}\n";
                        }
                        result += bl + "public void Remove" + relationName + "(" + elementTyp + " " + parameter + ")\n";
                        result += bl + "{\n";
                        result += bl + "\tif (this." + name + ".Contains(" + parameter + "))\n";
                        result += bl + "\t\tthis." + name + ".Remove(" + parameter + ");\n";
                        result += bl + "}\n";
                        textDoc.Selection.Insert(result, (int)vsInsertFlags.vsInsertFlagsInsertAtStart);
                    }
                }
                if (!isContainer)                 // isContainer may change in the if case, so we test it again
                {
                    ConfigurationOptions options = new ConfigurationOptions(document.ProjectItem.ContainingProject);
                    if (options.GenerateChangeEvents)
                    {
                        genChangeEvent = true;
                        result         = bl + "public event EventHandler " + bigname + "Changed;\n";
                        textDoc.Selection.Insert(result, (int)vsInsertFlags.vsInsertFlagsInsertAtStart);
                    }
                }

                result = string.Empty;

                string ilistType = null;
                if (isGenericList)
                {
                    ilistType = "IEnumerable" + genericParameter;
                }
                else
                {
                    ilistType = "IEnumerable";
                }

                if (isContainer)
                {
                    result += bl + "public " + ilistType + " " + bigname + '\n';
                }
                else
                {
                    result += bl + "public " + typeStr + " " + bigname + '\n';
                }
                result += bl + "{\n";

                result += bl + "\tget => this." + name + "; \n";

                if (genChangeEvent)                  // Set Accessor in mehreren Zeilen
                {
                    result += bl + "\tset\n";
                    result += bl + "\t{\n";
                    if (isContainer)
                    {
                        if (!isGenericList)
                        {
                            result += bl + "\t\tthis." + name + " = new ArrayList( (ICollection)value );\n";
                        }
                        else
                        {
                            result += bl + "\t\tthis." + name + " = value.ToList();\n";
                        }
                    }
                    else
                    {
                        result += bl + "\t\tthis." + name + " = value;\n";
                    }
                    result += bl + "\t\tif (" + bigname + "Changed != null)\n";
                    result += bl + "\t\t\t" + bigname + "Changed(this, EventArgs.Empty);\n";
                    result += bl + "\t}\n";
                }
                else                  // Accessor in einer Zeile
                {
                    if (isContainer)
                    {
                        if (!isGenericList)
                        {
                            result += bl + "\tset => this." + name + " = new ArrayList( (ICollection)value );\n";
                        }
                        else
                        {
                            result += bl + "\tset => this." + name + " = value.ToList();\n";
                        }
                    }
                    else
                    {
                        result += bl + "\tset => this." + name + " = value;\n";
                    }
                }

                result += bl + "}\n";
                TabProperty tp = TabProperties.Instance.CSharp;
                if (tp.UseSpaces)
                {
                    result = result.Replace("\t", tp.Indent);
                }
                textDoc.Selection.Insert(result, (int)vsInsertFlags.vsInsertFlagsInsertAtStart);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Add Accessor Add-in");
            }
        }