0

As a part of a project i am working on, we have a WinForm application that has a Web Browser control on it. from that control, I am calling an html file that will be in a shared folder on a local network. in that folder, there are also various images, of which a client may want to switch out from time to time.

All that is fine, but i am trying to use the html document, with some javascript to refresh, look in that folder, load all the images, and use sliderman.js to present these images as a slideshow. I am not all too familiar with javascript, but basically, in pseudo-code, this is what i am trying to accomplish:

<html>
  <body>
    <script type="text/javascript">
      function PageRefreshTimer(){
      }

      function GetFiles(){
        //gets files from local network location (ie: \\192.168.1.2\sharedfolder)

        for each file in folder {
          //add <img> tag to page for the image
        }
      }
    </script>
  </body>
</html>

what i have accomplished so far is this:

<div id="slider_container_3">   

            <div id="SliderName_3" class="SliderName_3">
                <!-- images will be inserted here -->
              <script type="text/javascript">
                window.alert("found script");

                if (window.File && window.FileReader && window.FileList && window.Blob) {
                  //do your stuff!
                } else {
                  alert('The File APIs are not fully supported by your browser.');
                }
              </script>

              <img src="../01.jpg" width="800" height="200" alt="" title="" />
              <img src="../02.jpg" width="800" height="200" alt="" title="" />
            </div>
            <div class="c"></div>

            <script type="text/javascript">
                //scripting for sliderman.js
                demo3Effect1 = {name: 'myEffect31', top: true, move: true, duration: 400};
                demo3Effect2 = {name: 'myEffect32', right: true, move: true, duration: 400};
                demo3Effect3 = {name: 'myEffect33', bottom: true, move: true, duration: 400};
                demo3Effect4 = {name: 'myEffect34', left: true, move: true, duration: 400};
                demo3Effect5 = {name: 'myEffect35', rows: 3, cols: 9, delay: 50, duration: 100, order: 'random', fade: true};
                demo3Effect6 = {name: 'myEffect36', rows: 2, cols: 4, delay: 100, duration: 400, order: 'random', fade: true, chess: true};

                effectsDemo3 = [demo3Effect1,demo3Effect2,demo3Effect3,demo3Effect4,demo3Effect5,demo3Effect6,'blinds'];

                var demoSlider_3 = Sliderman.slider({container: 'SliderName_3', width: 800, height: 200, effects: effectsDemo3, display: {autoplay: 10000}});
            </script>
            <div class="c"></div>

        </div>

if i have tags in there already, it runs the slideshow as it is supposed to. However, when it reaches the check to see if it supports the the API in the program class, it sends the message that it is not supported. Any reasoning behind this?

Is this just due to a lack of support for the API in the C# Web Browser control?

Termonator145
  • 109
  • 1
  • 14
  • use the [Chromium based browser control](https://github.com/cefsharp/CefSharp) instead. – Crowcoder Aug 31 '16 at 20:22
  • @Crowcoder due to the fact that the code for the winform is only available to our developers, and I am attempting to create the html file for a client that requested to be able to just place files in a folder, instead of having to change the settings for the winform, and re-open it to have the new images show – Termonator145 Aug 31 '16 at 20:27
  • You can't make an update to your app and release it? The IE based control is old and decrepit. You'll have all kinds of problems if you do much more than simple html. – Crowcoder Aug 31 '16 at 20:30
  • @Crowcoder not saying that we cant make an update, its the simple fact that this would take time to develop and release. Not to mention, that for a bit of support of newer Javascript APIs, the dev. team is highly likely to call it a waste of resources for something very few customers are likely to use. – Termonator145 Aug 31 '16 at 20:36
  • I know it is bad news, but if you don't have control over what the client is going to view then you can't even try to implement shims you might need or alternate libraries that would work with what amounts to IE7. – Crowcoder Aug 31 '16 at 20:49

1 Answers1

1

Internet Explorer 11 is the first version that supports the Files API, but only partially (doesn't support the File constructor). You can always force the Windows Forms WebBrowser to use the latest IE version but it has to be installed on the client's machine.

To sum it up, I don't think you'll have much luck when using the WebBrowser control since it's so dependent on which version the client is running.

Edit: Even if you have for example IE 11 installed on your machine, the WebBrowser control might use an older version like IE 9, which can easily be checked by using the Version property.

If it's possible to force your clients to install IE 11 (prompt to install after checking the version or something), then you can enable it and use the partial implementation of the Files API.

Community
  • 1
  • 1
Timo Salomäki
  • 7,099
  • 3
  • 25
  • 40