Beispiel #1
0
 def set_image_source(self, element_name, image_file):
     wpf_element = getattr(self, element_name)
     if not op.exists(image_file):
         # noinspection PyUnresolvedReferences
         wpf_element.Source = BitmapImage(Uri(os.path.join(__commandpath__, image_file)))
     else:
         wpf_element.Source = BitmapImage(Uri(image_file))
Beispiel #2
0
 def __init__(self):
     wpf.LoadComponent(self, xamlfile)
     logo = Image()
     bi = BitmapImage()
     bi.BeginInit()
     bi.UriSource = Uri("/logo-portcoast.png", UriKind.Relative)
     bi.EndInit()
     logo.Source = bi
Beispiel #3
0
class MainWindow(Window):
    def __init__(self):
        self.gui = wpf.LoadComponent(self, 'BubbleFromBottom.xaml')
        #self.create_runtime()

        self.Loaded += self.on_loaded
        #self.Closing += self.on_closing

        self.thinkBubble = BitmapImage()
        self.thinkBubble.BeginInit()
        self.thinkBubble.UriSource = Uri("think.png", UriKind.Relative)
        self.thinkBubble.CacheOption = BitmapCacheOption.OnLoad
        #self.thinkBubble.Height = 150
        #self.thinkBubble.Width = 150
        self.thinkBubble.EndInit()

        self.currentX = 300.0
        self.currentY = 700.0

    def on_loaded(self, s, e):
        bubble = Image()
        bubble.Name = "Bubble"
        #imageSource = System.Windows.Resources["think"]
        bubble.Source = self.thinkBubble
        bubble.SetValue(Canvas.TopProperty, self.currentY)
        bubble.SetValue(Canvas.LeftProperty, self.currentX)
        self.mainPanel.Children.Add(bubble)

        text = TextBox()
        text.Text = "???"
        text.FontSize = 65
        text.FontWeight = FontWeights.Bold
        text.BorderThickness = Thickness(0)
        text.SetValue(Canvas.TopProperty, self.currentY + 35)
        text.SetValue(Canvas.LeftProperty, self.currentX + 55)
        self.mainPanel.Children.Add(text)

        myDoubleAnimation = DoubleAnimation()
        myDoubleAnimation.From = 770.0
        myDoubleAnimation.To = 250.0

        myDoubleAnimation.Duration = Duration(TimeSpan.FromSeconds(3))

        myDoubleAnimationText = DoubleAnimation()
        myDoubleAnimationText.From = 770.0 + 35.0
        myDoubleAnimationText.To = 250.0 + 35.0

        myDoubleAnimationText.Duration = Duration(TimeSpan.FromSeconds(3))

        #myStoryboard = Storyboard()
        #myStoryboard.Children.Add(myDoubleAnimation)
        #Storyboard.SetTargetName(myDoubleAnimation, bubble.Name)
        #Storyboard.SetTargetProperty(myDoubleAnimation, PropertyPath(Canvas.TopProperty))

        #myStoryboard.Begin(self);

        bubble.BeginAnimation(Canvas.TopProperty, myDoubleAnimation)
        text.BeginAnimation(Canvas.TopProperty, myDoubleAnimationText)
Beispiel #4
0
 def createImage(self, grid):
    image = Image()
    bi = BitmapImage()
    bi.BeginInit()
    image_uri = os.path.join(os.path.dirname(__file__), 'image.jpg')
    bi.UriSource = Uri(image_uri, UriKind.RelativeOrAbsolute)
    bi.EndInit()
    image.Source = bi
    SetGridChild(grid, image, 1, 1, "Image")
    def __init__(self, mode):
        f = FileStream(Path.Combine(SCRIPTDIRECTORY, "DuplicateForm.xaml"),
                       FileMode.Open)
        self.win = XamlReader.Load(XmlReader.Create(f))
        f.Close()

        self._action = None

        self.RenameText = "The file you are moving will be renamed: "

        #Load the images and icon
        path = FileInfo(__file__).DirectoryName
        arrow = BitmapImage()
        arrow.BeginInit()

        arrow.UriSource = Uri(Path.Combine(SCRIPTDIRECTORY, "arrow.png"),
                              UriKind.Absolute)
        arrow.EndInit()
        self.win.FindName("Arrow1").Source = arrow
        self.win.FindName("Arrow2").Source = arrow
        self.win.FindName("Arrow3").Source = arrow

        icon = BitmapImage()
        icon.BeginInit()
        icon.UriSource = Uri(ICON, UriKind.Absolute)
        icon.EndInit()

        self.win.Icon = icon

        self.win.FindName("CancelButton").Click += self.CancelClick
        self.win.FindName("Cancel").Click += self.CancelClick
        self.win.FindName("ReplaceButton").Click += self.ReplaceClick
        self.win.FindName("RenameButton").Click += self.RenameClick

        self.win.Closing += self.FormClosing

        #The the correct text based on what mode we are in
        #Mode is set by default so only change if in Copy or Simulation mode
        if mode == Mode.Copy:
            self.win.FindName("MoveHeader").Content = "Copy and Replace"
            self.win.FindName(
                "MoveText"
            ).Content = "Replace the file in the destination folder with the file you are copying:"

            self.win.FindName("DontMoveHeader").Content = "Don't Copy"

            self.win.FindName(
                "RenameHeader").Content = "Copy, but keep both files"
            self.RenameText = "The file you are copying will be renamed: "
            self.win.FindName(
                "RenameText"
            ).Text = "The file you are copying will be renamed: "

        if mode == Mode.Simulate:
            self.win.FindName(
                "Subtitle"
            ).Content = "Click the file you want to keep (simulated, no files will be deleted or moved)"
Beispiel #6
0
 def add_image(self):
     """Добавляем картинку."""
     self.img_uri = Uri(self.image)
     self.button.LargeImage = BitmapImage(self.img_uri)
     self.button.Image = BitmapImage()
     self.button.Image.BeginInit()
     self.button.Image.UriSource = self.img_uri
     self.button.Image.DecodePixelHeight = 16
     self.button.Image.DecodePixelWidth = 16
     self.button.Image.EndInit()
Beispiel #7
0
 def setImage(self, path):
     self.txt.Text = path
     try:
         image = BitmapImage()
         image.BeginInit()
         image.CacheOption = BitmapCacheOption.OnLoad
         image.CreateOptions = BitmapCreateOptions.IgnoreImageCache
         image.UriSource = Uri(path)
         image.EndInit()
         self.img.Source = image
     except:
         pass
 def __init__(self, uri):
     self.smallIcon = BitmapImage()
     self.smallIcon.BeginInit()
     self.smallIcon.UriSource = uri
     self.smallIcon.CacheOption = BitmapCacheOption.OnLoad
     self.smallIcon.DecodePixelHeight = 16
     self.smallIcon.DecodePixelWidth = 16
     self.smallIcon.EndInit()
     self.largeIcon = BitmapImage()
     self.largeIcon.BeginInit()
     self.largeIcon.UriSource = uri
     self.largeIcon.CacheOption = BitmapCacheOption.OnLoad
     self.largeIcon.EndInit()
Beispiel #9
0
def add_stacked_buttons(panel):
    """Add a text box and combo box as stacked items"""
    combo_box_data = ComboBoxData("comboBox")
    text_data = TextBoxData("Text Box")
    text_data.Image = BitmapImage(Uri(SMALL_IMG_PATH))
    text_data.Name = "Text Box"
    text_data.ToolTip = "Enter some text here"
    text_data.LongDescription = """This is text that will appear next to the image
        when the user hovers the mouse over the control"""
    text_data.ToolTipImage = BitmapImage(Uri(LARGE_IMG_PATH))

    stacked_items = panel.AddStackedItems(text_data, combo_box_data)

    text_box = stacked_items[0]
    text_box.PromptText = "Enter a comment"
    text_box.ShowImageAsButton = True
    text_box.ToolTip = "Enter some text"
    text_box.EnterPressed += lambda sender, args: TaskDialog.Show(
        'new_ribbon_panel', sender.Value)

    combo_box = stacked_items[1]
    combo_box.ItemText = "ComboBox"
    combo_box.ToolTip = "Select an Option"
    combo_box.LongDescription = "Select a number or letter"

    member_data_a = ComboBoxMemberData('A', 'Option A')
    member_data_a.Image = BitmapImage(
        Uri(os.path.join(EXAMPLES_PATH, 'StartupScripts', 'a.png')))
    member_data_a.GroupName = 'Letters'
    combo_box.AddItem(member_data_a)

    member_data_b = ComboBoxMemberData('B', 'Option B')
    member_data_b.Image = BitmapImage(
        Uri(os.path.join(EXAMPLES_PATH, 'StartupScripts', 'b.png')))
    member_data_b.GroupName = 'Letters'
    combo_box.AddItem(member_data_b)

    member_data_c = ComboBoxMemberData('C', 'Option C')
    member_data_c.Image = BitmapImage(
        Uri(os.path.join(EXAMPLES_PATH, 'StartupScripts', 'c.png')))
    member_data_c.GroupName = 'Letters'
    combo_box.AddItem(member_data_c)

    member_data_1 = ComboBoxMemberData('1', 'Option 1')
    member_data_1.Image = BitmapImage(
        Uri(os.path.join(EXAMPLES_PATH, 'StartupScripts', 'one_small.png')))
    member_data_1.GroupName = 'Numbers'
    combo_box.AddItem(member_data_1)

    member_data_2 = ComboBoxMemberData('2', 'Option 2')
    member_data_2.Image = BitmapImage(
        Uri(os.path.join(EXAMPLES_PATH, 'StartupScripts', 'two_small.png')))
    member_data_2.GroupName = 'Numbers'
    combo_box.AddItem(member_data_2)

    member_data_3 = ComboBoxMemberData('3', 'Option 3')
    member_data_3.Image = BitmapImage(
        Uri(os.path.join(EXAMPLES_PATH, 'StartupScripts', 'three_small.png')))
    member_data_3.GroupName = 'Numbers'
    combo_box.AddItem(member_data_3)
Beispiel #10
0
 def __init__(self, fileDir, fileName):
     uri = Uri(op.join(fileDir, fileName))
     self.smallIcon = BitmapImage()
     self.smallIcon.BeginInit()
     self.smallIcon.UriSource = uri
     self.smallIcon.CacheOption = BitmapCacheOption.OnLoad
     self.smallIcon.DecodePixelHeight = 16
     self.smallIcon.DecodePixelWidth = 16
     self.smallIcon.EndInit()
     self.icon = BitmapImage()
     self.icon.BeginInit()
     self.icon.UriSource = uri
     self.icon.CacheOption = BitmapCacheOption.OnLoad
     self.icon.EndInit()
