Esempio n. 1
0
 def _get_map_value2(map, key, format=None):
     try:
         if str(type(map[key])) == "<type 'NSData'>":
             if format == 'str':
                 return Encoding.UTF8.GetString(map[key].Bytes)
             if format == 'bool':
                 return Convert.ToBoolean(map[key].Bytes)
             if format == 'int':
                 return Convert.ToInt32(map[key].Bytes)
             return map[key].Bytes
         if format == 'data':
             return Encoding.UTF8.GetBytes(str(map[key]))
         if format == 'bool':
             return bool(map[key])
         if format == 'int':
             return int(str(map[key]))
         return str(map[key])
     except:
         if format == 'bool':
             return False
         elif format == 'int':
             return 0
         elif format == 'str':
             return ""
         elif format == 'data':
             return bytes(0)
Esempio n. 2
0
def colorFromAhsb(a, h, s, b):
	if 0 > a or 255 < a:
		return Colors.Transparent

	if 0 > h or 360 < h:
		return Colors.Transparent

	if 0 > s or 1 < s:
		return Colors.Transparent

	if 0 > b or 1 < b:
		return Colors.Transparent;

	if 0 == s:
		return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(b * Byte.MaxValue), Convert.ToByte(b * Byte.MaxValue), Convert.ToByte(b * Byte.MaxValue))
		
	fMax = b - (b * s) + s if 0.5 < b else b + (b * s)
	fMin = b + (b * s) - s if 0.5 < b else b - (b * s)
	iSextant = Convert.ToInt32(Math.Floor(h / 60.0))

	if 300 <= h:
		h -= 360

	h = h / 60.0
	h -= 2 * Convert.ToSingle(Math.Floor(((iSextant + 1) % 6.0) / 2))

	fMid = h * (fMax - fMin) + fMin if 0 == iSextant % 2 else fMin - h * (fMax - fMin)
	iMax = Convert.ToInt32(fMax * Byte.MaxValue)
	iMid = Convert.ToInt32(fMid * Byte.MaxValue)
	iMin = Convert.ToInt32(fMin * Byte.MaxValue)
	
	if iSextant == 1:
		return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMid), Convert.ToByte(iMax), Convert.ToByte(iMin))

	elif iSextant == 2:
		return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMin), Convert.ToByte(iMax), Convert.ToByte(iMid))

	elif iSextant == 3:
		return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMin), Convert.ToByte(iMid), Convert.ToByte(iMax))

	elif iSextant == 4:
		return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMid), Convert.ToByte(iMin), Convert.ToByte(iMax))

	elif iSextant == 5:
		return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMax), Convert.ToByte(iMin), Convert.ToByte(iMid))

	return Color.FromArgb(Convert.ToByte(a), Convert.ToByte(iMax), Convert.ToByte(iMid), Convert.ToByte(iMin))
Esempio n. 3
0
 def _get_map_value(map, key, format=None):
     try:
         if map.ContainsKey(key) == False:
             if format == 'bool':
                 return False
             elif format == 'int':
                 return 0
             elif format == 'str':
                 return ""
             elif format == 'data':
                 return Encoding.UTF8.GetBytes("0")
         if hasattr(map[key], "Bytes"):
             if format == 'str':
                 return Encoding.UTF8.GetString(map[key].Bytes)
             if format == 'bool':
                 return Convert.ToBoolean(map[key].Bytes)
             if format == 'int':
                 return Convert.ToInt32(map[key].Bytes)
             return map[key].Bytes
         if format == 'data':
             if hasattr(map[key], "Bytes"):
                 return map[key].Bytes
             else:
                 return Encoding.UTF8.GetBytes(map[key].ToString())
         if format == 'bool':
             if hasattr(map[key], "ToBool"):
                 return map[key].ToBool()
             else:
                 return bool(map[key])
         if format == 'int':
             if hasattr(map[key], "ToInt"):
                 return map[key].ToInt()
             else:
                 return Convert.ToInt32(map[key])
         return map[key].ToString()
     except:
         if format == 'bool':
             return False
         elif format == 'int':
             return 0
         elif format == 'str':
             return ""
         elif format == 'data':
             return Encoding.UTF8.GetBytes("0")
