Esempio n. 1
0
        public int GetPrevLength()
        {
            ITextItem previtem = item;
            int       count    = 0;

            if (previtem is ITextTrim)
            {
                string leftpart = LeftPart;
                int    enterid  = leftpart.LastIndexOf('\n');
                if (enterid >= 0)
                {
                    return(leftpart.Length - enterid - 1);
                }
            }
            count += itemindex;
            while (previtem?.Parent != null)
            {
                ITextZone zone = previtem.Parent;
                if (GetPrevLength(zone, previtem.ID - 1, ref count))
                {
                    return(count);
                }
                previtem = previtem.Parent;
            }
            return(count);
        }
Esempio n. 2
0
        public ITextPosition NextSeek()
        {
            if (itemindex < item.ToString().Length)
            {
                return(Clone());
            }
            ITextItem nextitem = item;

            while (nextitem?.Parent != null && nextitem.ID + 1 >= nextitem.Parent.Items.Count)
            {
                nextitem = nextitem.Parent;
            }
            if (nextitem?.Parent == null)
            {
                return(Clone());
            }
            nextitem = nextitem.Parent.Items[nextitem.ID + 1];
            while (nextitem is ITextZone)
            {
                ITextZone zone = (ITextZone)(nextitem);
                nextitem = zone.Items.FirstOrDefault();
            }
            return(new TextPosition()
            {
                Item = nextitem, ItemIndex = 0, Line = this.line, Column = this.column
            });
        }
Esempio n. 3
0
        public ITextPosition PrevSeek()
        {
            if (itemindex > 0)
            {
                return(Clone());
            }
            ITextItem previtem = item;

            while (previtem?.Parent != null && previtem.ID <= 0)
            {
                previtem = previtem.Parent;
            }
            if (previtem?.Parent == null)
            {
                return(Clone());
            }
            previtem = previtem.Parent.Items[previtem.ID - 1];
            while (previtem is ITextZone)
            {
                ITextZone zone = (ITextZone)(previtem);
                previtem = zone.Items.LastOrDefault();
            }
            return(new TextPosition()
            {
                Item = previtem, ItemIndex = previtem.ToString().Length, Line = this.line, Column = this.column
            });
        }
Esempio n. 4
0
		public virtual void Deserialize(XmlNode node)
		{
			foreach (XmlNode childNode in node.ChildNodes)
			{
				DateTime tempDate;
				switch (childNode.Name)
				{
					case "StartDay":
						if (DateTime.TryParse(childNode.InnerText, out tempDate))
							StartDay = tempDate;
						break;
					case "FinishDay":
						if (DateTime.TryParse(childNode.InnerText, out tempDate))
							FinishDay = tempDate;
						break;
					case "BackgroundColor":
						int tempInt;
						if (Int32.TryParse(childNode.InnerText, out tempInt))
							_backgroundColor = Color.FromArgb(tempInt);
						break;
					case "TextItem":
						{
							_note = new TextItem();
							_note.Deserialize(childNode);
						}
						break;
					case "TextGroup":
						{
							_note = new TextGroup();
							_note.Deserialize(childNode);
						}
						break;
				}
			}
		}
Esempio n. 5
0
        public int GetNextLength()
        {
            ITextItem nextitem = item;
            int       count    = 0;

            if (nextitem is ITextTrim)
            {
                string rightpart = RightPart;
                int    enterid   = rightpart.IndexOf('\n');
                if (enterid >= 0)
                {
                    return(enterid);
                }
            }
            count += item.ToString().Length - itemindex;
            while (nextitem?.Parent != null)
            {
                ITextZone zone = nextitem.Parent;
                if (GetNextLength(zone, nextitem.ID + 1, ref count))
                {
                    return(count);
                }
                nextitem = nextitem.Parent;
            }
            return(count);
        }
