Пример #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))
Пример #2
0
    def _update_ext_info_panel(self, ext_pkg_item):
        # Update the name
        self.ext_name_l.Content = ext_pkg_item.Name
        self.ext_desc_l.Text = '{}  '.format(ext_pkg_item.Desciption)

        # Update the description and web link
        if ext_pkg_item.URL:
            self.ext_gitlink_t.Text = '({})'.format(ext_pkg_item.URL)
            self.ext_gitlink_hl.NavigateUri = Uri(ext_pkg_item.URL)

        # Update the author and profile link
        if ext_pkg_item.Author:
            self.ext_author_t.Text = ext_pkg_item.Author
            self.ext_authorlink_hl.NavigateUri = Uri(
                ext_pkg_item.ext_pkg.author_profile)

        # Update Installed folder info
        if ext_pkg_item.ext_pkg.is_installed:
            self.show_element(self.ext_installed_l)
            self.ext_installed_l.Content = 'Installed under:\n{}'.format(
                ext_pkg_item.ext_pkg.is_installed)
        else:
            self.hide_element(self.ext_installed_l)

        # Update dependencies
        if ext_pkg_item.ext_pkg.dependencies:
            self.show_element(self.ext_dependencies_l)
            self.ext_dependencies_l.Content = 'Dependencies:\n' + \
                                              ', '.join(ext_pkg_item.ext_pkg.dependencies)
        else:
            self.hide_element(self.ext_dependencies_l)
Пример #3
0
				def onUpdate():
					shortenedUri = None

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

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

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

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

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

						except Exception, e:
							Trace.WriteLine(e.clsException.Message)
							Trace.WriteLine(e.clsException.StackTrace)
def create_next_link_regx_with_image(next_link_image_url):
    """Creates a link regex using the image behind the next link"""

    if debug:
        print "Trying to create a next page link regex with image url:\n" + next_link_image_url

    next_link_url_escaped = escape_regex_characters(next_link_image_url)

    regex = "<a\\s[^<>]*href\\s*=\\s*(?([\"'])[\"'](?<link>[^\"']+)[\"']|(?<link>[^\\s<>]+))[^<>]*>[\\s\\n\\r\\t]*<img\\s[^<>]*src\\s*=\\s*[\"']?" + next_link_url_escaped + "[\"']?"

    result, matches = check_created_link_regex(regex)

    if not result:

        #Try with a relative link:

        relative_next_link_url = first_page_uri.MakeRelativeUri(
            Uri(next_link_image_url)).OriginalString

        if debug:
            print "Trying with relative image url: " + relative_next_link_url

        relative_next_link_url = relative_next_link_url.lstrip("/")

        relative_next_link_url = escape_regex_characters(
            relative_next_link_url)

        regex = "<a\\s[^<>]*href\\s*=\\s*(?([\"'])[\"'](?<link>[^\"']+)[\"']|(?<link>[^\\s<>]+))[^<>]*>[\\s\\n\\r\\t]*<img\\s[^<>]*src\\s*=\\s*[\"']?\\.*/?" + relative_next_link_url + "[\"']?"

        result, matches = check_created_link_regex(regex)

        if not result:

            #Try one other way

            relative_next_link_url = Uri(next_link_image_url).AbsolutePath

            relative_next_link_url = relative_next_link_url.lstrip("/")

            relative_next_link_url = escape_regex_characters(
                relative_next_link_url)

            if debug:
                print "Trying with relative image url: " + relative_next_link_url

            regex = "<a\\s[^<>]*href\\s*=\\s*(?([\"'])[\"'](?<link>[^\"']+)[\"']|(?<link>[^\\s<>]+))[^<>]*>[\\s\\n\\r\\t]*<img\\s[^<>]*src\\s*=\\s*[\"']?\\.*/?" + relative_next_link_url + "[\"']?"

            result, matches = check_created_link_regex(regex)

            if not result:
                if debug:
                    print "Couldn't create a next page regex with the image url"
                return None

    if debug: print "Found a next page regex with the image url!"
    link = LinkRegex(regex)
    link._matches = matches

    return link