Beispiel #11
0
 def __init__(self, h):
     self.ctrl = Label()
     self.Initialize(h)
     self.image = Image()
     self.image.HorizontalAlignment = HorizontalAlignment.Center
     self.image.VerticalAlignment = VerticalAlignment.Center
     if h.get('image'):
         self.image.Source = BitmapImage(
             System.Uri(h['image'], System.UriKind.Relative))
     if h.get('stretch'): self.Stretch(h['stretch'])
     else: self.StretchUniform()
     if h.get('size'):
         self.image.Height = float(h['size'])
         self.image.Width = float(h['size'])
     if h.get('scroll') and h['scroll']:
         scroll = ScrollViewer()
         scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto
         scroll.Content = self.image
         self.ctrl.Content = scroll
     elif h.get('multiple') and h['multiple']:
         stack = StackPanel()
         stack.Orientation = Orientation.Horizontal
         stack.Children.Add(self.image)
         self.ctrl.Content = stack
     else:
         self.ctrl.Content = self.image
    def showPreview(self):
        filename = None
        for extension in ["jpg", "png"]:
            filename = path.join(self.sModelPath, "preview." + extension)
            if path.exists(filename):
                break

        if filename:
            image = BitmapImage()
            image.BeginInit()
            imageUri = filename
            image.UriSource =  Uri(imageUri, UriKind.RelativeOrAbsolute)
            image.EndInit()
            self.imagePreview.Source = image
        else:
            pass
Beispiel #13
0
    def __init__(self):
        self.gui = wpf.LoadComponent(self, 'BubbleFromBottom.xaml')
        #self.create_runtime()

        self.Loaded += self.on_loaded
        #self.Closing += self.on_closing

        self.thinkBubble = BitmapImage()
        self.thinkBubble.BeginInit()
        self.thinkBubble.UriSource = Uri("think.png", UriKind.Relative)
        self.thinkBubble.CacheOption = BitmapCacheOption.OnLoad
        #self.thinkBubble.Height = 150
        #self.thinkBubble.Width = 150
        self.thinkBubble.EndInit()

        self.currentX = 300.0
        self.currentY = 700.0
Beispiel #14
0
    def __init__(self):
        self.gui = wpf.LoadComponent(self, 'SkeletalViewer.xaml')
        #self.create_runtime()

        self.Loaded += self.on_loaded
        self.Closing += self.on_closing

        self.thinkBubble = BitmapImage()
        self.thinkBubble.BeginInit()
        self.thinkBubble.UriSource = Uri("think2.png", UriKind.Relative)
        self.thinkBubble.CacheOption = BitmapCacheOption.OnLoad
        #self.thinkBubble.Height = 150
        #self.thinkBubble.Width = 150
        self.thinkBubble.EndInit()

        self.lastX = 0.0
        self.lastY = 300.0
        self.foundHead = False
Beispiel #15
0
def checkBaseword(thischar, bw, tarray, lifepoint, lplabel, HMS, bArray):
    gdflag = False
    counter = 0
    for X in bw:
        if X == thischar:
            tarray[counter].Text = thischar
            gdflag = True
        counter += 1
    lifepoints = int(lifepoint)
    if gdflag == False:
        lifepoints -= 1
        if lifepoints == 4:
            uri = Uri("D:\Repos\HangManEngine\HM7.jpg")
            HMS.Source = BitmapImage(uri)
        elif lifepoints == 3:
            uri = Uri("D:\Repos\HangManEngine\HM8.jpg")
            HMS.Source = BitmapImage(uri)
        elif lifepoints == 2:
            uri = Uri("D:\Repos\HangManEngine\HM9.jpg")
            HMS.Source = BitmapImage(uri)
        elif lifepoints == 1:
            uri = Uri("D:\Repos\HangManEngine\HM10.jpg")
            HMS.Source = BitmapImage(uri)
        elif lifepoints == 0:
            uri = Uri("D:\Repos\HangManEngine\HM11.jpg")
            HMS.Source = BitmapImage(uri)
            lplabel.Content = str(lifepoints)
            for X in bArray:
                X.IsEnabled = False
            form = LoseScreen()
            form.Show()
            lplabel.IsEnabled = False

    lplabel.Content = str(lifepoints)
    myString = ""
    for Y in tarray:
        myString = myString + Y.Text
    if myString == bw:
        for X in bArray:
            X.IsEnabled = False
        form = WinScreen()
        form.Show()
        lplabel.IsEnabled = False
Beispiel #16
0
def add_push_button(panel):
    """add push button"""
    push_button = panel.AddItem(
        PushButtonData("pb_HelloWorld", "Hello, world!", DLL_PATH,
                       "HelloWorld"))
    push_button.ToolTip = "Say hello world"
    context_help = ContextualHelp(ContextualHelpType.Url,
                                  "http://www.autodesk.com")
    push_button.SetContextualHelp(context_help)

    push_button.LargeImage = BitmapImage(Uri(LARGE_IMG_PATH))
Beispiel #17
0
 def image_path_to_bitmap(fname):
     try:
         if fname:
             bitmap = BitmapImage()
             bitmap.BeginInit()
             bitmap.UriSource = CommonUtil.path_to_uri(fname)
             bitmap.CacheOption = BitmapCacheOption.OnLoad
             bitmap.CreateOptions = BitmapCreateOptions.DelayCreation
             bitmap.EndInit()
             bitmap.Freeze()
             return bitmap
     except:
         pass
Beispiel #18
0
def add_stacked_buttons(panel):
    """Add a text box and combo box as stacked items"""
    #set comboboxdata and textboxdata
    combo_box_data = ComboBoxData("comboBox")
    text_data = TextBoxData("Text Box")
    text_data.Image = BitmapImage(Uri(panel_iconsmall))
    text_data.Name = "Text Box"
    text_data.ToolTip = "First, select a function in the combolist"
    text_data.ToolTipImage = BitmapImage(Uri(panel_iconlarge))
    text_data.LongDescription = """
    This is text that will appear next to the image when the user hovers the mouse over the control"""

    #generate panel objects
    stacked_items = panel.AddStackedItems(combo_box_data, text_data)

    #set combobox
    combo_box = stacked_items[0]
    combo_box.ItemText = "ComboBox"
    combo_box.ToolTip = "Select an Option"
    combo_box.LongDescription = """
    Select an option to enable the textbox and enter some parameters"""
    combo_box.CurrentChanged += switch_manager  # plug combo change manager

    #combobox members
    member_data_blank = ComboBoxMemberData('blank', 'Select...')
    combo_box.AddItem(member_data_blank)

    for option in list_options:
        lcombo = ComboBoxMemberData(option.apiname, option.title)
        lcombo.GroupName = option.group
        lcombo.Image = BitmapImage(Uri(path.join(panel_res_path, option.icon)))
        combo_box.AddItem(lcombo)

    #set textbox
    text_box = stacked_items[1]
    text_box.Width = 220
    text_box.PromptText = "User input..."
    text_box.Enabled = False
    text_box.SelectTextOnFocus = True
    text_box.ShowImageAsButton = True
    text_box.EnterPressed += answer_parser  # plug input manager function
Beispiel #19
0
def add_split_button(panel):
    """add a split button"""
    button_one = PushButtonData("pbButtonOne", "Option one", DLL_PATH,
                                "HelloWorld")
    button_one.LargeImage = BitmapImage(
        Uri(os.path.join(EXAMPLES_PATH, 'StartupScripts', 'one.png')))

    button_two = PushButtonData("pbButtonTwo", "Option two", DLL_PATH,
                                "HelloWorld")
    button_two.LargeImage = BitmapImage(
        Uri(os.path.join(EXAMPLES_PATH, 'StartupScripts', 'two.png')))

    button_three = PushButtonData("pbButtonThree", "Option three", DLL_PATH,
                                  "HelloWorld")
    button_three.LargeImage = BitmapImage(
        Uri(os.path.join(EXAMPLES_PATH, 'StartupScripts', 'three.png')))

    split_button = panel.AddItem(SplitButtonData("splitButton", "Split"))
    split_button.AddPushButton(button_one)
    split_button.AddPushButton(button_two)
    split_button.AddPushButton(button_three)
    def BtnBrowse_Click(self, sender, e):
        try:
            dlgOrg = OpenFileDialog()
            dlgOrg.Title = "Select orginal picture"
            dlgOrg.DefaultExt = ".jpg"
            dlgOrg.Filter = "JPG|*.jpg|PNG|*.png|TIF|*.tif"

            dlgMask = OpenFileDialog()
            dlgMask.Title = "Select mask picture"
            dlgMask.DefaultExt = ".tif"
            dlgOrg.Filter = "JPG|*.jpg|PNG|*.png|TIF|*.tif"

            if dlgOrg.ShowDialog(self):
                if dlgMask.ShowDialog(self):
                    print(dlgOrg.FileName)
                    print(dlgMask.FileName)
                    self.img.Source = BitmapImage(Uri(dlgOrg.FileName))
                    self.imgResult.Source = BitmapImage(Uri(dlgMask.FileName))
                    #import Test
        except e:
            print("Error: {}", e)
        return 0
Beispiel #21
0
 def setImage(self, path):
     self.txt.Text = path
     try:
         image = BitmapImage()
         image.BeginInit()
         image.CacheOption = BitmapCacheOption.OnLoad
         image.CreateOptions = BitmapCreateOptions.IgnoreImageCache
         image.UriSource = Uri(path)
         image.EndInit()
         self.img.Source = image
     except:
         pass
Beispiel #22
0
def add_radio_group(panel):
    """add radio button group"""
    radio_data = RadioButtonGroupData("radioGroup")
    radio_button_group = panel.AddItem(radio_data)

    tb1 = ToggleButtonData("toggleButton1", "Red")
    tb1.ToolTip = "Red Option"
    tb1.LargeImage = BitmapImage(
        Uri(os.path.join(EXAMPLES_PATH, 'StartupScripts', 'red.png')))

    tb2 = ToggleButtonData("toggleButton2", "Green")
    tb2.ToolTip = "Green Option"
    tb2.LargeImage = BitmapImage(
        Uri(os.path.join(EXAMPLES_PATH, 'StartupScripts', 'green.png')))

    tb3 = ToggleButtonData("toggleButton3", "Blue")
    tb3.ToolTip = "Blue Option"
    tb3.LargeImage = BitmapImage(
        Uri(os.path.join(EXAMPLES_PATH, 'StartupScripts', 'blue.png')))

    radio_button_group.AddItem(tb1)
    radio_button_group.AddItem(tb2)
    radio_button_group.AddItem(tb3)
 def add_image(self):
     """Добавляем картинку."""
     self.button.LargeImage = BitmapImage()
     stream = File.OpenRead(self.image)
     self.button.LargeImage.BeginInit()
     self.button.LargeImage.CacheOption = BitmapCacheOption.OnLoad
     self.button.LargeImage.StreamSource = stream
     self.button.LargeImage.DecodePixelHeight = 32
     self.button.LargeImage.DecodePixelWidth = 32
     self.button.LargeImage.EndInit()
     self.button.LargeImage.Freeze()
     stream.Close()
     stream.Dispose()
     stream = File.OpenRead(self.image)
     self.button.Image = BitmapImage()
     self.button.Image.BeginInit()
     self.button.Image.CacheOption = BitmapCacheOption.OnLoad
     self.button.Image.StreamSource = stream
     self.button.Image.DecodePixelHeight = 16
     self.button.Image.DecodePixelWidth = 16
     self.button.Image.EndInit()
     self.button.LargeImage.Freeze()
     stream.Close()
     stream.Dispose()
