Example #1
0
		def parseOutline(m, n):
			if not n.HasChildNodes:
				return None

			for xmlNode in n.ChildNodes:
				if xmlNode.Name.Equals("outline"):
					text = None
					xmlUrl = None
					htmlUrl = None

					for xmlAttribute in xmlNode.Attributes:
						if xmlAttribute.Name.Equals("title") or xmlAttribute.Name.Equals("text"):
							text = xmlAttribute.Value
						elif xmlAttribute.Name.Equals("xmlUrl"):
							xmlUrl = xmlAttribute.Value
						elif xmlAttribute.Name.Equals("htmlUrl"):
							htmlUrl = xmlAttribute.Value
						
					if not String.IsNullOrEmpty(text):
						if String.IsNullOrEmpty(xmlUrl):
							mi = MenuItem()
							mi.Header = text
								
							parsedMenuItem = parseOutline(mi, xmlNode)
								
							if parsedMenuItem is None:
								m.Items.Add(mi)
							else:
								m.Items.Add(parsedMenuItem)
						elif not String.IsNullOrEmpty(xmlUrl):
							mi = MenuItem()
								
							def onClick(sender, args):
								if not String.IsNullOrEmpty(sender.Tag):
									def onStart(state):
										Process.Start(state)

									Task.Factory.StartNew(onStart, sender.Tag)
								
							mi.Header = text
							mi.Click += onClick
							mi.Tag = htmlUrl
								
							m.Items.Add(mi)
				
			return m
Example #2
0
def onStart(s, e):
	global timer, menuItem, separator
	
	if String.IsNullOrEmpty(username) or String.IsNullOrEmpty(password):
		if menuItem is None:
			menuItem = MenuItem()
			menuItem.Header = "Gmail"

		for window in Application.Current.Windows:
			if window is Application.Current.MainWindow and window.ContextMenu is not None:
				if not window.ContextMenu.Items.Contains(menuItem):
					window.ContextMenu.Opened += onOpened
					window.ContextMenu.Items.Insert(window.ContextMenu.Items.Count - 4, menuItem)
				
					if not clr.GetClrType(Separator).IsInstanceOfType(window.ContextMenu.Items[10]):
						separator = Separator()
						window.ContextMenu.Items.Insert(10, separator)

	timer.Start()
Example #3
0
 def __init__(self, name, menu_table):
     self.ctrl = MenuItem()
     self.ctrl.Header = name
     for m in menu_table:
         if not m.get('name') or m['name'] == '-':
             self.ctrl.Items.Add(Separator())
             continue
         if not m.get('item'): continue  # Disabled
         if type(m['item']) == list:
             self.ctrl.Items.Add(EzMenu(m['name'], m['item']).ctrl)
         else:
             item = MenuItem()
             if m.get('name'): item.Header = m['name']
             if m.get('item'): item.Click += m['item']
             if m.get('tooltip'):
                 tooltip = ToolTip()
                 tooltip.Content = m['tooltip']
                 item.ToolTip = tooltip
             self.ctrl.Items.Add(item)
Example #4
0
def onOpened(s, e):
	global menuItem, timer

	menuItem.Items.Clear()

	if timer.IsEnabled:
		def onClick1(sender, args):
			global timer

			timer.Stop()

		stopMenuItem = MenuItem()
		stopMenuItem.Click += onClick1

		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			stopMenuItem.Header = "停止"
		else:
			stopMenuItem.Header = "Stop"

		menuItem.Items.Add(stopMenuItem)
		menuItem.Items.Add(Separator())

	def onClick2(sender, args):
		global timer, ts

		ts = TimeSpan(0, -1 * sender.Tag, 0)
		timer.Start()

	for i in range(1, 6):
		mi = MenuItem()
		mi.Click += onClick2
		mi.Tag = i

		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			mi.Header = i.ToString() + "分"
		else:
			if i == 1:
				mi.Header = i.ToString() + " minute"
			else:
				mi.Header = i.ToString() + " minutes"

		menuItem.Items.Add(mi)
Example #5
0
def onStart(s, e):
    global timer, menuItem, separator

    if String.IsNullOrEmpty(username) or String.IsNullOrEmpty(password):
        if menuItem is None:
            menuItem = MenuItem()
            menuItem.Header = "Gmail"

        for window in Application.Current.Windows:
            if window is Application.Current.MainWindow and window.ContextMenu is not None:
                if not window.ContextMenu.Items.Contains(menuItem):
                    window.ContextMenu.Opened += onOpened
                    window.ContextMenu.Items.Insert(
                        window.ContextMenu.Items.Count - 4, menuItem)

                    if not clr.GetClrType(Separator).IsInstanceOfType(
                            window.ContextMenu.Items[10]):
                        separator = Separator()
                        window.ContextMenu.Items.Insert(10, separator)

    timer.Start()
Example #6
0
        def parseOutline(m, n):
            if not n.HasChildNodes:
                return None

            for xmlNode in n.ChildNodes:
                if xmlNode.Name.Equals("outline"):
                    text = None
                    xmlUrl = None
                    htmlUrl = None

                    for xmlAttribute in xmlNode.Attributes:
                        if xmlAttribute.Name.Equals(
                                "title") or xmlAttribute.Name.Equals("text"):
                            text = xmlAttribute.Value
                        elif xmlAttribute.Name.Equals("xmlUrl"):
                            xmlUrl = xmlAttribute.Value
                        elif xmlAttribute.Name.Equals("htmlUrl"):
                            htmlUrl = xmlAttribute.Value

                    if not String.IsNullOrEmpty(text):
                        if String.IsNullOrEmpty(xmlUrl):
                            mi = MenuItem()
                            mi.Header = text

                            parsedMenuItem = parseOutline(mi, xmlNode)

                            if parsedMenuItem is None:
                                m.Items.Add(mi)
                            else:
                                m.Items.Add(parsedMenuItem)
                        elif not String.IsNullOrEmpty(xmlUrl):
                            mi = MenuItem()

                            def onClick(sender, args):
                                if not String.IsNullOrEmpty(sender.Tag):

                                    def onStart(state):
                                        Process.Start(state)

                                    Task.Factory.StartNew(onStart, sender.Tag)

                            mi.Header = text
                            mi.Click += onClick
                            mi.Tag = htmlUrl

                            m.Items.Add(mi)

            return m
Example #7
0
				Task.Factory.StartNew[Uri](onUpdate, TaskCreationOptions.LongRunning).ContinueWith(Action[Task[Uri]](onCompleted), TaskScheduler.FromCurrentSynchronizationContext())

			header = uri.ToString()
			
			if header.Length > maxLength:
				header = String.Concat(header.Remove(maxLength, header.Length - maxLength), "...")

			mi = MenuItem()
			mi.Click += onClick
			mi.Header = header
			mi.Tag = uri

			menuItem.Items.Add(mi)

	else:
		mi = MenuItem()
		mi.IsEnabled = False
		mi.Header = "N/A"

		menuItem.Items.Add(mi)

def onDrawClipboard(s, e):
	global uriList

	if s == Application.Current.MainWindow:
		text = tryGetClipboardText()

		if text is not None:
			match = Regex.Match(text, "(\\S+)://([^:/]+)(:(\\d+))?(/[^#\\s]*)(#(\\S+))?", RegexOptions.CultureInvariant);

			if match.Success:
Example #8
0
from System.Globalization import CultureInfo
from System.Windows import Application, Window
from System.Windows.Controls import MenuItem, Separator
from Apricot import Script

def onClick(s, e):
	Script.Instance.Activate()

def onStart(s, e):
	global menuItem, separator
	
	for window in Application.Current.Windows:
		if window is Application.Current.MainWindow and window.ContextMenu is not None:
			if not window.ContextMenu.Items.Contains(menuItem):
				menuItem.Click += onClick
				window.ContextMenu.Items.Insert(window.ContextMenu.Items.Count - 4, menuItem)
				
				if not clr.GetClrType(Separator).IsInstanceOfType(window.ContextMenu.Items[10]):
					separator = Separator()
					window.ContextMenu.Items.Insert(10, separator)

menuItem = MenuItem()
separator = None

if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
	menuItem.Header = "次のおしゃべり"
else:
	menuItem.Header = "Talk"