def check_created_image_regex(first_image_url, second_image_url, regex):
    matches = Regex.Matches(first_page_source._source, regex,
                            RegexOptions.IgnoreCase)

    escaped_first_image_url = escape_uri_string(first_image_url)
    escaped_second_image_url = escape_uri_string(second_image_url)

    if matches.Count == 0:
        return False, 0
    else:
        if debug:
            print "\nFound " + str(
                matches.Count
            ) + " match(es) on the first page with regex: " + regex
            print "Captured: " + matches[0].Value
            print "link group: " + matches[0].Groups["link"].Value

        #We don't care if there is more than one result. As long as the first result is the correct image
        result, image_uri = Uri.TryCreate(first_page_uri,
                                          matches[0].Groups["link"].Value)

        #Valid url and matches the input image url
        if result and image_uri.AbsoluteUri in (first_image_url,
                                                escaped_first_image_url):
            if debug: print "Valid uri and matches image url"

        else:
            if debug: print "Not a valid uri or doesn't match image url"
            return False, 0

        matches_second = Regex.Matches(second_page_source._source, regex,
                                       RegexOptions.IgnoreCase)

        if matches_second.Count == 0:
            if debug: print "No matches on the second page"
            return False, 0

        #Regex match on the second page. Same deal as above. We don't care if there is more than one result
        if debug:
            print "\nFound " + str(
                matches_second.Count) + " match(es) on the second page"
            print "Captured: " + matches_second[0].Value
            print "link group: " + matches_second[0].Groups["link"].Value

        result, image_uri = Uri.TryCreate(
            second_page_uri, matches_second[0].Groups["link"].Value)

        if result and image_uri.AbsoluteUri in (second_image_url,
                                                escaped_second_image_url):

            if debug:
                print "Regex works on both pages and returns the correct image"
            return True, matches.Count

        else:
            if debug: print "Invalid Uri or doesn't match the second image url"
            return False, 0

    return False, matches.Count
Пример #6
0
 def __init__(self, repository, username, password):
     from System import Uri
     self.repository = Uri(repository)
     self.username = username
     self.password = password
     self.requestedFields = [
         "summary", "issuetype", "status", "updated",
         "timeoriginalestimate", "subtasks"
     ]
    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)"
Пример #8
0
def HtmlWorksheetMenu(workbook, current):
    links = []
    for sheet in workbook._worksheets:
        if sheet.name == current:
            links.append(currentWorksheetMenuLink % (Uri.EscapeUriString(
                sheet.name), SecurityElement.Escape(sheet.name)))
        else:
            links.append(worksheetMenuLink % (Uri.EscapeUriString(
                sheet.name), SecurityElement.Escape(sheet.name)))
    return worksheetMenuTable % (len(links), ''.join(links))
def check_regex_against_source(regex, check_value, check_value2):

    matches = Regex.Matches(first_page_source._source, regex._regex,
                            RegexOptions.IgnoreCase)

    if matches.Count != 0:

        if debug:
            print "\n\nFound " + str(
                matches.Count
            ) + " match(es) on the first page with regex: " + regex._regex
            print "Captured: " + matches[0].Value
            print "link group: " + matches[0].Groups["link"].Value

        #We don't care if there is more than one result. As long as the first result is the correct image
        result, result_uri = Uri.TryCreate(first_page_uri,
                                           matches[0].Groups["link"].Value)

        if result and result_uri.AbsoluteUri in (check_value, check_value2):

            #Valid url and matches against the check_value

            if debug: print "Valid uri"

        else:
            return False

        matches_second = Regex.Matches(second_page_source._source,
                                       regex._regex, RegexOptions.IgnoreCase)

        if matches_second.Count == 0:
            if debug: print "No matches found on the second page"
            return False

        #Regex match on the second page. Same deal as above. We don't care if there is more than one result

        if debug:
            print "\nFound " + str(
                matches_second.Count) + " match(es) on the second page"
            print "Captured: " + matches_second[0].Value
            print "link group: " + matches_second[0].Groups["link"].Value

        result, result_uri = Uri.TryCreate(
            second_page_uri, matches_second[0].Groups["link"].Value)

        if result:
            regex._matches = matches.Count
            if debug: print "Added to valid regex"
            return regex

        else:
            if debug: print "Invalid uri"
            return False

    return False
def escape_uri_string(uri):
    if type(uri) != System.Uri:
        uri = Uri(uri)
    string = uri.AbsolutePath
    for character in [
            "%", "!", "*", "'", "(", ")", ";", ":", "@", "&", "=", "+", "$",
            ",", "?", "#", "[", "]", " "
    ]:
        string = string.replace(character, Uri.HexEscape(character))

    return uri.Scheme + "://" + uri.Host + string
Пример #11
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)
Пример #12
0
 def create_url(cls, host, port=None, is_secure=False):
     if port is None:
         return Uri(host)
     else:
         scheme = 'wss' if is_secure else 'ws'
         builder = UriBuilder(scheme, host, port)
         return builder.Uri
Пример #13
0
    def _ExecuteRaw(self, action, url, body, method):

        if self.logging:
            Log.Write("--ODATA REQUEST--\n\n" + str(url) + "\n\n" + str(body))

        args = [Uri(url)] if self._GetMethodType(method) == "Download" else [
            Uri(url), method, body
        ]

        response, duration = Helper.Utility.ExecuteAndTimeAction(action, *args)

        if self.logging:
            Log.Write("--ODATA RESPONSE [{0}s]--\n\n{1}".format(
                str(duration), response))

        return response