Esempio n. 4
0
def urlEncode(value):
	unreserved = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~"
	sb = StringBuilder()
	bytes = Encoding.UTF8.GetBytes(value)

	for b in bytes:
		if b < 0x80 and unreserved.IndexOf(Convert.ToChar(b)) != -1:
			sb.Append(Convert.ToChar(b))
		else:
			sb.Append('%' + String.Format("{0:X2}", Convert.ToInt32(b)))

	return sb.ToString()
Esempio n. 5
0
    def onSpeech():
        for process in Process.GetProcesses():
            if process.ProcessName.Equals("BouyomiChan"):
                tcpClient = tryConnect("127.0.0.1", 50001)

                if tcpClient is not None:
                    ns = None
                    bs = None
                    bw = None
                    bytes = Encoding.UTF8.GetBytes(text)

                    try:
                        ns = tcpClient.GetStream()
                        bs = BufferedStream(ns)
                        bw = BinaryWriter(bs)
                        bw.Write(Convert.ToInt16(0x0001))
                        bw.Write(Convert.ToInt16(-1))
                        bw.Write(Convert.ToInt16(-1))
                        bw.Write(Convert.ToInt16(-1))
                        bw.Write(Convert.ToInt16(1))
                        bw.Write(Convert.ToByte(0))
                        bw.Write(Convert.ToInt32(bytes.Length))
                        bw.Write(bytes)

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

                        if bw is not None:
                            bw.Close()

                        if ns is not None:
                            ns.Close()

                        tcpClient.Close()

                break