Script.Instance.Start += onStart
Example #9
0
def onOpened(s, e):
    global menuItem

    menuItem.Items.Clear()

    config = None
    directory = Path.Combine(
        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
        Assembly.GetEntryAssembly().GetName().Name)

    if Directory.Exists(directory):
        fileName1 = Path.GetFileName(Assembly.GetEntryAssembly().Location)

        for fileName2 in Directory.EnumerateFiles(directory, "*.config"):
            if fileName1.Equals(Path.GetFileNameWithoutExtension(fileName2)):
                exeConfigurationFileMap = ExeConfigurationFileMap()
                exeConfigurationFileMap.ExeConfigFilename = fileName2
                config = ConfigurationManager.OpenMappedExeConfiguration(
                    exeConfigurationFileMap, ConfigurationUserLevel.None)

    if config is None:
        config = ConfigurationManager.OpenExeConfiguration(
            ConfigurationUserLevel.None)
        directory = None

    if config.AppSettings.Settings["ActivateThreshold"] is not None:
        threshold = Int64.Parse(
            config.AppSettings.Settings["ActivateThreshold"].Value)

        childMenuItem = MenuItem()

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            childMenuItem.Header = "トーク間隔"
        else:
            childMenuItem.Header = "Talking Interval"

        menuItem.Items.Add(childMenuItem)

        intervalMenuItem1 = MenuItem()

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            intervalMenuItem1.Header = "15秒"
        else:
            intervalMenuItem1.Header = "15 seconds"

        if threshold == 150000000:
            intervalMenuItem1.IsChecked = True

        def onIntervalClick1(sender, args):
            config.AppSettings.Settings[
                "ActivateThreshold"].Value = "150000000"
            config.Save(ConfigurationSaveMode.Modified)

        intervalMenuItem1.Click += onIntervalClick1

        childMenuItem.Items.Add(intervalMenuItem1)

        intervalMenuItem2 = MenuItem()

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            intervalMenuItem2.Header = "30秒"
        else:
            intervalMenuItem2.Header = "30 seconds"

        if threshold == 300000000:
            intervalMenuItem2.IsChecked = True

        def onIntervalClick2(sender, args):
            config.AppSettings.Settings[
                "ActivateThreshold"].Value = "300000000"
            config.Save(ConfigurationSaveMode.Modified)

        intervalMenuItem2.Click += onIntervalClick2

        childMenuItem.Items.Add(intervalMenuItem2)

        intervalMenuItem3 = MenuItem()

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            intervalMenuItem3.Header = "1分"
        else:
            intervalMenuItem3.Header = "1 minute"

        if threshold == 600000000:
            intervalMenuItem3.IsChecked = True

        def onIntervalClick3(sender, args):
            config.AppSettings.Settings[
                "ActivateThreshold"].Value = "600000000"
            config.Save(ConfigurationSaveMode.Modified)

        intervalMenuItem3.Click += onIntervalClick3

        childMenuItem.Items.Add(intervalMenuItem3)

        intervalMenuItem4 = MenuItem()

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            intervalMenuItem4.Header = "2分"
        else:
            intervalMenuItem4.Header = "2 minutes"

        if threshold == 1200000000:
            intervalMenuItem4.IsChecked = True

        def onIntervalClick4(sender, args):
            config.AppSettings.Settings[
                "ActivateThreshold"].Value = "1200000000"
            config.Save(ConfigurationSaveMode.Modified)

        intervalMenuItem4.Click += onIntervalClick4

        childMenuItem.Items.Add(intervalMenuItem4)

        intervalMenuItem5 = MenuItem()

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            intervalMenuItem5.Header = "3分"
        else:
            intervalMenuItem5.Header = "3 minutes"

        if threshold == 1800000000:
            intervalMenuItem5.IsChecked = True

        def onIntervalClick5(sender, args):
            config.AppSettings.Settings[
                "ActivateThreshold"].Value = "1800000000"
            config.Save(ConfigurationSaveMode.Modified)

        intervalMenuItem5.Click += onIntervalClick5

        childMenuItem.Items.Add(intervalMenuItem5)

    childMenuItem = MenuItem()

    if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
        childMenuItem.Header = "テーマ"
    else:
        childMenuItem.Header = "Theme"

    menuItem.Items.Add(Separator())
    menuItem.Items.Add(childMenuItem)

    menuItem1 = MenuItem()
    menuItem2 = MenuItem()
    menuItem3 = MenuItem()
    menuItem4 = MenuItem()
    menuItem5 = MenuItem()
    menuItem6 = MenuItem()
    menuItem7 = MenuItem()
    menuItem8 = MenuItem()
    menuItem9 = MenuItem()
    menuItem10 = MenuItem()

    if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
        menuItem1.Header = "ブループリント"
        menuItem2.Header = "ドット"
        menuItem3.Header = "布"
        menuItem4.Header = "リネン"
        menuItem5.Header = "ノイズ1"
        menuItem6.Header = "ノイズ2"
        menuItem7.Header = "紙"
        menuItem8.Header = "ペンタゴン"
        menuItem9.Header = "雪"
        menuItem10.Header = "ストライプ"
    else:
        menuItem1.Header = "Blueprint"
        menuItem2.Header = "Dots"
        menuItem3.Header = "Fabric"
        menuItem4.Header = "Linen"
        menuItem5.Header = "Noise 1"
        menuItem6.Header = "Noise 2"
        menuItem7.Header = "Paper"
        menuItem8.Header = "Pentagon"
        menuItem9.Header = "Snow"
        menuItem10.Header = "Stripes"

    if config.AppSettings.Settings[
            "BackgroundColor"] is not None and config.AppSettings.Settings[
                "BackgroundImage"] is not None and config.AppSettings.Settings[
                    "TextColor"] is not None and config.AppSettings.Settings[
                        "LinkColor"]:
        backColor = config.AppSettings.Settings["BackgroundColor"].Value
        backImage = config.AppSettings.Settings["BackgroundImage"].Value
        textColor = config.AppSettings.Settings["TextColor"].Value
        linkColor = config.AppSettings.Settings["LinkColor"].Value

        if backColor.Equals("#FF2574B0") and backImage.Equals(
                "Assets\\Background-Blueprint.png") and textColor.Equals(
                    "#FFFFFFFF") and linkColor.Equals("#FFFEEC27"):
            menuItem1.IsChecked = True

        def onClick1(sender, args):
            config.AppSettings.Settings["BackgroundColor"].Value = "#FF2574B0"
            config.AppSettings.Settings[
                "BackgroundImage"].Value = "Assets\\Background-Blueprint.png"
            config.AppSettings.Settings["TextColor"].Value = "#FFFFFFFF"
            config.AppSettings.Settings["LinkColor"].Value = "#FFFEEC27"
            config.Save(ConfigurationSaveMode.Modified)

        menuItem1.Click += onClick1

        if backColor.Equals("#FF252525") and backImage.Equals(
                "Assets\\Background-Dots.png") and textColor.Equals(
                    "#FFFFFFFF") and linkColor.Equals("#FF00C0FF"):
            menuItem2.IsChecked = True

        def onClick2(sender, args):
            config.AppSettings.Settings["BackgroundColor"].Value = "#FF252525"
            config.AppSettings.Settings[
                "BackgroundImage"].Value = "Assets\\Background-Dots.png"
            config.AppSettings.Settings["TextColor"].Value = "#FFFFFFFF"
            config.AppSettings.Settings["LinkColor"].Value = "#FF00C0FF"
            config.Save(ConfigurationSaveMode.Modified)

        menuItem2.Click += onClick2

        if backColor.Equals("#FFEAEAEA") and backImage.Equals(
                "Assets\\Background-Fabric.png") and textColor.Equals(
                    "#FF000000") and linkColor.Equals("#FFFF0066"):
            menuItem3.IsChecked = True

        def onClick3(sender, args):
            config.AppSettings.Settings["BackgroundColor"].Value = "#FFEAEAEA"
            config.AppSettings.Settings[
                "BackgroundImage"].Value = "Assets\\Background-Fabric.png"
            config.AppSettings.Settings["TextColor"].Value = "#FF000000"
            config.AppSettings.Settings["LinkColor"].Value = "#FFFF0066"
            config.Save(ConfigurationSaveMode.Modified)

        menuItem3.Click += onClick3

        if backColor.Equals("#FF252525") and backImage.Equals(
                "Assets\\Background-Linen.png") and textColor.Equals(
                    "#FFFFFFFF") and linkColor.Equals("#FFFF6600"):
            menuItem4.IsChecked = True

        def onClick4(sender, args):
            config.AppSettings.Settings["BackgroundColor"].Value = "#FF252525"
            config.AppSettings.Settings[
                "BackgroundImage"].Value = "Assets\\Background-Linen.png"
            config.AppSettings.Settings["TextColor"].Value = "#FFFFFFFF"
            config.AppSettings.Settings["LinkColor"].Value = "#FFFF6600"
            config.Save(ConfigurationSaveMode.Modified)

        menuItem4.Click += onClick4

        if backColor.Equals("#FFF2F2F2") and backImage.Equals(
                "Assets\\Background-Noise1.png") and textColor.Equals(
                    "#FF333333") and linkColor.Equals("#FFFF0066"):
            menuItem5.IsChecked = True

        def onClick5(sender, args):
            config.AppSettings.Settings["BackgroundColor"].Value = "#FFF2F2F2"
            config.AppSettings.Settings[
                "BackgroundImage"].Value = "Assets\\Background-Noise1.png"
            config.AppSettings.Settings["TextColor"].Value = "#FF333333"
            config.AppSettings.Settings["LinkColor"].Value = "#FFFF0066"
            config.Save(ConfigurationSaveMode.Modified)

        menuItem5.Click += onClick5

        if backColor.Equals("#FF262727") and backImage.Equals(
                "Assets\\Background-Noise2.png") and textColor.Equals(
                    "#FFFFFFFF") and linkColor.Equals("#FFFF6600"):
            menuItem6.IsChecked = True

        def onClick6(sender, args):
            config.AppSettings.Settings["BackgroundColor"].Value = "#FF262727"
            config.AppSettings.Settings[
                "BackgroundImage"].Value = "Assets\\Background-Noise2.png"
            config.AppSettings.Settings["TextColor"].Value = "#FFFFFFFF"
            config.AppSettings.Settings["LinkColor"].Value = "#FFFF6600"
            config.Save(ConfigurationSaveMode.Modified)

        menuItem6.Click += onClick6

        if backColor.Equals("#FFFCFCFC") and backImage.Equals(
                "Assets\\Background-Paper.png") and textColor.Equals(
                    "#FF000000") and linkColor.Equals("#FFFF0099"):
            menuItem7.IsChecked = True

        def onClick7(sender, args):
            config.AppSettings.Settings["BackgroundColor"].Value = "#FFFCFCFC"
            config.AppSettings.Settings[
                "BackgroundImage"].Value = "Assets\\Background-Paper.png"
            config.AppSettings.Settings["TextColor"].Value = "#FF000000"
            config.AppSettings.Settings["LinkColor"].Value = "#FFFF0099"
            config.Save(ConfigurationSaveMode.Modified)

        menuItem7.Click += onClick7

        if backColor.Equals("#FFEEEEEE") and backImage.Equals(
                "Assets\\Background-Pentagon.png") and textColor.Equals(
                    "#FF333333") and linkColor.Equals("#FF00A0E9"):
            menuItem8.IsChecked = True

        def onClick8(sender, args):
            config.AppSettings.Settings["BackgroundColor"].Value = "#FFEEEEEE"
            config.AppSettings.Settings[
                "BackgroundImage"].Value = "Assets\\Background-Pentagon.png"
            config.AppSettings.Settings["TextColor"].Value = "#FF333333"
            config.AppSettings.Settings["LinkColor"].Value = "#FF00A0E9"
            config.Save(ConfigurationSaveMode.Modified)

        menuItem8.Click += onClick8

        if backColor.Equals("#FFFBFBFB") and backImage.Equals(
                "Assets\\Background-Snow.png") and textColor.Equals(
                    "#FF000000") and linkColor.Equals("#FF00A0E9"):
            menuItem9.IsChecked = True

        def onClick9(sender, args):
            config.AppSettings.Settings["BackgroundColor"].Value = "#FFFBFBFB"
            config.AppSettings.Settings[
                "BackgroundImage"].Value = "Assets\\Background-Snow.png"
            config.AppSettings.Settings["TextColor"].Value = "#FF000000"
            config.AppSettings.Settings["LinkColor"].Value = "#FF00A0E9"
            config.Save(ConfigurationSaveMode.Modified)

        menuItem9.Click += onClick9

        if backColor.Equals("#FF39343D") and backImage.Equals(
                "Assets\\Background-Stripes.png") and textColor.Equals(
                    "#FFFFFFFF") and linkColor.Equals("#FFFF6600"):
            menuItem10.IsChecked = True

        def onClick10(sender, args):
            config.AppSettings.Settings["BackgroundColor"].Value = "#FF39343D"
            config.AppSettings.Settings[
                "BackgroundImage"].Value = "Assets\\Background-Stripes.png"
            config.AppSettings.Settings["TextColor"].Value = "#FFFFFFFF"
            config.AppSettings.Settings["LinkColor"].Value = "#FFFF6600"
            config.Save(ConfigurationSaveMode.Modified)

        menuItem10.Click += onClick10

    childMenuItem.Items.Add(menuItem1)
    childMenuItem.Items.Add(menuItem2)
    childMenuItem.Items.Add(menuItem3)
    childMenuItem.Items.Add(menuItem4)
    childMenuItem.Items.Add(menuItem5)
    childMenuItem.Items.Add(menuItem6)
    childMenuItem.Items.Add(menuItem7)
    childMenuItem.Items.Add(menuItem8)
    childMenuItem.Items.Add(menuItem9)
    childMenuItem.Items.Add(menuItem10)

    if config.AppSettings.Settings["DropShadow"] is not None:
        dropShadow = Boolean.Parse(
            config.AppSettings.Settings["DropShadow"].Value)

        childMenuItem = MenuItem()
        childMenuItem.IsCheckable = True
        childMenuItem.IsChecked = dropShadow

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            childMenuItem.Header = "ドロップシャドウを有効にする"
        else:
            childMenuItem.Header = "Enable Drop Shadow"

        def onClick(sender, args):
            config.AppSettings.Settings[
                "DropShadow"].Value = sender.IsChecked.ToString()
            config.Save(ConfigurationSaveMode.Modified)

        childMenuItem.Click += onClick

        menuItem.Items.Add(Separator())
        menuItem.Items.Add(childMenuItem)

    menuItem.Items.Add(Separator())

    if config.AppSettings.Settings["FontFamily"] is not None:
        fontFamilyName = config.AppSettings.Settings["FontFamily"].Value

        childMenuItem = MenuItem()

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            childMenuItem.Header = "フォント"
        else:
            childMenuItem.Header = "Font"

        menuItem.Items.Add(childMenuItem)

        for fontFamily in [
                "Arial", "Calibri", "Cambria", "Candara", "Constantia",
                "Corbel", "Courier New", "Geogia", "MS UI Gothic", "Segoe UI",
                "Tahoma", "Times New Roman", "Verdana", "メイリオ", "MS ゴシック"
        ]:
            fontMenuItem = MenuItem()
            fontMenuItem.Header = fontFamily

            if fontFamily.Equals(fontFamilyName):
                fontMenuItem.IsChecked = True

            def onClick(sender, args):
                config.AppSettings.Settings["FontFamily"].Value = sender.Header
                config.Save(ConfigurationSaveMode.Modified)

            fontMenuItem.Click += onClick

            childMenuItem.Items.Add(fontMenuItem)

    if config.AppSettings.Settings["FontSize"] is not None:
        fontSize = config.AppSettings.Settings["FontSize"].Value

        fontSizeConverter = FontSizeConverter()
        childMenuItem = MenuItem()

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            childMenuItem.Header = "フォントサイズ"
        else:
            childMenuItem.Header = "Font Size"

        menuItem.Items.Add(childMenuItem)

        for size in [
                "8pt", "9pt", "10pt", "11pt", "12pt", "14pt", "16pt", "18pt",
                "20pt", "22pt", "24pt"
        ]:
            fontMenuItem = MenuItem()
            fontMenuItem.Header = size

            if fontSize.Equals(size):
                fontMenuItem.IsChecked = True

            def onClick(sender, args):
                config.AppSettings.Settings["FontSize"].Value = sender.Header
                config.Save(ConfigurationSaveMode.Modified)

            fontMenuItem.Click += onClick

            childMenuItem.Items.Add(fontMenuItem)

        if config.AppSettings.Settings["LineHeight"] is not None:
            lineHeight = Double.Parse(
                config.AppSettings.Settings["LineHeight"].Value)
            maxLineHeight = Convert.ToInt32(
                fontSizeConverter.ConvertFromString(fontSize)) * 2

            if maxLineHeight < lineHeight:
                maxLineHeight = lineHeight

            childMenuItem2 = MenuItem()

            if CultureInfo.CurrentCulture.Equals(
                    CultureInfo.GetCultureInfo("ja-JP")):
                childMenuItem2.Header = "行間"
            else:
                childMenuItem2.Header = "Line Height"

            menuItem.Items.Add(childMenuItem2)

            for i in range(
                    Convert.ToInt32(
                        fontSizeConverter.ConvertFromString(fontSize)),
                    Convert.ToInt32(maxLineHeight) + 1):
                lineHeightMenuItem = MenuItem()
                lineHeightMenuItem.Header = i.ToString()

                if lineHeight == i:
                    lineHeightMenuItem.IsChecked = True

                def onClick(sender, args):
                    config.AppSettings.Settings[
                        "LineHeight"].Value = sender.Header
                    config.Save(ConfigurationSaveMode.Modified)

                lineHeightMenuItem.Click += onClick

                childMenuItem2.Items.Add(lineHeightMenuItem)

    if config.AppSettings.Settings["FrameRate"] is not None:
        frameRate = Double.Parse(
            config.AppSettings.Settings["FrameRate"].Value)

        childMenuItem = MenuItem()

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            childMenuItem.Header = "フレームレート"
        else:
            childMenuItem.Header = "Frame Rate"

        menuItem.Items.Add(Separator())
        menuItem.Items.Add(childMenuItem)

        for i in [24, 30, 60]:
            frameRateMenuItem = MenuItem()
            frameRateMenuItem.Header = i.ToString()

            if frameRate == Convert.ToDouble(i):
                frameRateMenuItem.IsChecked = True

            def onClick(sender, args):
                config.AppSettings.Settings["FrameRate"].Value = sender.Header
                config.Save(ConfigurationSaveMode.Modified)

            frameRateMenuItem.Click += onClick

            childMenuItem.Items.Add(frameRateMenuItem)

    if config.AppSettings.Settings["Subscriptions"] is not None:
        path = config.AppSettings.Settings["Subscriptions"].Value

        childMenuItem = MenuItem()

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            childMenuItem.Header = "フィード"
        else:
            childMenuItem.Header = "Subscriptions"

        menuItem.Items.Add(Separator())
        menuItem.Items.Add(childMenuItem)

        editMenuItem = MenuItem()
        editMenuItem.Tag = path

        def onEdit(sender, args):
            global program

            path = sender.Tag

            def onStart(state):
                Process.Start(state)

            psi = ProcessStartInfo()

            if String.IsNullOrEmpty(program):
                psi.FileName = path
            else:
                psi.FileName = program
                psi.Arguments = path

            Task.Factory.StartNew(onStart, psi)

        editMenuItem.Click += onEdit

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            editMenuItem.Header = "フィードの編集..."
        else:
            editMenuItem.Header = "Edit..."

        childMenuItem.Items.Add(editMenuItem)
        childMenuItem.Items.Add(Separator())

        if directory is not None:
            fileName = Path.Combine(directory, path)

            if File.Exists(fileName):
                path = fileName

        def parseOutline(m, n):
            if not n.HasChildNodes:
                return None

            for xmlNode in n.ChildNodes:
                if xmlNode.Name.Equals("outline"):
                    text = None
                    xmlUrl = None
                    htmlUrl = None

                    for xmlAttribute in xmlNode.Attributes:
                        if xmlAttribute.Name.Equals(
                                "title") or xmlAttribute.Name.Equals("text"):
                            text = xmlAttribute.Value
                        elif xmlAttribute.Name.Equals("xmlUrl"):
                            xmlUrl = xmlAttribute.Value
                        elif xmlAttribute.Name.Equals("htmlUrl"):
                            htmlUrl = xmlAttribute.Value

                    if not String.IsNullOrEmpty(text):
                        if String.IsNullOrEmpty(xmlUrl):
                            mi = MenuItem()
                            mi.Header = text

                            parsedMenuItem = parseOutline(mi, xmlNode)

                            if parsedMenuItem is None:
                                m.Items.Add(mi)
                            else:
                                m.Items.Add(parsedMenuItem)
                        elif not String.IsNullOrEmpty(xmlUrl):
                            mi = MenuItem()

                            def onClick(sender, args):
                                if not String.IsNullOrEmpty(sender.Tag):

                                    def onStart(state):
                                        Process.Start(state)

                                    Task.Factory.StartNew(onStart, sender.Tag)

                            mi.Header = text
                            mi.Click += onClick
                            mi.Tag = htmlUrl

                            m.Items.Add(mi)

            return m

        doc = XmlDocument()
        doc.Load(path)

        for xmlNode in doc.SelectNodes("/opml/body"):
            parseOutline(childMenuItem, xmlNode)

    if config.AppSettings.Settings["Timeout"] is not None:
        timeout = Int32.Parse(config.AppSettings.Settings["Timeout"].Value)

        childMenuItem = MenuItem()

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            childMenuItem.Header = "タイムアウト"
        else:
            childMenuItem.Header = "Timeout"

        menuItem.Items.Add(Separator())
        menuItem.Items.Add(childMenuItem)

        for i in [15000, 30000, 60000, 120000, 180000]:
            timeMenuItem = MenuItem()
            timeMenuItem.Header = i.ToString()

            if timeout == i:
                timeMenuItem.IsChecked = True

            def onClick(sender, args):
                config.AppSettings.Settings["Timeout"].Value = sender.Header
                config.Save(ConfigurationSaveMode.Modified)

            timeMenuItem.Click += onClick

            childMenuItem.Items.Add(timeMenuItem)

    if config.AppSettings.Settings["Cache"] is not None:
        path = config.AppSettings.Settings["Cache"].Value

        if directory is not None:
            path = Path.Combine(directory, path)

        childMenuItem = MenuItem()
        childMenuItem.Tag = path

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            childMenuItem.Header = "キャッシュをクリア"
        else:
            childMenuItem.Header = "Clear Cache"

        def onClick(sender, args):
            if Directory.Exists(childMenuItem.Tag):
                for fileName in Directory.EnumerateFiles(childMenuItem.Tag):
                    File.Delete(fileName)

        childMenuItem.Click += onClick

        menuItem.Items.Add(Separator())
        menuItem.Items.Add(childMenuItem)

    childMenuItem = MenuItem()

    if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
        childMenuItem.Header = "GCを強制的に実行"
    else:
        childMenuItem.Header = "Force Garbage Collection"

    def onClick(sender, args):
        GC.Collect()

    childMenuItem.Click += onClick

    menuItem.Items.Add(childMenuItem)
