コード例 #1
0
 protected void NotifyUpdate()
 {
     this.OnPropertyChanged(this, "CurrentValue");
     this.OnPropertyChanged(this, "LiveValue");
     LoggerFacade.Info(this.VariableName + " variable value changed. New value: " + this.LiveValue);
     this.ValueChanged?.Invoke();
 }
コード例 #2
0
ファイル: GuiTimeout.cs プロジェクト: SomeZyla/TsGui
        public void Start(TimeoutFunction timeoutfunction)
        {
            this._timeoutfunction = timeoutfunction;

            if (this.TimeoutElapsed != TimeSpan.MinValue)
            {
                if (this._resetonactivity)
                {
                    Director.Instance.ParentWindow.MouseDown += this.ResetElapsed;
                    Director.Instance.ParentWindow.KeyDown   += this.ResetElapsed;
                }
                this.AfterTimer.Interval = TimeoutElapsed;
                this.AfterTimer.Tick    += this.OnTimeoutReached;
                this._afterstarttime     = DateTime.Now;
                this._afterendtime       = this._afterstarttime + this.TimeoutElapsed;
                this.AfterTimer.Start();
                LoggerFacade.Info("Timeout will occur in " + this.TimeoutElapsed.TotalMilliseconds + " milliseconds");
            }

            if (this.TimeoutDateTime != DateTime.MaxValue)
            {
                //first check if the timeout datetime has already passed.
                if (this.TimeoutDateTime < DateTime.Now)
                {
                    Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ContextIdle, new Action(() => this.OnTimeoutReached()));
                    return;
                }
                this.ResetAtTimerBlock(this, new EventArgs());
            }
        }
コード例 #3
0
ファイル: GuiTimeout.cs プロジェクト: SomeZyla/TsGui
 private void OnTimeoutReached()
 {
     LoggerFacade.Info("Timeout reached");
     this.AfterTimer.Stop();
     this.AtTimer.Stop();
     if (this._resetonactivity)
     {
         Director.Instance.ParentWindow.MouseDown -= this.ResetElapsed;
         Director.Instance.ParentWindow.KeyDown   -= this.ResetElapsed;
     }
     this._timeoutfunction();
 }
コード例 #4
0
 public void AddVariable(TsVariable Variable)
 {
     LoggerFacade.Info("Applying TS variable: " + Variable.Name + ". Value: " + Variable.Value);
     try
     {
         objTSEnv.Value[Variable.Name] = Variable.Value;
     }
     catch (Exception e)
     {
         throw new TsGuiKnownException("There was a fatal error while applying TS variable: " + Variable.Name, e.Message);
     }
 }
コード例 #5
0
ファイル: App.xaml.cs プロジェクト: SomeZyla/TsGui
        private void StartTsGui()
        {
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.OnUnhandledException);

            LoggerFacade.Info("*TsGui started - version " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());

            this._mainwindow = new MainWindow(this.Arguments);
            Director.Instance.Init(this._mainwindow, this.Arguments);
            //this._controller = new Director(this._mainwindow, this.Arguments);
        }
コード例 #6
0
ファイル: ListItem.cs プロジェクト: SomeZyla/TsGui
        public ListItem(string Value, string Text, Formatting Formatting, CollectionViewGuiOptionBase parentlist) : base()
        {
            this.Init(Formatting, parentlist);
            this.Value = Value;
            if (string.IsNullOrEmpty(Text))
            {
                this.Text = "";
            }
            else
            {
                this.Text = Text;
            }

            LoggerFacade.Info("Created ListItem: " + this.Text + ". Value: " + this.Value);
        }