Esempio n. 6
0
        /// <summary>
        /// Creates and returns the new folder as an IFileItem.
        /// </summary>
        /// <param name="items">
        /// A <see cref="IEnumerable"/>
        /// </param>
        /// <param name="modItems">
        /// A <see cref="IEnumerable"/>
        /// </param>
        /// <returns>
        /// A <see cref="IEnumerable"/>
        /// </returns>
        protected override IEnumerable <Item> Perform(Item source, Item destination)
        {
            IFileItem parent   = null;
            ITextItem fileName = null;

            if (source is IFileItem)
            {
                parent = source as IFileItem;
                // We provide a default folder name if none is provided.
                fileName = destination as ITextItem ??
                           Plugin.NewTextItem(GetNewFileName(parent.Path));
            }
            else if (source is ITextItem)
            {
                fileName = source as ITextItem;
                // We provide a default parent folder if none is provided.
                parent = destination as IFileItem ??
                         Plugin.NewFileItem(Plugin.ImportantFolders.Desktop);
            }

            string path = Path.Combine(parent.Path, fileName.Text);

            CreateFile(path);
            yield return(Plugin.NewFileItem(path) as Item);
        }
Esempio n. 7
0
        public int GetByteSpaceCount()
        {
            ITextItem previtem = item;
            int       count    = 0;

            if (previtem is ITextTrim)
            {
                string leftpart = LeftPart;
                int    enterid  = leftpart.LastIndexOf('\n');
                if (enterid >= 0)
                {
                    for (int i = enterid + 1; i < leftpart.Length; i++)
                    {
                        count += TextChar.GetByteSpaceCount(leftpart[i]);
                    }
                    return(count);
                }
            }
            foreach (char ch in LeftPart)
            {
                count += TextChar.GetByteSpaceCount(ch);
            }
            while (previtem?.Parent != null)
            {
                ITextZone zone = previtem.Parent;
                if (GetByteSpaceCount(zone, previtem.ID - 1, ref count))
                {
                    return(count);
                }
                previtem = previtem.Parent;
            }
            return(count);
        }
Esempio n. 8
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems)
        {
            GConf.Client client = new GConf.Client();

            string exec;

            try {
                exec = client.Get("/desktop/gnome/applications/terminal/exec") as string;
            }
            catch {
                exec = "gnome-terminal";
            }

            string hostname;

            if (items.First() is ITextItem)
            {
                ITextItem textitem = items.First() as ITextItem;
                hostname = textitem.Text;
            }
            else
            {
                SSHHostItem hostitem = items.First() as SSHHostItem;
                hostname = hostitem.Host;
            }

            Process term = new Process();

            term.StartInfo.FileName  = exec;
            term.StartInfo.Arguments = "-e 'ssh " + hostname + "'";
            term.Start();
            yield break;
        }
Esempio n. 9
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems)
        {
            Item item = items.First();

            using (Process zim = new Process()) {
                zim.StartInfo.FileName = "zim";

                if (item is ITextItem)
                {
                    ITextItem textitem = item as ITextItem;
                    string    args     = textitem.Text;
                    if (!args.Contains(" :"))
                    {
                        args = "_default_ " + args;
                    }

                    zim.StartInfo.Arguments = args;
                }
                else
                {
                    ZimPage page = item as ZimPage;
                    zim.StartInfo.Arguments = page.Notebook + " " + page.Name;
                }
                zim.Start();
            }
            yield break;
        }
Esempio n. 10
0
        public ITextPosition NextLine()
        {
            ITextItem nextitem = item;

            if (nextitem is ITextTrim)
            {
                string rightpart = RightPart;
                int    enterid   = rightpart.IndexOf('\n');
                if (enterid >= 0)
                {
                    return new TextPosition()
                           {
                               Item = nextitem, ItemIndex = this.itemindex + enterid + 1, Line = this.line + 1, Column = 1
                           }
                }
                ;
            }
            while (nextitem?.Parent != null)
            {
                ITextZone     zone   = nextitem.Parent;
                ITextPosition result = GetNextLine(zone, nextitem.ID + 1, line + 1);
                if (result != null)
                {
                    return(result);
                }
                nextitem = zone;
            }
            return(null);
        }