Beispiel #24
0
 def __init__(self, cfg):
     self.path = os.path.dirname(os.path.abspath(__file__))
     basename = os.path.basename(os.path.abspath(__file__)).split('.')[0]
     wpf.LoadComponent(self, os.path.join(self.path, basename + '.xaml'))
     self.Icon = BitmapImage(Uri(os.path.join(self.path, 'icon.ico')))
     self.config_file = os.path.join(self.path, cfg)
     self.config_file = cfg
     self.configuration = {}
     self.canvas = self.FindName("Canvas")
     self.started = False
     self.mask = []
     self.objects = []
     self.base = None
     self.ball = None
     self.floor = None
     #START Configuration file
     with open(self.config_file) as f:
         for l in f:
             if l.startswith('#') or l.startswith('\n'):
                 pass
             elif l.startswith('[blocks]'):
                 for l in f:
                     d = l.strip()
                     length = len(d)
                     row = []
                     for x in d:
                         if x == '@':
                             row.append(1)
                         elif x == 'x':
                             row.append(0)
                         else:
                             pass
                     self.mask.append(row)
             else:
                 kv = [x.strip() for x in l.split('=')]
                 self.configuration[kv[0].lower()] = int(kv[1])
     self.Width = self.configuration['width']
     self.Height = self.configuration['height']
     #END Configuration file
     self.timers = {
         'ball':
         self.create_timer(self.ball_timer,
                           1000 / self.configuration['fps']),
         'base':
         self.create_timer(self.base_timer,
                           1000 / self.configuration['fps'])
     }
Beispiel #25
0
 def __init__(self):
     wpf.LoadComponent(self, xamlfile)
     
     self.Icon = BitmapImage(Uri(dir_name + "\\portcoast.ico", UriKind.Relative))
     
     global viewType_Source
     viewType_Source = get_ViewType(doc)
     global viewType_Source_Name
     viewType_Source_Name = map(lambda x: x.Name, viewType_Source)
     self.cbbViewType.ItemsSource = viewType_Source_Name
     self.cbbViewType2.ItemsSource = viewType_Source_Name
     global view_Source
     view_Collector = DB.FilteredElementCollector(doc).\
                     OfCategory(OST_Views).ToElements()
     view_Source = map(lambda x: x, view_Collector)
     global view_Source_Name
     view_Source_Name = map(lambda i: "{}: {}".\
                            format(i.ViewType, i.Name) ,view_Source)
     
     self.lbViewNames.ItemsSource = view_Source_Name
Beispiel #26
0
 def __init__(self, h):
     self.ctrl = Button()
     self.Initialize(h)
     if h.get('fontsize'): self.SetFontSize(h['fontsize'])
     if h.get('handler'): self.ctrl.Click += h['handler']
     stack = StackPanel()
     stack.Orientation = Orientation.Vertical  #Horizontal
     self.ctrl.Content = stack
     if h.get('image'):
         image = Image()
         image.Source = BitmapImage(
             System.Uri(h['image'], System.UriKind.Relative))
         image.VerticalAlignment = VerticalAlignment.Center
         image.Stretch = Stretch.Fill  #Stretch.None
         if h.get('size'):
             image.Height = float(h['size'])
             image.Width = float(h['size'])
         stack.Children.Add(image)
     if h.get('label'):
         text = TextBlock()
         text.Text = h['label']
         text.TextAlignment = TextAlignment.Center
         stack.Children.Add(text)