Пример #14
0
    def __init__(self):

        wpf.LoadComponent(self, xamlfile)

        self.Icon = Media.Imaging.BitmapImage(Uri(dir_name + "\portcoast.ico", UriKind.Relative))

        self.lbCategories.ItemsSource = cbs
Пример #15
0
 def url(self, url):
     if isinstance(url, Uri):
         self._url = url
     elif isinstance(url, basestring):
         self._url = Uri(url)
     else:
         raise NotImplementedError
Пример #16
0
    def __init__(self):
        rd = ResourceDictionary()
        rd.Source = Uri(
            "pack://application:,,,/ClassicAssist.Shared;component/Resources/DarkTheme.xaml"
        )
        self.Resources.MergedDictionaries.Add(rd)
        self.Background = self.Resources["ThemeWindowBackgroundBrush"]

        self.Content = XamlReader.Parse(xaml)
        self.Title = "Rudder"
        self.Topmost = True
        self.Height = 250
        self.Width = 250
        self.refreshTime = TimeSpan.FromSeconds(30)

        self.events = [('forwardLeft', 'Forward Left'), ('forward', 'Forward'),
                       ('forwardRight', 'Forward Right'), ('left', 'Left'),
                       ('turnAround', 'Turn Around'), ('right', 'Right'),
                       ('backLeft', 'Back Left'), ('back', 'Back'),
                       ('backRight', 'Back Right'), ('stop', 'Stop'),
                       ('raiseAnchor', 'Raise Anchor'),
                       ('dropAnchor', 'Drop Anchor'),
                       ('turnLeft', 'Turn Left'), ('turnRight', 'Turn Right'),
                       ('start', 'Start')]
        self.setEvents()
Пример #17
0
    def onUpdate():
        if NetworkInterface.GetIsNetworkAvailable():
            try:
                response = None
                stream = None

                try:
                    response = request.GetResponse()
                    stream = response.GetResponseStream()
                    doc = XmlDocument()
                    doc.Load(stream)

                    for entryXmlNode in doc.GetElementsByTagName("entry"):
                        entry = Entry()

                        for xmlNode in entryXmlNode.ChildNodes:
                            if xmlNode.Name.Equals("title"):
                                entry.Title = xmlNode.InnerText
                            elif xmlNode.Name.Equals("issued"):
                                entry.Created = DateTime.Parse(
                                    xmlNode.InnerText)
                            elif xmlNode.Name.Equals("modified"):
                                entry.Modified = DateTime.Parse(
                                    xmlNode.InnerText)
                            elif xmlNode.Name.Equals("link"):
                                for attribute in xmlNode.Attributes:
                                    if attribute.Name.Equals("href"):
                                        entry.Resource = Uri(attribute.Value)
                            elif xmlNode.Name.Equals("author"):
                                for childXmlNode in xmlNode.ChildNodes:
                                    if childXmlNode.Name.Equals("name"):
                                        entry.Author = childXmlNode.InnerText

                        entry.Image = Uri(
                            "http://www.google.co.jp/options/icons/gmail.gif")
                        entryList.Add(entry)

                finally:
                    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)
Пример #18
0
    def __init__(self, client):
        self.client = client
        self.requests = Requests()
        self.crypto = None

        # Listener URLs
        self.base_url = URL  # This needs to be a tuple of callback domains (eventually)
        self.jobs_url = Uri(urljoin(self.base_url, 'jobs'))
Пример #19
0
 def __init__(self, canvas):
     self.canvas = canvas
     self.findRootVisual()
     self.rand = Random()
     self.RedrawScreen(0)
     wc = WebClient()
     wc.DownloadStringCompleted += self.xamlDownloaded
     wc.DownloadStringAsync(Uri('star.xaml', UriKind.Relative))
Пример #20
0
def get_rss1(url):
    g = Graph()
    UriLoader.Load(g, Uri(url))
    return [
        RSSItem(str(f.ItemArray[2]), "", str(f.ItemArray[0]))
        for f in g.ToDataTable().AsEnumerable()
        if "title" in str(f.ItemArray[1])
    ]