コード例 #7
0
        public AuthState Authenticate()
        {
            if (string.IsNullOrWhiteSpace(this.UsernameSource.Username) == true)
            {
                LoggerFacade.Warn("Cannot autheticate with empty username");
                this.SetState(AuthState.AccessDenied);
                return(AuthState.AccessDenied);
            }
            if (string.IsNullOrEmpty(this.PasswordSource.Password) == true)
            {
                LoggerFacade.Warn("Cannot autheticate with empty password");
                this.SetState(AuthState.AccessDenied);
                return(AuthState.AccessDenied);
            }

            LoggerFacade.Info("Authenticating user: "******" against domain " + this._domain);
            AuthState newstate;

            try
            {
                this.Context = new PrincipalContext(ContextType.Domain, this._domain, this.UsernameSource.Username, this.PasswordSource.Password);

                if (ActiveDirectoryMethods.IsUserMemberOfGroups(this.Context, this.UsernameSource.Username, this.RequiredGroups) == true)
                {
                    LoggerFacade.Info("Active Directory authorised");
                    newstate = AuthState.Authorised;
                }
                else
                {
                    LoggerFacade.Info("Active Directory not authorised");
                    newstate = AuthState.NotAuthorised;
                }
            }
            catch (Exception e)
            {
                LoggerFacade.Warn("Active Directory access denied");
                LoggerFacade.Trace(e.Message + Environment.NewLine + e.StackTrace);
                newstate = AuthState.AccessDenied;
            }

            this.SetState(newstate);
            return(newstate);
        }
コード例 #8
0
        //Constructors
        public TsPage(BaseLayoutElement Parent, XElement SourceXml, PageDefaults Defaults) : base(Parent)
        {
            //this._director = Defaults.RootController;
            LoggerFacade.Info("New page created");
            this.Parent        = Parent;
            this.ShowGridLines = Director.Instance.ShowGridLines;
            this.Page          = new TsPageUI(this);
            this.PageHeader    = Defaults.PageHeader;
            this.LeftPane      = Defaults.LeftPane;
            this.RightPane     = Defaults.RightPane;

            this.Page.Loaded += this.OnPageLoaded;

            this.GroupingStateChange        += this.OnPageHide;
            this.Page.DataContext            = this;
            this.Page.ButtonGrid.DataContext = Defaults.Buttons;
            this.Page.KeyDown += this.OnKeyDown;

            this.LoadXml(SourceXml);
            this.Update();
        }
コード例 #9
0
ファイル: GuiTimeout.cs プロジェクト: SomeZyla/TsGui
        private void ResetAtTimerBlock(object sender, EventArgs e)
        {
            this.AtTimer?.Stop();
            this.AtTimer = new DispatcherTimer();
            TimeSpan timeout = this.TimeoutDateTime - DateTime.Now;

            if (timeout.TotalMinutes > 10)
            {
                this.AtTimer.Interval = new TimeSpan(0, 5, 0);
                this.AtTimer.Tick    += this.ResetAtTimerBlock;
                this.AtTimer.Start();
                LoggerFacade.Info("Timeout will occur at " + this.TimeoutDateTime);
            }
            else if (timeout.TotalMilliseconds > 0)
            {
                this.AtTimer.Interval = timeout;
                this.AtTimer.Tick    += this.OnTimeoutReached;
                this.AtTimer.Start();
                LoggerFacade.Info("Timeout will occur at " + this.TimeoutDateTime);
            }
        }
コード例 #10
0
ファイル: SymbolFactory.cs プロジェクト: SomeZyla/TsGui
        public static UserControl Copy(UserControl control)
        {
            if (control == null)
            {
                return(null);
            }

            string type = control.GetType().ToString();

            LoggerFacade.Info("Creating symbol, type: " + type);

            if (type == "TsGui.View.Symbols.TsFolderUI")
            {
                return(new TsFolderUI());
            }
            else if (type == "TsGui.View.Symbols.TsCrossUI")
            {
                return(new TsCrossUI());
            }
            else if (type == "TsGui.View.Symbols.TsTickUI")
            {
                return(new TsTickUI());
            }
            else if (type == "TsGui.View.Symbols.TsWarnUI")
            {
                return(new TsWarnUI());
            }
            else if (type == "TsGui.View.Symbols.TsTrafficLightUI")
            {
                return(new TsTrafficLightUI());
            }
            else
            {
                return(null);
            }
        }