Example #10
0

def onClick(s, e):
    Script.Instance.Activate()


def onStart(s, e):
    global menuItem, separator

    for window in Application.Current.Windows:
        if window is Application.Current.MainWindow and window.ContextMenu is not None:
            if not window.ContextMenu.Items.Contains(menuItem):
                menuItem.Click += onClick
                window.ContextMenu.Items.Insert(
                    window.ContextMenu.Items.Count - 4, menuItem)

                if not clr.GetClrType(Separator).IsInstanceOfType(
                        window.ContextMenu.Items[10]):
                    separator = Separator()
                    window.ContextMenu.Items.Insert(10, separator)


menuItem = MenuItem()
separator = None

if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
    menuItem.Header = "次のおしゃべり"
else:
    menuItem.Header = "Talk"

Script.Instance.Start += onStart
Example #11
0
def onOpened(s, e):
	global appId, appSecret, accessToken, menuItem

	menuItem.Items.Clear()

	if accessToken is None:
		def onLogInClick(source, rea):
			window = Window()
			webBrowser = WebBrowser()
			
			def onWebBrowserNavigated(sender, nea):
				if Regex.IsMatch(nea.Uri.AbsoluteUri, "^http(s)?://www\\.facebook\\.com/connect/login_success\\.html", RegexOptions.CultureInvariant):
					for match in Regex.Matches(nea.Uri.Query, "\\??(?<1>.+?)=(?<2>.*?)(?:&|$)", RegexOptions.CultureInvariant | RegexOptions.Singleline):
						if match.Groups[1].Value.Equals("code"):
							sb = StringBuilder()
							d = Dictionary[String, String]()
							d.Add("client_id", appId)
							d.Add("redirect_uri", "https://www.facebook.com/connect/login_success.html")
							d.Add("client_secret", appSecret)
							d.Add("code", match.Groups[2].Value)

							for kvp in d:
								if sb.Length > 0:
									sb.Append('&')

								sb.AppendFormat("{0}={1}", kvp.Key, urlEncode(kvp.Value))

							request = WebRequest.Create(String.Concat("https://graph.facebook.com/oauth/access_token?", sb.ToString()))
							dictionary = Dictionary[String, String]()

							def onAuth():
								if NetworkInterface.GetIsNetworkAvailable():
									try:
										response = None
										stream = None
										streamReader = None
										shortLivedAccessToken = None

										try:
											response = request.GetResponse()
											stream = response.GetResponseStream()
											streamReader = StreamReader(stream)

											for m in Regex.Matches(streamReader.ReadToEnd(), "(?<1>.+?)=(?<2>.*?)(?:&|$)", RegexOptions.CultureInvariant | RegexOptions.Singleline):
												if m.Groups[1].Value.Equals("access_token"):
													shortLivedAccessToken =  m.Groups[2].Value

										finally:
											if streamReader is not None:
												streamReader.Close()
												streamReader = None

											if stream is not None:
												stream.Close()
												stream = None
				
											if response is not None:
												response.Close()
												response = None

										if shortLivedAccessToken is not None:
											d.Remove("redirect_uri")
											d.Remove("code")
											d.Add("grant_type", "fb_exchange_token")
											d.Add("fb_exchange_token", shortLivedAccessToken)
											sb.Clear()

											for kvp in d:
												if sb.Length > 0:
													sb.Append('&')

												sb.AppendFormat("{0}={1}", kvp.Key, urlEncode(kvp.Value))

											r = WebRequest.Create(String.Concat("https://graph.facebook.com/oauth/access_token?", sb.ToString()))
											
											try:
												response = r.GetResponse()
												stream = response.GetResponseStream()
												streamReader = StreamReader(stream)

												for m in Regex.Matches(streamReader.ReadToEnd(), "(?<1>.+?)=(?<2>.*?)(?:&|$)", RegexOptions.CultureInvariant | RegexOptions.Singleline):
													if not dictionary.ContainsKey(m.Groups[1].Value):
														dictionary.Add(m.Groups[1].Value, m.Groups[2].Value)

											finally:
												if streamReader is not None:
													streamReader.Close()

												if stream is not None:
													stream.Close()
				
												if response is not None:
													response.Close()

										if dictionary.ContainsKey("access_token"):
											fs = None
											sr = None
											sw = None

											try:
												fs = FileStream(__file__, FileMode.Open, FileAccess.ReadWrite, FileShare.Read)
												encoding = UTF8Encoding(False)
												sr = StreamReader(fs, encoding, True)
												lines = Regex.Replace(sr.ReadToEnd(), String.Concat("(?<=", Environment.NewLine, "accessToken\\s*=\\s*(?(?=\")(?<Open>\")|(?<Open>\")?))\\S*?(?=(?(?<=\")(?<Close-Open>\")|(?<Close-Open>\")?)", Environment.NewLine, "(?(Open)(?!))(?!\"))"), MatchEvaluator(lambda x: dictionary["access_token"] if x.Groups["Close"].Success else String.Format("\"{0}\"", dictionary["access_token"])), RegexOptions.CultureInvariant)
												fs.SetLength(0)
												sw = StreamWriter(fs, encoding)
												sw.Write(lines)

											finally:
												if sw is not None:
													sw.Close()

												if sr is not None:
													sr.Close()

												if fs is not None:
													fs.Close()

									except Exception, e:
										Trace.WriteLine(e.clsException.Message)
										Trace.WriteLine(e.clsException.StackTrace)

							def onCompleted(task):
								global accessToken

								if dictionary.ContainsKey("access_token"):
									accessToken = dictionary["access_token"]

							Task.Factory.StartNew(onAuth, TaskCreationOptions.LongRunning).ContinueWith(onCompleted, TaskScheduler.FromCurrentSynchronizationContext())

							break

			def onWindowLoaded(sender, args):
				sb = StringBuilder()
				d = Dictionary[String, String]()
				d.Add("client_id", appId)
				d.Add("redirect_uri", "https://www.facebook.com/connect/login_success.html")
				d.Add("scope", "read_stream, publish_stream")
				d.Add("display", "popup")

				for kvp in d:
					if sb.Length > 0:
						sb.Append('&')

					sb.AppendFormat("{0}={1}", kvp.Key, urlEncode(kvp.Value))

				webBrowser.Navigate(Uri(String.Concat("https://www.facebook.com/dialog/oauth?", sb.ToString())))

			def onCloseClick(source, args):
				window.Close()
			
			window.Owner = Application.Current.MainWindow
			window.Title = Application.Current.MainWindow.Title
			window.WindowStartupLocation = WindowStartupLocation.CenterScreen
			window.ResizeMode = ResizeMode.NoResize
			window.SizeToContent = SizeToContent.WidthAndHeight
			window.Background = SystemColors.ControlBrush
			window.Loaded += onWindowLoaded

			stackPanel = StackPanel()
			stackPanel.UseLayoutRounding = True
			stackPanel.HorizontalAlignment = HorizontalAlignment.Stretch
			stackPanel.VerticalAlignment = VerticalAlignment.Stretch
			stackPanel.Orientation = Orientation.Vertical

			window.Content = stackPanel

			solidColorBrush1 = SolidColorBrush(Colors.Black)
			solidColorBrush1.Opacity = 0.25

			if solidColorBrush1.CanFreeze:
				solidColorBrush1.Freeze()

			border1 = Border()
			border1.HorizontalAlignment = HorizontalAlignment.Stretch
			border1.VerticalAlignment = VerticalAlignment.Stretch
			border1.BorderThickness = Thickness(0, 0, 0, 1)
			border1.BorderBrush = solidColorBrush1

			stackPanel.Children.Add(border1)

			webBrowser.HorizontalAlignment = HorizontalAlignment.Stretch
			webBrowser.VerticalAlignment = VerticalAlignment.Stretch
			webBrowser.Width = 640
			webBrowser.Height = 480
			webBrowser.Navigated += onWebBrowserNavigated
			
			border1.Child = webBrowser

			solidColorBrush2 = SolidColorBrush(Colors.White)
			solidColorBrush2.Opacity = 0.5

			if solidColorBrush2.CanFreeze:
				solidColorBrush2.Freeze()

			border2 = Border()
			border2.HorizontalAlignment = HorizontalAlignment.Stretch
			border2.VerticalAlignment = VerticalAlignment.Stretch
			border2.BorderThickness = Thickness(0, 1, 0, 0)
			border2.BorderBrush = solidColorBrush2

			stackPanel.Children.Add(border2)

			closeButton = Button()
			closeButton.HorizontalAlignment = HorizontalAlignment.Right
			closeButton.VerticalAlignment = VerticalAlignment.Center
			closeButton.Margin = Thickness(10, 10, 10, 10)
			closeButton.Padding = Thickness(10, 2, 10, 2)
			closeButton.IsDefault = True

			if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
				closeButton.Content = "閉じる"
			else:
				closeButton.Content = "Close"

			closeButton.Click += onCloseClick

			border2.Child = closeButton

			window.Show()

		logInMenuItem = MenuItem()

		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			logInMenuItem.Header = "ログイン..."
		else:
			logInMenuItem.Header = "Log In..."

		logInMenuItem.Click += onLogInClick

		menuItem.Items.Add(logInMenuItem)