Пример #21
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
Пример #22
0
    def onUpdate():
        if NetworkInterface.GetIsNetworkAvailable():
            try:
                response = None
                stream = None

                try:
                    response = request.GetResponse()
                    stream = response.GetResponseStream()
                    doc = XmlDocument()
                    doc.Load(stream)

                    for itemXmlNode in doc.GetElementsByTagName("item"):
                        entry = Entry()
                        epicenter = None
                        maxLevel = None

                        for xmlNode in itemXmlNode.ChildNodes:
                            if xmlNode.Name.Equals("link"):
                                entry.Resource = Uri(xmlNode.InnerText)
                            elif xmlNode.Name.Equals("description"):
                                entry.Description = xmlNode.InnerText
                            elif xmlNode.Name.Equals("tenkiJP:earthquake"):
                                for attribute in xmlNode.Attributes:
                                    if attribute.Name.Equals("epicenter"):
                                        epicenter = attribute.Value
                                    elif attribute.Name.Equals("max_level"):
                                        maxLevel = attribute.Value
                                    elif attribute.Name.Equals(
                                            "outbreak_datetime"):
                                        entry.Created = entry.Modified = DateTime.Parse(
                                            attribute.Value)

                        if epicenter is not None:
                            if String.IsNullOrEmpty(maxLevel):
                                maxLevel = "N/A"

                            if CultureInfo.CurrentCulture.Equals(
                                    CultureInfo.GetCultureInfo("ja-JP")):
                                entry.Title = String.Format(
                                    "震度{0} - {1}", maxLevel, epicenter)
                            else:
                                entry.Title = String.Format(
                                    "Intensity {0} - {1}", maxLevel, epicenter)

                            entryList.Add(entry)

                finally:
                    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)
Пример #23
0
        def load_url(self, url):
            self.ishtml = False

            # WebViewControl as of 5.1.1 crashes on file:// urls. Stupid workaround to make it work
            if url.startswith('file://'):
                pass  # file:// urls ok with webview2
                #url = resolve_url(url, True)

            self.web_view.Source = Uri(url)
Пример #24
0
    def _update_ext_info_panel(self, ext_pkg_item):
        """Updated the extension information panel based on the info
        provided by the ext_pkg_item

        Args:
            ext_pkg_item: Extension package to display info for

        """

        # Update the name
        self.ext_name_l.Content = ext_pkg_item.Name
        self.ext_desc_l.Text = '{}  '.format(ext_pkg_item.Desciption)

        # Update the description and web link
        if ext_pkg_item.URL:
            self.ext_gitlink_t.Text = '({})'.format(ext_pkg_item.URL)
            self.ext_gitlink_hl.NavigateUri = Uri(ext_pkg_item.URL)
        else:
            self.ext_gitlink_t.Text = ''

        # Update the author and profile link
        if ext_pkg_item.Author:
            self.ext_author_t.Text = ext_pkg_item.Author
            self.ext_authorlink_hl.NavigateUri = \
                Uri(ext_pkg_item.ext_pkg.author_profile)
        else:
            self.ext_author_t.Text = ''

        # Update Installed folder info
        if ext_pkg_item.ext_pkg.is_installed:
            self.show_element(self.ext_installed_l)
            self.ext_installed_l.Content = \
                'Installed under:\n{}'.format(ext_pkg_item.ext_pkg.is_installed)
        else:
            self.hide_element(self.ext_installed_l)

        # Update dependencies
        if ext_pkg_item.ext_pkg.dependencies:
            self.show_element(self.ext_dependencies_l)
            self.ext_dependencies_l.Content = \
                'Dependencies:\n' + \
                ', '.join(ext_pkg_item.ext_pkg.dependencies)
        else:
            self.hide_element(self.ext_dependencies_l)
Пример #25
0
    def __init__(self):
        p = Process.GetCurrentProcess()

        self.SLEEP = 5000
        self.JITTER = 5000
        self.FIRST_CHECKIN = True
        self.GUID = Guid().NewGuid().ToString()
        self.URL = str(
            Uri(Uri(URL), self.GUID
                ))  # This needs to be a tuple of callback domains (eventually)
        self.USERNAME = Environment.UserName
        self.DOMAIN = Environment.UserDomainName
        self.HIGH_INTEGRITY = self.is_high_integrity()
        #self.IP = ManagementObject("Win32_NetworkAdapterConfiguration")
        #self.OS = ManagementObject("Win32_OperatingSystem")
        self.PROCESS = p.Id
        self.PROCESS_NAME = p.ProcessName
        self.HOSTNAME = Environment.MachineName
        self.JOBS = []
Пример #26
0
 def init(self):
     self.browser = WebBrowser()
     self.browser.Url = Uri(self.url)
     self.browser.StatusTextChanged += self.on_statustext_changed
     self.browser.Dock = DockStyle.Fill
     self.status_strip = StatusStrip()
     self.status = ToolStripStatusLabel()
     self.status_strip.Items.Add(self.status)
     self.Controls.Add(self.browser)
     self.Controls.Add(self.status_strip)
Пример #27
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
Пример #28
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()
Пример #29
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))
Пример #30
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