Esempio n. 11
0
        public ITextPosition PrevLine()
        {
            ITextItem previtem = item;

            if (previtem is ITextTrim)
            {
                string leftpart = LeftPart;
                int    enterid  = leftpart.LastIndexOf('\n');
                if (enterid >= 0)
                {
                    return new TextPosition()
                           {
                               Item = previtem, ItemIndex = enterid, Line = this.line - 1, Column = -1
                           }
                }
                ;
            }
            while (previtem?.Parent != null)
            {
                ITextZone     zone   = previtem.Parent;
                ITextPosition result = GetPrevLine(zone, previtem.ID - 1, line - 1);
                if (result != null)
                {
                    return(result);
                }
                previtem = zone;
            }
            return(null);
        }
        protected void RenderDefaultMatch(DrawingContext ctx, ITextPosition pos)
        {
            Brush brush = null;

            if (!ViewParent.TextCore.DictBrush.TryGetValue("background_rawtext_defaultmatch", out brush))
            {
                return;
            }
            ITextItem item = pos.Item;

            if (item is ITextKey)
            {
                return;
            }
            string        word  = item.ToString();
            ITextPosition start = Core.Start;
            ITextPosition end   = Core.End;

            if (Core is IMRAZoneSkipInfo)
            {
                IMRAZoneSkipInfo zkcore = (IMRAZoneSkipInfo)Core;
                while (start != null && !zkcore.SkipZone.IsAncestorOf(start.Item))
                {
                    if (!(start.Item is ITextTrim) && !(start.Item is ITextKey) &&
                        start.Item.ToString().Equals(word))
                    {
                        ITextPosition wstart = start.LeftPart.Length > 0 ? start.PrevItem() : start;
                        ITextPosition wend   = start.RightPart.Length > 0 ? start.NextItem() : start;
                        DrawTextRectangle(ctx, brush, null, wstart, wend);
                    }
                    start = start?.NextItem();
                }
                while (end != null && !zkcore.SkipZone.IsAncestorOf(end.Item))
                {
                    if (!(end.Item is ITextTrim) && !(end.Item is ITextKey) &&
                        end.Item.ToString().Equals(word))
                    {
                        ITextPosition wstart = end.LeftPart.Length > 0 ? end.PrevItem() : end;
                        ITextPosition wend   = end.RightPart.Length > 0 ? end.NextItem() : end;
                        DrawTextRectangle(ctx, brush, null, wstart, wend);
                    }
                    end = end?.PrevItem();
                }
            }
            else
            {
                while (start.Item != end.Item)
                {
                    if (!(start.Item is ITextTrim) && !(start.Item is ITextKey) &&
                        start.Item.ToString().Equals(word))
                    {
                        ITextPosition wstart = start.LeftPart.Length > 0 ? start.PrevItem() : start;
                        ITextPosition wend   = start.RightPart.Length > 0 ? start.NextItem() : start;
                        DrawTextRectangle(ctx, brush, null, wstart, wend);
                    }
                    start = start?.NextItem();
                }
            }
        }
Esempio n. 13
0
        public override bool SupportsModifierItemForItems(IEnumerable <Item> items, Item modItem)
        {
            ITextItem message   = items.First() as ITextItem;
            string    buddyName = GetContactNameFromItem(modItem);

            // make sure we dont go over 140 chars with the contact screen name
            return(!string.IsNullOrEmpty(buddyName) && message.Text.Length + buddyName.Length < MaxMessageLength);
        }
Esempio n. 14
0
 public bool IsChildOf(ITextItem that)
 {
     if (that == null)
     {
         return(false);
     }
     return(that.IsAncestorOf(this));
 }