Example #12
0
		childMenuItem.Header = "Force Garbage Collection"
			
	def onClick(sender, args):
		GC.Collect()
		
	childMenuItem.Click += onClick
		
	menuItem.Items.Add(childMenuItem)

def onStart(s, e):
	global menuItem, separator
	
	for window in Application.Current.Windows:
		if window is Application.Current.MainWindow and window.ContextMenu is not None:
			if not window.ContextMenu.Items.Contains(menuItem):
				window.ContextMenu.Opened += onOpened
				window.ContextMenu.Items.Insert(window.ContextMenu.Items.Count - 4, menuItem)
				
				if not clr.GetClrType(Separator).IsInstanceOfType(window.ContextMenu.Items[10]):
					separator = Separator()
					window.ContextMenu.Items.Insert(10, separator)

menuItem = MenuItem()
separator = None

if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
	menuItem.Header = "オプション"
else:
	menuItem.Header = "Settings"

Script.Instance.Start += onStart
Example #13
0
	global menuItem, separator
	
	for window in Application.Current.Windows:
		if window is Application.Current.MainWindow and window.ContextMenu is not None:
			if not window.ContextMenu.Items.Contains(menuItem):
				window.ContextMenu.Opened += onOpened
				window.ContextMenu.Items.Insert(window.ContextMenu.Items.Count - 4, menuItem)
				
				if not clr.GetClrType(Separator).IsInstanceOfType(window.ContextMenu.Items[10]):
					separator = Separator()
					window.ContextMenu.Items.Insert(10, separator)
	