Beispiel #27
0
 def __init__(self, filedir, filename):
     uri = Uri(op.join(filedir, filename))
     self.smallBitmap = BitmapImage()
     self.smallBitmap.BeginInit()
     self.smallBitmap.UriSource = uri
     self.smallBitmap.CacheOption = BitmapCacheOption.OnLoad
     self.smallBitmap.DecodePixelHeight = 16
     self.smallBitmap.DecodePixelWidth = 16
     self.smallBitmap.EndInit()
     self.mediumBitmap = BitmapImage()
     self.mediumBitmap.BeginInit()
     self.mediumBitmap.UriSource = uri
     self.mediumBitmap.CacheOption = BitmapCacheOption.OnLoad
     self.mediumBitmap.DecodePixelHeight = 24
     self.mediumBitmap.DecodePixelWidth = 24
     self.mediumBitmap.EndInit()
     self.largeBitmap = BitmapImage()
     self.largeBitmap.BeginInit()
     self.largeBitmap.UriSource = uri
     self.largeBitmap.CacheOption = BitmapCacheOption.OnLoad
     self.largeBitmap.EndInit()
    def lbImgs_SelectionChanged(self, sender, e):
        index = self.lbImgs.SelectedIndex
        print(index)
        path = "G:\\Projects\\Bachelor Project\\RetinaSegmentation\\RetinaSegmentation\\DataSet\\"

        self.rbGradable.IsChecked = True
        if index == 0:
            self.rbGrade0_Normal.IsChecked = True
            self.rbHEIDRiD_04.IsChecked = self.rbIDRiD_06.IsChecked = self.rbIDRiD_08.IsChecked = self.rbIDRiD_24.IsChecked = self.rbIDRiD_31.IsChecked = self.rbIDRiD_32.IsChecked = self.rbIDRiD_35.IsChecked = self.rbIDRiD_37.IsChecked = self.rbIDRiD_44.IsChecked = self.rbMAIDRiD_04.IsChecked = self.rbSEIDRiD_32.IsChecked = self.rbSEIDRiD_35.IsChecked = False

            self.rbNotGradable.IsChecked = True
            self.img.Source = BitmapImage(Uri(path + "Grade0_Normal.jpg"))
            self.imgResult.Source = BitmapImage(Uri(path +
                                                    "Grade0_Normal.jpg"))
            self.cbHemorrhage.IsChecked = self.cbMicroaneurysm.IsChecked = self.cbSoftExudates.IsChecked = self.cbHardExudates.IsChecked = False

        elif index == 1:
            self.rbIDRiD_32.IsChecked = True
            self.rbGrade0_Normal.IsChecked = self.rbHEIDRiD_04.IsChecked = self.rbIDRiD_06.IsChecked = self.rbIDRiD_08.IsChecked = self.rbIDRiD_24.IsChecked = self.rbIDRiD_31.IsChecked = self.rbIDRiD_35.IsChecked = self.rbIDRiD_37.IsChecked = self.rbIDRiD_44.IsChecked = self.rbMAIDRiD_04.IsChecked = self.rbSEIDRiD_32.IsChecked = self.rbSEIDRiD_35.IsChecked = False

            self.img.Source = BitmapImage(Uri(path + "HardEx\\IDRiD_32.jpg"))
            self.imgResult.Source = BitmapImage(
                Uri(path + "HardEx\\IDRiD_32_EX.tif"))
            self.cbHemorrhage.IsChecked = self.cbMicroaneurysm.IsChecked = self.cbSoftExudates.IsChecked = self.cbHardExudates.IsChecked = False
            self.cbHardExudates.IsChecked = True

        elif index == 2:
            self.rbIDRiD_35.IsChecked = True
            self.rbGrade0_Normal.IsChecked = self.rbHEIDRiD_04.IsChecked = self.rbIDRiD_06.IsChecked = self.rbIDRiD_08.IsChecked = self.rbIDRiD_24.IsChecked = self.rbIDRiD_31.IsChecked = self.rbIDRiD_32.IsChecked = self.rbIDRiD_37.IsChecked = self.rbIDRiD_44.IsChecked = self.rbMAIDRiD_04.IsChecked = self.rbSEIDRiD_32.IsChecked = self.rbSEIDRiD_35.IsChecked = False

            self.img.Source = BitmapImage(Uri(path + "HardEx\\IDRiD_35.jpg"))
            self.imgResult.Source = BitmapImage(
                Uri(path + "HardEx\\IDRiD_35_EX.tif"))
            self.cbHemorrhage.IsChecked = self.cbMicroaneurysm.IsChecked = self.cbSoftExudates.IsChecked = self.cbHardExudates.IsChecked = False
            self.cbHardExudates.IsChecked = True

        elif index == 3:
            self.rbIDRiD_37.IsChecked = True
            self.rbGrade0_Normal.IsChecked = self.rbHEIDRiD_04.IsChecked = self.rbIDRiD_06.IsChecked = self.rbIDRiD_08.IsChecked = self.rbIDRiD_24.IsChecked = self.rbIDRiD_31.IsChecked = self.rbIDRiD_32.IsChecked = self.rbIDRiD_35.IsChecked = self.rbIDRiD_44.IsChecked = self.rbMAIDRiD_04.IsChecked = self.rbSEIDRiD_32.IsChecked = self.rbSEIDRiD_35.IsChecked = False

            self.img.Source = BitmapImage(Uri(path + "HardEx\\IDRiD_37.jpg"))
            self.imgResult.Source = BitmapImage(
                Uri(path + "HardEx\\IDRiD_37_EX.tif"))
            self.cbHemorrhage.IsChecked = self.cbMicroaneurysm.IsChecked = self.cbSoftExudates.IsChecked = self.cbHardExudates.IsChecked = False
            self.cbHardExudates.IsChecked = True

        elif index == 4:
            self.rbHEIDRiD_04.IsChecked = True
            self.rbGrade0_Normal.IsChecked = self.rbIDRiD_37.IsChecked = self.rbIDRiD_06.IsChecked = self.rbIDRiD_08.IsChecked = self.rbIDRiD_24.IsChecked = self.rbIDRiD_31.IsChecked = self.rbIDRiD_32.IsChecked = self.rbIDRiD_35.IsChecked = self.rbIDRiD_44.IsChecked = self.rbMAIDRiD_04.IsChecked = self.rbSEIDRiD_32.IsChecked = self.rbSEIDRiD_35.IsChecked = False

            self.img.Source = BitmapImage(Uri(path + "HE\\IDRiD_04.jpg"))
            self.imgResult.Source = BitmapImage(
                Uri(path + "HE\\IDRiD_04_HE.tif"))
            self.cbHemorrhage.IsChecked = self.cbMicroaneurysm.IsChecked = self.cbSoftExudates.IsChecked = self.cbHardExudates.IsChecked = False
            self.cbHemorrhage.IsChecked = True

        elif index == 5:
            self.rbIDRiD_06.IsChecked = True
            self.rbGrade0_Normal.IsChecked = self.rbIDRiD_37.IsChecked = self.rbHEIDRiD_04.IsChecked = self.rbIDRiD_08.IsChecked = self.rbIDRiD_24.IsChecked = self.rbIDRiD_31.IsChecked = self.rbIDRiD_32.IsChecked = self.rbIDRiD_35.IsChecked = self.rbIDRiD_44.IsChecked = self.rbMAIDRiD_04.IsChecked = self.rbSEIDRiD_32.IsChecked = self.rbSEIDRiD_35.IsChecked = False

            self.img.Source = BitmapImage(Uri(path + "HE\\IDRiD_06.jpg"))
            self.imgResult.Source = BitmapImage(
                Uri(path + "HE\\IDRiD_06_HE.tif"))
            self.cbHemorrhage.IsChecked = self.cbMicroaneurysm.IsChecked = self.cbSoftExudates.IsChecked = self.cbHardExudates.IsChecked = False
            self.cbHemorrhage.IsChecked = True

        elif index == 6:
            self.rbIDRiD_08.IsChecked = True
            self.rbGrade0_Normal.IsChecked = self.rbIDRiD_37.IsChecked = self.rbHEIDRiD_04.IsChecked = self.rbIDRiD_06.IsChecked = self.rbIDRiD_24.IsChecked = self.rbIDRiD_31.IsChecked = self.rbIDRiD_32.IsChecked = self.rbIDRiD_35.IsChecked = self.rbIDRiD_44.IsChecked = self.rbMAIDRiD_04.IsChecked = self.rbSEIDRiD_32.IsChecked = self.rbSEIDRiD_35.IsChecked = False

            self.img.Source = BitmapImage(Uri(path + "HE\\IDRiD_08.jpg"))
            self.imgResult.Source = BitmapImage(
                Uri(path + "HE\\IDRiD_08_HE.tif"))
            self.cbHemorrhage.IsChecked = self.cbMicroaneurysm.IsChecked = self.cbSoftExudates.IsChecked = self.cbHardExudates.IsChecked = False
            self.cbHemorrhage.IsChecked = True

        elif index == 7:
            self.rbMAIDRiD_04.IsChecked = True
            self.rbGrade0_Normal.IsChecked = self.rbIDRiD_37.IsChecked = self.rbHEIDRiD_04.IsChecked = self.rbIDRiD_06.IsChecked = self.rbIDRiD_08.IsChecked = self.rbIDRiD_24.IsChecked = self.rbIDRiD_31.IsChecked = self.rbIDRiD_32.IsChecked = self.rbIDRiD_35.IsChecked = self.rbIDRiD_44.IsChecked = self.rbSEIDRiD_32.IsChecked = self.rbSEIDRiD_35.IsChecked = False

            self.img.Source = BitmapImage(Uri(path + "MA\\IDRiD_04.jpg"))
            self.imgResult.Source = BitmapImage(
                Uri(path + "MA\\IDRiD_04_MA.tif"))
            self.cbHemorrhage.IsChecked = self.cbMicroaneurysm.IsChecked = self.cbSoftExudates.IsChecked = self.cbHardExudates.IsChecked = False
            self.cbMicroaneurysm.IsChecked = True

        elif index == 8:
            self.rbIDRiD_24.IsChecked = True
            self.rbGrade0_Normal.IsChecked = self.rbIDRiD_37.IsChecked = self.rbHEIDRiD_04.IsChecked = self.rbIDRiD_06.IsChecked = self.rbIDRiD_08.IsChecked = self.rbIDRiD_31.IsChecked = self.rbIDRiD_32.IsChecked = self.rbIDRiD_35.IsChecked = self.rbIDRiD_44.IsChecked = self.rbMAIDRiD_04.IsChecked = self.rbSEIDRiD_32.IsChecked = self.rbSEIDRiD_35.IsChecked = False

            self.img.Source = BitmapImage(Uri(path + "MA\\IDRiD_24.jpg"))
            self.imgResult.Source = BitmapImage(
                Uri(path + "MA\\IDRiD_24_MA.tif"))
            self.cbHemorrhage.IsChecked = self.cbMicroaneurysm.IsChecked = self.cbSoftExudates.IsChecked = self.cbHardExudates.IsChecked = False
            self.cbMicroaneurysm.IsChecked = True

        elif index == 9:
            self.rbIDRiD_44.IsChecked = True
            self.rbGrade0_Normal.IsChecked = self.rbIDRiD_37.IsChecked = self.rbHEIDRiD_04.IsChecked = self.rbIDRiD_06.IsChecked = self.rbIDRiD_08.IsChecked = self.rbIDRiD_24.IsChecked = self.rbIDRiD_31.IsChecked = self.rbIDRiD_32.IsChecked = self.rbIDRiD_35.IsChecked = self.rbMAIDRiD_04.IsChecked = self.rbSEIDRiD_32.IsChecked = self.rbSEIDRiD_35.IsChecked = False

            self.img.Source = BitmapImage(Uri(path + "MA\\IDRiD_44.jpg"))
            self.imgResult.Source = BitmapImage(
                Uri(path + "MA\\IDRiD_44_MA.tif"))
            self.cbHemorrhage.IsChecked = self.cbMicroaneurysm.IsChecked = self.cbSoftExudates.IsChecked = self.cbHardExudates.IsChecked = False
            self.cbMicroaneurysm.IsChecked = True

        elif index == 10:
            self.rbIDRiD_31.IsChecked = True
            self.rbGrade0_Normal.IsChecked = self.rbIDRiD_37.IsChecked = self.rbHEIDRiD_04.IsChecked = self.rbIDRiD_06.IsChecked = self.rbIDRiD_08.IsChecked = self.rbIDRiD_24.IsChecked = self.rbIDRiD_32.IsChecked = self.rbIDRiD_35.IsChecked = self.rbIDRiD_44.IsChecked = self.rbMAIDRiD_04.IsChecked = self.rbSEIDRiD_32.IsChecked = self.rbSEIDRiD_35.IsChecked = False

            self.img.Source = BitmapImage(Uri(path + "SoftEx\\IDRiD_31.jpg"))
            self.imgResult.Source = BitmapImage(
                Uri(path + "SoftEx\\IDRiD_31_SE.tif"))
            self.cbHemorrhage.IsChecked = self.cbMicroaneurysm.IsChecked = self.cbSoftExudates.IsChecked = self.cbHardExudates.IsChecked = False
            self.cbSoftExudates.IsChecked = True

        elif index == 11:
            self.rbSEIDRiD_32.IsChecked = True
            self.rbGrade0_Normal.IsChecked = self.rbIDRiD_37.IsChecked = self.rbHEIDRiD_04.IsChecked = self.rbIDRiD_06.IsChecked = self.rbIDRiD_08.IsChecked = self.rbIDRiD_24.IsChecked = self.rbIDRiD_31.IsChecked = self.rbIDRiD_32.IsChecked = self.rbIDRiD_35.IsChecked = self.rbIDRiD_44.IsChecked = self.rbMAIDRiD_04.IsChecked = self.rbSEIDRiD_35.IsChecked = False

            self.img.Source = BitmapImage(Uri(path + "SoftEx\\IDRiD_32.jpg"))
            self.imgResult.Source = BitmapImage(
                Uri(path + "SoftEx\\IDRiD_32_SE.tif"))
            self.cbHemorrhage.IsChecked = self.cbMicroaneurysm.IsChecked = self.cbSoftExudates.IsChecked = self.cbHardExudates.IsChecked = False
            self.cbSoftExudates.IsChecked = True

        elif index == 12:
            self.rbSEIDRiD_35.IsChecked = True
            self.rbGrade0_Normal.IsChecked = self.rbIDRiD_37.IsChecked = self.rbHEIDRiD_04.IsChecked = self.rbIDRiD_06.IsChecked = self.rbIDRiD_08.IsChecked = self.rbIDRiD_24.IsChecked = self.rbIDRiD_31.IsChecked = self.rbIDRiD_32.IsChecked = self.rbIDRiD_35.IsChecked = self.rbIDRiD_44.IsChecked = self.rbMAIDRiD_04.IsChecked = self.rbSEIDRiD_32.IsChecked = False

            self.img.Source = BitmapImage(Uri(path + "SoftEx\\IDRiD_35.jpg"))
            self.imgResult.Source = BitmapImage(
                Uri(path + "SoftEx\\IDRiD_35_SE.tif"))
            self.cbHemorrhage.IsChecked = self.cbMicroaneurysm.IsChecked = self.cbSoftExudates.IsChecked = self.cbHardExudates.IsChecked = False
            self.cbSoftExudates.IsChecked = True

        self.Recommended()