Esempio n. 15
0
		public bool IsEqual(ITextItem targetItem)
		{
			var targetGroup = targetItem as TextGroup;
			if (targetGroup == null) return false;
			if (Separator != targetGroup.Separator) return false;
			if (Items.Count != targetGroup.Items.Count) return false;
			return Items.Select((t, i) => t.IsEqual(targetGroup.Items[i])).All(equal => equal);
		}
        protected void RenderBracket(DrawingContext ctx, ITextPosition pos)
        {
            ITextItem item = pos.Item;
            ITextZone zone = item.Parent;

            if (!(item is ITextKey))
            {
                return;
            }
            ITextKey key = (ITextKey)item;

            if ((key.KeyCore.Feature & (TextKeyFeatures.ZoneLeft | TextKeyFeatures.ZoneRight)) == TextKeyFeatures.None)
            {
                return;
            }
            Brush brush = null;

            ViewParent.TextCore.DictBrush.TryGetValue("background_rawtext_bracket", out brush);
            if (Core.ContainLine(pos.Line))
            {
                ITextPosition start = pos.LeftPart.Length > 0 ? pos.PrevItem() : pos;
                ITextPosition end   = pos.RightPart.Length > 0 ? pos.NextItem() : pos;
                DrawTextRectangle(ctx, brush, null, start.Column - 1, end.Column - start.Column);
            }
            if (item.ID == 0)
            {
                ITextItem rightkey = zone.Items.LastOrDefault();
                if (Core.ContainLine(pos.Line + zone.LineCount - 1))
                {
                    ITextPosition rstart = new TextPosition()
                    {
                        Item = rightkey, ItemIndex = 0, Line = pos.Line + zone.LineCount - 1, Column = -1
                    };
                    ITextPosition rend = rstart?.NextItem();
                    if (rstart != null && rend != null)
                    {
                        DrawTextRectangle(ctx, brush, null, rstart, rend);
                    }
                }
            }
            else
            {
                ITextItem leftkey = zone.Items.FirstOrDefault();
                if (Core.ContainLine(pos.Line - zone.LineCount + 1))
                {
                    ITextPosition lstart = new TextPosition()
                    {
                        Item = leftkey, ItemIndex = 0, Line = pos.Line - zone.LineCount + 1, Column = -1
                    };
                    ITextPosition lend = lstart?.NextItem();
                    if (lstart != null && lend != null)
                    {
                        DrawTextRectangle(ctx, brush, null, lstart, lend);
                    }
                }
            }
        }
Esempio n. 17
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems)
        {
            ZimPage   page            = items.First() as ZimPage;
            ITextItem newPageNameItem = modItems.First() as ITextItem;

            Process zim = new Process();

            zim.StartInfo.FileName  = "zim";
            zim.StartInfo.Arguments = page.Notebook + " " + page.Name + ":" + newPageNameItem.Text;
            zim.Start();

            yield break;
        }
Esempio n. 18
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems)
        {
            ITextItem item = items.First() as ITextItem;

            String  qrcode_content = item.Text;
            Process qrencode       = System.Diagnostics.Process.Start("/usr/bin/qrencode", String.Format("-s 6 -o /tmp/qrcode.png {0}", qrcode_content));

            qrencode.WaitForExit();
            Process feh = System.Diagnostics.Process.Start("/usr/bin/qiv", "/tmp/qrcode.png");

            feh.WaitForExit();
            yield break;
        }
        private void AddNote(DateRange noteRange, ITextItem note)
        {
            if (noteRange == null)
            {
                return;
            }
            Calendar.ActiveCalendarSection.AddNote(noteRange, note);
            Calendar.SettingsNotSaved = true;

            var calendarMonth = Calendar.ActiveCalendarSection.Months.FirstOrDefault(x => x.DaysRangeBegin <= noteRange.FinishDate.Value.Date && x.DaysRangeEnd >= noteRange.FinishDate.Value.Date);

            if (calendarMonth != null)
            {
                GetMonthControlByData(calendarMonth).AddNotes(GetNotesByWeeeks(calendarMonth));
            }
        }
Esempio n. 20
0
 public bool IsAncestorOf(ITextItem that)
 {
     if (that == null)
     {
         return(false);
     }
     if (that.Level < this.level)
     {
         return(false);
     }
     while (that.Level > this.level)
     {
         that = that.Parent;
     }
     return(this == that);
 }
Esempio n. 21
0
        protected Item[] TextItemPerform(ITextItem item, TasqueCategoryItem category)
        {
            string defaultCategory;

            GConf.Client conf   = new GConf.Client();
            TasqueDBus   tasque = new TasqueDBus();

            try {
                defaultCategory = conf.Get("/apps/gnome-do/plugins/tasque/default_category") as string;
            } catch (GConf.NoSuchKeyException) {
                conf.Set("/apps/gnome-do/plugins/tasque/default_category", "");
                return(null);
            }

            if (category.Name != "")
            {
                tasque.CreateTask(category.Name, item.Text);
            }
            else if (defaultCategory == String.Empty)
            {
                string[] split = item.Text.Split(':');
                if (split [0] == item.Text)
                {
                    IEnumerable <string> categories = tasque.GetCategoryNames();
                    tasque.CreateTask(categories.First(), item.Text);
                }
                else
                {
                    tasque.CreateTask(split [0], split [1]);
                }
            }
            else
            {
                string[] split = item.Text.Split(':');

                if (split [0] == item.Text)
                {
                    tasque.CreateTask(defaultCategory, item.Text);
                }
                else
                {
                    tasque.CreateTask(split [0], split [1]);
                }
            }
            return(null);
        }