def onStop(s, e):
	global timer
	
	timer.Stop()

ts = TimeSpan.Zero
timer = DispatcherTimer(DispatcherPriority.Background)
timer.Tick += onTick
timer.Interval = TimeSpan.FromMinutes(1)
menuItem = MenuItem()
separator = None

if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
	menuItem.Header = "タイマー"
else:
	menuItem.Header = "Timer"

Script.Instance.Start += onStart
Script.Instance.Stop += onStop
Example #14
0
		signInButton.Padding = Thickness(10, 2, 10, 2)
		signInButton.IsDefault = True

		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			signInButton.Content = "サインイン"
		else:
			signInButton.Content = "Sign in"

		signInButton.Click += onClick

		border2.Child = signInButton
		
		usernameTextBox.Focus()
		window.Show()

	signInMenuItem = MenuItem()

	if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
		signInMenuItem.Header = "サインイン"
	else:
		signInMenuItem.Header = "Sign in"

	signInMenuItem.Click += onSignInClick

	menuItem.Items.Add(signInMenuItem)

def onStart(s, e):
	global timer, menuItem, separator
	
	if String.IsNullOrEmpty(username) or String.IsNullOrEmpty(password):
		if menuItem is None:
Example #15
0
            window.Show()

    Task.Factory.StartNew(onValidate).ContinueWith(onCompleted, context)
    Directory.SetCurrentDirectory(currentDirectory)


def onStart(s, e):
    global menuItem, separator

    for window in Application.Current.Windows:
        if window is Application.Current.MainWindow and window.ContextMenu is not None:
            if not window.ContextMenu.Items.Contains(menuItem):
                menuItem.Click += onClick
                window.ContextMenu.Items.Insert(
                    window.ContextMenu.Items.Count - 4, menuItem)

                if not clr.GetClrType(Separator).IsInstanceOfType(
                        window.ContextMenu.Items[10]):
                    separator = Separator()
                    window.ContextMenu.Items.Insert(10, separator)


menuItem = MenuItem()
separator = None

if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
    menuItem.Header = "CHARMLをチェック"
else:
    menuItem.Header = "Validate"

Script.Instance.Start += onStart
Example #16
0
def onOpened(s, e):
	global menuItem, uriList

	menuItem.Items.Clear()

	if uriList.Count > 0:
		maxLength = 50
		stack = Stack[Uri](uriList)

		while stack.Count > 0:
			uri = stack.Pop()
			
			def onClick(sender, args):
				def onUpdate():
					shortenedUri = None

					if NetworkInterface.GetIsNetworkAvailable():
						try:
							request = WebRequest.Create(Uri(String.Concat("http://nazr.in/api/shorten.json?url=", urlEncode(uri.ToString()))))
							response = None
							stream = None
							streamReader = None

							try:
								response = request.GetResponse()
								stream = response.GetResponseStream()
								streamReader = StreamReader(stream)
								jsonDictionary = JsonDecoder.decode(streamReader.ReadToEnd())

								if jsonDictionary is not None and clr.GetClrType(Dictionary[String, Object]).IsInstanceOfType(jsonDictionary) and jsonDictionary.ContainsKey("url"):
									shortenedUri = Uri(jsonDictionary["url"])

							finally:
								if streamReader is not None:
									streamReader.Close()

								if stream is not None:
									stream.Close()
			
								if response is not None:
									response.Close()

						except Exception, e:
							Trace.WriteLine(e.clsException.Message)
							Trace.WriteLine(e.clsException.StackTrace)

					return shortenedUri

				def onCompleted(task):
					if task.Result is not None:
						Clipboard.SetDataObject(DataObject(DataFormats.UnicodeText, task.Result.ToString(), True))

				Task.Factory.StartNew[Uri](onUpdate, TaskCreationOptions.LongRunning).ContinueWith(Action[Task[Uri]](onCompleted), TaskScheduler.FromCurrentSynchronizationContext())

			header = uri.ToString()
			
			if header.Length > maxLength:
				header = String.Concat(header.Remove(maxLength, header.Length - maxLength), "...")

			mi = MenuItem()
			mi.Click += onClick
			mi.Header = header
			mi.Tag = uri

			menuItem.Items.Add(mi)
Example #17
0
	else:
		sb = StringBuilder()

		for character in Script.Instance.Characters:
			if sb.Length > 0:
				sb.Append("/")

			sb.Append(character.Name)

		def onMouseUp(sender, mbea):
			mbea.Handled = True

		def onKeyDown(sender, kea):
			kea.Handled = True

		postMenuItem = MenuItem()
		postMenuItem.KeyDown += onKeyDown
		
		menuItem.Items.Add(postMenuItem)

		stackPanel = StackPanel()
		stackPanel.HorizontalAlignment = HorizontalAlignment.Left
		stackPanel.VerticalAlignment = VerticalAlignment.Top
		stackPanel.Orientation = Orientation.Horizontal

		postMenuItem.Header = stackPanel
	
		comboBox = ComboBox()
		comboBox.IsEditable = True
		comboBox.Width = 240
		comboBox.MouseUp += onMouseUp