コード例 #11
0
ファイル: ActionFactory.cs プロジェクト: SomeZyla/TsGui
        public static IAction CreateAction(XElement inputxml)
        {
            XAttribute xtype = inputxml.Attribute("Type");

            if (xtype == null)
            {
                throw new ArgumentException("Missing Type attribute on Action" + Environment.NewLine);
            }

            LoggerFacade.Info("Creating Action, type: " + xtype.Value);

            #region
            if (xtype.Value == "Authentication")
            {
                var action = new AuthenticationAction(inputxml);
                return(action);
            }

            else
            {
                return(null);
            }
            #endregion
        }
コード例 #12
0
 public void AddVariable(TsVariable Variable)
 {
     LoggerFacade.Info("Testing variable applied: " + Variable.Name + ". Value: " + Variable.Value);
     this.variables.Add(Variable);
 }
コード例 #13
0
ファイル: TsActionButton.cs プロジェクト: SomeZyla/TsGui
 public void OnButtonClick(object o, RoutedEventArgs e)
 {
     LoggerFacade.Info("Action button clicked");
     this._action?.RunAction();
 }
コード例 #14
0
        public override void Execute()
        {
            // Bitmap bitmap = new Bitmap(Image.FromFile(bitmapPath));
            Bitmap bitmap = new Bitmap(bitmapPath);

            var sb = new StringBuilder();

            Color color;

            bool isFirstChar    = true;
            int  bitsPairNumber = 0;
            uint iCount         = uint.MaxValue;
            uint charValue      = 0;

            int  x       = 0;
            int  y       = 0;
            uint counter = 0;

            while (true)
            {
                bitsPairNumber = (int)counter % 4;

                color = bitmap.GetPixel(x, y);
                int[] c = new int[] { color.A, color.R, color.G, color.B };

                if (counter > 1 && bitsPairNumber == 0)
                {
                    if (isFirstChar)
                    {
                        iCount      = charValue * 4 + 4;
                        isFirstChar = false;
                    }
                    else
                    {
                        sb.Append((char)charValue);
                    }
                    charValue = 0;
                }

                for (int k = 0; k < 4; k++)
                {
                    if ((c[k] & 1) == 1)
                    {
                        int index = 4 * bitsPairNumber + k;
                        charValue += (uint)(1 << index);
                    }
                }

                if (x == bitmap.Width - 1)
                {
                    x = 0;
                    y++;
                }
                else
                {
                    x++;
                }

                if (y >= bitmap.Height - 1 || counter >= iCount)
                {
                    break;
                }
                counter++;
            }

            string message = sb.ToString();

            LoggerFacade.Info($"Odkodowana wiadomość:\n\n{message}\n");
        }
コード例 #15
0
 public void RefreshAll()
 {
     LoggerFacade.Info("Validation refresh all requested");
     this._owner.OnValidationChange();
 }