Esempio n. 22
0
        public virtual void Deserialize(XmlNode node)
        {
            foreach (XmlNode childNode in node.ChildNodes)
            {
                DateTime tempDate;
                switch (childNode.Name)
                {
                case "StartDay":
                    if (DateTime.TryParse(childNode.InnerText, out tempDate))
                    {
                        StartDay = tempDate;
                    }
                    break;

                case "FinishDay":
                    if (DateTime.TryParse(childNode.InnerText, out tempDate))
                    {
                        FinishDay = tempDate;
                    }
                    break;

                case "BackgroundColor":
                    int tempInt;
                    if (Int32.TryParse(childNode.InnerText, out tempInt))
                    {
                        _backgroundColor = Color.FromArgb(tempInt);
                    }
                    break;

                case "TextItem":
                {
                    _note = new TextItem();
                    _note.Deserialize(childNode);
                }
                break;

                case "TextGroup":
                {
                    _note = new TextGroup();
                    _note.Deserialize(childNode);
                }
                break;
                }
            }
        }
Esempio n. 23
0
        public bool IsEqual(ITextItem targetItem)
        {
            var targetGroup = targetItem as TextGroup;

            if (targetGroup == null)
            {
                return(false);
            }
            if (Separator != targetGroup.Separator)
            {
                return(false);
            }
            if (Items.Count != targetGroup.Items.Count)
            {
                return(false);
            }
            return(Items.Select((t, i) => t.IsEqual(targetGroup.Items[i])).All(equal => equal));
        }
Esempio n. 24
0
		public static Size Measure (ITextItem item,Graphics graphics) {
			
			if (!item.CanGrow) {
				return item.Size;
			}
			if (!String.IsNullOrEmpty(item.Text)) {
				SizeF size = graphics.MeasureString(item.Text.TrimEnd(),
				                                    item.Font,
				                                    item.Size.Width);
				var i = (int)size.Height/item.Font.Height;
				if (size.Height < item.Size.Height) {
					return item.Size;
				}
				return new Size(item.Size.Width,(int)Math.Ceiling(size.Height));
			}
			
			return item.Size;
		}
Esempio n. 25
0
        private string GetUrl(RequestTrackerItem tracker, ITextItem ticket)
        {
            if (tracker.URL.Substring(0, 4) == "FAIL")
            {
                Do.Platform.Services.Notifications.Notify("Request Tracker", "No trackers are configured. Please use the GNOME Do preferences ");
                throw new UriFormatException();
            }
            string newtext = Regex.Replace(ticket.Text, @"[^0-9]", "");

            if (string.IsNullOrEmpty(newtext))
            {
                Do.Platform.Services.Notifications.Notify("Request Tracker", "No ticket number provided");
                throw new ArgumentNullException();
            }

            string query = HttpUtility.UrlEncode(newtext);

            return(FormatUrl(tracker.URL, query));
        }
Esempio n. 26
0
 public bool HasEnterEnd()
 {
     for (int i = Items.Count - 1; i >= 0; i--)
     {
         ITextItem item = Items[i];
         if (item is ITextTrim)
         {
             ITextTrim trim = (ITextTrim)item;
             return(trim.GetEnterCount() > 0);
         }
         if (item is ITextLine)
         {
             ITextLine line = (ITextLine)item;
             return(line.HasEnterEnd());
         }
         return(false);
     }
     return(false);
 }
Esempio n. 27
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            string    text  = string.Empty;
            ITextItem titem = null;

            foreach (Item item in items)
            {
                if (item is IFileItem)
                {
                    titem = new TextItem(File.ReadAllText((item as IFileItem).Path));
                }
                else
                {
                    titem = new TextItem((item as ITextItem).Text);
                }
                text += titem.Text;
            }

            if (string.IsNullOrEmpty(text))
            {
                Services.Notifications.Notify("Pastebin", "No text provided for pasting.");
                yield break;
            }

            IPastebinProvider pastebinProvider = null;

            if (modifierItems.Any())
            {
                pastebinProvider = PastebinProviderFactory.GetProviderFromPreferences(text, (modifierItems.First() as ITextSyntaxItem).Syntax);
            }
            else
            {
                pastebinProvider = PastebinProviderFactory.GetProviderFromPreferences(text);
            }

            string url = Pastebin.PostUsing(pastebinProvider);

            if (!string.IsNullOrEmpty(url))
            {
                yield return(new TextItem(url));
            }
        }