Beispiel #29
0
	def onSignInClick(source, rea):
		config = None
		directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Assembly.GetEntryAssembly().GetName().Name)
		backgroundBrush = None
		textColor = SystemColors.ControlTextBrush
		
		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["BackgroundImage"] is not None:
			fileName = config.AppSettings.Settings["BackgroundImage"].Value if directory is None else Path.Combine(directory, config.AppSettings.Settings["BackgroundImage"].Value);
			fs = None
			bi = BitmapImage()

			try:
				fs = FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)

				bi.BeginInit()
				bi.StreamSource = fs
				bi.CacheOption = BitmapCacheOption.OnLoad
				bi.CreateOptions = BitmapCreateOptions.None
				bi.EndInit()

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

			backgroundBrush = ImageBrush(bi)
			backgroundBrush.TileMode = TileMode.Tile
			backgroundBrush.ViewportUnits = BrushMappingMode.Absolute
			backgroundBrush.Viewport = Rect(0, 0, bi.Width, bi.Height)
			backgroundBrush.Stretch = Stretch.None

			if backgroundBrush.CanFreeze:
				backgroundBrush.Freeze()

		if backgroundBrush is None and config.AppSettings.Settings["BackgroundColor"] is not None:
			if config.AppSettings.Settings["BackgroundColor"].Value.Length > 0:
				backgroundBrush = SolidColorBrush(ColorConverter.ConvertFromString(config.AppSettings.Settings["BackgroundColor"].Value))

				if backgroundBrush.CanFreeze:
					backgroundBrush.Freeze()

		if config.AppSettings.Settings["TextColor"] is not None:
			if config.AppSettings.Settings["TextColor"].Value.Length > 0:
				textColor = ColorConverter.ConvertFromString(config.AppSettings.Settings["TextColor"].Value)
				
		textBrush = SolidColorBrush(textColor)

		if textBrush.CanFreeze:
			textBrush.Freeze()

		window = Window()


			
		


		def onClick(source, args):
			global username, password

			if not String.IsNullOrEmpty(usernameTextBox.Text) and not String.IsNullOrEmpty(passwordBox.Password):
				username = usernameTextBox.Text
				password = passwordBox.Password

				def onSave():
					try:
						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(Regex.Replace(sr.ReadToEnd(), "username\\s*=\\s*\"\"", String.Format("username = \"{0}\"", username), RegexOptions.CultureInvariant), "password\\s*=\\s*\"\"", String.Format("password = \"{0}\"", password), 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 menuItem
	
					for window in Application.Current.Windows:
						if window is Application.Current.MainWindow and window.ContextMenu is not None:
							if window.ContextMenu.Items.Contains(menuItem):
								window.ContextMenu.Items.Remove(menuItem)
								window.ContextMenu.Opened -= onOpened
								
								if window.ContextMenu.Items[10].GetType().IsInstanceOfType(window.ContextMenu.Items[window.ContextMenu.Items.Count - 4]):
									window.ContextMenu.Items.RemoveAt(10)

					menuItem = None

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

			window.Close()
    def SetupFields(self, newbook, oldbook, renamefile, count):

        self.win.FindName("RenameText").Text = self.RenameText + renamefile

        if type(newbook) != FileInfo:
            #oldbook can be either a ComicBook object or a FileInfo object
            self.win.FindName("NewSeries").Content = newbook.ShadowSeries
            self.win.FindName("NewVolume").Content = newbook.ShadowVolume
            self.win.FindName("NewNumber").Content = newbook.ShadowNumber
            self.win.FindName("NewPages").Content = newbook.PageCount
            self.win.FindName("NewFileSize").Content = newbook.FileSizeAsText
            self.win.FindName(
                "NewPublishedDate"
            ).Content = newbook.MonthAsText + ", " + newbook.YearAsText
            self.win.FindName("NewAddedDate").Content = newbook.AddedTime
            self.win.FindName("NewPath").Text = newbook.FilePath
            self.win.FindName("NewScanInfo").Content = newbook.ScanInformation

            #Load the new book cover
            ncs = MemoryStream()
            ComicRack.App.GetComicThumbnail(newbook,
                                            newbook.PreferredFrontCover).Save(
                                                ncs, ImageFormat.Png)
            ncs.Position = 0
            newcover = BitmapImage()
            newcover.BeginInit()
            newcover.StreamSource = ncs
            newcover.EndInit()
            self.win.FindName("NewCover").Source = newcover
        else:
            self.win.FindName("NewSeries").Content = "Comic not in Library"
            self.win.FindName("NewVolume").Content = ""
            self.win.FindName("NewNumber").Content = ""
            self.win.FindName("NewPages").Content = ""
            self.win.FindName("NewFileSize").Content = '%.2f MB' % (
                newbook.Length / 1048576.0)  #Calculate bytes to MB
            self.win.FindName("NewPublishedDate").Content = ""
            self.win.FindName("NewAddedDate").Content = ""
            self.win.FindName("NewScanInfo").Content = ""
            self.win.FindName("NewPath").Text = newbook.FullName
            self.win.FindName("NewCover").Source = None

        #old book, possible for it to be a FileInfo object
        if type(oldbook) != FileInfo:
            self.win.FindName("OldSeries").Content = oldbook.ShadowSeries
            self.win.FindName("OldVolume").Content = oldbook.ShadowVolume
            self.win.FindName("OldNumber").Content = oldbook.ShadowNumber
            self.win.FindName("OldPages").Content = oldbook.PageCount
            self.win.FindName("OldFileSize").Content = oldbook.FileSizeAsText
            self.win.FindName(
                "OldPublishedDate"
            ).Content = oldbook.MonthAsText + ", " + oldbook.YearAsText
            self.win.FindName("OldAddedDate").Content = oldbook.AddedTime
            self.win.FindName("OldScanInfo").Content = oldbook.ScanInformation
            self.win.FindName("OldPath").Text = oldbook.FilePath

            #cover
            ocs = MemoryStream()
            ComicRack.App.GetComicThumbnail(oldbook,
                                            oldbook.PreferredFrontCover).Save(
                                                ocs, ImageFormat.Png)
            ncs.Position = 0
            oldcover = BitmapImage()
            oldcover.BeginInit()
            oldcover.StreamSource = ocs
            oldcover.EndInit()
            self.win.FindName("OldCover").Source = oldcover

        else:
            self.win.FindName("OldSeries").Content = "Comic not in Library"
            self.win.FindName("OldVolume").Content = ""
            self.win.FindName("OldNumber").Content = ""
            self.win.FindName("OldPages").Content = ""
            self.win.FindName("OldFileSize").Content = '%.2f MB' % (
                oldbook.Length / 1048576.0)  #Calculate bytes to MB
            self.win.FindName("OldPublishedDate").Content = ""
            self.win.FindName("OldAddedDate").Content = ""
            self.win.FindName("OldScanInfo").Content = ""
            self.win.FindName("OldPath").Text = oldbook.FullName
            self.win.FindName("OldCover").Source = None

        if count > 1:
            self.win.FindName("DoAll").Visibility = Visibility.Visible
            self.win.FindName(
                "DoAll"
            ).Content = "Do this for all conficts (" + str(count) + ")"
        else:
            self.win.FindName("DoAll").Visibility = Visibility.Hidden
Beispiel #31
0
	def onCompleted(task):
		global idList

		if task.Result.Key.Count > 0:
			sequenceList = List[Sequence]()

			for sequence in Script.Instance.Sequences:
				if sequence.Name.Equals("Weather"):
					sequenceList.Add(sequence)

			for s in task.Result.Key:
				Script.Instance.TryEnqueue(Script.Instance.Prepare(sequenceList, s))

		if Application.Current.MainWindow.IsVisible and task.Result.Value.Value.Value.Value.Count > 0 and not Enumerable.SequenceEqual[Double](idList, task.Result.Value.Value.Value.Key):
			width = 128
			height = 128
			max = 4
			window = Window()
			contentControl = ContentControl()
			grid = Grid()
			storyboard = Storyboard()

			def onCurrentStateInvalidated(sender, args):
				if sender.CurrentState == ClockState.Filling:
					window.Close()

			storyboard.CurrentStateInvalidated += onCurrentStateInvalidated
		
			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()
			
			fs = None
			bi = BitmapImage()

			try:
				fs = FileStream("Assets\\Background-Popup.png", FileMode.Open, FileAccess.Read, FileShare.Read)

				bi.BeginInit()
				bi.StreamSource = fs
				bi.CacheOption = BitmapCacheOption.OnLoad
				bi.CreateOptions = BitmapCreateOptions.None
				bi.EndInit()

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

			window.Owner = Application.Current.MainWindow
			window.Title = Application.Current.MainWindow.Title
			window.WindowStartupLocation = WindowStartupLocation.CenterOwner
			window.AllowsTransparency = True
			window.WindowStyle = WindowStyle.None
			window.ResizeMode = ResizeMode.NoResize
			window.ShowActivated = False
			window.ShowInTaskbar = Application.Current.MainWindow.ContextMenu.Items[5].IsChecked
			window.Topmost = True
			window.SizeToContent = SizeToContent.WidthAndHeight
			window.Background = Brushes.Transparent
			window.Loaded += onLoaded
			
			contentControl.UseLayoutRounding = True
			contentControl.HorizontalAlignment = HorizontalAlignment.Stretch
			contentControl.VerticalAlignment = VerticalAlignment.Stretch
			contentControl.Opacity = 0
			contentControl.RenderTransform = ScaleTransform(1, 1)

			window.Content = contentControl

			imageBrush = ImageBrush(bi)
			imageBrush.TileMode = TileMode.None
			imageBrush.Stretch = Stretch.Fill
			imageBrush.ViewboxUnits = BrushMappingMode.Absolute
			imageBrush.Viewbox = Rect(0, 0, bi.Width, bi.Height)
			imageBrush.AlignmentX = AlignmentX.Left
			imageBrush.AlignmentY = AlignmentY.Top
			imageBrush.Opacity = 0.5

			dg = DrawingGroup()
			dc = dg.Open()
			dc.DrawRectangle(SolidColorBrush(Color.FromArgb(Byte.MaxValue * 50 / 100, 0, 0, 0)), None, Rect(0, 0, bi.Width, bi.Height))
			dc.DrawRectangle(imageBrush, None, Rect(0, 0, bi.Width, bi.Height))
			dc.Close()

			backgroundBrush = ImageBrush(DrawingImage(dg))
			backgroundBrush.TileMode = TileMode.Tile
			backgroundBrush.ViewportUnits = BrushMappingMode.Absolute
			backgroundBrush.Viewport = Rect(0, 0, bi.Width, bi.Height)
			backgroundBrush.Stretch = Stretch.None

			if backgroundBrush.CanFreeze:
				backgroundBrush.Freeze()

			grid.HorizontalAlignment = HorizontalAlignment.Stretch
			grid.VerticalAlignment = VerticalAlignment.Stretch
			grid.Background = backgroundBrush
			grid.Width = 150
			grid.Height = 150
			grid.Clip = EllipseGeometry(Rect(0, 0, 150, 150))

			dropShadowEffect = DropShadowEffect()
			dropShadowEffect.BlurRadius = 1
			dropShadowEffect.Color = Colors.Black
			dropShadowEffect.Direction = 270
			dropShadowEffect.Opacity = 0.5
			dropShadowEffect.ShadowDepth = 1

			if dropShadowEffect.CanFreeze:
				dropShadowEffect.Freeze()

			grid.Effect = dropShadowEffect

			contentControl.Content = grid

			solidColorBrush = SolidColorBrush(colorFromAhsb(Byte.MaxValue, 60, 1.0, 1.0) if task.Result.Value.Key < 0 else colorFromAhsb(Byte.MaxValue, 0, 1.0, 0.4) if task.Result.Value.Key > 37 else colorFromAhsb(Byte.MaxValue, 60 - 60 * task.Result.Value.Key / 37, 1.0, 0.4 + 0.6 * Math.Pow(Math.E, (37 / 5 - task.Result.Value.Key) - 37 / 5) if task.Result.Value.Key < 37 / 5 else 0.4))

			if solidColorBrush.CanFreeze:
				solidColorBrush.Freeze()


			for stream in task.Result.Value.Value.Value.Value:
				try:
					bi = BitmapImage()
					bi.BeginInit()
					bi.StreamSource = stream
					bi.CacheOption = BitmapCacheOption.OnLoad
					bi.CreateOptions = BitmapCreateOptions.None
					bi.EndInit()

				finally:
					stream.Close()

				imageBrush = ImageBrush(bi)
				imageBrush.TileMode = TileMode.None
				imageBrush.ViewportUnits = BrushMappingMode.Absolute
				imageBrush.Viewport = Rect(0, 0, width, height)
				imageBrush.Stretch = Stretch.Uniform

				if imageBrush.CanFreeze:
					imageBrush.Freeze()

				g = Grid()
				g.HorizontalAlignment = HorizontalAlignment.Center
				g.VerticalAlignment = VerticalAlignment.Center
				g.Background = Brushes.Transparent
				g.Width = width
				g.Height = height

				grid.Children.Add(g)

				for i in range(max):
					rectangle = Rectangle()
					rectangle.HorizontalAlignment = HorizontalAlignment.Left
					rectangle.VerticalAlignment = VerticalAlignment.Top
					rectangle.Width = width
					rectangle.Height = height
					rectangle.Fill = solidColorBrush
					rectangle.Opacity = 0
					rectangle.OpacityMask = imageBrush
					rectangle.Clip = RectangleGeometry(Rect(0, height / max * i, width, height / max))
					rectangle.RenderTransform = TranslateTransform(0, 0)
					rectangle.Tag = i
					
					g.Children.Add(rectangle)

			window.Show()

			idList.Clear()
			idList.AddRange(task.Result.Value.Value.Value.Key)
Beispiel #32
0
class MainWindow(Window):
    def __init__(self):
        self.gui = wpf.LoadComponent(self, 'SkeletalViewer.xaml')
        #self.create_runtime()

        self.Loaded += self.on_loaded
        self.Closing += self.on_closing

        self.thinkBubble = BitmapImage()
        self.thinkBubble.BeginInit()
        self.thinkBubble.UriSource = Uri("think2.png", UriKind.Relative)
        self.thinkBubble.CacheOption = BitmapCacheOption.OnLoad
        #self.thinkBubble.Height = 150
        #self.thinkBubble.Width = 150
        self.thinkBubble.EndInit()

        self.lastX = 0.0
        self.lastY = 300.0
        self.foundHead = False

    def on_loaded(self, s, e):
        self.nui = Runtime()

        if not self.nui:
            MessageBox.Show(
                "Runtime initialization failed. Please make sure Kinect device is plugged in."
            )
            return

        self.nui.Initialize(RuntimeOptions.UseSkeletalTracking)
        self.nui.SkeletonFrameReady += self.nui_skeleton_frame_ready

    def getDisplayPosition(self, joint):
        depthX, depthY = self.nui.SkeletonEngine.SkeletonToDepthImage(
            joint.Position)
        depthX = depthX * 320
        depthY = depthY * 240
        iv = ImageViewArea()

        # only ImageResolution.Resolution640x480 is supported at this point
        colorX, colorY = self.nui.NuiCamera.GetColorPixelCoordinatesFromDepthPixel(
            ImageResolution.Resolution640x480, iv, depthX, depthY, 0)

        # map back to skeleton.Width & skeleton.Height
        return Point((self.skeleton.Width * colorX / 640.0),
                     (self.skeleton.Height * colorY / 480))

    def nui_skeleton_frame_ready(self, sender, e):
        skeletonFrame = e.SkeletonFrame
        self.skeleton.Children.Clear()

        for data in skeletonFrame.Skeletons:
            if SkeletonTrackingState.Tracked == data.TrackingState:
                for joint in data.Joints:
                    if joint.ID == JointID.Head:
                        jointPos = self.getDisplayPosition(joint)

                        self.lastX = jointPos.X
                        self.foundHead = True

        if self.foundHead:
            bubble = Image()
            #imageSource = System.Windows.Resources["think"]
            bubble.Source = self.thinkBubble
            bubble.SetValue(Canvas.TopProperty, self.lastY)
            bubble.SetValue(Canvas.LeftProperty, self.lastX)
            self.skeleton.Children.Add(bubble)

            text = TextBox()
            text.Text = "Hello World!"
            text.FontSize = 50
            text.FontWeight = FontWeights.Bold
            text.BorderThickness = Thickness(0)
            text.SetValue(Canvas.TopProperty, self.lastY + 120)
            text.SetValue(Canvas.LeftProperty, self.lastX + 60)
            self.skeleton.Children.Add(text)

    def on_closing(self, s, e):
        self.nui.Uninitialize()
Beispiel #33
0
    def onSignInClick(source, rea):
        config = None
        directory = Path.Combine(
            Environment.GetFolderPath(
                Environment.SpecialFolder.ApplicationData),
            Assembly.GetEntryAssembly().GetName().Name)
        backgroundBrush = None
        textColor = SystemColors.ControlTextBrush

        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["BackgroundImage"] is not None:
            fileName = config.AppSettings.Settings[
                "BackgroundImage"].Value if directory is None else Path.Combine(
                    directory,
                    config.AppSettings.Settings["BackgroundImage"].Value)
            fs = None
            bi = BitmapImage()

            try:
                fs = FileStream(fileName, FileMode.Open, FileAccess.Read,
                                FileShare.Read)

                bi.BeginInit()
                bi.StreamSource = fs
                bi.CacheOption = BitmapCacheOption.OnLoad
                bi.CreateOptions = BitmapCreateOptions.None
                bi.EndInit()

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

            backgroundBrush = ImageBrush(bi)
            backgroundBrush.TileMode = TileMode.Tile
            backgroundBrush.ViewportUnits = BrushMappingMode.Absolute
            backgroundBrush.Viewport = Rect(0, 0, bi.Width, bi.Height)
            backgroundBrush.Stretch = Stretch.None

            if backgroundBrush.CanFreeze:
                backgroundBrush.Freeze()

        if backgroundBrush is None and config.AppSettings.Settings[
                "BackgroundColor"] is not None:
            if config.AppSettings.Settings["BackgroundColor"].Value.Length > 0:
                backgroundBrush = SolidColorBrush(
                    ColorConverter.ConvertFromString(
                        config.AppSettings.Settings["BackgroundColor"].Value))

                if backgroundBrush.CanFreeze:
                    backgroundBrush.Freeze()

        if config.AppSettings.Settings["TextColor"] is not None:
            if config.AppSettings.Settings["TextColor"].Value.Length > 0:
                textColor = ColorConverter.ConvertFromString(
                    config.AppSettings.Settings["TextColor"].Value)

        textBrush = SolidColorBrush(textColor)

        if textBrush.CanFreeze:
            textBrush.Freeze()

        window = Window()

        def onClick(source, args):
            global username, password

            if not String.IsNullOrEmpty(
                    usernameTextBox.Text) and not String.IsNullOrEmpty(
                        passwordBox.Password):
                username = usernameTextBox.Text
                password = passwordBox.Password

                def onSave():
                    try:
                        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(
                                Regex.Replace(
                                    sr.ReadToEnd(), "username\\s*=\\s*\"\"",
                                    String.Format("username = \"{0}\"",
                                                  username),
                                    RegexOptions.CultureInvariant),
                                "password\\s*=\\s*\"\"",
                                String.Format("password = \"{0}\"", password),
                                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 menuItem

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

                                if window.ContextMenu.Items[10].GetType(
                                ).IsInstanceOfType(window.ContextMenu.Items[
                                        window.ContextMenu.Items.Count - 4]):
                                    window.ContextMenu.Items.RemoveAt(10)

                    menuItem = None

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

            window.Close()
Beispiel #34
0
def load_img(ipath):
    return BitmapImage(Uri(os.path.join(DIR_PATH, ipath)))
Beispiel #35
0
		def onCompleted(task):
			global maxWidth, maxHeight
			
			window = Window()
			contentControl = ContentControl()
			grid1 = Grid()
			tickTimer = DispatcherTimer(DispatcherPriority.Normal)
			closeTimer = DispatcherTimer(DispatcherPriority.Background)
		
			def onLoaded(sender, args):
				global rectList, digits

				storyboard = Storyboard()

				def onCurrentStateInvalidated(sender, args):
					if sender.CurrentState == ClockState.Filling:
						for element in grid1.Children:
							element.Opacity = 1

						storyboard.Remove(contentControl)

						if not grid1.Tag:
							closeTimer.Start()

				storyboard.CurrentStateInvalidated += onCurrentStateInvalidated

				r = Random(Environment.TickCount)
				dateTime = DateTime.Now

				digits[0] = dateTime.Hour / 10
				digits[1] = dateTime.Hour % 10
				digits[2] = dateTime.Minute / 10
				digits[3] = dateTime.Minute % 10
				digits[4] = dateTime.Second / 10
				digits[5] = dateTime.Second % 10

				for i in range(digits.Length):
					beginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(r.Next(500)))

					for element1 in grid1.Children:
						if Grid.GetColumn(element1) == i:
							doubleAnimation = DoubleAnimation(element1.Opacity, 1, TimeSpan.FromMilliseconds(500))
							doubleAnimation.BeginTime = beginTime
							sineEase = SineEase()

							sineEase.EasingMode = EasingMode.EaseOut
							doubleAnimation.EasingFunction = sineEase

							storyboard.Children.Add(doubleAnimation)
								
							Storyboard.SetTarget(doubleAnimation, element1)
							Storyboard.SetTargetProperty(doubleAnimation, PropertyPath(UIElement.OpacityProperty))

							if Grid.GetRow(element1) == 0:
								scale1 = Math.Max(element1.ActualWidth / maxWidth, element1.ActualHeight / maxHeight)

								if rectList[digits[Grid.GetColumn(element1)]].Width > maxWidth and rectList[digits[Grid.GetColumn(element1)]].Height > maxHeight:
									translateX = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].X + (rectList[digits[Grid.GetColumn(element1)]].Width - maxWidth) / 2.0))
									translateY = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].Y + (rectList[digits[Grid.GetColumn(element1)]].Height - maxHeight) / 2.0))

								elif rectList[digits[Grid.GetColumn(element1)]].Width > maxWidth:
									translateX = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].X + (rectList[digits[Grid.GetColumn(element1)]].Width - maxWidth) / 2.0))
									translateY = Math.Round(-rectList[digits[Grid.GetColumn(element1)]].Y)

								elif rectList[digits[Grid.GetColumn(element1)]].Height > maxHeight:
									translateX = Math.Round(-rectList[digits[Grid.GetColumn(element1)]].X)
									translateY = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].Y + (rectList[digits[Grid.GetColumn(element1)]].Height - maxHeight) / 2.0))

								else:
									translateX = Math.Round(-rectList[digits[Grid.GetColumn(element1)]].X)
									translateY = Math.Round(-rectList[digits[Grid.GetColumn(element1)]].Y)

								scale2 = Math.Max(maxWidth / rectList[digits[Grid.GetColumn(element1)]].Width, maxHeight / rectList[digits[Grid.GetColumn(element1)]].Height)

								if scale2 > 1:
									scale2 = 1

								for element2 in element1.Child.Children:
									transformGroup1 = TransformGroup()
									transformGroup1.Children.Add(TranslateTransform((element2.ActualWidth - maxWidth) / 2, (element2.ActualHeight - maxHeight) / 2))
									transformGroup1.Children.Add(ScaleTransform(scale1, scale1, element2.ActualWidth / 2, element2.ActualHeight / 2))
				
									element2.RenderTransform = transformGroup1
									
									for element3 in element2.Children:
										transformGroup2 = TransformGroup()
										transformGroup2.Children.Add(TranslateTransform(translateX, translateY))
										transformGroup2.Children.Add(ScaleTransform(scale2, scale2, maxWidth / 2, maxHeight / 2))
				
										element3.RenderTransform = transformGroup2

				contentControl.BeginStoryboard(storyboard, HandoffBehavior.SnapshotAndReplace, True)

				tickTimer.Start()

			def onWindowMouseEnter(sender, args):
				closeTimer.Stop()
				grid1.Tag = True

			def onWindowMouseLeave(sender, args):
				if closeTimer.Tag:
					closeTimer.Start()

				grid1.Tag = False

			def onTick(sender, args):
				global rectList, digits

				if rectList.Count > 0:
					dateTime = DateTime.Now

					for element1 in grid1.Children:
						if Grid.GetRow(element1) == 0:
							if Grid.GetColumn(element1) == 0:
								digit = dateTime.Hour / 10
							elif Grid.GetColumn(element1) == 1:
								digit = dateTime.Hour % 10
							elif Grid.GetColumn(element1) == 2:
								digit = dateTime.Minute / 10
							elif Grid.GetColumn(element1) == 3:
								digit = dateTime.Minute % 10
							elif Grid.GetColumn(element1) == 4:
								digit = dateTime.Second / 10
							else:
								digit = dateTime.Second % 10

							if digit != digits[Grid.GetColumn(element1)]:
								for element2 in element1.Child.Children:
									for element3 in element2.Children:
										storyboard = Storyboard()

										for transform in element3.RenderTransform.Children:
											if clr.GetClrType(TranslateTransform).IsInstanceOfType(transform):
												if rectList[digit].Width > maxWidth and rectList[digit].Height > maxHeight:
													translateX = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].X + (rectList[digit].X + (rectList[digit].Width - maxWidth) / 2.0 - rectList[digits[Grid.GetColumn(element1)]].X)))
													translateY = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].Y + (rectList[digit].Y + (rectList[digit].Height - maxHeight) / 2.0 - rectList[digits[Grid.GetColumn(element1)]].Y)))

												elif rectList[digit].Width > maxWidth:
													translateX = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].X + (rectList[digit].X + (rectList[digit].Width - maxWidth) / 2.0 - rectList[digits[Grid.GetColumn(element1)]].X)))
													translateY = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].Y + (rectList[digit].Y - rectList[digits[Grid.GetColumn(element1)]].Y)))

												elif rectList[digit].Height > maxHeight:
													translateX = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].X + (rectList[digit].X - rectList[digits[Grid.GetColumn(element1)]].X)))
													translateY = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].Y + (rectList[digit].Y + (rectList[digit].Height - maxHeight) / 2.0 - rectList[digits[Grid.GetColumn(element1)]].Y)))

												else:
													translateX = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].X + (rectList[digit].X - rectList[digits[Grid.GetColumn(element1)]].X)))
													translateY = Math.Round(-(rectList[digits[Grid.GetColumn(element1)]].Y + (rectList[digit].Y - rectList[digits[Grid.GetColumn(element1)]].Y)))

												doubleAnimation1 = DoubleAnimation(translateX, TimeSpan.FromMilliseconds(500))
												doubleAnimation2 = DoubleAnimation(translateY, TimeSpan.FromMilliseconds(500))
												sineEase = SineEase()

												sineEase.EasingMode = EasingMode.EaseInOut
												doubleAnimation1.EasingFunction = sineEase
												doubleAnimation2.EasingFunction = sineEase

												storyboard.Children.Add(doubleAnimation1)
												storyboard.Children.Add(doubleAnimation2)
								
												Storyboard.SetTarget(doubleAnimation1, element3)
												Storyboard.SetTarget(doubleAnimation2, element3)
												Storyboard.SetTargetProperty(doubleAnimation1, PropertyPath("(0).(1)[0].(2)", Canvas.RenderTransformProperty, TransformGroup.ChildrenProperty, TranslateTransform.XProperty))
												Storyboard.SetTargetProperty(doubleAnimation2, PropertyPath("(0).(1)[0].(2)", Canvas.RenderTransformProperty, TransformGroup.ChildrenProperty, TranslateTransform.YProperty))

											else:
												scale1 = Math.Max(maxWidth / rectList[digits[Grid.GetColumn(element1)]].Width, maxHeight / rectList[digits[Grid.GetColumn(element1)]].Height)
												scale2 = Math.Max(maxWidth / rectList[digit].Width, maxHeight / rectList[digit].Height)

												if scale1 > 1:
													scale1 = 1

												if scale2 > 1:
													scale2 = 1

												transform.ScaleX = transform.ScaleY = scale1 + (scale2 - scale1)

												doubleAnimation1 = DoubleAnimation(scale1 + (scale2 - scale1), TimeSpan.FromMilliseconds(500))
												doubleAnimation2 = DoubleAnimation(scale1 + (scale2 - scale1), TimeSpan.FromMilliseconds(500))
												sineEase = SineEase()

												sineEase.EasingMode = EasingMode.EaseInOut
												doubleAnimation1.EasingFunction = sineEase
												doubleAnimation2.EasingFunction = sineEase

												storyboard.Children.Add(doubleAnimation1)
												storyboard.Children.Add(doubleAnimation2)
								
												Storyboard.SetTarget(doubleAnimation1, element3)
												Storyboard.SetTarget(doubleAnimation2, element3)
												Storyboard.SetTargetProperty(doubleAnimation1, PropertyPath("(0).(1)[1].(2)", Canvas.RenderTransformProperty, TransformGroup.ChildrenProperty, ScaleTransform.ScaleXProperty))
												Storyboard.SetTargetProperty(doubleAnimation2, PropertyPath("(0).(1)[1].(2)", Canvas.RenderTransformProperty, TransformGroup.ChildrenProperty, ScaleTransform.ScaleYProperty))

										element3.BeginStoryboard(storyboard, HandoffBehavior.SnapshotAndReplace)

								digits[Grid.GetColumn(element1)] = digit

			def onClose(sender, args):
				global digits

				closeTimer.Stop()

				storyboard = Storyboard()

				def onCurrentStateInvalidated(sender, args):
					if sender.CurrentState == ClockState.Filling:
						for element in grid1.Children:
							element.Opacity = 0

						storyboard.Remove(contentControl)
						tickTimer.Stop()
						window.Close()

				storyboard.CurrentStateInvalidated += onCurrentStateInvalidated

				r = Random(Environment.TickCount)

				for i in range(digits.Length):
					beginTime = Nullable[TimeSpan](TimeSpan.FromMilliseconds(r.Next(500)))

					for element in grid1.Children:
						if Grid.GetColumn(element) == i:
							doubleAnimation = DoubleAnimation(element.Opacity, 0, TimeSpan.FromMilliseconds(500))
							doubleAnimation.BeginTime = beginTime
							sineEase = SineEase()

							sineEase.EasingMode = EasingMode.EaseIn
							doubleAnimation.EasingFunction = sineEase

							storyboard.Children.Add(doubleAnimation)

							Storyboard.SetTarget(doubleAnimation, element)
							Storyboard.SetTargetProperty(doubleAnimation, PropertyPath(UIElement.OpacityProperty))

				contentControl.BeginStoryboard(storyboard, HandoffBehavior.SnapshotAndReplace, True)
				closeTimer.Tag = False

			tickTimer.Tick += onTick
			tickTimer.Interval = TimeSpan.FromMilliseconds(100)

			closeTimer.Tick += onClose
			closeTimer.Interval = TimeSpan.FromSeconds(3)
			closeTimer.Tag = True

			window.Owner = Application.Current.MainWindow
			window.Title = Application.Current.MainWindow.Title
			window.WindowStartupLocation = WindowStartupLocation.CenterScreen
			window.AllowsTransparency = True
			window.WindowStyle = WindowStyle.None
			window.ResizeMode = ResizeMode.NoResize
			window.ShowActivated = False
			window.ShowInTaskbar = Application.Current.MainWindow.ContextMenu.Items[5].IsChecked
			window.Topmost = True
			window.SizeToContent = SizeToContent.WidthAndHeight
			window.Background = Brushes.Transparent
			window.Loaded += onLoaded
			window.MouseEnter += onWindowMouseEnter
			window.MouseLeave += onWindowMouseLeave

			contentControl.UseLayoutRounding = True
			contentControl.HorizontalAlignment = HorizontalAlignment.Stretch
			contentControl.VerticalAlignment = VerticalAlignment.Stretch

			window.Content = contentControl

			grid1.HorizontalAlignment = HorizontalAlignment.Center
			grid1.VerticalAlignment = VerticalAlignment.Center
			grid1.Background = Brushes.Transparent
			grid1.Tag = False

			contentControl.Content = grid1

			bitmapImageList1 = List[BitmapImage]()
			bitmapImageList2 = List[BitmapImage]()
			width = 0
			height = 0

			for stream in task.Result.Key:
				try:
					bitmapImage = BitmapImage()
					bitmapImage.BeginInit()
					bitmapImage.StreamSource = stream
					bitmapImage.CacheOption = BitmapCacheOption.OnLoad
					bitmapImage.CreateOptions = BitmapCreateOptions.None
					bitmapImage.EndInit()
					
					width += bitmapImage.PixelWidth

					if bitmapImage.PixelHeight > height:
						height = bitmapImage.PixelHeight

					bitmapImageList1.Add(bitmapImage)

				finally:
					stream.Close()

			for stream in task.Result.Value:
				try:
					bitmapImage = BitmapImage()
					bitmapImage.BeginInit()
					bitmapImage.StreamSource = stream
					bitmapImage.CacheOption = BitmapCacheOption.OnLoad
					bitmapImage.CreateOptions = BitmapCreateOptions.None
					bitmapImage.EndInit()
					
					bitmapImageList2.Add(bitmapImage)

				finally:
					stream.Close()

			x = 0
			kvpList = List[KeyValuePair[Point, BitmapImage]]()

			for bitmapImage in bitmapImageList1:
				rect = Rect(x, (height - bitmapImage.PixelHeight) / 2, bitmapImage.PixelWidth, bitmapImage.PixelHeight)

				rectList.Add(rect)
				kvpList.Add(KeyValuePair[Point, BitmapImage](rect.Location, bitmapImage))

				x += bitmapImage.PixelWidth

			rowDefinition1 = RowDefinition()
			rowDefinition1.Height = GridLength(1, GridUnitType.Auto)

			grid1.RowDefinitions.Add(rowDefinition1)

			for i in range(digits.Length):
				columnDefinition = ColumnDefinition()
				columnDefinition.Width = GridLength(1, GridUnitType.Star)

				grid1.ColumnDefinitions.Add(columnDefinition)

				border = Border()
				border.HorizontalAlignment = HorizontalAlignment.Stretch
				border.VerticalAlignment = VerticalAlignment.Stretch
				border.Margin = Thickness(4)
				border.BorderBrush = Brushes.Black
				border.BorderThickness = Thickness(1)
				border.Padding = Thickness(0)
				border.Width = 160
				border.Height = 480
				border.Background = Brushes.White
				border.Opacity = 0

				grid1.Children.Add(border)
			
				Grid.SetColumn(border, i);
				Grid.SetRow(border, 0)

				grid2 = Grid()
				grid2.HorizontalAlignment = HorizontalAlignment.Stretch
				grid2.VerticalAlignment = VerticalAlignment.Stretch
				grid2.Background = Brushes.Transparent
				grid2.ClipToBounds = True

				border.Child = grid2

				grid3 = Grid()
				grid3.HorizontalAlignment = HorizontalAlignment.Left
				grid3.VerticalAlignment = VerticalAlignment.Top
				grid3.Width = 160
				grid3.Height = 480
				grid3.Background = Brushes.Transparent

				grid2.Children.Add(grid3)

				canvas = Canvas()
				canvas.HorizontalAlignment = HorizontalAlignment.Left
				canvas.VerticalAlignment = VerticalAlignment.Top
				canvas.Width = width
				canvas.Height = maxHeight
				canvas.Background = Brushes.Transparent

				grid3.Children.Add(canvas)

				for kvp in kvpList:
					image = Image()
					image.HorizontalAlignment = HorizontalAlignment.Left
					image.VerticalAlignment = VerticalAlignment.Top
					image.Source = kvp.Value
					image.Width = kvp.Value.PixelWidth
					image.Height = kvp.Value.PixelHeight
					image.Stretch = Stretch.Fill
					
					canvas.Children.Add(image)

					Canvas.SetLeft(image, kvp.Key.X)
					Canvas.SetTop(image, kvp.Key.Y)
			
			column = 1

			rowDefinition2 = RowDefinition()
			rowDefinition2.Height = GridLength(1, GridUnitType.Auto)

			grid1.RowDefinitions.Add(rowDefinition2)

			for bitmapImage in bitmapImageList2:
				image = Image()
				image.HorizontalAlignment = HorizontalAlignment.Right
				image.VerticalAlignment = VerticalAlignment.Top
				image.Margin = Thickness(0, 0, 8, 0)
				image.Source = bitmapImage
				image.Width = bitmapImage.PixelWidth / 2
				image.Height = bitmapImage.PixelHeight / 2
				image.Stretch = Stretch.Fill

				grid1.Children.Add(image)
			
				Grid.SetColumn(image, column);
				Grid.SetRow(image, 1);

				column += 2

			window.Show()