コード例 #16
0
ファイル: Director.cs プロジェクト: SomeZyla/TsGui
        private void LoadXml(XElement SourceXml)
        {
            XElement x;
            TsPage   currPage = null;
            TsPage   prevPage = null;

            IEnumerable <XElement> pagesXml;

            if (SourceXml != null)
            {
                this._debug    = XmlHandler.GetBoolFromXAttribute(SourceXml, "Debug", this._debug);
                this._livedata = XmlHandler.GetBoolFromXAttribute(SourceXml, "LiveData", this._livedata);

                //Set show grid lines after pages and columns have been created.
                x = SourceXml.Element("ShowGridLines");
                if ((x != null) && (this._prodmode == false))
                {
                    this.ShowGridLines = true;
                }

                x = SourceXml.Element("UseTouchDefaults");
                if (x != null)
                {
                    this.UseTouchDefaults = true;
                }

                //turn hardware eval on or off
                x = SourceXml.Element("HardwareEval");
                if (x != null)
                {
                    this._hardwareevaluator = new HardwareEvaluator();
                }

                //start layout import
                this.TsMainWindow = new TsMainWindow(this.ParentWindow, SourceXml);

                this._buttons = new TsButtons();
                this._buttons.LoadXml(SourceXml.Element("Buttons"));

                PageDefaults pagedef = new PageDefaults();

                x = SourceXml.Element("Heading");
                if (x != null)
                {
                    pagedef.PageHeader = new TsPageHeader(this.TsMainWindow, x);
                }
                else
                {
                    pagedef.PageHeader = new TsPageHeader();
                }

                x = SourceXml.Element("LeftPane");
                if (x != null)
                {
                    pagedef.LeftPane = new TsPane(x);
                }
                else
                {
                    pagedef.LeftPane = new TsPane();
                }

                x = SourceXml.Element("RightPane");
                if (x != null)
                {
                    pagedef.RightPane = new TsPane(x);
                }
                else
                {
                    pagedef.RightPane = new TsPane();
                }

                pagedef.Buttons    = this._buttons;
                pagedef.MainWindow = this.TsMainWindow;


                this.TsMainWindow.LoadXml(SourceXml);
                GuiTimeout.Init(SourceXml.Element("Timeout"));

                foreach (XElement xauth in SourceXml.Elements("Authentication"))
                {
                    this._authlibrary.AddAuthenticator(AuthenticationFactory.GetAuthenticator(xauth));
                }

                //now read in the options and add to a dictionary for later use
                pagesXml = SourceXml.Elements("Page");
                if (pagesXml != null)
                {
                    //Debug.WriteLine("pagesXml not null");
                    foreach (XElement xPage in pagesXml)
                    {
                        #region
                        //Debug.WriteLine("creating new page");
                        if (currPage != null)
                        {
                            //record the last page as the prevPage
                            prevPage = currPage;
                            currPage = new TsPage(this.TsMainWindow, xPage, pagedef);
                        }
                        else
                        {
                            currPage         = new TsPage(this.TsMainWindow, xPage, pagedef);
                            currPage.IsFirst = true;
                        }

                        //create the new page and assign the next page/prev page links
                        currPage.PreviousPage = prevPage;
                        if (prevPage != null)
                        {
                            prevPage.NextPage = currPage;
                        }

                        this._pages.Add(currPage);
                        currPage.Page.Loaded += this.OnWindowLoaded;
                        #endregion
                    }

                    //currPage.IsLast = true;
                }

                x = SourceXml.Element("NoUI");
                if (x != null)
                {
                    this._nouicontainer = new NoUIContainer(x);
                }
            }

            LoggerFacade.Info("Config load finished");
            this.ConfigLoadFinished?.Invoke(this, null);
        }
コード例 #17
0
ファイル: Director.cs プロジェクト: SomeZyla/TsGui
        private void Startup()
        {
            LoggerFacade.Debug("*TsGui startup started");
            this.StartupFinished = false;
            this._prodmode       = this._envController.Init();


            XElement xconfig = this.ReadConfigFile();

            if (xconfig == null)
            {
                return;
            }

            //this.LoadXml(x);
            try { this.LoadXml(xconfig); }
            catch (TsGuiKnownException e)
            {
                string msg = "Error loading config file" + Environment.NewLine + e.CustomMessage + Environment.NewLine + e.Message;
                this.CloseWithError("Error loading config file", msg);
                return;
            }

            this.PopulateHwOptions();

            //now init everything
            this._optionlibrary.InitialiseOptions();

            //if prodmode isn't true, the envcontroller couldn't connect to sccm
            //prompt the user if they want to continue. exit if not.
            if (this._prodmode == true)
            {
                this._envController.HideProgressUI();
            }
            else
            {
                if (this.PromptTestMode() != true)
                {
                    this.Cancel(); return;
                }
                if (this._livedata == true)
                {
                    this._showtestwindow = true;
                }
            }

            //subscribe to closing event
            this.ParentWindow.Closing += this.OnWindowClosing;

            if (this._pages.Count > 0)
            {
                LoggerFacade.Debug("Loading pages");
                this.CurrentPage = this._pages.First();
                //update group settings to all controls
                foreach (IToggleControl t in this._toggles)
                {
                    t.InitialiseToggle();
                }

                this.ParentWindow.DataContext = this.TsMainWindow;

                // Now show and close the ghost window to make sure WinPE honours the
                // windowstartuplocation
                LoggerFacade.Trace("Loading ghost window");
                GhostWindow ghost = new GhostWindow();
                ghost.Show();
                ghost.Close();

                this.UpdateWindow();
                this.ParentWindow.Visibility            = Visibility.Visible;
                this.ParentWindow.WindowStartupLocation = this.TsMainWindow.WindowLocation.StartupLocation;
                this.StartupFinished = true;
                if ((this._debug == true) || (this._showtestwindow == true))
                {
                    this._testingwindow = new TestingWindow(this);
                }
                GuiTimeout.Instance?.Start(this.OnTimeoutReached);
                LoggerFacade.Info("*TsGui startup finished");
            }
            else
            {
                //No pages, finish using only the NoUI options
                LoggerFacade.Info("*No pages configured. Finishing TsGui");
                this.Finish();
            }
        }