Esempio n. 28
0
        public ITextPosition Next()
        {
            ITextItem nextitem   = item;
            char      nextchar   = default(char);
            int       nextindex  = -1;
            int       nextline   = line;
            int       nextcolumn = column + 1;

            if (itemindex >= item.ToString().Length)
            {
                while (nextitem?.Parent != null && nextitem.ID + 1 >= nextitem.Parent.Items.Count)
                {
                    nextitem = nextitem.Parent;
                }
                if (nextitem?.Parent == null)
                {
                    return(null);
                }
                nextitem = nextitem.Parent.Items[nextitem.ID + 1];
                while (nextitem is ITextZone)
                {
                    ITextZone zone = (ITextZone)(nextitem);
                    nextitem = zone.Items.FirstOrDefault();
                }
                nextchar  = nextitem.ToString()[0];
                nextindex = 1;
            }
            else
            {
                nextchar  = item.ToString()[itemindex];
                nextindex = itemindex + 1;
            }
            if (nextchar == '\n')
            {
                nextline   = line + 1;
                nextcolumn = 1;
            }
            return(new TextPosition()
            {
                Item = nextitem, ItemIndex = nextindex, Line = nextline, Column = nextcolumn
            });
        }
Esempio n. 29
0
        public ITextPosition Prev()
        {
            ITextItem previtem   = item;
            char      prevchar   = default(char);
            int       previndex  = itemindex - 1;
            int       prevline   = line;
            int       prevcolumn = column - 1;

            if (itemindex <= 0)
            {
                while (previtem?.Parent != null && previtem.ID <= 0)
                {
                    previtem = previtem.Parent;
                }
                if (previtem?.Parent == null)
                {
                    return(null);
                }
                previtem = previtem.Parent.Items[previtem.ID - 1];
                while (previtem is ITextZone)
                {
                    ITextZone zone = (ITextZone)(previtem);
                    previtem = zone.Items.LastOrDefault();
                }
                prevchar  = previtem.ToString().LastOrDefault();
                previndex = previtem.ToString().Length - 1;
            }
            else
            {
                prevchar  = previtem.ToString()[itemindex - 1];
                previndex = itemindex - 1;
            }
            if (prevchar == '\n')
            {
                prevline   = line - 1;
                prevcolumn = -1;
            }
            return(new TextPosition()
            {
                Item = previtem, ItemIndex = previndex, Line = prevline, Column = prevcolumn
            });
        }
Esempio n. 30
0
 public void Add(ITextItem item)
 {
     AncestorRelease();
     item.Parent = this;
     item.ID     = items.Count();
     item.Level  = Level + 1;
     items.Add(item);
     if (item is ITextTrim)
     {
         ITextTrim trim = (ITextTrim)item;
         linecount += trim.GetEnterCount();
     }
     if (item is ITextZone)
     {
         ITextZone zone = (ITextZone)item;
         linecount += zone.LineCount - 1;
         skipcount += zone.SkipCount;
     }
     AncestorCapture();
 }
Esempio n. 31
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems)
        {
            ITextItem mainItem = items.First() as ITextItem;

            ITextItem modItem = null;

            if (modItems.Any())
            {
                modItem = modItems.First() as ITextItem;
            }

            string title = null, content = null;

            // Check prefs to see if first text item should be
            // note title or content. The modifier item can provide
            // content or title, respectively.
            if (TomboyConfiguration.TitleFirst)
            {
                title = mainItem.Text;
                if (modItem != null)
                {
                    content = modItem.Text;
                }
            }
            else
            {
                content = mainItem.Text;
                if (modItem != null)
                {
                    title = modItem.Text;
                }
            }

            TomboyDBus tb = new TomboyDBus();

            // Null values are acceptable here.
            tb.CreateNewNote(title, content);

            yield break;
        }