Beispiel #36
0
	def onCompleted(task):
		global idList

		if task.Result.Key.Count > 0:
			sequenceList = List[Sequence]()

			for sequence in Script.Instance.Sequences:
				if sequence.Name.Equals("Weather"):
					sequenceList.Add(sequence)

			for s in task.Result.Key:
				Script.Instance.TryEnqueue(Script.Instance.Prepare(sequenceList, s))

		if Application.Current.MainWindow.IsVisible and task.Result.Value.Value.Value.Value.Count > 0 and not Enumerable.SequenceEqual[Double](idList, task.Result.Value.Value.Value.Key):
			width = 128
			height = 128
			max = 4
			window = Window()
			contentControl = ContentControl()
			grid = Grid()
			storyboard = Storyboard()

			def onCurrentStateInvalidated(sender, args):
				if sender.CurrentState == ClockState.Filling:
					window.Close()

			storyboard.CurrentStateInvalidated += onCurrentStateInvalidated
		
			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()
			
			fs = None
			bi = BitmapImage()

			try:
				fs = FileStream("Assets\\Background-Popup.png", FileMode.Open, FileAccess.Read, FileShare.Read)

				bi.BeginInit()
				bi.StreamSource = fs
				bi.CacheOption = BitmapCacheOption.OnLoad
				bi.CreateOptions = BitmapCreateOptions.None
				bi.EndInit()

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

			window.Owner = Application.Current.MainWindow
			window.Title = Application.Current.MainWindow.Title
			window.WindowStartupLocation = WindowStartupLocation.CenterOwner
			window.AllowsTransparency = True
			window.WindowStyle = WindowStyle.None
			window.ResizeMode = ResizeMode.NoResize
			window.ShowActivated = False
			window.ShowInTaskbar = Application.Current.MainWindow.ContextMenu.Items[5].IsChecked
			window.Topmost = True
			window.SizeToContent = SizeToContent.WidthAndHeight
			window.Background = Brushes.Transparent
			window.Loaded += onLoaded
			
			contentControl.UseLayoutRounding = True
			contentControl.HorizontalAlignment = HorizontalAlignment.Stretch
			contentControl.VerticalAlignment = VerticalAlignment.Stretch
			contentControl.Opacity = 0
			contentControl.RenderTransform = ScaleTransform(1, 1)

			window.Content = contentControl

			imageBrush = ImageBrush(bi)
			imageBrush.TileMode = TileMode.None
			imageBrush.Stretch = Stretch.Fill
			imageBrush.ViewboxUnits = BrushMappingMode.Absolute
			imageBrush.Viewbox = Rect(0, 0, bi.Width, bi.Height)
			imageBrush.AlignmentX = AlignmentX.Left
			imageBrush.AlignmentY = AlignmentY.Top
			imageBrush.Opacity = 0.5

			dg = DrawingGroup()
			dc = dg.Open()
			dc.DrawRectangle(SolidColorBrush(Color.FromArgb(Byte.MaxValue * 50 / 100, 0, 0, 0)), None, Rect(0, 0, bi.Width, bi.Height))
			dc.DrawRectangle(imageBrush, None, Rect(0, 0, bi.Width, bi.Height))
			dc.Close()

			backgroundBrush = ImageBrush(DrawingImage(dg))
			backgroundBrush.TileMode = TileMode.Tile
			backgroundBrush.ViewportUnits = BrushMappingMode.Absolute
			backgroundBrush.Viewport = Rect(0, 0, bi.Width, bi.Height)
			backgroundBrush.Stretch = Stretch.None

			if backgroundBrush.CanFreeze:
				backgroundBrush.Freeze()

			grid.HorizontalAlignment = HorizontalAlignment.Stretch
			grid.VerticalAlignment = VerticalAlignment.Stretch
			grid.Background = backgroundBrush
			grid.Width = 150
			grid.Height = 150
			grid.Clip = EllipseGeometry(Rect(0, 0, 150, 150))

			dropShadowEffect = DropShadowEffect()
			dropShadowEffect.BlurRadius = 1
			dropShadowEffect.Color = Colors.Black
			dropShadowEffect.Direction = 270
			dropShadowEffect.Opacity = 0.5
			dropShadowEffect.ShadowDepth = 1

			if dropShadowEffect.CanFreeze:
				dropShadowEffect.Freeze()

			grid.Effect = dropShadowEffect

			contentControl.Content = grid

			solidColorBrush = SolidColorBrush(colorFromAhsb(Byte.MaxValue, 60, 1.0, 1.0) if task.Result.Value.Key < 0 else colorFromAhsb(Byte.MaxValue, 0, 1.0, 0.4) if task.Result.Value.Key > 37 else colorFromAhsb(Byte.MaxValue, 60 - 60 * task.Result.Value.Key / 37, 1.0, 0.4 + 0.6 * Math.Pow(Math.E, (37 / 5 - task.Result.Value.Key) - 37 / 5) if task.Result.Value.Key < 37 / 5 else 0.4))

			if solidColorBrush.CanFreeze:
				solidColorBrush.Freeze()


			for stream in task.Result.Value.Value.Value.Value:
				try:
					bi = BitmapImage()
					bi.BeginInit()
					bi.StreamSource = stream
					bi.CacheOption = BitmapCacheOption.OnLoad
					bi.CreateOptions = BitmapCreateOptions.None
					bi.EndInit()

				finally:
					stream.Close()

				imageBrush = ImageBrush(bi)
				imageBrush.TileMode = TileMode.None
				imageBrush.ViewportUnits = BrushMappingMode.Absolute
				imageBrush.Viewport = Rect(0, 0, width, height)
				imageBrush.Stretch = Stretch.Uniform

				if imageBrush.CanFreeze:
					imageBrush.Freeze()

				g = Grid()
				g.HorizontalAlignment = HorizontalAlignment.Center
				g.VerticalAlignment = VerticalAlignment.Center
				g.Background = Brushes.Transparent
				g.Width = width
				g.Height = height

				grid.Children.Add(g)

				for i in range(max):
					rectangle = Rectangle()
					rectangle.HorizontalAlignment = HorizontalAlignment.Left
					rectangle.VerticalAlignment = VerticalAlignment.Top
					rectangle.Width = width
					rectangle.Height = height
					rectangle.Fill = solidColorBrush
					rectangle.Opacity = 0
					rectangle.OpacityMask = imageBrush
					rectangle.Clip = RectangleGeometry(Rect(0, height / max * i, width, height / max))
					rectangle.RenderTransform = TranslateTransform(0, 0)
					rectangle.Tag = i
					
					g.Children.Add(rectangle)

			window.Show()

			idList.Clear()
			idList.AddRange(task.Result.Value.Value.Value.Key)