Example #18
0
def onOpened(s, e):
	global menuItem

	menuItem.Items.Clear()

	config = None
	directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Assembly.GetEntryAssembly().GetName().Name)
	
	if Directory.Exists(directory):
		fileName1 = Path.GetFileName(Assembly.GetEntryAssembly().Location)
		
		for fileName2 in Directory.EnumerateFiles(directory, "*.config"):
			if fileName1.Equals(Path.GetFileNameWithoutExtension(fileName2)):
				exeConfigurationFileMap = ExeConfigurationFileMap()
				exeConfigurationFileMap.ExeConfigFilename = fileName2
				config = ConfigurationManager.OpenMappedExeConfiguration(exeConfigurationFileMap, ConfigurationUserLevel.None)
	
	if config is None:
		config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
		directory = None

	if config.AppSettings.Settings["ActivateThreshold"] is not None:
		threshold = Int64.Parse(config.AppSettings.Settings["ActivateThreshold"].Value)
			
		childMenuItem = MenuItem()
			
		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			childMenuItem.Header = "トーク間隔"
		else:
			childMenuItem.Header = "Talking Interval"

		menuItem.Items.Add(childMenuItem)

		intervalMenuItem1 = MenuItem()
			
		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			intervalMenuItem1.Header = "15秒"
		else:
			intervalMenuItem1.Header = "15 seconds"
			
		if threshold == 150000000:
			intervalMenuItem1.IsChecked = True
				
		def onIntervalClick1(sender, args):
			config.AppSettings.Settings["ActivateThreshold"].Value = "150000000"
			config.Save(ConfigurationSaveMode.Modified)
			
		intervalMenuItem1.Click += onIntervalClick1
					
		childMenuItem.Items.Add(intervalMenuItem1)
			
		intervalMenuItem2 = MenuItem()
			
		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			intervalMenuItem2.Header = "30秒"
		else:
			intervalMenuItem2.Header = "30 seconds"
			
		if threshold == 300000000:
			intervalMenuItem2.IsChecked = True
				
		def onIntervalClick2(sender, args):
			config.AppSettings.Settings["ActivateThreshold"].Value = "300000000"
			config.Save(ConfigurationSaveMode.Modified)
			
		intervalMenuItem2.Click += onIntervalClick2
					
		childMenuItem.Items.Add(intervalMenuItem2)
			
		intervalMenuItem3 = MenuItem()
			
		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			intervalMenuItem3.Header = "1分"
		else:
			intervalMenuItem3.Header = "1 minute"
			
		if threshold == 600000000:
			intervalMenuItem3.IsChecked = True
				
		def onIntervalClick3(sender, args):
			config.AppSettings.Settings["ActivateThreshold"].Value = "600000000"
			config.Save(ConfigurationSaveMode.Modified)
			
		intervalMenuItem3.Click += onIntervalClick3
					
		childMenuItem.Items.Add(intervalMenuItem3)

		intervalMenuItem4 = MenuItem()
			
		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			intervalMenuItem4.Header = "2分"
		else:
			intervalMenuItem4.Header = "2 minutes"
			
		if threshold == 1200000000:
			intervalMenuItem4.IsChecked = True
				
		def onIntervalClick4(sender, args):
			config.AppSettings.Settings["ActivateThreshold"].Value = "1200000000"
			config.Save(ConfigurationSaveMode.Modified)
			
		intervalMenuItem4.Click += onIntervalClick4
					
		childMenuItem.Items.Add(intervalMenuItem4)

		intervalMenuItem5 = MenuItem()
			
		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			intervalMenuItem5.Header = "3分"
		else:
			intervalMenuItem5.Header = "3 minutes"
			
		if threshold == 1800000000:
			intervalMenuItem5.IsChecked = True
				
		def onIntervalClick5(sender, args):
			config.AppSettings.Settings["ActivateThreshold"].Value = "1800000000"
			config.Save(ConfigurationSaveMode.Modified)
			
		intervalMenuItem5.Click += onIntervalClick5
					
		childMenuItem.Items.Add(intervalMenuItem5)
		
	childMenuItem = MenuItem()
		
	if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
		childMenuItem.Header = "テーマ"
	else:
		childMenuItem.Header = "Theme"

	menuItem.Items.Add(Separator())
	menuItem.Items.Add(childMenuItem)

	menuItem1 = MenuItem()
	menuItem2 = MenuItem()
	menuItem3 = MenuItem()
	menuItem4 = MenuItem()
	menuItem5 = MenuItem()
	menuItem6 = MenuItem()
	menuItem7 = MenuItem()
	menuItem8 = MenuItem()
	menuItem9 = MenuItem()
	menuItem10 = MenuItem()
		
	if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
		menuItem1.Header = "ブループリント"
		menuItem2.Header = "ドット"
		menuItem3.Header = "布"
		menuItem4.Header = "リネン"
		menuItem5.Header = "ノイズ1"
		menuItem6.Header = "ノイズ2"
		menuItem7.Header = "紙"
		menuItem8.Header = "ペンタゴン"
		menuItem9.Header = "雪"
		menuItem10.Header = "ストライプ"
	else:
		menuItem1.Header = "Blueprint"
		menuItem2.Header = "Dots"
		menuItem3.Header = "Fabric"
		menuItem4.Header = "Linen"
		menuItem5.Header = "Noise 1"
		menuItem6.Header = "Noise 2"
		menuItem7.Header = "Paper"
		menuItem8.Header = "Pentagon"
		menuItem9.Header = "Snow"
		menuItem10.Header = "Stripes"
		
	if config.AppSettings.Settings["BackgroundColor"] is not None and config.AppSettings.Settings["BackgroundImage"] is not None and config.AppSettings.Settings["TextColor"] is not None and config.AppSettings.Settings["LinkColor"]:
		backColor = config.AppSettings.Settings["BackgroundColor"].Value
		backImage = config.AppSettings.Settings["BackgroundImage"].Value
		textColor = config.AppSettings.Settings["TextColor"].Value
		linkColor = config.AppSettings.Settings["LinkColor"].Value

		if backColor.Equals("#FF2574B0") and backImage.Equals("Assets\\Background-Blueprint.png") and textColor.Equals("#FFFFFFFF") and linkColor.Equals("#FFFEEC27"):
			menuItem1.IsChecked = True
				
		def onClick1(sender, args):
			config.AppSettings.Settings["BackgroundColor"].Value = "#FF2574B0"
			config.AppSettings.Settings["BackgroundImage"].Value = "Assets\\Background-Blueprint.png"
			config.AppSettings.Settings["TextColor"].Value = "#FFFFFFFF"
			config.AppSettings.Settings["LinkColor"].Value = "#FFFEEC27"
			config.Save(ConfigurationSaveMode.Modified)
			
		menuItem1.Click += onClick1

		if backColor.Equals("#FF252525") and backImage.Equals("Assets\\Background-Dots.png") and textColor.Equals("#FFFFFFFF") and linkColor.Equals("#FF00C0FF"):
			menuItem2.IsChecked = True
				
		def onClick2(sender, args):
			config.AppSettings.Settings["BackgroundColor"].Value = "#FF252525"
			config.AppSettings.Settings["BackgroundImage"].Value = "Assets\\Background-Dots.png"
			config.AppSettings.Settings["TextColor"].Value = "#FFFFFFFF"
			config.AppSettings.Settings["LinkColor"].Value = "#FF00C0FF"
			config.Save(ConfigurationSaveMode.Modified)
			
		menuItem2.Click += onClick2

		if backColor.Equals("#FFEAEAEA") and backImage.Equals("Assets\\Background-Fabric.png") and textColor.Equals("#FF000000") and linkColor.Equals("#FFFF0066"):
			menuItem3.IsChecked = True
				
		def onClick3(sender, args):
			config.AppSettings.Settings["BackgroundColor"].Value = "#FFEAEAEA"
			config.AppSettings.Settings["BackgroundImage"].Value = "Assets\\Background-Fabric.png"
			config.AppSettings.Settings["TextColor"].Value = "#FF000000"
			config.AppSettings.Settings["LinkColor"].Value = "#FFFF0066"
			config.Save(ConfigurationSaveMode.Modified)
			
		menuItem3.Click += onClick3

		if backColor.Equals("#FF252525") and backImage.Equals("Assets\\Background-Linen.png") and textColor.Equals("#FFFFFFFF") and linkColor.Equals("#FFFF6600"):
			menuItem4.IsChecked = True
				
		def onClick4(sender, args):
			config.AppSettings.Settings["BackgroundColor"].Value = "#FF252525"
			config.AppSettings.Settings["BackgroundImage"].Value = "Assets\\Background-Linen.png"
			config.AppSettings.Settings["TextColor"].Value = "#FFFFFFFF"
			config.AppSettings.Settings["LinkColor"].Value = "#FFFF6600"
			config.Save(ConfigurationSaveMode.Modified)
			
		menuItem4.Click += onClick4
			
		if backColor.Equals("#FFF2F2F2") and backImage.Equals("Assets\\Background-Noise1.png") and textColor.Equals("#FF333333") and linkColor.Equals("#FFFF0066"):
			menuItem5.IsChecked = True
				
		def onClick5(sender, args):
			config.AppSettings.Settings["BackgroundColor"].Value = "#FFF2F2F2"
			config.AppSettings.Settings["BackgroundImage"].Value = "Assets\\Background-Noise1.png"
			config.AppSettings.Settings["TextColor"].Value = "#FF333333"
			config.AppSettings.Settings["LinkColor"].Value = "#FFFF0066"
			config.Save(ConfigurationSaveMode.Modified)
			
		menuItem5.Click += onClick5
			
		if backColor.Equals("#FF262727") and backImage.Equals("Assets\\Background-Noise2.png") and textColor.Equals("#FFFFFFFF") and linkColor.Equals("#FFFF6600"):
			menuItem6.IsChecked = True
				
		def onClick6(sender, args):
			config.AppSettings.Settings["BackgroundColor"].Value = "#FF262727"
			config.AppSettings.Settings["BackgroundImage"].Value = "Assets\\Background-Noise2.png"
			config.AppSettings.Settings["TextColor"].Value = "#FFFFFFFF"
			config.AppSettings.Settings["LinkColor"].Value = "#FFFF6600"
			config.Save(ConfigurationSaveMode.Modified)
			
		menuItem6.Click += onClick6

		if backColor.Equals("#FFFCFCFC") and backImage.Equals("Assets\\Background-Paper.png") and textColor.Equals("#FF000000") and linkColor.Equals("#FFFF0099"):
			menuItem7.IsChecked = True
				
		def onClick7(sender, args):
			config.AppSettings.Settings["BackgroundColor"].Value = "#FFFCFCFC"
			config.AppSettings.Settings["BackgroundImage"].Value = "Assets\\Background-Paper.png"
			config.AppSettings.Settings["TextColor"].Value = "#FF000000"
			config.AppSettings.Settings["LinkColor"].Value = "#FFFF0099"
			config.Save(ConfigurationSaveMode.Modified)
			
		menuItem7.Click += onClick7

		if backColor.Equals("#FFEEEEEE") and backImage.Equals("Assets\\Background-Pentagon.png") and textColor.Equals("#FF333333") and linkColor.Equals("#FF00A0E9"):
			menuItem8.IsChecked = True
				
		def onClick8(sender, args):
			config.AppSettings.Settings["BackgroundColor"].Value = "#FFEEEEEE"
			config.AppSettings.Settings["BackgroundImage"].Value = "Assets\\Background-Pentagon.png"
			config.AppSettings.Settings["TextColor"].Value = "#FF333333"
			config.AppSettings.Settings["LinkColor"].Value = "#FF00A0E9"
			config.Save(ConfigurationSaveMode.Modified)
			
		menuItem8.Click += onClick8

		if backColor.Equals("#FFFBFBFB") and backImage.Equals("Assets\\Background-Snow.png") and textColor.Equals("#FF000000") and linkColor.Equals("#FF00A0E9"):
			menuItem9.IsChecked = True
				
		def onClick9(sender, args):
			config.AppSettings.Settings["BackgroundColor"].Value = "#FFFBFBFB"
			config.AppSettings.Settings["BackgroundImage"].Value = "Assets\\Background-Snow.png"
			config.AppSettings.Settings["TextColor"].Value = "#FF000000"
			config.AppSettings.Settings["LinkColor"].Value = "#FF00A0E9"
			config.Save(ConfigurationSaveMode.Modified)
			
		menuItem9.Click += onClick9

		if backColor.Equals("#FF39343D") and backImage.Equals("Assets\\Background-Stripes.png") and textColor.Equals("#FFFFFFFF") and linkColor.Equals("#FFFF6600"):
			menuItem10.IsChecked = True
				
		def onClick10(sender, args):
			config.AppSettings.Settings["BackgroundColor"].Value = "#FF39343D"
			config.AppSettings.Settings["BackgroundImage"].Value = "Assets\\Background-Stripes.png"
			config.AppSettings.Settings["TextColor"].Value = "#FFFFFFFF"
			config.AppSettings.Settings["LinkColor"].Value = "#FFFF6600"
			config.Save(ConfigurationSaveMode.Modified)
			
		menuItem10.Click += onClick10
		
	childMenuItem.Items.Add(menuItem1)
	childMenuItem.Items.Add(menuItem2)
	childMenuItem.Items.Add(menuItem3)
	childMenuItem.Items.Add(menuItem4)
	childMenuItem.Items.Add(menuItem5)
	childMenuItem.Items.Add(menuItem6)
	childMenuItem.Items.Add(menuItem7)
	childMenuItem.Items.Add(menuItem8)
	childMenuItem.Items.Add(menuItem9)
	childMenuItem.Items.Add(menuItem10)
	
	if config.AppSettings.Settings["DropShadow"] is not None:
		dropShadow = Boolean.Parse(config.AppSettings.Settings["DropShadow"].Value)
			
		childMenuItem = MenuItem()
		childMenuItem.IsCheckable = True
		childMenuItem.IsChecked = dropShadow
			
		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			childMenuItem.Header = "ドロップシャドウを有効にする"
		else:
			childMenuItem.Header = "Enable Drop Shadow"
			
		def onClick(sender, args):
			config.AppSettings.Settings["DropShadow"].Value = sender.IsChecked.ToString()
			config.Save(ConfigurationSaveMode.Modified)
			
		childMenuItem.Click += onClick
			
		menuItem.Items.Add(Separator())
		menuItem.Items.Add(childMenuItem)
		
	menuItem.Items.Add(Separator())
			
	if config.AppSettings.Settings["FontFamily"] is not None:
		fontFamilyName = config.AppSettings.Settings["FontFamily"].Value
			
		childMenuItem = MenuItem()
			
		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			childMenuItem.Header = "フォント"
		else:
			childMenuItem.Header = "Font"

		menuItem.Items.Add(childMenuItem)
				
		for fontFamily in ["Arial", "Calibri", "Cambria", "Candara", "Constantia", "Corbel", "Courier New", "Geogia", "MS UI Gothic", "Segoe UI", "Tahoma", "Times New Roman", "Verdana", "メイリオ", "MS ゴシック"]:
			fontMenuItem = MenuItem()
			fontMenuItem.Header = fontFamily
			
			if fontFamily.Equals(fontFamilyName):
				fontMenuItem.IsChecked = True
					
			def onClick(sender, args):
				config.AppSettings.Settings["FontFamily"].Value = sender.Header
				config.Save(ConfigurationSaveMode.Modified)
				
			fontMenuItem.Click += onClick
			
			childMenuItem.Items.Add(fontMenuItem)
			
	if config.AppSettings.Settings["FontSize"] is not None:
		fontSize = config.AppSettings.Settings["FontSize"].Value
			
		fontSizeConverter = FontSizeConverter()
		childMenuItem = MenuItem()
			
		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			childMenuItem.Header = "フォントサイズ"
		else:
			childMenuItem.Header = "Font Size"

		menuItem.Items.Add(childMenuItem)
			
		for size in ["8pt", "9pt", "10pt", "11pt", "12pt", "14pt", "16pt", "18pt", "20pt", "22pt", "24pt"]:
			fontMenuItem = MenuItem()
			fontMenuItem.Header = size
				
			if fontSize.Equals(size):
				fontMenuItem.IsChecked = True
					
			def onClick(sender, args):
				config.AppSettings.Settings["FontSize"].Value = sender.Header
				config.Save(ConfigurationSaveMode.Modified)
				
			fontMenuItem.Click += onClick
				
			childMenuItem.Items.Add(fontMenuItem)
		
		if config.AppSettings.Settings["LineHeight"] is not None:
			lineHeight = Double.Parse(config.AppSettings.Settings["LineHeight"].Value)
			maxLineHeight = Convert.ToInt32(fontSizeConverter.ConvertFromString(fontSize)) * 2
				
			if maxLineHeight < lineHeight:
				maxLineHeight = lineHeight
				
			childMenuItem2 = MenuItem()
				
			if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
				childMenuItem2.Header = "行間"
			else:
				childMenuItem2.Header = "Line Height"

			menuItem.Items.Add(childMenuItem2)
				
			for i in range(Convert.ToInt32(fontSizeConverter.ConvertFromString(fontSize)), Convert.ToInt32(maxLineHeight) + 1):
				lineHeightMenuItem = MenuItem()
				lineHeightMenuItem.Header = i.ToString()
					
				if lineHeight == i:
					lineHeightMenuItem.IsChecked = True
						
				def onClick(sender, args):
					config.AppSettings.Settings["LineHeight"].Value = sender.Header
					config.Save(ConfigurationSaveMode.Modified)
					
				lineHeightMenuItem.Click += onClick
					
				childMenuItem2.Items.Add(lineHeightMenuItem)
			
	if config.AppSettings.Settings["FrameRate"] is not None:
		frameRate = Double.Parse(config.AppSettings.Settings["FrameRate"].Value)
		
		childMenuItem = MenuItem()
			
		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			childMenuItem.Header = "フレームレート"
		else:
			childMenuItem.Header = "Frame Rate"

		menuItem.Items.Add(Separator())
		menuItem.Items.Add(childMenuItem)

		for i in [24, 30, 60]:
			frameRateMenuItem = MenuItem()
			frameRateMenuItem.Header = i.ToString()
				
			if frameRate == Convert.ToDouble(i):
				frameRateMenuItem.IsChecked = True
					
			def onClick(sender, args):
				config.AppSettings.Settings["FrameRate"].Value = sender.Header
				config.Save(ConfigurationSaveMode.Modified)
				
			frameRateMenuItem.Click += onClick
				
			childMenuItem.Items.Add(frameRateMenuItem)

	if config.AppSettings.Settings["Subscriptions"] is not None:
		path = config.AppSettings.Settings["Subscriptions"].Value
			
		childMenuItem = MenuItem()
			
		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			childMenuItem.Header = "フィード"
		else:
			childMenuItem.Header = "Subscriptions"
			
		menuItem.Items.Add(Separator())
		menuItem.Items.Add(childMenuItem)

		editMenuItem = MenuItem()
		editMenuItem.Tag = path
			
		def onEdit(sender, args):
			global program
				
			path = sender.Tag

			def onStart(state):
				Process.Start(state)
					
			psi = ProcessStartInfo()

			if String.IsNullOrEmpty(program):
				psi.FileName = path
			else:
				psi.FileName = program
				psi.Arguments = path
				
			Task.Factory.StartNew(onStart, psi)
			
		editMenuItem.Click += onEdit
			
		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			editMenuItem.Header = "フィードの編集..."
		else:
			editMenuItem.Header = "Edit..."
			
		childMenuItem.Items.Add(editMenuItem)
		childMenuItem.Items.Add(Separator())
			
		if directory is not None:
			fileName = Path.Combine(directory, path)
			
			if File.Exists(fileName):
				path = fileName
					
		def parseOutline(m, n):
			if not n.HasChildNodes:
				return None

			for xmlNode in n.ChildNodes:
				if xmlNode.Name.Equals("outline"):
					text = None
					xmlUrl = None
					htmlUrl = None

					for xmlAttribute in xmlNode.Attributes:
						if xmlAttribute.Name.Equals("title") or xmlAttribute.Name.Equals("text"):
							text = xmlAttribute.Value
						elif xmlAttribute.Name.Equals("xmlUrl"):
							xmlUrl = xmlAttribute.Value
						elif xmlAttribute.Name.Equals("htmlUrl"):
							htmlUrl = xmlAttribute.Value
						
					if not String.IsNullOrEmpty(text):
						if String.IsNullOrEmpty(xmlUrl):
							mi = MenuItem()
							mi.Header = text
								
							parsedMenuItem = parseOutline(mi, xmlNode)
								
							if parsedMenuItem is None:
								m.Items.Add(mi)
							else:
								m.Items.Add(parsedMenuItem)
						elif not String.IsNullOrEmpty(xmlUrl):
							mi = MenuItem()
								
							def onClick(sender, args):
								if not String.IsNullOrEmpty(sender.Tag):
									def onStart(state):
										Process.Start(state)

									Task.Factory.StartNew(onStart, sender.Tag)
								
							mi.Header = text
							mi.Click += onClick
							mi.Tag = htmlUrl
								
							m.Items.Add(mi)
				
			return m
				
		doc = XmlDocument()
		doc.Load(path)

		for xmlNode in doc.SelectNodes("/opml/body"):
			parseOutline(childMenuItem, xmlNode)
		
	if config.AppSettings.Settings["Timeout"] is not None:
		timeout = Int32.Parse(config.AppSettings.Settings["Timeout"].Value)
			
		childMenuItem = MenuItem()
			
		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			childMenuItem.Header = "タイムアウト"
		else:
			childMenuItem.Header = "Timeout"

		menuItem.Items.Add(Separator())
		menuItem.Items.Add(childMenuItem)

		for i in [15000, 30000, 60000, 120000, 180000]:
			timeMenuItem = MenuItem()
			timeMenuItem.Header = i.ToString()
				
			if timeout == i:
				timeMenuItem.IsChecked = True
					
			def onClick(sender, args):
				config.AppSettings.Settings["Timeout"].Value = sender.Header
				config.Save(ConfigurationSaveMode.Modified)
				
			timeMenuItem.Click += onClick
				
			childMenuItem.Items.Add(timeMenuItem)
		
	if config.AppSettings.Settings["Cache"] is not None:
		path = config.AppSettings.Settings["Cache"].Value
			
		if directory is not None:
			path = Path.Combine(directory, path)
				
		childMenuItem = MenuItem()
		childMenuItem.Tag = path
			
		if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
			childMenuItem.Header = "キャッシュをクリア"
		else:
			childMenuItem.Header = "Clear Cache"
				
		def onClick(sender, args):
			if Directory.Exists(childMenuItem.Tag):
				for fileName in Directory.EnumerateFiles(childMenuItem.Tag):
					File.Delete(fileName)
			
		childMenuItem.Click += onClick
			
		menuItem.Items.Add(Separator())
		menuItem.Items.Add(childMenuItem)
		
	childMenuItem = MenuItem()
		
	if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
		childMenuItem.Header = "GCを強制的に実行"
	else:
		childMenuItem.Header = "Force Garbage Collection"
			
	def onClick(sender, args):
		GC.Collect()
		
	childMenuItem.Click += onClick
		
	menuItem.Items.Add(childMenuItem)