Esempio n. 32
0
        public ITextPosition NextItem()
        {
            ITextItem nextitem   = item;
            string    nexttext   = null;
            int       nextindex  = itemindex;
            int       nextline   = line;
            int       nextcolumn = column;

            if (itemindex >= item.ToString().Length)
            {
                while (nextitem?.Parent != null && nextitem.ID + 1 >= nextitem.Parent.Items.Count)
                {
                    nextitem = nextitem.Parent;
                }
                if (nextitem?.Parent == null)
                {
                    return(null);
                }
                nextitem = nextitem.Parent.Items[nextitem.ID + 1];
                while (nextitem is ITextZone)
                {
                    ITextZone zone = (ITextZone)(nextitem);
                    nextitem = zone.Items.FirstOrDefault();
                }
                nexttext  = nextitem.ToString();
                nextindex = nexttext.Length;
            }
            else
            {
                nexttext   = RightPart;
                nextindex += nexttext.Length;
            }
            RefNextLineColumn(nexttext, ref nextline, ref nextcolumn);
            return(new TextPosition()
            {
                Item = nextitem, ItemIndex = nextindex, Line = nextline, Column = nextcolumn
            });
        }
Esempio n. 33
0
        public ITextPosition PrevItem()
        {
            ITextItem previtem   = item;
            string    prevtext   = null;
            int       previndex  = itemindex;
            int       prevline   = line;
            int       prevcolumn = column;

            if (itemindex <= 0)
            {
                while (previtem?.Parent != null && previtem.ID <= 0)
                {
                    previtem = previtem.Parent;
                }
                if (previtem?.Parent == null)
                {
                    return(null);
                }
                previtem = previtem.Parent.Items[previtem.ID - 1];
                while (previtem is ITextZone)
                {
                    ITextZone zone = (ITextZone)(previtem);
                    previtem = zone.Items.LastOrDefault();
                }
                prevtext  = previtem.ToString();
                previndex = 0;
            }
            else
            {
                prevtext  = LeftPart;
                previndex = 0;
            }
            RefPrevLineColumn(prevtext, ref prevline, ref prevcolumn);
            return(new TextPosition()
            {
                Item = previtem, ItemIndex = previndex, Line = prevline, Column = prevcolumn
            });
        }
Esempio n. 34
0
		public virtual void Dispose()
		{
			_note = null;
			Parent = null;
		}
Esempio n. 35
0
        protected Item[] TextItemPerform(ITextItem item, TasqueCategoryItem category)
        {
            string defaultCategory;
            GConf.Client conf = new GConf.Client ();
            TasqueDBus tasque = new TasqueDBus ();

            try {
                defaultCategory = conf.Get ("/apps/gnome-do/plugins/tasque/default_category") as string;
            } catch (GConf.NoSuchKeyException) {
                conf.Set ("/apps/gnome-do/plugins/tasque/default_category", "");
                return null;
            }

            if (category.Name != "" ) {
                tasque.CreateTask(category.Name, item.Text);
            } else if (defaultCategory == String.Empty) {

                string[] split = item.Text.Split (':');
                if (split [0] == item.Text) {
                    IEnumerable<string> categories = tasque.GetCategoryNames ();
                    tasque.CreateTask (categories.First (), item.Text);
                } else {
                    tasque.CreateTask (split [0], split [1]);
                }
            } else {

                string[] split = item.Text.Split (':');

                if (split [0] == item.Text)
                    tasque.CreateTask (defaultCategory, item.Text);
                else
                    tasque.CreateTask (split [0], split [1]);
            }
            return null;
        }
Esempio n. 36
0
		public bool IsEqual(ITextItem targetItem)
		{
			var textItem = targetItem as TextItem;
			return textItem != null && Text == textItem.Text && IsBold == textItem.IsBold;
		}
Esempio n. 37
0
		private void AddNote(DateRange noteRange, ITextItem note)
		{
			if (noteRange == null) return;
			Calendar.CalendarContent.AddNote(noteRange, note);
			Calendar.SettingsNotSaved = true;

			var calendarMonth = Calendar.CalendarContent.Months.FirstOrDefault(x => x.DaysRangeBegin <= noteRange.FinishDate.Value.Date && x.DaysRangeEnd >= noteRange.FinishDate.Value.Date);
			if (calendarMonth != null)
				Months[calendarMonth.Date].AddNotes(GetNotesByWeeeks(calendarMonth));
		}