Ejemplo n.º 1
0
        /// <summary>
        /// Creates a computer node from the output of WMIC
        /// </summary>
        /// <param name="queryString"></param>
        /// <returns></returns>
        private ComputerNode CreateComputerNode(string queryString)
        {
            ComputerNode node = new ComputerNode();


            return(node);
        }
Ejemplo n.º 2
0
            private IDictionary <Move, IComputerNode> GetChildrenByMove()
            {
                if (this.finishedComputing)
                {
                    return(this.cachedChildren);
                }

                IDictionary <LogarithmicGrid, IComputerNode> knownComputerNodesWithSameSum;

                if (!this.SearchTree.knownComputerNodesBySum.TryGetValue(this.Sum, out knownComputerNodesWithSameSum))
                {
                    knownComputerNodesWithSameSum = new Dictionary <LogarithmicGrid, IComputerNode>();
                    this.SearchTree.knownComputerNodesBySum.Add(this.Sum, knownComputerNodesWithSameSum);
                }

                foreach (var kvp in this.possibleStatesLazy.Value)
                {
                    IComputerNode computerNode;

                    if (!knownComputerNodesWithSameSum.TryGetValue(kvp.Value, out computerNode))
                    {
                        computerNode = new ComputerNode(kvp.Value, this.SearchTree, this.Sum);
                        knownComputerNodesWithSameSum.Add(kvp.Value, computerNode);
                    }

                    this.cachedChildren.Add(kvp.Key, computerNode);
                }

                this.finishedComputing = true;

                return(this.cachedChildren);
            }
Ejemplo n.º 3
0
 static void Main(string[] args)
 {
     ComputerNode node = new ComputerNode();
     node.Start();
     System.Console.ReadLine();
     node.Stop();
 }
Ejemplo n.º 4
0
 public static void AddOnlineDegradedItems(this ContextMenuStrip menu, ComputerNode node)
 {
     if (node?.ComputerPanel.ConnectionState == ConnectionState.OnlineDegraded)
     {
         throw new NotImplementedException();
     }
 }
Ejemplo n.º 5
0
 public static void AddOnlineSlowItems(this ContextMenuStrip menu, ComputerNode node)
 {
     if (node?.ComputerPanel.ConnectionState == ConnectionState.OnlineSlow)
     {
         menu?.Items.Add(new ToolStripSeparator());
     }
 }
Ejemplo n.º 6
0
 public static void AddDefaultItems(this ContextMenuStrip menu, ComputerNode node)
 {
     menu?.Items.Add(ContextMenuLabels.RemoveNode, null, (s, e) => {
         var panel    = node.ComputerPanel;
         var mainForm = panel.ParentForm as MainForm;
         mainForm?.MainSplitContainer.Panel2.Controls.Remove(panel);
         node.Remove();
     });
 }
Ejemplo n.º 7
0
 public static void AddOfflineItems(this ContextMenuStrip menu, ComputerNode node)
 {
     if (node?.ComputerPanel.ConnectionState == ConnectionState.Offline)
     {
         var panel = node.ComputerPanel;
         menu?.Items.Add(new ToolStripSeparator());
         menu?.Items.Add(ContextMenuLabels.SetDescription, null, panel.ToolStripMenuItem_SetDescription);
     }
 }
Ejemplo n.º 8
0
 public static void AddOnlineItems(this ContextMenuStrip menu, ComputerNode node)
 {
     if (node?.ComputerPanel.ConnectionState == ConnectionState.Online)
     {
         var panel = node.ComputerPanel;
         menu?.Items.Add(new ToolStripSeparator());
         menu?.Items.Add(ContextMenuLabels.RemoteAssistance, null, panel.ToolStripMenuItem_StartRemoteAssistance);
         menu?.Items.Add(ContextMenuLabels.RemoteDesktop, null, panel.ToolStripMenuItem_StartRemoteDesktop);
     }
 }
Ejemplo n.º 9
0
 protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus)
 {
     if (powerStatus == PowerBroadcastStatus.Suspend || powerStatus == PowerBroadcastStatus.QuerySuspend)
     {
         if (node != null)
             node.Stop();
         node = null;
     }
     else if (powerStatus == PowerBroadcastStatus.ResumeSuspend ||
         powerStatus == PowerBroadcastStatus.ResumeCritical ||
         powerStatus == PowerBroadcastStatus.ResumeAutomatic ||
         powerStatus == PowerBroadcastStatus.QuerySuspendFailed)
     {
         if (node == null)
             node = new ComputerNode();
         node.Start();
     }
     return true;
 }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        public void Go()
        {
            List <string> processOutputs = new List <string>();
            string        processOutput  = string.Empty;
            ComputerNode  node           = null;

            foreach (IQuery query in this.queries)
            {
                processOutput = string.Empty;
                ProcessStartInfo psi = new ProcessStartInfo("cmd", query.QueryText)
                {
                    RedirectStandardOutput = true,
                    RedirectStandardError  = false,
                    WindowStyle            = ProcessWindowStyle.Normal,
                    UseShellExecute        = false,
                };

                Process p = new Process()
                {
                    StartInfo = psi
                };

                p.Start();

                using (System.IO.StreamReader sr = p.StandardOutput)
                    processOutput += sr.ReadToEnd();

                processOutputs.Add(processOutput);
            }


            node = CreateComputerNode(processOutput);

            if (OnQueryCompleted != null)
            {
                OnQueryCompleted.Invoke();
            }
        }
Ejemplo n.º 11
0
            private IDictionary<Move, IComputerNode> GetChildrenByMove()
            {
                if (this.finishedComputing)
                {
                    return this.cachedChildren;
                }

                IDictionary<LogarithmicGrid, IComputerNode> knownComputerNodesWithSameSum;
                if (!this.SearchTree.knownComputerNodesBySum.TryGetValue(this.Sum, out knownComputerNodesWithSameSum))
                {
                    knownComputerNodesWithSameSum = new Dictionary<LogarithmicGrid, IComputerNode>();
                    this.SearchTree.knownComputerNodesBySum.Add(this.Sum, knownComputerNodesWithSameSum);
                }

                foreach (var kvp in this.possibleStatesLazy.Value)
                {
                    IComputerNode computerNode;

                    if (!knownComputerNodesWithSameSum.TryGetValue(kvp.Value, out computerNode))
                    {
                        computerNode = new ComputerNode(kvp.Value, this.SearchTree, this.Sum);
                        knownComputerNodesWithSameSum.Add(kvp.Value, computerNode);
                    }

                    this.cachedChildren.Add(kvp.Key, computerNode);
                }

                this.finishedComputing = true;

                return this.cachedChildren;
            }
Ejemplo n.º 12
0
 protected override void OnStop()
 {
     if (node != null)
         node.Stop();
     node = null;
 }
Ejemplo n.º 13
0
 protected override void OnStart(string[] args)
 {
     if (node == null)
         node = new ComputerNode();
     node.Start();
 }
Ejemplo n.º 14
0
 protected override void OnContinue()
 {
     if (node == null)
         node = new ComputerNode();
     node.Start();
 }