Example #19
0
        signInButton.IsDefault = True

        if CultureInfo.CurrentCulture.Equals(
                CultureInfo.GetCultureInfo("ja-JP")):
            signInButton.Content = "サインイン"
        else:
            signInButton.Content = "Sign in"

        signInButton.Click += onClick

        border2.Child = signInButton

        usernameTextBox.Focus()
        window.Show()

    signInMenuItem = MenuItem()

    if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
        signInMenuItem.Header = "サインイン"
    else:
        signInMenuItem.Header = "Sign in"

    signInMenuItem.Click += onSignInClick

    menuItem.Items.Add(signInMenuItem)


def onStart(s, e):
    global timer, menuItem, separator

    if String.IsNullOrEmpty(username) or String.IsNullOrEmpty(password):
Example #20
0
    childMenuItem.Click += onClick

    menuItem.Items.Add(childMenuItem)


def onStart(s, e):
    global menuItem, separator

    for window in Application.Current.Windows:
        if window is Application.Current.MainWindow and window.ContextMenu is not None:
            if not window.ContextMenu.Items.Contains(menuItem):
                window.ContextMenu.Opened += onOpened
                window.ContextMenu.Items.Insert(
                    window.ContextMenu.Items.Count - 4, menuItem)

                if not clr.GetClrType(Separator).IsInstanceOfType(
                        window.ContextMenu.Items[10]):
                    separator = Separator()
                    window.ContextMenu.Items.Insert(10, separator)