Esempio n. 6
0
			def onLoaded(sender, args):
				time = 0
				speed = task.Result.Value.Value.Key.Key * 1000 / 60 / 60

				contentControl.Width = contentControl.ActualWidth * 1.5 if contentControl.ActualWidth > contentControl.ActualHeight else contentControl.ActualHeight * 1.5 
				contentControl.Height = contentControl.ActualWidth * 1.5 if contentControl.ActualWidth > contentControl.ActualHeight else contentControl.ActualHeight * 1.5
				contentControl.RenderTransform.CenterX = contentControl.Width / 2
				contentControl.RenderTransform.CenterY = contentControl.Height / 2

				doubleAnimation1 = DoubleAnimation(contentControl.Opacity, 1, TimeSpan.FromMilliseconds(500))
				doubleAnimation2 = DoubleAnimation(1.5, 1, TimeSpan.FromMilliseconds(500))
				doubleAnimation3 = DoubleAnimation(1.5, 1, TimeSpan.FromMilliseconds(500))
				doubleAnimation4 = DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(500))
				doubleAnimation5 = DoubleAnimation(1, 1.5, TimeSpan.FromMilliseconds(500))
				doubleAnimation6 = DoubleAnimation(1, 1.5, TimeSpan.FromMilliseconds(500))
				sineEase1 = SineEase()
				sineEase2 = SineEase()

				sineEase1.EasingMode = EasingMode.EaseOut
				sineEase2.EasingMode = EasingMode.EaseIn
				doubleAnimation1.EasingFunction = doubleAnimation2.EasingFunction = doubleAnimation3.EasingFunction = sineEase1
				doubleAnimation4.EasingFunction = doubleAnimation5.EasingFunction = doubleAnimation6.EasingFunction = sineEase2

				doubleAnimation4.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds((250 * (max - 1) * 2 + 1000 + 3000) * task.Result.Value.Value.Value.Value.Count - 500))
				doubleAnimation5.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds((250 * (max - 1) * 2 + 1000 + 3000) * task.Result.Value.Value.Value.Value.Count - 500))
				doubleAnimation6.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds((250 * (max - 1) * 2 + 1000 + 3000) * task.Result.Value.Value.Value.Value.Count - 500))

				storyboard.Children.Add(doubleAnimation1)
				storyboard.Children.Add(doubleAnimation2)
				storyboard.Children.Add(doubleAnimation3)
				storyboard.Children.Add(doubleAnimation4)
				storyboard.Children.Add(doubleAnimation5)
				storyboard.Children.Add(doubleAnimation6)

				Storyboard.SetTarget(doubleAnimation1, contentControl)
				Storyboard.SetTarget(doubleAnimation2, contentControl)
				Storyboard.SetTarget(doubleAnimation3, contentControl)
				Storyboard.SetTarget(doubleAnimation4, contentControl)
				Storyboard.SetTarget(doubleAnimation5, contentControl)
				Storyboard.SetTarget(doubleAnimation6, contentControl)
				Storyboard.SetTargetProperty(doubleAnimation1, PropertyPath(ContentControl.OpacityProperty))
				Storyboard.SetTargetProperty(doubleAnimation2, PropertyPath("(0).(1)", ContentControl.RenderTransformProperty, ScaleTransform.ScaleXProperty))
				Storyboard.SetTargetProperty(doubleAnimation3, PropertyPath("(0).(1)", ContentControl.RenderTransformProperty, ScaleTransform.ScaleYProperty))
				Storyboard.SetTargetProperty(doubleAnimation4, PropertyPath(ContentControl.OpacityProperty))
				Storyboard.SetTargetProperty(doubleAnimation5, PropertyPath("(0).(1)", ContentControl.RenderTransformProperty, ScaleTransform.ScaleXProperty))
				Storyboard.SetTargetProperty(doubleAnimation6, PropertyPath("(0).(1)", ContentControl.RenderTransformProperty, ScaleTransform.ScaleYProperty))

				for element1 in grid.Children:
					for element2 in element1.Children:
						w = element2.Width / 2 if speed > 15 else element2.Width / 2 * speed / 15;
						da1 = DoubleAnimation(element2.Opacity, 1, TimeSpan.FromMilliseconds(1000))
						da2 = DoubleAnimation(-w if Convert.ToInt32(task.Result.Value.Value.Key.Value / 180) % 2 == 0 else w, 0, TimeSpan.FromMilliseconds(1000))
						da3 = DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(1000))
						da4 = DoubleAnimation(0, w if Convert.ToInt32(task.Result.Value.Value.Key.Value / 180) % 2 == 0 else -w, TimeSpan.FromMilliseconds(1000))
						se1 = SineEase()
						se2 = SineEase()

						da1.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(time + 250 * element2.Tag))
						da2.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(time + 250 * element2.Tag))
						da3.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(time + 250 * element2.Tag * 2 + 250 * (max - 1) - 250 * element2.Tag + 3000))
						da4.BeginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(time + 250 * element2.Tag * 2 + 250 * (max - 1) - 250 * element2.Tag + 3000))

						se1.EasingMode = EasingMode.EaseOut
						se2.EasingMode = EasingMode.EaseIn
						da1.EasingFunction = da2.EasingFunction = se1
						da3.EasingFunction = da4.EasingFunction = se2

						storyboard.Children.Add(da1)
						storyboard.Children.Add(da2)
						storyboard.Children.Add(da3)
						storyboard.Children.Add(da4)

						Storyboard.SetTarget(da1, element2)
						Storyboard.SetTarget(da2, element2)
						Storyboard.SetTarget(da3, element2)
						Storyboard.SetTarget(da4, element2)
						Storyboard.SetTargetProperty(da1, PropertyPath(Rectangle.OpacityProperty))
						Storyboard.SetTargetProperty(da2, PropertyPath("(0).(1)", Rectangle.RenderTransformProperty, TranslateTransform.XProperty))
						Storyboard.SetTargetProperty(da3, PropertyPath(Rectangle.OpacityProperty))
						Storyboard.SetTargetProperty(da4, PropertyPath("(0).(1)", Rectangle.RenderTransformProperty, TranslateTransform.XProperty))

					time += 250 * (max - 1) + 1000 + 3000

				storyboard.Begin()