コード例 #18
0
ファイル: ListItem.cs プロジェクト: SomeZyla/TsGui
 public ListItem(XElement InputXml, Formatting Formatting, CollectionViewGuiOptionBase parentlist) : base()
 {
     this.Init(Formatting, parentlist);
     this.LoadXml(InputXml);
     LoggerFacade.Info("Created ListItem: " + this.Text + ". Value: " + this.Value);
 }
コード例 #19
0
ファイル: GuiFactory.cs プロジェクト: SomeZyla/TsGui
        private static IGuiOption GetGuiOption(XElement OptionXml, TsColumn Parent)
        {
            XAttribute xtype = OptionXml.Attribute("Type");

            if (xtype == null)
            {
                throw new ArgumentException("Missing Type attribute on GuiOption" + Environment.NewLine);
            }

            LoggerFacade.Info("Creating GuiOption, type: " + xtype.Value);

            IGuiOption newoption = null;

            #region
            if (xtype.Value == "DropDownList")
            {
                newoption = new TsDropDownList(OptionXml, Parent);
            }

            else if (xtype.Value == "CheckBox")
            {
                newoption = new TsCheckBox(OptionXml, Parent);
            }
            else if (xtype.Value == "FreeText")
            {
                newoption = new TsFreeText(OptionXml, Parent);
            }

            else if (xtype.Value == "ComputerName")
            {
                newoption = new TsComputerName(OptionXml, Parent);
            }
            else if (xtype.Value == "Heading")
            {
                newoption = new TsHeading(OptionXml, Parent);
                return(newoption);
            }
            else if (xtype.Value == "InfoBox")
            {
                newoption = new TsInfoBox(OptionXml, Parent);
            }
            else if (xtype.Value == "TrafficLight")
            {
                newoption = new TsTrafficLight(OptionXml, Parent);
            }
            else if (xtype.Value == "TickCross")
            {
                newoption = new TsTickCross(OptionXml, Parent);
            }
            else if (xtype.Value == "Image")
            {
                newoption = new TsImage(OptionXml, Parent);
                return(newoption);
            }
            else if (xtype.Value == "ComplianceRefreshButton")
            {
                newoption = new TsComplianceRefreshButton(OptionXml, Parent);
                return(newoption);
            }
            else if (xtype.Value == "PasswordBox")
            {
                newoption = new TsPasswordBox(OptionXml, Parent);
            }
            else if (xtype.Value == "UsernameBox")
            {
                newoption = new TsUsernameBox(OptionXml, Parent);
            }
            else if (xtype.Value == "ActionButton")
            {
                newoption = new TsActionButton(OptionXml, Parent);
            }
            else if (xtype.Value == "TreeView")
            {
                newoption = new TsTreeView(OptionXml, Parent);
            }
            else if (xtype.Value == "Timeout")
            {
                if (GuiTimeout.Instance == null)
                {
                    throw new TsGuiKnownException("No Timeout section defined in config. Timeout GuiOption type not available", string.Empty);
                }
                newoption = new TsTimeout(OptionXml, Parent);
            }
            else
            {
                return(null);
            }
            #endregion

            Director.Instance.AddOptionToLibary(newoption);
            return(newoption);
        }