menuItem = MenuItem()
separator = None

if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
    menuItem.Header = "オプション"
else:
    menuItem.Header = "Settings"

Script.Instance.Start += onStart
Example #21
0
			closeButton.Click += onCloseClick

			border.Child = closeButton

			window.Show()

	Task.Factory.StartNew(onValidate).ContinueWith(onCompleted, context)
	Directory.SetCurrentDirectory(currentDirectory)
		
def onStart(s, e):
	global menuItem, separator
	
	for window in Application.Current.Windows:
		if window is Application.Current.MainWindow and window.ContextMenu is not None:
			if not window.ContextMenu.Items.Contains(menuItem):
				menuItem.Click += onClick
				window.ContextMenu.Items.Insert(window.ContextMenu.Items.Count - 4, menuItem)
				
				if not clr.GetClrType(Separator).IsInstanceOfType(window.ContextMenu.Items[10]):
					separator = Separator()
					window.ContextMenu.Items.Insert(10, separator)

menuItem = MenuItem()
separator = None

if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
	menuItem.Header = "CHARMLをチェック"
else:
	menuItem.Header = "Validate"

Script.Instance.Start += onStart
Example #22
0
def create_menu(menu_instance, src, eval_script, parent=None):
  global _menubar_item_callback_id

  for m in src:
    if 'clickCallback' in m:
      m['callbackID'] = _menubar_item_callback_id
      _menubar_item_callback_id += 1

      eval_script(
        script='_macron.menubarCallbacks[{}] = {}'.format(
          m['callbackID'],
          multiple_replace(m['clickCallback'], {
            '/n': '\n',
            '/r': '\r'
          })
        )
      )

    if "seperator" in m:
      if parent:
        parent.AddChild(Separator())
      else:
        menu_instance.AddChild(Separator())
      continue

    # TODO improve
    class ClickCallbackWrapper:
      def __init__(self, menuitem_config):
        self.menuitem_config = menuitem_config
      
      def click_handler(self, sender, args):
        if sender.IsCheckable:
          self.menuitem_config['checked'] = sender.IsChecked
        
        if 'callbackID' in self.menuitem_config:
          eval_script(
            script='_macron.{}[{}].call(null, {})'.format(
              'contextmenuCallbacks' if self.menuitem_config['type'] == 'contextmenuitem' else 'menubarCallbacks',
              self.menuitem_config['callbackID'],
              dumps(self.menuitem_config)
            ),
            on_ready=False
          )

    menuitem = MenuItem()
    menuitem.Header = m["label"]
    click_wrapper = ClickCallbackWrapper(m) # config obj
    menuitem.Click += click_wrapper.click_handler

    if m["isCheckable"] == True and m['submenu'] == None:
      menuitem.IsCheckable = True
      if "checked" in m and m["checked"] != None:
        menuitem.IsChecked = m["checked"]

    if "submenu" in m and m['submenu']:
      create_menu(
        menu_instance=menu_instance,
        src=m["submenu"],
        eval_script=eval_script,
        parent=menuitem
      )

    if parent:
      parent.AddChild(menuitem)
    else:
      menu_instance.AddChild(menuitem)