Esempio n. 7
0
	def onUpdate():
		temp = 0
		windSpeed = 0
		windDeg = 0
		weatherIdList = List[Double]()
		weatherPathHashSet = HashSet[String]()
		weatherStreamList = List[MemoryStream]()
		weatherConditionList = List[String]()

		if NetworkInterface.GetIsNetworkAvailable():
			try:
				request = WebRequest.Create(Uri(String.Concat("http://api.openweathermap.org/data/2.5/find?q=", urlEncode(location), "&units=metric&cnt=1")))
				response = None
				stream = None
				streamReader = None

				try:
					nowDateTime = DateTime.Now
					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("list") and jsonDictionary["list"] is not None and clr.GetClrType(Array).IsInstanceOfType(jsonDictionary["list"]):
						for obj in jsonDictionary["list"]:
							if obj is not None and clr.GetClrType(Dictionary[String, Object]).IsInstanceOfType(obj):
								if obj.ContainsKey("main") and obj["main"] is not None and clr.GetClrType(Dictionary[String, Object]).IsInstanceOfType(obj["main"]) and obj["main"].ContainsKey("temp"):
									temp = obj["main"]["temp"]

								if obj.ContainsKey("wind") and obj["wind"] is not None and clr.GetClrType(Dictionary[String, Object]).IsInstanceOfType(obj["wind"]):
									if obj["wind"].ContainsKey("speed"):
										windSpeed = obj["wind"]["speed"]

									if obj["wind"].ContainsKey("deg"):
										windDeg = obj["wind"]["deg"]

								if obj.ContainsKey("weather") and obj["weather"] is not None and clr.GetClrType(Array).IsInstanceOfType(obj["weather"]):
									for o in obj["weather"]:
										if o is not None and clr.GetClrType(Dictionary[String, Object]).IsInstanceOfType(o) and o.ContainsKey("id") and o["id"] is not None:
											weatherIdList.Add(o["id"])
																
								for id in weatherIdList:
									digit = Convert.ToInt32(id / 100)
									path = None
									s = None

									if digit == 2:
										path = "Assets\\Cloud-Lightning.png"
										weatherConditionList.Add("Thunderstorm")

									elif  digit == 3:
										path = "Assets\\Cloud-Drizzle.png"
										weatherConditionList.Add("Drizzle")
														
									elif  digit == 5:
										d = Convert.ToInt32(id / 10)

										if d == 0:
											if nowDateTime.Hour > 6 and nowDateTime.Hour <= 18:
												path = "Assets\\Cloud-Rain-Sun.png"
																
											else:
												path = "Assets\\Cloud-Rain-Moon.png"

										else:
											path = "Assets\\Cloud-Rain.png"

										weatherConditionList.Add("Rain")
														
									elif  digit == 6:
										path = "Assets\\Cloud-Snow.png"
										weatherConditionList.Add("Snow")
														
									elif  digit == 7:
										path = "Assets\\Cloud-Fog.png"
															
										if Convert.ToInt32(id) == 701:
											weatherConditionList.Add("Mist")

										elif Convert.ToInt32(id) == 711:
											weatherConditionList.Add("Smoke")

										elif Convert.ToInt32(id) == 721:
											weatherConditionList.Add("Haze")

										elif Convert.ToInt32(id) == 731:
											weatherConditionList.Add("Dust")

										elif Convert.ToInt32(id) == 741:
											weatherConditionList.Add("Fog")
														
									elif  digit == 8:
										if Convert.ToInt32(id) == 800:
											if nowDateTime.Hour > 6 and nowDateTime.Hour <= 18:
												path = "Assets\\Sun.png"
												weatherConditionList.Add("Sunny")
																
											else:
												path = "Assets\\Moon.png"
												weatherConditionList.Add("Clear")

										elif Convert.ToInt32(id) >= 801 and Convert.ToInt32(id) <= 803:
											if nowDateTime.Hour > 6 and nowDateTime.Hour <= 18:
												path = "Assets\\Cloud-Sun.png"
																
											else:
												path = "Assets\\Cloud-Moon.png"

											weatherConditionList.Add("Cloudy")

										elif Convert.ToInt32(id) == 804:
											path = "Assets\\Cloud.png"
											weatherConditionList.Add("Overcast")
															
									else:
										if Convert.ToInt32(id) == 900:
											path = "Assets\\Tornado.png"
											weatherConditionList.Add("Tornado")

										elif Convert.ToInt32(id) == 905:
											path = "Assets\\Wind.png"
											weatherConditionList.Add("Windy")

										elif Convert.ToInt32(id) == 906:
											path = "Assets\\Cloud-Hail.png"
											weatherConditionList.Add("Hail")

									if path is not None and weatherPathHashSet.Contains(path) == False:
										fs = None

										try:
											fs = FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)
											ms = MemoryStream()
											buffer = Array.CreateInstance(Byte, fs.Length)
											bytesRead = fs.Read(buffer, 0, buffer.Length)

											while bytesRead > 0:
												ms.Write(buffer, 0, bytesRead)
												bytesRead = fs.Read(buffer, 0, buffer.Length)

											ms.Seek(0, SeekOrigin.Begin)
											weatherStreamList.Add(ms)

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

										weatherPathHashSet.Add(path)

				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)
Esempio n. 8
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)
Esempio n. 9
0
        def onDispatch(task):
            global httpListener

            if task.Exception is None:
                httpListener.GetContextAsync().ContinueWith[List[Entry]](
                    Func[Task[HttpListenerContext], List[Entry]](onDispatch),
                    TaskContinuationOptions.LongRunning).ContinueWith(
                        Action[Task[List[Entry]]](onCompleted), context)

                try:
                    if task.Result.Request.HttpMethod.Equals(
                            WebRequestMethods.Http.Post
                    ) and task.Result.Request.Url.AbsolutePath.Equals(
                            "/alert"):
                        if task.Result.Request.ContentType.Equals(
                                "application/json"):
                            stream = None
                            streamReader = None

                            try:
                                stream = task.Result.Request.InputStream
                                streamReader = StreamReader(stream)
                                jsonArray = JsonDecoder.decode(
                                    streamReader.ReadToEnd())

                                if jsonArray is not None and clr.GetClrType(
                                        Array).IsInstanceOfType(jsonArray):
                                    entryList = List[Entry]()

                                    for obj in jsonArray:
                                        if clr.GetClrType(Dictionary[
                                                String,
                                                Object]).IsInstanceOfType(obj):
                                            entry = Entry()

                                            if obj.ContainsKey(
                                                    "resource"
                                            ) and clr.GetClrType(
                                                    String).IsInstanceOfType(
                                                        obj["resource"]):
                                                entry.Resource = Uri(
                                                    obj["resource"])

                                            if obj.ContainsKey(
                                                    "title"
                                            ) and clr.GetClrType(
                                                    String).IsInstanceOfType(
                                                        obj["title"]):
                                                entry.Title = obj["title"]

                                            if obj.ContainsKey(
                                                    "description"
                                            ) and clr.GetClrType(
                                                    String).IsInstanceOfType(
                                                        obj["description"]):
                                                entry.Description = obj[
                                                    "description"]

                                            if obj.ContainsKey(
                                                    "author"
                                            ) and clr.GetClrType(
                                                    String).IsInstanceOfType(
                                                        obj["author"]):
                                                entry.Author = obj["author"]

                                            if obj.ContainsKey(
                                                    "created"
                                            ) and clr.GetClrType(
                                                    String).IsInstanceOfType(
                                                        obj["created"]):
                                                entry.Created = DateTime.Parse(
                                                    obj["created"])

                                            if obj.ContainsKey(
                                                    "modified"
                                            ) and clr.GetClrType(
                                                    String).IsInstanceOfType(
                                                        obj["modified"]):
                                                entry.Modified = DateTime.Parse(
                                                    obj["modified"])

                                            if obj.ContainsKey(
                                                    "image"
                                            ) and clr.GetClrType(
                                                    String).IsInstanceOfType(
                                                        obj["image"]):
                                                entry.Image = Uri(obj["image"])

                                            if obj.ContainsKey(
                                                    "tags") and clr.GetClrType(
                                                        Array
                                                    ).IsInstanceOfType(
                                                        obj["tags"]):
                                                for o in obj["tags"]:
                                                    if clr.GetClrType(
                                                            String
                                                    ).IsInstanceOfType(o):
                                                        entry.Tags.Add(o)

                                            entryList.Add(entry)

                                        else:
                                            task.Result.Response.StatusCode = Convert.ToInt32(
                                                HttpStatusCode.BadRequest)

                                            return None

                                    return entryList

                                else:
                                    task.Result.Response.StatusCode = Convert.ToInt32(
                                        HttpStatusCode.BadRequest)

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

                                if stream is not None:
                                    stream.Close()

                        else:
                            task.Result.Response.StatusCode = Convert.ToInt32(
                                HttpStatusCode.UnsupportedMediaType)

                    else:
                        task.Result.Response.StatusCode = Convert.ToInt32(
                            HttpStatusCode.Forbidden)

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

                finally:
Esempio n. 10
0
    def GetDescriptionSubRecord(self, rec):
        p = self.page

        # table has up to 5 columns
        ss = structure = rec.Structure
        if not structure or not structure.elements:
            with p.table(id='record-desc'):
                if ss:
                    with p.thead():
                        with p.tr():
                            p.td(ss.name, class_='headerlabel', width="33%")
                            p.td(ss.desc, colspan='4', class_='header')
                #with p.tfoot(): # write a blank footer to fix the HtmlRenderer Control
                #	with p.tr(class_='hidden'):
                #		p.td('',class_='header',width="33%").td('').td('').td('').td('')
                with p.tr():
                    p.td("String:", width="33%", class_='label')
                    p.td(rec.GetStrData(), class_='value', colspan='4')
                with p.tr():
                    p.td("Hex:", width="33%", class_='label')
                    p.td(rec.GetHexData(), class_='value', colspan='4')
            return

        try:
            plugin = rec.GetPlugin()
            pluginFile = plugin.Name
            elems = [
                elem for elem in rec.EnumerateElements(True)
                if elem.Structure != None and not elem.Structure.notininfo
            ]
            if not elems:
                return

            with p.table(id='record-desc'):
                with p.thead():
                    with p.tr():
                        p.td(ss.name, class_='headerlabel')
                        p.td(ss.desc, colspan='4', class_='header')
                #with p.tfoot(): # write a blank footer to fix the HtmlRenderer Control
                #	with p.tr(class_='hidden'):
                #		p.td('',class_='header',width="33%").td('').td('').td('').td('')
                with p.tbody():
                    for elem in elems:
                        sselem = elem.Structure
                        ssname = self.GetElementName(elem)
                        value = self.GetElementValue(elem)
                        strValue = str(value)

                        with p.tr():
                            p.td(ssname, width="33%", class_='label')

                            if sselem.type == ElementValueType.Blob:
                                p.td(TypeConverter.GetHexData(elem.Data),
                                     class_='value',
                                     colspan='4')
                            elif sselem.type == ElementValueType.Str4:
                                p.td(TypeConverter.GetString(elem.Data),
                                     class_='text',
                                     colspan='4')
                            elif sselem.type == ElementValueType.BString:
                                p.td(TypeConverter.GetBString(elem.Data),
                                     class_='text',
                                     colspan='4')
                            elif sselem.type == ElementValueType.IString:
                                p.td(TypeConverter.GetIString(elem.Data),
                                     class_='text',
                                     colspan='4')
                            elif sselem.type == ElementValueType.FormID:
                                if not value:
                                    p.td(strValue, class_='value', colspan='4')
                                else:
                                    formid = value.ToString("X8")
                                    record = plugin.GetRecordByID(value)
                                    if not record:  # lookup plugin name using the id
                                        prefName = plugin.GetRecordMaster(
                                            value)
                                        with p.td(class_='formid',
                                                  colspan='4'):
                                            p.a(formid,
                                                href=createLink(
                                                    pluginFile,
                                                    sselem.FormIDType, formid,
                                                    prefName))
                                    else:  # lookup actual record to know actual type
                                        pref = record.GetPlugin()
                                        with p.td(class_='formid',
                                                  width="15%"):
                                            p.a(formid,
                                                href=createLink(
                                                    pluginFile, record.Name,
                                                    record.FormID.ToString(
                                                        "X8"), pref.Name))

                                        if record.Name != sselem.FormIDType:
                                            p.td(record.DescriptiveName,
                                                 class_='text',
                                                 width='20%')
                                        else:
                                            p.td(getEditorID(record),
                                                 class_='text',
                                                 width='20%')

                                        id, fullStr = getFullNameWithID(record)
                                        if id == None:
                                            p.td(fullStr,
                                                 class_='text',
                                                 colspan=2)
                                        else:
                                            p.td(id,
                                                 class_='textid',
                                                 width="15%")
                                            p.td(fullStr, class_='text')

                            elif sselem.type == ElementValueType.LString:
                                if elem.Type == ElementValueType.String:
                                    p.td(value, class_='text', colspan=4)
                                elif TypeConverter.IsLikelyString(elem.Data):
                                    p.td(TypeConverter.GetString(elem.Data),
                                         class_='text',
                                         colspan=4)
                                else:
                                    id = TypeConverter.h2i(elem.Data)
                                    p.td(id.ToString("X8"), class_='text')
                                    p.td(plugin.LookupFormStrings(id),
                                         class_='text',
                                         colspan=3)

                            elif sselem.type in (ElementValueType.SByte,
                                                 ElementValueType.Int,
                                                 ElementValueType.Short,
                                                 ElementValueType.Byte,
                                                 ElementValueType.UInt,
                                                 ElementValueType.UShort):

                                if sselem.type in (ElementValueType.Byte,
                                                   ElementValueType.UInt,
                                                   ElementValueType.UShort):
                                    intVal = Convert.ToUInt32(value)
                                else:
                                    intVal = Convert.ToInt32(value)

                                hasOptions = sselem.options != None and sselem.options.Length > 0
                                hasFlags = sselem.flags != None and sselem.flags.Length > 1

                                if sselem.hexview or hasFlags:
                                    hexstr = value.ToString(
                                        "X" + str(elem.Data.Count * 2))
                                    if sselem.hexviewwithdec:
                                        p.td(hexstr,
                                             class_='text',
                                             width="15%")
                                        p.td(strValue,
                                             class_='text',
                                             width="15%")
                                    else:
                                        p.td(hexstr,
                                             class_='text',
                                             colspan=3,
                                             width="30%")
                                else:
                                    p.td(strValue,
                                         class_='text',
                                         colspan=3,
                                         width="30%")

                                strDesc = ''
                                if hasOptions:
                                    for k in xrange(0, sselem.options.Length,
                                                    2):
                                        ok, intValOption = int.TryParse(
                                            sselem.options[k + 1])
                                        if ok and intVal == intValOption:
                                            strDesc = sselem.options[k]
                                elif hasFlags:
                                    sb = StringBuilder()
                                    for k in xrange(0, sselem.flags.Length, 1):
                                        if ((intVal & (1 << k)) != 0):
                                            if (sb.Length > 0):
                                                sb.Append("<br/>")
                                            sb.Append(sselem.flags[k])
                                    strDesc = sb.ToString()
                                p.td(strDesc,
                                     class_='desc',
                                     colspan=3,
                                     width='50%')
                                pass

                            else:
                                #p.td(str(sselem.type), class_='text',width='auto' )
                                p.td(strValue, class_='text', colspan=4)
        except Exception, e:
            p.p("Warning: Subrecord doesn't seem to match the expected structure",
                class_='danger')
            p.p(str(e), class_='danger')